Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6d83bdfc authored by Rambo Wang's avatar Rambo Wang Committed by Automerger Merge Worker
Browse files

Merge "Redact location info from PhysicalChannelConfig" am: 92f92c7c am: 8dd68b73

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1644103

Change-Id: I7c92bd310f0eca7848daa0851be3a0511ef6d04f
parents 6cd0a977 8dd68b73
Loading
Loading
Loading
Loading
+32 −6
Original line number Diff line number Diff line
@@ -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.
     *
+25 −0
Original line number Diff line number Diff line
@@ -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);
        }