Use codegen to catch LinkageErrors from plugins
Plugins that were built against old apis have the potential to crash
SystemUI when unsupported calls are made into them, or they make calls
to methods that no longer exist. These cases cause a LinkageError to be
thrown at the callsite. Incrememting the plugin interface version can
mitigate some of these issues, but is an incomplete solution and
requires manually maintence.
This cl attempts to solve this problem by using codegen to write a proxy
implementation of the interface. This proxy catches those errors, logs
them, and provides a recovery path where the plugin can be disabled but
the application can continue. Recovery will not be possible at every
callsite, but this will at least provide standardized wtf logging for
all locations and a straightforward mechanism for correcting issues
when they occur.
I've also changed VersionCheckerImpl to log a wtf and disable the plugin
in the event that versions don't match. This is so that SystemUI can
continue as normal in the event that plugin interface has changed.
Bug: 359432141
Test: Manually checked mismatched clock apk
Flag: NONE Not user-facing, adding catch blocks
Change-Id: Iee7e1dd0faba5c0c4b9fe71f3678d077a2a8b939
diff --git a/packages/SystemUI/plugin/Android.bp b/packages/SystemUI/plugin/Android.bp
index 682a68f..a26cf12 100644
--- a/packages/SystemUI/plugin/Android.bp
+++ b/packages/SystemUI/plugin/Android.bp
@@ -23,9 +23,7 @@
}
java_library {
-
name: "SystemUIPluginLib",
-
srcs: [
"bcsmartspace/src/**/*.java",
"bcsmartspace/src/**/*.kt",
@@ -40,6 +38,8 @@
export_proguard_flags_files: true,
},
+ plugins: ["PluginAnnotationProcessor"],
+
// If you add a static lib here, you may need to also add the package to the ClassLoaderFilter
// in PluginInstance. That will ensure that loaded plugins have access to the related classes.
// You should also add it to proguard_common.flags so that proguard does not remove the portions
@@ -53,7 +53,6 @@
"SystemUILogLib",
"androidx.annotation_annotation",
],
-
}
android_app {