Skip to content

Commit

Permalink
Fix mobile-install v1 on Pie devices
Browse files Browse the repository at this point in the history
Ref: #6814

RELNOTES: Fixed a mobile-install v1 bug when deploying to Android 9 Pie devices. #6814
PiperOrigin-RevId: 224566583
  • Loading branch information
jin authored and Copybara-Service committed Dec 7, 2018
1 parent 821efbd commit c01cf1b
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,15 @@ private void monkeyPatchExistingResources() {
throw new IllegalStateException("Could not create new AssetManager");
}

// Kitkat needs this method call, Lollipop doesn't. However, it doesn't seem to cause any harm
// in L, so we do it unconditionally.
Method mEnsureStringBlocks = AssetManager.class.getDeclaredMethod("ensureStringBlocks");
mEnsureStringBlocks.setAccessible(true);
mEnsureStringBlocks.invoke(newAssetManager);
if (android.os.Build.VERSION.SDK_INT <= android.os.Build.VERSION_CODES.KITKAT) {
// Kitkat needs this method call, Lollipop doesn't.
//
// This method call was removed from Pie:
// https://android.googlesource.com/platform/frameworks/base/+/bebfcc46a249a70af04bc18490a897888a142fb8%5E%21/#F7
Method mEnsureStringBlocks = AssetManager.class.getDeclaredMethod("ensureStringBlocks");
mEnsureStringBlocks.setAccessible(true);
mEnsureStringBlocks.invoke(newAssetManager);
}

// Find the singleton instance of ResourcesManager
Class<?> clazz = Class.forName("android.app.ResourcesManager");
Expand Down

0 comments on commit c01cf1b

Please sign in to comment.