Settings page to manage FSI permission

Apps > Special App Access > Manage Full Screen Intents > App Specific page

Follows new Settings Platform Architecture that the Settings team
is migrating to for UDC.

Bug: 243421660
Test: make SettingsGoogle -j40
adb install -r out/target/product/$TARGET_PRODUCT/system_ext/priv-app/SettingsGoogle/SettingsGoogle.apk

Change-Id: Id2ca18480ddf788bee18b67a3689ef9593059a24
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index d357e8c..863ace4 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1681,6 +1681,25 @@
                        android:value="@string/menu_key_apps"/>
         </activity-alias>
 
+        <activity-alias android:name="com.google.android.settings.ManageFullScreenIntent"
+                        android:exported="true"
+                        android:targetActivity=".spa.SpaBridgeActivity">
+            <meta-data android:name="com.android.settings.spa.DESTINATION"
+                       android:value="TogglePermissionAppList/UseFullScreenIntent"/>
+        </activity-alias>
+
+        <activity-alias android:name="com.google.android.settings.AppManageFullScreenIntent"
+                        android:exported="true"
+                        android:targetActivity=".spa.SpaAppBridgeActivity">
+            <intent-filter>
+                <action android:name="android.settings.MANAGE_APP_USE_FULL_SCREEN_INTENT" />
+                <category android:name="android.intent.category.DEFAULT" />
+                <data android:scheme="package" />
+            </intent-filter>
+            <meta-data android:name="com.android.settings.spa.DESTINATION"
+                       android:value="TogglePermissionAppInfoPage/UseFullScreenIntent"/>
+        </activity-alias>
+
         <activity android:name=".applications.InstalledAppOpenByDefaultActivity"
                   android:label="@string/application_info_label"
                   android:exported="true">
diff --git a/res/values/strings.xml b/res/values/strings.xml
index ecd8aad..36d17ca 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -8880,6 +8880,15 @@
     <!-- Label for showing apps that can manage external storage[CHAR LIMIT=45] -->
     <string name="filter_manage_external_storage">Can access all files</string>
 
+    <!-- Manage full screen intent permission title [CHAR LIMIT=40] -->
+    <string name="full_screen_intent_title">Manage full screen intents</string>
+
+    <!-- Label for setting that allows apps to send full screen intents. [CHAR LIMIT=NONE] -->
+    <string name="permit_full_screen_intent">Allow apps to send full screen intents</string>
+
+    <!-- Description for setting that allows apps to send full screen intents. [CHAR LIMIT=NONE] -->
+    <string name="footer_description_full_screen_intent">Allow this app to send full screen intent notifications that cover the entire screen.</string>
+
     <!-- Media management apps settings title [CHAR LIMIT=40] -->
     <string name="media_management_apps_title">Media management apps</string>
     <!-- Label for a setting which controls whether an app can manage media files [CHAR LIMIT=45] -->
diff --git a/res/xml/special_access.xml b/res/xml/special_access.xml
index e6dd3ed..eb02369 100644
--- a/res/xml/special_access.xml
+++ b/res/xml/special_access.xml
@@ -95,6 +95,11 @@
         settings:controller="com.android.settings.applications.specialaccess.notificationaccess.NotificationAccessController" />
 
     <Preference
+        android:key="use_full_screen_intent"
+        android:title="@string/full_screen_intent_title"
+        settings:controller="com.android.settings.spa.app.specialaccess.UseFullScreenIntentPreferenceController" />
+
+    <Preference
         android:key="picture_in_picture"
         android:title="@string/picture_in_picture_title"
         android:order="900"
diff --git a/src/com/android/settings/spa/SettingsSpaEnvironment.kt b/src/com/android/settings/spa/SettingsSpaEnvironment.kt
index 55ea0c9..15aaa74 100644
--- a/src/com/android/settings/spa/SettingsSpaEnvironment.kt
+++ b/src/com/android/settings/spa/SettingsSpaEnvironment.kt
@@ -31,6 +31,7 @@
 import com.android.settings.spa.app.specialaccess.PictureInPictureListProvider
 import com.android.settings.spa.app.specialaccess.SpecialAppAccessPageProvider
 import com.android.settings.spa.app.specialaccess.WifiControlAppListProvider
