Merge "Implement new Manage Apps list"
This commit is contained in:
@@ -759,7 +759,6 @@
|
||||
<intent-filter android:priority="1">
|
||||
<action android:name="android.settings.APPLICATION_SETTINGS" />
|
||||
<action android:name="android.settings.MANAGE_APPLICATIONS_SETTINGS" />
|
||||
<action android:name="android.settings.MANAGE_ALL_APPLICATIONS_SETTINGS" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
@@ -774,6 +773,19 @@
|
||||
android:resource="@id/application_settings" />
|
||||
</activity>
|
||||
|
||||
<activity android:name="Settings$AllApplicationsActivity"
|
||||
android:label="@string/applications_settings"
|
||||
android:taskAffinity="">
|
||||
<intent-filter>
|
||||
<action android:name="android.settings.MANAGE_ALL_APPLICATIONS_SETTINGS" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
||||
android:value="com.android.settings.applications.ManageApplications" />
|
||||
<meta-data android:name="com.android.settings.TOP_LEVEL_HEADER_ID"
|
||||
android:resource="@id/application_settings" />
|
||||
</activity>
|
||||
|
||||
<!-- Keep compatibility with old shortcuts. -->
|
||||
<activity-alias android:name=".applications.ManageApplications"
|
||||
android:label="@string/applications_settings"
|
||||
|
25
res/drawable/ic_settings_24dp.xml
Normal file
25
res/drawable/ic_settings_24dp.xml
Normal file
@@ -0,0 +1,25 @@
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:pathData="M19.4,13.0c0.0,-0.3 0.1,-0.6 0.1,-1.0s0.0,-0.7 -0.1,-1.0l2.1,-1.7c0.2,-0.2 0.2,-0.4 0.1,-0.6l-2.0,-3.5C19.5,5.1 19.3,5.0 19.0,5.1l-2.5,1.0c-0.5,-0.4 -1.1,-0.7 -1.7,-1.0l-0.4,-2.6C14.5,2.2 14.2,2.0 14.0,2.0l-4.0,0.0C9.8,2.0 9.5,2.2 9.5,2.4L9.1,5.1C8.5,5.3 8.0,5.7 7.4,6.1L5.0,5.1C4.7,5.0 4.5,5.1 4.3,5.3l-2.0,3.5C2.2,8.9 2.3,9.2 2.5,9.4L4.6,11.0c0.0,0.3 -0.1,0.6 -0.1,1.0s0.0,0.7 0.1,1.0l-2.1,1.7c-0.2,0.2 -0.2,0.4 -0.1,0.6l2.0,3.5C4.5,18.9 4.7,19.0 5.0,18.9l2.5,-1.0c0.5,0.4 1.1,0.7 1.7,1.0l0.4,2.6c0.0,0.2 0.2,0.4 0.5,0.4l4.0,0.0c0.2,0.0 0.5,-0.2 0.5,-0.4l0.4,-2.6c0.6,-0.3 1.2,-0.6 1.7,-1.0l2.5,1.0c0.2,0.1 0.5,0.0 0.6,-0.2l2.0,-3.5c0.1,-0.2 0.1,-0.5 -0.1,-0.6L19.4,13.0zM12.0,15.5c-1.9,0.0 -3.5,-1.6 -3.5,-3.5s1.6,-3.5 3.5,-3.5s3.5,1.6 3.5,3.5S13.9,15.5 12.0,15.5z"
|
||||
android:fillColor="#ffffffff" />
|
||||
</vector>
|
41
res/layout/apps_filter_spinner.xml
Normal file
41
res/layout/apps_filter_spinner.xml
Normal file
@@ -0,0 +1,41 @@
|
||||
<?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.
|
||||
-->
|
||||
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?android:attr/actionBarSize"
|
||||
android:background="@drawable/switchbar_background"
|
||||
android:gravity="center_vertical"
|
||||
android:theme="?attr/switchBarTheme" >
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/filter_spinner"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_marginStart="@dimen/switchbar_subsettings_margin_start"
|
||||
android:layout_alignWithParentIfMissing="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:textAlignment="viewStart" />
|
||||
|
||||
<View
|
||||
android:id="@+id/row_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/listDivider" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
27
res/layout/filter_spinner_item.xml
Normal file
27
res/layout/filter_spinner_item.xml
Normal file
@@ -0,0 +1,27 @@
|
||||
<?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.
|
||||
-->
|
||||
|
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@android:id/text1"
|
||||
style="?android:attr/spinnerItemStyle"
|
||||
android:singleLine="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="marquee"
|
||||
android:textAppearance="@style/TextAppearance.Switch"
|
||||
android:textColor="@android:color/white"
|
||||
android:textAlignment="inherit"/>
|
@@ -1,43 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/*
|
||||
**
|
||||
** Copyright 2012, 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:background="@drawable/default_preference_background">
|
||||
|
||||
<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:padding="0dp">
|
||||
</android.support.v4.view.PagerTabStrip>
|
||||
</android.support.v4.view.ViewPager>
|
||||
|
||||
</LinearLayout>
|
23
res/menu/manage_apps.xml
Normal file
23
res/menu/manage_apps.xml
Normal file
@@ -0,0 +1,23 @@
|
||||
<?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/advanced"
|
||||
android:title="@string/advanced_apps"
|
||||
android:icon="@drawable/ic_settings_24dp"
|
||||
android:showAsAction="collapseActionView|ifRoom" />
|
||||
</menu>
|
@@ -5626,6 +5626,8 @@
|
||||
<string name="keywords_accounts">account</string>
|
||||
<string name="keywords_users">restriction restrict restricted</string>
|
||||
<string name="keywords_keyboard_and_ime">text correction correct sound vibrate auto language gesture suggest suggestion theme offensive word type emoji international</string>
|
||||
<string name="keywords_reset_apps">reset preferences default</string>
|
||||
<string name="keywords_all_apps">apps download applications system</string>
|
||||
<!-- Search keywords for different screen unlock modes : slide to unlock, password, pattern and PIN [CHAR LIMIT=none] -->
|
||||
<string name="keywords_lockscreen">slide password pattern pin</string>
|
||||
|
||||
@@ -6088,10 +6090,29 @@
|
||||
<item quantity="other"><xliff:g id="count" example="10">%d</xliff:g> permissions granted</item>
|
||||
</plurals>
|
||||
|
||||
<!-- Launch defaults preference summary with some set [CHAR LIMIT=40] -->
|
||||
<string name="launch_defaults_some">Some defaults set</string>
|
||||
<!-- Launch defaults preference summary with none set [CHAR LIMIT=40] -->
|
||||
<string name="launch_defaults_none">No defaults set</string>
|
||||
<!-- Launch defaults preference summary with some set [CHAR LIMIT=40] -->
|
||||
<string name="launch_defaults_some">Some defaults set</string>
|
||||
<!-- Launch defaults preference summary with none set [CHAR LIMIT=40] -->
|
||||
<string name="launch_defaults_none">No defaults set</string>
|
||||
|
||||
<!-- Label for showing all apps in list [CHAR LIMIT=30] -->
|
||||
<string name="filter_all_apps">All apps</string>
|
||||
<!-- Label for showing enabled apps in list [CHAR LIMIT=30] -->
|
||||
<string name="filter_enabled_apps">Enabled</string>
|
||||
<!-- Label for showing personal apps in list [CHAR LIMIT=30] -->
|
||||
<string name="filter_personal_apps">Personal</string>
|
||||
<!-- Label for showing work apps in list [CHAR LIMIT=30] -->
|
||||
<string name="filter_work_apps">Work</string>
|
||||
|
||||
<!-- Description for advanced menu option to reset app preferences [CHAR LIMIT=NONE] -->
|
||||
<string name="reset_app_preferences_description">Reset preferences across all apps to defaults</string>
|
||||
|
||||
<!-- Description of settings item that leads to list of all apps
|
||||
[CHAR LIMIT=NONE] -->
|
||||
<string name="all_apps_summary"><xliff:g id="count" example="10">%d</xliff:g> apps installed, including system and downloaded apps</string>
|
||||
|
||||
<!-- Title for advanced application management settings [CHAR LIMIT=30] -->
|
||||
<string name="advanced_apps">Advanced</string>
|
||||
|
||||
<!-- Warning toast shown when data usage screen can't find specified app -->
|
||||
<string name="unknown_app">Unknown app</string>
|
||||
|
38
res/xml/advanced_apps.xml
Normal file
38
res/xml/advanced_apps.xml
Normal file
@@ -0,0 +1,38 @@
|
||||
<?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.
|
||||
-->
|
||||
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
|
||||
android:key="applications_settings">
|
||||
|
||||
<PreferenceScreen
|
||||
android:key="all_apps"
|
||||
android:fragment="com.android.settings.applications.ManageApplications"
|
||||
android:title="@string/filter_all_apps"
|
||||
settings:keywords="@string/keywords_all_apps">
|
||||
<extra
|
||||
android:name="classname"
|
||||
android:value="com.android.settings.Settings$AllApplicationsActivity" />
|
||||
</PreferenceScreen>
|
||||
|
||||
<Preference
|
||||
android:key="reset_all"
|
||||
android:title="@string/reset_app_preferences"
|
||||
android:summary="@string/reset_app_preferences_description"
|
||||
settings:keywords="@string/keywords_reset_apps" />
|
||||
|
||||
</PreferenceScreen>
|
@@ -47,6 +47,7 @@ public class Settings extends SettingsActivity {
|
||||
public static class DeviceInfoSettingsActivity extends SettingsActivity { /* empty */ }
|
||||
public static class ApplicationSettingsActivity extends SettingsActivity { /* empty */ }
|
||||
public static class ManageApplicationsActivity extends SettingsActivity { /* empty */ }
|
||||
public static class AllApplicationsActivity extends SettingsActivity { /* empty */ }
|
||||
public static class AppOpsSummaryActivity extends SettingsActivity {
|
||||
@Override
|
||||
public boolean isValidFragment(String className) {
|
||||
|
257
src/com/android/settings/applications/AdvancedAppSettings.java
Normal file
257
src/com/android/settings/applications/AdvancedAppSettings.java
Normal file
@@ -0,0 +1,257 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package com.android.settings.applications;
|
||||
|
||||
import static android.net.NetworkPolicyManager.POLICY_NONE;
|
||||
import static android.net.NetworkPolicyManager.POLICY_REJECT_METERED_BACKGROUND;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.AppOpsManager;
|
||||
import android.app.INotificationManager;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.IPackageManager;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.NetworkPolicyManager;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.RemoteException;
|
||||
import android.os.ServiceManager;
|
||||
import android.os.UserHandle;
|
||||
import android.preference.Preference;
|
||||
import android.preference.Preference.OnPreferenceClickListener;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
import com.android.settings.applications.ApplicationsState.AppEntry;
|
||||
import com.android.settings.applications.ApplicationsState.Callbacks;
|
||||
import com.android.settings.applications.ApplicationsState.Session;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AdvancedAppSettings extends SettingsPreferenceFragment implements Callbacks,
|
||||
DialogInterface.OnClickListener, DialogInterface.OnDismissListener {
|
||||
|
||||
static final String TAG = "AdvancedAppSettings";
|
||||
static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
|
||||
|
||||
private static final String KEY_ALL_APPS = "all_apps";
|
||||
private static final String KEY_RESET_ALL = "reset_all";
|
||||
private static final String EXTRA_RESET_DIALOG = "resetDialog";
|
||||
|
||||
private ApplicationsState mApplicationsState;
|
||||
private Session mSession;
|
||||
private Preference mAllApps;
|
||||
private Preference mResetAll;
|
||||
|
||||
AlertDialog mResetDialog;
|
||||
|
||||
private boolean mActivityResumed;
|
||||
private PackageManager mPm;
|
||||
private IPackageManager mIPm;
|
||||
private INotificationManager mNm;
|
||||
private NetworkPolicyManager mNpm;
|
||||
private AppOpsManager mAom;
|
||||
private Handler mHandler;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
addPreferencesFromResource(R.xml.advanced_apps);
|
||||
|
||||
mApplicationsState = ApplicationsState.getInstance(getActivity().getApplication());
|
||||
mSession = mApplicationsState.newSession(this);
|
||||
|
||||
mAllApps = findPreference(KEY_ALL_APPS);
|
||||
mResetAll = findPreference(KEY_RESET_ALL);
|
||||
mResetAll.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
buildResetDialog();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
updateAllAppsSummary();
|
||||
|
||||
mPm = getActivity().getPackageManager();
|
||||
mIPm = IPackageManager.Stub.asInterface(ServiceManager.getService("package"));
|
||||
mNm = INotificationManager.Stub.asInterface(
|
||||
ServiceManager.getService(Context.NOTIFICATION_SERVICE));
|
||||
mNpm = NetworkPolicyManager.from(getActivity());
|
||||
mAom = (AppOpsManager)getActivity().getSystemService(Context.APP_OPS_SERVICE);
|
||||
mHandler = new Handler(getActivity().getMainLooper());
|
||||
}
|
||||
|
||||
private void updateAllAppsSummary() {
|
||||
mAllApps.setSummary(getString(R.string.all_apps_summary, mSession.getAllApps().size()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
if (savedInstanceState != null && savedInstanceState.getBoolean(EXTRA_RESET_DIALOG)) {
|
||||
buildResetDialog();
|
||||
}
|
||||
|
||||
return super.onCreateView(inflater, container, savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
if (mResetDialog != null) {
|
||||
mResetDialog.dismiss();
|
||||
mResetDialog = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
mActivityResumed = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
mActivityResumed = false;
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
if (mResetDialog != null) {
|
||||
outState.putBoolean(EXTRA_RESET_DIALOG, true);
|
||||
}
|
||||
}
|
||||
|
||||
void buildResetDialog() {
|
||||
if (mResetDialog == null) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
builder.setTitle(R.string.reset_app_preferences_title);
|
||||
builder.setMessage(R.string.reset_app_preferences_desc);
|
||||
builder.setPositiveButton(R.string.reset_app_preferences_button, this);
|
||||
builder.setNegativeButton(R.string.cancel, null);
|
||||
mResetDialog = builder.show();
|
||||
mResetDialog.setOnDismissListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
if (mResetDialog == dialog) {
|
||||
mResetDialog = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
if (mResetDialog == dialog) {
|
||||
(new AsyncTask<Void, Void, Void>() {
|
||||
@Override protected Void doInBackground(Void... params) {
|
||||
List<ApplicationInfo> apps = mPm.getInstalledApplications(
|
||||
PackageManager.GET_DISABLED_COMPONENTS);
|
||||
for (int i=0; i<apps.size(); i++) {
|
||||
ApplicationInfo app = apps.get(i);
|
||||
try {
|
||||
if (DEBUG) Log.v(TAG, "Enabling notifications: " + app.packageName);
|
||||
mNm.setNotificationsEnabledForPackage(app.packageName, app.uid, true);
|
||||
} catch (android.os.RemoteException ex) {
|
||||
}
|
||||
if (!app.enabled) {
|
||||
if (DEBUG) Log.v(TAG, "Enabling app: " + app.packageName);
|
||||
if (mPm.getApplicationEnabledSetting(app.packageName)
|
||||
== PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER) {
|
||||
mPm.setApplicationEnabledSetting(app.packageName,
|
||||
PackageManager.COMPONENT_ENABLED_STATE_DEFAULT,
|
||||
PackageManager.DONT_KILL_APP);
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
mIPm.resetPreferredActivities(UserHandle.myUserId());
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
mAom.resetAllModes();
|
||||
final int[] restrictedUids = mNpm.getUidsWithPolicy(
|
||||
POLICY_REJECT_METERED_BACKGROUND);
|
||||
final int currentUserId = ActivityManager.getCurrentUser();
|
||||
for (int uid : restrictedUids) {
|
||||
// Only reset for current user
|
||||
if (UserHandle.getUserId(uid) == currentUserId) {
|
||||
if (DEBUG) Log.v(TAG, "Clearing data policy: " + uid);
|
||||
mNpm.setUidPolicy(uid, POLICY_NONE);
|
||||
}
|
||||
}
|
||||
mHandler.post(new Runnable() {
|
||||
@Override public void run() {
|
||||
if (DEBUG) Log.v(TAG, "Done clearing");
|
||||
if (getActivity() != null && mActivityResumed) {
|
||||
if (DEBUG) Log.v(TAG, "Updating UI!");
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
return null;
|
||||
}
|
||||
}).execute();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRunningStateChanged(boolean running) {
|
||||
// No-op.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPackageListChanged() {
|
||||
updateAllAppsSummary();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRebuildComplete(ArrayList<AppEntry> apps) {
|
||||
// No-op.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPackageIconChanged() {
|
||||
// No-op.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPackageSizeChanged(String packageName) {
|
||||
// No-op.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAllSizesComputed() {
|
||||
// No-op.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLauncherInfoChanged() {
|
||||
// No-op.
|
||||
}
|
||||
|
||||
}
|
@@ -179,6 +179,11 @@ public abstract class AppInfoBase extends PreferenceFragment
|
||||
// No op.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLauncherInfoChanged() {
|
||||
// No op.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPackageListChanged() {
|
||||
refreshUi();
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package com.android.settings.applications;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.app.AppGlobals;
|
||||
import android.app.Application;
|
||||
import android.content.BroadcastReceiver;
|
||||
@@ -12,6 +13,7 @@ import android.content.pm.IPackageStatsObserver;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageStats;
|
||||
import android.content.pm.ParceledListSlice;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Handler;
|
||||
@@ -54,11 +56,12 @@ public class ApplicationsState {
|
||||
public void onPackageIconChanged();
|
||||
public void onPackageSizeChanged(String packageName);
|
||||
public void onAllSizesComputed();
|
||||
public void onLauncherInfoChanged();
|
||||
}
|
||||
|
||||
public static interface AppFilter {
|
||||
public void init();
|
||||
public boolean filterApp(ApplicationInfo info);
|
||||
public boolean filterApp(AppEntry info);
|
||||
}
|
||||
|
||||
static final int SIZE_UNKNOWN = -1;
|
||||
@@ -101,6 +104,8 @@ public class ApplicationsState {
|
||||
|
||||
boolean mounted;
|
||||
|
||||
boolean hasLauncherEntry;
|
||||
|
||||
String getNormalizedLabel() {
|
||||
if (normalizedLabel != null) {
|
||||
return normalizedLabel;
|
||||
@@ -175,13 +180,6 @@ public class ApplicationsState {
|
||||
private final Collator sCollator = Collator.getInstance();
|
||||
@Override
|
||||
public int compare(AppEntry object1, AppEntry object2) {
|
||||
final boolean normal1 = object1.info.enabled
|
||||
&& (object1.info.flags&ApplicationInfo.FLAG_INSTALLED) != 0;
|
||||
final boolean normal2 = object2.info.enabled
|
||||
&& (object2.info.flags&ApplicationInfo.FLAG_INSTALLED) != 0;
|
||||
if (normal1 != normal2) {
|
||||
return normal1 ? -1 : 1;
|
||||
}
|
||||
return sCollator.compare(object1.label, object2.label);
|
||||
}
|
||||
};
|
||||
@@ -219,22 +217,65 @@ public class ApplicationsState {
|
||||
}
|
||||
};
|
||||
|
||||
public static final AppFilter THIRD_PARTY_FILTER = new AppFilter() {
|
||||
public static final AppFilter FILTER_PERSONAL = new AppFilter() {
|
||||
private int mCurrentUser;
|
||||
|
||||
public void init() {
|
||||
mCurrentUser = ActivityManager.getCurrentUser();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean filterApp(AppEntry entry) {
|
||||
return UserHandle.getUserId(entry.info.uid) == mCurrentUser;
|
||||
}
|
||||
};
|
||||
|
||||
public static final AppFilter FILTER_WORK = new AppFilter() {
|
||||
private int mCurrentUser;
|
||||
|
||||
public void init() {
|
||||
mCurrentUser = ActivityManager.getCurrentUser();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean filterApp(AppEntry entry) {
|
||||
return UserHandle.getUserId(entry.info.uid) != mCurrentUser;
|
||||
}
|
||||
};
|
||||
|
||||
public static final AppFilter FILTER_DOWNLOADED_AND_LAUNCHER = new AppFilter() {
|
||||
public void init() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean filterApp(ApplicationInfo info) {
|
||||
if ((info.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0) {
|
||||
public boolean filterApp(AppEntry entry) {
|
||||
if ((entry.info.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0) {
|
||||
return true;
|
||||
} else if ((info.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
|
||||
} else if ((entry.info.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
|
||||
return true;
|
||||
} else if (entry.hasLauncherEntry) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
public static final AppFilter ON_SD_CARD_FILTER = new AppFilter() {
|
||||
public static final AppFilter FILTER_THIRD_PARTY = new AppFilter() {
|
||||
public void init() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean filterApp(AppEntry entry) {
|
||||
if ((entry.info.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0) {
|
||||
return true;
|
||||
} else if ((entry.info.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
public static final AppFilter FILTER_ON_SD_CARD = new AppFilter() {
|
||||
final CanBeOnSdCardChecker mCanBeOnSdCardChecker
|
||||
= new CanBeOnSdCardChecker();
|
||||
|
||||
@@ -243,34 +284,38 @@ public class ApplicationsState {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean filterApp(ApplicationInfo info) {
|
||||
return mCanBeOnSdCardChecker.check(info);
|
||||
public boolean filterApp(AppEntry entry) {
|
||||
return mCanBeOnSdCardChecker.check(entry.info);
|
||||
}
|
||||
};
|
||||
|
||||
public static final AppFilter DISABLED_FILTER = new AppFilter() {
|
||||
public static final AppFilter FILTER_DISABLED = new AppFilter() {
|
||||
public void init() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean filterApp(ApplicationInfo info) {
|
||||
if (!info.enabled) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
public boolean filterApp(AppEntry entry) {
|
||||
return !entry.info.enabled;
|
||||
}
|
||||
};
|
||||
|
||||
public static final AppFilter ALL_ENABLED_FILTER = new AppFilter() {
|
||||
public static final AppFilter FILTER_ALL_ENABLED = new AppFilter() {
|
||||
public void init() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean filterApp(ApplicationInfo info) {
|
||||
if (info.enabled) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
public boolean filterApp(AppEntry entry) {
|
||||
return entry.info.enabled;
|
||||
}
|
||||
};
|
||||
|
||||
public static final AppFilter FILTER_EVERYTHING = new AppFilter() {
|
||||
public void init() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean filterApp(AppEntry entry) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -398,6 +443,7 @@ public class ApplicationsState {
|
||||
static final int MSG_PACKAGE_SIZE_CHANGED = 4;
|
||||
static final int MSG_ALL_SIZES_COMPUTED = 5;
|
||||
static final int MSG_RUNNING_STATE_CHANGED = 6;
|
||||
static final int MSG_LAUNCHER_INFO_CHANGED = 7;
|
||||
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
@@ -436,6 +482,11 @@ public class ApplicationsState {
|
||||
msg.arg1 != 0);
|
||||
}
|
||||
} break;
|
||||
case MSG_LAUNCHER_INFO_CHANGED: {
|
||||
for (int i=0; i<mActiveSessions.size(); i++) {
|
||||
mActiveSessions.get(i).mCallbacks.onLauncherInfoChanged();
|
||||
}
|
||||
} break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -543,6 +594,12 @@ public class ApplicationsState {
|
||||
}
|
||||
}
|
||||
|
||||
ArrayList<AppEntry> getAllApps() {
|
||||
synchronized (mEntriesMap) {
|
||||
return new ArrayList<>(mAppEntries);
|
||||
}
|
||||
}
|
||||
|
||||
// Creates a new list of app entries with the given filter and comparator.
|
||||
ArrayList<AppEntry> rebuild(AppFilter filter, Comparator<AppEntry> comparator) {
|
||||
synchronized (mRebuildSync) {
|
||||
@@ -601,21 +658,20 @@ public class ApplicationsState {
|
||||
filter.init();
|
||||
}
|
||||
|
||||
List<ApplicationInfo> apps;
|
||||
List<AppEntry> apps;
|
||||
synchronized (mEntriesMap) {
|
||||
apps = new ArrayList<ApplicationInfo>(mApplications);
|
||||
apps = new ArrayList<>(mAppEntries);
|
||||
}
|
||||
|
||||
ArrayList<AppEntry> filteredApps = new ArrayList<AppEntry>();
|
||||
if (DEBUG) Log.i(TAG, "Rebuilding...");
|
||||
for (int i=0; i<apps.size(); i++) {
|
||||
ApplicationInfo info = apps.get(i);
|
||||
if (filter == null || filter.filterApp(info)) {
|
||||
AppEntry entry = apps.get(i);
|
||||
if (filter == null || filter.filterApp(entry)) {
|
||||
synchronized (mEntriesMap) {
|
||||
if (DEBUG_LOCKING) Log.v(TAG, "rebuild acquired lock");
|
||||
AppEntry entry = getEntryLocked(info);
|
||||
entry.ensureLabel(mContext);
|
||||
if (DEBUG) Log.i(TAG, "Using " + info.packageName + ": " + entry);
|
||||
if (DEBUG) Log.i(TAG, "Using " + entry.info.packageName + ": " + entry);
|
||||
filteredApps.add(entry);
|
||||
if (DEBUG_LOCKING) Log.v(TAG, "rebuild releasing lock");
|
||||
}
|
||||
@@ -962,6 +1018,7 @@ public class ApplicationsState {
|
||||
static final int MSG_LOAD_ENTRIES = 2;
|
||||
static final int MSG_LOAD_ICONS = 3;
|
||||
static final int MSG_LOAD_SIZES = 4;
|
||||
static final int MSG_LOAD_LAUNCHER = 5;
|
||||
|
||||
boolean mRunning;
|
||||
|
||||
@@ -1074,9 +1131,40 @@ public class ApplicationsState {
|
||||
if (numDone >= 6) {
|
||||
sendEmptyMessage(MSG_LOAD_ENTRIES);
|
||||
} else {
|
||||
sendEmptyMessage(MSG_LOAD_ICONS);
|
||||
sendEmptyMessage(MSG_LOAD_LAUNCHER);
|
||||
}
|
||||
} break;
|
||||
case MSG_LOAD_LAUNCHER: {
|
||||
Intent launchIntent = new Intent(Intent.ACTION_MAIN, null)
|
||||
.addCategory(Intent.CATEGORY_LAUNCHER);
|
||||
|
||||
for (int i = 0; i < mEntriesMap.size(); i++) {
|
||||
int userId = mEntriesMap.keyAt(i);
|
||||
List<ResolveInfo> intents = mPm.queryIntentActivitiesAsUser(launchIntent,
|
||||
PackageManager.GET_DISABLED_COMPONENTS, userId);
|
||||
synchronized (mEntriesMap) {
|
||||
if (DEBUG_LOCKING) Log.v(TAG, "MSG_LOAD_LAUNCHER acquired lock");
|
||||
HashMap<String, AppEntry> userEntries = mEntriesMap.valueAt(i);
|
||||
final int N = intents.size();
|
||||
for (int j = 0; j < N; j++) {
|
||||
String packageName = intents.get(j).activityInfo.packageName;
|
||||
AppEntry entry = userEntries.get(packageName);
|
||||
if (entry != null) {
|
||||
entry.hasLauncherEntry = true;
|
||||
} else {
|
||||
Log.w(TAG, "Cannot find pkg: " + packageName
|
||||
+ " on user " + userId);
|
||||
}
|
||||
}
|
||||
if (DEBUG_LOCKING) Log.v(TAG, "MSG_LOAD_LAUNCHER releasing lock");
|
||||
}
|
||||
}
|
||||
|
||||
if (!mMainHandler.hasMessages(MainHandler.MSG_LAUNCHER_INFO_CHANGED)) {
|
||||
mMainHandler.sendEmptyMessage(MainHandler.MSG_LAUNCHER_INFO_CHANGED);
|
||||
}
|
||||
sendEmptyMessage(MSG_LOAD_ICONS);
|
||||
} break;
|
||||
case MSG_LOAD_ICONS: {
|
||||
int numDone = 0;
|
||||
synchronized (mEntriesMap) {
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -29,6 +29,7 @@ import com.android.settings.SecuritySettings;
|
||||
import com.android.settings.WallpaperTypeSettings;
|
||||
import com.android.settings.WirelessSettings;
|
||||
import com.android.settings.accessibility.AccessibilitySettings;
|
||||
import com.android.settings.applications.AdvancedAppSettings;
|
||||
import com.android.settings.bluetooth.BluetoothSettings;
|
||||
import com.android.settings.deviceinfo.Memory;
|
||||
import com.android.settings.deviceinfo.UsbSettings;
|
||||
@@ -67,16 +68,17 @@ public final class Ranking {
|
||||
public static final int RANK_NOTIFICATIONS = 9;
|
||||
public static final int RANK_STORAGE = 10;
|
||||
public static final int RANK_POWER_USAGE = 11;
|
||||
public static final int RANK_USERS = 12;
|
||||
public static final int RANK_LOCATION = 13;
|
||||
public static final int RANK_SECURITY = 14;
|
||||
public static final int RANK_IME = 15;
|
||||
public static final int RANK_PRIVACY = 16;
|
||||
public static final int RANK_DATE_TIME = 17;
|
||||
public static final int RANK_ACCESSIBILITY = 18;
|
||||
public static final int RANK_PRINTING = 19;
|
||||
public static final int RANK_DEVELOPEMENT = 20;
|
||||
public static final int RANK_DEVICE_INFO = 21;
|
||||
public static final int RANK_APPS = 12;
|
||||
public static final int RANK_USERS = 13;
|
||||
public static final int RANK_LOCATION = 14;
|
||||
public static final int RANK_SECURITY = 15;
|
||||
public static final int RANK_IME = 16;
|
||||
public static final int RANK_PRIVACY = 17;
|
||||
public static final int RANK_DATE_TIME = 18;
|
||||
public static final int RANK_ACCESSIBILITY = 19;
|
||||
public static final int RANK_PRINTING = 20;
|
||||
public static final int RANK_DEVELOPEMENT = 21;
|
||||
public static final int RANK_DEVICE_INFO = 22;
|
||||
|
||||
public static final int RANK_UNDEFINED = -1;
|
||||
public static final int RANK_OTHERS = 1024;
|
||||
@@ -129,6 +131,9 @@ public final class Ranking {
|
||||
sRankMap.put(PowerUsageSummary.class.getName(), RANK_POWER_USAGE);
|
||||
sRankMap.put(BatterySaverSettings.class.getName(), RANK_POWER_USAGE);
|
||||
|
||||
// Advanced app settings
|
||||
sRankMap.put(AdvancedAppSettings.class.getName(), RANK_APPS);
|
||||
|
||||
// Users
|
||||
sRankMap.put(UserSettings.class.getName(), RANK_USERS);
|
||||
|
||||
|
@@ -31,6 +31,7 @@ import com.android.settings.SecuritySettings;
|
||||
import com.android.settings.WallpaperTypeSettings;
|
||||
import com.android.settings.WirelessSettings;
|
||||
import com.android.settings.accessibility.AccessibilitySettings;
|
||||
import com.android.settings.applications.AdvancedAppSettings;
|
||||
import com.android.settings.bluetooth.BluetoothSettings;
|
||||
import com.android.settings.deviceinfo.Memory;
|
||||
import com.android.settings.deviceinfo.UsbSettings;
|
||||
@@ -188,6 +189,13 @@ public final class SearchIndexableResources {
|
||||
BatterySaverSettings.class.getName(),
|
||||
R.drawable.ic_settings_battery));
|
||||
|
||||
sResMap.put(AdvancedAppSettings.class.getName(),
|
||||
new SearchIndexableResource(
|
||||
Ranking.getRankForClassName(AdvancedAppSettings.class.getName()),
|
||||
R.xml.advanced_apps,
|
||||
AdvancedAppSettings.class.getName(),
|
||||
R.drawable.ic_settings_applications));
|
||||
|
||||
sResMap.put(UserSettings.class.getName(),
|
||||
new SearchIndexableResource(
|
||||
Ranking.getRankForClassName(UserSettings.class.getName()),
|
||||
|
Reference in New Issue
Block a user