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

Commit fafc8aad authored by Ben Lin's avatar Ben Lin Committed by Android (Google) Code Review
Browse files

Merge "Don't allow app handle to be drawn for any task w/ default home package." into main

parents e0a5ac00 d0b23cfd
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ import android.app.ActivityManager.RunningTaskInfo;
import android.app.ActivityTaskManager;
import android.app.IActivityManager;
import android.app.IActivityTaskManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.graphics.Point;
@@ -1467,6 +1468,9 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel,
                && isTopActivityExemptFromDesktopWindowing(mContext, taskInfo)) {
            return false;
        }
        if (isPartOfDefaultHomePackage(taskInfo)) {
            return false;
        }
        return DesktopModeStatus.canEnterDesktopMode(mContext)
                && !DesktopWallpaperActivity.isWallpaperTask(taskInfo)
                && taskInfo.getWindowingMode() != WINDOWING_MODE_PINNED
@@ -1474,6 +1478,14 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel,
                && !taskInfo.configuration.windowConfiguration.isAlwaysOnTop();
    }

    private boolean isPartOfDefaultHomePackage(RunningTaskInfo taskInfo) {
        final ComponentName currentDefaultHome =
                mContext.getPackageManager().getHomeActivities(new ArrayList<>());
        return currentDefaultHome != null && taskInfo.baseActivity != null
                && currentDefaultHome.getPackageName()
                .equals(taskInfo.baseActivity.getPackageName());
    }

    private void createWindowDecoration(
            ActivityManager.RunningTaskInfo taskInfo,
            SurfaceControl taskSurface,