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

Commit 42d9a422 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 5426495 from f8f3e2b1 to qt-release

Change-Id: Ic1ce40de81851c3644e20f80cb065ab6f09b0610
parents 463acafc f8f3e2b1
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -2167,8 +2167,11 @@ message TelephonyCallSession {
    // Call quality when changed
    optional CallQuality call_quality = 23;

    // Call quality summary at the end of a call
    optional CallQualitySummary call_quality_summary = 24;
    // Downlink call quality summary at the end of a call
    optional CallQualitySummary call_quality_summary_dl = 24;

    // Uplink call quality summary at the end of a call
    optional CallQualitySummary call_quality_summary_ul = 25;

  }

+43 −13
Original line number Diff line number Diff line
@@ -16,10 +16,12 @@

package com.android.internal.telephony;

import static android.os.Binder.withCleanCallingIdentity;
import static android.telephony.AccessNetworkConstants.AccessNetworkType.EUTRAN;
import static android.telephony.AccessNetworkConstants.AccessNetworkType.GERAN;
import static android.telephony.AccessNetworkConstants.AccessNetworkType.UTRAN;

import android.content.Context;
import android.hardware.radio.V1_0.RadioError;
import android.os.AsyncResult;
import android.os.Binder;
@@ -39,8 +41,10 @@ import android.telephony.RadioAccessSpecifier;
import android.telephony.TelephonyScanManager;
import android.util.Log;

import java.util.Collection;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;

