Merge "[BiometricsV2] Rewrite Activity to Kotlin"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index a87b27d..b1018c6 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -586,8 +586,8 @@
     <string name="location_settings_summary_location_off">Off</string>
     <!-- Summary for Location settings when location is on, explaining how many apps have location permission [CHAR LIMIT=NONE]-->
     <string name="location_settings_summary_location_on">{count, plural,
-      =1      {On - # app has access to location}
-      other   {On - # apps have access to location}
+      =1      {On / # app has access to location}
+      other   {On / # apps have access to location}
     }</string>
     <!-- Location settings, loading the number of apps which have location permission [CHAR LIMIT=30] -->
     <string name="location_settings_loading_app_permission_stats">Loading\u2026</string>
@@ -10546,8 +10546,6 @@
     <string name="platform_compat_default_disabled_title">Default disabled changes</string>
     <!-- Title for target SDK gated app compat changes category (do not translate 'targetSdkVersion') [CHAR LIMIT=50] -->
     <string name="platform_compat_target_sdk_title">Enabled for targetSdkVersion &gt;= <xliff:g id="number" example="29">%d</xliff:g></string>
-    <!-- Title for the dialog shown when no debuggable apps are available [CHAR LIMIT=30] -->
-    <string name="platform_compat_dialog_title_no_apps">No apps available</string>
     <!-- Explanatory text shown when no debuggable apps are available [CHAR LIMIT=NONE] -->
     <string name="platform_compat_dialog_text_no_apps">App compatibility changes can only be modified for debuggable apps. Install a debuggable app and try again.</string>
 
diff --git a/res/xml/development_settings.xml b/res/xml/development_settings.xml
index b26005a..32acac6 100644
--- a/res/xml/development_settings.xml
+++ b/res/xml/development_settings.xml
@@ -258,7 +258,7 @@
             android:key="platform_compat_dashboard"
             android:title="@string/platform_compat_dashboard_title"
             android:summary="@string/platform_compat_dashboard_summary"
-            android:fragment="com.android.settings.development.compat.PlatformCompatDashboard"
+            settings:controller="com.android.settings.spa.development.compat.PlatformCompatPreferenceController"
             />
 
         <SwitchPreference
diff --git a/src/com/android/settings/accessibility/ScreenFlashNotificationColorDialogFragment.java b/src/com/android/settings/accessibility/ScreenFlashNotificationColorDialogFragment.java
index 8a440b6..9683966 100644
--- a/src/com/android/settings/accessibility/ScreenFlashNotificationColorDialogFragment.java
+++ b/src/com/android/settings/accessibility/ScreenFlashNotificationColorDialogFragment.java
@@ -119,7 +119,7 @@
         synchronized (this) {
             if (mTimer != null) mTimer.cancel();
 
-            mTimer = new Timer();
+            mTimer = createTimer();
             if (mIsPreview) {
                 mTimer.schedule(getStopTask(), 0);
                 startDelay = BETWEEN_STOP_AND_START_DELAY_MS;
@@ -176,4 +176,8 @@
         getContext().sendBroadcast(stopIntent);
         mIsPreview = false;
     }
+
+    Timer createTimer() {
+        return new Timer();
+    }
 }
diff --git a/src/com/android/settings/development/DevelopmentOptionsActivityRequestCodes.java b/src/com/android/settings/development/DevelopmentOptionsActivityRequestCodes.java
index 0d91fdd..b7b2759 100644
--- a/src/com/android/settings/development/DevelopmentOptionsActivityRequestCodes.java
+++ b/src/com/android/settings/development/DevelopmentOptionsActivityRequestCodes.java
@@ -25,12 +25,4 @@
     int REQUEST_CODE_DEBUG_APP = 1;
 
     int REQUEST_MOCK_LOCATION_APP = 2;
-
-    int REQUEST_CODE_ANGLE_ALL_USE_ANGLE = 3;
-
-    int REQUEST_CODE_ANGLE_DRIVER_PKGS = 4;
-
-    int REQUEST_CODE_ANGLE_DRIVER_VALUES = 5;
-
-    int REQUEST_COMPAT_CHANGE_APP = 6;
 }
diff --git a/src/com/android/settings/development/compat/PlatformCompatDashboard.java b/src/com/android/settings/development/compat/PlatformCompatDashboard.java
index f8cbf21..3f0ffc7 100644
--- a/src/com/android/settings/development/compat/PlatformCompatDashboard.java
+++ b/src/com/android/settings/development/compat/PlatformCompatDashboard.java
@@ -17,21 +17,16 @@
 package com.android.settings.development.compat;
 
 import static com.android.internal.compat.OverrideAllowedState.ALLOWED;
-import static com.android.settings.development.DevelopmentOptionsActivityRequestCodes.REQUEST_COMPAT_CHANGE_APP;
 
-import android.app.Activity;
-import android.app.AlertDialog;
 import android.app.settings.SettingsEnums;
 import android.compat.Compatibility.ChangeConfig;
 import android.content.Context;
-import android.content.Intent;
 import android.content.pm.ApplicationInfo;
 import android.content.pm.PackageManager;
 import android.graphics.drawable.Drawable;
 import android.os.Bundle;
 import android.os.RemoteException;
 import android.os.ServiceManager;
-import android.text.TextUtils;
 import android.util.ArraySet;
 
 import androidx.annotation.VisibleForTesting;
@@ -40,35 +35,28 @@
 import androidx.preference.PreferenceCategory;
 import androidx.preference.SwitchPreference;
 
-import com.android.internal.compat.AndroidBuildClassifier;
 import com.android.internal.compat.CompatibilityChangeConfig;
 import com.android.internal.compat.CompatibilityChangeInfo;
 import com.android.internal.compat.IPlatformCompat;
 import com.android.settings.R;
 import com.android.settings.dashboard.DashboardFragment;
-import com.android.settings.development.AppPicker;
 
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import java.util.TreeMap;
 
-
 /**
  * Dashboard for Platform Compat preferences.
  */
 public class PlatformCompatDashboard extends DashboardFragment {
     private static final String TAG = "PlatformCompatDashboard";
-    private static final String COMPAT_APP = "compat_app";
+    public static final String COMPAT_APP = "compat_app";
 
     private IPlatformCompat mPlatformCompat;
 
     private CompatibilityChangeInfo[] mChanges;
 
-    private AndroidBuildClassifier mAndroidBuildClassifier = new AndroidBuildClassifier();
-
-    private boolean mShouldStartAppPickerOnResume = true;
-
     @VisibleForTesting
     String mSelectedApp;
 
@@ -108,32 +96,6 @@
         } catch (RemoteException e) {
             throw new RuntimeException("Could not list changes!", e);
         }
-        if (icicle != null) {
-            mShouldStartAppPickerOnResume = false;
-            mSelectedApp = icicle.getString(COMPAT_APP);
-        }
-    }
-
-    @Override
-    public void onActivityResult(int requestCode, int resultCode, Intent data) {
-        if (requestCode == REQUEST_COMPAT_CHANGE_APP) {
-            mShouldStartAppPickerOnResume = false;
-            switch (resultCode) {
-                case Activity.RESULT_OK:
-                    mSelectedApp = data.getAction();
-                    break;
-                case Activity.RESULT_CANCELED:
-                    if (TextUtils.isEmpty(mSelectedApp)) {
-                        finish();
-                    }
-                    break;
-                case AppPicker.RESULT_NO_MATCHING_APPS:
-                    mSelectedApp = null;
-                    break;
-            }
-            return;
-        }
-        super.onActivityResult(requestCode, resultCode, data);
     }
 
     @Override
@@ -142,33 +104,18 @@
         if (isFinishingOrDestroyed()) {
             return;
         }
-        if (!mShouldStartAppPickerOnResume) {
-            if (TextUtils.isEmpty(mSelectedApp)) {
-                new AlertDialog.Builder(getContext())
-                        .setTitle(R.string.platform_compat_dialog_title_no_apps)
-                        .setMessage(R.string.platform_compat_dialog_text_no_apps)
-                        .setPositiveButton(R.string.okay, (dialog, which) -> finish())
-                        .setOnDismissListener(dialog -> finish())
-                        .setCancelable(false)
-                        .show();
-                return;
-            }
-            try {
-                final ApplicationInfo applicationInfo = getApplicationInfo();
-                addPreferences(applicationInfo);
-                return;
-            } catch (PackageManager.NameNotFoundException e) {
-                mShouldStartAppPickerOnResume = true;
-                mSelectedApp = null;
-            }
+        Bundle arguments = getArguments();
+        if (arguments == null) {
+            finish();
+            return;
         }
-        startAppPicker();
-    }
-
-    @Override
-    public void onSaveInstanceState(Bundle outState) {
-        super.onSaveInstanceState(outState);
-        outState.putString(COMPAT_APP, mSelectedApp);
+        mSelectedApp = arguments.getString(COMPAT_APP);
+        try {
+            final ApplicationInfo applicationInfo = getApplicationInfo();
+            addPreferences(applicationInfo);
+        } catch (PackageManager.NameNotFoundException ignored) {
+            finish();
+        }
     }
 
     private void addPreferences(ApplicationInfo applicationInfo) {
@@ -266,12 +213,6 @@
         appPreference.setIcon(icon);
         appPreference.setSummary(getString(R.string.platform_compat_selected_app_summary,
                                          mSelectedApp, applicationInfo.targetSdkVersion));
-        appPreference.setKey(mSelectedApp);
-        appPreference.setOnPreferenceClickListener(
-                preference -> {
-                    startAppPicker();
-                    return true;
-                });
         return appPreference;
     }
 
@@ -294,17 +235,6 @@
         }
     }
 
