Improve resetting of application state.
We now reset preferred apps to our defaults, instead of just clearing everything out. Change-Id: I70f713ce62b2ffb2d7f6a8e056978847734c27f7
This commit is contained in:
@@ -1115,6 +1115,8 @@ public class ManageApplications extends Fragment implements
|
|||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
if (mResetDialog == dialog) {
|
if (mResetDialog == dialog) {
|
||||||
final PackageManager pm = getActivity().getPackageManager();
|
final PackageManager pm = getActivity().getPackageManager();
|
||||||
|
final IPackageManager mIPm = IPackageManager.Stub.asInterface(
|
||||||
|
ServiceManager.getService("package"));
|
||||||
final INotificationManager nm = INotificationManager.Stub.asInterface(
|
final INotificationManager nm = INotificationManager.Stub.asInterface(
|
||||||
ServiceManager.getService(Context.NOTIFICATION_SERVICE));
|
ServiceManager.getService(Context.NOTIFICATION_SERVICE));
|
||||||
final NetworkPolicyManager npm = NetworkPolicyManager.from(getActivity());
|
final NetworkPolicyManager npm = NetworkPolicyManager.from(getActivity());
|
||||||
@@ -1130,8 +1132,6 @@ public class ManageApplications extends Fragment implements
|
|||||||
nm.setNotificationsEnabledForPackage(app.packageName, true);
|
nm.setNotificationsEnabledForPackage(app.packageName, true);
|
||||||
} catch (android.os.RemoteException ex) {
|
} catch (android.os.RemoteException ex) {
|
||||||
}
|
}
|
||||||
if (DEBUG) Log.v(TAG, "Clearing preferred: " + app.packageName);
|
|
||||||
pm.clearPackagePreferredActivities(app.packageName);
|
|
||||||
if (!app.enabled) {
|
if (!app.enabled) {
|
||||||
if (DEBUG) Log.v(TAG, "Enabling app: " + app.packageName);
|
if (DEBUG) Log.v(TAG, "Enabling app: " + app.packageName);
|
||||||
if (pm.getApplicationEnabledSetting(app.packageName)
|
if (pm.getApplicationEnabledSetting(app.packageName)
|
||||||
@@ -1142,16 +1142,9 @@ public class ManageApplications extends Fragment implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// We should have cleared all of the preferred apps above;
|
try {
|
||||||
// just in case some may be lingering, retrieve whatever is
|
mIPm.resetPreferredActivities(UserHandle.myUserId());
|
||||||
// still set and remove it.
|
} catch (RemoteException e) {
|
||||||
ArrayList<IntentFilter> filters = new ArrayList<IntentFilter>();
|
|
||||||
ArrayList<ComponentName> prefActivities = new ArrayList<ComponentName>();
|
|
||||||
pm.getPreferredActivities(filters, prefActivities, null);
|
|
||||||
for (int i=0; i<prefActivities.size(); i++) {
|
|
||||||
if (DEBUG) Log.v(TAG, "Clearing preferred: "
|
|
||||||
+ prefActivities.get(i).getPackageName());
|
|
||||||
pm.clearPackagePreferredActivities(prefActivities.get(i).getPackageName());
|
|
||||||
}
|
}
|
||||||
final int[] restrictedUids = npm.getUidsWithPolicy(
|
final int[] restrictedUids = npm.getUidsWithPolicy(
|
||||||
POLICY_REJECT_METERED_BACKGROUND);
|
POLICY_REJECT_METERED_BACKGROUND);
|
||||||
|
Reference in New Issue
Block a user