diff options
author | Andres Morales <anmorales@google.com> | 2013-12-12 17:36:39 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2013-12-12 17:36:40 +0000 |
commit | ec31555d8822ad68bed6f478594d65e821b0851b (patch) | |
tree | 65cb2318f54b6b51b450f5e372ec9576bfb9ced7 /packages | |
parent | c62cbd9c2865c0152da4dc7e06b62ba41a0a5367 (diff) | |
parent | 38a7ed05f8fed0aa81f7214d827875f9876ffbe1 (diff) | |
download | frameworks_base-ec31555d8822ad68bed6f478594d65e821b0851b.zip frameworks_base-ec31555d8822ad68bed6f478594d65e821b0851b.tar.gz frameworks_base-ec31555d8822ad68bed6f478594d65e821b0851b.tar.bz2 |
Merge "Adding INfcUnlockSettings and NfcUnlock interface class."
Diffstat (limited to 'packages')
3 files changed, 41 insertions, 0 deletions
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java index 1bae9b8..dfcd8a8 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java @@ -16,6 +16,7 @@ package com.android.keyguard; +import android.nfc.NfcUnlock; import com.android.internal.widget.LockPatternUtils; import com.android.keyguard.KeyguardSecurityModel.SecurityMode; import com.android.keyguard.KeyguardUpdateMonitor.DisplayClientState; @@ -50,6 +51,7 @@ import android.provider.Settings; import android.util.AttributeSet; import android.util.Log; import android.util.Slog; + import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; @@ -296,6 +298,11 @@ public class KeyguardHostView extends KeyguardViewBase { } } } + @Override + public void onNfcUnlock() { + if (NfcUnlock.getPropertyEnabled()) mCallback.dismiss(true); + } + }; private static final boolean isMusicPlaying(int playbackState) { diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java index a849316..3b712e9 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java @@ -36,6 +36,7 @@ import static android.os.BatteryManager.EXTRA_LEVEL; import static android.os.BatteryManager.EXTRA_HEALTH; import android.media.AudioManager; import android.media.IRemoteControlDisplay; +import android.nfc.NfcUnlock; import android.os.BatteryManager; import android.os.Bundle; import android.os.Handler; @@ -94,6 +95,7 @@ public class KeyguardUpdateMonitor { protected static final int MSG_REPORT_EMERGENCY_CALL_ACTION = 318; private static final int MSG_SCREEN_TURNED_ON = 319; private static final int MSG_SCREEN_TURNED_OFF = 320; + private static final int MSG_NFC_UNLOCK = 321; private static KeyguardUpdateMonitor sInstance; @@ -194,6 +196,9 @@ public class KeyguardUpdateMonitor { case MSG_SCREEN_TURNED_ON: handleScreenTurnedOn(); break; + case MSG_NFC_UNLOCK: + handleNfcUnlock(); + break; } } }; @@ -311,6 +316,15 @@ public class KeyguardUpdateMonitor { } }; + private final BroadcastReceiver mNfcUnlockReceiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + if (NfcUnlock.ACTION_NFC_UNLOCK.equals(intent.getAction())) { + mHandler.sendEmptyMessage(MSG_NFC_UNLOCK); + } + } + } + ; /** * When we receive a * {@link com.android.internal.telephony.TelephonyIntents#ACTION_SIM_STATE_CHANGED} broadcast, @@ -495,6 +509,15 @@ public class KeyguardUpdateMonitor { } } + private void handleNfcUnlock() { + for (int i = 0; i < mCallbacks.size(); i++) { + KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get(); + if (cb != null) { + cb.onNfcUnlock(); + } + } + } + private KeyguardUpdateMonitor(Context context) { mContext = context; @@ -524,6 +547,11 @@ public class KeyguardUpdateMonitor { filter.addAction(Intent.ACTION_USER_REMOVED); context.registerReceiver(mBroadcastReceiver, filter); + final IntentFilter nfcUnlockIntentFilter = new IntentFilter(); + nfcUnlockIntentFilter.addAction(NfcUnlock.ACTION_NFC_UNLOCK); + context.registerReceiver(mNfcUnlockReceiver, nfcUnlockIntentFilter, + NfcUnlock.NFC_UNLOCK_PERMISSION, null /* run on default scheduler */); + final IntentFilter bootCompleteFilter = new IntentFilter(); bootCompleteFilter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY); bootCompleteFilter.addAction(Intent.ACTION_BOOT_COMPLETED); diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java index c08880d..481d132 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java @@ -20,6 +20,7 @@ import android.app.admin.DevicePolicyManager; import android.graphics.Bitmap; import android.media.AudioManager; import android.os.SystemClock; +import android.util.Log; import android.view.WindowManagerPolicy; import com.android.internal.telephony.IccCardConstants; @@ -172,4 +173,9 @@ class KeyguardUpdateMonitorCallback { * {@link WindowManagerPolicy#OFF_BECAUSE_OF_PROX_SENSOR}. */ public void onScreenTurnedOff(int why) { } + + /** + * Called when the NFC Service has found a tag that is registered for NFC unlock. + */ + public void onNfcUnlock() { } } |