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

Commit 7638c935 authored by Jack Yu's avatar Jack Yu
Browse files

Migrated carrier apps initialization code

Moved the carrier apps initialization code from
SubscriptionInfoUpdater, which will be removed soon.

There is no logic change

Fix: 267096646
Test: Boot up test + Basic phone testing + atest FrameworksTelephonyTests
Change-Id: I042d0bd77dad016fda442ac789579e32875d10fe
parent bca6964e
Loading
Loading
Loading
Loading
+30 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import static com.android.internal.telephony.CommandsInterface.SERVICE_CLASS_VOI

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.ActivityManager;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.BroadcastReceiver;
import android.content.ContentValues;
@@ -483,6 +484,10 @@ public class GsmCdmaPhone extends Phone {

        mCDM = new CarrierKeyDownloadManager(this);
        mCIM = new CarrierInfoManager();

        if (isSubscriptionManagerServiceEnabled()) {
            initializeCarrierApps();
        }
    }

    private void initRatSpecific(int precisePhoneType) {
@@ -561,6 +566,31 @@ public class GsmCdmaPhone extends Phone {
        }
    }

    /**
     * Initialize the carrier apps.
     */
    private void initializeCarrierApps() {
        // Only perform on the default phone. There is no need to do it twice on the DSDS device.
        if (mPhoneId != 0) return;

        logd("initializeCarrierApps");
        mContext.registerReceiverForAllUsers(new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                // Remove this line after testing
                if (Intent.ACTION_USER_FOREGROUND.equals(intent.getAction())) {
                    UserHandle userHandle = intent.getParcelableExtra(Intent.EXTRA_USER);
                    // If couldn't get current user ID, guess it's 0.
                    CarrierAppUtils.disableCarrierAppsUntilPrivileged(mContext.getOpPackageName(),
                            TelephonyManager.getDefault(),
                            userHandle != null ? userHandle.getIdentifier() : 0, mContext);
                }
            }
        }, new IntentFilter(Intent.ACTION_USER_FOREGROUND), null, null);
        CarrierAppUtils.disableCarrierAppsUntilPrivileged(mContext.getOpPackageName(),
                TelephonyManager.getDefault(), ActivityManager.getCurrentUser(), mContext);
    }

    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
    public boolean isPhoneTypeGsm() {
        return mPrecisePhoneType == PhoneConstants.PHONE_TYPE_GSM;