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

Commit d9f8f576 authored by Svet Ganov's avatar Svet Ganov
Browse files

Remove the obsolete 'show legacy' option from permission screens

bug:22523221

Change-Id: I09b605c7689c7402942c02a2639f1f28c7ee0c54
parent e6c7e911
Loading
Loading
Loading
Loading
+0 −24
Original line number Original line Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2015 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.
-->

<menu xmlns:android="http://schemas.android.com/apk/res/android">

    <item
        android:id="@+id/toggle_legacy_permissions"
        android:title="@string/show_legacy_permissions">
    </item>

</menu>
+0 −6
Original line number Original line Diff line number Diff line
@@ -221,12 +221,6 @@
    <!-- Warning for turning off permissions on older apps -->
    <!-- Warning for turning off permissions on older apps -->
    <string name="old_sdk_deny_warning">This app was designed for an older version of Android. Denying permission may cause it to no longer function as intended.</string>
    <string name="old_sdk_deny_warning">This app was designed for an older version of Android. Denying permission may cause it to no longer function as intended.</string>


    <!-- Label for the menu option to show legacy permissions [CHAR LIMIT=40] -->
    <string name="show_legacy_permissions">Show legacy</string>

    <!-- Label for the menu option to hide legacy permissions [CHAR LIMIT=40] -->
    <string name="hide_legacy_permissions">Hide legacy</string>

    <!-- The default description of a permission, i.e. what it does.  [CHAR LIMIT=40] -->
    <!-- The default description of a permission, i.e. what it does.  [CHAR LIMIT=40] -->
    <string name="default_permission_description">perform an unknown action</string>
    <string name="default_permission_description">perform an unknown action</string>


