diff options
author | 2024-02-06 18:37:29 +0000 | |
---|---|---|
committer | 2024-02-06 18:42:32 +0000 | |
commit | 75f5cbea9fd8672ab7a37dabedaedf53f7804cdd (patch) | |
tree | 062cfe6e0029e6dfa2505b57c1cc931dbab7202e | |
parent | 7593029ac6c19a77b6ce54fcf9dfcb9ad5a9a25c (diff) |
Turn ContentProvider injection failures into errors.
Prior to this change, we simply logged this as a warning. This would
hide errors, in particular `InvocationTargetException` which itself
wraps any errors that happened during the call to `#inject`.
For the bug in question, ZenMode is actually failing to initialize,
which is causing the injection of the KeyguardSliceProvider to fail.
This change does not fix ZenMode, but will resurface the stack trace
appropriately.
Moreover, any process that is failing to initialize its
ContentProvider is already having a bad time, so if it didn't fail
here, it was going to fail somewhere else. That is what we see on the
bug.
Flag: NA
Bug: 323327880
Test: manually built and run
Change-Id: Ic2189b6c142eb0a7ec23ca49924a551626b8c326
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/SystemUIAppComponentFactoryBase.kt | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/SystemUIAppComponentFactoryBase.kt b/packages/SystemUI/src/com/android/systemui/SystemUIAppComponentFactoryBase.kt index e88aaf015f87..aab0b1e99e09 100644 --- a/packages/SystemUI/src/com/android/systemui/SystemUIAppComponentFactoryBase.kt +++ b/packages/SystemUI/src/com/android/systemui/SystemUIAppComponentFactoryBase.kt @@ -22,7 +22,6 @@ import android.content.BroadcastReceiver import android.content.ContentProvider import android.content.Context import android.content.Intent -import android.util.Log import androidx.core.app.AppComponentFactory import com.android.systemui.dagger.ContextComponentHelper import com.android.systemui.dagger.SysUIComponent @@ -91,7 +90,8 @@ abstract class SystemUIAppComponentFactoryBase : AppComponentFactory() { return app } - @UsesReflection(KeepTarget(instanceOfClassConstant = SysUIComponent::class, methodName = "inject")) + @UsesReflection( + KeepTarget(instanceOfClassConstant = SysUIComponent::class, methodName = "inject")) override fun instantiateProviderCompat(cl: ClassLoader, className: String): ContentProvider { val contentProvider = super.instantiateProviderCompat(cl, className) if (contentProvider is ContextInitializer) { @@ -103,11 +103,12 @@ abstract class SystemUIAppComponentFactoryBase : AppComponentFactory() { .getMethod("inject", contentProvider.javaClass) injectMethod.invoke(rootComponent, contentProvider) } catch (e: NoSuchMethodException) { - Log.w(TAG, "No injector for class: " + contentProvider.javaClass, e) + throw RuntimeException("No injector for class: " + contentProvider.javaClass, e) } catch (e: IllegalAccessException) { - Log.w(TAG, "No injector for class: " + contentProvider.javaClass, e) + throw RuntimeException("Injector inaccessible for class: " + + contentProvider.javaClass, e) } catch (e: InvocationTargetException) { - Log.w(TAG, "No injector for class: " + contentProvider.javaClass, e) + throw RuntimeException("Error while injecting: " + contentProvider.javaClass, e) } initializer } |