summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/shared/src/com/android/systemui/shared/plugins/PluginInitializer.java10
-rw-r--r--packages/SystemUI/shared/src/com/android/systemui/shared/plugins/PluginManagerImpl.java28
-rw-r--r--packages/SystemUI/src/com/android/systemui/plugins/PluginInitializerImpl.java36
3 files changed, 43 insertions, 31 deletions
diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/plugins/PluginInitializer.java b/packages/SystemUI/shared/src/com/android/systemui/shared/plugins/PluginInitializer.java
index c6a086dcfbdc..c3815e4cee78 100644
--- a/packages/SystemUI/shared/src/com/android/systemui/shared/plugins/PluginInitializer.java
+++ b/packages/SystemUI/shared/src/com/android/systemui/shared/plugins/PluginInitializer.java
@@ -14,7 +14,6 @@
package com.android.systemui.shared.plugins;
-import android.annotation.Nullable;
import android.content.Context;
import android.os.Looper;
@@ -26,11 +25,16 @@ public interface PluginInitializer {
Looper getBgLooper();
/**
- * This Runnable is run on the bg looper during initialization of {@link PluginManagerImpl}.
+ * Called from the bg looper during initialization of {@link PluginManagerImpl}.
*/
- @Nullable Runnable getBgInitCallback();
+ void onPluginManagerInit();
String[] getWhitelistedPlugins(Context context);
PluginEnabler getPluginEnabler(Context context);
+
+ /**
+ * Called from {@link PluginManagerImpl#handleWtfs()}.
+ */
+ void handleWtfs();
}
diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/plugins/PluginManagerImpl.java b/packages/SystemUI/shared/src/com/android/systemui/shared/plugins/PluginManagerImpl.java
index a54e08eba23d..87f29342b167 100644
--- a/packages/SystemUI/shared/src/com/android/systemui/shared/plugins/PluginManagerImpl.java
+++ b/packages/SystemUI/shared/src/com/android/systemui/shared/plugins/PluginManagerImpl.java
@@ -74,11 +74,11 @@ public class PluginManagerImpl extends BroadcastReceiver implements PluginManage
private final boolean isDebuggable;
private final PluginPrefs mPluginPrefs;
private final PluginEnabler mPluginEnabler;
+ private final PluginInitializer mPluginInitializer;
private ClassLoaderFilter mParentClassLoader;
private boolean mListening;
private boolean mHasOneShot;
private Looper mLooper;
- private boolean mWtfsSet;
public PluginManagerImpl(Context context, PluginInitializer initializer) {
this(context, new PluginInstanceManagerFactory(), Build.IS_DEBUGGABLE,
@@ -87,7 +87,7 @@ public class PluginManagerImpl extends BroadcastReceiver implements PluginManage
@VisibleForTesting
PluginManagerImpl(Context context, PluginInstanceManagerFactory factory, boolean debuggable,
- UncaughtExceptionHandler defaultHandler, PluginInitializer initializer) {
+ UncaughtExceptionHandler defaultHandler, final PluginInitializer initializer) {
mContext = context;
mFactory = factory;
mLooper = initializer.getBgLooper();
@@ -95,15 +95,18 @@ public class PluginManagerImpl extends BroadcastReceiver implements PluginManage
mWhitelistedPlugins.addAll(Arrays.asList(initializer.getWhitelistedPlugins(mContext)));
mPluginPrefs = new PluginPrefs(mContext);
mPluginEnabler = initializer.getPluginEnabler(mContext);
+ mPluginInitializer = initializer;
PluginExceptionHandler uncaughtExceptionHandler = new PluginExceptionHandler(
defaultHandler);
Thread.setUncaughtExceptionPreHandler(uncaughtExceptionHandler);
- Runnable bgRunnable = initializer.getBgInitCallback();
- if (bgRunnable != null) {
- new Handler(mLooper).post(bgRunnable);
- }
+ new Handler(mLooper).post(new Runnable() {
+ @Override
+ public void run() {
+ initializer.onPluginManagerInit();
+ }
+ });
}
public String[] getWhitelistedPlugins() {
@@ -299,16 +302,7 @@ public class PluginManagerImpl extends BroadcastReceiver implements PluginManage
}
public void handleWtfs() {
- if (!mWtfsSet) {
- mWtfsSet = true;
- Log.setWtfHandler(new Log.TerribleFailureHandler() {
- @Override
- public void onTerribleFailure(String tag, Log.TerribleFailure what,
- boolean system) {
- throw new CrashWhilePluginActiveException(what);
- }
- });
- }
+ mPluginInitializer.handleWtfs();
}
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
@@ -391,7 +385,7 @@ public class PluginManagerImpl extends BroadcastReceiver implements PluginManage
}
}
- private class CrashWhilePluginActiveException extends RuntimeException {
+ public static class CrashWhilePluginActiveException extends RuntimeException {
public CrashWhilePluginActiveException(Throwable throwable) {
super(throwable);
}
diff --git a/packages/SystemUI/src/com/android/systemui/plugins/PluginInitializerImpl.java b/packages/SystemUI/src/com/android/systemui/plugins/PluginInitializerImpl.java
index ac0a226080bf..774567ef8bb1 100644
--- a/packages/SystemUI/src/com/android/systemui/plugins/PluginInitializerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/plugins/PluginInitializerImpl.java
@@ -16,29 +16,29 @@ package com.android.systemui.plugins;
import android.content.Context;
import android.os.Looper;
+import android.util.Log;
import com.android.systemui.Dependency;
+import com.android.systemui.R;
import com.android.systemui.shared.plugins.PluginEnabler;
import com.android.systemui.shared.plugins.PluginInitializer;
-import com.android.systemui.R;
+import com.android.systemui.shared.plugins.PluginManagerImpl;
public class PluginInitializerImpl implements PluginInitializer {
+
+ private boolean mWtfsSet;
+
@Override
public Looper getBgLooper() {
return Dependency.get(Dependency.BG_LOOPER);
}
@Override
- public Runnable getBgInitCallback() {
- return new Runnable() {
- @Override
- public void run() {
- // Plugin dependencies that don't have another good home can go here, but
- // dependencies that have better places to init can happen elsewhere.
- Dependency.get(PluginDependencyProvider.class)
- .allowPluginDependency(ActivityStarter.class);
- }
- };
+ public void onPluginManagerInit() {
+ // Plugin dependencies that don't have another good home can go here, but
+ // dependencies that have better places to init can happen elsewhere.
+ Dependency.get(PluginDependencyProvider.class)
+ .allowPluginDependency(ActivityStarter.class);
}
@Override
@@ -49,4 +49,18 @@ public class PluginInitializerImpl implements PluginInitializer {
public PluginEnabler getPluginEnabler(Context context) {
return new PluginEnablerImpl(context);
}
+
+ @Override
+ public void handleWtfs() {
+ if (!mWtfsSet) {
+ mWtfsSet = true;
+ Log.setWtfHandler(new Log.TerribleFailureHandler() {
+ @Override
+ public void onTerribleFailure(String tag, Log.TerribleFailure what,
+ boolean system) {
+ throw new PluginManagerImpl.CrashWhilePluginActiveException(what);
+ }
+ });
+ }
+ }
}