/**
 * Manages radio access network scan requests.
@@ -160,6 +164,25 @@ public final class NetworkScanRequestTracker {
        return true;
    }

    private static boolean doesCellInfoCorrespondToKnownMccMnc(CellInfo ci,
            Collection<String> knownMccMncs) {
        String mccMnc = ci.getCellIdentity().getMccString()
                + ci.getCellIdentity().getMncString();
        return knownMccMncs.contains(mccMnc);
    }

    /**
     * @return S list of MCC/MNC ids that apps should be allowed to see as results from a network
     * scan when scan results are restricted due to location privacy.
     */
    public static List<String> getAllowedMccMncsForLocationRestrictedScan(Context context) {
        return withCleanCallingIdentity(() -> SubscriptionController.getInstance()
                .getAllSubInfoList(context.getOpPackageName()).stream()
                .filter(subInfo -> subInfo.getMccString() != null)
                .map(subInfo -> subInfo.getMccString() + subInfo.getMncString())
                .collect(Collectors.toList()));
    }

    /** Sends a message back to the application via its callback. */
    private void notifyMessenger(NetworkScanRequestInfo nsri, int what, int err,
            List<CellInfo> result) {
@@ -168,7 +191,17 @@ public final class NetworkScanRequestTracker {
        message.what = what;
        message.arg1 = err;
        message.arg2 = nsri.mScanId;

        if (result != null) {
            if (what == TelephonyScanManager.CALLBACK_RESTRICTED_SCAN_RESULTS) {
                List<String> allowedMccMncs =
                        getAllowedMccMncsForLocationRestrictedScan(nsri.mPhone.getContext());

                result = result.stream().map(CellInfo::sanitizeLocationInfo)
                        .filter(ci -> doesCellInfoCorrespondToKnownMccMnc(ci, allowedMccMncs))
                        .collect(Collectors.toList());
            }

            CellInfo[] ci = result.toArray(new CellInfo[result.size()]);
            Bundle b = new Bundle();
            b.putParcelableArray(TelephonyScanManager.SCAN_RESULT_KEY, ci);
@@ -387,25 +420,23 @@ public final class NetworkScanRequestTracker {
                    .build();
            if (ar.exception == null && ar.result != null) {
                NetworkScanResult nsr = (NetworkScanResult) ar.result;
                if (nsr.scanError == NetworkScan.SUCCESS) {
                    if (LocationAccessPolicy.checkLocationPermission(
                boolean isLocationAccessAllowed = LocationAccessPolicy.checkLocationPermission(
                        nsri.mPhone.getContext(), locationQuery)
                            == LocationAccessPolicy.LocationPermissionResult.ALLOWED) {
                        notifyMessenger(nsri, TelephonyScanManager.CALLBACK_SCAN_RESULTS,
                        == LocationAccessPolicy.LocationPermissionResult.ALLOWED;
                int notifyMsg = isLocationAccessAllowed
                        ? TelephonyScanManager.CALLBACK_SCAN_RESULTS
                        : TelephonyScanManager.CALLBACK_RESTRICTED_SCAN_RESULTS;
                if (nsr.scanError == NetworkScan.SUCCESS) {
                    notifyMessenger(nsri, notifyMsg,
                            rilErrorToScanError(nsr.scanError), nsr.networkInfos);
                    }
                    if (nsr.scanStatus == NetworkScanResult.SCAN_STATUS_COMPLETE) {
                        deleteScanAndMayNotify(nsri, NetworkScan.SUCCESS, true);
                        nsri.mPhone.mCi.unregisterForNetworkScanResult(mHandler);
                    }
                } else {
                    if (nsr.networkInfos != null) {
                        if (LocationAccessPolicy.checkLocationPermission(
                                nsri.mPhone.getContext(), locationQuery)
                                == LocationAccessPolicy.LocationPermissionResult.ALLOWED) {
                            notifyMessenger(nsri, TelephonyScanManager.CALLBACK_SCAN_RESULTS,
                                    NetworkScan.SUCCESS, nsr.networkInfos);
                        }
                        notifyMessenger(nsri, notifyMsg,
                                rilErrorToScanError(nsr.scanError), nsr.networkInfos);
                    }
                    deleteScanAndMayNotify(nsri, rilErrorToScanError(nsr.scanError), true);
                    nsri.mPhone.mCi.unregisterForNetworkScanResult(mHandler);
@@ -417,7 +448,6 @@ public final class NetworkScanRequestTracker {
            }
        }


        // Stops the scan if the scanId and uid match the mScanId and mUid.
        // If the scan to be stopped is the live scan, we only send the request to RIL, while the
        // mLiveRequestInfo will not be cleared and the user will not be notified either.
+1 −0
Original line number Diff line number Diff line
@@ -155,6 +155,7 @@ public interface PhoneInternalInterface {
    static final String REASON_CARRIER_ACTION_DISABLE_METERED_APN =
            "carrierActionDisableMeteredApn";
    static final String REASON_CSS_INDICATOR_CHANGED = "cssIndicatorChanged";
    static final String REASON_RELEASED_BY_CONNECTIVITY_SERVICE = "releasedByConnectivityService";

    // Used for band mode selection methods
    static final int BM_UNSPECIFIED = RILConstants.BAND_MODE_UNSPECIFIED; // automatic
+299 −137

File changed.

Preview size limit exceeded, changes collapsed.

+87 −50
Original line number Diff line number Diff line
@@ -350,7 +350,7 @@ public class EuiccController extends IEuiccController.Stub {
                    forceDeactivateSim,
                    new DownloadSubscriptionGetMetadataCommandCallback(token, subscription,
                            switchAfterDownload, callingPackage, forceDeactivateSim,
                            callbackIntent));
                            callbackIntent, false /* withUserConsent */));
        } finally {
            Binder.restoreCallingIdentity(token);
        }
@@ -359,28 +359,51 @@ public class EuiccController extends IEuiccController.Stub {
    class DownloadSubscriptionGetMetadataCommandCallback extends GetMetadataCommandCallback {
        private final boolean mSwitchAfterDownload;
        private final boolean mForceDeactivateSim;
        private final boolean mWithUserConsent;

        DownloadSubscriptionGetMetadataCommandCallback(long callingToken,
                DownloadableSubscription subscription, boolean switchAfterDownload,
                String callingPackage, boolean forceDeactivateSim,
                PendingIntent callbackIntent) {
                PendingIntent callbackIntent, boolean withUserConsent) {
            super(callingToken, subscription, callingPackage, callbackIntent);
            mSwitchAfterDownload = switchAfterDownload;
            mForceDeactivateSim = forceDeactivateSim;
            mWithUserConsent = withUserConsent;
        }

        @Override
        public void onGetMetadataComplete(int cardId,
                GetDownloadableSubscriptionMetadataResult result) {
            DownloadableSubscription subscription = result.getDownloadableSubscription();
            if (mWithUserConsent) {
                // We won't get RESULT_MUST_DEACTIVATE_SIM for the case with user consent.
                if (result.getResult() != EuiccService.RESULT_OK) {
                    // Just propagate the error as normal.
                    super.onGetMetadataComplete(cardId, result);
                    return;
                }

                if (checkCarrierPrivilegeInMetadata(subscription, mCallingPackage)) {
                    // Caller can download this profile. Since we already have the user's consent,
                    // proceed to download.
                    downloadSubscriptionPrivileged(cardId,
                            mCallingToken, subscription, mSwitchAfterDownload,  mForceDeactivateSim,
                            mCallingPackage, null /* resolvedBundle */,
                            mCallbackIntent);
                } else {
                    Log.e(TAG, "Caller does not have carrier privilege in metadata.");
                    sendResult(mCallbackIntent, ERROR, null /* extrasIntent */);
                }
            } else { // !mWithUserConsent
                if (result.getResult() == EuiccService.RESULT_MUST_DEACTIVATE_SIM) {
                // If we need to deactivate the current SIM to even check permissions, go ahead and
                // require that the user resolve the stronger permission dialog.
                    // If we need to deactivate the current SIM to even check permissions, go ahead
                    // and require that the user resolve the stronger permission dialog.
                    Intent extrasIntent = new Intent();
                    addResolutionIntent(extrasIntent, EuiccService.ACTION_RESOLVE_NO_PRIVILEGES,
                            mCallingPackage,
                            0 /* resolvableErrors */,
                            false /* confirmationCodeRetried */,
                            EuiccOperation.forDownloadNoPrivileges(
                            EuiccOperation.forDownloadNoPrivilegesCheckMetadata(
                                    mCallingToken, mSubscription, mSwitchAfterDownload,
                                    mCallingPackage),
                            cardId);
@@ -394,31 +417,7 @@ public class EuiccController extends IEuiccController.Stub {
                    return;
                }

            DownloadableSubscription subscription = result.getDownloadableSubscription();
            UiccAccessRule[] rules = null;
            List<UiccAccessRule> rulesList = subscription.getAccessRules();
            if (rulesList != null) {
                rules = rulesList.toArray(new UiccAccessRule[rulesList.size()]);
            }
            if (rules == null) {
                Log.e(TAG, "No access rules but caller is unprivileged");
                sendResult(mCallbackIntent, ERROR, null /* extrasIntent */);
                return;
            }

            final PackageInfo info;
            try {
                info = mPackageManager.getPackageInfo(
                        mCallingPackage, PackageManager.GET_SIGNATURES);
            } catch (PackageManager.NameNotFoundException e) {
                Log.e(TAG, "Calling package valid but gone");
                sendResult(mCallbackIntent, ERROR, null /* extrasIntent */);
                return;
            }

            for (int i = 0; i < rules.length; i++) {
                if (rules[i].getCarrierPrivilegeStatus(info)
                        == TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS) {
                if (checkCarrierPrivilegeInMetadata(subscription, mCallingPackage)) {
                    // Caller can download this profile.
                    // On a multi-active SIM device, if the caller can manage the active
                    // subscription on the target SIM, or there is no active subscription on the
@@ -435,7 +434,7 @@ public class EuiccController extends IEuiccController.Stub {
                        return;
                    }

                    // Switch might still be permitted, but the user must consent first.
                    // Download might still be permitted, but the user must consent first.
                    Intent extrasIntent = new Intent();
                    addResolutionIntent(extrasIntent, EuiccService.ACTION_RESOLVE_NO_PRIVILEGES,
                            mCallingPackage,
@@ -446,20 +445,26 @@ public class EuiccController extends IEuiccController.Stub {
                                    mCallingPackage),
                            cardId);
                    sendResult(mCallbackIntent, RESOLVABLE_ERROR, extrasIntent);
                    return;
                } else {
                    Log.e(TAG, "Caller is not permitted to download this profile per metadata");
                    sendResult(mCallbackIntent, ERROR, null /* extrasIntent */);
                }
            }
            Log.e(TAG, "Caller is not permitted to download this profile");
            sendResult(mCallbackIntent, ERROR, null /* extrasIntent */);
        }

        @Override
        protected EuiccOperation getOperationForDeactivateSim() {
            return EuiccOperation.forDownloadDeactivateSim(
                    mCallingToken, mSubscription, mSwitchAfterDownload, mCallingPackage);
    }

    // Already have user consent. Check metadata first before proceed to download.
    void downloadSubscriptionPrivilegedCheckMetadata(int cardId, final long callingToken,
            DownloadableSubscription subscription, boolean switchAfterDownload,
            boolean forceDeactivateSim, final String callingPackage, Bundle resolvedBundle,
            final PendingIntent callbackIntent) {
        mConnector.getDownloadableSubscriptionMetadata(cardId, subscription, forceDeactivateSim,
                new DownloadSubscriptionGetMetadataCommandCallback(callingToken, subscription,
                        switchAfterDownload, callingPackage, forceDeactivateSim, callbackIntent,
                        true /* withUserConsent */));
    }

    // Continue to download subscription without checking anything.
    void downloadSubscriptionPrivileged(int cardId, final long callingToken,
            DownloadableSubscription subscription, boolean switchAfterDownload,
            boolean forceDeactivateSim, final String callingPackage, Bundle resolvedBundle,
@@ -1166,6 +1171,38 @@ public class EuiccController extends IEuiccController.Stub {
        return resultRef.get();
    }

    // Returns whether the caller has carrier privilege on the given subscription.
    private boolean checkCarrierPrivilegeInMetadata(DownloadableSubscription subscription,
            String callingPackage) {
        UiccAccessRule[] rules = null;
        List<UiccAccessRule> rulesList = subscription.getAccessRules();
        if (rulesList != null) {
            rules = rulesList.toArray(new UiccAccessRule[rulesList.size()]);
        }
        if (rules == null) {
            Log.e(TAG, "No access rules but caller is unprivileged");
            return false;
        }

        final PackageInfo info;
        try {
            info = mPackageManager.getPackageInfo(callingPackage, PackageManager.GET_SIGNATURES);
        } catch (PackageManager.NameNotFoundException e) {
            Log.e(TAG, "Calling package valid but gone");
            return false;
        }

        for (int i = 0; i < rules.length; i++) {
            if (rules[i].getCarrierPrivilegeStatus(info)
                    == TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS) {
                Log.i(TAG, "Calling package has carrier privilege to this profile");
                return true;
            }
        }
        Log.e(TAG, "Calling package doesn't have carrier privilege to this profile");
        return false;
    }

    private boolean supportMultiActiveSlots() {
        return mTelephonyManager.getPhoneCount() > 1;
    }
Loading