Remove all apps page
Instead move the functionality back into overflow menu as show/hide system apps. Also move the reset app preferences from advanced to the overflow menu. Bug: 20210160 Change-Id: Ied573e1f7dfc438b06642ee2af8f11868130ba3b
This commit is contained in:
@@ -18,6 +18,25 @@
|
|||||||
<item
|
<item
|
||||||
android:id="@+id/advanced"
|
android:id="@+id/advanced"
|
||||||
android:title="@string/advanced_apps"
|
android:title="@string/advanced_apps"
|
||||||
android:icon="@drawable/ic_settings_24dp"
|
android:showAsAction="never" />
|
||||||
android:showAsAction="collapseActionView|ifRoom" />
|
<item
|
||||||
|
android:id="@+id/show_system"
|
||||||
|
android:title="@string/menu_show_system"
|
||||||
|
android:showAsAction="never" />
|
||||||
|
<item
|
||||||
|
android:id="@+id/hide_system"
|
||||||
|
android:title="@string/menu_hide_system"
|
||||||
|
android:showAsAction="never" />
|
||||||
|
<item
|
||||||
|
android:id="@+id/sort_order_alpha"
|
||||||
|
android:title="@string/sort_order_alpha"
|
||||||
|
android:showAsAction="never" />
|
||||||
|
<item
|
||||||
|
android:id="@+id/sort_order_size"
|
||||||
|
android:title="@string/sort_order_size"
|
||||||
|
android:showAsAction="never" />
|
||||||
|
<item
|
||||||
|
android:id="@+id/reset_app_preferences"
|
||||||
|
android:title="@string/reset_app_preferences"
|
||||||
|
android:showAsAction="never" />
|
||||||
</menu>
|
</menu>
|
||||||
|
@@ -4234,8 +4234,10 @@
|
|||||||
<string name="menu_duration_12h">12 hours</string>
|
<string name="menu_duration_12h">12 hours</string>
|
||||||
<!-- [CHAR LIMIT=NONE] Menu for process stats to show 3 hours of data -->
|
<!-- [CHAR LIMIT=NONE] Menu for process stats to show 3 hours of data -->
|
||||||
<string name="menu_duration_1d">1 day</string>
|
<string name="menu_duration_1d">1 day</string>
|
||||||
<!-- [CHAR LIMIT=NONE] Menu for process stats to control whether system processes are shown -->
|
<!-- [CHAR LIMIT=NONE] Menu for manage apps to control whether system processes are shown -->
|
||||||
<string name="menu_show_system">Show system</string>
|
<string name="menu_show_system">Show system</string>
|
||||||
|
<!-- [CHAR LIMIT=NONE] Menu for manage apps to control whether system processes are hidden -->
|
||||||
|
<string name="menu_hide_system">Hide system</string>
|
||||||
<!-- [CHAR LIMIT=NONE] Menu for process stats to control whether computation should be based
|
<!-- [CHAR LIMIT=NONE] Menu for process stats to control whether computation should be based
|
||||||
on Uss (Unique Set Size) instead of Pss (Proportional Set Size) -->
|
on Uss (Unique Set Size) instead of Pss (Proportional Set Size) -->
|
||||||
<string name="menu_use_uss">Use Uss</string>
|
<string name="menu_use_uss">Use Uss</string>
|
||||||
@@ -6359,15 +6361,9 @@
|
|||||||
<!-- Label for showing apps with domain URLs (data URI with http or https) in list [CHAR LIMIT=30] -->
|
<!-- Label for showing apps with domain URLs (data URI with http or https) in list [CHAR LIMIT=30] -->
|
||||||
<string name="filter_with_domain_urls_apps">With domain URLs</string>
|
<string name="filter_with_domain_urls_apps">With domain URLs</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>
|
|
||||||
|
|
||||||
<!-- Summary for a trust agent that was disabled by the device policy [LIMIT=NONE] -->
|
<!-- Summary for a trust agent that was disabled by the device policy [LIMIT=NONE] -->
|
||||||
<string name="trust_agent_disabled_device_admin">Disabled by administrator</string>
|
<string name="trust_agent_disabled_device_admin">Disabled by administrator</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] -->
|
<!-- Title for advanced application management settings [CHAR LIMIT=30] -->
|
||||||
<string name="advanced_apps">Advanced</string>
|
<string name="advanced_apps">Advanced</string>
|
||||||
|
|
||||||
|
@@ -40,22 +40,6 @@
|
|||||||
android:value="com.android.settings.Settings$DomainsURLsAppListActivity" />
|
android:value="com.android.settings.Settings$DomainsURLsAppListActivity" />
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|
||||||
<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" />
|
|
||||||
|
|
||||||
<com.android.settings.applications.DefaultEmergencyPreference
|
<com.android.settings.applications.DefaultEmergencyPreference
|
||||||
android:key="default_emergency_app"
|
android:key="default_emergency_app"
|
||||||
android:title="@string/default_emergency_app"
|
android:title="@string/default_emergency_app"
|
||||||
|
@@ -15,33 +15,13 @@
|
|||||||
*/
|
*/
|
||||||
package com.android.settings.applications;
|
package com.android.settings.applications;
|
||||||
|
|
||||||
import static android.net.NetworkPolicyManager.POLICY_NONE;
|
|
||||||
import static android.net.NetworkPolicyManager.POLICY_REJECT_METERED_BACKGROUND;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.ActivityManager;
|
|
||||||
import android.app.AlertDialog;
|
|
||||||
import android.app.AppOpsManager;
|
|
||||||
import android.app.INotificationManager;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.content.pm.ApplicationInfo;
|
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.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;
|
||||||
import android.preference.Preference.OnPreferenceClickListener;
|
|
||||||
import android.provider.SearchIndexableResource;
|
import android.provider.SearchIndexableResource;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
|
|
||||||
import com.android.internal.logging.MetricsLogger;
|
import com.android.internal.logging.MetricsLogger;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
@@ -56,35 +36,20 @@ import com.android.settings.search.Indexable;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class AdvancedAppSettings extends SettingsPreferenceFragment implements Callbacks,
|
public class AdvancedAppSettings extends SettingsPreferenceFragment implements Callbacks, Callback,
|
||||||
DialogInterface.OnClickListener, DialogInterface.OnDismissListener, Callback, Indexable {
|
Indexable {
|
||||||
|
|
||||||
static final String TAG = "AdvancedAppSettings";
|
static final String TAG = "AdvancedAppSettings";
|
||||||
static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
|
static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
|
||||||
|
|
||||||
private static final String KEY_APP_PERM = "manage_perms";
|
private static final String KEY_APP_PERM = "manage_perms";
|
||||||
private static final String KEY_ALL_APPS = "all_apps";
|
|
||||||
private static final String KEY_APP_DOMAIN_URLS = "domain_urls";
|
private static final String KEY_APP_DOMAIN_URLS = "domain_urls";
|
||||||
private static final String KEY_RESET_ALL = "reset_all";
|
|
||||||
private static final String KEY_DEFAULT_EMERGENCY_APP = "default_emergency_app";
|
private static final String KEY_DEFAULT_EMERGENCY_APP = "default_emergency_app";
|
||||||
private static final String EXTRA_RESET_DIALOG = "resetDialog";
|
|
||||||
|
|
||||||
private ApplicationsState mApplicationsState;
|
private ApplicationsState mApplicationsState;
|
||||||
private Session mSession;
|
private Session mSession;
|
||||||
private Preference mAppPermsPreference;
|
private Preference mAppPermsPreference;
|
||||||
private Preference mAppDomainURLsPreference;
|
private Preference mAppDomainURLsPreference;
|
||||||
private Preference mAllAppsPreference;
|
|
||||||
private Preference mResetAllPreference;
|
|
||||||
|
|
||||||
AlertDialog mResetDialog;
|
|
||||||
|
|
||||||
private boolean mActivityResumed;
|
|
||||||
private PackageManager mPm;
|
|
||||||
private IPackageManager mIPm;
|
|
||||||
private INotificationManager mNm;
|
|
||||||
private NetworkPolicyManager mNpm;
|
|
||||||
private AppOpsManager mAom;
|
|
||||||
private Handler mHandler;
|
|
||||||
private PermissionsInfo mPermissionsInfo;
|
private PermissionsInfo mPermissionsInfo;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -97,25 +62,8 @@ public class AdvancedAppSettings extends SettingsPreferenceFragment implements C
|
|||||||
|
|
||||||
mAppPermsPreference = findPreference(KEY_APP_PERM);
|
mAppPermsPreference = findPreference(KEY_APP_PERM);
|
||||||
mAppDomainURLsPreference = findPreference(KEY_APP_DOMAIN_URLS);
|
mAppDomainURLsPreference = findPreference(KEY_APP_DOMAIN_URLS);
|
||||||
mAllAppsPreference = findPreference(KEY_ALL_APPS);
|
|
||||||
mResetAllPreference = findPreference(KEY_RESET_ALL);
|
|
||||||
mResetAllPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
|
||||||
buildResetDialog();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
updateUI();
|
updateUI();
|
||||||
|
|
||||||
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());
|
|
||||||
|
|
||||||
if (!DefaultEmergencyPreference.isAvailable(getActivity())) {
|
if (!DefaultEmergencyPreference.isAvailable(getActivity())) {
|
||||||
removePreference(KEY_DEFAULT_EMERGENCY_APP);
|
removePreference(KEY_DEFAULT_EMERGENCY_APP);
|
||||||
}
|
}
|
||||||
@@ -123,7 +71,6 @@ public class AdvancedAppSettings extends SettingsPreferenceFragment implements C
|
|||||||
|
|
||||||
private void updateUI() {
|
private void updateUI() {
|
||||||
ArrayList<AppEntry> allApps = mSession.getAllApps();
|
ArrayList<AppEntry> allApps = mSession.getAllApps();
|
||||||
mAllAppsPreference.setSummary(getString(R.string.all_apps_summary, allApps.size()));
|
|
||||||
|
|
||||||
int countAppWithDomainURLs = 0;
|
int countAppWithDomainURLs = 0;
|
||||||
for (AppEntry entry : allApps) {
|
for (AppEntry entry : allApps) {
|
||||||
@@ -136,25 +83,6 @@ public class AdvancedAppSettings extends SettingsPreferenceFragment implements C
|
|||||||
mAppDomainURLsPreference.setSummary(summary);
|
mAppDomainURLsPreference.setSummary(summary);
|
||||||
}
|
}
|
||||||
|
|
||||||
@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
|
@Override
|
||||||
protected int getMetricsCategory() {
|
protected int getMetricsCategory() {
|
||||||
return MetricsLogger.APPLICATIONS_ADVANCED;
|
return MetricsLogger.APPLICATIONS_ADVANCED;
|
||||||
@@ -163,97 +91,9 @@ public class AdvancedAppSettings extends SettingsPreferenceFragment implements C
|
|||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
mActivityResumed = true;
|
|
||||||
mPermissionsInfo = new PermissionsInfo(getActivity(), this);
|
mPermissionsInfo = new PermissionsInfo(getActivity(), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@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
|
@Override
|
||||||
public void onRunningStateChanged(boolean running) {
|
public void onRunningStateChanged(boolean running) {
|
||||||
// No-op.
|
// No-op.
|
||||||
|
@@ -349,6 +349,27 @@ public class ApplicationsState {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public static class CompoundFilter implements AppFilter {
|
||||||
|
private final AppFilter mFirstFilter;
|
||||||
|
private final AppFilter mSecondFilter;
|
||||||
|
|
||||||
|
public CompoundFilter(AppFilter first, AppFilter second) {
|
||||||
|
mFirstFilter = first;
|
||||||
|
mSecondFilter = second;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init() {
|
||||||
|
mFirstFilter.init();
|
||||||
|
mSecondFilter.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean filterApp(AppEntry info) {
|
||||||
|
return mFirstFilter.filterApp(info) && mSecondFilter.filterApp(info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final Context mContext;
|
final Context mContext;
|
||||||
final PackageManager mPm;
|
final PackageManager mPm;
|
||||||
final IPackageManager mIpm;
|
final IPackageManager mIpm;
|
||||||
|
@@ -58,14 +58,15 @@ import com.android.internal.logging.MetricsLogger;
|
|||||||
import com.android.settings.InstrumentedFragment;
|
import com.android.settings.InstrumentedFragment;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.Settings.AllApplicationsActivity;
|
import com.android.settings.Settings.AllApplicationsActivity;
|
||||||
|
import com.android.settings.Settings.DomainsURLsAppListActivity;
|
||||||
import com.android.settings.Settings.NotificationAppListActivity;
|
import com.android.settings.Settings.NotificationAppListActivity;
|
||||||
import com.android.settings.SettingsActivity;
|
import com.android.settings.SettingsActivity;
|
||||||
import com.android.settings.Utils;
|
import com.android.settings.Utils;
|
||||||
import com.android.settings.applications.ApplicationsState.AppEntry;
|
import com.android.settings.applications.ApplicationsState.AppEntry;
|
||||||
import com.android.settings.applications.ApplicationsState.AppFilter;
|
import com.android.settings.applications.ApplicationsState.AppFilter;
|
||||||
|
import com.android.settings.applications.ApplicationsState.CompoundFilter;
|
||||||
import com.android.settings.notification.NotificationBackend;
|
import com.android.settings.notification.NotificationBackend;
|
||||||
import com.android.settings.notification.NotificationBackend.AppRow;
|
import com.android.settings.notification.NotificationBackend.AppRow;
|
||||||
import com.android.settings.Settings.DomainsURLsAppListActivity;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -141,19 +142,23 @@ public class ManageApplications extends InstrumentedFragment
|
|||||||
// Filter options used for displayed list of applications
|
// Filter options used for displayed list of applications
|
||||||
// The order which they appear is the order they will show when spinner is present.
|
// The order which they appear is the order they will show when spinner is present.
|
||||||
public static final int FILTER_APPS_DOWNLOADED_AND_LAUNCHER = 0;
|
public static final int FILTER_APPS_DOWNLOADED_AND_LAUNCHER = 0;
|
||||||
public static final int FILTER_APPS_ALL = 1;
|
public static final int FILTER_APPS_DL_ENABLED = 1;
|
||||||
public static final int FILTER_APPS_ENABLED = 2;
|
public static final int FILTER_APPS_DL_DISABLED = 2;
|
||||||
public static final int FILTER_APPS_DISABLED = 3;
|
public static final int FILTER_APPS_ALL = 3;
|
||||||
public static final int FILTER_APPS_BLOCKED = 4;
|
public static final int FILTER_APPS_ENABLED = 4;
|
||||||
public static final int FILTER_APPS_PRIORITY = 5;
|
public static final int FILTER_APPS_DISABLED = 5;
|
||||||
public static final int FILTER_APPS_SENSITIVE = 6;
|
public static final int FILTER_APPS_BLOCKED = 6;
|
||||||
public static final int FILTER_APPS_PERSONAL = 7;
|
public static final int FILTER_APPS_PRIORITY = 7;
|
||||||
public static final int FILTER_APPS_WORK = 8;
|
public static final int FILTER_APPS_SENSITIVE = 8;
|
||||||
public static final int FILTER_APPS_WITH_DOMAIN_URLS = 9;
|
public static final int FILTER_APPS_PERSONAL = 9;
|
||||||
|
public static final int FILTER_APPS_WORK = 10;
|
||||||
|
public static final int FILTER_APPS_WITH_DOMAIN_URLS = 11;
|
||||||
|
|
||||||
// This is the string labels for the filter modes above, the order must be kept in sync.
|
// This is the string labels for the filter modes above, the order must be kept in sync.
|
||||||
public static final int[] FILTER_LABELS = new int[] {
|
public static final int[] FILTER_LABELS = new int[] {
|
||||||
R.string.filter_all_apps, // Downloaded and launcher, spinner not shown in this case
|
R.string.filter_all_apps, // Downloaded and launcher
|
||||||
|
R.string.filter_enabled_apps, // Downloaded and launcher, Enabled
|
||||||
|
R.string.filter_apps_disabled, // Downloaded and launcher, Disabled
|
||||||
R.string.filter_all_apps, // All apps
|
R.string.filter_all_apps, // All apps
|
||||||
R.string.filter_enabled_apps, // Enabled
|
R.string.filter_enabled_apps, // Enabled
|
||||||
R.string.filter_apps_disabled, // Disabled
|
R.string.filter_apps_disabled, // Disabled
|
||||||
@@ -168,6 +173,12 @@ public class ManageApplications extends InstrumentedFragment
|
|||||||
// be kept in sync.
|
// be kept in sync.
|
||||||
public static final AppFilter[] FILTERS = new AppFilter[] {
|
public static final AppFilter[] FILTERS = new AppFilter[] {
|
||||||
ApplicationsState.FILTER_DOWNLOADED_AND_LAUNCHER, // Downloaded and launcher
|
ApplicationsState.FILTER_DOWNLOADED_AND_LAUNCHER, // Downloaded and launcher
|
||||||
|
new CompoundFilter( // Downloaded and launcher, Enabled
|
||||||
|
ApplicationsState.FILTER_DOWNLOADED_AND_LAUNCHER,
|
||||||
|
ApplicationsState.FILTER_ALL_ENABLED),
|
||||||
|
new CompoundFilter( // Downloaded and launcher, Disabled
|
||||||
|
ApplicationsState.FILTER_DOWNLOADED_AND_LAUNCHER,
|
||||||
|
ApplicationsState.FILTER_DISABLED),
|
||||||
ApplicationsState.FILTER_EVERYTHING, // All apps
|
ApplicationsState.FILTER_EVERYTHING, // All apps
|
||||||
ApplicationsState.FILTER_ALL_ENABLED, // Enabled
|
ApplicationsState.FILTER_ALL_ENABLED, // Enabled
|
||||||
ApplicationsState.FILTER_DISABLED, // Disabled
|
ApplicationsState.FILTER_DISABLED, // Disabled
|
||||||
@@ -179,14 +190,12 @@ public class ManageApplications extends InstrumentedFragment
|
|||||||
ApplicationsState.FILTER_WITH_DOMAIN_URLS, // Apps with Domain URLs
|
ApplicationsState.FILTER_WITH_DOMAIN_URLS, // Apps with Domain URLs
|
||||||
};
|
};
|
||||||
|
|
||||||
// sort order that can be changed through the menu can be sorted alphabetically
|
|
||||||
// or size(descending)
|
|
||||||
private static final int MENU_OPTIONS_BASE = 0;
|
|
||||||
public static final int SORT_ORDER_ALPHA = MENU_OPTIONS_BASE + 1;
|
|
||||||
public static final int SORT_ORDER_SIZE = MENU_OPTIONS_BASE + 2;
|
|
||||||
public static final int RESET_APP_PREFERENCES = MENU_OPTIONS_BASE + 3;
|
|
||||||
// sort order
|
// sort order
|
||||||
private int mSortOrder = SORT_ORDER_ALPHA;
|
private int mSortOrder = R.id.sort_order_alpha;
|
||||||
|
|
||||||
|
// whether showing system apps.
|
||||||
|
private boolean mShowSystem;
|
||||||
|
private boolean mHasDisabledApps;
|
||||||
|
|
||||||
private ApplicationsState mApplicationsState;
|
private ApplicationsState mApplicationsState;
|
||||||
|
|
||||||
@@ -214,9 +223,8 @@ public class ManageApplications extends InstrumentedFragment
|
|||||||
private Menu mOptionsMenu;
|
private Menu mOptionsMenu;
|
||||||
|
|
||||||
public static final int LIST_TYPE_MAIN = 0;
|
public static final int LIST_TYPE_MAIN = 0;
|
||||||
public static final int LIST_TYPE_ALL = 1;
|
public static final int LIST_TYPE_NOTIFICATION = 1;
|
||||||
public static final int LIST_TYPE_NOTIFICATION = 2;
|
public static final int LIST_TYPE_DOMAINS_URLS = 2;
|
||||||
public static final int LIST_TYPE_DOMAINS_URLS = 3;
|
|
||||||
|
|
||||||
private View mRootView;
|
private View mRootView;
|
||||||
|
|
||||||
@@ -224,6 +232,7 @@ public class ManageApplications extends InstrumentedFragment
|
|||||||
private Spinner mFilterSpinner;
|
private Spinner mFilterSpinner;
|
||||||
private FilterSpinnerAdapter mFilterAdapter;
|
private FilterSpinnerAdapter mFilterAdapter;
|
||||||
private NotificationBackend mNotifBackend;
|
private NotificationBackend mNotifBackend;
|
||||||
|
private ResetAppsHelper mResetAppsHelper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
@@ -238,7 +247,7 @@ public class ManageApplications extends InstrumentedFragment
|
|||||||
className = intent.getComponent().getClassName();
|
className = intent.getComponent().getClassName();
|
||||||
}
|
}
|
||||||
if (className.equals(AllApplicationsActivity.class.getName())) {
|
if (className.equals(AllApplicationsActivity.class.getName())) {
|
||||||
mListType = LIST_TYPE_ALL;
|
mShowSystem = true;
|
||||||
} else if (className.equals(NotificationAppListActivity.class.getName())) {
|
} else if (className.equals(NotificationAppListActivity.class.getName())) {
|
||||||
mListType = LIST_TYPE_NOTIFICATION;
|
mListType = LIST_TYPE_NOTIFICATION;
|
||||||
mNotifBackend = new NotificationBackend();
|
mNotifBackend = new NotificationBackend();
|
||||||
@@ -254,6 +263,8 @@ public class ManageApplications extends InstrumentedFragment
|
|||||||
}
|
}
|
||||||
|
|
||||||
mInvalidSizeStr = getActivity().getText(R.string.invalid_size_value);
|
mInvalidSizeStr = getActivity().getText(R.string.invalid_size_value);
|
||||||
|
|
||||||
|
mResetAppsHelper = new ResetAppsHelper(getActivity());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -263,8 +274,6 @@ public class ManageApplications extends InstrumentedFragment
|
|||||||
// initialize the inflater
|
// initialize the inflater
|
||||||
mInflater = inflater;
|
mInflater = inflater;
|
||||||
|
|
||||||
createHeader();
|
|
||||||
|
|
||||||
mRootView = inflater.inflate(R.layout.manage_applications_apps, null);
|
mRootView = inflater.inflate(R.layout.manage_applications_apps, null);
|
||||||
mLoadingContainer = mRootView.findViewById(R.id.loading_container);
|
mLoadingContainer = mRootView.findViewById(R.id.loading_container);
|
||||||
mLoadingContainer.setVisibility(View.VISIBLE);
|
mLoadingContainer.setVisibility(View.VISIBLE);
|
||||||
@@ -294,6 +303,10 @@ public class ManageApplications extends InstrumentedFragment
|
|||||||
((PreferenceFrameLayout.LayoutParams) mRootView.getLayoutParams()).removeBorders = true;
|
((PreferenceFrameLayout.LayoutParams) mRootView.getLayoutParams()).removeBorders = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
createHeader();
|
||||||
|
|
||||||
|
mResetAppsHelper.onRestoreInstanceState(savedInstanceState);
|
||||||
|
|
||||||
return mRootView;
|
return mRootView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -316,32 +329,30 @@ public class ManageApplications extends InstrumentedFragment
|
|||||||
mFilterAdapter.enableFilter(FILTER_APPS_WORK);
|
mFilterAdapter.enableFilter(FILTER_APPS_WORK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
updateMainFilters();
|
||||||
if (mListType == LIST_TYPE_NOTIFICATION) {
|
if (mListType == LIST_TYPE_NOTIFICATION) {
|
||||||
mFilterAdapter.enableFilter(FILTER_APPS_BLOCKED);
|
mFilterAdapter.enableFilter(FILTER_APPS_BLOCKED);
|
||||||
mFilterAdapter.enableFilter(FILTER_APPS_PRIORITY);
|
mFilterAdapter.enableFilter(FILTER_APPS_PRIORITY);
|
||||||
mFilterAdapter.enableFilter(FILTER_APPS_SENSITIVE);
|
mFilterAdapter.enableFilter(FILTER_APPS_SENSITIVE);
|
||||||
} else if (mListType == LIST_TYPE_DOMAINS_URLS) {
|
|
||||||
mFilterAdapter.disableFilter(FILTER_APPS_ALL);
|
|
||||||
mFilterAdapter.enableFilter(FILTER_APPS_WITH_DOMAIN_URLS);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getDefaultFilter() {
|
private int getDefaultFilter() {
|
||||||
if (mListType == LIST_TYPE_MAIN) {
|
switch (mListType) {
|
||||||
return FILTER_APPS_DOWNLOADED_AND_LAUNCHER;
|
case LIST_TYPE_MAIN:
|
||||||
} else if (mListType == LIST_TYPE_DOMAINS_URLS) {
|
return mShowSystem ? FILTER_APPS_ALL : FILTER_APPS_DOWNLOADED_AND_LAUNCHER;
|
||||||
|
case LIST_TYPE_DOMAINS_URLS:
|
||||||
return FILTER_APPS_WITH_DOMAIN_URLS;
|
return FILTER_APPS_WITH_DOMAIN_URLS;
|
||||||
}
|
default:
|
||||||
return FILTER_APPS_ALL;
|
return FILTER_APPS_ALL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getMetricsCategory() {
|
protected int getMetricsCategory() {
|
||||||
switch (mListType) {
|
switch (mListType) {
|
||||||
case LIST_TYPE_MAIN:
|
case LIST_TYPE_MAIN:
|
||||||
return MetricsLogger.MANAGE_APPLICATIONS;
|
return MetricsLogger.MANAGE_APPLICATIONS;
|
||||||
case LIST_TYPE_ALL:
|
|
||||||
return MetricsLogger.MANAGE_APPLICATIONS_ALL;
|
|
||||||
case LIST_TYPE_NOTIFICATION:
|
case LIST_TYPE_NOTIFICATION:
|
||||||
return MetricsLogger.MANAGE_APPLICATIONS_NOTIFICATIONS;
|
return MetricsLogger.MANAGE_APPLICATIONS_NOTIFICATIONS;
|
||||||
case LIST_TYPE_DOMAINS_URLS:
|
case LIST_TYPE_DOMAINS_URLS:
|
||||||
@@ -365,6 +376,7 @@ public class ManageApplications extends InstrumentedFragment
|
|||||||
@Override
|
@Override
|
||||||
public void onSaveInstanceState(Bundle outState) {
|
public void onSaveInstanceState(Bundle outState) {
|
||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
|
mResetAppsHelper.onSaveInstanceState(outState);
|
||||||
outState.putInt(EXTRA_SORT_ORDER, mSortOrder);
|
outState.putInt(EXTRA_SORT_ORDER, mSortOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -376,6 +388,12 @@ public class ManageApplications extends InstrumentedFragment
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop() {
|
||||||
|
super.onStop();
|
||||||
|
mResetAppsHelper.stop();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroyView() {
|
public void onDestroyView() {
|
||||||
super.onDestroyView();
|
super.onDestroyView();
|
||||||
@@ -428,19 +446,11 @@ public class ManageApplications extends InstrumentedFragment
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||||
if (mListType == LIST_TYPE_DOMAINS_URLS) {
|
if (mListType != LIST_TYPE_MAIN) {
|
||||||
// No option menu
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mOptionsMenu = menu;
|
mOptionsMenu = menu;
|
||||||
if (mListType == LIST_TYPE_MAIN) {
|
|
||||||
// Only show advanced options when in the main app list (from dashboard).
|
|
||||||
inflater.inflate(R.menu.manage_apps, menu);
|
inflater.inflate(R.menu.manage_apps, menu);
|
||||||
}
|
|
||||||
menu.add(0, SORT_ORDER_ALPHA, 1, R.string.sort_order_alpha)
|
|
||||||
.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
|
|
||||||
menu.add(0, SORT_ORDER_SIZE, 2, R.string.sort_order_size)
|
|
||||||
.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
|
|
||||||
updateOptionsMenu();
|
updateOptionsMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -460,11 +470,19 @@ public class ManageApplications extends InstrumentedFragment
|
|||||||
}
|
}
|
||||||
if (mListType != LIST_TYPE_MAIN) {
|
if (mListType != LIST_TYPE_MAIN) {
|
||||||
// Allow sorting except on main apps list.
|
// Allow sorting except on main apps list.
|
||||||
mOptionsMenu.findItem(SORT_ORDER_ALPHA).setVisible(mSortOrder != SORT_ORDER_ALPHA);
|
mOptionsMenu.findItem(R.id.sort_order_alpha).setVisible(
|
||||||
mOptionsMenu.findItem(SORT_ORDER_SIZE).setVisible(mSortOrder != SORT_ORDER_SIZE);
|
mSortOrder != R.id.sort_order_alpha);
|
||||||
|
mOptionsMenu.findItem(R.id.sort_order_size).setVisible(
|
||||||
|
mSortOrder != R.id.sort_order_size);
|
||||||
|
|
||||||
|
mOptionsMenu.findItem(R.id.show_system).setVisible(false);
|
||||||
|
mOptionsMenu.findItem(R.id.hide_system).setVisible(false);
|
||||||
} else {
|
} else {
|
||||||
mOptionsMenu.findItem(SORT_ORDER_ALPHA).setVisible(false);
|
mOptionsMenu.findItem(R.id.sort_order_alpha).setVisible(false);
|
||||||
mOptionsMenu.findItem(SORT_ORDER_SIZE).setVisible(false);
|
mOptionsMenu.findItem(R.id.sort_order_size).setVisible(false);
|
||||||
|
|
||||||
|
mOptionsMenu.findItem(R.id.show_system).setVisible(!mShowSystem);
|
||||||
|
mOptionsMenu.findItem(R.id.hide_system).setVisible(mShowSystem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -472,13 +490,21 @@ public class ManageApplications extends InstrumentedFragment
|
|||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
int menuId = item.getItemId();
|
int menuId = item.getItemId();
|
||||||
switch(item.getItemId()) {
|
switch(item.getItemId()) {
|
||||||
case SORT_ORDER_ALPHA:
|
case R.id.sort_order_alpha:
|
||||||
case SORT_ORDER_SIZE:
|
case R.id.sort_order_size:
|
||||||
mSortOrder = menuId;
|
mSortOrder = menuId;
|
||||||
if (mApplications != null) {
|
if (mApplications != null) {
|
||||||
mApplications.rebuild(mSortOrder);
|
mApplications.rebuild(mSortOrder);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case R.id.show_system:
|
||||||
|
case R.id.hide_system:
|
||||||
|
mShowSystem = !mShowSystem;
|
||||||
|
updateMainFilters();
|
||||||
|
break;
|
||||||
|
case R.id.reset_app_preferences:
|
||||||
|
mResetAppsHelper.buildResetDialog();
|
||||||
|
return true;
|
||||||
case R.id.advanced:
|
case R.id.advanced:
|
||||||
((SettingsActivity) getActivity()).startPreferencePanel(
|
((SettingsActivity) getActivity()).startPreferencePanel(
|
||||||
AdvancedAppSettings.class.getName(), null, R.string.advanced_apps,
|
AdvancedAppSettings.class.getName(), null, R.string.advanced_apps,
|
||||||
@@ -492,6 +518,18 @@ public class ManageApplications extends InstrumentedFragment
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateMainFilters() {
|
||||||
|
if (mListType != LIST_TYPE_MAIN) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mFilterAdapter.setFilterEnabled(FILTER_APPS_ALL, mShowSystem);
|
||||||
|
mFilterAdapter.setFilterEnabled(FILTER_APPS_ENABLED, mShowSystem && mHasDisabledApps);
|
||||||
|
mFilterAdapter.setFilterEnabled(FILTER_APPS_DISABLED, mShowSystem && mHasDisabledApps);
|
||||||
|
mFilterAdapter.setFilterEnabled(FILTER_APPS_DOWNLOADED_AND_LAUNCHER, !mShowSystem);
|
||||||
|
mFilterAdapter.setFilterEnabled(FILTER_APPS_DL_ENABLED, !mShowSystem && mHasDisabledApps);
|
||||||
|
mFilterAdapter.setFilterEnabled(FILTER_APPS_DL_DISABLED, !mShowSystem && mHasDisabledApps);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
if (mApplications != null && mApplications.getCount() > position) {
|
if (mApplications != null && mApplications.getCount() > position) {
|
||||||
@@ -506,7 +544,9 @@ public class ManageApplications extends InstrumentedFragment
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||||
mApplications.setFilter(mFilterAdapter.getFilter(position));
|
mFilter = mFilterAdapter.getFilter(position);
|
||||||
|
mApplications.setFilter(mFilter);
|
||||||
|
if (DEBUG) Log.d(TAG, "Selecting filter " + mFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -522,17 +562,11 @@ public class ManageApplications extends InstrumentedFragment
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setHasDisabled(boolean hasDisabledApps) {
|
public void setHasDisabled(boolean hasDisabledApps) {
|
||||||
if (mListType == LIST_TYPE_MAIN) {
|
mHasDisabledApps = hasDisabledApps;
|
||||||
// No filtering on main app list.
|
mFilterAdapter.setFilterEnabled(
|
||||||
return;
|
mShowSystem ? FILTER_APPS_ENABLED : FILTER_APPS_DL_ENABLED, hasDisabledApps);
|
||||||
}
|
mFilterAdapter.setFilterEnabled(
|
||||||
if (hasDisabledApps) {
|
mShowSystem ? FILTER_APPS_DISABLED : FILTER_APPS_DL_DISABLED, hasDisabledApps);
|
||||||
mFilterAdapter.enableFilter(FILTER_APPS_ENABLED);
|
|
||||||
mFilterAdapter.enableFilter(FILTER_APPS_DISABLED);
|
|
||||||
} else {
|
|
||||||
mFilterAdapter.disableFilter(FILTER_APPS_ENABLED);
|
|
||||||
mFilterAdapter.disableFilter(FILTER_APPS_DISABLED);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static class FilterSpinnerAdapter extends ArrayAdapter<CharSequence> {
|
static class FilterSpinnerAdapter extends ArrayAdapter<CharSequence> {
|
||||||
@@ -553,23 +587,45 @@ public class ManageApplications extends InstrumentedFragment
|
|||||||
return mFilterOptions.get(position);
|
return mFilterOptions.get(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setFilterEnabled(int filter, boolean enabled) {
|
||||||
|
if (enabled) {
|
||||||
|
enableFilter(filter);
|
||||||
|
} else {
|
||||||
|
disableFilter(filter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void enableFilter(int filter) {
|
public void enableFilter(int filter) {
|
||||||
if (mFilterOptions.contains(filter)) return;
|
if (mFilterOptions.contains(filter)) return;
|
||||||
|
if (DEBUG) Log.d(TAG, "Enabling filter " + filter);
|
||||||
mFilterOptions.add(filter);
|
mFilterOptions.add(filter);
|
||||||
Collections.sort(mFilterOptions);
|
Collections.sort(mFilterOptions);
|
||||||
mManageApplications.mSpinnerHeader.setVisibility(
|
mManageApplications.mSpinnerHeader.setVisibility(
|
||||||
mFilterOptions.size() > 1 ? View.VISIBLE : View.GONE);
|
mFilterOptions.size() > 1 ? View.VISIBLE : View.GONE);
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
|
if (mFilterOptions.size() == 1) {
|
||||||
|
if (DEBUG) Log.d(TAG, "Auto selecting filter " + filter);
|
||||||
|
mManageApplications.mFilterSpinner.setSelection(0);
|
||||||
|
mManageApplications.onItemSelected(null, null, 0, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disableFilter(int filter) {
|
public void disableFilter(int filter) {
|
||||||
if (!mFilterOptions.remove((Integer) filter)) {
|
if (!mFilterOptions.remove((Integer) filter)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (DEBUG) Log.d(TAG, "Disabling filter " + filter);
|
||||||
Collections.sort(mFilterOptions);
|
Collections.sort(mFilterOptions);
|
||||||
mManageApplications.mSpinnerHeader.setVisibility(
|
mManageApplications.mSpinnerHeader.setVisibility(
|
||||||
mFilterOptions.size() > 1 ? View.VISIBLE : View.GONE);
|
mFilterOptions.size() > 1 ? View.VISIBLE : View.GONE);
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
|
if (mManageApplications.mFilter == filter) {
|
||||||
|
if (mFilterOptions.size() > 0) {
|
||||||
|
if (DEBUG) Log.d(TAG, "Auto selecting filter " + mFilterOptions.get(0));
|
||||||
|
mManageApplications.mFilterSpinner.setSelection(0);
|
||||||
|
mManageApplications.onItemSelected(null, null, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -716,7 +772,7 @@ public class ManageApplications extends InstrumentedFragment
|
|||||||
}
|
}
|
||||||
filterObj = FILTERS[mFilterMode];
|
filterObj = FILTERS[mFilterMode];
|
||||||
switch (mLastSortMode) {
|
switch (mLastSortMode) {
|
||||||
case SORT_ORDER_SIZE:
|
case R.id.sort_order_size:
|
||||||
switch (mWhichSize) {
|
switch (mWhichSize) {
|
||||||
case SIZE_INTERNAL:
|
case SIZE_INTERNAL:
|
||||||
comparatorObj = ApplicationsState.INTERNAL_SIZE_COMPARATOR;
|
comparatorObj = ApplicationsState.INTERNAL_SIZE_COMPARATOR;
|
||||||
@@ -845,7 +901,7 @@ public class ManageApplications extends InstrumentedFragment
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (holder.entry.info.packageName.equals(mManageApplications.mCurrentPkgName)
|
if (holder.entry.info.packageName.equals(mManageApplications.mCurrentPkgName)
|
||||||
&& mLastSortMode == SORT_ORDER_SIZE) {
|
&& mLastSortMode == R.id.sort_order_size) {
|
||||||
// We got the size information for the last app the
|
// We got the size information for the last app the
|
||||||
// user viewed, and are sorting by size... they may
|
// user viewed, and are sorting by size... they may
|
||||||
// have cleared data, so we immediately want to resort
|
// have cleared data, so we immediately want to resort
|
||||||
@@ -866,7 +922,7 @@ public class ManageApplications extends InstrumentedFragment
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAllSizesComputed() {
|
public void onAllSizesComputed() {
|
||||||
if (mLastSortMode == SORT_ORDER_SIZE) {
|
if (mLastSortMode == R.id.sort_order_size) {
|
||||||
rebuild(false);
|
rebuild(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
145
src/com/android/settings/applications/ResetAppsHelper.java
Normal file
145
src/com/android/settings/applications/ResetAppsHelper.java
Normal file
@@ -0,0 +1,145 @@
|
|||||||
|
/*
|
||||||
|
* 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.RemoteException;
|
||||||
|
import android.os.ServiceManager;
|
||||||
|
import android.os.UserHandle;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ResetAppsHelper implements DialogInterface.OnClickListener,
|
||||||
|
DialogInterface.OnDismissListener {
|
||||||
|
|
||||||
|
private static final String EXTRA_RESET_DIALOG = "resetDialog";
|
||||||
|
|
||||||
|
private final PackageManager mPm;
|
||||||
|
private final IPackageManager mIPm;
|
||||||
|
private final INotificationManager mNm;
|
||||||
|
private final NetworkPolicyManager mNpm;
|
||||||
|
private final AppOpsManager mAom;
|
||||||
|
private final Context mContext;
|
||||||
|
|
||||||
|
private AlertDialog mResetDialog;
|
||||||
|
|
||||||
|
public ResetAppsHelper(Context context) {
|
||||||
|
mContext = context;
|
||||||
|
mPm = context.getPackageManager();
|
||||||
|
mIPm = IPackageManager.Stub.asInterface(ServiceManager.getService("package"));
|
||||||
|
mNm = INotificationManager.Stub.asInterface(
|
||||||
|
ServiceManager.getService(Context.NOTIFICATION_SERVICE));
|
||||||
|
mNpm = NetworkPolicyManager.from(context);
|
||||||
|
mAom = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onRestoreInstanceState(Bundle savedInstanceState) {
|
||||||
|
if (savedInstanceState != null && savedInstanceState.getBoolean(EXTRA_RESET_DIALOG)) {
|
||||||
|
buildResetDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onSaveInstanceState(Bundle outState) {
|
||||||
|
if (mResetDialog != null) {
|
||||||
|
outState.putBoolean(EXTRA_RESET_DIALOG, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stop() {
|
||||||
|
if (mResetDialog != null) {
|
||||||
|
mResetDialog.dismiss();
|
||||||
|
mResetDialog = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void buildResetDialog() {
|
||||||
|
if (mResetDialog == null) {
|
||||||
|
mResetDialog = new AlertDialog.Builder(mContext)
|
||||||
|
.setTitle(R.string.reset_app_preferences_title)
|
||||||
|
.setMessage(R.string.reset_app_preferences_desc)
|
||||||
|
.setPositiveButton(R.string.reset_app_preferences_button, this)
|
||||||
|
.setNegativeButton(R.string.cancel, null)
|
||||||
|
.setOnDismissListener(this)
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDismiss(DialogInterface dialog) {
|
||||||
|
if (mResetDialog == dialog) {
|
||||||
|
mResetDialog = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
if (mResetDialog != dialog) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
AsyncTask.execute(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
List<ApplicationInfo> apps = mPm.getInstalledApplications(
|
||||||
|
PackageManager.GET_DISABLED_COMPONENTS);
|
||||||
|
for (int i = 0; i < apps.size(); i++) {
|
||||||
|
ApplicationInfo app = apps.get(i);
|
||||||
|
try {
|
||||||
|
mNm.setNotificationsEnabledForPackage(app.packageName, app.uid, true);
|
||||||
|
} catch (android.os.RemoteException ex) {
|
||||||
|
}
|
||||||
|
if (!app.enabled) {
|
||||||
|
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) {
|
||||||
|
mNpm.setUidPolicy(uid, POLICY_NONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user