Remove dead code
- Remove AppOpsDetails/AppOpsSummary and related code Bug: 68426851 Test: robotests Change-Id: I4b665e65bfff8b0365f45325b34965dc51d07bc0
This commit is contained in:
@@ -1192,23 +1192,6 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<!--
|
|
||||||
<activity android:name="Settings$AppOpsSummaryActivity"
|
|
||||||
android:label="@string/app_ops_settings"
|
|
||||||
android:taskAffinity=""
|
|
||||||
android:enabled="false">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MAIN" />
|
|
||||||
<action android:name="android.settings.APP_OPS_SETTINGS" />
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
<category android:name="android.intent.category.VOICE_LAUNCH" />
|
|
||||||
<category android:name="com.android.settings.SHORTCUT" />
|
|
||||||
</intent-filter>
|
|
||||||
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
|
||||||
android:value="com.android.settings.applications.AppOpsSummary" />
|
|
||||||
</activity>
|
|
||||||
-->
|
|
||||||
|
|
||||||
<activity android:name="Settings$BackgroundCheckSummaryActivity"
|
<activity android:name="Settings$BackgroundCheckSummaryActivity"
|
||||||
android:label="@string/background_check_title"
|
android:label="@string/background_check_title"
|
||||||
android:taskAffinity=""
|
android:taskAffinity=""
|
||||||
|
@@ -1,57 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!--
|
|
||||||
/*
|
|
||||||
** Copyright 2013, 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.
|
|
||||||
*/
|
|
||||||
-->
|
|
||||||
<ScrollView
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:clipToPadding="false"
|
|
||||||
android:scrollbarStyle="@integer/preference_scrollbar_style">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/all_details"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:paddingBottom="5dip"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<!-- App snippet -->
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
|
||||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<!-- Application snippet label, version and icon -->
|
|
||||||
<include
|
|
||||||
layout="@layout/app_item"
|
|
||||||
android:id="@+id/app_snippet" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<!-- Operations list -->
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/operations_section"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:orientation="vertical">
|
|
||||||
</LinearLayout>
|
|
||||||
</LinearLayout>
|
|
||||||
</ScrollView>
|
|
@@ -1,43 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!--
|
|
||||||
/*
|
|
||||||
**
|
|
||||||
** Copyright 2013, 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"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<android.support.v4.view.ViewPager
|
|
||||||
android:id="@+id/pager"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_weight="1">
|
|
||||||
<android.support.v4.view.PagerTabStrip
|
|
||||||
android:id="@+id/tabs"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="top"
|
|
||||||
android:textAppearance="@style/TextAppearance.PagerTabs"
|
|
||||||
android:paddingLeft="@dimen/pager_tabs_padding"
|
|
||||||
android:paddingRight="@dimen/pager_tabs_padding">
|
|
||||||
</android.support.v4.view.PagerTabStrip>
|
|
||||||
</android.support.v4.view.ViewPager>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
@@ -3916,8 +3916,6 @@
|
|||||||
<string name="instant_app_details_summary">More info on <xliff:g id="app_store">%1$s</xliff:g></string>
|
<string name="instant_app_details_summary">More info on <xliff:g id="app_store">%1$s</xliff:g></string>
|
||||||
|
|
||||||
<!-- App Ops Settings --> <skip />
|
<!-- App Ops Settings --> <skip />
|
||||||
<!-- [CHAR LIMIT=NONE] App ops settings title, on main settings screen. If clicked, the user is taken to a settings screen for app operations -->
|
|
||||||
<string name="app_ops_settings">App ops</string>
|
|
||||||
<!-- [CHAR LIMIT=NONE] Time label for an operation that is currently running. -->
|
<!-- [CHAR LIMIT=NONE] Time label for an operation that is currently running. -->
|
||||||
<string name="app_ops_running">Running</string>
|
<string name="app_ops_running">Running</string>
|
||||||
<!-- [CHAR LIMIT=NONE] Time label for an operation that has never executed. -->
|
<!-- [CHAR LIMIT=NONE] Time label for an operation that has never executed. -->
|
||||||
|
@@ -19,7 +19,6 @@ package com.android.settings;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.FeatureFlagUtils;
|
import android.util.FeatureFlagUtils;
|
||||||
|
|
||||||
import com.android.settings.applications.AppOpsSummary;
|
|
||||||
import com.android.settings.enterprise.EnterprisePrivacySettings;
|
import com.android.settings.enterprise.EnterprisePrivacySettings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -57,15 +56,6 @@ public class Settings extends SettingsActivity {
|
|||||||
public static class ManageApplicationsActivity extends SettingsActivity { /* empty */ }
|
public static class ManageApplicationsActivity extends SettingsActivity { /* empty */ }
|
||||||
public static class ManageAssistActivity extends SettingsActivity { /* empty */ }
|
public static class ManageAssistActivity extends SettingsActivity { /* empty */ }
|
||||||
public static class HighPowerApplicationsActivity extends SettingsActivity { /* empty */ }
|
public static class HighPowerApplicationsActivity extends SettingsActivity { /* empty */ }
|
||||||
public static class AppOpsSummaryActivity extends SettingsActivity {
|
|
||||||
@Override
|
|
||||||
public boolean isValidFragment(String className) {
|
|
||||||
if (AppOpsSummary.class.getName().equals(className)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return super.isValidFragment(className);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public static class BackgroundCheckSummaryActivity extends SettingsActivity { /* empty */ }
|
public static class BackgroundCheckSummaryActivity extends SettingsActivity { /* empty */ }
|
||||||
public static class StorageUseActivity extends SettingsActivity { /* empty */ }
|
public static class StorageUseActivity extends SettingsActivity { /* empty */ }
|
||||||
|
|
||||||
|
@@ -39,7 +39,6 @@ import android.widget.Switch;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.SettingsActivity;
|
|
||||||
import com.android.settings.applications.AppOpsState.AppOpEntry;
|
import com.android.settings.applications.AppOpsState.AppOpEntry;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -47,27 +46,17 @@ import java.util.List;
|
|||||||
public class AppOpsCategory extends ListFragment implements
|
public class AppOpsCategory extends ListFragment implements
|
||||||
LoaderManager.LoaderCallbacks<List<AppOpEntry>> {
|
LoaderManager.LoaderCallbacks<List<AppOpEntry>> {
|
||||||
|
|
||||||
private static final int RESULT_APP_DETAILS = 1;
|
|
||||||
|
|
||||||
AppOpsState mState;
|
AppOpsState mState;
|
||||||
boolean mUserControlled;
|
|
||||||
|
|
||||||
// This is the Adapter being used to display the list's data.
|
// This is the Adapter being used to display the list's data.
|
||||||
AppListAdapter mAdapter;
|
AppListAdapter mAdapter;
|
||||||
|
|
||||||
String mCurrentPkgName;
|
|
||||||
|
|
||||||
public AppOpsCategory() {
|
public AppOpsCategory() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public AppOpsCategory(AppOpsState.OpsTemplate template) {
|
public AppOpsCategory(AppOpsState.OpsTemplate template) {
|
||||||
this(template, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public AppOpsCategory(AppOpsState.OpsTemplate template, boolean userControlled) {
|
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putParcelable("template", template);
|
args.putParcelable("template", template);
|
||||||
args.putBoolean("userControlled", userControlled);
|
|
||||||
setArguments(args);
|
setArguments(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,22 +114,18 @@ public class AppOpsCategory extends ListFragment implements
|
|||||||
final InterestingConfigChanges mLastConfig = new InterestingConfigChanges();
|
final InterestingConfigChanges mLastConfig = new InterestingConfigChanges();
|
||||||
final AppOpsState mState;
|
final AppOpsState mState;
|
||||||
final AppOpsState.OpsTemplate mTemplate;
|
final AppOpsState.OpsTemplate mTemplate;
|
||||||
final boolean mUserControlled;
|
|
||||||
|
|
||||||
List<AppOpEntry> mApps;
|
List<AppOpEntry> mApps;
|
||||||
PackageIntentReceiver mPackageObserver;
|
PackageIntentReceiver mPackageObserver;
|
||||||
|
|
||||||
public AppListLoader(Context context, AppOpsState state, AppOpsState.OpsTemplate template,
|
public AppListLoader(Context context, AppOpsState state, AppOpsState.OpsTemplate template) {
|
||||||
boolean userControlled) {
|
|
||||||
super(context);
|
super(context);
|
||||||
mState = state;
|
mState = state;
|
||||||
mTemplate = template;
|
mTemplate = template;
|
||||||
mUserControlled = userControlled;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public List<AppOpEntry> loadInBackground() {
|
@Override public List<AppOpEntry> loadInBackground() {
|
||||||
return mState.buildState(mTemplate, 0, null,
|
return mState.buildState(mTemplate, 0, null, AppOpsState.LABEL_COMPARATOR);
|
||||||
mUserControlled ? AppOpsState.LABEL_COMPARATOR : AppOpsState.RECENCY_COMPARATOR);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -259,15 +244,13 @@ public class AppOpsCategory extends ListFragment implements
|
|||||||
private final Resources mResources;
|
private final Resources mResources;
|
||||||
private final LayoutInflater mInflater;
|
private final LayoutInflater mInflater;
|
||||||
private final AppOpsState mState;
|
private final AppOpsState mState;
|
||||||
private final boolean mUserControlled;
|
|
||||||
|
|
||||||
List<AppOpEntry> mList;
|
List<AppOpEntry> mList;
|
||||||
|
|
||||||
public AppListAdapter(Context context, AppOpsState state, boolean userControlled) {
|
public AppListAdapter(Context context, AppOpsState state) {
|
||||||
mResources = context.getResources();
|
mResources = context.getResources();
|
||||||
mInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
mInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
mState = state;
|
mState = state;
|
||||||
mUserControlled = userControlled;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setData(List<AppOpEntry> data) {
|
public void setData(List<AppOpEntry> data) {
|
||||||
@@ -293,7 +276,8 @@ public class AppOpsCategory extends ListFragment implements
|
|||||||
/**
|
/**
|
||||||
* Populate new items in the list.
|
* Populate new items in the list.
|
||||||
*/
|
*/
|
||||||
@Override public View getView(int position, View convertView, ViewGroup parent) {
|
@Override
|
||||||
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
View view;
|
View view;
|
||||||
|
|
||||||
if (convertView == null) {
|
if (convertView == null) {
|
||||||
@@ -303,21 +287,14 @@ public class AppOpsCategory extends ListFragment implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
AppOpEntry item = getItem(position);
|
AppOpEntry item = getItem(position);
|
||||||
((ImageView)view.findViewById(R.id.app_icon)).setImageDrawable(
|
((ImageView) view.findViewById(R.id.app_icon)).setImageDrawable(
|
||||||
item.getAppEntry().getIcon());
|
item.getAppEntry().getIcon());
|
||||||
((TextView)view.findViewById(R.id.app_name)).setText(item.getAppEntry().getLabel());
|
((TextView) view.findViewById(R.id.app_name)).setText(item.getAppEntry().getLabel());
|
||||||
if (mUserControlled) {
|
((TextView) view.findViewById(R.id.op_name)).setText(
|
||||||
((TextView) view.findViewById(R.id.op_name)).setText(
|
item.getTimeText(mResources, false));
|
||||||
item.getTimeText(mResources, false));
|
view.findViewById(R.id.op_time).setVisibility(View.GONE);
|
||||||
view.findViewById(R.id.op_time).setVisibility(View.GONE);
|
((Switch) view.findViewById(R.id.op_switch)).setChecked(
|
||||||
((Switch) view.findViewById(R.id.op_switch)).setChecked(
|
item.getPrimaryOpMode() == AppOpsManager.MODE_ALLOWED);
|
||||||
item.getPrimaryOpMode() == AppOpsManager.MODE_ALLOWED);
|
|
||||||
} else {
|
|
||||||
((TextView) view.findViewById(R.id.op_name)).setText(item.getSummaryText(mState));
|
|
||||||
((TextView) view.findViewById(R.id.op_time)).setText(
|
|
||||||
item.getTimeText(mResources, false));
|
|
||||||
view.findViewById(R.id.op_switch).setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
@@ -327,7 +304,6 @@ public class AppOpsCategory extends ListFragment implements
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
mState = new AppOpsState(getActivity());
|
mState = new AppOpsState(getActivity());
|
||||||
mUserControlled = getArguments().getBoolean("userControlled");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void onActivityCreated(Bundle savedInstanceState) {
|
@Override public void onActivityCreated(Bundle savedInstanceState) {
|
||||||
@@ -341,7 +317,7 @@ public class AppOpsCategory extends ListFragment implements
|
|||||||
setHasOptionsMenu(true);
|
setHasOptionsMenu(true);
|
||||||
|
|
||||||
// Create an empty adapter we will use to display the loaded data.
|
// Create an empty adapter we will use to display the loaded data.
|
||||||
mAdapter = new AppListAdapter(getActivity(), mState, mUserControlled);
|
mAdapter = new AppListAdapter(getActivity(), mState);
|
||||||
setListAdapter(mAdapter);
|
setListAdapter(mAdapter);
|
||||||
|
|
||||||
// Start out with a progress indicator.
|
// Start out with a progress indicator.
|
||||||
@@ -351,36 +327,20 @@ public class AppOpsCategory extends ListFragment implements
|
|||||||
getLoaderManager().initLoader(0, null, this);
|
getLoaderManager().initLoader(0, null, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// utility method used to start sub activity
|
|
||||||
private void startApplicationDetailsActivity() {
|
|
||||||
// start new fragment to display extended information
|
|
||||||
Bundle args = new Bundle();
|
|
||||||
args.putString(AppOpsDetails.ARG_PACKAGE_NAME, mCurrentPkgName);
|
|
||||||
|
|
||||||
SettingsActivity sa = (SettingsActivity) getActivity();
|
|
||||||
sa.startPreferencePanel(this, AppOpsDetails.class.getName(), args,
|
|
||||||
R.string.app_ops_settings, null, this, RESULT_APP_DETAILS);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void onListItemClick(ListView l, View v, int position, long id) {
|
@Override public void onListItemClick(ListView l, View v, int position, long id) {
|
||||||
AppOpEntry entry = mAdapter.getItem(position);
|
AppOpEntry entry = mAdapter.getItem(position);
|
||||||
if (entry != null) {
|
if (entry != null) {
|
||||||
if (mUserControlled) {
|
// We treat this as tapping on the check box, toggling the app op state.
|
||||||
// We treat this as tapping on the check box, toggling the app op state.
|
Switch sw = v.findViewById(R.id.op_switch);
|
||||||
Switch sw = ((Switch) v.findViewById(R.id.op_switch));
|
boolean checked = !sw.isChecked();
|
||||||
boolean checked = !sw.isChecked();
|
sw.setChecked(checked);
|
||||||
sw.setChecked(checked);
|
AppOpsManager.OpEntry op = entry.getOpEntry(0);
|
||||||
AppOpsManager.OpEntry op = entry.getOpEntry(0);
|
int mode = checked ? AppOpsManager.MODE_ALLOWED : AppOpsManager.MODE_IGNORED;
|
||||||
int mode = checked ? AppOpsManager.MODE_ALLOWED : AppOpsManager.MODE_IGNORED;
|
mState.getAppOpsManager().setMode(op.getOp(),
|
||||||
mState.getAppOpsManager().setMode(op.getOp(),
|
entry.getAppEntry().getApplicationInfo().uid,
|
||||||
entry.getAppEntry().getApplicationInfo().uid,
|
entry.getAppEntry().getApplicationInfo().packageName,
|
||||||
entry.getAppEntry().getApplicationInfo().packageName,
|
mode);
|
||||||
mode);
|
entry.overridePrimaryOpMode(mode);
|
||||||
entry.overridePrimaryOpMode(mode);
|
|
||||||
} else {
|
|
||||||
mCurrentPkgName = entry.getAppEntry().getApplicationInfo().packageName;
|
|
||||||
startApplicationDetailsActivity();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -388,9 +348,9 @@ public class AppOpsCategory extends ListFragment implements
|
|||||||
Bundle fargs = getArguments();
|
Bundle fargs = getArguments();
|
||||||
AppOpsState.OpsTemplate template = null;
|
AppOpsState.OpsTemplate template = null;
|
||||||
if (fargs != null) {
|
if (fargs != null) {
|
||||||
template = (AppOpsState.OpsTemplate)fargs.getParcelable("template");
|
template = fargs.getParcelable("template");
|
||||||
}
|
}
|
||||||
return new AppListLoader(getActivity(), mState, template, mUserControlled);
|
return new AppListLoader(getActivity(), mState, template);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void onLoadFinished(Loader<List<AppOpEntry>> loader, List<AppOpEntry> data) {
|
@Override public void onLoadFinished(Loader<List<AppOpEntry>> loader, List<AppOpEntry> data) {
|
||||||
|
@@ -1,223 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (C) 2013 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.applications;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.AppOpsManager;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.pm.PackageInfo;
|
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.content.pm.PackageManager.NameNotFoundException;
|
|
||||||
import android.content.pm.PermissionGroupInfo;
|
|
||||||
import android.content.pm.PermissionInfo;
|
|
||||||
import android.content.res.Resources;
|
|
||||||
import android.graphics.drawable.Drawable;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.CompoundButton;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.Switch;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
|
||||||
import com.android.settings.applications.manageapplications.ManageApplications;
|
|
||||||
import com.android.settings.core.InstrumentedPreferenceFragment;
|
|
||||||
import com.android.settings.R;
|
|
||||||
import com.android.settings.SettingsActivity;
|
|
||||||
import com.android.settings.Utils;
|
|
||||||
import com.android.settings.widget.EntityHeaderController;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class AppOpsDetails extends InstrumentedPreferenceFragment {
|
|
||||||
static final String TAG = "AppOpsDetails";
|
|
||||||
|
|
||||||
public static final String ARG_PACKAGE_NAME = "package";
|
|
||||||
|
|
||||||
private AppOpsState mState;
|
|
||||||
private PackageManager mPm;
|
|
||||||
private AppOpsManager mAppOps;
|
|
||||||
private PackageInfo mPackageInfo;
|
|
||||||
private LayoutInflater mInflater;
|
|
||||||
private View mRootView;
|
|
||||||
private LinearLayout mOperationsSection;
|
|
||||||
|
|
||||||
// Utility method to set application label and icon.
|
|
||||||
private void setAppLabelAndIcon(PackageInfo pkgInfo) {
|
|
||||||
final View appSnippet = mRootView.findViewById(R.id.app_snippet);
|
|
||||||
CharSequence label = mPm.getApplicationLabel(pkgInfo.applicationInfo);
|
|
||||||
Drawable icon = mPm.getApplicationIcon(pkgInfo.applicationInfo);
|
|
||||||
setupAppSnippet(appSnippet, label, icon,
|
|
||||||
pkgInfo != null ? pkgInfo.versionName : null);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String retrieveAppEntry() {
|
|
||||||
final Bundle args = getArguments();
|
|
||||||
String packageName = (args != null) ? args.getString(ARG_PACKAGE_NAME) : null;
|
|
||||||
if (packageName == null) {
|
|
||||||
Intent intent = (args == null) ?
|
|
||||||
getActivity().getIntent() : (Intent) args.getParcelable("intent");
|
|
||||||
if (intent != null) {
|
|
||||||
packageName = intent.getData().getSchemeSpecificPart();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
mPackageInfo = mPm.getPackageInfo(packageName,
|
|
||||||
PackageManager.MATCH_DISABLED_COMPONENTS |
|
|
||||||
PackageManager.MATCH_ANY_USER);
|
|
||||||
} catch (NameNotFoundException e) {
|
|
||||||
Log.e(TAG, "Exception when retrieving package:" + packageName, e);
|
|
||||||
mPackageInfo = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return packageName;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean refreshUi() {
|
|
||||||
if (mPackageInfo == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
setAppLabelAndIcon(mPackageInfo);
|
|
||||||
|
|
||||||
Resources res = getActivity().getResources();
|
|
||||||
|
|
||||||
mOperationsSection.removeAllViews();
|
|
||||||
String lastPermGroup = "";
|
|
||||||
for (AppOpsState.OpsTemplate tpl : AppOpsState.ALL_TEMPLATES) {
|
|
||||||
List<AppOpsState.AppOpEntry> entries = mState.buildState(tpl,
|
|
||||||
mPackageInfo.applicationInfo.uid, mPackageInfo.packageName);
|
|
||||||
for (final AppOpsState.AppOpEntry entry : entries) {
|
|
||||||
final AppOpsManager.OpEntry firstOp = entry.getOpEntry(0);
|
|
||||||
final View view = mInflater.inflate(R.layout.app_ops_details_item,
|
|
||||||
mOperationsSection, false);
|
|
||||||
mOperationsSection.addView(view);
|
|
||||||
String perm = AppOpsManager.opToPermission(firstOp.getOp());
|
|
||||||
if (perm != null) {
|
|
||||||
try {
|
|
||||||
PermissionInfo pi = mPm.getPermissionInfo(perm, 0);
|
|
||||||
if (pi.group != null && !lastPermGroup.equals(pi.group)) {
|
|
||||||
lastPermGroup = pi.group;
|
|
||||||
PermissionGroupInfo pgi = mPm.getPermissionGroupInfo(pi.group, 0);
|
|
||||||
if (pgi.icon != 0) {
|
|
||||||
((ImageView)view.findViewById(R.id.op_icon)).setImageDrawable(
|
|
||||||
pgi.loadIcon(mPm));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (NameNotFoundException e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
((TextView)view.findViewById(R.id.op_name)).setText(
|
|
||||||
entry.getSwitchText(mState));
|
|
||||||
((TextView)view.findViewById(R.id.op_time)).setText(
|
|
||||||
entry.getTimeText(res, true));
|
|
||||||
Switch sw = (Switch)view.findViewById(R.id.switchWidget);
|
|
||||||
final int switchOp = AppOpsManager.opToSwitch(firstOp.getOp());
|
|
||||||
sw.setChecked(mAppOps.checkOp(switchOp, entry.getPackageOps().getUid(),
|
|
||||||
entry.getPackageOps().getPackageName()) == AppOpsManager.MODE_ALLOWED);
|
|
||||||
sw.setOnCheckedChangeListener(new Switch.OnCheckedChangeListener() {
|
|
||||||
@Override
|
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
|
||||||
mAppOps.setMode(switchOp, entry.getPackageOps().getUid(),
|
|
||||||
entry.getPackageOps().getPackageName(), isChecked
|
|
||||||
? AppOpsManager.MODE_ALLOWED : AppOpsManager.MODE_IGNORED);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setIntentAndFinish(boolean finish, boolean appChanged) {
|
|
||||||
Intent intent = new Intent();
|
|
||||||
intent.putExtra(ManageApplications.APP_CHG, appChanged);
|
|
||||||
SettingsActivity sa = (SettingsActivity)getActivity();
|
|
||||||
sa.finishPreferencePanel(this, Activity.RESULT_OK, intent);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Called when the activity is first created. */
|
|
||||||
@Override
|
|
||||||
public void onCreate(Bundle icicle) {
|
|
||||||
super.onCreate(icicle);
|
|
||||||
|
|
||||||
mState = new AppOpsState(getActivity());
|
|
||||||
mPm = getActivity().getPackageManager();
|
|
||||||
mInflater = (LayoutInflater)getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
|
||||||
mAppOps = (AppOpsManager)getActivity().getSystemService(Context.APP_OPS_SERVICE);
|
|
||||||
|
|
||||||
retrieveAppEntry();
|
|
||||||
|
|
||||||
setHasOptionsMenu(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View onCreateView(
|
|
||||||
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
|
||||||
final View view = inflater.inflate(R.layout.app_ops_details, container, false);
|
|
||||||
Utils.prepareCustomPreferencesList(container, view, view, false);
|
|
||||||
|
|
||||||
mRootView = view;
|
|
||||||
mOperationsSection = (LinearLayout)view.findViewById(R.id.operations_section);
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMetricsCategory() {
|
|
||||||
return MetricsEvent.APP_OPS_DETAILS;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
if (!refreshUi()) {
|
|
||||||
setIntentAndFinish(true, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated app info pages should use {@link EntityHeaderController} to show the app header.
|
|
||||||
*/
|
|
||||||
void setupAppSnippet(View appSnippet, CharSequence label, Drawable icon,
|
|
||||||
CharSequence versionName) {
|
|
||||||
LayoutInflater.from(appSnippet.getContext()).inflate(R.layout.widget_text_views,
|
|
||||||
appSnippet.findViewById(android.R.id.widget_frame));
|
|
||||||
|
|
||||||
ImageView iconView = appSnippet.findViewById(android.R.id.icon);
|
|
||||||
iconView.setImageDrawable(icon);
|
|
||||||
// Set application name.
|
|
||||||
TextView labelView = appSnippet.findViewById(android.R.id.title);
|
|
||||||
labelView.setText(label);
|
|
||||||
// Version number of application
|
|
||||||
TextView appVersion = appSnippet.findViewById(R.id.widget_text1);
|
|
||||||
|
|
||||||
if (!TextUtils.isEmpty(versionName)) {
|
|
||||||
appVersion.setSelected(true);
|
|
||||||
appVersion.setVisibility(View.VISIBLE);
|
|
||||||
appVersion.setText(appSnippet.getContext().getString(R.string.version_text,
|
|
||||||
String.valueOf(versionName)));
|
|
||||||
} else {
|
|
||||||
appVersion.setVisibility(View.INVISIBLE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -50,8 +50,6 @@ public class AppOpsState {
|
|||||||
final CharSequence[] mOpSummaries;
|
final CharSequence[] mOpSummaries;
|
||||||
final CharSequence[] mOpLabels;
|
final CharSequence[] mOpLabels;
|
||||||
|
|
||||||
List<AppOpEntry> mApps;
|
|
||||||
|
|
||||||
public AppOpsState(Context context) {
|
public AppOpsState(Context context) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mAppOps = (AppOpsManager)context.getSystemService(Context.APP_OPS_SERVICE);
|
mAppOps = (AppOpsManager)context.getSystemService(Context.APP_OPS_SERVICE);
|
||||||
|
@@ -1,132 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (C) 2013 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.applications;
|
|
||||||
|
|
||||||
import android.app.Fragment;
|
|
||||||
import android.app.FragmentManager;
|
|
||||||
import android.content.res.TypedArray;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.preference.PreferenceFrameLayout;
|
|
||||||
import android.support.v13.app.FragmentPagerAdapter;
|
|
||||||
import android.support.v4.view.PagerTabStrip;
|
|
||||||
import android.support.v4.view.ViewPager;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
|
|
||||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
|
||||||
import com.android.settings.core.InstrumentedPreferenceFragment;
|
|
||||||
import com.android.settings.R;
|
|
||||||
|
|
||||||
public class AppOpsSummary extends InstrumentedPreferenceFragment {
|
|
||||||
// layout inflater object used to inflate views
|
|
||||||
private LayoutInflater mInflater;
|
|
||||||
|
|
||||||
private ViewGroup mContentContainer;
|
|
||||||
private View mRootView;
|
|
||||||
private ViewPager mViewPager;
|
|
||||||
|
|
||||||
CharSequence[] mPageNames;
|
|
||||||
static AppOpsState.OpsTemplate[] sPageTemplates = new AppOpsState.OpsTemplate[] {
|
|
||||||
AppOpsState.LOCATION_TEMPLATE,
|
|
||||||
AppOpsState.PERSONAL_TEMPLATE,
|
|
||||||
AppOpsState.MESSAGING_TEMPLATE,
|
|
||||||
AppOpsState.MEDIA_TEMPLATE,
|
|
||||||
AppOpsState.DEVICE_TEMPLATE
|
|
||||||
};
|
|
||||||
|
|
||||||
int mCurPos;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMetricsCategory() {
|
|
||||||
return MetricsEvent.APP_OPS_SUMMARY;
|
|
||||||
}
|
|
||||||
|
|
||||||
class MyPagerAdapter extends FragmentPagerAdapter implements ViewPager.OnPageChangeListener {
|
|
||||||
|
|
||||||
public MyPagerAdapter(FragmentManager fm) {
|
|
||||||
super(fm);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Fragment getItem(int position) {
|
|
||||||
return new AppOpsCategory(sPageTemplates[position]);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getCount() {
|
|
||||||
return sPageTemplates.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CharSequence getPageTitle(int position) {
|
|
||||||
return mPageNames[position];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPageSelected(int position) {
|
|
||||||
mCurPos = position;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPageScrollStateChanged(int state) {
|
|
||||||
if (state == ViewPager.SCROLL_STATE_IDLE) {
|
|
||||||
//updateCurrentTab(mCurPos);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
|
||||||
// initialize the inflater
|
|
||||||
mInflater = inflater;
|
|
||||||
|
|
||||||
View rootView = mInflater.inflate(R.layout.app_ops_summary,
|
|
||||||
container, false);
|
|
||||||
mContentContainer = container;
|
|
||||||
mRootView = rootView;
|
|
||||||
|
|
||||||
mPageNames = getResources().getTextArray(R.array.app_ops_categories);
|
|
||||||
|
|
||||||
mViewPager = (ViewPager) rootView.findViewById(R.id.pager);
|
|
||||||
MyPagerAdapter adapter = new MyPagerAdapter(getChildFragmentManager());
|
|
||||||
mViewPager.setAdapter(adapter);
|
|
||||||
mViewPager.setOnPageChangeListener(adapter);
|
|
||||||
PagerTabStrip tabs = (PagerTabStrip) rootView.findViewById(R.id.tabs);
|
|
||||||
|
|
||||||
// This should be set in the XML layout, but PagerTabStrip lives in
|
|
||||||
// support-v4 and doesn't have styleable attributes.
|
|
||||||
final TypedArray ta = tabs.getContext().obtainStyledAttributes(
|
|
||||||
new int[] { android.R.attr.colorAccent });
|
|
||||||
final int colorAccent = ta.getColor(0, 0);
|
|
||||||
ta.recycle();
|
|
||||||
|
|
||||||
tabs.setTabIndicatorColorResource(colorAccent);
|
|
||||||
|
|
||||||
// We have to do this now because PreferenceFrameLayout looks at it
|
|
||||||
// only when the view is added.
|
|
||||||
if (container instanceof PreferenceFrameLayout) {
|
|
||||||
((PreferenceFrameLayout.LayoutParams) rootView.getLayoutParams()).removeBorders = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return rootView;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -60,8 +60,8 @@ public class BackgroundCheckSummary extends InstrumentedPreferenceFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
FragmentTransaction ft = getChildFragmentManager().beginTransaction();
|
FragmentTransaction ft = getChildFragmentManager().beginTransaction();
|
||||||
ft.add(R.id.appops_content, new AppOpsCategory(AppOpsState.RUN_IN_BACKGROUND_TEMPLATE,
|
ft.add(R.id.appops_content, new AppOpsCategory(AppOpsState.RUN_IN_BACKGROUND_TEMPLATE),
|
||||||
true), "appops");
|
"appops");
|
||||||
ft.commitAllowingStateLoss();
|
ft.commitAllowingStateLoss();
|
||||||
|
|
||||||
return rootView;
|
return rootView;
|
||||||
|
Reference in New Issue
Block a user