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

Commit 8be1634a authored by Winson's avatar Winson
Browse files

Disallow launching third party apps in safe mode.

- Also desaturates out the disabled task

Bug: 25785926
Change-Id: I9fa48c062cfaf6d9cb60a9e49291ca6e15c6b343
parent 1af8eda6
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -52,6 +52,8 @@
    <!-- Tint color for the content on the notification overflow card. -->
    <color name="keyguard_overflow_content_color">#ff686868</color>

    <!-- The disabled recents task bar background color. -->
    <color name="recents_task_bar_disabled_background_color">#ff676767</color>
    <!-- The default recents task bar background color. -->
    <color name="recents_task_bar_default_background_color">#ffe6e6e6</color>
    <!-- The default recents task view background color. -->
+2 −0
Original line number Diff line number Diff line
@@ -714,6 +714,8 @@
    <string name="recents_search_bar_label">search</string>
    <!-- Recents: Launch error string. [CHAR LIMIT=NONE] -->
    <string name="recents_launch_error_message">Could not start <xliff:g id="app" example="Calendar">%s</xliff:g>.</string>
    <!-- Recents: Launch disabled string. [CHAR LIMIT=NONE] -->
    <string name="recents_launch_disabled_message"><xliff:g id="app" example="Calendar">%s</xliff:g> is disabled in safe-mode.</string>
    <!-- Recents: Show history string. [CHAR LIMIT=NONE] -->
    <string name="recents_history_button_label">History</string>
    <!-- Recents: History clear all string. [CHAR LIMIT=NONE] -->
+4 −1
Original line number Diff line number Diff line
@@ -837,11 +837,13 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
     * Draws the header of a task used for the window animation into a bitmap.
     */
    private Bitmap drawThumbnailTransitionBitmap(Task toTask, TaskViewTransform toTransform) {
        SystemServicesProxy ssp = Recents.getSystemServices();
        if (toTransform != null && toTask.key != null) {
            Bitmap thumbnail;
            synchronized (mHeaderBarLock) {
                int toHeaderWidth = (int) toTransform.rect.width();
                int toHeaderHeight = (int) (mHeaderBar.getMeasuredHeight() * toTransform.scale);
                boolean disabledInSafeMode = !toTask.isSystemApp && ssp.isInSafeMode();
                mHeaderBar.onTaskViewSizeChanged((int) toTransform.rect.width(),
                        (int) toTransform.rect.height());
                thumbnail = Bitmap.createBitmap(toHeaderWidth, toHeaderHeight,
@@ -851,7 +853,8 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
                } else {
                    Canvas c = new Canvas(thumbnail);
                    c.scale(toTransform.scale, toTransform.scale);
                    mHeaderBar.rebindToTask(toTask, false /* touchExplorationEnabled */);
                    mHeaderBar.rebindToTask(toTask, false /* touchExplorationEnabled */,
                            disabledInSafeMode);
                    mHeaderBar.draw(c);
                    c.setBitmap(null);
                }
+10 −0
Original line number Diff line number Diff line
@@ -112,6 +112,8 @@ public class SystemServicesProxy {
    Display mDisplay;
    String mRecentsPackage;
    ComponentName mAssistComponent;

    boolean mIsSafeMode;
    boolean mHasFreeformWorkspaceSupport;

    Bitmap mDummyIcon;
@@ -137,6 +139,7 @@ public class SystemServicesProxy {
                mPm.hasSystemFeature(PackageManager.FEATURE_FREEFORM_WINDOW_MANAGEMENT) ||
                        Settings.Global.getInt(context.getContentResolver(),
                                DEVELOPMENT_ENABLE_FREEFORM_WINDOWS_SUPPORT, 0) != 0;
        mIsSafeMode = mPm.isSafeMode();

        // Get the dummy thumbnail width/heights
        Resources res = context.getResources();
@@ -261,6 +264,13 @@ public class SystemServicesProxy {
        return mHasFreeformWorkspaceSupport;
    }

    /**
     * Returns whether this device is in the safe mode.
     */
    public boolean isInSafeMode() {
        return mIsSafeMode;
    }

    /** Returns whether the recents is currently running */
    public boolean isRecentsTopMost(ActivityManager.RunningTaskInfo topTask,
            MutableBoolean isHomeTopMost) {
+5 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.systemui.recents.model;

import android.app.ActivityManager;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.UserInfo;
import android.content.res.Resources;
import android.graphics.Bitmap;
@@ -189,11 +190,14 @@ public class RecentsTaskLoadPlan {
            Bitmap thumbnail = loader.getAndUpdateThumbnail(taskKey, false);
            int activityColor = loader.getActivityPrimaryColor(t.taskDescription);
            int backgroundColor = loader.getActivityBackgroundColor(t.taskDescription);
            boolean isSystemApp = (loader.getAndUpdateActivityInfo(taskKey).applicationInfo.flags
                    & ApplicationInfo.FLAG_SYSTEM) != 0;

            // Add the task to the stack
            Task task = new Task(taskKey, t.affiliatedTaskId, t.affiliatedTaskColor, icon,
                    thumbnail, title, contentDescription, dismissDescription, activityColor,
                    backgroundColor, !isStackTask, isLaunchTarget, t.bounds, t.taskDescription);
                    backgroundColor, !isStackTask, isLaunchTarget, isSystemApp, t.bounds,
                    t.taskDescription);

            allTasks.add(task);
            affiliatedTaskCounts.put(taskKey.id, affiliatedTaskCounts.get(taskKey.id, 0) + 1);
Loading