Fix crash when launching Activities in 'android' package

The LoadedApk for the 'android' package doesn't have a resource
directory set. This is fine since the AssetManager loads the
'android' package's resources by default.

This is a regression caused by https://googleplex-android-review.googlesource.com/#/c/525840/

Bug:17104110
Change-Id: I8a2158a75b4ff0e941837c11a2cb77a7aad09270
This commit is contained in:
Adam Lesinski
2014-08-20 10:49:13 -07:00
parent e2527bc206
commit 54130de7d2
2 changed files with 13 additions and 4 deletions

View File

@@ -178,8 +178,13 @@ public class ResourcesManager {
//}
AssetManager assets = new AssetManager();
if (assets.addAssetPath(resDir) == 0) {
return null;
// resDir can be null if the 'android' package is creating a new Resources object.
// This is fine, since each AssetManager automatically loads the 'android' package
// already.
if (resDir != null) {
if (assets.addAssetPath(resDir) == 0) {
return null;
}
}
if (splitResDirs != null) {

View File

@@ -62,8 +62,12 @@ public final class ResourcesKey {
return false;
}
ResourcesKey peer = (ResourcesKey) obj;
if (!mResDir.equals(peer.mResDir)) {
return false;
if (mResDir != peer.mResDir) {
if (mResDir == null || peer.mResDir == null) {
return false;
} else if (!mResDir.equals(peer.mResDir)) {
return false;
}
}
if (mDisplayId != peer.mDisplayId) {
return false;