-    private void startAppPicker() {
-        final Intent intent = new Intent(getContext(), AppPicker.class)
-                .putExtra(AppPicker.EXTRA_INCLUDE_NOTHING, false);
-        // If build is neither userdebug nor eng, only include debuggable apps
-        final boolean debuggableBuild = mAndroidBuildClassifier.isDebuggableBuild();
-        if (!debuggableBuild) {
-            intent.putExtra(AppPicker.EXTRA_DEBUGGABLE, true /* value */);
-        }
-        startActivityForResult(intent, REQUEST_COMPAT_CHANGE_APP);
-    }
-
     private class CompatChangePreferenceChangeListener implements OnPreferenceChangeListener {
         private final long changeId;
 
diff --git a/src/com/android/settings/devicelock/DeviceLockPreferenceController.java b/src/com/android/settings/devicelock/DeviceLockPreferenceController.java
index 4b6fe88..cf54c87 100644
--- a/src/com/android/settings/devicelock/DeviceLockPreferenceController.java
+++ b/src/com/android/settings/devicelock/DeviceLockPreferenceController.java
@@ -47,6 +47,11 @@
     @Override
     public void updateState(Preference preference) {
         super.updateState(preference);
+        if (mDeviceLockManager == null) {
+            Log.w(TAG, "DeviceLockManager is not available");
+            preference.setVisible(false);
+            return;
+        }
         mDeviceLockManager.getKioskApps(mContext.getMainExecutor(),
                 result -> {
                     // if kiosk apps present on the device, the device is provisioned by Device Lock
diff --git a/src/com/android/settings/network/MobilePlanPreferenceController.java b/src/com/android/settings/network/MobilePlanPreferenceController.java
index d8963ad..fcca5e6 100644
--- a/src/com/android/settings/network/MobilePlanPreferenceController.java
+++ b/src/com/android/settings/network/MobilePlanPreferenceController.java
@@ -57,7 +57,7 @@
     public static final int MANAGE_MOBILE_PLAN_DIALOG_ID = 1;
 
     private static final String TAG = "MobilePlanPrefContr";
-    private static final String KEY_MANAGE_MOBILE_PLAN = "manage_mobile_plan";
+    static final String KEY_MANAGE_MOBILE_PLAN = "manage_mobile_plan";
     private static final String SAVED_MANAGE_MOBILE_PLAN_MSG = "mManageMobilePlanMessage";
 
     private final UserManager mUserManager;
diff --git a/src/com/android/settings/network/NetworkDashboardFragment.java b/src/com/android/settings/network/NetworkDashboardFragment.java
index 4ea3464..d558aa8 100644
--- a/src/com/android/settings/network/NetworkDashboardFragment.java
+++ b/src/com/android/settings/network/NetworkDashboardFragment.java
@@ -181,5 +181,17 @@
                             null /* metricsFeatureProvider */, null /* fragment */,
                             null /* mobilePlanHost */, null /* LifecycleOwner */);
                 }
+
+                @Override
+                public List<String> getNonIndexableKeys(Context context) {
+                    final List<String> keys = super.getNonIndexableKeys(context);
+
+                    MobilePlanPreferenceController mppc =
+                            new MobilePlanPreferenceController(context, null);
+                    if (!mppc.isAvailable()) {
+                        keys.add(MobilePlanPreferenceController.KEY_MANAGE_MOBILE_PLAN);
+                    }
+                    return keys;
+                }
             };
 }
