diff options
author | Benoit Hebrard <benoit.hebrard@sonyericsson.com> | 2010-06-15 16:33:26 +0200 |
---|---|---|
committer | Johan Redestig <johan.redestig@sonyericsson.com> | 2010-06-15 16:33:26 +0200 |
commit | ef782f72b7c8a7563854c866298a394e4720b62f (patch) | |
tree | 08dda2af0d02417b91118d4ca0db568f28e8091b | |
parent | 794841710d11f59fd1736d1c889cc9b91f38f78e (diff) | |
download | base-ef782f72b7c8a7563854c866298a394e4720b62f.tar.gz |
Telephony : Dial emergency phone numbers when screen is locked
The current implementation do not allow dialing emergency phone
numbers with the qwerty-keyboard when the screen is locked.
This contribution will automatically start the emergency dialer
if a valid digit (i.e. 0-9,*,+,#) is entered from the qwerty
keypad when the screen is locked. The emergency dialer appears
pre-filled with the first entered digit.
Change-Id: I136b5434f99bfab6f1908d3698e2700f7e59d036
-rw-r--r-- | phone/com/android/internal/policy/impl/KeyguardScreenCallback.java | 6 | ||||
-rw-r--r-- | phone/com/android/internal/policy/impl/LockPatternKeyguardView.java | 27 |
2 files changed, 33 insertions, 0 deletions
diff --git a/phone/com/android/internal/policy/impl/KeyguardScreenCallback.java b/phone/com/android/internal/policy/impl/KeyguardScreenCallback.java index 6bb6a45..1c4a462 100644 --- a/phone/com/android/internal/policy/impl/KeyguardScreenCallback.java +++ b/phone/com/android/internal/policy/impl/KeyguardScreenCallback.java @@ -63,6 +63,12 @@ public interface KeyguardScreenCallback extends KeyguardViewCallback { void takeEmergencyCallAction(); /** + * Take action to send an emergency call to a prefilled number. + * @param prefilled number + */ + void takeEmergencyCallAction(String number); + + /** * Report that the user had a failed attempt unlocking via the pattern. */ void reportFailedPatternAttempt(); diff --git a/phone/com/android/internal/policy/impl/LockPatternKeyguardView.java b/phone/com/android/internal/policy/impl/LockPatternKeyguardView.java index 85918fb..fded21e 100644 --- a/phone/com/android/internal/policy/impl/LockPatternKeyguardView.java +++ b/phone/com/android/internal/policy/impl/LockPatternKeyguardView.java @@ -36,6 +36,8 @@ import android.graphics.ColorFilter; import android.graphics.PixelFormat; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; +import android.net.Uri; +import android.telephony.PhoneNumberUtils; import android.os.SystemProperties; import android.text.TextUtils; import android.util.Log; @@ -245,9 +247,19 @@ public class LockPatternKeyguardView extends KeyguardViewBase } public void takeEmergencyCallAction() { + takeEmergencyCallAction(null); + } + + public void takeEmergencyCallAction(String number) { Intent intent = new Intent(ACTION_EMERGENCY_DIAL); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); + + // Add number if available + if (number != null) { + intent.setData(Uri.parse("tel:" + number)); + } + getContext().startActivity(intent); } @@ -436,6 +448,21 @@ public class LockPatternKeyguardView extends KeyguardViewBase } @Override + public boolean dispatchKeyEvent(KeyEvent event) { + if (DEBUG) Log.d(TAG, "dispatchKeyEvent for key=" + event.getKeyCode()); + + // Dial emergency number if screen is locked + if (event.getAction() == KeyEvent.ACTION_UP && (!mScreenOn || mMode == Mode.LockScreen)) { + char c = event.getNumber(); + if (PhoneNumberUtils.isReallyDialable(c)) { + if (DEBUG) Log.d(TAG, "starting emergency dialer with number=" + c); + mKeyguardScreenCallback.takeEmergencyCallAction(c + ""); + } + } + return super.dispatchKeyEvent(event); + } + + @Override public void verifyUnlock() { if (!isSecure()) { // non-secure keyguard screens are successfull by default |