Post-review Keyguard cleanup.

- remove userActivity() from KeyguardService interface and call it
on PowerManager directly
- Split IKeyguardResult into two parts: IKeyguardShowCallback and
IKeyguardExitCallback.
- Misc other changes from the review.

Change-Id: I3f679cfa5d3f8bc742f2b2259ac354045e89a87b
This commit is contained in:
Jim Miller
2013-02-28 17:36:24 -08:00
parent 32e18d9f32
commit 25190577cc
12 changed files with 166 additions and 175 deletions

View File

@@ -180,7 +180,8 @@ LOCAL_SRC_FILES += \
core/java/com/android/internal/backup/IBackupTransport.aidl \
core/java/com/android/internal/policy/IFaceLockCallback.aidl \
core/java/com/android/internal/policy/IFaceLockInterface.aidl \
core/java/com/android/internal/policy/IKeyguardResult.aidl \
core/java/com/android/internal/policy/IKeyguardShowCallback.aidl \
core/java/com/android/internal/policy/IKeyguardExitCallback.aidl \
core/java/com/android/internal/policy/IKeyguardService.aidl \
core/java/com/android/internal/os/IDropBoxManagerService.aidl \
core/java/com/android/internal/os/IResultReceiver.aidl \

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2012 The Android Open Source Project
* Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
*/
package com.android.internal.policy;
oneway interface IKeyguardResult {
void onShown(IBinder windowToken);
oneway interface IKeyguardExitCallback {
void onKeyguardExitResult(boolean success);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2012 The Android Open Source Project
* Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,8 @@
*/
package com.android.internal.policy;
import com.android.internal.policy.IKeyguardResult;
import com.android.internal.policy.IKeyguardShowCallback;
import com.android.internal.policy.IKeyguardExitCallback;
import android.os.Bundle;
@@ -25,17 +26,16 @@ interface IKeyguardService {
boolean isShowingAndNotHidden();
boolean isInputRestricted();
boolean isDismissable();
oneway void userActivity();
oneway void verifyUnlock(IKeyguardResult result);
oneway void verifyUnlock(IKeyguardExitCallback callback);
oneway void keyguardDone(boolean authenticated, boolean wakeup);
oneway void setHidden(boolean isHidden);
oneway void dismiss();
oneway void onWakeKeyWhenKeyguardShowingTq(int keyCode);
oneway void onWakeMotionWhenKeyguardShowingTq();
oneway void onWakeKeyWhenKeyguardShowing(int keyCode);
oneway void onWakeMotionWhenKeyguardShowing();
oneway void onDreamingStarted();
oneway void onDreamingStopped();
oneway void onScreenTurnedOff(int reason);
oneway void onScreenTurnedOn(IKeyguardResult result);
oneway void onScreenTurnedOn(IKeyguardShowCallback callback);
oneway void setKeyguardEnabled(boolean enabled);
oneway void onSystemReady();
oneway void doKeyguardTimeout(in Bundle options);

View File

@@ -0,0 +1,20 @@
/*
* Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.internal.policy;
oneway interface IKeyguardShowCallback {
void onShown(IBinder windowToken);
}

View File

@@ -45,17 +45,5 @@
<service android:name=".KeyguardService"
android:exported="true" />
<activity android:name=".KeyguardTestActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.Holo"
android:hardwareAccelerated="true"
android:process="com.android.keyguard.keyguard_test"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2010 The Android Open Source Project
* Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,10 +24,10 @@ import android.content.Intent;
import android.os.Bundle;
import android.os.IBinder;
import android.util.Log;
import android.view.accessibility.AccessibilityManager;
import com.android.internal.policy.IKeyguardService;
import com.android.internal.policy.IKeyguardResult;
import com.android.internal.policy.IKeyguardExitCallback;
import com.android.internal.policy.IKeyguardShowCallback;
import com.android.internal.widget.LockPatternUtils;
public class KeyguardService extends Service {
@@ -66,11 +66,8 @@ public class KeyguardService extends Service {
public boolean isInputRestricted() {
return mKeyguardViewMediator.isInputRestricted();
}
public void userActivity() {
mKeyguardViewMediator.userActivity();
}
public void verifyUnlock(IKeyguardResult result) {
mKeyguardViewMediator.verifyUnlock(result);
public void verifyUnlock(IKeyguardExitCallback callback) {
mKeyguardViewMediator.verifyUnlock(callback);
}
public void keyguardDone(boolean authenticated, boolean wakeup) {
mKeyguardViewMediator.keyguardDone(authenticated, wakeup);
@@ -81,11 +78,11 @@ public class KeyguardService extends Service {
public void dismiss() {
mKeyguardViewMediator.dismiss();
}
public void onWakeKeyWhenKeyguardShowingTq(int keyCode) {
mKeyguardViewMediator.onWakeKeyWhenKeyguardShowingTq(keyCode);
public void onWakeKeyWhenKeyguardShowing(int keyCode) {
mKeyguardViewMediator.onWakeKeyWhenKeyguardShowing(keyCode);
}
public void onWakeMotionWhenKeyguardShowingTq() {
mKeyguardViewMediator.onWakeMotionWhenKeyguardShowingTq();
public void onWakeMotionWhenKeyguardShowing() {
mKeyguardViewMediator.onWakeMotionWhenKeyguardShowing();
}
public void onDreamingStarted() {
mKeyguardViewMediator.onDreamingStarted();
@@ -96,8 +93,8 @@ public class KeyguardService extends Service {
public void onScreenTurnedOff(int reason) {
mKeyguardViewMediator.onScreenTurnedOff(reason);
}
public void onScreenTurnedOn(IKeyguardResult result) {
mKeyguardViewMediator.onScreenTurnedOn(result);
public void onScreenTurnedOn(IKeyguardShowCallback callback) {
mKeyguardViewMediator.onScreenTurnedOn(callback);
}
public void setKeyguardEnabled(boolean enabled) {
mKeyguardViewMediator.setKeyguardEnabled(enabled);

View File

@@ -16,7 +16,8 @@
package com.android.keyguard;
import com.android.internal.policy.IKeyguardResult;
import com.android.internal.policy.IKeyguardShowCallback;
import com.android.internal.policy.IKeyguardExitCallback;
import com.android.internal.policy.IKeyguardService;
import android.app.Activity;
@@ -58,16 +59,21 @@ public class KeyguardTestActivity extends Activity implements OnClickListener {
IKeyguardService mService = null;
KeyguardResult mKeyguardResult = new KeyguardResult();
KeyguardShowCallback mKeyguardShowCallback = new KeyguardShowCallback();
KeyguardExitCallback mKeyguardExitCallback = new KeyguardExitCallback();
RemoteServiceConnection mConnection;
private boolean mSentSystemReady;
class KeyguardResult extends IKeyguardResult.Stub {
class KeyguardShowCallback extends IKeyguardShowCallback.Stub {
@Override
public void onShown(IBinder windowToken) throws RemoteException {
Log.v(TAG, "Keyguard is shown, windowToken = " + windowToken);
}
}
class KeyguardExitCallback extends IKeyguardExitCallback.Stub {
@Override
public void onKeyguardExitResult(boolean success) throws RemoteException {
@@ -236,7 +242,7 @@ public class KeyguardTestActivity extends Activity implements OnClickListener {
try {
switch (v.getId()) {
case R.id.on_screen_turned_on:
mService.onScreenTurnedOn(mKeyguardResult);
mService.onScreenTurnedOn(mKeyguardShowCallback);
break;
case R.id.on_screen_turned_off:
mService.onScreenTurnedOff(WindowManagerPolicy.OFF_BECAUSE_OF_USER);
@@ -249,7 +255,7 @@ public class KeyguardTestActivity extends Activity implements OnClickListener {
mService.doKeyguardTimeout(null);
break;
case R.id.verify_unlock:
mService.verifyUnlock(mKeyguardResult);
mService.verifyUnlock(mKeyguardExitCallback);
break;
}
} catch (RemoteException e) {

View File

@@ -16,7 +16,7 @@
package com.android.keyguard;
import com.android.internal.policy.IKeyguardResult;
import com.android.internal.policy.IKeyguardShowCallback;
import com.android.internal.widget.LockPatternUtils;
import android.app.Activity;
@@ -331,7 +331,7 @@ public class KeyguardViewManager {
}
}
public synchronized void onScreenTurnedOn(final IKeyguardResult result) {
public synchronized void onScreenTurnedOn(final IKeyguardShowCallback callback) {
if (DEBUG) Log.d(TAG, "onScreenTurnedOn()");
mScreenOn = true;
if (mKeyguardView != null) {
@@ -339,7 +339,7 @@ public class KeyguardViewManager {
// Caller should wait for this window to be shown before turning
// on the screen.
if (result != null) {
if (callback != null) {
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.
@@ -351,28 +351,25 @@ public class KeyguardViewManager {
token = mKeyguardHost.getWindowToken();
}
try {
result.onShown(token);
callback.onShown(token);
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Slog.w(TAG, "Exception calling onShown():", e);
}
}
});
} else {
try {
result.onShown(null);
callback.onShown(null);
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Slog.w(TAG, "Exception calling onShown():", e);
}
}
}
} else if (result != null) {
} else if (callback != null) {
try {
result.onShown(null);
callback.onShown(null);
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Slog.w(TAG, "Exception calling onShown():", e);
}
}
}

View File

@@ -16,7 +16,8 @@
package com.android.keyguard;
import com.android.internal.policy.IKeyguardResult;
import com.android.internal.policy.IKeyguardExitCallback;
import com.android.internal.policy.IKeyguardShowCallback;
import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT;
import android.app.Activity;
@@ -46,6 +47,7 @@ import android.provider.Settings;
import android.telephony.TelephonyManager;
import android.util.EventLog;
import android.util.Log;
import android.util.Slog;
import android.view.KeyEvent;
import android.view.WindowManager;
import android.view.WindowManagerPolicy;
@@ -220,7 +222,7 @@ public class KeyguardViewMediator {
* how we'll ultimately let them know whether it was successful. We use this
* var being non-null as an indicator that there is an in progress request.
*/
private IKeyguardResult mExitSecureCallback;
private IKeyguardExitCallback mExitSecureCallback;
// the properties of the keyguard
@@ -463,7 +465,7 @@ public class KeyguardViewMediator {
mPM.wakeUp(SystemClock.uptimeMillis());
}
public void userActivity() {
private void userActivity() {
userActivity(AWAKE_INTERVAL_DEFAULT_MS);
}
@@ -590,7 +592,7 @@ public class KeyguardViewMediator {
try {
mExitSecureCallback.onKeyguardExitResult(false);
} catch (RemoteException e) {
e.printStackTrace();
Slog.w(TAG, "Failed to call onKeyguardExitResult(false)", e);
}
mExitSecureCallback = null;
if (!mExternallyEnabled) {
@@ -664,13 +666,13 @@ public class KeyguardViewMediator {
/**
* Let's us know the screen was turned on.
*/
public void onScreenTurnedOn(IKeyguardResult result) {
public void onScreenTurnedOn(IKeyguardShowCallback callback) {
synchronized (this) {
mScreenOn = true;
cancelDoKeyguardLaterLocked();
if (DEBUG) Log.d(TAG, "onScreenTurnedOn, seq = " + mDelayedShowingSequence);
if (result != null) {
notifyScreenOnLocked(result);
if (callback != null) {
notifyScreenOnLocked(callback);
}
}
maybeSendUserPresentBroadcast();
@@ -744,7 +746,7 @@ public class KeyguardViewMediator {
try {
mExitSecureCallback.onKeyguardExitResult(false);
} catch (RemoteException e) {
e.printStackTrace();
Slog.w(TAG, "Failed to call onKeyguardExitResult(false)", e);
}
mExitSecureCallback = null;
resetStateLocked(null);
@@ -773,16 +775,16 @@ public class KeyguardViewMediator {
/**
* @see android.app.KeyguardManager#exitKeyguardSecurely
*/
public void verifyUnlock(IKeyguardResult result) {
public void verifyUnlock(IKeyguardExitCallback callback) {
synchronized (this) {
if (DEBUG) Log.d(TAG, "verifyUnlock");
if (!mUpdateMonitor.isDeviceProvisioned()) {
// don't allow this api when the device isn't provisioned
if (DEBUG) Log.d(TAG, "ignoring because device isn't provisioned");
try {
result.onKeyguardExitResult(false);
callback.onKeyguardExitResult(false);
} catch (RemoteException e) {
e.printStackTrace();
Slog.w(TAG, "Failed to call onKeyguardExitResult(false)", e);
}
} else if (mExternallyEnabled) {
// this only applies when the user has externally disabled the
@@ -790,19 +792,19 @@ public class KeyguardViewMediator {
// using the api properly.
Log.w(TAG, "verifyUnlock called when not externally disabled");
try {
result.onKeyguardExitResult(false);
callback.onKeyguardExitResult(false);
} catch (RemoteException e) {
e.printStackTrace();
Slog.w(TAG, "Failed to call onKeyguardExitResult(false)", e);
}
} else if (mExitSecureCallback != null) {
// already in progress with someone else
try {
result.onKeyguardExitResult(false);
callback.onKeyguardExitResult(false);
} catch (RemoteException e) {
e.printStackTrace();
Slog.w(TAG, "Failed to call onKeyguardExitResult(false)", e);
}
} else {
mExitSecureCallback = result;
mExitSecureCallback = callback;
verifyUnlockLocked();
}
}
@@ -962,7 +964,7 @@ public class KeyguardViewMediator {
* @see #onScreenTurnedOn()
* @see #handleNotifyScreenOn
*/
private void notifyScreenOnLocked(IKeyguardResult result) {
private void notifyScreenOnLocked(IKeyguardShowCallback result) {
if (DEBUG) Log.d(TAG, "notifyScreenOnLocked");
Message msg = mHandler.obtainMessage(NOTIFY_SCREEN_ON, result);
mHandler.sendMessage(msg);
@@ -973,7 +975,7 @@ public class KeyguardViewMediator {
* its state accordingly and then poke the wake lock when it is ready.
* @param keyCode The wake key.
* @see #handleWakeWhenReady
* @see #onWakeKeyWhenKeyguardShowingTq(int)
* @see #onWakeKeyWhenKeyguardShowing(int)
*/
private void wakeWhenReady(int keyCode) {
if (DBG_WAKE) Log.d(TAG, "wakeWhenReady(" + keyCode + ")");
@@ -1055,7 +1057,7 @@ public class KeyguardViewMediator {
*
* @param keyCode The keycode of the key that woke the device
*/
public void onWakeKeyWhenKeyguardShowingTq(int keyCode) {
public void onWakeKeyWhenKeyguardShowing(int keyCode) {
if (DEBUG) Log.d(TAG, "onWakeKeyWhenKeyguardShowing(" + keyCode + ")");
// give the keyguard view manager a chance to adjust the state of the
@@ -1074,7 +1076,7 @@ public class KeyguardViewMediator {
* Be sure not to take any action that takes a long time; any significant
* action should be posted to a handler.
*/
public void onWakeMotionWhenKeyguardShowingTq() {
public void onWakeMotionWhenKeyguardShowing() {
if (DEBUG) Log.d(TAG, "onWakeMotionWhenKeyguardShowing()");
// give the keyguard view manager a chance to adjust the state of the
@@ -1100,7 +1102,7 @@ public class KeyguardViewMediator {
try {
mExitSecureCallback.onKeyguardExitResult(authenticated);
} catch (RemoteException e) {
e.printStackTrace();
Slog.w(TAG, "Failed to call onKeyguardExitResult(" + authenticated + ")", e);
}
mExitSecureCallback = null;
@@ -1142,7 +1144,7 @@ public class KeyguardViewMediator {
handleNotifyScreenOff();
return;
case NOTIFY_SCREEN_ON:
handleNotifyScreenOn((IKeyguardResult) msg.obj);
handleNotifyScreenOn((IKeyguardShowCallback) msg.obj);
return;
case WAKE_WHEN_READY:
handleWakeWhenReady(msg.arg1);
@@ -1433,10 +1435,10 @@ public class KeyguardViewMediator {
* Handle message sent by {@link #notifyScreenOnLocked()}
* @see #NOTIFY_SCREEN_ON
*/
private void handleNotifyScreenOn(IKeyguardResult result) {
private void handleNotifyScreenOn(IKeyguardShowCallback callback) {
synchronized (KeyguardViewMediator.this) {
if (DEBUG) Log.d(TAG, "handleNotifyScreenOn");
mKeyguardViewManager.onScreenTurnedOn(result);
mKeyguardViewManager.onScreenTurnedOn(callback);
}
}

View File

@@ -19,8 +19,10 @@ package com.android.internal.policy.impl;
import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Slog;
import com.android.internal.policy.IKeyguardResult;
import com.android.internal.policy.IKeyguardShowCallback;
import com.android.internal.policy.IKeyguardExitCallback;
import com.android.internal.policy.IKeyguardService;
/**
@@ -30,6 +32,7 @@ import com.android.internal.policy.IKeyguardService;
*/
public class KeyguardServiceWrapper implements IKeyguardService {
private IKeyguardService mService;
private String TAG = "KeyguardServiceWrapper";
public KeyguardServiceWrapper(IKeyguardService service) {
mService = service;
@@ -39,7 +42,7 @@ public class KeyguardServiceWrapper implements IKeyguardService {
try {
return mService.isShowing();
} catch (RemoteException e) {
e.printStackTrace();
Slog.w(TAG , "Remote Exception", e);
}
return false;
}
@@ -48,7 +51,7 @@ public class KeyguardServiceWrapper implements IKeyguardService {
try {
return mService.isSecure();
} catch (RemoteException e) {
e.printStackTrace();
Slog.w(TAG , "Remote Exception", e);
}
return false; // TODO cache state
}
@@ -57,7 +60,7 @@ public class KeyguardServiceWrapper implements IKeyguardService {
try {
return mService.isShowingAndNotHidden();
} catch (RemoteException e) {
e.printStackTrace();
Slog.w(TAG , "Remote Exception", e);
}
return false; // TODO cache state
}
@@ -66,7 +69,7 @@ public class KeyguardServiceWrapper implements IKeyguardService {
try {
return mService.isInputRestricted();
} catch (RemoteException e) {
e.printStackTrace();
Slog.w(TAG , "Remote Exception", e);
}
return false; // TODO cache state
}
@@ -75,25 +78,16 @@ public class KeyguardServiceWrapper implements IKeyguardService {
try {
return mService.isDismissable();
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Slog.w(TAG , "Remote Exception", e);
}
return true; // TODO cache state
}
public void userActivity() {
public void verifyUnlock(IKeyguardExitCallback callback) {
try {
mService.userActivity();
mService.verifyUnlock(callback);
} catch (RemoteException e) {
e.printStackTrace();
}
}
public void verifyUnlock(IKeyguardResult result) {
try {
mService.verifyUnlock(result);
} catch (RemoteException e) {
e.printStackTrace();
Slog.w(TAG , "Remote Exception", e);
}
}
@@ -101,7 +95,7 @@ public class KeyguardServiceWrapper implements IKeyguardService {
try {
mService.keyguardDone(authenticated, wakeup);
} catch (RemoteException e) {
e.printStackTrace();
Slog.w(TAG , "Remote Exception", e);
}
}
@@ -109,7 +103,7 @@ public class KeyguardServiceWrapper implements IKeyguardService {
try {
mService.setHidden(isHidden);
} catch (RemoteException e) {
e.printStackTrace();
Slog.w(TAG , "Remote Exception", e);
}
}
@@ -117,23 +111,23 @@ public class KeyguardServiceWrapper implements IKeyguardService {
try {
mService.dismiss();
} catch (RemoteException e) {
e.printStackTrace();
Slog.w(TAG , "Remote Exception", e);
}
}
public void onWakeKeyWhenKeyguardShowingTq(int keyCode) {
public void onWakeKeyWhenKeyguardShowing(int keyCode) {
try {
mService.onWakeKeyWhenKeyguardShowingTq(keyCode);
mService.onWakeKeyWhenKeyguardShowing(keyCode);
} catch (RemoteException e) {
e.printStackTrace();
Slog.w(TAG , "Remote Exception", e);
}
}
public void onWakeMotionWhenKeyguardShowingTq() {
public void onWakeMotionWhenKeyguardShowing() {
try {
mService.onWakeMotionWhenKeyguardShowingTq();
mService.onWakeMotionWhenKeyguardShowing();
} catch (RemoteException e) {
e.printStackTrace();
Slog.w(TAG , "Remote Exception", e);
}
}
@@ -141,7 +135,7 @@ public class KeyguardServiceWrapper implements IKeyguardService {
try {
mService.onDreamingStarted();
} catch (RemoteException e) {
e.printStackTrace();
Slog.w(TAG , "Remote Exception", e);
}
}
@@ -149,7 +143,7 @@ public class KeyguardServiceWrapper implements IKeyguardService {
try {
mService.onDreamingStopped();
} catch (RemoteException e) {
e.printStackTrace();
Slog.w(TAG , "Remote Exception", e);
}
}
@@ -157,15 +151,15 @@ public class KeyguardServiceWrapper implements IKeyguardService {
try {
mService.onScreenTurnedOff(reason);
} catch (RemoteException e) {
e.printStackTrace();
Slog.w(TAG , "Remote Exception", e);
}
}
public void onScreenTurnedOn(IKeyguardResult result) {
public void onScreenTurnedOn(IKeyguardShowCallback result) {
try {
mService.onScreenTurnedOn(result);
} catch (RemoteException e) {
e.printStackTrace();
Slog.w(TAG , "Remote Exception", e);
}
}
@@ -173,7 +167,7 @@ public class KeyguardServiceWrapper implements IKeyguardService {
try {
mService.setKeyguardEnabled(enabled);
} catch (RemoteException e) {
e.printStackTrace();
Slog.w(TAG , "Remote Exception", e);
}
}
@@ -181,7 +175,7 @@ public class KeyguardServiceWrapper implements IKeyguardService {
try {
mService.onSystemReady();
} catch (RemoteException e) {
e.printStackTrace();
Slog.w(TAG , "Remote Exception", e);
}
}
@@ -189,7 +183,7 @@ public class KeyguardServiceWrapper implements IKeyguardService {
try {
mService.doKeyguardTimeout(options);
} catch (RemoteException e) {
e.printStackTrace();
Slog.w(TAG , "Remote Exception", e);
}
}
@@ -197,7 +191,7 @@ public class KeyguardServiceWrapper implements IKeyguardService {
try {
mService.setCurrentUser(userId);
} catch (RemoteException e) {
e.printStackTrace();
Slog.w(TAG , "Remote Exception", e);
}
}
@@ -205,7 +199,7 @@ public class KeyguardServiceWrapper implements IKeyguardService {
try {
mService.showAssistant();
} catch (RemoteException e) {
e.printStackTrace();
Slog.w(TAG , "Remote Exception", e);
}
}

View File

@@ -727,7 +727,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
if (keyguardShowing) {
// since it took two seconds of long press to bring this up,
// poke the wake lock so they have some time to see the dialog.
mKeyguardDelegate.userActivity();
mPowerManager.userActivity(SystemClock.uptimeMillis(), false);
}
}
@@ -1689,10 +1689,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
hideKeyguardScrim();
break;
case TYPE_KEYGUARD_SCRIM:
// TODO: put this back when done testing
// if (mKeyguardScrim != null) {
// return WindowManagerGlobal.ADD_MULTIPLE_SINGLETON;
// }
if (mKeyguardScrim != null) {
return WindowManagerGlobal.ADD_MULTIPLE_SINGLETON;
}
mKeyguardScrim = win;
break;
@@ -3912,7 +3911,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
if (isWakeMotion) {
if (mKeyguardDelegate != null && mKeyguardDelegate.isShowing()) {
// If the keyguard is showing, let it decide what to do with the wake motion.
mKeyguardDelegate.onWakeMotionWhenKeyguardShowingTq();
mKeyguardDelegate.onWakeMotionWhenKeyguardShowing();
} else {
// Otherwise, wake the device ourselves.
result |= ACTION_WAKE_UP;
@@ -4732,7 +4731,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
public void keepScreenOnStoppedLw() {
if (mKeyguardDelegate != null && !mKeyguardDelegate.isShowingAndNotHidden()) {
long curTime = SystemClock.uptimeMillis();
mPowerManager.userActivity(curTime, false);
mPowerManager.userActivity(SystemClock.uptimeMillis(), false);
}
}

View File

@@ -12,11 +12,11 @@ import android.util.Log;
import android.util.Slog;
import android.view.WindowManagerPolicy.OnKeyguardExitResult;
import com.android.internal.policy.IKeyguardResult;
import com.android.internal.policy.IKeyguardExitCallback;
import com.android.internal.policy.IKeyguardShowCallback;
import com.android.internal.policy.IKeyguardService;
import com.android.internal.widget.LockPatternUtils;
import com.android.internal.policy.impl.KeyguardServiceWrapper;
import com.android.internal.policy.impl.keyguard.KeyguardServiceDelegate.ShowListener;
/**
* A local class that keeps a cache of keyguard state that can be restored in the event
@@ -27,12 +27,11 @@ public class KeyguardServiceDelegate {
private static final String KEYGUARD_PACKAGE = "com.android.keyguard";
private static final String KEYGUARD_CLASS = "com.android.keyguard.KeyguardService";
private static final String TAG = "KeyguardServiceDelegate";
private final static boolean DEBUG = true;
private ServiceConnection mKeyguardConnection;
private static final boolean DEBUG = true;
protected KeyguardServiceWrapper mKeyguardService;
private KeyguardState mKeyguardState = new KeyguardState();
/* package */ class KeyguardState {
/* package */ static final class KeyguardState {
boolean showing;
boolean showingAndNotHidden;
boolean inputRestricted;
@@ -45,29 +44,18 @@ public class KeyguardServiceDelegate {
public int offReason;
public int currentUser;
public boolean screenIsOn;
public boolean restoreStateWhenConnected;
public ShowListener showListener;
};
public interface ShowListener {
public void onShown(IBinder windowToken);
}
private class KeyguardResult extends IKeyguardResult.Stub {
// A delegate class to map a particular invocation with a ShowListener object.
private final class KeyguardShowDelegate extends IKeyguardShowCallback.Stub {
private ShowListener mShowListener;
private OnKeyguardExitResult mOnKeyguardExitResult;
KeyguardResult(ShowListener showListener, OnKeyguardExitResult onKeyguardExitResult) {
KeyguardShowDelegate(ShowListener showListener) {
mShowListener = showListener;
mOnKeyguardExitResult = onKeyguardExitResult;
}
@Override
public IBinder asBinder() {
if (DEBUG) Log.v(TAG, "asBinder() called for KeyguardResult, "
+ "mShowListener = " + mShowListener
+ ", mOnKeyguardExitResult = " + mOnKeyguardExitResult);
return super.asBinder();
}
@Override
@@ -77,6 +65,15 @@ public class KeyguardServiceDelegate {
mShowListener.onShown(windowToken);
}
}
};
// A delegate class to map a particular invocation with an OnKeyguardExitResult object.
private final class KeyguardExitDelegate extends IKeyguardExitCallback.Stub {
private OnKeyguardExitResult mOnKeyguardExitResult;
KeyguardExitDelegate(OnKeyguardExitResult onKeyguardExitResult) {
mOnKeyguardExitResult = onKeyguardExitResult;
}
@Override
public void onKeyguardExitResult(boolean success) throws RemoteException {
@@ -88,7 +85,6 @@ public class KeyguardServiceDelegate {
};
public KeyguardServiceDelegate(Context context, LockPatternUtils lockPatternUtils) {
mKeyguardConnection = createServiceConnection();
Intent intent = new Intent();
intent.setClassName(KEYGUARD_PACKAGE, KEYGUARD_CLASS);
if (!context.bindServiceAsUser(intent, mKeyguardConnection,
@@ -99,27 +95,24 @@ public class KeyguardServiceDelegate {
}
}
private ServiceConnection createServiceConnection() {
return new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
if (DEBUG) Log.v(TAG, "*** Keyguard connected (yay!)");
mKeyguardService = new KeyguardServiceWrapper(
IKeyguardService.Stub.asInterface(service));
if (mKeyguardState.systemIsReady) {
mKeyguardService.onSystemReady();
}
private final ServiceConnection mKeyguardConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
if (DEBUG) Log.v(TAG, "*** Keyguard connected (yay!)");
mKeyguardService = new KeyguardServiceWrapper(
IKeyguardService.Stub.asInterface(service));
if (mKeyguardState.systemIsReady) {
mKeyguardService.onSystemReady();
}
}
@Override
public void onServiceDisconnected(ComponentName name) {
if (DEBUG) Log.v(TAG, "*** Keyguard disconnected (boo!)");
mKeyguardService = null;
}
@Override
public void onServiceDisconnected(ComponentName name) {
if (DEBUG) Log.v(TAG, "*** Keyguard disconnected (boo!)");
mKeyguardService = null;
}
};
}
};
public boolean isShowing() {
if (mKeyguardService != null) {
@@ -144,7 +137,7 @@ public class KeyguardServiceDelegate {
public void verifyUnlock(final OnKeyguardExitResult onKeyguardExitResult) {
if (mKeyguardService != null) {
mKeyguardService.verifyUnlock(new KeyguardResult(null, onKeyguardExitResult));
mKeyguardService.verifyUnlock(new KeyguardExitDelegate(onKeyguardExitResult));
}
}
@@ -176,13 +169,13 @@ public class KeyguardServiceDelegate {
public void onWakeKeyWhenKeyguardShowingTq(int keycodePower) {
if (mKeyguardService != null) {
mKeyguardService.onWakeKeyWhenKeyguardShowingTq(keycodePower);
mKeyguardService.onWakeKeyWhenKeyguardShowing(keycodePower);
}
}
public void onWakeMotionWhenKeyguardShowingTq() {
public void onWakeMotionWhenKeyguardShowing() {
if (mKeyguardService != null) {
mKeyguardService.onWakeMotionWhenKeyguardShowingTq();
mKeyguardService.onWakeMotionWhenKeyguardShowing();
}
}
@@ -203,12 +196,13 @@ public class KeyguardServiceDelegate {
public void onScreenTurnedOn(final ShowListener showListener) {
if (mKeyguardService != null) {
if (DEBUG) Log.v(TAG, "onScreenTurnedOn(showListener = " + showListener + ")");
mKeyguardService.onScreenTurnedOn(new KeyguardResult(showListener, null));
mKeyguardService.onScreenTurnedOn(new KeyguardShowDelegate(showListener));
} else {
// try again when we establish a connection
if (DEBUG) Log.w(TAG, "onScreenTurnedOn(): no keyguard service!");
mKeyguardState.showListener = showListener;
mKeyguardState.restoreStateWhenConnected = true;
Slog.w(TAG, "onScreenTurnedOn(): no keyguard service!");
// This shouldn't happen, but if it does, invoke the listener immediately
// to avoid a dark screen...
showListener.onShown(null);
}
mKeyguardState.screenIsOn = true;
}
@@ -263,10 +257,4 @@ public class KeyguardServiceDelegate {
mKeyguardState.currentUser = newUserId;
}
public void userActivity() {
if (mKeyguardService != null) {
mKeyguardService.userActivity();
}
}
}