diff --git a/src/com/android/settings/slices/RestrictedSliceUtils.java b/src/com/android/settings/slices/RestrictedSliceUtils.java
new file mode 100644
index 0000000..a5b5a14
--- /dev/null
+++ b/src/com/android/settings/slices/RestrictedSliceUtils.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.slices;
+
+import android.content.ContentResolver;
+import android.net.Uri;
+import android.provider.SettingsSlicesContract;
+
+/**
+ * A utility class to check slice Uris for restriction.
+ */
+public class RestrictedSliceUtils {
+
+    /**
+     * Uri for the notifying open networks Slice.
+     */
+    private static final Uri NOTIFY_OPEN_NETWORKS_SLICE_URI = new Uri.Builder()
+        .scheme(ContentResolver.SCHEME_CONTENT)
+        .authority(SettingsSliceProvider.SLICE_AUTHORITY)
+        .appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
+        .appendPath("notify_open_networks")
+        .build();
+
+    /**
+     * Uri for the auto turning on Wi-Fi Slice.
+     */
+    private static final Uri AUTO_TURN_ON_WIFI_SLICE_URI = new Uri.Builder()
+        .scheme(ContentResolver.SCHEME_CONTENT)
+        .authority(SettingsSliceProvider.SLICE_AUTHORITY)
+        .appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
+        .appendPath("enable_wifi_wakeup")
+        .build();
+
+    /**
+     * Uri for the usb tethering Slice.
+     */
+    private static final Uri USB_TETHERING_SLICE_URI = new Uri.Builder()
+        .scheme(ContentResolver.SCHEME_CONTENT)
+        .authority(SettingsSliceProvider.SLICE_AUTHORITY)
+        .appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
+        .appendPath("enable_usb_tethering")
+        .build();
+
+    /**
+     * Uri for the bluetooth tethering Slice.
+     */
+    private static final Uri BLUETOOTH_TETHERING_SLICE_URI = new Uri.Builder()
+        .scheme(ContentResolver.SCHEME_CONTENT)
+        .authority(SettingsSliceProvider.SLICE_AUTHORITY)
+        .appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
+        .appendPath("enable_bluetooth_tethering_2")
+        .build();
+
+    /**
+     * Returns true if the slice Uri restricts access to guest user.
+     */
+    public static boolean isGuestRestricted(Uri sliceUri) {
+        if (AUTO_TURN_ON_WIFI_SLICE_URI.equals(sliceUri)
+            || NOTIFY_OPEN_NETWORKS_SLICE_URI.equals(sliceUri)
+            || BLUETOOTH_TETHERING_SLICE_URI.equals(sliceUri)
+            || USB_TETHERING_SLICE_URI.equals(sliceUri)
+            || CustomSliceRegistry.MOBILE_DATA_SLICE_URI.equals(sliceUri)) {
+            return true;
+        }
+        return false;
+    }
+}
diff --git a/src/com/android/settings/slices/SettingsSliceProvider.java b/src/com/android/settings/slices/SettingsSliceProvider.java
index 12272a7..5d2bde3 100644
--- a/src/com/android/settings/slices/SettingsSliceProvider.java
+++ b/src/com/android/settings/slices/SettingsSliceProvider.java
@@ -30,6 +30,7 @@
 import android.net.Uri;
 import android.os.Binder;
 import android.os.StrictMode;
+import android.os.UserManager;
 import android.provider.Settings;
 import android.provider.SettingsSlicesContract;
 import android.text.TextUtils;
@@ -233,6 +234,14 @@
                 getContext().getTheme().rebase();
             }
 