+1 −1
Original line number Original line Diff line number Diff line
@@ -75,7 +75,7 @@ public class PermissionStatusReceiver extends BroadcastReceiver {
            int additionalCount = 0;
            int additionalCount = 0;


            for (AppPermissionGroup group : appPermissions.getPermissionGroups()) {
            for (AppPermissionGroup group : appPermissions.getPermissionGroups()) {
                if (Utils.shouldShowPermission(group, false)) {
                if (Utils.shouldShowPermission(group)) {
                    totalCount++;
                    totalCount++;
                    if (group.areRuntimePermissionsGranted()) {
                    if (group.areRuntimePermissionsGranted()) {
                        grantedCount++;
                        grantedCount++;
+2 −27
Original line number Original line Diff line number Diff line
@@ -71,7 +71,6 @@ public final class AppPermissionsFragment extends SettingsWithHeader
    private PreferenceScreen mExtraScreen;
    private PreferenceScreen mExtraScreen;


    private boolean mHasConfirmedRevoke;
    private boolean mHasConfirmedRevoke;
    private boolean mShowLegacyPermissions;


    public static AppPermissionsFragment newInstance(String packageName) {
    public static AppPermissionsFragment newInstance(String packageName) {
        return setPackageName(new AppPermissionsFragment(), packageName);
        return setPackageName(new AppPermissionsFragment(), packageName);
@@ -127,12 +126,6 @@ public final class AppPermissionsFragment extends SettingsWithHeader
                return true;
                return true;
            }
            }


            case R.id.toggle_legacy_permissions: {
                mShowLegacyPermissions = !mShowLegacyPermissions;
                loadPreferences();
                return true;
            }

            case MENU_ALL_PERMS: {
            case MENU_ALL_PERMS: {
                Fragment frag = AllAppPermissionsFragment.newInstance(
                Fragment frag = AllAppPermissionsFragment.newInstance(
                        getArguments().getString(Intent.EXTRA_PACKAGE_NAME));
                        getArguments().getString(Intent.EXTRA_PACKAGE_NAME));
@@ -157,20 +150,9 @@ public final class AppPermissionsFragment extends SettingsWithHeader
    @Override
    @Override
    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
        super.onCreateOptionsMenu(menu, inflater);
        super.onCreateOptionsMenu(menu, inflater);
        inflater.inflate(R.menu.toggle_legacy_permissions, menu);
        menu.add(Menu.NONE, MENU_ALL_PERMS, Menu.NONE, R.string.all_permissions);
        menu.add(Menu.NONE, MENU_ALL_PERMS, Menu.NONE, R.string.all_permissions);
    }
    }


    @Override
    public void onPrepareOptionsMenu(Menu menu) {
        MenuItem item = menu.findItem(R.id.toggle_legacy_permissions);
        if (!mShowLegacyPermissions) {
            item.setTitle(R.string.show_legacy_permissions);
        } else {
            item.setTitle(R.string.hide_legacy_permissions);
        }
    }

    private static void bindUi(SettingsWithHeader fragment, PackageInfo packageInfo) {
    private static void bindUi(SettingsWithHeader fragment, PackageInfo packageInfo) {
        Activity activity = fragment.getActivity();
        Activity activity = fragment.getActivity();
        PackageManager pm = activity.getPackageManager();
        PackageManager pm = activity.getPackageManager();
@@ -223,18 +205,11 @@ public final class AppPermissionsFragment extends SettingsWithHeader
        extraPerms.setTitle(R.string.additional_permissions);
        extraPerms.setTitle(R.string.additional_permissions);


        for (AppPermissionGroup group : mAppPermissions.getPermissionGroups()) {
        for (AppPermissionGroup group : mAppPermissions.getPermissionGroups()) {
            if (!Utils.shouldShowPermission(group, true /* showLegacy */)) {
            if (!Utils.shouldShowPermission(group)) {
                continue;
                continue;
            }
            }


            boolean isPlatform = group.getDeclaringPackage().equals(Utils.OS_PKG);
            boolean isPlatform = group.getDeclaringPackage().equals(Utils.OS_PKG);
            boolean isLegacy = isPlatform && !Utils.isModernPermissionGroup(group.getName());
            boolean isTelevision = Utils.isTelevision(context);

            if (isLegacy && !mShowLegacyPermissions && !isTelevision) {
                // Television shows legacy on the extra screen
                continue;
            }


            SwitchPreference preference = new SwitchPreference(context);
            SwitchPreference preference = new SwitchPreference(context);
            preference.setOnPreferenceChangeListener(this);
            preference.setOnPreferenceChangeListener(this);
@@ -251,7 +226,7 @@ public final class AppPermissionsFragment extends SettingsWithHeader
            preference.setEnabled(!group.isPolicyFixed());
            preference.setEnabled(!group.isPolicyFixed());
            preference.setChecked(group.areRuntimePermissionsGranted());
            preference.setChecked(group.areRuntimePermissionsGranted());


            if (isPlatform && (!isLegacy || !isTelevision)) {
            if (isPlatform) {
                screen.addPreference(preference);
                screen.addPreference(preference);
            } else {
            } else {
                if (mExtraScreen == null) {
                if (mExtraScreen == null) {
+10 −2
Original line number Original line Diff line number Diff line
@@ -34,6 +34,7 @@ import android.text.SpannableString;
import android.text.style.ForegroundColorSpan;
import android.text.style.ForegroundColorSpan;
import android.util.ArrayMap;
import android.util.ArrayMap;
import android.util.Log;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.View;
import android.view.Window;
import android.view.Window;
@@ -246,8 +247,15 @@ public class GrantPermissionsActivity extends Activity
    }
    }


    @Override
    @Override
    public void onBackPressed() {
    public boolean onKeyDown(int keyCode, KeyEvent event)  {
        mViewHandler.onBackPressed();
        // We do not allow backing out.
        return keyCode == KeyEvent.KEYCODE_BACK;
    }

    @Override
    public boolean onKeyUp(int keyCode, KeyEvent event)  {
        // We do not allow backing out.
        return keyCode == KeyEvent.KEYCODE_BACK;
    }
    }


    @Override
    @Override
Loading