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

Commit f37c63a0 authored by Meng Wang's avatar Meng Wang Committed by Android (Google) Code Review
Browse files

Merge "Do not use hidden API Binder.withCleanCallingIdentity"

parents 4e5ad8a6 0f656559
Loading
Loading
Loading
Loading
+10 −5
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

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;
@@ -24,6 +23,7 @@ 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;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
@@ -178,10 +178,15 @@ public final class NetworkScanRequestTracker {
     * scan when scan results are restricted due to location privacy.
     */
    public static Set<String> getAllowedMccMncsForLocationRestrictedScan(Context context) {
        return withCleanCallingIdentity(() -> SubscriptionController.getInstance()
        final long token = Binder.clearCallingIdentity();
        try {
            return SubscriptionController.getInstance()
                    .getAvailableSubscriptionInfoList(context.getOpPackageName()).stream()
                    .flatMap(NetworkScanRequestTracker::getAllowableMccMncsFromSubscriptionInfo)
            .collect(Collectors.toSet()));
                    .collect(Collectors.toSet());
        } finally {
            Binder.restoreCallingIdentity(token);
        }
    }

    private static Stream<String> getAllowableMccMncsFromSubscriptionInfo(SubscriptionInfo info) {
+12 −2
Original line number Diff line number Diff line
@@ -163,7 +163,12 @@ public class RcsMessageController extends IRcsMessage.Stub {
     */
    private <T> T performWriteOperation(String callingPackage, ThrowingSupplier<T> fn) {
        RcsPermissions.checkWritePermissions(mContext, callingPackage);
        return Binder.withCleanCallingIdentity(fn);
        final long token = Binder.clearCallingIdentity();
        try {
            return fn.get();
        } finally {
            Binder.restoreCallingIdentity(token);
        }
    }

    /**
@@ -173,7 +178,12 @@ public class RcsMessageController extends IRcsMessage.Stub {
     */
    private <T> T performReadOperation(String callingPackage, ThrowingSupplier<T> fn) {
        RcsPermissions.checkReadPermissions(mContext, callingPackage);
        return Binder.withCleanCallingIdentity(fn);
        final long token = Binder.clearCallingIdentity();
        try {
            return fn.get();
        } finally {
            Binder.restoreCallingIdentity(token);
        }
    }

    @VisibleForTesting