summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWink Saville <wink@google.com>2010-02-12 12:12:45 -0800
committerWink Saville <wink@google.com>2010-02-12 12:12:45 -0800
commit2693030ea4604f68cf662aa4785a9a8fb3a1a23d (patch)
tree6f6284e8899f7f4221cb2489aa586110bddc709f /src
parent999b6a5ecb36405d3697f9fb11df9a5bb0273e73 (diff)
downloadandroid_packages_apps_Trebuchet-2693030ea4604f68cf662aa4785a9a8fb3a1a23d.tar.gz
android_packages_apps_Trebuchet-2693030ea4604f68cf662aa4785a9a8fb3a1a23d.tar.bz2
android_packages_apps_Trebuchet-2693030ea4604f68cf662aa4785a9a8fb3a1a23d.zip
Launcher changes to handle UTS test mode.
When in UTS test mode keys received need to be handled by the Phone application or Contacts application to operate properly in the test mode. When not in test mode the search widget will handle the keys as it was before this change. The UTS test mode is enabled when presist.sys.uts-test-mode is 1. bug: 2402366 Change-Id: I58e68830f9ce6905e189ecba1c04b1076799a0a0 Signed-off-by: Wink Saville <wink@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher2/Launcher.java56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 45545db55..7a4e2bc2c 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -43,13 +43,16 @@ import android.graphics.Rect;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.ColorDrawable;
+import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Parcelable;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemProperties;
+import android.provider.ContactsContract;
import android.provider.LiveFolders;
+import android.telephony.PhoneNumberUtils;
import android.text.Selection;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
@@ -201,6 +204,8 @@ public final class Launcher extends Activity
private ImageView mPreviousView;
private ImageView mNextView;
+ private boolean mUtsTestMode;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -406,6 +411,7 @@ public final class Launcher extends Activity
super.onResume();
mPaused = false;
+ mUtsTestMode = SystemProperties.getInt("persist.sys.uts-test-mode", 0) == 1;
if (mRestoring) {
mWorkspaceLoading = true;
@@ -456,6 +462,10 @@ public final class Launcher extends Activity
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
+ if (mUtsTestMode) {
+ return handleUtsTestModeKeyDown(keyCode, event);
+ }
+
boolean handled = super.onKeyDown(keyCode, event);
if (!handled && acceptFilter() && keyCode != KeyEvent.KEYCODE_ENTER) {
boolean gotKey = TextKeyListener.getInstance().onKeyDown(mWorkspace, mDefaultKeySsb,
@@ -474,6 +484,52 @@ public final class Launcher extends Activity
return handled;
}
+ public boolean handleUtsTestModeKeyDown(int keyCode, KeyEvent event) {
+ Log.d(TAG, "UTS-TEST-MODE");
+ boolean handled = super.onKeyDown(keyCode, event);
+ if (!handled && acceptFilter() && keyCode != KeyEvent.KEYCODE_ENTER) {
+ boolean gotKey = TextKeyListener.getInstance().onKeyDown(mWorkspace, mDefaultKeySsb,
+ keyCode, event);
+ if (gotKey && mDefaultKeySsb != null && mDefaultKeySsb.length() > 0) {
+ // something usable has been typed - dispatch it now.
+ final String str = mDefaultKeySsb.toString();
+
+ boolean isDialable = true;
+ final int count = str.length();
+ for (int i = 0; i < count; i++) {
+ if (!PhoneNumberUtils.isReallyDialable(str.charAt(i))) {
+ isDialable = false;
+ break;
+ }
+ }
+ Intent intent;
+ if (isDialable) {
+ intent = new Intent(Intent.ACTION_DIAL, Uri.fromParts("tel", str, null));
+ } else {
+ intent = new Intent(ContactsContract.Intents.UI.FILTER_CONTACTS_ACTION);
+ intent.putExtra(ContactsContract.Intents.UI.FILTER_TEXT_EXTRA_KEY, str);
+ }
+
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
+ | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
+
+ try {
+ startActivity(intent);
+ } catch (android.content.ActivityNotFoundException ex) {
+ // Oh well... no one knows how to filter/dial. Life goes on.
+ }
+
+ mDefaultKeySsb.clear();
+ mDefaultKeySsb.clearSpans();
+ Selection.setSelection(mDefaultKeySsb, 0);
+
+ return true;
+ }
+ }
+
+ return handled;
+ }
+
private String getTypedText() {
return mDefaultKeySsb.toString();
}