+            // Checking if some semi-sensitive slices are requested by a guest user. If so, will
+            // return an empty slice.
+            final UserManager userManager = getContext().getSystemService(UserManager.class);
+            if (userManager.isGuestUser() && RestrictedSliceUtils.isGuestRestricted(sliceUri)) {
+                Log.i(TAG, "Guest user access denied.");
+                return null;
+            }
+
             // Before adding a slice to {@link CustomSliceManager}, please get approval
             // from the Settings team.
             if (CustomSliceRegistry.isValidUri(sliceUri)) {
diff --git a/src/com/android/settings/spa/SettingsSpaEnvironment.kt b/src/com/android/settings/spa/SettingsSpaEnvironment.kt
index 599b610..7b450c9 100644
--- a/src/com/android/settings/spa/SettingsSpaEnvironment.kt
+++ b/src/com/android/settings/spa/SettingsSpaEnvironment.kt
@@ -37,6 +37,7 @@
 import com.android.settings.spa.app.specialaccess.UseFullScreenIntentAppListProvider
 import com.android.settings.spa.core.instrumentation.SpaLogProvider
 import com.android.settings.spa.development.UsageStatsPageProvider
+import com.android.settings.spa.development.compat.PlatformCompatAppListPageProvider
 import com.android.settings.spa.home.HomePageProvider
 import com.android.settings.spa.network.NetworkAndInternetPageProvider
 import com.android.settings.spa.notification.AppListNotificationsPageProvider
@@ -84,6 +85,7 @@
                 LanguageAndInputPageProvider,
                 AppLanguagesPageProvider,
                 UsageStatsPageProvider,
+                PlatformCompatAppListPageProvider,
                 BackgroundInstalledAppsPageProvider,
                 CloneAppInfoSettingsProvider,
                 NetworkAndInternetPageProvider,
@@ -97,5 +99,5 @@
     override val logger =
         if (FeatureFlagUtils.isEnabled(context, FeatureFlagUtils.SETTINGS_ENABLE_SPA_METRICS))
             SpaLogProvider
-        else object: SpaLogger {}
+        else object : SpaLogger {}
 }
diff --git a/src/com/android/settings/spa/development/compat/PlatformCompatAppList.kt b/src/com/android/settings/spa/development/compat/PlatformCompatAppList.kt
new file mode 100644
index 0000000..5f3b4e7
--- /dev/null
+++ b/src/com/android/settings/spa/development/compat/PlatformCompatAppList.kt
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.spa.development.compat
+
+import android.os.Bundle
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.res.stringResource
+import com.android.settings.R
+import com.android.settingslib.spa.framework.common.SettingsPageProvider
+import com.android.settingslib.spa.framework.compose.rememberContext
+import com.android.settingslib.spaprivileged.template.app.AppListPage
+
+object PlatformCompatAppListPageProvider : SettingsPageProvider {
+    override val name = "PlatformCompatAppList"
+
+    @Composable
+    override fun Page(arguments: Bundle?) {
+        AppListPage(
+            title = stringResource(R.string.platform_compat_dashboard_title),
+            listModel = rememberContext(::PlatformCompatAppListModel),
+            noItemMessage = stringResource(R.string.platform_compat_dialog_text_no_apps),
+        )
+    }
+}
\ No newline at end of file
diff --git a/src/com/android/settings/spa/development/compat/PlatformCompatAppListModel.kt b/src/com/android/settings/spa/development/compat/PlatformCompatAppListModel.kt
new file mode 100644
index 0000000..c6752b9
--- /dev/null
+++ b/src/com/android/settings/spa/development/compat/PlatformCompatAppListModel.kt
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.spa.development.compat
+
+import android.app.settings.SettingsEnums
+import android.content.Context
+import android.content.pm.ApplicationInfo
+import android.os.Build
+import androidx.compose.runtime.Composable
+import androidx.core.os.bundleOf
+import com.android.settings.core.SubSettingLauncher
+import com.android.settings.development.compat.PlatformCompatDashboard
+import com.android.settingslib.spa.framework.compose.stateOf
+import com.android.settingslib.spa.framework.util.filterItem
+import com.android.settingslib.spa.framework.util.mapItem
+import com.android.settingslib.spaprivileged.model.app.AppListModel
+import com.android.settingslib.spaprivileged.model.app.AppRecord
+import com.android.settingslib.spaprivileged.model.app.hasFlag
+import com.android.settingslib.spaprivileged.model.app.userHandle
+import com.android.settingslib.spaprivileged.template.app.AppListItem
+import com.android.settingslib.spaprivileged.template.app.AppListItemModel
+import kotlinx.coroutines.flow.Flow
+
+data class PlatformCompatAppRecord(
+    override val app: ApplicationInfo,
+) : AppRecord
+
+class PlatformCompatAppListModel(
+    private val context: Context,
+) : AppListModel<PlatformCompatAppRecord> {
+
+    override fun transform(userIdFlow: Flow<Int>, appListFlow: Flow<List<ApplicationInfo>>) =
+        appListFlow.mapItem(::PlatformCompatAppRecord)
+
+    override fun filter(
+        userIdFlow: Flow<Int>, option: Int, recordListFlow: Flow<List<PlatformCompatAppRecord>>,
+    ) = recordListFlow.filterItem { record ->
+        Build.IS_DEBUGGABLE || record.app.hasFlag(ApplicationInfo.FLAG_DEBUGGABLE)
+    }
+
+    @Composable
+    override fun getSummary(option: Int, record: PlatformCompatAppRecord) =
+        stateOf(record.app.packageName)
+
+    @Composable
+    override fun AppListItemModel<PlatformCompatAppRecord>.AppItem() {
+        AppListItem { navigateToAppCompat(app = record.app) }
+    }
+
+    private fun navigateToAppCompat(app: ApplicationInfo) {
+        SubSettingLauncher(context)
+            .setDestination(PlatformCompatDashboard::class.qualifiedName)
+            .setSourceMetricsCategory(SettingsEnums.DEVELOPMENT)
+            .setArguments(bundleOf(PlatformCompatDashboard.COMPAT_APP to app.packageName))
+            .setUserHandle(app.userHandle)
+            .launch()
+    }
+}
diff --git a/src/com/android/settings/spa/development/compat/PlatformCompatPreferenceController.kt b/src/com/android/settings/spa/development/compat/PlatformCompatPreferenceController.kt
new file mode 100644
index 0000000..c0a421c
--- /dev/null
+++ b/src/com/android/settings/spa/development/compat/PlatformCompatPreferenceController.kt
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.settings.spa.development.compat
+
+import android.content.Context
+import androidx.preference.Preference
+import com.android.settings.core.BasePreferenceController
+import com.android.settings.spa.SpaActivity.Companion.startSpaActivity
+
+class PlatformCompatPreferenceController(context: Context, preferenceKey: String) :
+    BasePreferenceController(context, preferenceKey) {
+    override fun getAvailabilityStatus() = AVAILABLE
+
+    override fun handlePreferenceTreeClick(preference: Preference): Boolean {
+        if (preference.key == mPreferenceKey) {
+            mContext.startSpaActivity(PlatformCompatAppListPageProvider.name)
+            return true
+        }
+        return false
+    }
+}
\ No newline at end of file
diff --git a/src/com/android/settings/users/UserDetailsSettings.java b/src/com/android/settings/users/UserDetailsSettings.java
index 2f9031e..402d4b1 100644
--- a/src/com/android/settings/users/UserDetailsSettings.java
+++ b/src/com/android/settings/users/UserDetailsSettings.java
@@ -79,6 +79,7 @@
 
     /** Whether to enable the app_copying fragment. */
     private static final boolean SHOW_APP_COPYING_PREF = false;
