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

Commit c6e18250 authored by Grace Jia's avatar Grace Jia Committed by Automerger Merge Worker
Browse files

Fix IllegalStateException when creating context for work profile. am: 8caa16cb am: 6eb86c40

parents b59d4fec 6eb86c40
Loading
Loading
Loading
Loading
+1 −25
Original line number Diff line number Diff line
@@ -32,7 +32,6 @@ import android.os.Binder;
import android.os.Build;
import android.os.RemoteException;
import android.os.TelephonyServiceManager.ServiceRegisterer;
import android.os.UserHandle;
import android.telephony.ImsiEncryptionInfo;
import android.telephony.PhoneNumberUtils;
import android.telephony.SubscriptionManager;
@@ -152,8 +151,7 @@ public class PhoneSubInfoController extends IPhoneSubInfo.Stub {
    public String getSubscriberIdForSubscriber(int subId, String callingPackage,
            String callingFeatureId) {
        String message = "getSubscriberIdForSubscriber";

        enforceCallingPackage(callingPackage, Binder.getCallingUid(), message);
        mAppOps.checkPackage(Binder.getCallingUid(), callingPackage);

        long identity = Binder.clearCallingIdentity();
        boolean isActive;
@@ -334,28 +332,6 @@ public class PhoneSubInfoController extends IPhoneSubInfo.Stub {
                "Requires MODIFY_PHONE_STATE");
    }

    /**
     * Make sure the caller is the calling package itself
     *
     * @throws SecurityException if the caller is not the calling package
     */
    private void enforceCallingPackage(String callingPackage, int callingUid, String message) {
        int packageUid = -1;
        PackageManager pm = mContext.createContextAsUser(
                UserHandle.getUserHandleForUid(callingUid), 0).getPackageManager();
        if (pm != null) {
            try {
                packageUid = pm.getPackageUid(callingPackage, 0);
            } catch (PackageManager.NameNotFoundException e) {
                // packageUid is -1
            }
        }
        if (packageUid != callingUid) {
            throw new SecurityException(message + ": Package " + callingPackage
                    + " does not belong to " + callingUid);
        }
    }

    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
    private int getDefaultSubscription() {
        return  PhoneFactory.getDefaultSubscription();