diff options
17 files changed, 113 insertions, 132 deletions
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java index db5dcc5c264b..af59ea1d22ff 100644 --- a/core/java/android/app/Activity.java +++ b/core/java/android/app/Activity.java @@ -77,7 +77,6 @@ import android.os.IBinder; import android.os.Looper; import android.os.Parcelable; import android.os.PersistableBundle; -import android.os.PowerManager; import android.os.Process; import android.os.RemoteException; import android.os.ServiceManager.ServiceNotFoundException; @@ -8788,9 +8787,7 @@ public class Activity extends ContextThemeWrapper * the activity is visible after the screen is turned on when the lockscreen is up. In addition, * if this flag is set and the activity calls {@link * KeyguardManager#requestDismissKeyguard(Activity, KeyguardManager.KeyguardDismissCallback)} - * the screen will turn on. If the screen is off and device is not secured, this flag can turn - * screen on and dismiss keyguard to make this activity visible and resume, which can be used to - * replace {@link PowerManager#ACQUIRE_CAUSES_WAKEUP} + * the screen will turn on. * * @param turnScreenOn {@code true} to turn on the screen; {@code false} otherwise. * diff --git a/core/java/android/app/admin/DevicePolicyManagerInternal.java b/core/java/android/app/admin/DevicePolicyManagerInternal.java index a0d2977cf09a..01875eda2eca 100644 --- a/core/java/android/app/admin/DevicePolicyManagerInternal.java +++ b/core/java/android/app/admin/DevicePolicyManagerInternal.java @@ -16,6 +16,7 @@ package android.app.admin; +import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.UserIdInt; import android.content.ComponentName; @@ -77,6 +78,13 @@ public abstract class DevicePolicyManagerInternal { OnCrossProfileWidgetProvidersChangeListener listener); /** + * @param userHandle the handle of the user whose profile owner is being fetched. + * @return the configured supervision app if it exists and is the device owner or policy owner. + */ + public abstract @Nullable ComponentName getProfileOwnerOrDeviceOwnerSupervisionComponent( + @NonNull UserHandle userHandle); + + /** * Checks if an app with given uid is an active device owner of its user. * * <p>This takes the DPMS lock. DO NOT call from PM/UM/AM with their lock held. diff --git a/core/java/android/window/SplashScreenView.java b/core/java/android/window/SplashScreenView.java index acf20d701eeb..6a875d1be65d 100644 --- a/core/java/android/window/SplashScreenView.java +++ b/core/java/android/window/SplashScreenView.java @@ -316,7 +316,8 @@ public final class SplashScreenView extends FrameLayout { } private SurfaceView createSurfaceView(@NonNull SplashScreenView view) { - final SurfaceView surfaceView = new SurfaceView(view.getContext()); + final Context viewContext = view.getContext(); + final SurfaceView surfaceView = new SurfaceView(viewContext); surfaceView.setPadding(0, 0, 0, 0); surfaceView.setBackground(mIconBackground); if (mSurfacePackage == null) { @@ -326,10 +327,10 @@ public final class SplashScreenView extends FrameLayout { + Thread.currentThread().getId()); } - SurfaceControlViewHost viewHost = new SurfaceControlViewHost(mContext, - mContext.getDisplay(), + SurfaceControlViewHost viewHost = new SurfaceControlViewHost(viewContext, + viewContext.getDisplay(), surfaceView.getHostToken()); - ImageView imageView = new ImageView(mContext); + ImageView imageView = new ImageView(viewContext); imageView.setBackground(mIconDrawable); viewHost.setView(imageView, mIconSize, mIconSize); SurfaceControlViewHost.SurfacePackage surfacePackage = viewHost.getSurfacePackage(); diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/SplashscreenContentDrawer.java b/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/SplashscreenContentDrawer.java index 29326ec90e31..cdd745ff9794 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/SplashscreenContentDrawer.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/SplashscreenContentDrawer.java @@ -50,6 +50,7 @@ import android.os.Trace; import android.os.UserHandle; import android.util.ArrayMap; import android.util.Slog; +import android.view.ContextThemeWrapper; import android.view.SurfaceControl; import android.view.View; import android.window.SplashScreenView; @@ -299,6 +300,11 @@ public class SplashscreenContentDrawer { } } + /** Creates the wrapper with system theme to avoid unexpected styles from app. */ + ContextThemeWrapper createViewContextWrapper(Context appContext) { + return new ContextThemeWrapper(appContext, mContext.getTheme()); + } + /** The configuration of the splash screen window. */ public static class SplashScreenWindowAttrs { private int mWindowBgResId = 0; @@ -472,7 +478,8 @@ public class SplashscreenContentDrawer { } Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "fillViewWithIcon"); - final SplashScreenView.Builder builder = new SplashScreenView.Builder(mContext) + final ContextThemeWrapper wrapper = createViewContextWrapper(mContext); + final SplashScreenView.Builder builder = new SplashScreenView.Builder(wrapper) .setBackgroundColor(mThemeColor) .setOverlayDrawable(mOverlayDrawable) .setIconSize(iconSize) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/StartingSurfaceDrawer.java b/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/StartingSurfaceDrawer.java index 147f5e30f9d6..4dae63485f8c 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/StartingSurfaceDrawer.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/StartingSurfaceDrawer.java @@ -137,24 +137,11 @@ public class StartingSurfaceDrawer { private final SparseArray<SurfaceControlViewHost> mAnimatedSplashScreenSurfaceHosts = new SparseArray<>(1); - /** Obtain proper context for showing splash screen on the provided display. */ - private Context getDisplayContext(Context context, int displayId) { - if (displayId == DEFAULT_DISPLAY) { - // The default context fits. - return context; - } - - final Display targetDisplay = mDisplayManager.getDisplay(displayId); - if (targetDisplay == null) { - // Failed to obtain the non-default display where splash screen should be shown, - // lets not show at all. - return null; - } - - return context.createDisplayContext(targetDisplay); + private Display getDisplay(int displayId) { + return mDisplayManager.getDisplay(displayId); } - private int getSplashScreenTheme(int splashScreenThemeResId, ActivityInfo activityInfo) { + int getSplashScreenTheme(int splashScreenThemeResId, ActivityInfo activityInfo) { return splashScreenThemeResId != 0 ? splashScreenThemeResId : activityInfo.getThemeResource() != 0 ? activityInfo.getThemeResource() @@ -177,7 +164,7 @@ public class StartingSurfaceDrawer { final int displayId = taskInfo.displayId; final int taskId = taskInfo.taskId; - Context context = mContext; + // replace with the default theme if the application didn't set final int theme = getSplashScreenTheme(windowInfo.splashScreenThemeResId, activityInfo); if (DEBUG_SPLASH_SCREEN) { @@ -186,13 +173,16 @@ public class StartingSurfaceDrawer { + " suggestType=" + suggestType); } - // Obtain proper context to launch on the right display. - final Context displayContext = getDisplayContext(context, displayId); - if (displayContext == null) { + final Display display = getDisplay(displayId); + if (display == null) { // Can't show splash screen on requested display, so skip showing at all. return; } - context = displayContext; + Context context = displayId == DEFAULT_DISPLAY + ? mContext : mContext.createDisplayContext(display); + if (context == null) { + return; + } if (theme != context.getThemeResId()) { try { context = context.createPackageContextAsUser(activityInfo.packageName, @@ -303,7 +293,8 @@ public class StartingSurfaceDrawer { // Record whether create splash screen view success, notify to current thread after // create splash screen view finished. final SplashScreenViewSupplier viewSupplier = new SplashScreenViewSupplier(); - final FrameLayout rootLayout = new FrameLayout(context); + final FrameLayout rootLayout = new FrameLayout( + mSplashscreenContentDrawer.createViewContextWrapper(context)); rootLayout.setPadding(0, 0, 0, 0); rootLayout.setFitsSystemWindows(false); final Runnable setViewSynchronized = () -> { diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/startingsurface/StartingSurfaceDrawerTests.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/startingsurface/StartingSurfaceDrawerTests.java index eef0d9bb268f..18b8faf4dbe6 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/startingsurface/StartingSurfaceDrawerTests.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/startingsurface/StartingSurfaceDrawerTests.java @@ -30,6 +30,7 @@ import static org.junit.Assert.assertNotEquals; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -101,7 +102,6 @@ public class StartingSurfaceDrawerTests { static final class TestStartingSurfaceDrawer extends StartingSurfaceDrawer{ int mAddWindowForTask = 0; - int mViewThemeResId; TestStartingSurfaceDrawer(Context context, ShellExecutor splashScreenExecutor, TransactionPool pool) { @@ -113,7 +113,6 @@ public class StartingSurfaceDrawerTests { View view, WindowManager wm, WindowManager.LayoutParams params, int suggestType) { // listen for addView mAddWindowForTask = taskId; - mViewThemeResId = view.getContext().getThemeResId(); // Do not wait for background color return false; } @@ -183,12 +182,15 @@ public class StartingSurfaceDrawerTests { final int taskId = 1; final StartingWindowInfo windowInfo = createWindowInfo(taskId, 0); + final int[] theme = new int[1]; + doAnswer(invocation -> theme[0] = (Integer) invocation.callRealMethod()) + .when(mStartingSurfaceDrawer).getSplashScreenTheme(eq(0), any()); + mStartingSurfaceDrawer.addSplashScreenStartingWindow(windowInfo, mBinder, STARTING_WINDOW_TYPE_SPLASH_SCREEN); waitHandlerIdle(mTestHandler); - verify(mStartingSurfaceDrawer).addWindow(eq(taskId), eq(mBinder), any(), any(), any(), - eq(STARTING_WINDOW_TYPE_SPLASH_SCREEN)); - assertNotEquals(mStartingSurfaceDrawer.mViewThemeResId, 0); + verify(mStartingSurfaceDrawer).getSplashScreenTheme(eq(0), any()); + assertNotEquals(theme[0], 0); } @Test diff --git a/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java b/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java index e9c565377530..2c0b52638d2f 100644 --- a/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java +++ b/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java @@ -496,6 +496,9 @@ public class ScreenDecorations extends SystemUI implements Tunable { lp.privateFlags |= WindowManager.LayoutParams.SYSTEM_FLAG_SHOW_FOR_ALL_USERS | WindowManager.LayoutParams.PRIVATE_FLAG_NO_MOVE_ANIMATION; + // FLAG_SLIPPERY can only be set by trusted overlays + lp.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_TRUSTED_OVERLAY; + if (!DEBUG_SCREENSHOT_ROUNDED_CORNERS) { lp.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_IS_ROUNDED_CORNERS_OVERLAY; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/LightRevealScrim.kt b/packages/SystemUI/src/com/android/systemui/statusbar/LightRevealScrim.kt index bbee1942cfc4..21ed9da896a5 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/LightRevealScrim.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/LightRevealScrim.kt @@ -155,11 +155,6 @@ class LightRevealScrim(context: Context?, attrs: AttributeSet?) : View(context, lateinit var isScrimOpaqueChangedListener: Consumer<Boolean> /** - * A runnable to call when the scrim has been fully revealed. This is only invoked once - */ - var fullyRevealedRunnable: Runnable? = null - - /** * How much of the underlying views are revealed, in percent. 0 means they will be completely * obscured and 1 means they'll be fully visible. */ @@ -170,20 +165,10 @@ class LightRevealScrim(context: Context?, attrs: AttributeSet?) : View(context, revealEffect.setRevealAmountOnScrim(value, this) updateScrimOpaque() - maybeTriggerFullyRevealedRunnable() invalidate() } } - private fun maybeTriggerFullyRevealedRunnable() { - if (revealAmount == 1.0f) { - fullyRevealedRunnable?.let { - it.run() - fullyRevealedRunnable = null - } - } - } - /** * The [LightRevealEffect] used to manipulate the radial gradient whenever [revealAmount] * changes. diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShadeDepthController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShadeDepthController.kt index 98e6879d208f..2a8771e96e7b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShadeDepthController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShadeDepthController.kt @@ -37,6 +37,7 @@ import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dump.DumpManager import com.android.systemui.plugins.statusbar.StatusBarStateController import com.android.systemui.statusbar.phone.BiometricUnlockController +import com.android.systemui.statusbar.phone.BiometricUnlockController.MODE_WAKE_AND_UNLOCK import com.android.systemui.statusbar.phone.DozeParameters import com.android.systemui.statusbar.phone.PanelExpansionListener import com.android.systemui.statusbar.phone.ScrimController @@ -72,10 +73,6 @@ class NotificationShadeDepthController @Inject constructor( private const val TAG = "DepthController" } - /** - * Is did we already unblur while dozing? - */ - private var alreadyUnblurredWhileDozing = false lateinit var root: View private var blurRoot: View? = null private var keyguardAnimator: Animator? = null @@ -240,11 +237,9 @@ class NotificationShadeDepthController @Inject constructor( private val keyguardStateCallback = object : KeyguardStateController.Callback { override fun onKeyguardFadingAwayChanged() { if (!keyguardStateController.isKeyguardFadingAway || - !biometricUnlockController.isWakeAndUnlock) { + biometricUnlockController.mode != MODE_WAKE_AND_UNLOCK) { return } - // When wakeAndUnlocking the screen remains dozing, so we have to manually trigger - // the unblur earlier keyguardAnimator?.cancel() keyguardAnimator = ValueAnimator.ofFloat(1f, 0f).apply { @@ -266,7 +261,6 @@ class NotificationShadeDepthController @Inject constructor( }) start() } - alreadyUnblurredWhileDozing = statusBarStateController.dozeAmount != 0.0f } override fun onKeyguardShowingChanged() { @@ -288,24 +282,10 @@ class NotificationShadeDepthController @Inject constructor( if (isDozing) { shadeAnimation.finishIfRunning() brightnessMirrorSpring.finishIfRunning() - - // unset this for safety, to be ready for the next wakeup - alreadyUnblurredWhileDozing = false } } override fun onDozeAmountChanged(linear: Float, eased: Float) { - if (alreadyUnblurredWhileDozing) { - if (linear == 0.0f) { - // We finished waking up, let's reset - alreadyUnblurredWhileDozing = false - } else { - // We've already handled the unbluring from the keyguardAnimator above. - // if we would continue, we'd play another unzoom / blur animation from the - // dozing changing. - return - } - } wakeAndUnlockBlurRadius = blurUtils.blurRadiusOfRatio(eased) scheduleUpdate() } @@ -463,7 +443,6 @@ class NotificationShadeDepthController @Inject constructor( it.println("blursDisabledForAppLaunch: $blursDisabledForAppLaunch") it.println("qsPanelExpansion: $qsPanelExpansion") it.println("transitionToFullShadeProgress: $transitionToFullShadeProgress") - it.println("alreadyUnblurredWhileDozing: $alreadyUnblurredWhileDozing") it.println("lastAppliedBlur: $lastAppliedBlur") } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java index 6cf1d82149ce..88434cc214be 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java @@ -360,7 +360,6 @@ public class StatusBar extends SystemUI implements DemoMode, } private LockscreenShadeTransitionController mLockscreenShadeTransitionController; - private boolean mCallingFadingAwayAfterReveal; public interface ExpansionChangedListener { void onExpansionChanged(float expansion, boolean expanded); @@ -640,7 +639,7 @@ public class StatusBar extends SystemUI implements DemoMode, + "mStatusBarKeyguardViewManager was null"); return; } - if (mKeyguardStateController.isKeyguardFadingAway() && !mCallingFadingAwayAfterReveal) { + if (mKeyguardStateController.isKeyguardFadingAway()) { mStatusBarKeyguardViewManager.onKeyguardFadedAway(); } } @@ -3584,19 +3583,8 @@ public class StatusBar extends SystemUI implements DemoMode, public void fadeKeyguardWhilePulsing() { mNotificationPanelViewController.fadeOut(0, FADE_KEYGUARD_DURATION_PULSING, ()-> { - Runnable finishFading = () -> { - mCallingFadingAwayAfterReveal = false; - hideKeyguard(); - mStatusBarKeyguardViewManager.onKeyguardFadedAway(); - }; - if (mLightRevealScrim.getRevealAmount() != 1.0f) { - mCallingFadingAwayAfterReveal = true; - // we're still revealing the Light reveal, let's only go to keyguard once - // Going there introduces lots of jank - mLightRevealScrim.setFullyRevealedRunnable(finishFading); - } else { - finishFading.run(); - } + hideKeyguard(); + mStatusBarKeyguardViewManager.onKeyguardFadedAway(); }).start(); } diff --git a/services/core/java/com/android/server/wm/DisplayPolicy.java b/services/core/java/com/android/server/wm/DisplayPolicy.java index d0457b08aa34..b87d6f4fdf57 100644 --- a/services/core/java/com/android/server/wm/DisplayPolicy.java +++ b/services/core/java/com/android/server/wm/DisplayPolicy.java @@ -56,6 +56,7 @@ import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR; import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN; import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS; import static android.view.WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE; +import static android.view.WindowManager.LayoutParams.FLAG_SLIPPERY; import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS; import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT; import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES; @@ -848,6 +849,20 @@ public class DisplayPolicy { } /** + * Only trusted overlays are allowed to use FLAG_SLIPPERY. + */ + static int sanitizeFlagSlippery(int flags, int privateFlags, String name) { + if ((flags & FLAG_SLIPPERY) == 0) { + return flags; + } + if ((privateFlags & PRIVATE_FLAG_TRUSTED_OVERLAY) != 0) { + return flags; + } + Slog.w(TAG, "Removing FLAG_SLIPPERY for non-trusted overlay " + name); + return flags & ~FLAG_SLIPPERY; + } + + /** * Sanitize the layout parameters coming from a client. Allows the policy * to do things like ensure that windows of a specific type can't take * input focus. @@ -927,6 +942,8 @@ public class DisplayPolicy { if (mExtraNavBarAlt == win) { mExtraNavBarAltPosition = getAltBarPosition(attrs); } + + attrs.flags = sanitizeFlagSlippery(attrs.flags, attrs.privateFlags, win.getName()); } /** diff --git a/services/core/java/com/android/server/wm/KeyguardController.java b/services/core/java/com/android/server/wm/KeyguardController.java index cf0f973fa7db..054854aef121 100644 --- a/services/core/java/com/android/server/wm/KeyguardController.java +++ b/services/core/java/com/android/server/wm/KeyguardController.java @@ -190,8 +190,7 @@ class KeyguardController { if (keyguardChanged) { // Irrelevant to AOD. - dismissMultiWindowModeForTaskIfNeeded(null /* currentTaskControllsingOcclusion */, - false /* turningScreenOn */); + dismissMultiWindowModeForTaskIfNeeded(null /* currentTaskControllsingOcclusion */); mKeyguardGoingAway = false; if (keyguardShowing) { mDismissalRequested = false; @@ -385,6 +384,8 @@ class KeyguardController { mService.continueWindowLayout(); } } + dismissMultiWindowModeForTaskIfNeeded(topActivity != null + ? topActivity.getRootTask() : null); } /** @@ -410,21 +411,6 @@ class KeyguardController { } } - /** - * Called when somebody wants to turn screen on. - */ - private void handleTurnScreenOn(int displayId) { - if (displayId != DEFAULT_DISPLAY) { - return; - } - - mTaskSupervisor.wakeUp("handleTurnScreenOn"); - if (mKeyguardShowing && canDismissKeyguard()) { - mWindowManager.dismissKeyguard(null /* callback */, null /* message */); - mDismissalRequested = true; - } - } - boolean isDisplayOccluded(int displayId) { return getDisplayState(displayId).mOccluded; } @@ -438,11 +424,9 @@ class KeyguardController { } private void dismissMultiWindowModeForTaskIfNeeded( - @Nullable Task currentTaskControllingOcclusion, boolean turningScreenOn) { - // If turningScreenOn is true, it means that the visibility state has changed from - // currentTaskControllingOcclusion and we should update windowing mode. + @Nullable Task currentTaskControllingOcclusion) { // TODO(b/113840485): Handle docked stack for individual display. - if (!turningScreenOn && (!mKeyguardShowing || !isDisplayOccluded(DEFAULT_DISPLAY))) { + if (!mKeyguardShowing || !isDisplayOccluded(DEFAULT_DISPLAY)) { return; } @@ -581,26 +565,17 @@ class KeyguardController { && controller.mWindowManager.isKeyguardSecure( controller.mService.getCurrentUserId()); - boolean occludingChange = false; - boolean turningScreenOn = false; if (mTopTurnScreenOnActivity != lastTurnScreenOnActivity && mTopTurnScreenOnActivity != null && !mService.mWindowManager.mPowerManager.isInteractive() - && (mRequestDismissKeyguard || occludedByActivity - || controller.canDismissKeyguard())) { - turningScreenOn = true; - controller.handleTurnScreenOn(mDisplayId); + && (mRequestDismissKeyguard || occludedByActivity)) { + controller.mTaskSupervisor.wakeUp("handleTurnScreenOn"); mTopTurnScreenOnActivity.setCurrentLaunchCanTurnScreenOn(false); } if (lastOccluded != mOccluded) { - occludingChange = true; controller.handleOccludedChanged(mDisplayId, mTopOccludesActivity); } - - if (occludingChange || turningScreenOn) { - controller.dismissMultiWindowModeForTaskIfNeeded(task, turningScreenOn); - } } /** diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index e3ff9e75dbd8..dd515db6337a 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -56,6 +56,7 @@ import static android.view.WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; import static android.view.WindowManager.LayoutParams.FLAG_SECURE; import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER; import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED; +import static android.view.WindowManager.LayoutParams.FLAG_SLIPPERY; import static android.view.WindowManager.LayoutParams.INPUT_FEATURE_NO_INPUT_CHANNEL; import static android.view.WindowManager.LayoutParams.INVALID_WINDOW_TYPE; import static android.view.WindowManager.LayoutParams.LAST_APPLICATION_WINDOW; @@ -8223,8 +8224,10 @@ public class WindowManagerService extends IWindowManager.Stub h.token = channelToken; h.name = name; + flags = DisplayPolicy.sanitizeFlagSlippery(flags, privateFlags, name); + final int sanitizedFlags = flags & (LayoutParams.FLAG_NOT_TOUCHABLE - | LayoutParams.FLAG_SLIPPERY | LayoutParams.FLAG_NOT_FOCUSABLE); + | FLAG_SLIPPERY | LayoutParams.FLAG_NOT_FOCUSABLE); h.layoutParamsFlags = WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | sanitizedFlags; h.layoutParamsType = type; h.dispatchingTimeoutMillis = DEFAULT_DISPATCHING_TIMEOUT_MILLIS; diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index d48c9ea4831c..99e28d101496 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -12647,6 +12647,13 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { } @Override + public @Nullable ComponentName getProfileOwnerOrDeviceOwnerSupervisionComponent( + @NonNull UserHandle userHandle) { + return DevicePolicyManagerService.this.getProfileOwnerOrDeviceOwnerSupervisionComponent( + userHandle); + } + + @Override public boolean isActiveDeviceOwner(int uid) { return isDeviceOwner(new CallerIdentity(uid, null, null)); } diff --git a/services/tests/mockingservicestests/src/com/android/server/usage/UserUsageStatsServiceTest.java b/services/tests/mockingservicestests/src/com/android/server/usage/UserUsageStatsServiceTest.java index 24c58f49bed6..7358551d1bc5 100644 --- a/services/tests/mockingservicestests/src/com/android/server/usage/UserUsageStatsServiceTest.java +++ b/services/tests/mockingservicestests/src/com/android/server/usage/UserUsageStatsServiceTest.java @@ -72,7 +72,7 @@ public class UserUsageStatsServiceTest { HashMap<String, Long> installedPkgs = new HashMap<>(); installedPkgs.put(TEST_PACKAGE_NAME, System.currentTimeMillis()); - mService.init(System.currentTimeMillis(), installedPkgs); + mService.init(System.currentTimeMillis(), installedPkgs, true); } @After diff --git a/services/usage/java/com/android/server/usage/UsageStatsService.java b/services/usage/java/com/android/server/usage/UsageStatsService.java index 1b8492722c10..ac1fcce20dc0 100644 --- a/services/usage/java/com/android/server/usage/UsageStatsService.java +++ b/services/usage/java/com/android/server/usage/UsageStatsService.java @@ -380,6 +380,7 @@ public class UsageStatsService extends SystemService implements if (userId == UserHandle.USER_SYSTEM) { UsageStatsIdleService.scheduleUpdateMappingsJob(getContext()); } + final boolean deleteObsoleteData = shouldDeleteObsoleteData(UserHandle.of(userId)); synchronized (mLock) { // This should be safe to add this early. Other than reportEventOrAddToQueue, every // other user grabs the lock before accessing @@ -402,7 +403,7 @@ public class UsageStatsService extends SystemService implements boolean needToFlush = !pendingEvents.isEmpty(); initializeUserUsageStatsServiceLocked(userId, System.currentTimeMillis(), - installedPackages); + installedPackages, deleteObsoleteData); final UserUsageStatsService userService = getUserUsageStatsServiceLocked(userId); if (userService == null) { Slog.i(TAG, "Attempted to unlock stopped or removed user " + userId); @@ -596,13 +597,13 @@ public class UsageStatsService extends SystemService implements * when the user is initially unlocked. */ private void initializeUserUsageStatsServiceLocked(int userId, long currentTimeMillis, - HashMap<String, Long> installedPackages) { + HashMap<String, Long> installedPackages, boolean deleteObsoleteData) { final File usageStatsDir = new File(Environment.getDataSystemCeDirectory(userId), "usagestats"); final UserUsageStatsService service = new UserUsageStatsService(getContext(), userId, usageStatsDir, this); try { - service.init(currentTimeMillis, installedPackages); + service.init(currentTimeMillis, installedPackages, deleteObsoleteData); mUserState.put(userId, service); } catch (Exception e) { if (mUserManager.isUserUnlocked(userId)) { @@ -1165,6 +1166,10 @@ public class UsageStatsService extends SystemService implements * Called by the Binder stub. */ private boolean updatePackageMappingsData() { + // don't update the mappings if a profile user is defined + if (!shouldDeleteObsoleteData(UserHandle.SYSTEM)) { + return true; // return true so job scheduler doesn't reschedule the job + } // fetch the installed packages outside the lock so it doesn't block package manager. final HashMap<String, Long> installedPkgs = getInstalledPackages(UserHandle.USER_SYSTEM); synchronized (mLock) { @@ -1309,6 +1314,13 @@ public class UsageStatsService extends SystemService implements } } + private boolean shouldDeleteObsoleteData(UserHandle userHandle) { + final DevicePolicyManagerInternal dpmInternal = getDpmInternal(); + // If a profile owner is not defined for the given user, obsolete data should be deleted + return dpmInternal == null + || dpmInternal.getProfileOwnerOrDeviceOwnerSupervisionComponent(userHandle) == null; + } + private String buildFullToken(String packageName, String token) { final StringBuilder sb = new StringBuilder(packageName.length() + token.length() + 1); sb.append(packageName); @@ -2532,8 +2544,12 @@ public class UsageStatsService extends SystemService implements private class MyPackageMonitor extends PackageMonitor { @Override public void onPackageRemoved(String packageName, int uid) { - mHandler.obtainMessage(MSG_PACKAGE_REMOVED, getChangingUserId(), 0, packageName) - .sendToTarget(); + final int changingUserId = getChangingUserId(); + // Only remove the package's data if a profile owner is not defined for the user + if (shouldDeleteObsoleteData(UserHandle.of(changingUserId))) { + mHandler.obtainMessage(MSG_PACKAGE_REMOVED, changingUserId, 0, packageName) + .sendToTarget(); + } super.onPackageRemoved(packageName, uid); } } diff --git a/services/usage/java/com/android/server/usage/UserUsageStatsService.java b/services/usage/java/com/android/server/usage/UserUsageStatsService.java index 36d8c857ca21..fee4a47fd6ff 100644 --- a/services/usage/java/com/android/server/usage/UserUsageStatsService.java +++ b/services/usage/java/com/android/server/usage/UserUsageStatsService.java @@ -115,8 +115,9 @@ class UserUsageStatsService { mSystemTimeSnapshot = System.currentTimeMillis(); } - void init(final long currentTimeMillis, HashMap<String, Long> installedPackages) { - readPackageMappingsLocked(installedPackages); + void init(final long currentTimeMillis, HashMap<String, Long> installedPackages, + boolean deleteObsoleteData) { + readPackageMappingsLocked(installedPackages, deleteObsoleteData); mDatabase.init(currentTimeMillis); if (mDatabase.wasUpgradePerformed()) { mDatabase.prunePackagesDataOnUpgrade(installedPackages); @@ -180,12 +181,13 @@ class UserUsageStatsService { return mDatabase.onPackageRemoved(packageName, timeRemoved); } - private void readPackageMappingsLocked(HashMap<String, Long> installedPackages) { + private void readPackageMappingsLocked(HashMap<String, Long> installedPackages, + boolean deleteObsoleteData) { mDatabase.readMappingsLocked(); // Package mappings for the system user are updated after 24 hours via a job scheduled by // UsageStatsIdleService to ensure restored data is not lost on first boot. Additionally, // this makes user service initialization a little quicker on subsequent boots. - if (mUserId != UserHandle.USER_SYSTEM) { + if (mUserId != UserHandle.USER_SYSTEM && deleteObsoleteData) { updatePackageMappingsLocked(installedPackages); } } |