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

Commit e8ffc29f authored by HJ ChangLiao's avatar HJ ChangLiao
Browse files

Remove ops preference from specific app

Remve below preference in Settings>Apps>Specific app:
Display over apps screen> App display on top permisson
Usage access> App usage preferences
Modify system settings> App modify system settings permission

Change-Id: Ib4128e563b0e2739c16136694ce24182f0da6626
Fixes: 72737995
Test: Manual test
parent 47862916
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -8342,8 +8342,6 @@
    <string name="system_alert_window_access_title">Display over other apps</string>
    <!-- Label for setting which controls whether app can display over other apps [CHAR LIMIT=45] -->
    <string name="permit_draw_overlay">Allow display over other apps</string>
    <!-- Link to the apps page for SYSTEM_ALERT_WINDOW settings [CHAR LIMIT=45] -->
    <string name="app_overlay_permission_preference">App display on top permission</string>
    <!-- Description of allowing overlay setting [CHAR LIMIT=NONE] -->
    <string name="allow_overlay_description">Allow this app to display on top of other apps you\u2019re using. It may interfere with your use of those apps or change the way they seem to appear or behave.</string>
@@ -8385,8 +8383,6 @@
    <string name="write_settings_title">Can modify system settings</string>
    <!-- Main settings screen item's title to go into the write system settings screen [CHAR LIMIT=30] -->
    <string name="write_system_settings">Modify system settings</string>
    <!-- Link to the apps page for WRITE_SETTINGS settings [CHAR LIMIT=52] -->
    <string name="write_settings_preference">App modify system settings permission</string>
    <!-- Label for setting which controls whether app can write system settings [CHAR LIMIT=45] -->
    <string name="permit_write_settings">Allow modifying system settings</string>
    <!-- Description of the write system settings [CHAR LIMIT=NONE] -->
+0 −3
Original line number Diff line number Diff line
@@ -20,9 +20,6 @@
    <SwitchPreference
        android:key="app_ops_settings_switch" />

    <Preference
        android:key="app_ops_settings_preference" />

    <Preference
        android:key="app_ops_settings_description"
        android:selectable="false" />
+0 −4
Original line number Diff line number Diff line
@@ -22,10 +22,6 @@
        android:key="app_ops_settings_switch"
        android:title="@string/permit_draw_overlay"/>

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

    <Preference
        android:summary="@string/allow_overlay_description"
        android:selectable="false"/>
+0 −4
Original line number Diff line number Diff line
@@ -22,10 +22,6 @@
        android:key="app_ops_settings_switch"
        android:title="@string/permit_write_settings"/>

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

    <Preference
        android:summary="@string/write_settings_description"
        android:selectable="false"/>
+0 −23
Original line number Diff line number Diff line
@@ -45,7 +45,6 @@ public class UsageAccessDetails extends AppInfoWithHeader implements OnPreferenc

    private static final String KEY_APP_OPS_PREFERENCE_SCREEN = "app_ops_preference_screen";
    private static final String KEY_APP_OPS_SETTINGS_SWITCH = "app_ops_settings_switch";
    private static final String KEY_APP_OPS_SETTINGS_PREFS = "app_ops_settings_preference";
    private static final String KEY_APP_OPS_SETTINGS_DESC = "app_ops_settings_description";

    // Use a bridge to get the usage stats but don't initialize it to connect with all state.
@@ -53,7 +52,6 @@ public class UsageAccessDetails extends AppInfoWithHeader implements OnPreferenc
    private AppStateUsageBridge mUsageBridge;
    private AppOpsManager mAppOpsManager;
    private SwitchPreference mSwitchPref;
    private Preference mUsagePrefs;
    private Preference mUsageDesc;
    private Intent mSettingsIntent;
    private UsageState mUsageState;
@@ -70,16 +68,13 @@ public class UsageAccessDetails extends AppInfoWithHeader implements OnPreferenc

        addPreferencesFromResource(R.xml.app_ops_permissions_details);
        mSwitchPref = (SwitchPreference) findPreference(KEY_APP_OPS_SETTINGS_SWITCH);
        mUsagePrefs = findPreference(KEY_APP_OPS_SETTINGS_PREFS);
        mUsageDesc = findPreference(KEY_APP_OPS_SETTINGS_DESC);

        getPreferenceScreen().setTitle(R.string.usage_access);
        mSwitchPref.setTitle(R.string.permit_usage_access);
        mUsagePrefs.setTitle(R.string.app_usage_preference);
        mUsageDesc.setSummary(R.string.usage_access_description);

        mSwitchPref.setOnPreferenceChangeListener(this);
        mUsagePrefs.setOnPreferenceClickListener(this);

        mSettingsIntent = new Intent(Intent.ACTION_MAIN)
                .addCategory(Settings.INTENT_CATEGORY_USAGE_ACCESS_CONFIG)
@@ -88,16 +83,6 @@ public class UsageAccessDetails extends AppInfoWithHeader implements OnPreferenc

    @Override
    public boolean onPreferenceClick(Preference preference) {
        if (preference == mUsagePrefs) {
            if (mSettingsIntent != null) {
                try {
                    getActivity().startActivityAsUser(mSettingsIntent, new UserHandle(mUserId));
                } catch (ActivityNotFoundException e) {
                    Log.w(TAG, "Unable to launch app usage access settings " + mSettingsIntent, e);
                }
            }
            return true;
        }
        return false;
    }

@@ -150,14 +135,10 @@ public class UsageAccessDetails extends AppInfoWithHeader implements OnPreferenc
        boolean hasAccess = mUsageState.isPermissible();
        mSwitchPref.setChecked(hasAccess);
        mSwitchPref.setEnabled(mUsageState.permissionDeclared);
        mUsagePrefs.setEnabled(hasAccess);

        ResolveInfo resolveInfo = mPm.resolveActivityAsUser(mSettingsIntent,
                PackageManager.GET_META_DATA, mUserId);
        if (resolveInfo != null) {
            if (findPreference(KEY_APP_OPS_SETTINGS_PREFS) == null) {
                getPreferenceScreen().addPreference(mUsagePrefs);
            }
            Bundle metaData = resolveInfo.activityInfo.metaData;
            mSettingsIntent.setComponent(new ComponentName(resolveInfo.activityInfo.packageName,
                    resolveInfo.activityInfo.name));
@@ -166,10 +147,6 @@ public class UsageAccessDetails extends AppInfoWithHeader implements OnPreferenc
                mSwitchPref.setSummary(
                        metaData.getString(Settings.METADATA_USAGE_ACCESS_REASON));
            }
        } else {
            if (findPreference(KEY_APP_OPS_SETTINGS_PREFS) != null) {
                getPreferenceScreen().removePreference(mUsagePrefs);
            }
        }

        return true;
Loading