Skip to content

Commit 24d7b5f

Browse files
author
Nick Pelly
committed
Send ACTION_USER_PRESENT when provisioning is completed.
This is needed for application to know when the keyguard becomes unlocked, because isKeyguardLocked() is typically true while provisioning (setup wizard), but ACTION_USER_PRSENT was not sent when it transitions to false after provisioning. Bug: 5436867 Bug: 5430833 Change-Id: Icae13ff9cab84774a002a426eb9cb353fa1dc530
1 parent 9e076a6 commit 24d7b5f

File tree

4 files changed

+39
-5
lines changed

4 files changed

+39
-5
lines changed

policy/src/com/android/internal/policy/impl/KeyguardStatusViewManager.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,10 @@ public void onPhoneStateChanged(int phoneState) {
606606
public void onClockVisibilityChanged() {
607607
// ignored
608608
}
609+
610+
public void onDeviceProvisioned() {
611+
// ignored
612+
}
609613
};
610614

611615
private SimStateCallback mSimStateCallback = new SimStateCallback() {

policy/src/com/android/internal/policy/impl/KeyguardUpdateMonitor.java

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ public class KeyguardUpdateMonitor {
9999
private static final int MSG_RINGER_MODE_CHANGED = 305;
100100
private static final int MSG_PHONE_STATE_CHANGED = 306;
101101
private static final int MSG_CLOCK_VISIBILITY_CHANGED = 307;
102+
private static final int MSG_DEVICE_PROVISIONED = 308;
102103

103104
/**
104105
* When we receive a
@@ -178,6 +179,9 @@ public void handleMessage(Message msg) {
178179
case MSG_CLOCK_VISIBILITY_CHANGED:
179180
handleClockVisibilityChanged();
180181
break;
182+
case MSG_DEVICE_PROVISIONED:
183+
handleDeviceProvisioned();
184+
break;
181185
}
182186
}
183187
};
@@ -197,10 +201,8 @@ public void onChange(boolean selfChange) {
197201
super.onChange(selfChange);
198202
mDeviceProvisioned = Settings.Secure.getInt(mContext.getContentResolver(),
199203
Settings.Secure.DEVICE_PROVISIONED, 0) != 0;
200-
if (mDeviceProvisioned && mContentObserver != null) {
201-
// We don't need the observer anymore...
202-
mContext.getContentResolver().unregisterContentObserver(mContentObserver);
203-
mContentObserver = null;
204+
if (mDeviceProvisioned) {
205+
mHandler.sendMessage(mHandler.obtainMessage(MSG_DEVICE_PROVISIONED));
204206
}
205207
if (DEBUG) Log.d(TAG, "DEVICE_PROVISIONED state = " + mDeviceProvisioned);
206208
}
@@ -212,8 +214,14 @@ public void onChange(boolean selfChange) {
212214

213215
// prevent a race condition between where we check the flag and where we register the
214216
// observer by grabbing the value once again...
215-
mDeviceProvisioned = Settings.Secure.getInt(mContext.getContentResolver(),
217+
boolean provisioned = Settings.Secure.getInt(mContext.getContentResolver(),
216218
Settings.Secure.DEVICE_PROVISIONED, 0) != 0;
219+
if (provisioned != mDeviceProvisioned) {
220+
mDeviceProvisioned = provisioned;
221+
if (mDeviceProvisioned) {
222+
mHandler.sendMessage(mHandler.obtainMessage(MSG_DEVICE_PROVISIONED));
223+
}
224+
}
217225
}
218226

219227
// take a guess to start
@@ -271,6 +279,17 @@ public void onReceive(Context context, Intent intent) {
271279
}, filter);
272280
}
273281

282+
protected void handleDeviceProvisioned() {
283+
for (int i = 0; i < mInfoCallbacks.size(); i++) {
284+
mInfoCallbacks.get(i).onDeviceProvisioned();
285+
}
286+
if (mContentObserver != null) {
287+
// We don't need the observer anymore...
288+
mContext.getContentResolver().unregisterContentObserver(mContentObserver);
289+
mContentObserver = null;
290+
}
291+
}
292+
274293
protected void handlePhoneStateChanged(String newState) {
275294
if (DEBUG) Log.d(TAG, "handlePhoneStateChanged(" + newState + ")");
276295
if (TelephonyManager.EXTRA_STATE_IDLE.equals(newState)) {
@@ -477,6 +496,10 @@ interface InfoCallback {
477496
*/
478497
void onClockVisibilityChanged();
479498

499+
/**
500+
* Called when the device becomes provisioned
501+
*/
502+
void onDeviceProvisioned();
480503
}
481504

482505
/**

policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,4 +1323,9 @@ public void onRingerModeChanged(int state) {
13231323
public void onTimeChanged() {
13241324
// ignored
13251325
}
1326+
1327+
/** {@inheritDoc} */
1328+
public void onDeviceProvisioned() {
1329+
mContext.sendBroadcast(mUserPresentIntent);
1330+
}
13261331
}

policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,8 @@ public void onRefreshCarrierInfo(CharSequence plmn, CharSequence spn) {}
615615
public void onRingerModeChanged(int state) {}
616616
@Override
617617
public void onClockVisibilityChanged() {}
618+
@Override
619+
public void onDeviceProvisioned() {}
618620

619621
//We need to stop faceunlock when a phonecall comes in
620622
@Override

0 commit comments

Comments
 (0)