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

Commit 5eec82ab authored by Sarup Dalwani's avatar Sarup Dalwani
Browse files

Moving intent redirection feature flag from setting to DeviceConfig

Turn on flag : adb shell device_config put app_cloning allow_intent_redirection_for_clone_profile true
Turn off flag : adb shell device_config put app_cloning
allow_intent_redirection_for_clone_profile false

Bug: 236221777
Test: atest CtsAppCloningHostTest:com.android.cts.appcloning.IntentRedirectionTest
Change-Id: Ib1d1dc5526d2804df9a8caa142e2d8cd9df4cd63
parent 9dc3aa3e
Loading
Loading
Loading
Loading
+0 −12
Original line number Diff line number Diff line
@@ -51,16 +51,6 @@ public class FeatureFlagUtils {
    /** @hide */
    public static final String SETTINGS_SUPPORT_LARGE_SCREEN = "settings_support_large_screen";

    /**
     * Feature flag to allow/restrict intent redirection from/to clone profile.
     * Default value is false,this is to ensure that framework is not impacted by intent redirection
     * till we are ready to launch.
     * From Android U onwards, this would be set to true and eventually removed.
     * @hide
     */
    public static final String SETTINGS_ALLOW_INTENT_REDIRECTION_FOR_CLONE_PROFILE =
            "settings_allow_intent_redirection_for_clone_profile";

    /**
     * Support locale opt-out and opt-in switch for per app's language.
     * @hide
@@ -174,7 +164,6 @@ public class FeatureFlagUtils {
        DEFAULT_FLAGS.put(SETTINGS_ENABLE_SECURITY_HUB, "true");
        DEFAULT_FLAGS.put(SETTINGS_SUPPORT_LARGE_SCREEN, "true");
        DEFAULT_FLAGS.put("settings_search_always_expand", "true");
        DEFAULT_FLAGS.put(SETTINGS_ALLOW_INTENT_REDIRECTION_FOR_CLONE_PROFILE, "false");
        DEFAULT_FLAGS.put(SETTINGS_APP_LOCALE_OPT_IN_ENABLED, "true");
        DEFAULT_FLAGS.put(SETTINGS_VOLUME_PANEL_IN_SYSTEMUI, "false");
        DEFAULT_FLAGS.put(SETTINGS_ENABLE_MONITOR_PHANTOM_PROCS, "true");
@@ -196,7 +185,6 @@ public class FeatureFlagUtils {

    static {
        PERSISTENT_FLAGS = new HashSet<>();
        PERSISTENT_FLAGS.add(SETTINGS_ALLOW_INTENT_REDIRECTION_FOR_CLONE_PROFILE);
        PERSISTENT_FLAGS.add(SETTINGS_APP_LOCALE_OPT_IN_ENABLED);
        PERSISTENT_FLAGS.add(SETTINGS_SUPPORT_LARGE_SCREEN);
        PERSISTENT_FLAGS.add(SETTINGS_ENABLE_MONITOR_PHANTOM_PROCS);
+26 −0
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ package com.android.server.pm;

import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.os.Binder;
import android.provider.DeviceConfig;

import com.android.server.pm.pkg.PackageStateInternal;
import com.android.server.pm.resolution.ComponentResolverApi;
@@ -32,6 +34,30 @@ import java.util.function.Function;
 */
public class CloneProfileResolver extends CrossProfileResolver {

    /**
     * Feature flag to allow/restrict intent redirection from/to clone profile.
     * Default value is false,this is to ensure that framework is not impacted by intent redirection
     * till we are ready to launch.
     * From Android U onwards, this would be set to true and eventually removed.
     * @hide
     */
    private static final String FLAG_ALLOW_INTENT_REDIRECTION_FOR_CLONE_PROFILE =
            "allow_intent_redirection_for_clone_profile";

    /**
     * Returns true if intent redirection for clone profile feature flag is set
     * @return value of flag allow_intent_redirection_for_clone_profile
     */
    public static boolean isIntentRedirectionForCloneProfileAllowed() {
        final long token = Binder.clearCallingIdentity();
        try {
            return DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_APP_CLONING,
                    FLAG_ALLOW_INTENT_REDIRECTION_FOR_CLONE_PROFILE, false /* defaultValue */);
        } finally {
            Binder.restoreCallingIdentity(token);
        }
    }

    public CloneProfileResolver(ComponentResolverApi componentResolver,
            UserManagerService userManagerService) {
        super(componentResolver, userManagerService);
+1 −3
Original line number Diff line number Diff line
@@ -32,7 +32,6 @@ import android.content.pm.ResolveInfo;
import android.content.pm.UserInfo;
import android.os.Process;
import android.text.TextUtils;
import android.util.FeatureFlagUtils;
import android.util.Pair;
import android.util.Slog;
import android.util.SparseArray;
@@ -250,8 +249,7 @@ public class CrossProfileIntentResolverEngine {
         * SETTINGS_ALLOW_INTENT_REDIRECTION_FOR_CLONE_PROFILE is enabled
         */
        if (sourceUserInfo.isCloneProfile() || targetUserInfo.isCloneProfile()) {
            if (FeatureFlagUtils.isEnabled(mContext,
                    FeatureFlagUtils.SETTINGS_ALLOW_INTENT_REDIRECTION_FOR_CLONE_PROFILE)) {
            if (CloneProfileResolver.isIntentRedirectionForCloneProfileAllowed()) {
                return new CloneProfileResolver(computer.getComponentResolver(),
                        mUserManager);
            } else {