Java 类android.location.GpsSatellite 实例源码

项目:MVPAndroidBootstrap    文件:LocationHelper.java   
public void onGpsStatusChanged(int event) {

            if (event == GpsStatus.GPS_EVENT_SATELLITE_STATUS) {
                try {
                    // Check number of satellites in list to determine fix state
                    GpsStatus status = myLocationManager.getGpsStatus(null);
                    Iterable<GpsSatellite> satellites = status.getSatellites();

                    sat_count = 0;

                    Iterator<GpsSatellite> satI = satellites.iterator();
                    while (satI.hasNext()) {
                        GpsSatellite satellite = satI.next();
                        Log.d(LogUtils.generateTag(this), "Satellite: snr=" + satellite.getSnr() + ", elevation=" + satellite.getElevation());
                        sat_count++;
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    sat_count = min_gps_sat_count + 1;
                }

                Log.d(LogUtils.generateTag(this), "#### sat_count = " + sat_count);

            }
        }
项目:letv    文件:e.java   
private void b() {
    this.m = 0;
    this.l = 0;
    GpsStatus gpsStatus = b.getGpsStatus(null);
    if (gpsStatus != null) {
        int maxSatellites = gpsStatus.getMaxSatellites();
        Iterator it = gpsStatus.getSatellites().iterator();
        if (it != null) {
            while (it.hasNext() && this.l <= maxSatellites) {
                this.l++;
                if (((GpsSatellite) it.next()).usedInFix()) {
                    this.m++;
                }
            }
        }
    }
}
项目:Android_GPS_NMEA_Server_Reader_Sender    文件:MaoNmeaTools.java   
public static String convertNmeaGSA(List<GpsSatellite> satellites) {
    StringBuilder localStringBuilder = new StringBuilder();
    localStringBuilder.append("$GPGSA,,,");

    int satelliteChannelCount = 12;
    for (GpsSatellite s : satellites) {
        if ((s.getPrn() > 0) && s.usedInFix()) {
            localStringBuilder.append(String.format(Locale.getDefault(), "%02d,", s.getPrn()));
            satelliteChannelCount--;
        }
        if (satelliteChannelCount == 0) {
            break;
        }
    }
    while (satelliteChannelCount-- > 0) {
        localStringBuilder.append(",");
    }

    localStringBuilder.append(",,,4");
    localStringBuilder.append(calcNmeaCrc(localStringBuilder));
    return localStringBuilder.toString();
}
项目:AndroidPractice    文件:GpsActivity.java   
public void onGpsStatusChanged(int event) { // GPS状态变化时的回调,如卫星数
            GpsStatus status = locationManager.getGpsStatus(null); //取当前状态
            if(event == GpsStatus.GPS_EVENT_SATELLITE_STATUS){
                int maxSatellites = status.getMaxSatellites();
                Iterator<GpsSatellite> it = status.getSatellites().iterator();
                mSatelliteList.clear();
                int count = 0;
                while (it.hasNext() && count <= maxSatellites) {
                    GpsSatellite s = it.next();
//                Log.i("gjh","~~~~~~~~~~~~~~~~~~~~~~~~~~~" );
//                Log.i("gjh","信号:" + s.getSnr());
//                Log.i("gjh","序号:" + s.getPrn());
//                Log.i("gjh","卫星仰角:" + s.getElevation());
//                Log.i("gjh","卫星方位角 :" + s.getAzimuth());
//                Log.i("gjh","^^^^^^^^^^^^^^^^^^^^^^^^^^^^" );
                    mSatelliteList.add(s);
                    count++;
                }
            }
            mAdapter.notifyDataSetChanged();
            Log.i(TAG,mSatelliteList.size()+"" );
        }
项目:PokeFaker    文件:HookLocationFaker.java   
private static String satelliteToString(GpsSatellite s) {
    StringBuilder sb = new StringBuilder();
    if (s != null) {
        sb.append("GpsSatellite[" +
                "usedInFix = " + s.usedInFix() + ", " +
                "hasAlmanac = " + s.hasAlmanac() + ", " +
                "hasEphemeris = " + s.hasEphemeris() + ", " +
                "prn = " + s.getPrn() + ", " +
                "snr = " + s.getSnr() + ", " +
                "elevation = " + s.getElevation() + ", " +
                "azimuth = " + s.getAzimuth() + "]");
    } else {
        sb.append("GpsSatellite[null]");
    }
    return sb.toString();
}
项目:PokeFaker    文件:HookLocationFaker.java   
public static List<GpsSatellite> fetchGpsSatellites() {
    if (cacheGpsSatelliteList == null) {
        cacheGpsSatelliteList = new ArrayList<>();
        for (FakeGpsSatellite fake: staticList) {
            GpsSatellite real = ((GpsSatellite) XposedHelpers.newInstance(GpsSatellite.class, fake.mPrn));
            XposedHelpers.setBooleanField(real, "mValid", fake.mValid);
            XposedHelpers.setBooleanField(real, "mUsedInFix", fake.mUsedInFix);
            XposedHelpers.setBooleanField(real, "mHasAlmanac", fake.mHasAlmanac);
            XposedHelpers.setBooleanField(real, "mHasEphemeris", fake.mHasEphemeris);
            XposedHelpers.setFloatField(real, "mSnr", fake.mSnr);
            XposedHelpers.setFloatField(real, "mElevation", fake.mElevation);
            XposedHelpers.setFloatField(real, "mAzimuth", fake.mAzimuth);
            cacheGpsSatelliteList.add(real);
        }
    }
    return cacheGpsSatelliteList;

}
项目:iTester    文件:GPSActivity.java   
private String updateGpsStatus(int event, GpsStatus status) {  
    StringBuilder sb2 = new StringBuilder("");  
    if (status == null) {  
        uHandler.sendEmptyMessage(1);
        sb2.append(getResources().getString(R.string.label_gps_satellitenumber) +0);  
    } else if (event == GpsStatus.GPS_EVENT_SATELLITE_STATUS) {  
        int maxSatellites = status.getMaxSatellites();  
        Iterator<GpsSatellite> it = status.getSatellites().iterator();  
        numSatelliteList.clear();  
        int count = 0;  
        while (it.hasNext() && count <= maxSatellites) {  
            GpsSatellite s = it.next();  
            numSatelliteList.add(s);  
            count++;  
        }  
        sb2.append(getResources().getString(R.string.label_gps_satellitenumber) + numSatelliteList.size());  
        uHandler.sendEmptyMessage(1);
    }  

    return sb2.toString();  
}
项目:uds    文件:QtLocation.java   
public void onGpsStatusChanged(int event) {

        switch(event)
        {
            case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
                m_locationManager.getGpsStatus(m_status);
                Iterable<GpsSatellite> iSatellite=m_status.getSatellites();
                Iterator<GpsSatellite> iterator=iSatellite.iterator();
                ArrayList<QtSatInfo> satInfo=new ArrayList<QtSatInfo>();
                int index=0;
                while(iterator.hasNext())
                {
                    GpsSatellite gpsSat=iterator.next();

                    satInfo.add(new QtSatInfo(gpsSat.getPrn(),gpsSat.getSnr(),
                            gpsSat.getElevation(), gpsSat.getAzimuth()));
                    index++;
                }

                if(0!=index)
                    gpsSatelliteDataUpdated(satInfo.toArray());
                break;
        }

    }
项目:RxAndroidBootstrap    文件:LocationHelper.java   
public void onGpsStatusChanged(int event) {

            if (event == GpsStatus.GPS_EVENT_SATELLITE_STATUS) {
                try {
                    // Check number of satellites in list to determine fix state
                    GpsStatus status = myLocationManager.getGpsStatus(null);
                    Iterable<GpsSatellite> satellites = status.getSatellites();

                    sat_count = 0;

                    Iterator<GpsSatellite> satI = satellites.iterator();
                    while (satI.hasNext()) {
                        GpsSatellite satellite = satI.next();
                        Log.d(LogUtils.generateTag(this), "Satellite: snr=" + satellite.getSnr() + ", elevation=" + satellite.getElevation());
                        sat_count++;
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    sat_count = min_gps_sat_count + 1;
                }

                Log.d(LogUtils.generateTag(this), "#### sat_count = " + sat_count);

            }
        }
项目:tabulae    文件:LocusService.java   
@Override public void onGpsStatusChanged(int event) {
    gpsStatus = locationManager.getGpsStatus(gpsStatus);
    switch (event) {
        case GpsStatus.GPS_EVENT_STARTED:
        case GpsStatus.GPS_EVENT_FIRST_FIX:
        case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
        case GpsStatus.GPS_EVENT_STOPPED:
        default:
    }
    int count_seen = 0;
    int count_fix = 0;
    for (GpsSatellite s: gpsStatus.getSatellites()) {
        count_seen++;
        if (s.usedInFix())
            count_fix++;
        // Log.d(TAG, "getSnr=" + s.getSnr());
    }
    // Log.d(TAG, "LocusService.onGpsStatusChanged event=" + event
        // + ", satellites=" + count_fix + "/" + count_seen + "/" + gpsStatus.getMaxSatellites()
        // + ", timeToFirstFix=" + gpsStatus.getTimeToFirstFix()
        // );
}
项目:MiBandDecompiled    文件:e.java   
private void b()
{
    m = 0;
    l = 0;
    GpsStatus gpsstatus = b.getGpsStatus(null);
    if (gpsstatus != null)
    {
        int i1 = gpsstatus.getMaxSatellites();
        Iterator iterator = gpsstatus.getSatellites().iterator();
        if (iterator != null)
        {
            while (iterator.hasNext() && l <= i1) 
            {
                l = 1 + l;
                if (((GpsSatellite)iterator.next()).usedInFix())
                {
                    m = 1 + m;
                }
            }
        }
    }
}
项目:MAST-MOBILE    文件:CaptureDataMapActivity.java   
@Override
public void onLocationChanged(Location location) {
    if (MAP_MODE == FEATURE_DRAW_LINE_GPS_MODE || MAP_MODE == FEATURE_DRAW_POLYGON_GPS_MODE
            || MAP_MODE == FEATURE_DRAW_POINT_GPS_MODE) {
        int satellitesInFix = 0;
        for (GpsSatellite sat : locationManager.getGpsStatus(null).getSatellites()) {
            if (sat.usedInFix()) {
                satellitesInFix++;
            }
        }
        if (actionMode != null) {
            int accuracy = (int) locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER).getAccuracy();
            actionMode.setTitle(accuracy + getResources().getString(R.string.gps_accuracy));
            actionMode.setSubtitle(satellitesInFix + " " + getResources().getString(R.string.sats_use_msg));
        }
    }
}
项目:GPSLogger    文件:GPSApplication.java   
public void updateSats() {
    if ((mlocManager != null) && (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED))
    {
        final GpsStatus gs = mlocManager.getGpsStatus(null);
        int sats_inview = 0;    // Satellites in view;
        int sats_used = 0;      // Satellites used in fix;

        if (gs != null) {
            Iterable<GpsSatellite> sats = gs.getSatellites();
            for (GpsSatellite sat : sats) {
                sats_inview++;
                if (sat.usedInFix()) sats_used++;
                //Log.w("myApp", "[#] GPSApplication.java - updateSats: i=" + i);
            }
            _NumberOfSatellites = sats_inview;
            _NumberOfSatellitesUsedInFix = sats_used;
        } else {
            _NumberOfSatellites = NOT_AVAILABLE;
            _NumberOfSatellitesUsedInFix = NOT_AVAILABLE;
        }
    } else {
        _NumberOfSatellites = NOT_AVAILABLE;
        _NumberOfSatellitesUsedInFix = NOT_AVAILABLE;
    }
    //Log.w("myApp", "[#] GPSApplication.java - updateSats: Total=" + _NumberOfSatellites + " Used=" + _NumberOfSatellitesUsedInFix);
}
项目:android_maplibui    文件:TrackerService.java   
@Override
public void onGpsStatusChanged(int event)
{
    switch (event) {
        case GpsStatus.GPS_EVENT_STARTED:
        case GpsStatus.GPS_EVENT_STOPPED:
            mHasGPSFix = false;
            break;
        case GpsStatus.GPS_EVENT_FIRST_FIX:
            mHasGPSFix = true;
            break;

        case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
            mSatellitesCount = 0;

            for (GpsSatellite sat : mLocationManager.getGpsStatus(null).getSatellites()) {
                if (sat.usedInFix()) {
                    mSatellitesCount++;
                }
            }
            break;
    }
}
项目:Flight-Computer-Android-Flightradar24    文件:GpsSkyActivity.java   
private void updateStatus(GpsStatus status) {
    setStarted(true);           
    Iterator<GpsSatellite> satellites = status.getSatellites().iterator();
    if (mPrns == null) {
        int length = status.getMaxSatellites();
        mPrns = new int[length];
        mSnrs = new float[length];
        mSvElevations = new float[length];
        mSvAzimuths = new float[length];
    }
    mSvCount = 0;          
    while (satellites.hasNext()) {
        GpsSatellite satellite = satellites.next();
        int prn = satellite.getPrn();
        mPrns[mSvCount] = prn;
        mSnrs[mSvCount] = satellite.getSnr();
        mSvElevations[mSvCount] = satellite.getElevation();
        mSvAzimuths[mSvCount] = satellite.getAzimuth();             
        mSvCount++;
    }
    mAdapter.notifyDataSetChanged();
}
项目:Flight-Computer-Android-Flightradar24    文件:GpsSkyView.java   
public void setSats(GpsStatus status) {
    Iterator<GpsSatellite> satellites = status.getSatellites().iterator();

    if (mSnrs == null) {
        int length = status.getMaxSatellites();
        mSnrs = new float[length];
        mElevs = new float[length];
        mAzims = new float[length];
    }

    mSvCount = 0;
    while (satellites.hasNext()) {
        GpsSatellite satellite = satellites.next();
        mSnrs[mSvCount] = satellite.getSnr();
        mElevs[mSvCount] = satellite.getElevation();
        mAzims[mSvCount] = satellite.getAzimuth();
        mSvCount++;
    }

    mStarted = true;
    invalidate();
}
项目:nethunter-app    文件:NMEA.java   
public static String formatGpsGsa(GpsStatus gps) {
    String fix = "1";
    String prn = "";
    int nbr_sat = 0;
    Iterator<GpsSatellite> satellites = gps.getSatellites().iterator();
    for (int i = 0; i < 12; i++) {
        if (satellites.hasNext()) {
            GpsSatellite sat = satellites.next();
            if (sat.usedInFix()) {
                prn = prn + sat.getPrn();
                nbr_sat++;
            }
        }

        prn = prn + ",";
    }

    if (nbr_sat > 3)
        fix = "3";
    else if (nbr_sat > 0)
        fix = "2";

    //TODO: calculate DOP values
    return fix + "," + prn + ",,,";
}
项目:ironman    文件:GPSTracker.java   
@Override
public void onGpsStatusChanged(int event) {
    switch (event) {
    case android.location.GpsStatus.GPS_EVENT_STARTED:
        break;

    case android.location.GpsStatus.GPS_EVENT_SATELLITE_STATUS:
        satellites.clear();
        gpsStatus = locationManager.getGpsStatus(gpsStatus);
        for (GpsSatellite sat : gpsStatus.getSatellites()) {
            if (sat.usedInFix()) {
                satellites.add(sat);
            }
        }
        break;

    case android.location.GpsStatus.GPS_EVENT_FIRST_FIX:
        break;

    case android.location.GpsStatus.GPS_EVENT_STOPPED:
        break;
    }
}
项目:geodroid_master_update    文件:GpsStatusInfo.java   
private void analyze() {
    if (satellites != null) {
        return;
    }
    satellites = status.getSatellites().iterator();
    maxSatellites = status.getMaxSatellites();

    satCount = 0;
    satUsedInFixCount = 0;
    while( satellites.hasNext() ) {
        GpsSatellite satellite = satellites.next();
        satCount++;
        if (satellite.usedInFix()) {
            satUsedInFixCount++;
        }
    }
}
项目:satstat    文件:PasvLocListenerService.java   
@Override
public void onGpsStatusChanged(int event) {
    GpsStatus status = mLocationManager.getGpsStatus(null);
    int satsUsed = 0;
    Iterable<GpsSatellite> sats = status.getSatellites();
    for (GpsSatellite sat : sats) {
        if (sat.usedInFix()) {
            satsUsed++;
        }
    }
    if (satsUsed == 0) {
        if (mStatus != GPS_INACTIVE)
            mStatus = GPS_SEARCH;
        showStatusNoLocation();
    }
}
项目:satstat    文件:MainActivity.java   
/**
   * Called when the status of the GPS changes. Updates GPS display.
   */
  public void onGpsStatusChanged (int event) {
GpsStatus status = locationManager.getGpsStatus(null);
int satsInView = 0;
int satsUsed = 0;
Iterable<GpsSatellite> sats = status.getSatellites();
for (GpsSatellite sat : sats) {
    satsInView++;
    if (sat.usedInFix()) {
        satsUsed++;
    }
}

if (gpsSectionFragment != null) {
        gpsSectionFragment.onGpsStatusChanged(status, satsInView, satsUsed, sats);
    }

if (mapSectionFragment != null) {
    mapSectionFragment.onGpsStatusChanged(status, satsInView, satsUsed, sats);
}
  }
项目:osmLib    文件:OsmAndLocationProvider.java   
private void updateGPSInfo(GpsStatus s) {
    boolean fixed = false;
    int n = 0;
    int u = 0;
    if (s != null) {
        Iterator<GpsSatellite> iterator = s.getSatellites().iterator();
        while (iterator.hasNext()) {
            GpsSatellite g = iterator.next();
            n++;
            if (g.usedInFix()) {
                u++;
                fixed = true;
            }
        }
    }
    gpsInfo.fixed = fixed;
    gpsInfo.foundSatellites = n;
    gpsInfo.usedSatellites = u;
    Log.d(TAG, "updateGPSInfo : " + gpsInfo);
}
项目:siarhei.luskanau.gps.tracker.free    文件:LocationService.java   
private void updateSatellites(Location location) {
    if (location.getExtras() != null && location.getExtras().containsKey(AppConstants.SATELLITES)) {
        return;
    }
    try {
        GpsStatus localGpsStatus = locationManager.getGpsStatus(null);
        int satellites = 0;
        Iterator<GpsSatellite> iterator = localGpsStatus.getSatellites().iterator();
        for (; iterator.hasNext(); ) {
            if (iterator.next().usedInFix()) {
                satellites++;
            }
        }
        if (satellites > 0) {
            location.getExtras().putInt(AppConstants.SATELLITES, satellites);
        }
    } catch (Exception e) {
        Log.w(getPackageName(), e);
    }
}
项目:localcloud_fe    文件:JSONHelper.java   
/**
 * Converts GpsStatus into JSON.
 * @param gpsStatus Send a GpsStatus whenever the GPS fires
 * @return JSON representation of the satellite data
 */
public static String satelliteDataJSON(GpsStatus gpsStatus){

    final Calendar calendar = Calendar.getInstance();
    final JSONObject json = new JSONObject();

    try {
        json.put("provider", SATELLITE_PROVIDER);
        json.put("timestamp", calendar.getTimeInMillis());

        if(gpsStatus.getSatellites() != null) {
            int count = 0;
            final int timeToFirstFix = gpsStatus.getTimeToFirstFix();

            for(GpsSatellite sat: gpsStatus.getSatellites() ){
                final JSONObject satelliteInfo = new JSONObject();

                satelliteInfo.put("PRN", sat.getPrn());
                satelliteInfo.put("timeToFirstFix", timeToFirstFix);
                satelliteInfo.put("usedInFix", sat.usedInFix());
                satelliteInfo.put("azimuth", sat.getAzimuth());
                satelliteInfo.put("elevation", sat.getElevation());
                satelliteInfo.put("hasEphemeris", sat.hasEphemeris());
                satelliteInfo.put("hasAlmanac", sat.hasAlmanac());
                satelliteInfo.put("SNR", sat.getSnr());

                json.put(Integer.toString(count), satelliteInfo);

                count++;
            }
        }
    }
    catch (JSONException exc){
        logJSONException(exc);
    }

    return json.toString();
}
项目:localcloud_fe    文件:JSONHelper.java   
/**
 * Converts GpsStatus into JSON.
 * @param gpsStatus Send a GpsStatus whenever the GPS fires
 * @return JSON representation of the satellite data
 */
public static String satelliteDataJSON(GpsStatus gpsStatus){

    final Calendar calendar = Calendar.getInstance();
    final JSONObject json = new JSONObject();

    try {
        json.put("provider", SATELLITE_PROVIDER);
        json.put("timestamp", calendar.getTimeInMillis());

        if(gpsStatus.getSatellites() != null) {
            int count = 0;
            final int timeToFirstFix = gpsStatus.getTimeToFirstFix();

            for(GpsSatellite sat: gpsStatus.getSatellites() ){
                final JSONObject satelliteInfo = new JSONObject();

                satelliteInfo.put("PRN", sat.getPrn());
                satelliteInfo.put("timeToFirstFix", timeToFirstFix);
                satelliteInfo.put("usedInFix", sat.usedInFix());
                satelliteInfo.put("azimuth", sat.getAzimuth());
                satelliteInfo.put("elevation", sat.getElevation());
                satelliteInfo.put("hasEphemeris", sat.hasEphemeris());
                satelliteInfo.put("hasAlmanac", sat.hasAlmanac());
                satelliteInfo.put("SNR", sat.getSnr());

                json.put(Integer.toString(count), satelliteInfo);

                count++;
            }
        }
    }
    catch (JSONException exc){
        logJSONException(exc);
    }

    return json.toString();
}
项目:localcloud_fe    文件:JSONHelper.java   
/**
 * Converts GpsStatus into JSON.
 * @param gpsStatus Send a GpsStatus whenever the GPS fires
 * @return JSON representation of the satellite data
 */
public static String satelliteDataJSON(GpsStatus gpsStatus){

    final Calendar calendar = Calendar.getInstance();
    final JSONObject json = new JSONObject();

    try {
        json.put("provider", SATELLITE_PROVIDER);
        json.put("timestamp", calendar.getTimeInMillis());

        if(gpsStatus.getSatellites() != null) {
            int count = 0;
            final int timeToFirstFix = gpsStatus.getTimeToFirstFix();

            for(GpsSatellite sat: gpsStatus.getSatellites() ){
                final JSONObject satelliteInfo = new JSONObject();

                satelliteInfo.put("PRN", sat.getPrn());
                satelliteInfo.put("timeToFirstFix", timeToFirstFix);
                satelliteInfo.put("usedInFix", sat.usedInFix());
                satelliteInfo.put("azimuth", sat.getAzimuth());
                satelliteInfo.put("elevation", sat.getElevation());
                satelliteInfo.put("hasEphemeris", sat.hasEphemeris());
                satelliteInfo.put("hasAlmanac", sat.hasAlmanac());
                satelliteInfo.put("SNR", sat.getSnr());

                json.put(Integer.toString(count), satelliteInfo);

                count++;
            }
        }
    }
    catch (JSONException exc){
        logJSONException(exc);
    }

    return json.toString();
}
项目:AndroidToolbox    文件:GNSSLocationService.java   
private int getNumSatsInFix(LocationManager locationManager) {
    if (ContextCompat.checkSelfPermission(this,Manifest.permission.ACCESS_FINE_LOCATION)!= PackageManager.PERMISSION_GRANTED) {
        CustomLog.e(TAG,"Logic error. no permissions to get number of satellites in fix. Cannot continue");
        return Constants.INVALID_NUMBER_OF_SATS;
    }
    int numSats=0;
    int numSatsInFix=0;
    for (GpsSatellite sat : locationManager.getGpsStatus(null).getSatellites()) {
        if(sat.usedInFix()) {
            numSatsInFix++;
        }
        numSats++;
    }
    return numSatsInFix;
}
项目:AndroidToolbox    文件:GNSSLocationService.java   
private int getNumSats(LocationManager locationManager) {
    if (ContextCompat.checkSelfPermission(this,Manifest.permission.ACCESS_FINE_LOCATION)!= PackageManager.PERMISSION_GRANTED) {
        CustomLog.e(TAG,"Logic error. no permissions to get number of satellites. Cannot continue");
        return Constants.INVALID_NUMBER_OF_SATS;
    }
    int numSats=0;
    for (GpsSatellite sat : locationManager.getGpsStatus(null).getSatellites()) {
        numSats++;
    }
    return numSats;
}
项目:Android_GPS_NMEA_Server_Reader_Sender    文件:MaoNmeaTools.java   
public static int calSatelliteUseInFix(List<GpsSatellite> satellites) {
    int count = 0;
    for (GpsSatellite s : satellites) {
        if ((s.getPrn() > 0) && s.usedInFix())
            count++;
    }
    return count;
}
项目:Android_GPS_NMEA_Server_Reader_Sender    文件:MainActivity.java   
private void generateNmeaWithBeidou() {

        if (PackageManager.PERMISSION_GRANTED != checkCallingOrSelfPermission(PERMISSION_ACCESS_FINE_LOCATION)) {
            programLog(GenerateNmeaWithBeidou + No_Permission_ACCESS_FINE_LOCATION);
            return;
        }


        Iterator satelliteIterator = this.mLocationManager.getGpsStatus(null).getSatellites().iterator();
        List<GpsSatellite> satellites = new ArrayList<>();
        while (satelliteIterator.hasNext())
            satellites.add((GpsSatellite) satelliteIterator.next());

        String temp;
        temp = convertNmeaGSA(satellites);
        commitNmeaMessage(temp);

        String[] tempList = convertNmeaGSV(satellites);
        for (String gsv : tempList)
            commitNmeaMessage(gsv);


        Location location = this.mLocationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
        if (location != null) {
            temp = convertNmeaGGA(location, calSatelliteUseInFix(satellites));
            commitNmeaMessage(temp);
            temp = convertNmeaGLL(location);
            commitNmeaMessage(temp);
            temp = convertNmeaRMC(location);
            commitNmeaMessage(temp);
            temp = convertNmeaVTG(location);
            commitNmeaMessage(temp);
        }
    }
项目:cordova-plugin-advanced-geolocation    文件:JSONHelper.java   
/**
 * Converts GpsStatus into JSON.
 * @param gpsStatus Send a GpsStatus whenever the GPS fires
 * @return JSON representation of the satellite data
 */
public static String satelliteDataJSON(GpsStatus gpsStatus){

    final Calendar calendar = Calendar.getInstance();
    final JSONObject json = new JSONObject();

    try {
        json.put("provider", SATELLITE_PROVIDER);
        json.put("timestamp", calendar.getTimeInMillis());

        if(gpsStatus.getSatellites() != null) {
            int count = 0;
            final int timeToFirstFix = gpsStatus.getTimeToFirstFix();

            for(GpsSatellite sat: gpsStatus.getSatellites() ){
                final JSONObject satelliteInfo = new JSONObject();

                satelliteInfo.put("PRN", sat.getPrn());
                satelliteInfo.put("timeToFirstFix", timeToFirstFix);
                satelliteInfo.put("usedInFix", sat.usedInFix());
                satelliteInfo.put("azimuth", sat.getAzimuth());
                satelliteInfo.put("elevation", sat.getElevation());
                satelliteInfo.put("hasEphemeris", sat.hasEphemeris());
                satelliteInfo.put("hasAlmanac", sat.hasAlmanac());
                satelliteInfo.put("SNR", sat.getSnr());

                json.put(Integer.toString(count), satelliteInfo);

                count++;
            }
        }
    }
    catch (JSONException exc){
        logJSONException(exc);
    }

    return json.toString();
}
项目:truth-android    文件:GpsSatelliteSubject.java   
public static SubjectFactory<GpsSatelliteSubject, GpsSatellite> type() {
  return new SubjectFactory<GpsSatelliteSubject, GpsSatellite>() {
    @Override
    public GpsSatelliteSubject getSubject(FailureStrategy fs, GpsSatellite that) {
      return new GpsSatelliteSubject(fs, that);
    }
  };
}
项目:RxTools    文件:ActivityLocation.java   
private void getLocation() {
    if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
        ActivityCompat.requestPermissions(mContext, new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION}, 1);
        return;
    }
    locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 2000, 0, this);
    locationManager.addGpsStatusListener(new GpsStatus.Listener() {
        @Override
        public void onGpsStatusChanged(int event) {
            switch (event) {
                case GpsStatus.GPS_EVENT_STARTED:
                    System.out.println("GPS_EVENT_STARTED");
                    mGpsCount.setText("0");
                    break;
                case GpsStatus.GPS_EVENT_FIRST_FIX:
                    System.out.println("GPS_EVENT_FIRST_FIX");
                    break;
                case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
                    System.out.println("GPS_EVENT_SATELLITE_STATUS");
                    if (ActivityCompat.checkSelfPermission(mContext, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
                        return;
                    }
                    GpsStatus gpsStatus = locationManager.getGpsStatus(null);
                    Iterable<GpsSatellite> gpsSatellites = gpsStatus.getSatellites();
                    int count = 0;
                    Iterator iterator = gpsSatellites.iterator();
                    while (iterator.hasNext()) {
                        count++;
                        iterator.next();
                    }
                    mGpsCount.setText(count + "");
                    break;
                case GpsStatus.GPS_EVENT_STOPPED:
                    System.out.println("GPS_EVENT_STOPPED");
                    //gpsState.setText("已停止定位");
                    break;
            }
        }
    });
}
项目:CameraDVR    文件:LocationMonitor.java   
@Override
public void onGpsStatusChanged(int arg0) {
    switch (arg0) {
    case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
        GpsStatus gpsStatus = mLocationManager.getGpsStatus(null);
        int usedinfix = 0;

        if (gpsStatus != null) {
            Iterator<GpsSatellite> satellites = gpsStatus
                    .getSatellites().iterator();

            if (satellites != null) {
                while (satellites.hasNext()) {
                    GpsSatellite satellite = satellites.next();

                    if (satellite.usedInFix()) {
                        usedinfix++;
                    }
                }
            }
        }
        mUsedInFix = usedinfix;
        if (mUsedInFix < 3) {
            updateGpsSpeed(-1);
        }
        break;

    case GpsStatus.GPS_EVENT_STARTED:
        break;
    case GpsStatus.GPS_EVENT_STOPPED:
        break;
    }
}
项目:PokeFaker    文件:HookLocationFaker.java   
private void hook_gpsStatusUpdate(XC_LoadPackage.LoadPackageParam lpparam) {
        if (!lpparam.packageName.equals("com.nianticlabs.pokemongo")) return;

        XposedHelpers.findAndHookMethod(
                    "com.nianticlabs.nia.location.NianticLocationManager",
                    lpparam.classLoader,
                    "gpsStatusUpdate",
                    int.class,
                    GpsSatellite[].class,
                    new XC_MethodReplacement() {
                        @Override
                        protected Object replaceHookedMethod(MethodHookParam param) throws Throwable {
//                            int timeToFix = ((int) param.args[0]);
//                            GpsSatellite[] satellites = ((GpsSatellite[]) param.args[1]);
//                            for (GpsSatellite s: satellites) {
//                                XposedBridge.log(satelliteToString(s));
//                            }
                            Location locationGps = mLocationHolder.pollLocation("gps");
                            Location locationNetwork = mLocationHolder.pollLocation("network");
                            call_updateLocation(locationGps);
                            call_updateLocation(locationNetwork);

//                            List<GpsSatellite> fakeSatelliteList = FakeGpsSatellite.fetchGpsSatellites();
//                            GpsSatellite[] fakeSatellites = new GpsSatellite[fakeSatelliteList.size()];
//                            for (int i = 0; i < fakeSatelliteList.size(); i++) {
//                                fakeSatellites[i] = fakeSatelliteList.get(i);
//                            }
//                            param.args[1] = fakeSatellites;
                            return null;
                        }
                    }
        );
    }
