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

Commit 7f70ba18 authored by Billy Lau's avatar Billy Lau
Browse files

Bug: 21589105 Rescoping SYSTEM_ALERT_WINDOW and WRITE_SETTINGS permission to an

explicit toggle to be enabled through Settings via Apps -> Advanced Apps.

Added new and refactored an old xml to define the UX for two new Preferences
in Advanced Settings. Modified the existing AdvancedAppSettings to add
control flow for two new settings. Also enriched ManageApplications to
handle these cases. Added additional strings in xml/values/strings.xml
to support these settings. Also defined new classes to handle these the
toggle of these permissions per app.

Refactored codes from AppStateUsageBridge to a generic AppStateAppOpsBridge so
that future usages related to AppOps can inherit from this class.

Change-Id: I43b81282a063e05844c7805556a6d05cfc02bcdb
parent 01ce80b5
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -2522,5 +2522,23 @@
            </intent-filter>
        </provider>

        <activity android:name="Settings$OverlaySettingsActivity"
                android:label="@string/draw_overlay_title"
                android:taskAffinity="">
            <intent-filter android:priority="1">
                <action android:name="android.settings.action.MANAGE_OVERLAY_PERMISSION" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

        <activity android:name="Settings$WriteSettingsActivity"
                android:label="@string/write_settings_title"
                android:taskAffinity="">
            <intent-filter android:priority="1">
                <action android:name="android.settings.action.MANAGE_WRITE_SETTINGS" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

    </application>
</manifest>
+59 −0
Original line number Diff line number Diff line
@@ -6855,4 +6855,63 @@
    <!-- Number of characters used for lock screen text [CHAR LIMIT=NONE] -->
    <string name="accessibility_lock_screen_progress"><xliff:g id="count" example="1">%1$d</xliff:g> of <xliff:g id="count" example="1">%2$d</xliff:g> characters used</string>
    <!-- System Alert Window settings -->
    <!-- Title of Draw Overlay preference item [CHAR LIMIT=30] -->
    <string name="draw_overlay_title">Apps that can draw overlay</string>
    <!-- Title of draw overlay screen [CHAR LIMIT=30] -->
    <string name="draw_overlay">Draw over other apps</string>
    <!-- Settings title in main settings screen for SYSTEM_ALERT_WINDOW [CHAR LIMIT=45] -->
    <string name="system_alert_window_settings">Draw over other apps</string>
    <!-- Title for the apps with SYSTEM_ALERT_WINDOW permission/privilege [CHAR LIMIT=20] -->
    <string name="system_alert_window_apps_title">Apps</string>
    <!-- Title for the apps that are allowed to draw on top of other apps [CHAR LIMIT=60] -->
    <string name="system_alert_window_access_title">Can draw overlays</string>
    <!-- Label for setting which controls whether app can draw overlays [CHAR LIMIT=45] -->
    <string name="permit_draw_overlay">Permit drawing overlays</string>
    <!-- Link to the apps page for SYSTEM_ALERT_WINDOW settings [CHAR LIMIT=45] -->
    <string name="app_overlay_permission_preference">App draw on top permission</string>
    <!-- Description of allowing overlay setting [CHAR LIMIT=NONE] -->
    <string name="allow_overlay_description">This permission allows an app to display on top of other apps you\u2019re using and may interfere with your use of the interface in other applications, or change what you think you are seeing in other applications.</string>
    <!-- Keyword for SYSTEM_ALERT_WINDOW -->
    <string name="keywords_system_alert_window">system alert window dialog draw on top other apps</string>
    <!-- Main settings screen item's title to go into the overlay settings screen [CHAR LIMIT=25] -->
    <string name="overlay_settings">Overlay settings</string>
    <!-- Summary of number of apps currently can draw overlays [CHAR LIMIT=60] -->
    <string name="system_alert_window_summary"><xliff:g id="count" example="10">%d</xliff:g> of <xliff:g id="count" example="10">%d</xliff:g> apps allowed to draw on top of other apps</string>
    <!-- Label for showing apps that can draw overlays [CHAR LIMIT=45] -->
    <string name="filter_overlay_apps">Apps with permission</string>
    <!-- Summary of app allowed to draw overlay [CHAR LIMIT=60] -->
    <string name="system_alert_window_on">Yes</string>
    <!-- Summary of app not allowed to draw overlay [CHAR LIMIT=60] -->
    <string name="system_alert_window_off">No</string>
    <!-- Write Settings settings -->
    <!-- Settings title in main settings screen for WRITE_SETTINGS [CHAR LIMIT=30] -->
    <string name="write_settings">Write system settings</string>
    <!-- Keyword for WRITE_SETTINGS -->
    <string name="keywords_write_settings">write modify system settings</string>
    <!-- Summary of number of apps currently can draw overlays [CHAR LIMIT=60] -->
    <string name="write_settings_summary"><xliff:g id="count" example="10">%d</xliff:g> of <xliff:g id="count" example="10">%d</xliff:g> apps allowed to read or write system settings</string>
    <!-- Label for showing apps that can write system settings [CHAR LIMIT=45] -->
    <string name="filter_write_settings_apps">Can write system settings</string>
    <!-- Title for the apps that are allowed to write system settings [CHAR LIMIT=60] -->
    <string name="write_settings_title">Can write system settings</string>
    <!-- Main settings screen item's title to go into the write system settings screen [CHAR LIMIT=25] -->
    <string name="write_system_settings">Write system settings</string>
    <!-- Link to the apps page for WRITE_SETTINGS settings [CHAR LIMIT=45] -->
    <string name="write_settings_preference">App write system settings permission</string>
    <!-- Label for setting which controls whether app can write system settings [CHAR LIMIT=45] -->
    <string name="permit_write_settings">Allow write system settings</string>
    <!-- Description of the write system settings [CHAR LIMIT=NONE] -->
    <string name="write_settings_description">This permission allows an app to read or write system settings.</string>
    <!-- Summary of app allowed to write system settings [CHAR LIMIT=45] -->
    <string name="write_settings_on">Yes</string>
    <!-- Summary of app not allowed to write system settings [CHAR LIMIT=45] -->
    <string name="write_settings_off">No</string>
