Пример #1
0
  @SmallTest
  public void testTrackPointXml_BundledGeoIdHeight() {

    Gpx10WriteHandler writeHandler = new Gpx10WriteHandler(null, null, null, true, 0, null);

    Location loc = new Location("MOCK");
    loc.setLatitude(12.193);
    loc.setLongitude(19.111);
    loc.setAltitude(9001);
    loc.setBearing(91.88f);
    loc.setSpeed(188.44f);
    Bundle b = new Bundle();
    b.putString("GEOIDHEIGHT", "MYGEOIDHEIGHT");
    loc.setExtras(b);

    String actual = writeHandler.GetTrackPointXml(loc, "2011-09-17T18:45:33Z");
    String expected =
        "<trkseg><trkpt lat=\"12.193\" lon=\"19.111\"><ele>9001.0</ele><time>2011-09-17T18:45:33Z</time>"
            + "<course>91.88</course><speed>188.44</speed><src>MOCK</src><geoidheight>MYGEOIDHEIGHT</geoidheight></trkpt>\n</trkseg></trk></gpx>";

    assertEquals("Trackpoint XML with a geoid height", expected, actual);
  }
  public GpsLocationProvider(Context context, ILocationManager locationManager) {
    mContext = context;
    mLocationManager = locationManager;
    mNIHandler = new GpsNetInitiatedHandler(context, this);

    mLocation.setExtras(mLocationExtras);

    // Create a wake lock
    PowerManager powerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
    mWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, WAKELOCK_KEY);

    mAlarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);
    mWakeupIntent = PendingIntent.getBroadcast(mContext, 0, new Intent(ALARM_WAKEUP), 0);
    mTimeoutIntent = PendingIntent.getBroadcast(mContext, 0, new Intent(ALARM_TIMEOUT), 0);

    mConnMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);

    // Battery statistics service to be notified when GPS turns on or off
    mBatteryStats = IBatteryStats.Stub.asInterface(ServiceManager.getService("batteryinfo"));

    mProperties = new Properties();
    try {
      File file = new File(PROPERTIES_FILE);
      FileInputStream stream = new FileInputStream(file);
      mProperties.load(stream);
      stream.close();
      mNtpServer = mProperties.getProperty("NTP_SERVER", null);

      mSuplServerHost = mProperties.getProperty("SUPL_HOST");
      String portString = mProperties.getProperty("SUPL_PORT");
      if (mSuplServerHost != null && portString != null) {
        try {
          mSuplServerPort = Integer.parseInt(portString);
        } catch (NumberFormatException e) {
          Log.e(TAG, "unable to parse SUPL_PORT: " + portString);
        }
      }

      mC2KServerHost = mProperties.getProperty("C2K_HOST");
      portString = mProperties.getProperty("C2K_PORT");
      if (mC2KServerHost != null && portString != null) {
        try {
          mC2KServerPort = Integer.parseInt(portString);
        } catch (NumberFormatException e) {
          Log.e(TAG, "unable to parse C2K_PORT: " + portString);
        }
      }
    } catch (IOException e) {
      Log.w(TAG, "Could not open GPS configuration file " + PROPERTIES_FILE);
    }

    // wait until we are fully initialized before returning
    mThread = new GpsLocationProviderThread();
    mThread.start();
    while (true) {
      try {
        mInitializedLatch.await();
        break;
      } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
      }
    }
  }