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

Commit 399a111d authored by Achim Thesmann's avatar Achim Thesmann
Browse files

Enable ASM when targeting C

Enables the ASM logic if the app targets C and all relevant feature flags are on and the app is opted in (either voluntary or forced).
This also moves the compat change flag to the BackgroundActivityStartController and removed an orphaned flag.

Bug: 416033243
Flag: android.security.asm_restrictions_enabled
Test: atest ActivitySecurityModelTest (TODO)
Change-Id: I6623752fc6765f9e2a63bffcaeb2ef8ffd18c892
parent 1d6228f2
Loading
Loading
Loading
Loading
+0 −17
Original line number Diff line number Diff line
@@ -104,8 +104,6 @@ import android.app.WindowConfiguration;
import android.app.WindowConfiguration.WindowingMode;
import android.app.compat.CompatChanges;
import android.compat.annotation.ChangeId;
import android.compat.annotation.Disabled;
import android.compat.annotation.EnabledSince;
import android.compat.annotation.Overridable;
import android.content.Context;
import android.content.IIntentSender;
@@ -120,7 +118,6 @@ import android.content.pm.ResolveInfo;
import android.content.pm.UserInfo;
import android.content.res.Configuration;
import android.os.Binder;
import android.os.Build;
import android.os.Bundle;
import android.os.IBinder;
import android.os.OperationCanceledException;
@@ -181,20 +178,6 @@ class ActivityStarter {
     */
    private static final long MAX_TASK_WEIGHT_FOR_ADDING_ACTIVITY = 300;

    /**
     * Feature flag to protect PendingIntent being abused to start background activity.
     */
    @ChangeId
    @EnabledSince(targetSdkVersion = Build.VERSION_CODES.TIRAMISU)
    static final long ENABLE_PENDING_INTENT_BAL_OPTION = 192341120L;

    /**
     * Feature flag for go/activity-security rules
     */
    @ChangeId
    @Disabled
    static final long ASM_RESTRICTIONS = 230590090L;

    @ChangeId
    @Overridable
    private static final long ENABLE_PREVENT_INTENT_REDIRECT_TAKE_ACTION = 29623414L;
+5 −1
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import static android.app.ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_DENIED;
import static android.app.ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_SYSTEM_DEFINED;
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
import static android.os.Build.VERSION_CODES.BAKLAVA;
import static android.os.Build.VERSION_CODES.UPSIDE_DOWN_CAKE;
import static android.os.Process.INVALID_PID;
import static android.os.Process.INVALID_UID;
@@ -35,7 +36,6 @@ import static android.os.Process.SYSTEM_UID;
import static android.provider.DeviceConfig.NAMESPACE_WINDOW_MANAGER;
import static android.security.Flags.asmOptSystemIntoEnforcement;

import static com.android.server.wm.ActivityStarter.ASM_RESTRICTIONS;
import static com.android.server.wm.ActivityTaskManagerDebugConfig.DEBUG_ACTIVITY_STARTS;
import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_ATM;
import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_WITH_CLASS_NAME;
@@ -141,6 +141,10 @@ public class BackgroundActivityStartController {
    @EnabledAfter(targetSdkVersion = UPSIDE_DOWN_CAKE)
    private static final long DEFAULT_RESCIND_BAL_PRIVILEGES_FROM_PENDING_INTENT_CREATOR =
            296478951;
    /**  Feature flag for go/activity-security rules */
    @ChangeId
    @EnabledAfter(targetSdkVersion = BAKLAVA)
    static final long ASM_RESTRICTIONS = 230590090L;
    public static final ActivityOptions ACTIVITY_OPTIONS_SYSTEM_DEFINED =
            ActivityOptions.makeBasic()
                    .setPendingIntentBackgroundActivityStartMode(