From 2fde06bc0b1d4c24ac983c5f9019e54726164432 Mon Sep 17 00:00:00 2001 From: Pranav Vashi Date: Thu, 2 May 2024 00:38:12 +0530 Subject: [PATCH] StringBlock: Prevent SystemUI crash when inflating QS * Reported while switching between light/dark themes. Log: 05-01 21:03:37.375 2512 2512 E AndroidRuntime: FATAL EXCEPTION: main 05-01 21:03:37.375 2512 2512 E AndroidRuntime: Process: com.android.systemui, PID: 2512 05-01 21:03:37.375 2512 2512 E AndroidRuntime: android.view.InflateException: Binary XML file line #28 in com.android.systemui:layout/qs_tile_label_vertical: Binary XML file line #28 in com.android.systemui:layout/qs_tile_label_vertical: Error inflating class 05-01 21:03:37.375 2512 2512 E AndroidRuntime: Caused by: android.view.InflateException: Binary XML file line #28 in com.android.systemui:layout/qs_tile_label_vertical: Error inflating class 05-01 21:03:37.375 2512 2512 E AndroidRuntime: Caused by: java.lang.reflect.InvocationTargetException 05-01 21:03:37.375 2512 2512 E AndroidRuntime: at java.lang.reflect.Constructor.newInstance0(Native Method) 05-01 21:03:37.375 2512 2512 E AndroidRuntime: at java.lang.reflect.Constructor.newInstance(Constructor.java:343) 05-01 21:03:37.375 2512 2512 E AndroidRuntime: at android.view.LayoutInflater.createView(LayoutInflater.java:747) 05-01 21:03:37.375 2512 2512 E AndroidRuntime: at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:902) 05-01 21:03:37.375 2512 2512 E AndroidRuntime: at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:857) 05-01 21:03:37.375 2512 2512 E AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:1019) 05-01 21:03:37.375 2512 2512 E AndroidRuntime: at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:980) 05-01 21:03:37.375 2512 2512 E AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:570) 05-01 21:03:37.375 2512 2512 E AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:462) 05-01 21:03:37.375 2512 2512 E AndroidRuntime: at com.android.systemui.qs.tileimpl.QSTileViewImpl.createAndAddLabels(QSTileViewImpl.kt:397) 05-01 21:03:37.375 2512 2512 E AndroidRuntime: at com.android.systemui.qs.tileimpl.QSTileViewImpl.(QSTileViewImpl.kt:287) 05-01 21:03:37.375 2512 2512 E AndroidRuntime: at com.android.systemui.qs.QSPanelControllerBase.addTile(QSPanelControllerBase.java:302) 05-01 21:03:37.375 2512 2512 E AndroidRuntime: at com.android.systemui.qs.QSPanelControllerBase.setTiles(QSPanelControllerBase.java:280) 05-01 21:03:37.375 2512 2512 E AndroidRuntime: at com.android.systemui.qs.QSPanelControllerBase.setTiles(QSPanelControllerBase.java:249) 05-01 21:03:37.375 2512 2512 E AndroidRuntime: at com.android.systemui.qs.QSPanelControllerBase.onTuningChanged(QSPanelControllerBase.java:546) 05-01 21:03:37.375 2512 2512 E AndroidRuntime: at com.android.systemui.tuner.TunerServiceImpl.addTunable(TunerServiceImpl.java:348) 05-01 21:03:37.375 2512 2512 E AndroidRuntime: at com.android.systemui.tuner.TunerServiceImpl.addTunable(TunerServiceImpl.java:314) 05-01 21:03:37.375 2512 2512 E AndroidRuntime: at com.android.systemui.qs.QSPanelControllerBase.onViewAttached(QSPanelControllerBase.java:223) 05-01 21:03:37.375 2512 2512 E AndroidRuntime: at com.android.systemui.qs.QSPanelController.onViewAttached(QSPanelController.java:118) 05-01 21:03:37.375 2512 2512 E AndroidRuntime: at com.android.systemui.util.ViewController$1.onViewAttachedToWindow(ViewController.java:52) 05-01 21:03:37.375 2512 2512 E AndroidRuntime: at com.android.systemui.util.ViewController.init(ViewController.java:80) 05-01 21:03:37.375 2512 2512 E AndroidRuntime: at com.android.systemui.qs.QSImpl.onComponentCreated(QSImpl.java:231) 05-01 21:03:37.375 2512 2512 E AndroidRuntime: at com.android.systemui.qs.QSFragmentLegacy.onViewCreated(QSFragmentLegacy.java:78) 05-01 21:03:37.375 2512 2512 E AndroidRuntime: at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1313) 05-01 21:03:37.375 2512 2512 E AndroidRuntime: at android.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1581) 05-01 21:03:37.375 2512 2512 E AndroidRuntime: at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1642) 05-01 21:03:37.375 2512 2512 E AndroidRuntime: at android.app.FragmentManagerImpl.dispatchMoveToState(FragmentManager.java:3052) 05-01 21:03:37.375 2512 2512 E AndroidRuntime: at android.app.FragmentManagerImpl.dispatchStart(FragmentManager.java:3009) 05-01 21:03:37.375 2512 2512 E AndroidRuntime: at android.app.FragmentController.dispatchStart(FragmentController.java:196) 05-01 21:03:37.375 2512 2512 E AndroidRuntime: at com.android.systemui.fragments.FragmentHostManager.createFragmentHost(FragmentHostManager.java:115) 05-01 21:03:37.375 2512 2512 E AndroidRuntime: at com.android.systemui.fragments.FragmentHostManager.reloadFragments(FragmentHostManager.java:235) 05-01 21:03:37.375 2512 2512 E AndroidRuntime: at com.android.systemui.fragments.FragmentHostManager.onConfigurationChanged(FragmentHostManager.java:185) 05-01 21:03:37.375 2512 2512 E AndroidRuntime: at com.android.systemui.fragments.FragmentService$FragmentHostState.handleSendConfigurationChange(FragmentService.java:143) 05-01 21:03:37.375 2512 2512 E AndroidRuntime: at com.android.systemui.fragments.FragmentService$FragmentHostState.lambda$sendConfigurationChange$0(FragmentService.java:135) 05-01 21:03:37.375 2512 2512 E AndroidRuntime: at com.android.systemui.fragments.FragmentService$FragmentHostState.$r8$lambda$ILnRBQ67muZvoLLBWD-A7ymjzuo(FragmentService.java:0) 05-01 21:03:37.375 2512 2512 E AndroidRuntime: at com.android.systemui.fragments.FragmentService$FragmentHostState$$ExternalSyntheticLambda0.run(R8$$SyntheticClass:0) 05-01 21:03:37.375 2512 2512 E AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:959) 05-01 21:03:37.375 2512 2512 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:100) 05-01 21:03:37.375 2512 2512 E AndroidRuntime: at android.os.Looper.loopOnce(Looper.java:232) 05-01 21:03:37.375 2512 2512 E AndroidRuntime: at android.os.Looper.loop(Looper.java:317) 05-01 21:03:37.375 2512 2512 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:8498) 05-01 21:03:37.375 2512 2512 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method) 05-01 21:03:37.375 2512 2512 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552) 05-01 21:03:37.375 2512 2512 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:878) 05-01 21:03:37.375 2512 2512 E AndroidRuntime: Caused by: java.lang.ArrayIndexOutOfBoundsException: length=2; index=6 05-01 21:03:37.375 2512 2512 E AndroidRuntime: at android.content.res.StringBlock.getSequence(StringBlock.java:109) 05-01 21:03:37.375 2512 2512 E AndroidRuntime: at android.content.res.ApkAssets.getStringFromPool(ApkAssets.java:358) 05-01 21:03:37.375 2512 2512 E AndroidRuntime: at android.content.res.AssetManager.getPooledStringForCookie(AssetManager.java:878) 05-01 21:03:37.375 2512 2512 E AndroidRuntime: at android.content.res.TypedArray.loadStringValueAt(TypedArray.java:1402) 05-01 21:03:37.375 2512 2512 E AndroidRuntime: at android.content.res.TypedArray.getValueAt(TypedArray.java:1387) 05-01 21:03:37.375 2512 2512 E AndroidRuntime: at android.content.res.TypedArray.getFont(TypedArray.java:1044) 05-01 21:03:37.375 2512 2512 E AndroidRuntime: at android.widget.TextView.readTextAppearance(TextView.java:4319) 05-01 21:03:37.375 2512 2512 E AndroidRuntime: at android.widget.TextView.(TextView.java:1225) 05-01 21:03:37.375 2512 2512 E AndroidRuntime: at com.android.systemui.util.SafeMarqueeTextView.(SafeMarqueeTextView.kt:18) 05-01 21:03:37.375 2512 2512 E AndroidRuntime: at com.android.systemui.util.DelayableMarqueeTextView.(DelayableMarqueeTextView.kt:28) 05-01 21:03:37.375 2512 2512 E AndroidRuntime: at com.android.systemui.util.DelayableMarqueeTextView.(DelayableMarqueeTextView.kt:23) 05-01 21:03:37.375 2512 2512 E AndroidRuntime: at com.android.systemui.util.DelayableMarqueeTextView.(DelayableMarqueeTextView.kt:0) 05-01 21:03:37.375 2512 2512 E AndroidRuntime: ... 44 more Signed-off-by: Pranav Vashi Signed-off-by: Jis G Jacob --- core/java/android/content/res/StringBlock.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/java/android/content/res/StringBlock.java b/core/java/android/content/res/StringBlock.java index 0070a6f920db4..5e84521714ee1 100644 --- a/core/java/android/content/res/StringBlock.java +++ b/core/java/android/content/res/StringBlock.java @@ -105,7 +105,7 @@ public CharSequence get(int idx) { @Nullable public CharSequence getSequence(int idx) { synchronized (this) { - if (mStrings != null) { + if (mStrings != null && idx < mStrings.length) { CharSequence res = mStrings[idx]; if (res != null) { return res;