import com.android.internal.widget.PointerLocationView;
import com.android.server.GestureLauncherService;
import com.android.server.LocalServices;
+import com.android.server.SystemServiceManager;
import com.android.server.policy.keyguard.KeyguardServiceDelegate;
import com.android.server.policy.keyguard.KeyguardServiceDelegate.DrawnListener;
import com.android.server.policy.keyguard.KeyguardStateMonitor.StateCallback;
boolean mBootMessageNeedsHiding;
KeyguardServiceDelegate mKeyguardDelegate;
+ private boolean mKeyguardBound;
final Runnable mWindowManagerDrawCallback = new Runnable() {
@Override
public void run() {
boolean mSystemReady;
boolean mSystemBooted;
- private boolean mDeferBindKeyguard;
boolean mHdmiPlugged;
HdmiControl mHdmiControl;
IUiModeManager mUiModeManager;
handleStartTransitionForKeyguardLw(transit, null /* transit */);
}
});
+ mKeyguardDelegate = new KeyguardServiceDelegate(mContext,
+ new StateCallback() {
+ @Override
+ public void onTrustedChanged() {
+ mWindowManagerFuncs.notifyKeyguardTrustedChanged();
+ }
+ });
}
/**
reportScreenStateToVrManager(false);
}
+ private long getKeyguardDrawnTimeout() {
+ final boolean bootCompleted =
+ LocalServices.getService(SystemServiceManager.class).isBootCompleted();
+ // Set longer timeout if it has not booted yet to prevent showing empty window.
+ return bootCompleted ? 1000 : 5000;
+ }
+
// Called on the DisplayManager's DisplayPowerController thread.
@Override
public void screenTurningOn(final ScreenOnListener screenOnListener) {
if (mKeyguardDelegate != null) {
mHandler.removeMessages(MSG_KEYGUARD_DRAWN_TIMEOUT);
- mHandler.sendEmptyMessageDelayed(MSG_KEYGUARD_DRAWN_TIMEOUT, 1000);
+ mHandler.sendEmptyMessageDelayed(MSG_KEYGUARD_DRAWN_TIMEOUT,
+ getKeyguardDrawnTimeout());
mKeyguardDelegate.onScreenTurningOn(mKeyguardDrawnCallback);
} else {
if (DEBUG_WAKEUP) Slog.d(TAG,
return out;
}
+ private void bindKeyguard() {
+ synchronized (mLock) {
+ if (mKeyguardBound) {
+ return;
+ }
+ mKeyguardBound = true;
+ }
+ mKeyguardDelegate.bindService(mContext);
+ }
+
+ @Override
+ public void onSystemUiStarted() {
+ bindKeyguard();
+ }
+
/** {@inheritDoc} */
@Override
public void systemReady() {
- mKeyguardDelegate = new KeyguardServiceDelegate(mContext,
- new StateCallback() {
- @Override
- public void onTrustedChanged() {
- mWindowManagerFuncs.notifyKeyguardTrustedChanged();
- }
- });
+ // In normal flow, systemReady is called before other system services are ready.
+ // So it is better not to bind keyguard here.
mKeyguardDelegate.onSystemReady();
mVrManagerInternal = LocalServices.getService(VrManagerInternal.class);
readCameraLensCoverState();
updateUiMode();
- boolean bindKeyguardNow;
synchronized (mLock) {
updateOrientationListenerLp();
mSystemReady = true;
updateSettings();
}
});
-
- bindKeyguardNow = mDeferBindKeyguard;
- if (bindKeyguardNow) {
- // systemBooted ran but wasn't able to bind to the Keyguard, we'll do it now.
- mDeferBindKeyguard = false;
+ // If this happens, for whatever reason, systemReady came later than systemBooted.
+ // And keyguard should be already bound from systemBooted
+ if (mSystemBooted) {
+ mKeyguardDelegate.onBootCompleted();
}
}
- if (bindKeyguardNow) {
- mKeyguardDelegate.bindService(mContext);
- mKeyguardDelegate.onBootCompleted();
- }
mSystemGestures.systemReady();
mImmersiveModeConfirmation.systemReady();
}
/** {@inheritDoc} */
@Override
public void systemBooted() {
- boolean bindKeyguardNow = false;
- synchronized (mLock) {
- // Time to bind Keyguard; take care to only bind it once, either here if ready or
- // in systemReady if not.
- if (mKeyguardDelegate != null) {
- bindKeyguardNow = true;
- } else {
- // Because mKeyguardDelegate is null, we know that the synchronized block in
- // systemReady didn't run yet and setting this will actually have an effect.
- mDeferBindKeyguard = true;
- }
- }
- if (bindKeyguardNow) {
- mKeyguardDelegate.bindService(mContext);
- mKeyguardDelegate.onBootCompleted();
- }
+ bindKeyguard();
synchronized (mLock) {
mSystemBooted = true;
+ if (mSystemReady) {
+ mKeyguardDelegate.onBootCompleted();
+ }
}
startedWakingUp();
screenTurningOn(null);
screenTurnedOn();
}
+ @Override
+ public boolean canDismissBootAnimation() {
+ synchronized (mLock) {
+ return mKeyguardDrawComplete;
+ }
+ }
+
ProgressDialog mBootMsgDialog = null;
/** {@inheritDoc} */
performEnableScreen();
}
+ /**
+ * Called when System UI has been started.
+ */
+ public void onSystemUiStarted() {
+ mPolicy.onSystemUiStarted();
+ }
+
private void performEnableScreen() {
synchronized(mWindowMap) {
if (DEBUG_BOOT) Slog.i(TAG_WM, "performEnableScreen: mDisplayEnabled=" + mDisplayEnabled
return;
}
+ if (!mShowingBootMessages && !mPolicy.canDismissBootAnimation()) {
+ return;
+ }
+
// Don't enable the screen until all existing windows have been drawn.
if (!mForceDisplayEnabled
// TODO(multidisplay): Expand to all displays?
try {
IBinder surfaceFlinger = ServiceManager.getService("SurfaceFlinger");
if (surfaceFlinger != null) {
- //Slog.i(TAG_WM, "******* TELLING SURFACE FLINGER WE ARE BOOTED!");
+ Slog.i(TAG_WM, "******* TELLING SURFACE FLINGER WE ARE BOOTED!");
Parcel data = Parcel.obtain();
data.writeInterfaceToken("android.ui.ISurfaceComposer");
surfaceFlinger.transact(IBinder.FIRST_CALL_TRANSACTION, // BOOT_FINISHED
final MediaRouterService mediaRouterF = mediaRouter;
final MmsServiceBroker mmsServiceF = mmsService;
final IpSecService ipSecServiceF = ipSecService;
+ final WindowManagerService windowManagerF = wm;
// We now tell the activity manager it is okay to run third party
// code. It will call back into us once it has gotten to the state
traceBeginAndSlog("StartSystemUI");
try {
- startSystemUi(context);
+ startSystemUi(context, windowManagerF);
} catch (Throwable e) {
reportWtf("starting System UI", e);
}
}, BOOT_TIMINGS_TRACE_LOG);
}
- static final void startSystemUi(Context context) {
+ static final void startSystemUi(Context context, WindowManagerService windowManager) {
Intent intent = new Intent();
intent.setComponent(new ComponentName("com.android.systemui",
"com.android.systemui.SystemUIService"));
intent.addFlags(Intent.FLAG_DEBUG_TRIAGED_MISSING);
//Slog.d(TAG, "Starting service: " + intent);
context.startServiceAsUser(intent, UserHandle.SYSTEM);
+ windowManager.onSystemUiStarted();
}
private static void traceBeginAndSlog(String name) {