summaryrefslogtreecommitdiffstats
path: root/policy/src/com/android/internal
diff options
context:
space:
mode:
Diffstat (limited to 'policy/src/com/android/internal')
-rw-r--r--policy/src/com/android/internal/policy/impl/KeyguardViewManager.java28
-rw-r--r--policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java57
-rw-r--r--policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java122
-rw-r--r--policy/src/com/android/internal/policy/impl/PatternUnlockScreen.java6
-rw-r--r--policy/src/com/android/internal/policy/impl/PhoneWindow.java12
-rwxr-xr-xpolicy/src/com/android/internal/policy/impl/PhoneWindowManager.java85
6 files changed, 190 insertions, 120 deletions
diff --git a/policy/src/com/android/internal/policy/impl/KeyguardViewManager.java b/policy/src/com/android/internal/policy/impl/KeyguardViewManager.java
index cbf1c90..91f1527 100644
--- a/policy/src/com/android/internal/policy/impl/KeyguardViewManager.java
+++ b/policy/src/com/android/internal/policy/impl/KeyguardViewManager.java
@@ -24,6 +24,7 @@ import android.content.pm.ActivityInfo;
import android.content.res.Resources;
import android.graphics.PixelFormat;
import android.graphics.Canvas;
+import android.os.IBinder;
import android.os.SystemProperties;
import android.util.Log;
import android.view.View;
@@ -59,6 +60,10 @@ public class KeyguardViewManager implements KeyguardWindowController {
private boolean mScreenOn = false;
+ public interface ShowListener {
+ void onShown(IBinder windowToken);
+ };
+
/**
* @param context Used to create views.
* @param viewManager Keyguard will be attached to this.
@@ -206,7 +211,8 @@ public class KeyguardViewManager implements KeyguardWindowController {
}
}
- public synchronized void onScreenTurnedOn() {
+ public synchronized void onScreenTurnedOn(
+ final KeyguardViewManager.ShowListener showListener) {
if (DEBUG) Log.d(TAG, "onScreenTurnedOn()");
mScreenOn = true;
if (mKeyguardView != null) {
@@ -214,6 +220,26 @@ public class KeyguardViewManager implements KeyguardWindowController {
// When screen is turned on, need to bind to FaceLock service if we are using FaceLock
mKeyguardView.bindToFaceLock();
+
+ // Caller should wait for this window to be shown before turning
+ // on the screen.
+ if (mKeyguardHost.getVisibility() == View.VISIBLE) {
+ // Keyguard may be in the process of being shown, but not yet
+ // updated with the window manager... give it a chance to do so.
+ mKeyguardHost.post(new Runnable() {
+ @Override public void run() {
+ if (mKeyguardHost.getVisibility() == View.VISIBLE) {
+ showListener.onShown(mKeyguardHost.getWindowToken());
+ } else {
+ showListener.onShown(null);
+ }
+ }
+ });
+ } else {
+ showListener.onShown(null);
+ }
+ } else {
+ showListener.onShown(null);
}
}
diff --git a/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java b/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java
index 64a9677..0f1d633 100644
--- a/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java
+++ b/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java
@@ -116,7 +116,6 @@ public class KeyguardViewMediator implements KeyguardViewCallback,
private static final int KEYGUARD_DONE_AUTHENTICATING = 11;
private static final int SET_HIDDEN = 12;
private static final int KEYGUARD_TIMEOUT = 13;
- private static final int REPORT_SHOW_DONE = 14;
/**
* The default amount of time we stay awake (used for all key input)
@@ -239,8 +238,6 @@ public class KeyguardViewMediator implements KeyguardViewCallback,
private boolean mScreenOn = false;
- private boolean mShowPending = false;
-
// last known state of the cellular connection
private String mPhoneState = TelephonyManager.EXTRA_STATE_IDLE;
@@ -383,19 +380,7 @@ public class KeyguardViewMediator implements KeyguardViewCallback,
} else if (why == WindowManagerPolicy.OFF_BECAUSE_OF_PROX_SENSOR) {
// Do not enable the keyguard if the prox sensor forced the screen off.
} else {
- if (!doKeyguardLocked() && why == WindowManagerPolicy.OFF_BECAUSE_OF_USER) {
- // The user has explicitly turned off the screen, causing it
- // to lock. We want to block here until the keyguard window
- // has shown, so the power manager won't complete the screen
- // off flow until that point, so we know it won't turn *on*
- // the screen until this is done.
- while (mShowPending) {
- try {
- wait();
- } catch (InterruptedException e) {
- }
- }
- }
+ doKeyguardLocked();
}
}
}
@@ -403,12 +388,12 @@ public class KeyguardViewMediator implements KeyguardViewCallback,
/**
* Let's us know the screen was turned on.
*/
- public void onScreenTurnedOn() {
+ public void onScreenTurnedOn(KeyguardViewManager.ShowListener showListener) {
synchronized (this) {
mScreenOn = true;
mDelayedShowingSequence++;
if (DEBUG) Log.d(TAG, "onScreenTurnedOn, seq = " + mDelayedShowingSequence);
- notifyScreenOnLocked();
+ notifyScreenOnLocked(showListener);
}
}
@@ -573,7 +558,7 @@ public class KeyguardViewMediator implements KeyguardViewCallback,
* work that will happen is done; returns false if the caller can wait for
* the keyguard to be shown.
*/
- private boolean doKeyguardLocked() {
+ private void doKeyguardLocked() {
// if another app is disabling us, don't show
if (!mExternallyEnabled) {
if (DEBUG) Log.d(TAG, "doKeyguard: not showing because externally disabled");
@@ -587,13 +572,13 @@ public class KeyguardViewMediator implements KeyguardViewCallback,
// ends (see the broadcast receiver below)
// TODO: clean this up when we have better support at the window manager level
// for apps that wish to be on top of the keyguard
- return true;
+ return;
}
// if the keyguard is already showing, don't bother
if (mKeyguardViewManager.isShowing()) {
if (DEBUG) Log.d(TAG, "doKeyguard: not showing because it is already showing");
- return true;
+ return;
}
// if the setup wizard hasn't run yet, don't show
@@ -609,18 +594,16 @@ public class KeyguardViewMediator implements KeyguardViewCallback,
if (!lockedOrMissing && !provisioned) {
if (DEBUG) Log.d(TAG, "doKeyguard: not showing because device isn't provisioned"
+ " and the sim is not locked or missing");
- return true;
+ return;
}
if (mLockPatternUtils.isLockScreenDisabled()) {
if (DEBUG) Log.d(TAG, "doKeyguard: not showing because lockscreen is off");
- return true;
+ return;
}
if (DEBUG) Log.d(TAG, "doKeyguard: showing the lock screen");
- mShowPending = true;
showLocked();
- return false;
}
/**
@@ -658,9 +641,10 @@ public class KeyguardViewMediator implements KeyguardViewCallback,
* @see #onScreenTurnedOn()
* @see #handleNotifyScreenOn
*/
- private void notifyScreenOnLocked() {
+ private void notifyScreenOnLocked(KeyguardViewManager.ShowListener showListener) {
if (DEBUG) Log.d(TAG, "notifyScreenOnLocked");
- mHandler.sendEmptyMessage(NOTIFY_SCREEN_ON);
+ Message msg = mHandler.obtainMessage(NOTIFY_SCREEN_ON, showListener);
+ mHandler.sendMessage(msg);
}
/**
@@ -974,7 +958,7 @@ public class KeyguardViewMediator implements KeyguardViewCallback,
handleNotifyScreenOff();
return;
case NOTIFY_SCREEN_ON:
- handleNotifyScreenOn();
+ handleNotifyScreenOn((KeyguardViewManager.ShowListener)msg.obj);
return;
case WAKE_WHEN_READY:
handleWakeWhenReady(msg.arg1);
@@ -996,12 +980,6 @@ public class KeyguardViewMediator implements KeyguardViewCallback,
doKeyguardLocked();
}
break;
- case REPORT_SHOW_DONE:
- synchronized (KeyguardViewMediator.this) {
- mShowPending = false;
- KeyguardViewMediator.this.notifyAll();
- }
- break;
}
}
};
@@ -1076,6 +1054,7 @@ public class KeyguardViewMediator implements KeyguardViewCallback,
final Ringtone sfx = RingtoneManager.getRingtone(mContext, soundUri);
if (sfx != null) {
sfx.setStreamType(AudioManager.STREAM_SYSTEM);
+ sfx.setWakeMode(mContext, PowerManager.PARTIAL_WAKE_LOCK);
sfx.play();
} else {
if (DEBUG) Log.d(TAG, "playSounds: failed to load ringtone from uri: "
@@ -1113,12 +1092,6 @@ public class KeyguardViewMediator implements KeyguardViewCallback,
playSounds(true);
mShowKeyguardWakeLock.release();
-
- // We won't say the show is done yet because the view hierarchy
- // still needs to do the traversal. Posting this message allows
- // us to hold off until that is done.
- Message msg = mHandler.obtainMessage(REPORT_SHOW_DONE);
- mHandler.sendMessage(msg);
}
}
@@ -1284,10 +1257,10 @@ public class KeyguardViewMediator implements KeyguardViewCallback,
* Handle message sent by {@link #notifyScreenOnLocked()}
* @see #NOTIFY_SCREEN_ON
*/
- private void handleNotifyScreenOn() {
+ private void handleNotifyScreenOn(KeyguardViewManager.ShowListener showListener) {
synchronized (KeyguardViewMediator.this) {
if (DEBUG) Log.d(TAG, "handleNotifyScreenOn");
- mKeyguardViewManager.onScreenTurnedOn();
+ mKeyguardViewManager.onScreenTurnedOn(showListener);
}
}
diff --git a/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java b/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java
index e2a1149..d9bd5f2 100644
--- a/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java
+++ b/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java
@@ -46,6 +46,8 @@ import android.graphics.ColorFilter;
import android.graphics.PixelFormat;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
import android.os.IBinder;
import android.os.RemoteException;
import android.os.SystemClock;
@@ -74,7 +76,7 @@ import java.io.IOException;
* {@link com.android.internal.policy.impl.KeyguardViewManager}
* via its {@link com.android.internal.policy.impl.KeyguardViewCallback}, as appropriate.
*/
-public class LockPatternKeyguardView extends KeyguardViewBase {
+public class LockPatternKeyguardView extends KeyguardViewBase implements Handler.Callback {
private static final int TRANSPORT_USERACTIVITY_TIMEOUT = 10000;
@@ -103,9 +105,15 @@ public class LockPatternKeyguardView extends KeyguardViewBase {
// The following were added to support FaceLock
private IFaceLockInterface mFaceLockService;
private boolean mBoundToFaceLockService = false;
- private boolean mFaceLockServiceRunning = false;
private View mFaceLockAreaView;
+ private boolean mFaceLockServiceRunning = false;
+ private final Object mFaceLockServiceRunningLock = new Object();
+
+ private Handler mHandler;
+ private final int MSG_SHOW_FACELOCK_AREA_VIEW = 0;
+ private final int MSG_HIDE_FACELOCK_AREA_VIEW = 1;
+
/**
* The current {@link KeyguardScreen} will use this to communicate back to us.
*/
@@ -244,6 +252,7 @@ public class LockPatternKeyguardView extends KeyguardViewBase {
KeyguardWindowController controller) {
super(context);
+ mHandler = new Handler(this);
mConfiguration = context.getResources().getConfiguration();
mEnableFallback = false;
mRequiresSim = TextUtils.isEmpty(SystemProperties.get("keyguard.no_require_sim"));
@@ -594,10 +603,6 @@ public class LockPatternKeyguardView extends KeyguardViewBase {
}
private boolean isSecure() {
- // TODO: make this work with SIM and Account cases below.
- boolean usingBiometric = mLockPatternUtils.usingBiometricWeak();
- if (usingBiometric && mLockPatternUtils.isBiometricEnabled())
- return true;
UnlockMode unlockMode = getUnlockMode();
boolean secure = false;
switch (unlockMode) {
@@ -705,12 +710,6 @@ public class LockPatternKeyguardView extends KeyguardViewBase {
mKeyguardScreenCallback,
mUpdateMonitor.getFailedAttempts());
view.setEnableFallback(mEnableFallback);
-
- // TODO(bcolonna): For pattern unlock, it can give us the view where the pattern is
- // displayed and FaceLock can draw in that area.
- // For other views it's not so simple and we should probably change how the FaceLock
- // area is determined.
- mFaceLockAreaView = view.getUnlockAreaView();
unlockView = view;
} else if (unlockMode == UnlockMode.SimPuk) {
unlockView = new SimPukUnlockScreen(
@@ -760,6 +759,8 @@ public class LockPatternKeyguardView extends KeyguardViewBase {
throw new IllegalArgumentException("unknown unlock mode " + unlockMode);
}
initializeTransportControlView(unlockView);
+ initializeFaceLockAreaView(unlockView); // Only shows view if FaceLock is enabled
+
mUnlockScreenMode = unlockMode;
return unlockView;
}
@@ -939,6 +940,41 @@ public class LockPatternKeyguardView extends KeyguardViewBase {
// Everything below pertains to FaceLock - might want to separate this out
+ // Only pattern and pin unlock screens actually have a view for the FaceLock area, so it's not
+ // uncommon for it to not exist. But if it does exist, we need to make sure it's showing if
+ // FaceLock is enabled, and make sure it's not showing if FaceLock is disabled
+ private void initializeFaceLockAreaView(View view) {
+ mFaceLockAreaView = view.findViewById(R.id.faceLockAreaView);
+ if (mFaceLockAreaView == null) {
+ if (DEBUG) Log.d(TAG, "Layout does not have faceLockAreaView");
+ } else {
+ if (mLockPatternUtils.usingBiometricWeak()) {
+ mHandler.sendEmptyMessage(MSG_SHOW_FACELOCK_AREA_VIEW);
+ } else {
+ mHandler.sendEmptyMessage(MSG_HIDE_FACELOCK_AREA_VIEW);
+ }
+ }
+ }
+
+ // Handles covering or exposing FaceLock area on the client side when FaceLock starts or stops
+ // This needs to be done in a handler because the call could be coming from a callback from the
+ // FaceLock service that is in a thread that can't modify the UI
+ @Override
+ public boolean handleMessage(Message msg) {
+ switch (msg.what) {
+ case MSG_SHOW_FACELOCK_AREA_VIEW:
+ mFaceLockAreaView.setVisibility(View.VISIBLE);
+ break;
+ case MSG_HIDE_FACELOCK_AREA_VIEW:
+ mFaceLockAreaView.setVisibility(View.GONE);
+ break;
+ default:
+ Log.w(TAG, "Unhandled message");
+ return false;
+ }
+ return true;
+ }
+
// Binds to FaceLock service, but does not tell it to start
public void bindToFaceLock() {
if (mLockPatternUtils.usingBiometricWeak()) {
@@ -987,23 +1023,20 @@ public class LockPatternKeyguardView extends KeyguardViewBase {
throw new RuntimeException("Remote exception");
}
- // TODO(bcolonna): Need to set location properly (only works for pattern view now)
if (mFaceLockAreaView != null) {
- int[] unlockLocationOnScreen = new int[2];
- mFaceLockAreaView.getLocationOnScreen(unlockLocationOnScreen);
- int x = unlockLocationOnScreen[0];
- int y = unlockLocationOnScreen[1];
- int w = mFaceLockAreaView.getWidth();
- int h = mFaceLockAreaView.getHeight();
- if (DEBUG) Log.d(TAG, "(x,y) (wxh): (" + x + "," + y + ") (" + w + "x" + h + ")");
- startFaceLock(mFaceLockAreaView.getWindowToken(), x, y, w, h);
+ startFaceLock(mFaceLockAreaView.getWindowToken(),
+ mFaceLockAreaView.getLeft(), mFaceLockAreaView.getTop(),
+ mFaceLockAreaView.getWidth(), mFaceLockAreaView.getHeight());
}
}
// Cleans up if FaceLock service unexpectedly disconnects
@Override
public void onServiceDisconnected(ComponentName className) {
- mFaceLockService = null;
+ synchronized(mFaceLockServiceRunningLock) {
+ mFaceLockService = null;
+ mFaceLockServiceRunning = false;
+ }
if (DEBUG) Log.w(TAG, "Unexpected disconnect from FaceLock service");
}
};
@@ -1012,16 +1045,18 @@ public class LockPatternKeyguardView extends KeyguardViewBase {
public void startFaceLock(IBinder windowToken, int x, int y, int h, int w)
{
if (mLockPatternUtils.usingBiometricWeak()) {
- if (!mFaceLockServiceRunning) {
- if (DEBUG) Log.d(TAG, "Starting FaceLock");
- try {
- mFaceLockService.startUi(windowToken, x, y, h, w);
- } catch (RemoteException e) {
- throw new RuntimeException("Remote exception");
+ synchronized (mFaceLockServiceRunningLock) {
+ if (!mFaceLockServiceRunning) {
+ if (DEBUG) Log.d(TAG, "Starting FaceLock");
+ try {
+ mFaceLockService.startUi(windowToken, x, y, h, w);
+ } catch (RemoteException e) {
+ throw new RuntimeException("Remote exception");
+ }
+ mFaceLockServiceRunning = true;
+ } else {
+ if (DEBUG) Log.w(TAG, "startFaceLock() attempted while running");
}
- mFaceLockServiceRunning = true;
- } else {
- if (DEBUG) Log.w(TAG, "startFaceLock() attempted while running");
}
}
}
@@ -1033,14 +1068,16 @@ public class LockPatternKeyguardView extends KeyguardViewBase {
// Note that attempting to stop FaceLock when it's not running is not an issue.
// FaceLock can return, which stops it and then we try to stop it when the
// screen is turned off. That's why we check.
- if (mFaceLockServiceRunning) {
- try {
- if (DEBUG) Log.d(TAG, "Stopping FaceLock");
- mFaceLockService.stopUi();
- } catch (RemoteException e) {
- throw new RuntimeException("Remote exception");
+ synchronized (mFaceLockServiceRunningLock) {
+ if (mFaceLockServiceRunning) {
+ try {
+ if (DEBUG) Log.d(TAG, "Stopping FaceLock");
+ mFaceLockService.stopUi();
+ } catch (RemoteException e) {
+ throw new RuntimeException("Remote exception");
+ }
+ mFaceLockServiceRunning = false;
}
- mFaceLockServiceRunning = false;
}
}
}
@@ -1052,6 +1089,9 @@ public class LockPatternKeyguardView extends KeyguardViewBase {
@Override
public void unlock() {
if (DEBUG) Log.d(TAG, "FaceLock unlock");
+ // Note that we don't hide the client FaceLockAreaView because we want to keep the
+ // lock screen covered while the phone is unlocked
+
stopFaceLock();
mKeyguardScreenCallback.keyguardDone(true);
mKeyguardScreenCallback.reportSuccessfulUnlockAttempt();
@@ -1062,6 +1102,8 @@ public class LockPatternKeyguardView extends KeyguardViewBase {
public void cancel() {
// In this case, either the user has cancelled out, or FaceLock failed to recognize them
if (DEBUG) Log.d(TAG, "FaceLock cancel");
+ // Here we hide the client FaceLockViewArea to expose the underlying backup method
+ mHandler.sendEmptyMessage(MSG_HIDE_FACELOCK_AREA_VIEW);
stopFaceLock();
}
@@ -1070,8 +1112,12 @@ public class LockPatternKeyguardView extends KeyguardViewBase {
public void sleepDevice() {
// In this case, it appears the phone has been turned on accidentally
if (DEBUG) Log.d(TAG, "FaceLock accidental turn on");
+ // Here we hide the client FaceLockViewArea to expose the underlying backup method
+ mHandler.sendEmptyMessage(MSG_HIDE_FACELOCK_AREA_VIEW);
stopFaceLock();
// TODO(bcolonna): how do we put the phone back to sleep (i.e., turn off the screen)
+ // TODO(bcolonna): this should be removed once the service is no longer calling it
+ // because we are just going to let the lockscreen timeout
}
};
}
diff --git a/policy/src/com/android/internal/policy/impl/PatternUnlockScreen.java b/policy/src/com/android/internal/policy/impl/PatternUnlockScreen.java
index 0cafeb5..88c42a6 100644
--- a/policy/src/com/android/internal/policy/impl/PatternUnlockScreen.java
+++ b/policy/src/com/android/internal/policy/impl/PatternUnlockScreen.java
@@ -199,12 +199,6 @@ class PatternUnlockScreen extends LinearLayoutWithDefaultTouchRecepient
setFocusableInTouchMode(true);
}
- // TODO(bcolonna): This is to tell FaceLock where to draw...but this covers up the wireless
- // service text, so we will want to change the way the area is specified
- public View getUnlockAreaView() {
- return mLockPatternView;
- }
-
public void setEnableFallback(boolean state) {
if (DEBUG) Log.d(TAG, "setEnableFallback(" + state + ")");
mEnableFallback = state;
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindow.java b/policy/src/com/android/internal/policy/impl/PhoneWindow.java
index 903b405..bca95d3 100644
--- a/policy/src/com/android/internal/policy/impl/PhoneWindow.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindow.java
@@ -2135,7 +2135,9 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
com.android.internal.R.attr.actionModePopupWindowStyle);
mActionModePopup.setLayoutInScreenEnabled(true);
mActionModePopup.setLayoutInsetDecor(true);
- mActionModePopup.setClippingEnabled(false);
+ mActionModePopup.setFocusable(true);
+ mActionModePopup.setWindowLayoutType(
+ WindowManager.LayoutParams.TYPE_APPLICATION);
mActionModePopup.setContentView(mActionModeView);
mActionModePopup.setWidth(MATCH_PARENT);
@@ -2144,10 +2146,12 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
com.android.internal.R.attr.actionBarSize, heightValue, true);
final int height = TypedValue.complexToDimensionPixelSize(heightValue.data,
mContext.getResources().getDisplayMetrics());
- mActionModePopup.setHeight(height);
+ mActionModeView.setContentHeight(height);
+ mActionModePopup.setHeight(WRAP_CONTENT);
mShowActionModePopup = new Runnable() {
public void run() {
- mActionModePopup.showAtLocation(PhoneWindow.DecorView.this,
+ mActionModePopup.showAtLocation(
+ mActionModeView.getApplicationWindowToken(),
Gravity.TOP | Gravity.FILL_HORIZONTAL, 0, 0);
}
};
@@ -3467,6 +3471,8 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
}
public boolean onOpenSubMenu(MenuBuilder subMenu) {
+ if (subMenu == null) return false;
+
// Set a simple callback for the submenu
subMenu.setCallback(this);
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
index 10447ad..c8c0041 100755
--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -40,8 +40,10 @@ import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.graphics.RectF;
import android.os.Binder;
+import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
+import android.os.IRemoteCallback;
import android.os.LocalPowerManager;
import android.os.Message;
import android.os.Messenger;
@@ -284,7 +286,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
int mLidKeyboardAccessibility;
int mLidNavigationAccessibility;
int mLongPressOnPowerBehavior = -1;
- boolean mScreenOn = false;
+ boolean mScreenOnEarly = false;
+ boolean mScreenOnFully = false;
boolean mOrientationSensorEnabled = false;
int mCurrentAppOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
static final int DEFAULT_ACCELEROMETER_ROTATION = 0;
@@ -544,11 +547,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
}
//Could have been invoked due to screen turning on or off or
//change of the currently visible window's orientation
- if (localLOGV) Log.v(TAG, "Screen status="+mScreenOn+
+ if (localLOGV) Log.v(TAG, "Screen status="+mScreenOnEarly+
", current orientation="+mCurrentAppOrientation+
", SensorEnabled="+mOrientationSensorEnabled);
boolean disable = true;
- if (mScreenOn) {
+ if (mScreenOnEarly) {
if (needSensorRunningLp()) {
disable = false;
//enable listener if not already enabled
@@ -2091,11 +2094,13 @@ public class PhoneWindowManager implements WindowManagerPolicy {
/** {@inheritDoc} */
public void animatingWindowLw(WindowState win,
WindowManager.LayoutParams attrs) {
+ if (DEBUG_LAYOUT) Slog.i(TAG, "Win " + win + ": isVisibleOrBehindKeyguardLw="
+ + win.isVisibleOrBehindKeyguardLw());
if (mTopFullscreenOpaqueWindowState == null &&
win.isVisibleOrBehindKeyguardLw()) {
if ((attrs.flags & FLAG_FORCE_NOT_FULLSCREEN) != 0) {
mForceStatusBar = true;
- }
+ }
if (attrs.type >= FIRST_APPLICATION_WINDOW
&& attrs.type <= LAST_APPLICATION_WINDOW
&& attrs.x == 0 && attrs.y == 0
@@ -2134,10 +2139,10 @@ public class PhoneWindowManager implements WindowManagerPolicy {
: null;
if (mStatusBar != null) {
- if (localLOGV) Log.i(TAG, "force=" + mForceStatusBar
+ if (DEBUG_LAYOUT) Log.i(TAG, "force=" + mForceStatusBar
+ " top=" + mTopFullscreenOpaqueWindowState);
if (mForceStatusBar) {
- if (DEBUG_LAYOUT) Log.v(TAG, "Showing status bar");
+ if (DEBUG_LAYOUT) Log.v(TAG, "Showing status bar: forced");
if (mStatusBar.showLw(true)) changes |= FINISH_LAYOUT_REDO_LAYOUT;
} else if (mTopFullscreenOpaqueWindowState != null) {
if (localLOGV) {
@@ -2165,11 +2170,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
}
}});
}
- } else if (localLOGV) {
+ } else if (DEBUG_LAYOUT) {
Log.v(TAG, "Preventing status bar from hiding by policy");
}
} else {
- if (DEBUG_LAYOUT) Log.v(TAG, "Showing status bar");
+ if (DEBUG_LAYOUT) Log.v(TAG, "Showing status bar: top is not fullscreen");
if (mStatusBar.showLw(true)) changes |= FINISH_LAYOUT_REDO_LAYOUT;
}
}
@@ -2806,7 +2811,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
public void screenTurnedOff(int why) {
EventLog.writeEvent(70000, 0);
synchronized (mLock) {
- mScreenOn = false;
+ mScreenOnEarly = false;
+ mScreenOnFully = false;
}
mKeyguardMediator.onScreenTurnedOff(why);
synchronized (mLock) {
@@ -2814,25 +2820,38 @@ public class PhoneWindowManager implements WindowManagerPolicy {
updateLockScreenTimeout();
updateScreenSaverTimeoutLocked();
}
- try {
- mWindowManager.waitForAllDrawn();
- } catch (RemoteException e) {
- }
- // Wait for one frame to give surface flinger time to do its
- // compositing. Yes this is a hack, but I am really not up right now for
- // implementing some mechanism to block until SF is done. :p
- try {
- Thread.sleep(20);
- } catch (InterruptedException e) {
- }
}
/** {@inheritDoc} */
- public void screenTurnedOn() {
+ public void screenTurningOn(final ScreenOnListener screenOnListener) {
EventLog.writeEvent(70000, 1);
- mKeyguardMediator.onScreenTurnedOn();
+ //Slog.i(TAG, "Screen turning on...");
+ mKeyguardMediator.onScreenTurnedOn(new KeyguardViewManager.ShowListener() {
+ @Override public void onShown(IBinder windowToken) {
+ if (windowToken != null) {
+ try {
+ mWindowManager.waitForWindowDrawn(windowToken, new IRemoteCallback.Stub() {
+ @Override public void sendResult(Bundle data) {
+ Slog.i(TAG, "Lock screen displayed!");
+ screenOnListener.onScreenOn();
+ synchronized (mLock) {
+ mScreenOnFully = true;
+ }
+ }
+ });
+ } catch (RemoteException e) {
+ }
+ } else {
+ Slog.i(TAG, "No lock screen!");
+ screenOnListener.onScreenOn();
+ synchronized (mLock) {
+ mScreenOnFully = true;
+ }
+ }
+ }
+ });
synchronized (mLock) {
- mScreenOn = true;
+ mScreenOnEarly = true;
updateOrientationListenerLp();
updateLockScreenTimeout();
updateScreenSaverTimeoutLocked();
@@ -2840,8 +2859,13 @@ public class PhoneWindowManager implements WindowManagerPolicy {
}
/** {@inheritDoc} */
- public boolean isScreenOn() {
- return mScreenOn;
+ public boolean isScreenOnEarly() {
+ return mScreenOnEarly;
+ }
+
+ /** {@inheritDoc} */
+ public boolean isScreenOnFully() {
+ return mScreenOnFully;
}
/** {@inheritDoc} */
@@ -3228,7 +3252,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
synchronized (mScreenSaverActivator) {
mHandler.removeCallbacks(mScreenSaverActivator);
- if (mScreenSaverEnabled && mScreenOn && mScreenSaverTimeout > 0) {
+ if (mScreenSaverEnabled && mScreenOnEarly && mScreenSaverTimeout > 0) {
if (localLOGV)
Log.v(TAG, "scheduling screensaver for " + mScreenSaverTimeout + "ms from now");
mHandler.postDelayed(mScreenSaverActivator, mScreenSaverTimeout);
@@ -3236,7 +3260,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
if (localLOGV) {
if (mScreenSaverTimeout == 0)
Log.v(TAG, "screen saver disabled by user");
- else if (!mScreenOn)
+ else if (!mScreenOnEarly)
Log.v(TAG, "screen saver disabled while screen off");
else
Log.v(TAG, "screen saver disabled by wakelock");
@@ -3257,7 +3281,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
private void updateLockScreenTimeout() {
synchronized (mScreenLockTimeout) {
- boolean enable = (mAllowLockscreenWhenOn && mScreenOn && mKeyguardMediator.isSecure());
+ boolean enable = (mAllowLockscreenWhenOn && mScreenOnEarly && mKeyguardMediator.isSecure());
if (mLockScreenTimerActive != enable) {
if (enable) {
if (localLOGV) Log.v(TAG, "setting lockscreen timer");
@@ -3466,7 +3490,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
public boolean allowKeyRepeat() {
// disable key repeat when screen is off
- return mScreenOn;
+ return mScreenOnEarly;
}
private void updateSystemUiVisibility() {
@@ -3522,7 +3546,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
pw.print(mLidKeyboardAccessibility);
pw.print(" mLidNavigationAccessibility="); pw.print(mLidNavigationAccessibility);
pw.print(" mLongPressOnPowerBehavior="); pw.println(mLongPressOnPowerBehavior);
- pw.print(prefix); pw.print("mScreenOn="); pw.print(mScreenOn);
+ pw.print(prefix); pw.print("mScreenOnEarly="); pw.print(mScreenOnEarly);
+ pw.print(" mScreenOnFully="); pw.print(mScreenOnFully);
pw.print(" mOrientationSensorEnabled="); pw.print(mOrientationSensorEnabled);
pw.print(" mHasSoftInput="); pw.println(mHasSoftInput);
pw.print(prefix); pw.print("mUnrestrictedScreen=("); pw.print(mUnrestrictedScreenLeft);