+    private static final int MESSAGE_PADDING = 20;
 
     private UserManager mUserManager;
     private UserCapabilities mUserCaps;
@@ -274,6 +275,7 @@
                 context.getDrawable(com.android.settingslib.R.drawable.ic_admin_panel_settings));
         dialogHelper.setTitle(R.string.user_revoke_admin_confirm_title);
         dialogHelper.setMessage(R.string.user_revoke_admin_confirm_message);
+        dialogHelper.setMessagePadding(MESSAGE_PADDING);
         dialogHelper.setPositiveButton(R.string.remove, view -> {
             updateUserAdminStatus(false);
             dialogHelper.getDialog().dismiss();
@@ -294,6 +296,7 @@
                 context.getDrawable(com.android.settingslib.R.drawable.ic_admin_panel_settings));
         dialogHelper.setTitle(com.android.settingslib.R.string.user_grant_admin_title);
         dialogHelper.setMessage(com.android.settingslib.R.string.user_grant_admin_message);
+        dialogHelper.setMessagePadding(MESSAGE_PADDING);
         dialogHelper.setPositiveButton(com.android.settingslib.R.string.user_grant_admin_button,
                 view -> {
                     updateUserAdminStatus(true);
diff --git a/tests/robotests/src/com/android/settings/accessibility/ScreenFlashNotificationColorDialogFragmentTest.java b/tests/robotests/src/com/android/settings/accessibility/ScreenFlashNotificationColorDialogFragmentTest.java
index dab13a0..4c06319 100644
--- a/tests/robotests/src/com/android/settings/accessibility/ScreenFlashNotificationColorDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/ScreenFlashNotificationColorDialogFragmentTest.java
@@ -42,6 +42,7 @@
 import androidx.fragment.app.FragmentActivity;
 
 import com.android.settings.R;
+import com.android.settings.testutils.FakeTimer;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -49,9 +50,12 @@
 import org.robolectric.Robolectric;
 import org.robolectric.RobolectricTestRunner;
 import org.robolectric.shadows.ShadowContextWrapper;
+import org.robolectric.util.ReflectionHelpers;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Timer;
+import java.util.function.Consumer;
 
 @RunWith(RobolectricTestRunner.class)
 public class ScreenFlashNotificationColorDialogFragmentTest {
@@ -68,9 +72,8 @@
         mShadowContextWrapper = shadowOf(fragmentActivity);
 
         mCurrentColor = ROSE.mColorInt;
-        mDialogFragment = ScreenFlashNotificationColorDialogFragment.getInstance(
-                mCurrentColor, selectedColor -> mCurrentColor = selectedColor
-        );
+        mDialogFragment = createFragment();
+
         mDialogFragment.show(fragmentActivity.getSupportFragmentManager(), "test");
 
         mAlertDialog = (AlertDialog) mDialogFragment.getDialog();
@@ -91,16 +94,19 @@
     }
 
     @Test
-    public void clickNeutral_assertStartPreview() throws InterruptedException {
+    public void clickNeutral_assertStartPreview() {
         performClickOnDialog(BUTTON_NEUTRAL);
-        Thread.sleep(100);
+        getTimerFromFragment().runOneTask();
 
-        Intent captured = getLastCapturedIntent();
-        assertThat(captured.getAction()).isEqualTo(ACTION_FLASH_NOTIFICATION_START_PREVIEW);
-        assertThat(captured.getIntExtra(EXTRA_FLASH_NOTIFICATION_PREVIEW_TYPE, TYPE_SHORT_PREVIEW))
-                .isEqualTo(TYPE_LONG_PREVIEW);
-        assertThat(captured.getIntExtra(EXTRA_FLASH_NOTIFICATION_PREVIEW_COLOR, Color.TRANSPARENT))
-                .isEqualTo(ROSE.mColorInt);
+        assertStartPreview(ROSE.mColorInt);
+    }
+
+    @Test
+    public void clickNeutral_flushAllScheduledTasks_assertStopPreview() {
+        performClickOnDialog(BUTTON_NEUTRAL);
+        getTimerFromFragment().runAllTasks();
+
+        assertStopPreview();
     }
 
     @Test
@@ -116,51 +122,47 @@
     }
 
     @Test
-    public void clickNeutralAndPause_assertStopPreview() throws InterruptedException {
+    public void clickNeutralAndPause_assertStopPreview() {
         performClickOnDialog(BUTTON_NEUTRAL);
-        Thread.sleep(100);
+        getTimerFromFragment().runOneTask();
         mDialogFragment.onPause();
-        Thread.sleep(100);
 
-        assertThat(getLastCapturedIntent().getAction())
-                .isEqualTo(ACTION_FLASH_NOTIFICATION_STOP_PREVIEW);
+        assertStopPreview();
     }
 
     @Test
-    public void clickNeutralAndClickNegative_assertStopPreview() throws InterruptedException {
+    public void clickNeutralAndClickNegative_assertStopPreview() {
         performClickOnDialog(BUTTON_NEUTRAL);
-        Thread.sleep(100);
+        getTimerFromFragment().runOneTask();
         performClickOnDialog(BUTTON_NEGATIVE);
-        Thread.sleep(100);
 
-        assertThat(getLastCapturedIntent().getAction())
-                .isEqualTo(ACTION_FLASH_NOTIFICATION_STOP_PREVIEW);
+        assertStopPreview();
     }
 
     @Test
-    public void clickNeutralAndClickPositive_assertStopPreview() throws InterruptedException {
+    public void clickNeutralAndClickPositive_assertStopPreview() {
         performClickOnDialog(BUTTON_NEUTRAL);
-        Thread.sleep(100);
+        getTimerFromFragment().runOneTask();
         performClickOnDialog(BUTTON_POSITIVE);
-        Thread.sleep(100);
 
-        assertThat(getLastCapturedIntent().getAction())
-                .isEqualTo(ACTION_FLASH_NOTIFICATION_STOP_PREVIEW);
+        assertStopPreview();
     }
 
     @Test
-    public void clickNeutralAndClickColor_assertStartPreview() throws InterruptedException {
+    public void clickNeutralAndClickColor_assertStartPreview() {
         performClickOnDialog(BUTTON_NEUTRAL);
-        Thread.sleep(100);
+        getTimerFromFragment().runOneTask();
         checkColorButton(CYAN);
-        Thread.sleep(500);
+        // When changing the color while the preview is running, the fragment will schedule three
+        // tasks: stop the current preview, start the new preview, stop the new preview
+        int numOfPendingTasks = getTimerFromFragment().numOfPendingTasks();
+        // Run all the pending tasks except the last one
+        while (numOfPendingTasks > 1) {
+            getTimerFromFragment().runOneTask();
+            numOfPendingTasks--;
+        }
 
-        Intent captured = getLastCapturedIntent();
-        assertThat(captured.getAction()).isEqualTo(ACTION_FLASH_NOTIFICATION_START_PREVIEW);
-        assertThat(captured.getIntExtra(EXTRA_FLASH_NOTIFICATION_PREVIEW_TYPE, TYPE_SHORT_PREVIEW))
-                .isEqualTo(TYPE_LONG_PREVIEW);
-        assertThat(captured.getIntExtra(EXTRA_FLASH_NOTIFICATION_PREVIEW_COLOR, Color.TRANSPARENT))
-                .isEqualTo(CYAN.mColorInt);
+        assertStartPreview(CYAN.mColorInt);
     }
 
     @Test
@@ -168,6 +170,7 @@
         checkColorButton(AZURE);
         performClickOnDialog(BUTTON_NEGATIVE);
 
+        assertThat(getTimerFromFragment()).isNull();
         assertThat(mCurrentColor).isEqualTo(ROSE.mColorInt);
     }
 
@@ -193,4 +196,46 @@
         final int size = capturedIntents.size();
         return capturedIntents.get(size - 1);
     }
+
+    private ScreenFlashNotificationColorDialogFragment createFragment() {
+        ScreenFlashNotificationColorDialogFragmentWithFakeTimer fragment =
+                new ScreenFlashNotificationColorDialogFragmentWithFakeTimer();
+        ReflectionHelpers.setField(fragment, "mCurrentColor", mCurrentColor);
+        ReflectionHelpers.setField(fragment, "mConsumer",
+                (Consumer<Integer>) selectedColor -> mCurrentColor = selectedColor);
+
+        return fragment;
+    }
+
+    private FakeTimer getTimerFromFragment() {
+        return (FakeTimer) ReflectionHelpers.getField(mDialogFragment, "mTimer");
+    }
+
+    private void assertStartPreview(int color) {
+        Intent captured = getLastCapturedIntent();
+        assertThat(captured.getAction()).isEqualTo(ACTION_FLASH_NOTIFICATION_START_PREVIEW);
+        assertThat(captured.getIntExtra(EXTRA_FLASH_NOTIFICATION_PREVIEW_TYPE, TYPE_SHORT_PREVIEW))
+                .isEqualTo(TYPE_LONG_PREVIEW);
+        assertThat(captured.getIntExtra(EXTRA_FLASH_NOTIFICATION_PREVIEW_COLOR, Color.TRANSPARENT))
+                .isEqualTo(color);
+    }
+
+    private void assertStopPreview() {
+        assertThat(getTimerFromFragment().numOfPendingTasks()).isEqualTo(0);
+        assertThat(getLastCapturedIntent().getAction())
+                .isEqualTo(ACTION_FLASH_NOTIFICATION_STOP_PREVIEW);
+    }
+
+    /**
+     * A {@link ScreenFlashNotificationColorDialogFragment} that uses a fake timer so that it won't
+     * create unmanageable timer threads during test.
+     */
+    public static class ScreenFlashNotificationColorDialogFragmentWithFakeTimer extends
+            ScreenFlashNotificationColorDialogFragment {
+
+        @Override
+        Timer createTimer() {
+            return new FakeTimer();
+        }
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/devicelock/DeviceLockPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/devicelock/DeviceLockPreferenceControllerTest.java
index 3176969..3b81c83 100644
--- a/tests/robotests/src/com/android/settings/devicelock/DeviceLockPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/devicelock/DeviceLockPreferenceControllerTest.java
@@ -93,4 +93,17 @@
         outcomeReceiver.onResult(TEST_KIOSK_APPS);
         assertThat(preference.isVisible()).isTrue();
     }
+
+    @Test
+    public void testUpdateState_preferenceBecomesInvisibleIfDeviceLockManagerIsNotAvailable() {
+        Context context = spy(mContext);
+        when(context.getSystemService(DeviceLockManager.class)).thenReturn(null);
+        mController = new DeviceLockPreferenceController(context, TEST_PREFERENCE_KEY);
+
+        Preference preference = new Preference(mContext, null, 0, 0);
+        preference.setVisible(true);
+
+        mController.updateState(preference);
+        assertThat(preference.isVisible()).isFalse();
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java b/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java
index b7d249d..4903a28 100644
--- a/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java
+++ b/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java
@@ -119,6 +119,7 @@
     private Context mContext;
     private SettingsSliceProvider mProvider;
     private ShadowPackageManager mPackageManager;
+    private ShadowUserManager mShadowUserManager;
 
     @Mock
     private SliceManager mManager;
@@ -157,6 +158,7 @@
         when(mManager.getPinnedSlices()).thenReturn(Collections.emptyList());
 
         mPackageManager = Shadows.shadowOf(mContext.getPackageManager());
+        mShadowUserManager = ShadowUserManager.getShadow();
 
         SliceProvider.setSpecs(SliceLiveData.SUPPORTED_SPECS);
     }
@@ -293,6 +295,37 @@
     }
 
     @Test
+    public void onBindSlice_guestRestricted_returnsNull() {
+        final String key = "enable_usb_tethering";
+        mShadowUserManager.setGuestUser(true);
+        final Uri testUri = new Uri.Builder()
+            .scheme(ContentResolver.SCHEME_CONTENT)
+            .authority(SettingsSliceProvider.SLICE_AUTHORITY)
+            .appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
+            .appendPath(key)
+            .build();
+
+        final Slice slice = mProvider.onBindSlice(testUri);
+
+        assertThat(slice).isNull();
+    }
+
+    @Test
+    public void onBindSlice_notGuestRestricted_returnsNotNull() {
+        final String key = "enable_usb_tethering";
+        final Uri testUri = new Uri.Builder()
+            .scheme(ContentResolver.SCHEME_CONTENT)
+            .authority(SettingsSliceProvider.SLICE_AUTHORITY)
+            .appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
+            .appendPath(key)
+            .build();
+
+        final Slice slice = mProvider.onBindSlice(testUri);
+
+        assertThat(slice).isNotNull();
+    }
+
+    @Test
     public void getDescendantUris_fullActionUri_returnsSelf() {
         final Collection<Uri> descendants = mProvider.onGetSliceDescendants(ACTION_SLICE_URI);
 
diff --git a/tests/robotests/src/com/android/settings/slices/SlicePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/slices/SlicePreferenceControllerTest.java
index e8bd27d..56ea33c 100644
--- a/tests/robotests/src/com/android/settings/slices/SlicePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/slices/SlicePreferenceControllerTest.java
@@ -18,15 +18,15 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
-import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
 
+import android.annotation.NonNull;
 import android.content.Context;
 import android.net.Uri;
 
 import androidx.lifecycle.LiveData;
+import androidx.lifecycle.Observer;
 import androidx.slice.Slice;
 
 import org.junit.Before;
@@ -80,7 +80,6 @@
 
     @Test
     public void onStop_unregisterObserver() {
-        when(mLiveData.hasActiveObservers()).thenReturn(true);
         mController.onStart();
 
         mController.onStop();
@@ -88,20 +87,18 @@
     }
 
     @Test
-    public void onStop_noActiveObservers_notUnregisterObserver() {
-        when(mLiveData.hasActiveObservers()).thenReturn(false);
+    public void onStop_unregisterObserverAndHasSecurityException_noCrash() {
+        LiveData<Slice> liveData = new LiveData<Slice>() {
+            @Override
+            public void removeObserver(@NonNull Observer<? super Slice> observer) {
+                super.removeObserver(observer);
+                throw new SecurityException("SecurityException Test");
+            }
+        };
+        mController.mLiveData = liveData;
         mController.onStart();
 
         mController.onStop();
-        verify(mLiveData, never()).removeObserver(mController);
-    }
-
-    @Test
-    public void onStop_notRegisterObserver_notUnregisterObserver() {
-        when(mLiveData.hasActiveObservers()).thenReturn(true);
-
-        mController.onStop();
-        verify(mLiveData, never()).removeObserver(mController);
     }
 
     @Test
diff --git a/tests/robotests/src/com/android/settings/testutils/FakeTimer.java b/tests/robotests/src/com/android/settings/testutils/FakeTimer.java
new file mode 100644
index 0000000..d7934cb
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/testutils/FakeTimer.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.testutils;
+
+import java.util.PriorityQueue;
+import java.util.Timer;
+import java.util.TimerTask;
+
+/**
+ * A fake {@link Timer} that doesn't create a TimerThread which is hard to manage in test.
+ */
+public class FakeTimer extends Timer {
+    private final PriorityQueue<ScheduledTimerTask> mQueue = new PriorityQueue<>();
+
+    public FakeTimer() {
+    }
+
+    @Override
+    public void cancel() {
+        mQueue.clear();
+    }
+
+    @Override
+    public void schedule(TimerTask task, long delay) {
+        mQueue.offer(new ScheduledTimerTask(System.currentTimeMillis() + delay, task));
+    }
+
+    /**
+     * Runs the first task in the queue if there's any.
+     */
+    public void runOneTask() {
+        if (mQueue.size() > 0) {
+            mQueue.poll().mTask.run();
+        }
+    }
+
+    /**
+     * Runs all the queued tasks in order.
+     */
+    public void runAllTasks() {
+        while (mQueue.size() > 0) {
+            mQueue.poll().mTask.run();
+        }
+    }
+
+    /**
+     * Returns number of pending tasks in the timer
+     */
+    public int numOfPendingTasks() {
+        return mQueue.size();
+    }
+
+    private static class ScheduledTimerTask implements Comparable<ScheduledTimerTask> {
+        final long mTimeToRunInMillisSeconds;
+        final TimerTask mTask;
+
+        ScheduledTimerTask(long timeToRunInMilliSeconds, TimerTask task) {
+            this.mTimeToRunInMillisSeconds = timeToRunInMilliSeconds;
+            this.mTask = task;
+        }
+
+        @Override
+        public int compareTo(ScheduledTimerTask other) {
+            return Long.compare(this.mTimeToRunInMillisSeconds, other.mTimeToRunInMillisSeconds);
+        }
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowUserManager.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowUserManager.java
index df38420..324a829 100644
--- a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowUserManager.java
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowUserManager.java
@@ -55,6 +55,7 @@
     private int[] profileIdsForUser = new int[0];
     private boolean mUserSwitchEnabled;
     private Bundle mDefaultGuestUserRestriction = new Bundle();
+    private boolean mIsGuestUser = false;
 
     private @UserManager.UserSwitchabilityResult int mSwitchabilityStatus =
             UserManager.SWITCHABILITY_STATUS_OK;
@@ -270,4 +271,13 @@
             mUserProfileInfos.get(i).flags |= UserInfo.FLAG_ADMIN;
         }
     }
+
+    @Implementation
+    protected boolean isGuestUser() {
+        return mIsGuestUser;
+    }
+
+    public void setGuestUser(boolean isGuestUser) {
+        mIsGuestUser = isGuestUser;
+    }
 }
diff --git a/tests/spa_unit/src/com/android/settings/spa/development/compat/PlatformCompatAppListModelTest.kt b/tests/spa_unit/src/com/android/settings/spa/development/compat/PlatformCompatAppListModelTest.kt
new file mode 100644
index 0000000..78aca85
--- /dev/null
+++ b/tests/spa_unit/src/com/android/settings/spa/development/compat/PlatformCompatAppListModelTest.kt
@@ -0,0 +1,107 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.spa.development.compat
+
+import android.content.Context
+import android.content.pm.ApplicationInfo
+import android.content.pm.PackageManager
+import android.content.pm.PackageManager.PackageInfoFlags
+import androidx.compose.runtime.State
+import androidx.compose.ui.test.junit4.createComposeRule
+import androidx.test.core.app.ApplicationProvider
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import com.google.common.truth.Truth.assertThat
+import kotlinx.coroutines.ExperimentalCoroutinesApi
+import kotlinx.coroutines.flow.first
+import kotlinx.coroutines.flow.flowOf
+import kotlinx.coroutines.test.runTest
+import org.junit.Before
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.mockito.Mock
+import org.mockito.Mockito.any
+import org.mockito.Mockito.anyInt
+import org.mockito.Spy
+import org.mockito.junit.MockitoJUnit
+import org.mockito.junit.MockitoRule
+import org.mockito.Mockito.`when` as whenever
+
+@OptIn(ExperimentalCoroutinesApi::class)
+@RunWith(AndroidJUnit4::class)
+class PlatformCompatAppListModelTest {
+    @get:Rule
+    val composeTestRule = createComposeRule()
+
+    @get:Rule
+    val mockito: MockitoRule = MockitoJUnit.rule()
+
+    @Spy
+    private val context: Context = ApplicationProvider.getApplicationContext()
+
+    @Mock
+    private lateinit var packageManager: PackageManager
+
+    private lateinit var listModel: PlatformCompatAppListModel
+
+    @Before
+    fun setUp() {
+        whenever(context.packageManager).thenReturn(packageManager)
+        whenever(packageManager.getInstalledPackagesAsUser(any<PackageInfoFlags>(), anyInt()))
+            .thenReturn(emptyList())
+        listModel = PlatformCompatAppListModel(context)
+    }
+
+    @Test
+    fun transform() = runTest {
+        val recordListFlow = listModel.transform(
+            userIdFlow = flowOf(USER_ID),
+            appListFlow = flowOf(listOf(APP)),
+        )
+
+        val recordList = recordListFlow.first()
+        assertThat(recordList).hasSize(1)
+        val record = recordList[0]
+        assertThat(record.app).isSameInstanceAs(APP)
+    }
+
+    @Test
+    fun getSummary() = runTest {
+        val summaryState = getSummaryState(APP)
+
+        assertThat(summaryState.value).isEqualTo(PACKAGE_NAME)
+    }
+
+    private fun getSummaryState(app: ApplicationInfo): State<String> {
+        lateinit var summary: State<String>
+        composeTestRule.setContent {
+            summary = listModel.getSummary(
+                option = 0,
+                record = PlatformCompatAppRecord(app),
+            )
+        }
+        return summary
+    }
+
+    private companion object {
+        const val USER_ID = 0
+        const val PACKAGE_NAME = "package.name"
+        val APP = ApplicationInfo().apply {
+            packageName = PACKAGE_NAME
+        }
+    }
+}
\ No newline at end of file