Initialize GlobalActionsPanelPlugin before GlobalActions is launched
Previously, we were loading the GlobalActionsPanelPlugin in the constructor for GlobalActionsDialog, which is instantiated on demand the first time that Global Actions is launched. Because the plugin is loaded in the background, a race condition exists where the GlobalActions Dialog is displayed before the plugin has finished loading, and so the Plugin will not appear, despite being enabled. In this change, the GlobalActionsPanelPlugin is loaded in GlobalActionsImpl, which is scoped to the SystemUI Applcation lifetime (it will always be available). Therefore, the plugin will start loading as soon as it is enabled by the user. The race condition still exists, but is greatly mitigated and should not pose a significant issue. Test: manual Change-Id: I624f7b0b9133e044fa486ad6a74944aba0511a70
This commit is contained in:
@@ -92,8 +92,6 @@ import com.android.systemui.plugins.GlobalActions.GlobalActionsManager;
|
||||
import com.android.systemui.plugins.GlobalActionsPanelPlugin;
|
||||
import com.android.systemui.statusbar.phone.ScrimController;
|
||||
import com.android.systemui.statusbar.policy.ConfigurationController;
|
||||
import com.android.systemui.statusbar.policy.ExtensionController;
|
||||
import com.android.systemui.statusbar.policy.ExtensionController.Extension;
|
||||
import com.android.systemui.util.EmergencyDialerConstants;
|
||||
import com.android.systemui.util.leak.RotationUtils;
|
||||
import com.android.systemui.volume.SystemUIInterpolators.LogAccelerateInterpolator;
|
||||
@@ -161,9 +159,8 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
|
||||
private final EmergencyAffordanceManager mEmergencyAffordanceManager;
|
||||
private final ScreenshotHelper mScreenshotHelper;
|
||||
private final ScreenRecordHelper mScreenRecordHelper;
|
||||
|
||||
private final Extension<GlobalActionsPanelPlugin> mPanelExtension;
|
||||
private ActivityStarter mActivityStarter;
|
||||
private final ActivityStarter mActivityStarter;
|
||||
private GlobalActionsPanelPlugin mPanelPlugin;
|
||||
|
||||
/**
|
||||
* @param context everything needs a context :(
|
||||
@@ -209,10 +206,6 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
|
||||
|
||||
Dependency.get(ConfigurationController.class).addCallback(this);
|
||||
|
||||
mPanelExtension = Dependency.get(ExtensionController.class)
|
||||
.newExtension(GlobalActionsPanelPlugin.class)
|
||||
.withPlugin(GlobalActionsPanelPlugin.class)
|
||||
.build();
|
||||
mActivityStarter = Dependency.get(ActivityStarter.class);
|
||||
}
|
||||
|
||||
@@ -221,9 +214,11 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
|
||||
*
|
||||
* @param keyguardShowing True if keyguard is showing
|
||||
*/
|
||||
public void showDialog(boolean keyguardShowing, boolean isDeviceProvisioned) {
|
||||
public void showDialog(boolean keyguardShowing, boolean isDeviceProvisioned,
|
||||
GlobalActionsPanelPlugin panelPlugin) {
|
||||
mKeyguardShowing = keyguardShowing;
|
||||
mDeviceProvisioned = isDeviceProvisioned;
|
||||
mPanelPlugin = panelPlugin;
|
||||
if (mDialog != null) {
|
||||
mDialog.dismiss();
|
||||
mDialog = null;
|
||||
@@ -400,8 +395,8 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
|
||||
mAdapter = new MyAdapter();
|
||||
|
||||
GlobalActionsPanelPlugin.PanelViewController panelViewController =
|
||||
mPanelExtension.get() != null
|
||||
? mPanelExtension.get().onPanelShown(
|
||||
mPanelPlugin != null
|
||||
? mPanelPlugin.onPanelShown(
|
||||
new GlobalActionsPanelPlugin.Callbacks() {
|
||||
@Override
|
||||
public void dismissGlobalActionsMenu() {
|
||||
|
||||
@@ -37,8 +37,10 @@ import com.android.systemui.Dependency;
|
||||
import com.android.systemui.SysUiServiceProvider;
|
||||
import com.android.systemui.colorextraction.SysuiColorExtractor;
|
||||
import com.android.systemui.plugins.GlobalActions;
|
||||
import com.android.systemui.plugins.GlobalActionsPanelPlugin;
|
||||
import com.android.systemui.statusbar.CommandQueue;
|
||||
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
|
||||
import com.android.systemui.statusbar.policy.ExtensionController;
|
||||
import com.android.systemui.statusbar.policy.KeyguardMonitor;
|
||||
|
||||
public class GlobalActionsImpl implements GlobalActions, CommandQueue.Callbacks {
|
||||
@@ -48,6 +50,7 @@ public class GlobalActionsImpl implements GlobalActions, CommandQueue.Callbacks
|
||||
private final Context mContext;
|
||||
private final KeyguardMonitor mKeyguardMonitor;
|
||||
private final DeviceProvisionedController mDeviceProvisionedController;
|
||||
private final ExtensionController.Extension<GlobalActionsPanelPlugin> mPanelExtension;
|
||||
private GlobalActionsDialog mGlobalActions;
|
||||
private boolean mDisabled;
|
||||
|
||||
@@ -56,6 +59,10 @@ public class GlobalActionsImpl implements GlobalActions, CommandQueue.Callbacks
|
||||
mKeyguardMonitor = Dependency.get(KeyguardMonitor.class);
|
||||
mDeviceProvisionedController = Dependency.get(DeviceProvisionedController.class);
|
||||
SysUiServiceProvider.getComponent(context, CommandQueue.class).addCallback(this);
|
||||
mPanelExtension = Dependency.get(ExtensionController.class)
|
||||
.newExtension(GlobalActionsPanelPlugin.class)
|
||||
.withPlugin(GlobalActionsPanelPlugin.class)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -74,7 +81,8 @@ public class GlobalActionsImpl implements GlobalActions, CommandQueue.Callbacks
|
||||
mGlobalActions = new GlobalActionsDialog(mContext, manager);
|
||||
}
|
||||
mGlobalActions.showDialog(mKeyguardMonitor.isShowing(),
|
||||
mDeviceProvisionedController.isDeviceProvisioned());
|
||||
mDeviceProvisionedController.isDeviceProvisioned(),
|
||||
mPanelExtension.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user