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

Commit 0506a46f authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "CarrierAppUtils: Improve readability of update state logic" into main

parents fbca4c9c 0b3ce174
Loading
Loading
Loading
Loading
+17 −5
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import android.util.ArrayMap;
import android.util.Log;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.flags.Flags;
import com.android.internal.telephony.util.TelephonyUtils;

import java.util.ArrayList;
@@ -185,11 +186,7 @@ public final class CarrierAppUtils {
                if (hasPrivileges) {
                    // Only update enabled state for the app on /system. Once it has been
                    // updated we shouldn't touch it.
                    if (!isUpdatedSystemApp(ai) && enabledSetting
                            == PackageManager.COMPONENT_ENABLED_STATE_DEFAULT
                            || enabledSetting
                            == PackageManager.COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED
                            || (ai.flags & ApplicationInfo.FLAG_INSTALLED) == 0) {
                    if (shouldUpdateEnabledState(ai, enabledSetting)) {
                        Log.i(TAG, "Update state (" + packageName + "): ENABLED for user "
                                + userId);
                        context.createContextAsUser(UserHandle.of(userId), 0)
@@ -330,6 +327,21 @@ public final class CarrierAppUtils {
        }
    }

    private static boolean shouldUpdateEnabledState(ApplicationInfo appInfo, int enabledSetting) {
        if (Flags.cleanupCarrierAppUpdateEnabledStateLogic()) {
            return !isUpdatedSystemApp(appInfo)
                    && (enabledSetting == PackageManager.COMPONENT_ENABLED_STATE_DEFAULT
                            || enabledSetting
                                    == PackageManager.COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED
                            || (appInfo.flags & ApplicationInfo.FLAG_INSTALLED) == 0);
        } else {
            return !isUpdatedSystemApp(appInfo)
                            && enabledSetting == PackageManager.COMPONENT_ENABLED_STATE_DEFAULT
                    || enabledSetting == PackageManager.COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED
                    || (appInfo.flags & ApplicationInfo.FLAG_INSTALLED) == 0;
        }
    }

    /**
     * Returns the list of "default" carrier apps.
     *