Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e461e673 authored by Arc Wang's avatar Arc Wang
Browse files

Fix crashes when clearing storage for a protected package

When clearing storage for a protected package,
ActivityManager throws a SecurityException.

This change catches the exception then shows a dialog
with the message "Couldn't clear storage for app".

Bug: 191806850
Test: manual visual
      1. Lock the device.
      2. Clear storage for a protected package.
Change-Id: Ic3e2c2237c6ee6dc945b03dac35b3b96a26129a9
parent 22f6857a
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -368,7 +368,12 @@ public class AppStorageSettings extends AppInfoWithHeader
        }
        ActivityManager am = (ActivityManager)
                getActivity().getSystemService(Context.ACTIVITY_SERVICE);
        boolean res = am.clearApplicationUserData(packageName, mClearDataObserver);
        boolean res = false;
        try {
            res = am.clearApplicationUserData(packageName, mClearDataObserver);
        } catch (SecurityException e) {
            Log.i(TAG, "Failed to clear application user data: " + e);
        }
        if (!res) {
            // Clearing data failed for some obscure reason. Just log error for now
            Log.i(TAG, "Couldn't clear application user data for package:" + packageName);