diff options
| author | 2019-01-30 10:24:43 -0800 | |
|---|---|---|
| committer | 2019-01-30 10:24:43 -0800 | |
| commit | ce7aa1bf682c02c0ac1eff0f983192fb0f52f28b (patch) | |
| tree | 66514bcd38311019db5442eeb3ee930ba5aacef6 | |
| parent | 67069937773ae8bf6d6257a10a01a9e04226fad6 (diff) | |
| parent | 0b329918fc39fe80ba84eb22f659a30f966a21c3 (diff) | |
Merge "[layout precompilation] Add testing hook for precompiled layouts" am: 15b86c9037
am: 0b329918fc
Change-Id: I6417624f74b779e05f5a4a30c484487a943697c6
| -rw-r--r-- | api/test-current.txt | 4 | ||||
| -rw-r--r-- | core/java/android/view/LayoutInflater.java | 20 |
2 files changed, 22 insertions, 2 deletions
diff --git a/api/test-current.txt b/api/test-current.txt index af455fb4abb6..30c6fdf55cbe 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -1790,6 +1790,10 @@ package android.view { method public boolean isSystemGroup(); } + public abstract class LayoutInflater { + method public void setPrecompiledLayoutsEnabledForTesting(boolean); + } + public final class MotionEvent extends android.view.InputEvent implements android.os.Parcelable { method public void setActionButton(int); method public void setButtonState(int); diff --git a/core/java/android/view/LayoutInflater.java b/core/java/android/view/LayoutInflater.java index f2259b045c0a..2ee72bffc9ec 100644 --- a/core/java/android/view/LayoutInflater.java +++ b/core/java/android/view/LayoutInflater.java @@ -20,6 +20,7 @@ import android.annotation.LayoutRes; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.SystemService; +import android.annotation.TestApi; import android.annotation.UnsupportedAppUsage; import android.content.Context; import android.content.res.Resources; @@ -389,9 +390,13 @@ public abstract class LayoutInflater { } private void initPrecompiledViews() { + initPrecompiledViews( + SystemProperties.getBoolean(USE_PRECOMPILED_LAYOUT_SYSTEM_PROPERTY, false)); + } + + private void initPrecompiledViews(boolean enablePrecompiledViews) { + mUseCompiledView = enablePrecompiledViews; try { - mUseCompiledView = - SystemProperties.getBoolean(USE_PRECOMPILED_LAYOUT_SYSTEM_PROPERTY, false); if (mUseCompiledView) { mPrecompiledClassLoader = mContext.getClassLoader(); String dexFile = mContext.getCodeCacheDir() + COMPILED_VIEW_DEX_FILE_NAME; @@ -409,6 +414,17 @@ public abstract class LayoutInflater { } mUseCompiledView = false; } + if (!mUseCompiledView) { + mPrecompiledClassLoader = null; + } + } + + /** + * @hide for use by CTS tests + */ + @TestApi + public void setPrecompiledLayoutsEnabledForTesting(boolean enablePrecompiledLayouts) { + initPrecompiledViews(enablePrecompiledLayouts); } /** |