Merge "Disable failing PipRotationTest_ShellTransit"
diff --git a/core/java/android/hardware/camera2/params/MandatoryStreamCombination.java b/core/java/android/hardware/camera2/params/MandatoryStreamCombination.java
index e5b9cdb..26415d3 100644
--- a/core/java/android/hardware/camera2/params/MandatoryStreamCombination.java
+++ b/core/java/android/hardware/camera2/params/MandatoryStreamCombination.java
@@ -920,15 +920,15 @@
         // UH res YUV / RAW / JPEG + YUV preview size stream
         new StreamCombinationTemplate(new StreamTemplate [] {
                 new StreamTemplate(ImageFormat.YUV_420_888, SizeThreshold.FULL_RES),
-                 new StreamTemplate(ImageFormat.PRIVATE, SizeThreshold.PREVIEW)},
+                new StreamTemplate(ImageFormat.YUV_420_888, SizeThreshold.PREVIEW)},
                 "No-viewfinder Ultra high resolution YUV image capture with image analysis"),
         new StreamCombinationTemplate(new StreamTemplate [] {
                 new StreamTemplate(ImageFormat.RAW_SENSOR, SizeThreshold.FULL_RES),
-                new StreamTemplate(ImageFormat.PRIVATE, SizeThreshold.PREVIEW)},
+                new StreamTemplate(ImageFormat.YUV_420_888, SizeThreshold.PREVIEW)},
                 "No-viewfinder Ultra high resolution RAW_SENSOR image capture with image analysis"),
         new StreamCombinationTemplate(new StreamTemplate [] {
                 new StreamTemplate(ImageFormat.JPEG, SizeThreshold.FULL_RES),
-                new StreamTemplate(ImageFormat.PRIVATE, SizeThreshold.PREVIEW)},
+                new StreamTemplate(ImageFormat.YUV_420_888, SizeThreshold.PREVIEW)},
                 "No-viewfinder Ultra high resolution JPEG image capture with image analysis"),
 
         // UH res YUV / RAW / JPEG + PRIV preview + PRIV RECORD stream
diff --git a/core/java/android/service/notification/NotificationListenerService.java b/core/java/android/service/notification/NotificationListenerService.java
index 02176b0..fb52ed2 100644
--- a/core/java/android/service/notification/NotificationListenerService.java
+++ b/core/java/android/service/notification/NotificationListenerService.java
@@ -261,6 +261,10 @@
     /**
      * Notification was canceled when entering lockdown mode, which turns off
      * Smart Lock, fingerprint unlocking, and notifications on the lock screen.
+     * All the listeners shall ensure the canceled notifications are indeed removed
+     * on their end to prevent data leaking.
+     * When the user exits the lockdown mode, the removed notifications (due to lockdown)
+     * will be restored via NotificationListeners#notifyPostedLocked()
      */
     public static final int REASON_LOCKDOWN = 23;
 
diff --git a/core/java/android/view/inputmethod/IInputMethodManagerInvoker.java b/core/java/android/view/inputmethod/IInputMethodManagerInvoker.java
index 60edf35..d21ceb2 100644
--- a/core/java/android/view/inputmethod/IInputMethodManagerInvoker.java
+++ b/core/java/android/view/inputmethod/IInputMethodManagerInvoker.java
@@ -182,9 +182,9 @@
 
     @AnyThread
     @Nullable