+import com.android.settings.spa.app.specialaccess.UseFullScreenIntentAppListProvider
 import com.android.settings.spa.development.UsageStatsPageProvider
 import com.android.settings.spa.home.HomePageProvider
 import com.android.settings.spa.notification.AppListNotificationsPageProvider
@@ -51,6 +52,7 @@
             DisplayOverOtherAppsAppListProvider,
             MediaManagementAppsAppListProvider,
             ModifySystemSettingsAppListProvider,
+            UseFullScreenIntentAppListProvider,
             PictureInPictureListProvider,
             InstallUnknownAppsListProvider,
             AlarmsAndRemindersAppListProvider,
diff --git a/src/com/android/settings/spa/app/specialaccess/SpecialAppAccess.kt b/src/com/android/settings/spa/app/specialaccess/SpecialAppAccess.kt
index 5b9205a..e9cfafb 100644
--- a/src/com/android/settings/spa/app/specialaccess/SpecialAppAccess.kt
+++ b/src/com/android/settings/spa/app/specialaccess/SpecialAppAccess.kt
@@ -60,6 +60,7 @@
                 DisplayOverOtherAppsAppListProvider,
                 MediaManagementAppsAppListProvider,
                 ModifySystemSettingsAppListProvider,
+                UseFullScreenIntentAppListProvider,
                 PictureInPictureListProvider,
                 InstallUnknownAppsListProvider,
                 AlarmsAndRemindersAppListProvider,
diff --git a/src/com/android/settings/spa/app/specialaccess/UseFullScreenIntent.kt b/src/com/android/settings/spa/app/specialaccess/UseFullScreenIntent.kt
new file mode 100644
index 0000000..514e480
--- /dev/null
+++ b/src/com/android/settings/spa/app/specialaccess/UseFullScreenIntent.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.app.specialaccess
+
+import android.Manifest
+import android.app.AppOpsManager
+import android.content.Context
+import com.android.settings.R
+import com.android.settingslib.spaprivileged.template.app.AppOpPermissionListModel
+import com.android.settingslib.spaprivileged.template.app.TogglePermissionAppListProvider
+
+object UseFullScreenIntentAppListProvider : TogglePermissionAppListProvider {
+    override val permissionType = "UseFullScreenIntent"
+    override fun createModel(context: Context) = UseFullScreenIntentListModel(context)
+}
+
+class UseFullScreenIntentListModel(context: Context) : AppOpPermissionListModel(context) {
+    override val pageTitleResId = R.string.full_screen_intent_title
+    override val switchTitleResId = R.string.permit_full_screen_intent
+    override val footerResId = R.string.footer_description_full_screen_intent
+    override val appOp = AppOpsManager.OP_USE_FULL_SCREEN_INTENT
+    override val permission = Manifest.permission.USE_FULL_SCREEN_INTENT
+    override val setModeByUid = true
+}
diff --git a/src/com/android/settings/spa/app/specialaccess/UseFullScreenIntentPreferenceController.java b/src/com/android/settings/spa/app/specialaccess/UseFullScreenIntentPreferenceController.java
new file mode 100644
index 0000000..1c764b6
--- /dev/null
+++ b/src/com/android/settings/spa/app/specialaccess/UseFullScreenIntentPreferenceController.java
@@ -0,0 +1,47 @@
+/*
+ * 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.app.specialaccess;
+
+import android.content.Context;
+import android.os.Build;
+import android.text.TextUtils;
+
+import androidx.preference.Preference;
+
+import com.android.settings.core.BasePreferenceController;
+import com.android.settings.spa.SpaActivity;
+
+public class UseFullScreenIntentPreferenceController extends BasePreferenceController {
+    public UseFullScreenIntentPreferenceController(Context context, String preferenceKey) {
+        super(context, preferenceKey);
+    }
+
+    @Override
+    public int getAvailabilityStatus() {
+        return AVAILABLE;
+    }
+
+    @Override
+    public boolean handlePreferenceTreeClick(Preference preference) {
+        if (TextUtils.equals(preference.getKey(), mPreferenceKey)) {
+            SpaActivity.startSpaActivity(
+                    mContext, UseFullScreenIntentAppListProvider.INSTANCE.getAppListRoute());
+            return true;
+        }
+        return false;
+    }
+}