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

Commit 22103395 authored by jinwu's avatar jinwu
Browse files

Fix get null from getExternalCacheDir

Gallery can't work when this API getExternalCacheDir return null.
Use getCacheDir instead of getExternalCacheDir to avoid it.

Change-Id: I7d2731c5881be0b8f95760f16159afbe583a0dea
parent 933abdff
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -67,7 +67,7 @@ public abstract class AbstractGalleryActivity extends AbstractPermissionActivity
    private BroadcastReceiver mMountReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            if (getExternalCacheDir() != null) onStorageReady();
            if (getCacheDir() != null) onStorageReady();
        }
    };
    private IntentFilter mMountFilter = new IntentFilter(Intent.ACTION_MEDIA_MOUNTED);
@@ -156,7 +156,7 @@ public abstract class AbstractGalleryActivity extends AbstractPermissionActivity
    @Override
    protected void onStart() {
        super.onStart();
        if (getExternalCacheDir() == null) {
        if (getCacheDir() == null) {
            OnCancelListener onCancel = new OnCancelListener() {
                @Override
                public void onCancel(DialogInterface dialog) {
+1 −1
Original line number Diff line number Diff line
@@ -96,7 +96,7 @@ public class GalleryAppImpl extends Application implements GalleryApp {
    @Override
    public synchronized DownloadCache getDownloadCache() {
        if (mDownloadCache == null) {
            File cacheDir = new File(getExternalCacheDir(), DOWNLOAD_FOLDER);
            File cacheDir = new File(getCacheDir(), DOWNLOAD_FOLDER);

            if (!cacheDir.isDirectory()) cacheDir.mkdirs();

+1 −1
Original line number Diff line number Diff line
@@ -54,7 +54,7 @@ public class CacheStorageUsageInfo {
    }

    public void loadStorageInfo(JobContext jc) {
        File cacheDir = mContext.getExternalCacheDir();
        File cacheDir = mContext.getCacheDir();
        if (cacheDir == null) {
            cacheDir = mContext.getCacheDir();
        }
+2 −2
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ public class CacheManager {
            }
            BlobCache cache = sCacheMap.get(filename);
            if (cache == null) {
                File cacheDir = context.getExternalCacheDir();
                File cacheDir = context.getCacheDir();
                String path = cacheDir.getAbsolutePath() + "/" + filename;
                try {
                    cache = new BlobCache(path, maxEntries, maxBytes, false,
@@ -72,7 +72,7 @@ public class CacheManager {
        if (n != 0) return;
        pref.edit().putInt(KEY_CACHE_UP_TO_DATE, 1).commit();

        File cacheDir = context.getExternalCacheDir();
        File cacheDir = context.getCacheDir();
        String prefix = cacheDir.getAbsolutePath() + "/";

        BlobCache.deleteFiles(prefix + "imgcache");