private static final boolean DEBUG = false;
private final Context mContext;
- private final LegacyGlobalActions mLegacyGlobalActions;
private final StatusBarManagerInternal mStatusBarInternal;
private final Handler mHandler;
+ private final WindowManagerFuncs mWindowManagerFuncs;
+ private LegacyGlobalActions mLegacyGlobalActions;
private boolean mKeyguardShowing;
private boolean mDeviceProvisioned;
private boolean mStatusBarConnected;
public GlobalActions(Context context, WindowManagerFuncs windowManagerFuncs) {
mContext = context;
mHandler = new Handler();
- mLegacyGlobalActions = new LegacyGlobalActions(context, windowManagerFuncs,
- this::onGlobalActionsDismissed);
+ mWindowManagerFuncs = windowManagerFuncs;
mStatusBarInternal = LocalServices.getService(StatusBarManagerInternal.class);
// Some form factors do not have a status bar.
}
}
+ private void ensureLegacyCreated() {
+ if (mLegacyGlobalActions != null) return;
+ mLegacyGlobalActions = new LegacyGlobalActions(mContext, mWindowManagerFuncs,
+ this::onGlobalActionsDismissed);
+ }
+
public void showDialog(boolean keyguardShowing, boolean deviceProvisioned) {
if (DEBUG) Slog.d(TAG, "showDialog " + keyguardShowing + " " + deviceProvisioned);
mKeyguardShowing = keyguardShowing;
mHandler.postDelayed(mShowTimeout, 5000);
} else {
// SysUI isn't alive, show legacy menu.
+ ensureLegacyCreated();
mLegacyGlobalActions.showDialog(mKeyguardShowing, mDeviceProvisioned);
}
}
mStatusBarConnected = connected;
if (mShowing && !mStatusBarConnected) {
// Status bar died but we need to be showing global actions still, show the legacy.
+ ensureLegacyCreated();
mLegacyGlobalActions.showDialog(mKeyguardShowing, mDeviceProvisioned);
}
}
public void run() {
if (DEBUG) Slog.d(TAG, "Global actions timeout");
// We haven't heard from sysui, show the legacy dialog.
+ ensureLegacyCreated();
mLegacyGlobalActions.showDialog(mKeyguardShowing, mDeviceProvisioned);
}
};