项目:openbmap    文件:GpsProvider.java   
@Override
public void onGpsStatusChanged(final int event) {
    int satCount = -1;

    switch (event) {
        case GpsStatus.GPS_EVENT_FIRST_FIX:
            satCount = 0;
            break;
        case GpsStatus.GPS_EVENT_STARTED:
            satCount = -1;
            break;
        case GpsStatus.GPS_EVENT_STOPPED:
            satCount = -1;
            break;
        case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
            // first of all we check if the time from the last used fix to the current fix is greater than the logging interval
            if ((event != GpsStatus.GPS_EVENT_SATELLITE_STATUS)
                    || (mLastGPSTimestamp + gpsLoggingInterval) < System.currentTimeMillis()) {
                mLastGPSTimestamp = System.currentTimeMillis(); // save the time of this fix

                final GpsStatus status = lmgr.getGpsStatus(null);

                // Count active satellites
                satCount = 0;
                for (@SuppressWarnings("unused") final GpsSatellite sat:status.getSatellites()) {
                    satCount++;
                }
            }
            break;
        default:
            break;
    }

    if (mListener != null) {
        mListener.onSatInfo(satCount);
    }

}
项目:OtterBenchmark    文件:GpsMonitor.java   
private void showGpsStatusInfo(GpsStatus gpsStatus) {
    max_satellites.setText(String.valueOf(gpsStatus.getMaxSatellites()));
    int satelliteCount = 0;
    for (GpsSatellite gpsSatellite : gpsStatus.getSatellites()) {
        // TODO: Show each GpsSatellite detail.
        satelliteCount++;
    }
    satellites.setText(String.valueOf(satelliteCount));
    first_fix_time.setText(String.valueOf(gpsStatus.getTimeToFirstFix()));
}
项目:BackPackTrackII    文件:GpsStatusService.java   
@Override
public void onGpsStatusChanged(int event) {
    if (event == GpsStatus.GPS_EVENT_SATELLITE_STATUS) {
        // Count fixed/visible satellites
        int fixed = 0;
        int visible = 0;
        LocationManager lm = (LocationManager) getSystemService(LOCATION_SERVICE);
        for (GpsSatellite sat : lm.getGpsStatus(null).getSatellites()) {
            visible++;
            if (sat.usedInFix())
                fixed++;
        }

        // Persist fixed/visible satellites
        Log.i(TAG, "Satellites fixed/visible=" + fixed + "/" + visible);
        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(GpsStatusService.this);
        SharedPreferences.Editor editor = prefs.edit();
        editor.putInt(SettingsFragment.PREF_SATS_FIXED, fixed);
        editor.putInt(SettingsFragment.PREF_SATS_VISIBLE, visible);
        editor.apply();

        // Send state changed intent
        Intent intent = new Intent(GpsStatusService.this, BackgroundService.class);
        intent.setAction(BackgroundService.ACTION_STATE_CHANGED);
        startService(intent);
    }
}
项目:tabulae    文件:LocusService.java   
private Bundle toBundle(Bundle ret, GpsStatus gpsStatus) {
    int count_seen = 0;
    int count_fix = 0;
    for (GpsSatellite s: gpsStatus.getSatellites()) {
        count_seen++;
        if (s.usedInFix()) {
            count_fix++;
        }
    }
    ret.putInt("satellites", count_fix);
    ret.putInt("satellites_seen", count_seen);
    return ret;
}
项目:MAST-MOBILE    文件:CaptureDataMapActivity.java   
public void onGpsStatusChanged(int event) {
    //GpsStatus gpsStatus = locationManager.getGpsStatus(null);
    switch (event) {
        case GpsStatus.GPS_EVENT_STARTED:
            //displayGPSNotification();
            break;
        case GpsStatus.GPS_EVENT_FIRST_FIX:
            try {
                showToast(getResources().getString(R.string.gps_fix_success_msg), Toast.LENGTH_LONG, Gravity.CENTER);
                int satellitesInFix = 0;
                for (GpsSatellite sat : locationManager.getGpsStatus(null).getSatellites()) {
                    if (sat.usedInFix()) {
                        satellitesInFix++;
                    }
                }
                if (actionMode != null) {
                    int accuracy = (int) locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER).getAccuracy();
                    actionMode.setTitle(accuracy + getResources().getString(R.string.gps_accuracy));
                    actionMode.setSubtitle(satellitesInFix + " " + getResources().getString(R.string.sats_use_msg));
                }
            } catch (Exception e) {
                e.printStackTrace();
                cf.appLog("", e);
            }
            break;
        case GpsStatus.GPS_EVENT_STOPPED:
            //showToast("GPS_EVENT_STOPPED", Toast.LENGTH_SHORT, 0);
            break;
    }
}