Merge "Follow storage API polishing." into oc-dev
am: e398a84199
Change-Id: Iad89fac67061de273b88f5d3e384de0349577e57
This commit is contained in:
@@ -19,6 +19,7 @@ package com.android.settings.applications;
|
||||
import android.annotation.NonNull;
|
||||
import android.content.Context;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.os.UserHandle;
|
||||
import android.util.Log;
|
||||
|
||||
@@ -27,6 +28,8 @@ import com.android.settings.utils.AsyncLoader;
|
||||
import com.android.settingslib.applications.StorageStatsSource;
|
||||
import com.android.settingslib.applications.StorageStatsSource.AppStorageStats;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Fetches the storage stats using the StorageStatsManager for a given package and user tuple.
|
||||
*/
|
||||
@@ -49,7 +52,7 @@ public class FetchPackageStorageAsyncLoader extends AsyncLoader<AppStorageStats>
|
||||
AppStorageStats result = null;
|
||||
try {
|
||||
result = mSource.getStatsForPackage(mInfo.volumeUuid, mInfo.packageName, mUser);
|
||||
} catch (IllegalStateException e) {
|
||||
} catch (NameNotFoundException | IOException e) {
|
||||
Log.w(TAG, "Package may have been removed during query, failing gracefully", e);
|
||||
}
|
||||
return result;
|
||||
|
@@ -23,15 +23,20 @@ import android.os.UserHandle;
|
||||
import android.provider.DocumentsContract;
|
||||
import android.support.annotation.WorkerThread;
|
||||
import android.text.format.Formatter;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settingslib.applications.StorageStatsSource;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* MusicViewHolderController controls an Audio/Music file view in the ManageApplications view.
|
||||
*/
|
||||
public class MusicViewHolderController implements FileViewHolderController {
|
||||
private static final String TAG = "MusicViewHolderController";
|
||||
|
||||
private static final String AUTHORITY_MEDIA = "com.android.providers.media.documents";
|
||||
|
||||
private Context mContext;
|
||||
@@ -51,7 +56,12 @@ public class MusicViewHolderController implements FileViewHolderController {
|
||||
@Override
|
||||
@WorkerThread
|
||||
public void queryStats() {
|
||||
mMusicSize = mSource.getExternalStorageStats(mVolumeUuid, mUser).audioBytes;
|
||||
try {
|
||||
mMusicSize = mSource.getExternalStorageStats(mVolumeUuid, mUser).audioBytes;
|
||||
} catch (IOException e) {
|
||||
mMusicSize = 0;
|
||||
Log.w(TAG, e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -23,6 +23,7 @@ import static android.content.pm.ApplicationInfo.CATEGORY_VIDEO;
|
||||
import android.content.Context;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.UserInfo;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.os.UserHandle;
|
||||
import android.util.Log;
|
||||
import android.util.SparseArray;
|
||||
@@ -32,6 +33,7 @@ import com.android.settings.applications.UserManagerWrapper;
|
||||
import com.android.settings.utils.AsyncLoader;
|
||||
import com.android.settingslib.applications.StorageStatsSource;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -83,7 +85,7 @@ public class StorageAsyncLoader
|
||||
StorageStatsSource.AppStorageStats stats;
|
||||
try {
|
||||
stats = mStatsManager.getStatsForPackage(mUuid, app.packageName, myUser);
|
||||
} catch (IllegalStateException e) {
|
||||
} catch (NameNotFoundException | IOException e) {
|
||||
// This may happen if the package was removed during our calculation.
|
||||
Log.w("App unexpectedly not found", e);
|
||||
continue;
|
||||
@@ -122,7 +124,11 @@ public class StorageAsyncLoader
|
||||
}
|
||||
|
||||
Log.d(TAG, "Loading external stats");
|
||||
result.externalStats = mStatsManager.getExternalStorageStats(mUuid, UserHandle.of(userId));
|
||||
try {
|
||||
result.externalStats = mStatsManager.getExternalStorageStats(mUuid, UserHandle.of(userId));
|
||||
} catch (IOException e) {
|
||||
Log.w(TAG, e);
|
||||
}
|
||||
Log.d(TAG, "Obtaining result completed");
|
||||
return result;
|
||||
}
|
||||
|
Reference in New Issue
Block a user