Skip to content

Commit 92d5705

Browse files
author
Amith Yamasani
committed
Handle null cache directory
data/android directory doesn't exist sometimes, and hence cache directory creation fails. Don't crash the process due to that. Change-Id: I22d7ed5df9c70f021a87029e89a13a11b4b0303b
1 parent 2c1dfa2 commit 92d5705

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

core/java/android/app/ActivityThread.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4070,10 +4070,14 @@ private void handleBindApplication(AppBindData data) {
40704070
if (!Process.isIsolated()) {
40714071
final File cacheDir = appContext.getCacheDir();
40724072

4073-
// Provide a usable directory for temporary files
4074-
System.setProperty("java.io.tmpdir", cacheDir.getAbsolutePath());
4075-
4076-
setupGraphicsSupport(data.info, cacheDir);
4073+
if (cacheDir != null) {
4074+
// Provide a usable directory for temporary files
4075+
System.setProperty("java.io.tmpdir", cacheDir.getAbsolutePath());
4076+
4077+
setupGraphicsSupport(data.info, cacheDir);
4078+
} else {
4079+
Log.e(TAG, "Unable to setupGraphicsSupport due to missing cache directory");
4080+
}
40774081
}
40784082
/**
40794083
* For system applications on userdebug/eng builds, log stack

core/java/android/app/ContextImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,7 @@ public File getCacheDir() {
769769
}
770770
if (!mCacheDir.exists()) {
771771
if(!mCacheDir.mkdirs()) {
772-
Log.w(TAG, "Unable to create cache directory");
772+
Log.w(TAG, "Unable to create cache directory " + mCacheDir.getAbsolutePath());
773773
return null;
774774
}
775775
FileUtils.setPermissions(

0 commit comments

Comments
 (0)