Redact location info from PhysicalChannelConfig

If the registrant process is neither phone nor system,
the location info (e.g. physical cell id) will be redacted
before sending the PhysicalChannelConfig change to registrant.

Bug: 182605476
Test: atest com.android.internal.telephony.TelephonyRegistryTest
Change-Id: I05015d06f3f7301bdebfc22d1a9b32fd8bbbfe69
This commit is contained in:
Rambo Wang
2021-03-17 21:55:21 -07:00
parent 66fc99d578
commit 8a11bfc999
2 changed files with 57 additions and 6 deletions

View File

@@ -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.
*

View File

@@ -291,6 +291,14 @@ public final class PhysicalChannelConfig implements Parcelable {
return mCellConnectionStatus;
}
/**
* 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);
}