diff options
| author | 2019-02-01 16:55:48 -0500 | |
|---|---|---|
| committer | 2019-02-01 22:04:36 +0000 | |
| commit | 97b8ce1e1ffe587f87dad50d24951fbac4fcc3b7 (patch) | |
| tree | 41d7d4c9f18fe5c0fefb2cb5253c30fd39607a73 | |
| parent | 45289f0bef9ecb1c0d7b9fbaa37fd38f3f7b0c57 (diff) | |
OverlayPlugin listener method called from main thread
- onPluginDisconnected is being called from non-main thread
causing fatal exception when calling setForcePluginOpen()
- this is a temporary fix
Test: manual
Bug: 123532083
Change-Id: I585c53844244f3acc2f87bc752ad7b564fb7d36d
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/SystemUIApplication.java | 48 |
1 files changed, 31 insertions, 17 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java b/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java index 1d8a21d13fa2..12f40f385cb2 100644 --- a/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java +++ b/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java @@ -24,6 +24,8 @@ import android.content.Intent; import android.content.IntentFilter; import android.content.pm.ApplicationInfo; import android.content.res.Configuration; +import android.os.Handler; +import android.os.Looper; import android.os.Process; import android.os.SystemProperties; import android.os.Trace; @@ -200,34 +202,46 @@ public class SystemUIApplication extends Application implements SysUiServiceProv } Dependency.get(InitController.class).executePostInitTasks(); log.traceEnd(); + final Handler mainHandler = new Handler(Looper.getMainLooper()); Dependency.get(PluginManager.class).addPluginListener( new PluginListener<OverlayPlugin>() { private ArraySet<OverlayPlugin> mOverlays; @Override public void onPluginConnected(OverlayPlugin plugin, Context pluginContext) { - StatusBar statusBar = getComponent(StatusBar.class); - if (statusBar != null) { - plugin.setup(statusBar.getStatusBarWindow(), - statusBar.getNavigationBarView()); - } - // Lazy init. - if (mOverlays == null) mOverlays = new ArraySet<>(); - if (plugin.holdStatusBarOpen()) { - mOverlays.add(plugin); - Dependency.get(StatusBarWindowController.class).setStateListener(b -> - mOverlays.forEach(o -> o.setCollapseDesired(b))); - Dependency.get(StatusBarWindowController.class).setForcePluginOpen( - mOverlays.size() != 0); + mainHandler.post(new Runnable() { + @Override + public void run() { + StatusBar statusBar = getComponent(StatusBar.class); + if (statusBar != null) { + plugin.setup(statusBar.getStatusBarWindow(), + statusBar.getNavigationBarView()); + } + // Lazy init. + if (mOverlays == null) mOverlays = new ArraySet<>(); + if (plugin.holdStatusBarOpen()) { + mOverlays.add(plugin); + Dependency.get(StatusBarWindowController.class) + .setStateListener(b -> mOverlays.forEach( + o -> o.setCollapseDesired(b))); + Dependency.get(StatusBarWindowController.class) + .setForcePluginOpen(mOverlays.size() != 0); - } + } + } + }); } @Override public void onPluginDisconnected(OverlayPlugin plugin) { - mOverlays.remove(plugin); - Dependency.get(StatusBarWindowController.class).setForcePluginOpen( - mOverlays.size() != 0); + mainHandler.post(new Runnable() { + @Override + public void run() { + mOverlays.remove(plugin); + Dependency.get(StatusBarWindowController.class).setForcePluginOpen( + mOverlays.size() != 0); + } + }); } }, OverlayPlugin.class, true /* Allow multiple plugins */); |