-    InputMethodSubtype getCurrentInputMethodSubtype() {
+    InputMethodSubtype getCurrentInputMethodSubtype(@UserIdInt int userId) {
         try {
-            return mTarget.getCurrentInputMethodSubtype();
+            return mTarget.getCurrentInputMethodSubtype(userId);
         } catch (RemoteException e) {
             throw e.rethrowFromSystemServer();
         }
diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java
index 8ce134e7..e7abbbc 100644
--- a/core/java/android/view/inputmethod/InputMethodManager.java
+++ b/core/java/android/view/inputmethod/InputMethodManager.java
@@ -3374,7 +3374,7 @@
      */
     @Nullable
     public InputMethodSubtype getCurrentInputMethodSubtype() {
-        return mServiceInvoker.getCurrentInputMethodSubtype();
+        return mServiceInvoker.getCurrentInputMethodSubtype(UserHandle.myUserId());
     }
 
     /**
diff --git a/core/java/com/android/internal/view/IInputMethodManager.aidl b/core/java/com/android/internal/view/IInputMethodManager.aidl
index eb8b860..d5f8352 100644
--- a/core/java/com/android/internal/view/IInputMethodManager.aidl
+++ b/core/java/com/android/internal/view/IInputMethodManager.aidl
@@ -88,7 +88,10 @@
             + "android.Manifest.permission.TEST_INPUT_METHOD)")
     boolean isInputMethodPickerShownForTest();
 
-    @nullable InputMethodSubtype getCurrentInputMethodSubtype();
+    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = "
+            + "android.Manifest.permission.INTERACT_ACROSS_USERS_FULL, conditional = true)")
+    @nullable InputMethodSubtype getCurrentInputMethodSubtype(int userId);
+
     void setAdditionalInputMethodSubtypes(String id, in InputMethodSubtype[] subtypes);
     // This is kept due to @UnsupportedAppUsage.
     // TODO(Bug 113914148): Consider removing this.
diff --git a/libs/hwui/thread/WorkQueue.h b/libs/hwui/thread/WorkQueue.h
index 46b8bc0..f2751d2 100644
--- a/libs/hwui/thread/WorkQueue.h
+++ b/libs/hwui/thread/WorkQueue.h
@@ -57,7 +57,7 @@
 
 public:
     WorkQueue(std::function<void()>&& wakeFunc, std::mutex& lock)
-            : mWakeFunc(move(wakeFunc)), mLock(lock) {}
+            : mWakeFunc(std::move(wakeFunc)), mLock(lock) {}
 
     void process() {
         auto now = clock::now();
diff --git a/services/core/java/com/android/server/display/DisplayDevice.java b/services/core/java/com/android/server/display/DisplayDevice.java
index 76d71e2..e53aef7 100644
--- a/services/core/java/com/android/server/display/DisplayDevice.java
+++ b/services/core/java/com/android/server/display/DisplayDevice.java
@@ -30,8 +30,8 @@
 import java.io.PrintWriter;
 
 /**
- * Represents a physical display device such as the built-in display
- * an external monitor, or a WiFi display.
+ * Represents a display device such as the built-in display, an external monitor, a WiFi display,
+ * or a {@link android.hardware.display.VirtualDisplay}.
  * <p>
  * Display devices are guarded by the {@link DisplayManagerService.SyncRoot} lock.
  * </p>
diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
index bbf9410..af95b4f 100644
--- a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
+++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
@@ -1765,8 +1765,7 @@
         mLastSwitchUserId = userId;
 
         // mSettings should be created before buildInputMethodListLocked
-        mSettings = new InputMethodSettings(
-                mRes, context.getContentResolver(), mMethodMap, userId, !mSystemReady);
+        mSettings = new InputMethodSettings(mContext, mMethodMap, userId, !mSystemReady);
 
         updateCurrentProfileIds();
         AdditionalSubtypeUtils.load(mAdditionalSubtypeMap, userId);
@@ -2138,8 +2137,8 @@
             //TODO(b/197848765): This can be optimized by caching multi-user methodMaps/methodList.
             //TODO(b/210039666): use cache.
             final ArrayMap<String, InputMethodInfo> methodMap = queryMethodMapForUser(userId);
-            final InputMethodSettings settings = new InputMethodSettings(mContext.getResources(),
-                    mContext.getContentResolver(), methodMap, userId, true);
+            final InputMethodSettings settings = new InputMethodSettings(mContext, methodMap,
+                    userId, true);
             final InputMethodInfo imi = methodMap.get(settings.getSelectedInputMethod());
             return imi != null && imi.supportsStylusHandwriting();
         }
@@ -2171,8 +2170,8 @@
             return mSettings.getEnabledInputMethodListLocked();
         }
         final ArrayMap<String, InputMethodInfo> methodMap = queryMethodMapForUser(userId);
-        final InputMethodSettings settings = new InputMethodSettings(mContext.getResources(),
-                mContext.getContentResolver(), methodMap, userId, true);
+        final InputMethodSettings settings = new InputMethodSettings(mContext, methodMap, userId,
+                true);
         return settings.getEnabledInputMethodListLocked();
     }
 
@@ -2237,17 +2236,17 @@
                 return Collections.emptyList();
             }
             return mSettings.getEnabledInputMethodSubtypeListLocked(
-                    mContext, imi, allowsImplicitlySelectedSubtypes);
+                    imi, allowsImplicitlySelectedSubtypes);
         }
         final ArrayMap<String, InputMethodInfo> methodMap = queryMethodMapForUser(userId);
         final InputMethodInfo imi = methodMap.get(imiId);
         if (imi == null) {
             return Collections.emptyList();
         }
-        final InputMethodSettings settings = new InputMethodSettings(mContext.getResources(),
-                mContext.getContentResolver(), methodMap, userId, true);
+        final InputMethodSettings settings = new InputMethodSettings(mContext, methodMap, userId,
+                true);
         return settings.getEnabledInputMethodSubtypeListLocked(
-                mContext, imi, allowsImplicitlySelectedSubtypes);
+                imi, allowsImplicitlySelectedSubtypes);
     }
 
     /**
@@ -3066,7 +3065,7 @@
         for (int i = 0; i < numImes; ++i) {
             final InputMethodInfo imi = imes.get(i);
             final List<InputMethodSubtype> subtypes =
-                    mSettings.getEnabledInputMethodSubtypeListLocked(mContext, imi, true);
+                    mSettings.getEnabledInputMethodSubtypeListLocked(imi, true);
             final int subtypeCount = subtypes.size();
             if (subtypeCount == 0) {
                 ++nonAuxCount;
@@ -4155,8 +4154,7 @@
             }
 
             final ArrayMap<String, InputMethodInfo> methodMap = queryMethodMapForUser(userId);
-            final InputMethodSettings settings = new InputMethodSettings(
-                    mContext.getResources(), mContext.getContentResolver(), methodMap,
+            final InputMethodSettings settings = new InputMethodSettings(mContext, methodMap,
                     userId, false);
             return settings.getLastInputMethodSubtypeLocked();
         }
@@ -5286,18 +5284,38 @@
 
     /**
      * Gets the current subtype of this input method.
+     *
+     * @param userId User ID to be queried about.
+     * @return The current {@link InputMethodSubtype} for the specified user.
      */
+    @Nullable
     @Override
-    public InputMethodSubtype getCurrentInputMethodSubtype() {
+    public InputMethodSubtype getCurrentInputMethodSubtype(@UserIdInt int userId) {
+        if (UserHandle.getCallingUserId() != userId) {
+            mContext.enforceCallingPermission(Manifest.permission.INTERACT_ACROSS_USERS_FULL, null);
+        }
         synchronized (ImfLock.class) {
-            // TODO: Make this work even for non-current users?
-            if (!calledFromValidUserLocked()) {
-                return null;
+            if (mSettings.getCurrentUserId() == userId) {
+                return getCurrentInputMethodSubtypeLocked();
             }
-            return getCurrentInputMethodSubtypeLocked();
+
+            final ArrayMap<String, InputMethodInfo> methodMap = queryMethodMapForUser(userId);
+            final InputMethodSettings settings = new InputMethodSettings(mContext, methodMap,
+                    userId, false);
+            return settings.getCurrentInputMethodSubtypeForNonCurrentUsers();
         }
     }
 
+    /**
+     * Returns the current {@link InputMethodSubtype} for the current user.
+     *
+     * <p>CAVEATS: You must also update
+     * {@link InputMethodSettings#getCurrentInputMethodSubtypeForNonCurrentUsers()}
+     * when you update the algorithm of this method.</p>
+     *
+     * <p>TODO: Address code duplication between this and
+     * {@link InputMethodSettings#getCurrentInputMethodSubtypeForNonCurrentUsers()}.</p>
+     */
     @GuardedBy("ImfLock.class")
     InputMethodSubtype getCurrentInputMethodSubtypeLocked() {
         String selectedMethodId = getSelectedMethodIdLocked();
@@ -5317,7 +5335,7 @@
                 // the most applicable subtype from explicitly or implicitly enabled
                 // subtypes.
                 List<InputMethodSubtype> explicitlyOrImplicitlyEnabledSubtypes =
-                        mSettings.getEnabledInputMethodSubtypeListLocked(mContext, imi, true);
+                        mSettings.getEnabledInputMethodSubtypeListLocked(imi, true);
                 // If there is only one explicitly or implicitly enabled subtype,
                 // just returns it.
                 if (explicitlyOrImplicitlyEnabledSubtypes.size() == 1) {
@@ -5361,9 +5379,8 @@
             return true;
         }
         final ArrayMap<String, InputMethodInfo> methodMap = queryMethodMapForUser(userId);
-        final InputMethodSettings settings = new InputMethodSettings(
-                mContext.getResources(), mContext.getContentResolver(), methodMap,
-                userId, false);
+        final InputMethodSettings settings = new InputMethodSettings(mContext, methodMap, userId,
+                false);
         if (!methodMap.containsKey(imeId)
                 || !settings.getEnabledInputMethodListLocked().contains(methodMap.get(imeId))) {
             return false; // IME is not found or not enabled.
@@ -5435,8 +5452,7 @@
                     return true;
                 }
                 final ArrayMap<String, InputMethodInfo> methodMap = queryMethodMapForUser(userId);
-                final InputMethodSettings settings = new InputMethodSettings(
-                        mContext.getResources(), mContext.getContentResolver(), methodMap,
+                final InputMethodSettings settings = new InputMethodSettings(mContext, methodMap,
                         userId, false);
                 if (!methodMap.containsKey(imeId)) {
                     return false; // IME is not found.
@@ -6138,8 +6154,8 @@
             }
         } else {
             final ArrayMap<String, InputMethodInfo> methodMap = queryMethodMapForUser(userId);
-            final InputMethodSettings settings = new InputMethodSettings(mContext.getResources(),
-                    mContext.getContentResolver(), methodMap, userId, false);
+            final InputMethodSettings settings = new InputMethodSettings(mContext, methodMap,
+                    userId, false);
             if (enabled) {
                 if (!methodMap.containsKey(imeId)) {
                     failedToEnableUnknownIme = true;
@@ -6275,9 +6291,8 @@
                         AdditionalSubtypeUtils.load(additionalSubtypeMap, userId);
                         queryInputMethodServicesInternal(mContext, userId, additionalSubtypeMap,
                                 methodMap, methodList, DirectBootAwareness.AUTO);
-                        final InputMethodSettings settings = new InputMethodSettings(
-                                mContext.getResources(), mContext.getContentResolver(), methodMap,
-                                userId, false);
+                        final InputMethodSettings settings = new InputMethodSettings(mContext,
+                                methodMap, userId, false);
 
                         nextEnabledImes = InputMethodInfoUtils.getDefaultEnabledImes(mContext,
                                 methodList);
diff --git a/services/core/java/com/android/server/inputmethod/InputMethodSubtypeSwitchingController.java b/services/core/java/com/android/server/inputmethod/InputMethodSubtypeSwitchingController.java
index a643226..c83a969 100644
--- a/services/core/java/com/android/server/inputmethod/InputMethodSubtypeSwitchingController.java
+++ b/services/core/java/com/android/server/inputmethod/InputMethodSubtypeSwitchingController.java
@@ -200,7 +200,7 @@
                     continue;
                 }
                 final List<InputMethodSubtype> explicitlyOrImplicitlyEnabledSubtypeList =
-                        mSettings.getEnabledInputMethodSubtypeListLocked(mContext, imi, true);
+                        mSettings.getEnabledInputMethodSubtypeListLocked(imi, true);
                 final ArraySet<String> enabledSubtypeSet = new ArraySet<>();
                 for (InputMethodSubtype subtype : explicitlyOrImplicitlyEnabledSubtypeList) {
                     enabledSubtypeSet.add(String.valueOf(subtype.hashCode()));
diff --git a/services/core/java/com/android/server/inputmethod/InputMethodUtils.java b/services/core/java/com/android/server/inputmethod/InputMethodUtils.java
index 5e20dfb..dd43e90 100644
--- a/services/core/java/com/android/server/inputmethod/InputMethodUtils.java
+++ b/services/core/java/com/android/server/inputmethod/InputMethodUtils.java
@@ -233,6 +233,7 @@
      * TODO: Move all putters and getters of settings to this class.
      * TODO(b/235661780): Make the setting supports multi-users.
      */
+    @UserHandleAware
     public static class InputMethodSettings {
         private final TextUtils.SimpleStringSplitter mInputMethodSplitter =
                 new TextUtils.SimpleStringSplitter(INPUT_METHOD_SEPARATOR);
@@ -240,6 +241,8 @@
         private final TextUtils.SimpleStringSplitter mSubtypeSplitter =
                 new TextUtils.SimpleStringSplitter(INPUT_METHOD_SUBTYPE_SEPARATOR);
 
+        @NonNull
+        private final Context mUserAwareContext;
         private final Resources mRes;
         private final ContentResolver mResolver;
         private final ArrayMap<String, InputMethodInfo> mMethodMap;
@@ -299,11 +302,14 @@
             return imsList;
         }
 
-        InputMethodSettings(Resources res, ContentResolver resolver,
+        InputMethodSettings(@NonNull Context context,
                 ArrayMap<String, InputMethodInfo> methodMap, @UserIdInt int userId,
                 boolean copyOnWrite) {
-            mRes = res;
-            mResolver = resolver;
+            mUserAwareContext = context.getUserId() == userId
+                    ? context
+                    : context.createContextAsUser(UserHandle.of(userId), 0 /* flags */);
+            mRes = mUserAwareContext.getResources();
+            mResolver = mUserAwareContext.getContentResolver();
             mMethodMap = methodMap;
             switchCurrentUser(userId, copyOnWrite);
         }
@@ -405,12 +411,11 @@
         }
 
         List<InputMethodSubtype> getEnabledInputMethodSubtypeListLocked(
-                Context context, InputMethodInfo imi, boolean allowsImplicitlySelectedSubtypes) {
+                InputMethodInfo imi, boolean allowsImplicitlySelectedSubtypes) {
             List<InputMethodSubtype> enabledSubtypes =
                     getEnabledInputMethodSubtypeListLocked(imi);
             if (allowsImplicitlySelectedSubtypes && enabledSubtypes.isEmpty()) {
-                enabledSubtypes = SubtypeUtils.getImplicitlyApplicableSubtypesLocked(
-                        context.getResources(), imi);
+                enabledSubtypes = SubtypeUtils.getImplicitlyApplicableSubtypesLocked(mRes, imi);
             }
             return InputMethodSubtype.sort(imi, enabledSubtypes);
         }
@@ -813,6 +818,56 @@
             }
         }
 
+        /**
+         * A variant of {@link InputMethodManagerService#getCurrentInputMethodSubtypeLocked()} for
+         * non-current users.
+         *
+         * <p>TODO: Address code duplication between this and
+         * {@link InputMethodManagerService#getCurrentInputMethodSubtypeLocked()}.</p>
+         *
+         * @return {@link InputMethodSubtype} if exists. {@code null} otherwise.
+         */
+        @Nullable
+        InputMethodSubtype getCurrentInputMethodSubtypeForNonCurrentUsers() {
+            final String selectedMethodId = getSelectedInputMethod();
+            if (selectedMethodId == null) {
+                return null;
+            }
+            final InputMethodInfo imi = mMethodMap.get(selectedMethodId);
+            if (imi == null || imi.getSubtypeCount() == 0) {
+                return null;
+            }
+
+            final int subtypeHashCode = getSelectedInputMethodSubtypeHashCode();
+            if (subtypeHashCode != InputMethodUtils.NOT_A_SUBTYPE_ID) {
+                final int subtypeIndex = SubtypeUtils.getSubtypeIdFromHashCode(imi,
+                        subtypeHashCode);
+                if (subtypeIndex >= 0) {
+                    return imi.getSubtypeAt(subtypeIndex);
+                }
+            }
+
+            // If there are no selected subtypes, the framework will try to find the most applicable
+            // subtype from explicitly or implicitly enabled subtypes.
+            final List<InputMethodSubtype> explicitlyOrImplicitlyEnabledSubtypes =
+                    getEnabledInputMethodSubtypeListLocked(imi, true);
+            // If there is only one explicitly or implicitly enabled subtype, just returns it.
+            if (explicitlyOrImplicitlyEnabledSubtypes.isEmpty()) {
+                return null;
+            }
+            if (explicitlyOrImplicitlyEnabledSubtypes.size() == 1) {
+                return explicitlyOrImplicitlyEnabledSubtypes.get(0);
+            }
+            final InputMethodSubtype subtype = SubtypeUtils.findLastResortApplicableSubtypeLocked(
+                    mRes, explicitlyOrImplicitlyEnabledSubtypes, SubtypeUtils.SUBTYPE_MODE_KEYBOARD,
+                    null, true);
+            if (subtype != null) {
+                return subtype;
+            }
+            return SubtypeUtils.findLastResortApplicableSubtypeLocked(mRes,
+                    explicitlyOrImplicitlyEnabledSubtypes, null, null, true);
+        }
+
         public void dumpLocked(final Printer pw, final String prefix) {
             pw.println(prefix + "mCurrentUserId=" + mCurrentUserId);
             pw.println(prefix + "mCurrentProfileIds=" + Arrays.toString(mCurrentProfileIds));
diff --git a/services/core/java/com/android/server/locksettings/LockSettingsService.java b/services/core/java/com/android/server/locksettings/LockSettingsService.java
index 884ae171..804315c 100644
--- a/services/core/java/com/android/server/locksettings/LockSettingsService.java
+++ b/services/core/java/com/android/server/locksettings/LockSettingsService.java
@@ -1626,7 +1626,6 @@
 
             onSyntheticPasswordKnown(userId, sp);
             setLockCredentialWithSpLocked(credential, sp, userId);
-            mSpManager.destroyLskfBasedProtector(oldProtectorId, userId);
             sendCredentialsOnChangeIfRequired(credential, userId, isLockTiedToParent);
             return true;
         }
@@ -2642,8 +2641,7 @@
 
     /**
      * Changes the user's LSKF by creating an LSKF-based protector that uses the new LSKF (which may
-     * be empty) and setting the new protector as the user's current LSKF-based protector.  The old
-     * LSKF-based protector is not destroyed, and the SP itself is not changed.
+     * be empty) and replacing the old LSKF-based protector with it.  The SP itself is not changed.
      *
      * Also maintains the invariants described in {@link SyntheticPasswordManager} by
      * setting/clearing the protection (by the SP) on the user's file-based encryption key and
@@ -2655,6 +2653,7 @@
             SyntheticPassword sp, int userId) {
         if (DEBUG) Slog.d(TAG, "setLockCredentialWithSpLocked: user=" + userId);
         final int savedCredentialType = getCredentialTypeInternal(userId);
+        final long oldProtectorId = getCurrentLskfBasedProtectorId(userId);
         final long newProtectorId = mSpManager.createLskfBasedProtector(getGateKeeperService(),
                 credential, sp, userId);
         final Map<Integer, LockscreenCredential> profilePasswords;
@@ -2700,7 +2699,7 @@
                 entry.getValue().zeroize();
             }
         }
-
+        mSpManager.destroyLskfBasedProtector(oldProtectorId, userId);
         return newProtectorId;
     }
 
@@ -2934,9 +2933,7 @@
             return false;
         }
         onSyntheticPasswordKnown(userId, result.syntheticPassword);
-        final long oldProtectorId = getCurrentLskfBasedProtectorId(userId);
         setLockCredentialWithSpLocked(credential, result.syntheticPassword, userId);
-        mSpManager.destroyLskfBasedProtector(oldProtectorId, userId);
         return true;
     }
 
diff --git a/services/core/java/com/android/server/locksettings/LockSettingsShellCommand.java b/services/core/java/com/android/server/locksettings/LockSettingsShellCommand.java
index 76032f4..1aee345 100644
--- a/services/core/java/com/android/server/locksettings/LockSettingsShellCommand.java
+++ b/services/core/java/com/android/server/locksettings/LockSettingsShellCommand.java
@@ -176,12 +176,6 @@
             pw.println("  set-password [--old <CREDENTIAL>] [--user USER_ID] <PASSWORD>");
             pw.println("    Sets the lock screen as password, using the given PASSOWRD to unlock.");
             pw.println("");
-            pw.println("  sp [--old <CREDENTIAL>] [--user USER_ID]");
-            pw.println("    Gets whether synthetic password is enabled.");
-            pw.println("");
-            pw.println("  sp [--old <CREDENTIAL>] [--user USER_ID] <1|0>");
-            pw.println("    Enables / disables synthetic password.");
-            pw.println("");
             pw.println("  clear [--old <CREDENTIAL>] [--user USER_ID]");
             pw.println("    Clears the lock credentials.");
             pw.println("");
diff --git a/services/core/java/com/android/server/locksettings/SyntheticPasswordManager.java b/services/core/java/com/android/server/locksettings/SyntheticPasswordManager.java
index 2d0143a..7ace03d 100644
--- a/services/core/java/com/android/server/locksettings/SyntheticPasswordManager.java
+++ b/services/core/java/com/android/server/locksettings/SyntheticPasswordManager.java
@@ -1308,7 +1308,6 @@
         SyntheticPasswordBlob blob = SyntheticPasswordBlob.fromBytes(loadState(SP_BLOB_NAME,
                     protectorId, userId));
         destroyProtectorCommon(protectorId, userId);
-        destroyState(SECDISCARDABLE_NAME, protectorId, userId);
         if (blob.mProtectorType == PROTECTOR_TYPE_WEAK_TOKEN_BASED) {
             notifyWeakEscrowTokenRemovedListeners(protectorId, userId);
         }
@@ -1332,7 +1331,6 @@
      */
     public void destroyLskfBasedProtector(long protectorId, int userId) {
         destroyProtectorCommon(protectorId, userId);
-        destroyState(SECDISCARDABLE_NAME, protectorId, userId);
         destroyState(PASSWORD_DATA_NAME, protectorId, userId);
         destroyState(PASSWORD_METRICS_NAME, protectorId, userId);
     }
@@ -1340,6 +1338,7 @@
     private void destroyProtectorCommon(long protectorId, int userId) {
         destroyState(SP_BLOB_NAME, protectorId, userId);
         destroySPBlobKey(getKeyName(protectorId));
+        destroyState(SECDISCARDABLE_NAME, protectorId, userId);
         if (hasState(WEAVER_SLOT_NAME, protectorId, userId)) {
             destroyWeaverSlot(protectorId, userId);
         }
diff --git a/services/core/java/com/android/server/wm/DisplayAreaGroup.java b/services/core/java/com/android/server/wm/DisplayAreaGroup.java
index 8488314..705327d 100644
--- a/services/core/java/com/android/server/wm/DisplayAreaGroup.java
+++ b/services/core/java/com/android/server/wm/DisplayAreaGroup.java
@@ -25,7 +25,10 @@
 import android.content.res.Configuration;
 import android.graphics.Rect;
 
+import com.android.internal.annotations.Keep;
+
 /** The root of a partition of the logical display. */
+@Keep
 class DisplayAreaGroup extends RootDisplayArea {
 
     DisplayAreaGroup(WindowManagerService wms, String name, int featureId) {
diff --git a/services/core/java/com/android/server/wm/DisplayAreaPolicyBuilder.java b/services/core/java/com/android/server/wm/DisplayAreaPolicyBuilder.java
index 8e21d96..f49e64e 100644
--- a/services/core/java/com/android/server/wm/DisplayAreaPolicyBuilder.java
+++ b/services/core/java/com/android/server/wm/DisplayAreaPolicyBuilder.java
@@ -38,6 +38,7 @@
 import android.window.DisplayAreaOrganizer;
 import android.window.WindowContainerToken;
 
+import com.android.internal.annotations.Keep;
 import com.android.internal.annotations.VisibleForTesting;
 import com.android.internal.protolog.common.ProtoLog;
 import com.android.server.policy.WindowManagerPolicy;
@@ -142,6 +143,7 @@
  * the window to the corresponding {@link DisplayArea.Tokens} under the returned root
  * {@link RootDisplayArea}.
  */
+@Keep
 class DisplayAreaPolicyBuilder {
 
     @Nullable private HierarchyBuilder mRootHierarchyBuilder;
diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/close/CloseAppBackButtonTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/close/CloseAppBackButtonTest.kt
index d53d96b..9cc1bfe 100644
--- a/tests/FlickerTests/src/com/android/server/wm/flicker/close/CloseAppBackButtonTest.kt
+++ b/tests/FlickerTests/src/com/android/server/wm/flicker/close/CloseAppBackButtonTest.kt
@@ -22,6 +22,7 @@
 import com.android.server.wm.flicker.FlickerParametersRunnerFactory
 import com.android.server.wm.flicker.FlickerTestParameter
 import com.android.server.wm.flicker.FlickerTestParameterFactory
+import com.android.server.wm.flicker.annotation.FlickerServiceCompatible
 import com.android.server.wm.flicker.annotation.Group4
 import com.android.server.wm.flicker.dsl.FlickerBuilder
 import org.junit.FixMethodOrder
@@ -60,6 +61,7 @@
  *        apps are running before setup
  */
 @RequiresDevice
+@FlickerServiceCompatible
 @RunWith(Parameterized::class)
 @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/close/CloseAppHomeButtonTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/close/CloseAppHomeButtonTest.kt
index 1348d7a..02c1325 100644
--- a/tests/FlickerTests/src/com/android/server/wm/flicker/close/CloseAppHomeButtonTest.kt
+++ b/tests/FlickerTests/src/com/android/server/wm/flicker/close/CloseAppHomeButtonTest.kt
@@ -21,6 +21,7 @@
 import com.android.server.wm.flicker.FlickerParametersRunnerFactory
 import com.android.server.wm.flicker.FlickerTestParameter
 import com.android.server.wm.flicker.FlickerTestParameterFactory
+import com.android.server.wm.flicker.annotation.FlickerServiceCompatible
 import com.android.server.wm.flicker.annotation.Group4
 import com.android.server.wm.flicker.dsl.FlickerBuilder
 import org.junit.FixMethodOrder
@@ -59,6 +60,7 @@
  *        apps are running before setup
  */
 @RequiresDevice
+@FlickerServiceCompatible
 @RunWith(Parameterized::class)
 @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppColdTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppColdTest.kt
index 4640d36..cd01f74 100644
--- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppColdTest.kt
+++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppColdTest.kt
@@ -22,6 +22,7 @@
 import com.android.server.wm.flicker.FlickerParametersRunnerFactory
 import com.android.server.wm.flicker.FlickerTestParameter
 import com.android.server.wm.flicker.FlickerTestParameterFactory
+import com.android.server.wm.flicker.annotation.FlickerServiceCompatible
 import com.android.server.wm.flicker.annotation.Group1
 import com.android.server.wm.flicker.dsl.FlickerBuilder
 import com.android.server.wm.flicker.helpers.setRotation
@@ -50,6 +51,7 @@
  *        apps are running before setup
  */
 @RequiresDevice
+@FlickerServiceCompatible
 @RunWith(Parameterized::class)
 @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromOverviewTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromOverviewTest.kt
index 34c0b23..30f5a41 100644
--- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromOverviewTest.kt
+++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromOverviewTest.kt
@@ -23,6 +23,7 @@
 import com.android.server.wm.flicker.FlickerParametersRunnerFactory
 import com.android.server.wm.flicker.FlickerTestParameter
 import com.android.server.wm.flicker.FlickerTestParameterFactory
+import com.android.server.wm.flicker.annotation.FlickerServiceCompatible
 import com.android.server.wm.flicker.annotation.Group1
 import com.android.server.wm.flicker.dsl.FlickerBuilder
 import com.android.server.wm.flicker.helpers.setRotation
@@ -52,6 +53,7 @@
  *        apps are running before setup
  */
 @RequiresDevice
+@FlickerServiceCompatible
 @RunWith(Parameterized::class)
 @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppNonResizeableTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppNonResizeableTest.kt
index 1ad5426..8ec6113 100644
--- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppNonResizeableTest.kt
+++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppNonResizeableTest.kt
@@ -25,6 +25,7 @@
 import com.android.server.wm.flicker.FlickerParametersRunnerFactory
 import com.android.server.wm.flicker.FlickerTestParameter
 import com.android.server.wm.flicker.FlickerTestParameterFactory
+import com.android.server.wm.flicker.annotation.FlickerServiceCompatible
 import com.android.server.wm.flicker.annotation.Group1
 import com.android.server.wm.flicker.helpers.NonResizeableAppHelper
 import com.android.server.wm.flicker.statusBarLayerPositionAtEnd
@@ -57,6 +58,7 @@
  *        apps are running before setup
  */
 @RequiresDevice
+@FlickerServiceCompatible
 @RunWith(Parameterized::class)
 @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppWarmTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppWarmTest.kt
index bc5ab7d..0678d632 100644
--- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppWarmTest.kt
+++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppWarmTest.kt
@@ -22,6 +22,7 @@
 import com.android.server.wm.flicker.FlickerParametersRunnerFactory
 import com.android.server.wm.flicker.FlickerTestParameter
 import com.android.server.wm.flicker.FlickerTestParameterFactory
+import com.android.server.wm.flicker.annotation.FlickerServiceCompatible
 import com.android.server.wm.flicker.annotation.Group1
 import com.android.server.wm.flicker.dsl.FlickerBuilder
 import com.android.server.wm.flicker.helpers.setRotation
@@ -50,6 +51,7 @@
  *        apps are running before setup
  */
 @RequiresDevice
+@FlickerServiceCompatible
 @RunWith(Parameterized::class)
 @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
 @FixMethodOrder(MethodSorters.NAME_ASCENDING)