diff --git a/res/drawable-hdpi/ic_emergency.png b/res/drawable-hdpi/ic_emergency.png
new file mode 100644
index 00000000000..89c05e36049
Binary files /dev/null and b/res/drawable-hdpi/ic_emergency.png differ
diff --git a/res/drawable-hdpi/stat_sys_phone_call.png b/res/drawable-hdpi/stat_sys_phone_call.png
new file mode 100755
index 00000000000..9b5f07576cc
Binary files /dev/null and b/res/drawable-hdpi/stat_sys_phone_call.png differ
diff --git a/res/drawable-mdpi/ic_emergency.png b/res/drawable-mdpi/ic_emergency.png
new file mode 100755
index 00000000000..c6faf1e9e43
Binary files /dev/null and b/res/drawable-mdpi/ic_emergency.png differ
diff --git a/res/drawable-mdpi/stat_sys_phone_call.png b/res/drawable-mdpi/stat_sys_phone_call.png
new file mode 100644
index 00000000000..c44d0620f7f
Binary files /dev/null and b/res/drawable-mdpi/stat_sys_phone_call.png differ
diff --git a/res/layout/crypt_keeper_password_entry.xml b/res/layout/crypt_keeper_password_entry.xml
index a5193ceae2f..60dcf6a2910 100644
--- a/res/layout/crypt_keeper_password_entry.xml
+++ b/res/layout/crypt_keeper_password_entry.xml
@@ -42,4 +42,16 @@
android:textColor="#ffffffff"
/>
-
\ No newline at end of file
+
+
+
+
diff --git a/res/values/strings.xml b/res/values/strings.xml
index f7318bd19c4..674866f09a9 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -3481,4 +3481,9 @@ found in the list of installed applications.
%1$s %2$s\nwarning
+
+ Emergency call
+
+ Return to call
+
diff --git a/src/com/android/settings/CryptKeeper.java b/src/com/android/settings/CryptKeeper.java
index 20bf7cee2e5..612f4c05bce 100644
--- a/src/com/android/settings/CryptKeeper.java
+++ b/src/com/android/settings/CryptKeeper.java
@@ -16,6 +16,7 @@
package com.android.settings;
+import com.android.internal.telephony.ITelephony;
import com.android.internal.widget.PasswordEntryKeyboardHelper;
import com.android.internal.widget.PasswordEntryKeyboardView;
@@ -33,9 +34,11 @@ import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.os.PowerManager;
+import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemProperties;
import android.os.storage.IMountService;
+import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;
@@ -62,6 +65,9 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
private static final int COOL_DOWN_ATTEMPTS = 10;
private static final int COOL_DOWN_INTERVAL = 30; // 30 seconds
+ // Intent action for launching the Emergency Dialer activity.
+ static final String ACTION_EMERGENCY_DIAL = "com.android.phone.EmergencyDialer.DIAL";
+
private int mCooldown;
PowerManager.WakeLock mWakeLock;
private EditText mPasswordEntry;
@@ -347,6 +353,8 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
keyboardView, mPasswordEntry, false);
keyboardHelper.setKeyboardMode(PasswordEntryKeyboardHelper.KEYBOARD_MODE_ALPHA);
}
+
+ updateEmergencyCallButtonState();
}
private IMountService getMountService() {
@@ -381,4 +389,73 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
}
return false;
}
-}
\ No newline at end of file
+
+ //
+ // Code to update the state of, and handle clicks from, the "Emergency call" button.
+ //
+ // This code is mostly duplicated from the corresponding code in
+ // LockPatternUtils and LockPatternKeyguardView under frameworks/base.
+ //
+
+ private void updateEmergencyCallButtonState() {
+ Button button = (Button) findViewById(R.id.emergencyCallButton);
+ // The button isn't present at all in some configurations.
+ if (button == null) return;
+
+ if (isEmergencyCallCapable()) {
+ button.setVisibility(View.VISIBLE);
+ button.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+ takeEmergencyCallAction();
+ }
+ });
+ } else {
+ button.setVisibility(View.GONE);
+ return;
+ }
+
+ int newState = TelephonyManager.getDefault().getCallState();
+ int textId;
+ if (newState == TelephonyManager.CALL_STATE_OFFHOOK) {
+ // show "return to call" text and show phone icon
+ textId = R.string.cryptkeeper_return_to_call;
+ int phoneCallIcon = R.drawable.stat_sys_phone_call;
+ button.setCompoundDrawablesWithIntrinsicBounds(phoneCallIcon, 0, 0, 0);
+ } else {
+ textId = R.string.cryptkeeper_emergency_call;
+ int emergencyIcon = R.drawable.ic_emergency;
+ button.setCompoundDrawablesWithIntrinsicBounds(emergencyIcon, 0, 0, 0);
+ }
+ button.setText(textId);
+ }
+
+ private boolean isEmergencyCallCapable() {
+ return getResources().getBoolean(com.android.internal.R.bool.config_voice_capable);
+ }
+
+ private void takeEmergencyCallAction() {
+ if (TelephonyManager.getDefault().getCallState() == TelephonyManager.CALL_STATE_OFFHOOK) {
+ resumeCall();
+ } else {
+ launchEmergencyDialer();
+ }
+ }
+
+ private void resumeCall() {
+ ITelephony phone = ITelephony.Stub.asInterface(ServiceManager.checkService("phone"));
+ if (phone != null) {
+ try {
+ phone.showCallScreen();
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error calling ITelephony service: " + e);
+ }
+ }
+ }
+
+ private void launchEmergencyDialer() {
+ Intent intent = new Intent(ACTION_EMERGENCY_DIAL);
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
+ | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
+ startActivity(intent);
+ }
+}