</resources>
+20 −0
Original line number Diff line number Diff line
@@ -42,6 +42,26 @@
        android:title="@string/default_apps_title"
        settings:keywords="@string/keywords_default_apps" />

    <PreferenceScreen
        android:key="system_alert_window"
        android:title="@string/system_alert_window_settings"
        android:fragment="com.android.settings.applications.ManageApplications"
        settings:keywords="@string/keywords_system_alert_window">
        <extra
            android:name="classname"
            android:value="com.android.settings.Settings$OverlaySettingsActivity" />
    </PreferenceScreen>

    <PreferenceScreen
        android:key="write_settings_apps"
        android:title="@string/write_settings"
        android:fragment="com.android.settings.applications.ManageApplications"
        settings:keywords="@string/keywords_write_settings">
        <extra
            android:name="classname"
            android:value="com.android.settings.Settings$WriteSettingsActivity" />
    </PreferenceScreen>

    <PreferenceScreen
        android:key="high_power_apps"
        android:title="@string/high_power_apps"
+4 −7
Original line number Diff line number Diff line
@@ -15,19 +15,16 @@
-->

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
    android:title="@string/usage_access">
    xmlns:settings="http://schemas.android.com/apk/res/com.android.settings">

    <SwitchPreference
        android:key="usage_switch"
        android:title="@string/permit_usage_access" />
        android:key="app_ops_settings_switch" />

    <Preference
        android:key="app_usage_preference"
        android:title="@string/app_usage_preference" />
        android:key="app_ops_settings_preference" />

    <Preference
        android:summary="@string/usage_access_description"
        android:key="app_ops_settings_description"
        android:selectable="false" />

</PreferenceScreen>
+2 −1
Original line number Diff line number Diff line
@@ -114,5 +114,6 @@ public class Settings extends SettingsActivity {
    public static class ApnSettingsActivity extends SettingsActivity { /* empty */ }
    public static class WifiCallingSettingsActivity extends SettingsActivity { /* empty */ }
    public static class MemorySettingsActivity extends SettingsActivity { /* empty */ }
    public static class OverlaySettingsActivity extends SettingsActivity { /* empty */ }
    public static class WriteSettingsActivity extends SettingsActivity { /* empty */ }
}
Loading