Fix a crash when transferring an app.

This crash occurs because the background loader is loading
the storage for an app which is currently being moved off of
the device. In the native code which is calculating the storage,
it throws an InstallerException which is caught and rethrown as an
IllegalStateException.

We handle this in the view by reporting that we could not calculate
the size of the app.

Change-Id: I109b1be60ae60f8ef31b08cb4392b576261fa806
Fixes: 35922033
Test: Robotest
This commit is contained in:
Daniel Nishi
2017-03-02 12:52:40 -08:00
parent 8e12df9d62
commit 6a256e77d6
6 changed files with 285 additions and 71 deletions

View File

@@ -20,6 +20,7 @@ import android.annotation.NonNull;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.os.UserHandle;
import android.util.Log;
import com.android.internal.util.Preconditions;
import com.android.settings.utils.AsyncLoader;
@@ -30,6 +31,7 @@ import com.android.settingslib.applications.StorageStatsSource.AppStorageStats;
* Fetches the storage stats using the StorageStatsManager for a given package and user tuple.
*/
public class FetchPackageStorageAsyncLoader extends AsyncLoader<AppStorageStats> {
private static final String TAG = "FetchPackageStorage";
private final StorageStatsSource mSource;
private final ApplicationInfo mInfo;
private final UserHandle mUser;
@@ -44,7 +46,13 @@ public class FetchPackageStorageAsyncLoader extends AsyncLoader<AppStorageStats>
@Override
public AppStorageStats loadInBackground() {
return mSource.getStatsForPackage(mInfo.volumeUuid, mInfo.packageName, mUser);
AppStorageStats result = null;
try {
result = mSource.getStatsForPackage(mInfo.volumeUuid, mInfo.packageName, mUser);
} catch (IllegalStateException e) {
Log.w(TAG, "Package may have been removed during query, failing gracefully", e);
}
return result;
}
@Override