diff options
author | Heemin Seog <hseog@google.com> | 2019-05-20 17:39:46 -0700 |
---|---|---|
committer | Heemin Seog <hseog@google.com> | 2019-05-21 10:00:01 -0700 |
commit | 78dd1ef10b5632bf00fa1edd662c4a41a3e02b37 (patch) | |
tree | 368d7ef5b006ef8d234939c3d3e235c3d8f93e5b | |
parent | 337bd824d7b55c0ee81acf4b601425eec8af5ab5 (diff) | |
download | android_packages_apps_PackageInstaller-78dd1ef10b5632bf00fa1edd662c4a41a3e02b37.tar.gz android_packages_apps_PackageInstaller-78dd1ef10b5632bf00fa1edd662c4a41a3e02b37.tar.bz2 android_packages_apps_PackageInstaller-78dd1ef10b5632bf00fa1edd662c4a41a3e02b37.zip |
Cleanup unused permissions pages
Bug: 122822231
Test: manual
Change-Id: I665cb3f3bc7be717f3d8c27d16ec0f8f44b3d867
-rw-r--r-- | Android.bp | 2 | ||||
-rw-r--r-- | res/layout/car_app_permissions.xml | 70 | ||||
-rw-r--r-- | res/values/overlayable.xml | 1 | ||||
-rw-r--r-- | res/values/themes.xml | 4 | ||||
-rw-r--r-- | src/com/android/packageinstaller/permission/ui/auto/AppPermissionsFragment.java | 221 |
5 files changed, 1 insertions, 297 deletions
@@ -44,9 +44,9 @@ android_app { static_libs: [ "iconloader", - "androidx.car_car", "com.google.android.material_material", "androidx.transition_transition", + "androidx-constraintlayout_constraintlayout", "androidx.core_core", "androidx.media_media", "androidx.legacy_legacy-support-core-utils", diff --git a/res/layout/car_app_permissions.xml b/res/layout/car_app_permissions.xml deleted file mode 100644 index 560ce9e8..00000000 --- a/res/layout/car_app_permissions.xml +++ /dev/null @@ -1,70 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2018 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. ---> - -<LinearLayout - xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res-auto" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:orientation="vertical"> - <RelativeLayout - android:layout_width="match_parent" - android:layout_height="@*android:dimen/car_app_bar_height" - android:gravity="end|center_vertical" > - <FrameLayout - android:id="@+id/action_bar_icon_container" - android:layout_width="@*android:dimen/car_margin" - android:layout_height="@*android:dimen/car_app_bar_height" - android:foreground="@drawable/button_ripple_bg" - android:layout_alignParentStart="true"> - <ImageView - android:layout_width="@*android:dimen/car_primary_icon_size" - android:layout_height="@*android:dimen/car_primary_icon_size" - android:tint="@*android:color/car_tint" - android:scaleType="fitCenter" - android:layout_gravity="center" - android:src="@drawable/ic_arrow_back"/> - </FrameLayout> - <TextView - android:id="@+id/title" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginStart="@*android:dimen/car_margin" - android:textAppearance="@*android:style/CarBody1" - android:fontFamily="medium" - android:text="@string/app_permissions" - android:layout_gravity="center_vertical" - android:layout_centerVertical="true" - android:layout_alignParentStart="true" - android:maxLines="1" - android:ellipsize="end"/> - </RelativeLayout> - - <View - android:layout_width="match_parent" - android:layout_height="@*android:dimen/car_list_divider_height" - android:background="@*android:color/car_list_divider"/> - - <androidx.car.widget.PagedListView - android:id="@+id/list" - android:theme="@style/PagedListTheme" - android:layout_width="match_parent" - android:layout_height="match_parent" - app:showPagedListViewDivider="true" - app:alignDividerStartTo="@id/container" - app:gutter="both"/> - -</LinearLayout> diff --git a/res/values/overlayable.xml b/res/values/overlayable.xml index 7f8370c0..759dcf47 100644 --- a/res/values/overlayable.xml +++ b/res/values/overlayable.xml @@ -218,7 +218,6 @@ <!-- START THEMES --> <item type="style" name="Settings" /> <item type="style" name="TextAppearance.CategoryTitle" /> - <item type="style" name="PagedListTheme" /> <item type="style" name="ReviewPermissions" /> <item type="style" name="GrantPermissions" /> <item type="style" name="Header.Settings" /> diff --git a/res/values/themes.xml b/res/values/themes.xml index 1f064bda..1bff6b50 100644 --- a/res/values/themes.xml +++ b/res/values/themes.xml @@ -30,10 +30,6 @@ <!-- 0.8 Spacing, 0.8/11 = 0.072727273 --> <item name="android:letterSpacing">0.072727273</item> </style> - <style name="PagedListTheme" parent="Theme.Car.NoActionBar"> - <item name="listItemPrimaryIconTint">?android:attr/textColorPrimary</item> - <item name="android:colorAccent">@*android:color/accent_device_default_light</item> - </style> <style name="ReviewPermissions" parent="@android:style/Theme.DeviceDefault.Settings"> diff --git a/src/com/android/packageinstaller/permission/ui/auto/AppPermissionsFragment.java b/src/com/android/packageinstaller/permission/ui/auto/AppPermissionsFragment.java deleted file mode 100644 index d99fd524..00000000 --- a/src/com/android/packageinstaller/permission/ui/auto/AppPermissionsFragment.java +++ /dev/null @@ -1,221 +0,0 @@ -/* - * Copyright (C) 2017 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.packageinstaller.permission.ui.auto; - - -import android.app.Activity; -import android.app.AlertDialog; -import android.app.Fragment; -import android.content.Context; -import android.content.Intent; -import android.content.pm.PackageInfo; -import android.content.pm.PackageManager; -import android.graphics.drawable.Drawable; -import android.os.Bundle; -import android.util.Log; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.Toast; - -import androidx.car.widget.ListItem; -import androidx.car.widget.ListItemAdapter; -import androidx.car.widget.ListItemProvider; -import androidx.car.widget.PagedListView; -import androidx.car.widget.TextListItem; - -import com.android.packageinstaller.permission.model.AppPermissionGroup; -import com.android.packageinstaller.permission.model.AppPermissions; -import com.android.packageinstaller.permission.utils.Utils; -import com.android.permissioncontroller.R; - -import java.util.ArrayList; - -/** - * Contains all permissions in a list for a given application. - */ -public final class AppPermissionsFragment extends Fragment { - - private static final String LOG_TAG = "ManagePermsFragment"; - public static final String EXTRA_LAYOUT = "extra_layout"; - - private AppPermissions mAppPermissions; - - private String mPackageName; - - protected PagedListView mListView; - protected ListItemAdapter mPagedListAdapter; - - - /** - * Creates a new instance. - * - * @param packageName the packageName of the application that we are listing the - * permissions here. - */ - public static AppPermissionsFragment newInstance(String packageName) { - AppPermissionsFragment fragment = new AppPermissionsFragment(); - Bundle arguments = new Bundle(); - arguments.putInt(EXTRA_LAYOUT, R.layout.car_app_permissions); - arguments.putString(Intent.EXTRA_PACKAGE_NAME, packageName); - fragment.setArguments(arguments); - return fragment; - } - - @Override - public void onActivityCreated(Bundle savedInstanceState) { - super.onActivityCreated(savedInstanceState); - getView().findViewById(R.id.action_bar_icon_container).setOnClickListener( - v -> getActivity().onBackPressed()); - - mListView = (PagedListView) getView().findViewById(R.id.list); - mPagedListAdapter = new ListItemAdapter(getContext(), getItemProvider()); - mListView.setAdapter(mPagedListAdapter); - } - - protected void notifyDataSetChanged() { - mPagedListAdapter.notifyDataSetChanged(); - } - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - if (savedInstanceState != null - && savedInstanceState.containsKey(Intent.EXTRA_PACKAGE_NAME)) { - mPackageName = savedInstanceState.getString(Intent.EXTRA_PACKAGE_NAME); - } else if (getArguments() != null - && getArguments().containsKey(Intent.EXTRA_PACKAGE_NAME)) { - mPackageName = getArguments().getString(Intent.EXTRA_PACKAGE_NAME); - } - - if (mPackageName == null) { - Log.e(LOG_TAG, "package name is missing"); - return; - } - Activity activity = getActivity(); - PackageInfo packageInfo = getPackageInfo(activity, mPackageName); - if (packageInfo == null) { - Toast.makeText(activity, R.string.app_not_found_dlg_title, Toast.LENGTH_LONG).show(); - activity.finish(); - return; - } - - mAppPermissions = new AppPermissions(activity, packageInfo, true, new Runnable() { - @Override - public void run() { - activity.finish(); - } - }); - } - - @Override - public void onSaveInstanceState(Bundle outState) { - super.onSaveInstanceState(outState); - outState.putString(Intent.EXTRA_PACKAGE_NAME, mPackageName); - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - return inflater.inflate(getArguments().getInt(EXTRA_LAYOUT), container, false); - } - - @Override - public void onResume() { - super.onResume(); - mAppPermissions.refresh(); - } - - /** - * Gets the list of the LineItems to show up in the list - */ - public ListItemProvider getItemProvider() { - ArrayList<ListItem> items = new ArrayList<>(); - Context context = getContext(); - if (context == null) { - return new ListItemProvider.ListProvider(items); - } - - for (AppPermissionGroup group : mAppPermissions.getPermissionGroups()) { - if (!Utils.shouldShowPermission(getContext(), group)) { - continue; - } - items.add(new PermissionLineItem(group, context)); - } - return new ListItemProvider.ListProvider(items); - } - - private static PackageInfo getPackageInfo(Activity activity, String packageName) { - try { - return activity.getPackageManager().getPackageInfo( - packageName, PackageManager.GET_PERMISSIONS); - } catch (PackageManager.NameNotFoundException e) { - if (Log.isLoggable(LOG_TAG, Log.INFO)) { - Log.i(LOG_TAG, "No package:" + activity.getCallingPackage(), e); - } - return null; - } - } - - private class PermissionLineItem extends TextListItem { - - private boolean mSwitchState; - - PermissionLineItem(AppPermissionGroup permissionGroup, Context context) { - super(context); - setTitle(permissionGroup.getLabel().toString()); - Drawable icon = Utils.loadDrawable(context.getPackageManager(), - permissionGroup.getIconPkg(), permissionGroup.getIconResId()); - setPrimaryActionIcon(icon, TextListItem.PRIMARY_ACTION_ICON_SIZE_SMALL); - setSwitch( - permissionGroup.areRuntimePermissionsGranted(), - /* showDivider= */ false, - (button, isChecked) -> { - mSwitchState = isChecked; - updatePermission(permissionGroup, context, mSwitchState); - }); - setOnClickListener(v -> { - mSwitchState = !mSwitchState; - setSwitchState(mSwitchState); - updatePermission(permissionGroup, context, mSwitchState); - notifyDataSetChanged(); - }); - } - - private void updatePermission(AppPermissionGroup permissionGroup, Context context, - boolean isGranted) { - if (isGranted) { - permissionGroup.grantRuntimePermissions(/* fixedByTheUser= */ false); - return; - } - boolean grantedByDefault = permissionGroup.hasGrantedByDefaultPermission(); - if (!grantedByDefault && permissionGroup.doesSupportRuntimePermissions()) { - permissionGroup.revokeRuntimePermissions(/* fixedByTheUser= */ false); - return; - } - new AlertDialog.Builder(context) - .setMessage(grantedByDefault - ? R.string.system_warning - : R.string.old_sdk_deny_warning) - .setNegativeButton(R.string.cancel, /* listener= */ null) - .setPositiveButton(R.string.grant_dialog_button_deny_anyway, - (dialog, which) -> - permissionGroup.revokeRuntimePermissions( - /* fixedByTheUser= */ false)) - .show(); - } - } -} |