GpsStatus: Bounds check PRN to avoid array indexing exceptions.
Change-Id: Iea8b525dd8681f32cb7ce7415dad0ec665d9016d Signed-off-by: Mike Lockwood <lockwood@android.com>
This commit is contained in:
@@ -150,15 +150,17 @@ public final class GpsStatus {
|
||||
for (i = 0; i < svCount; i++) {
|
||||
int prn = prns[i] - 1;
|
||||
int prnShift = (1 << prn);
|
||||
GpsSatellite satellite = mSatellites[prn];
|
||||
|
||||
satellite.mValid = true;
|
||||
satellite.mSnr = snrs[i];
|
||||
satellite.mElevation = elevations[i];
|
||||
satellite.mAzimuth = azimuths[i];
|
||||
satellite.mHasEphemeris = ((ephemerisMask & prnShift) != 0);
|
||||
satellite.mHasAlmanac = ((almanacMask & prnShift) != 0);
|
||||
satellite.mUsedInFix = ((usedInFixMask & prnShift) != 0);
|
||||
if (prn >= 0 && prn < mSatellites.length) {
|
||||
GpsSatellite satellite = mSatellites[prn];
|
||||
|
||||
satellite.mValid = true;
|
||||
satellite.mSnr = snrs[i];
|
||||
satellite.mElevation = elevations[i];
|
||||
satellite.mAzimuth = azimuths[i];
|
||||
satellite.mHasEphemeris = ((ephemerisMask & prnShift) != 0);
|
||||
satellite.mHasAlmanac = ((almanacMask & prnShift) != 0);
|
||||
satellite.mUsedInFix = ((usedInFixMask & prnShift) != 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user