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

Commit 123768a9 authored by Edward Cunningham's avatar Edward Cunningham Committed by Android (Google) Code Review
Browse files

Merge "Allow holders of SYSTEM_ALERT_WINDOW permission to start activities...

Merge "Allow holders of SYSTEM_ALERT_WINDOW permission to start activities from background" into qt-dev
parents a47236b5 1548684f
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -1038,6 +1038,12 @@ class ActivityStarter {
                }
            }
        }
        // don't abort if the callingUid has SYSTEM_ALERT_WINDOW permission
        if (mService.hasSystemAlertWindowPermission(callingUid, callingPid, callingPackage)) {
            Slog.w(TAG, "Background activity start for " + callingPackage
                    + " allowed because SYSTEM_ALERT_WINDOW permission is granted.");
            return false;
        }
        // anything that has fallen through would currently be aborted
        Slog.w(TAG, "Background activity start [callingPackage: " + callingPackage
                + "; callingUid: " + callingUid
+11 −3
Original line number Diff line number Diff line
@@ -108,12 +108,10 @@ import static com.android.server.wm.ActivityTaskManagerDebugConfig.POSTFIX_SWITC
import static com.android.server.wm.ActivityTaskManagerDebugConfig.POSTFIX_VISIBILITY;
import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_ATM;
import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_WITH_CLASS_NAME;
import static com.android.server.wm.ActivityTaskManagerInternal.ASSIST_ACTIVITY_ID;
import static com.android.server.wm.ActivityTaskManagerInternal.ASSIST_KEY_CONTENT;
import static com.android.server.wm.ActivityTaskManagerInternal.ASSIST_KEY_DATA;
import static com.android.server.wm.ActivityTaskManagerInternal.ASSIST_KEY_RECEIVER_EXTRAS;
import static com.android.server.wm.ActivityTaskManagerInternal.ASSIST_KEY_STRUCTURE;
import static com.android.server.wm.ActivityTaskManagerInternal.ASSIST_TASK_ID;
import static com.android.server.wm.ActivityTaskManagerService.H.REPORT_TIME_TRACKER_MSG;
import static com.android.server.wm.ActivityTaskManagerService.UiHandler.DISMISS_DIALOG_UI_MSG;
import static com.android.server.wm.RecentsAnimationController.REORDER_KEEP_IN_PLACE;
@@ -136,6 +134,7 @@ import android.app.ActivityTaskManager;
import android.app.ActivityThread;
import android.app.AlertDialog;
import android.app.AppGlobals;
import android.app.AppOpsManager;
import android.app.Dialog;
import android.app.IActivityController;
import android.app.IActivityTaskManager;
@@ -216,7 +215,6 @@ import android.text.format.Time;
import android.util.ArrayMap;
import android.util.EventLog;
import android.util.Log;
import android.util.Pair;
import android.util.Slog;
import android.util.SparseArray;
import android.util.SparseIntArray;
@@ -875,6 +873,16 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
        return getUserManager().hasUserRestriction(restriction, userId);
    }

    boolean hasSystemAlertWindowPermission(int callingUid, int callingPid, String callingPackage) {
        final int mode = getAppOpsService().noteOperation(AppOpsManager.OP_SYSTEM_ALERT_WINDOW,
                callingUid, callingPackage);
        if (mode == AppOpsManager.MODE_DEFAULT) {
            return checkPermission(Manifest.permission.SYSTEM_ALERT_WINDOW, callingPid, callingUid)
                    == PERMISSION_GRANTED;
        }
        return mode == AppOpsManager.MODE_ALLOWED;
    }

    protected RecentTasks createRecentTasks() {
        return new RecentTasks(this, mStackSupervisor);
    }
+12 −0
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ import static com.android.server.wm.ActivityStackSupervisor.ON_TOP;

import android.app.ActivityManagerInternal;
import android.app.ActivityOptions;
import android.app.AppOpsManager;
import android.app.IApplicationThread;
import android.content.ComponentName;
import android.content.Context;
@@ -413,12 +414,18 @@ class ActivityTestsBase {
        ActivityStackSupervisor mTestStackSupervisor;

        ActivityDisplay mDefaultDisplay;
        AppOpsService mAppOpsService;

        TestActivityTaskManagerService(Context context) {
            super(context);
            spyOn(this);

            mUgmInternal = mock(UriGrantsManagerInternal.class);
            mAppOpsService = mock(AppOpsService.class);

            // Make sure permission checks aren't overridden.
            doReturn(AppOpsManager.MODE_DEFAULT)
                    .when(mAppOpsService).noteOperation(anyInt(), anyInt(), anyString());

            mSupportsMultiWindow = true;
            mSupportsMultiDisplay = true;
@@ -481,6 +488,11 @@ class ActivityTestsBase {
            return userId;
        }

        @Override
        AppOpsService getAppOpsService() {
            return mAppOpsService;
        }

        @Override
        void updateCpuStats() {
        }