@@ -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 /**
0 commit comments