diff options
| -rw-r--r-- | services/core/java/com/android/server/TelephonyRegistry.java | 38 | ||||
| -rw-r--r-- | telephony/java/android/telephony/PhysicalChannelConfig.java | 25 |
2 files changed, 57 insertions, 6 deletions
diff --git a/services/core/java/com/android/server/TelephonyRegistry.java b/services/core/java/com/android/server/TelephonyRegistry.java index 78ffcbdaff4d..a95589b5ace3 100644 --- a/services/core/java/com/android/server/TelephonyRegistry.java +++ b/services/core/java/com/android/server/TelephonyRegistry.java @@ -1170,7 +1170,9 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { TelephonyCallback.EVENT_PHYSICAL_CHANNEL_CONFIG_CHANGED)) { try { r.callback.onPhysicalChannelConfigChanged( - mPhysicalChannelConfigs); + shouldSanitizeLocationForPhysicalChannelConfig(r) + ? getLocationSanitizedConfigs(mPhysicalChannelConfigs) + : mPhysicalChannelConfigs); } catch (RemoteException ex) { remove(r.binder); } @@ -2371,8 +2373,10 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { return; } + List<PhysicalChannelConfig> sanitizedConfigs = getLocationSanitizedConfigs(configs); if (VDBG) { - log("notifyPhysicalChannelConfig: subId=" + subId + " configs=" + configs); + log("notifyPhysicalChannelConfig: subId=" + subId + " configs=" + configs + + " sanitizedConfigs=" + sanitizedConfigs); } synchronized (mRecords) { @@ -2385,11 +2389,14 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { && idMatch(r.subId, subId, phoneId)) { try { if (DBG_LOC) { - log("notifyPhysicalChannelConfig: " - + "mPhysicalChannelConfigs=" - + configs + " r=" + r); + log("notifyPhysicalChannelConfig: mPhysicalChannelConfigs=" + + (shouldSanitizeLocationForPhysicalChannelConfig(r) + ? sanitizedConfigs : configs) + + " r=" + r); } - r.callback.onPhysicalChannelConfigChanged(configs); + r.callback.onPhysicalChannelConfigChanged( + shouldSanitizeLocationForPhysicalChannelConfig(r) + ? sanitizedConfigs : configs); } catch (RemoteException ex) { mRemoveList.add(r.binder); } @@ -2400,6 +2407,25 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { } } + private static boolean shouldSanitizeLocationForPhysicalChannelConfig(Record record) { + // Always redact location info from PhysicalChannelConfig if the registrant is from neither + // PHONE nor SYSTEM process. There is no user case that the registrant needs the location + // info (e.g. physicalCellId). This also remove the need for the location permissions check. + return record.callerUid != Process.PHONE_UID && record.callerUid != Process.SYSTEM_UID; + } + + /** + * Return a copy of the PhysicalChannelConfig list but with location info removed. + */ + private static List<PhysicalChannelConfig> getLocationSanitizedConfigs( + List<PhysicalChannelConfig> configs) { + List<PhysicalChannelConfig> sanitizedConfigs = new ArrayList<>(configs.size()); + for (PhysicalChannelConfig config : configs) { + sanitizedConfigs.add(config.createLocationInfoSanitizedCopy()); + } + return sanitizedConfigs; + } + /** * Notify that the data enabled has changed. * diff --git a/telephony/java/android/telephony/PhysicalChannelConfig.java b/telephony/java/android/telephony/PhysicalChannelConfig.java index dfe269cbb0d9..1c9cd94b245d 100644 --- a/telephony/java/android/telephony/PhysicalChannelConfig.java +++ b/telephony/java/android/telephony/PhysicalChannelConfig.java @@ -292,6 +292,14 @@ public final class PhysicalChannelConfig implements Parcelable { } /** + * Return a copy of this PhysicalChannelConfig object but redact all the location info. + * @hide + */ + public PhysicalChannelConfig createLocationInfoSanitizedCopy() { + return new Builder(this).setPhysicalCellId(PHYSICAL_CELL_ID_UNKNOWN).build(); + } + + /** * @return String representation of the connection status * @hide */ @@ -540,6 +548,23 @@ public final class PhysicalChannelConfig implements Parcelable { mBand = BAND_UNKNOWN; } + /** + * Builder object constructed from existing PhysicalChannelConfig object. + * @hide + */ + public Builder(PhysicalChannelConfig config) { + mNetworkType = config.getNetworkType(); + mFrequencyRange = config.getFrequencyRange(); + mDownlinkChannelNumber = config.getDownlinkChannelNumber(); + mUplinkChannelNumber = config.getUplinkChannelNumber(); + mCellBandwidthDownlinkKhz = config.getCellBandwidthDownlinkKhz(); + mCellBandwidthUplinkKhz = config.getCellBandwidthUplinkKhz(); + mCellConnectionStatus = config.getConnectionStatus(); + mContextIds = Arrays.copyOf(config.getContextIds(), config.getContextIds().length); + mPhysicalCellId = config.getPhysicalCellId(); + mBand = config.getBand(); + } + public PhysicalChannelConfig build() { return new PhysicalChannelConfig(this); } |