Merge "Be more careful about exceptions in input callbacks."
diff --git a/core/java/com/android/internal/widget/LockPatternUtils.java b/core/java/com/android/internal/widget/LockPatternUtils.java
index 4d308dd..f77e8f3 100644
--- a/core/java/com/android/internal/widget/LockPatternUtils.java
+++ b/core/java/com/android/internal/widget/LockPatternUtils.java
@@ -223,6 +223,14 @@
}
}
+ public int getCurrentUser() {
+ if (Process.myUid() == Process.SYSTEM_UID) {
+ return mCurrentUserId;
+ } else {
+ throw new SecurityException("Only the system process can get the current user");
+ }
+ }
+
public void removeUser(int userId) {
if (Process.myUid() == Process.SYSTEM_UID) {
try {
diff --git a/core/res/res/layout/input_method_switch_dialog_title.xml b/core/res/res/layout/input_method_switch_dialog_title.xml
new file mode 100644
index 0000000..7032bd3
--- /dev/null
+++ b/core/res/res/layout/input_method_switch_dialog_title.xml
@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright 2012, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical" >
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="9dip"
+ android:layout_marginLeft="20dip"
+ android:layout_marginRight="10dip"
+ android:layout_marginTop="6dip"
+ android:gravity="center_vertical"
+ android:orientation="vertical" >
+
+ <com.android.internal.widget.DialogTitle
+ android:id="@+id/alertTitle"
+ style="@android:style/DialogWindowTitle.Holo"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:ellipsize="end"
+ android:singleLine="true"
+ android:text="@string/select_input_method" />
+ </LinearLayout>
+
+ <!-- Hard keyboard switch -->
+
+ <LinearLayout
+ android:id="@+id/hard_keyboard_section"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical" >
+
+ <View
+ android:layout_width="match_parent"
+ android:layout_height="2dip"
+ android:background="@android:color/holo_blue_light" />
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal" >
+
+ <LinearLayout
+ android:layout_width="0dip"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:background="?android:attr/selectableItemBackground"
+ android:ellipsize="marquee"
+ android:gravity="center_vertical"
+ android:minHeight="?android:attr/listPreferredItemHeightSmall"
+ android:orientation="vertical"
+ android:paddingBottom="5dip"
+ android:paddingLeft="16dip"
+ android:paddingRight="0dip"
+ android:paddingTop="5dip" >
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:singleLine="true"
+ android:text="@string/hardware"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:textColor="?android:attr/textColorAlertDialogListItem" />
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:singleLine="true"
+ android:text="@string/use_physical_keyboard"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:textColor="?android:attr/textColorAlertDialogListItem" />
+ </LinearLayout>
+
+ <Switch
+ android:id="@+id/hard_keyboard_switch"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:layout_marginRight="12dip" />
+ </LinearLayout>
+ </LinearLayout>
+
+ <View
+ android:id="@+id/titleDivider"
+ android:layout_width="match_parent"
+ android:layout_height="2dip"
+ android:background="@android:drawable/divider_horizontal_dark" />
+
+</LinearLayout>
\ No newline at end of file
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index cbfc1a4..aaef701 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -85,6 +85,8 @@
<java-symbol type="id" name="fillInIntent" />
<java-symbol type="id" name="find" />
<java-symbol type="id" name="fullscreenArea" />
+ <java-symbol type="id" name="hard_keyboard_section" />
+ <java-symbol type="id" name="hard_keyboard_switch" />
<java-symbol type="id" name="headers" />
<java-symbol type="id" name="hour" />
<java-symbol type="id" name="icon" />
@@ -1042,6 +1044,7 @@
<java-symbol type="layout" name="icon_menu_layout" />
<java-symbol type="layout" name="input_method" />
<java-symbol type="layout" name="input_method_extract_view" />
+ <java-symbol type="layout" name="input_method_switch_dialog_title" />
<java-symbol type="layout" name="js_prompt" />
<java-symbol type="layout" name="list_content_simple" />
<java-symbol type="layout" name="list_menu_item_checkbox" />
@@ -1449,6 +1452,7 @@
<java-symbol type="string" name="factorytest_no_action" />
<java-symbol type="string" name="factorytest_not_system" />
<java-symbol type="string" name="factorytest_reboot" />
+ <java-symbol type="string" name="hardware" />
<java-symbol type="string" name="heavy_weight_notification" />
<java-symbol type="string" name="heavy_weight_notification_detail" />
<java-symbol type="string" name="input_method_binding_label" />
@@ -1471,6 +1475,7 @@
<java-symbol type="string" name="usb_cd_installer_notification_title" />
<java-symbol type="string" name="usb_mtp_notification_title" />
<java-symbol type="string" name="usb_notification_message" />
+ <java-symbol type="string" name="use_physical_keyboard" />
<java-symbol type="string" name="usb_ptp_notification_title" />
<java-symbol type="string" name="vpn_text" />
<java-symbol type="string" name="vpn_text_long" />
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 86cece4..0eb46bd 100755
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -2927,6 +2927,10 @@
<string name="select_input_method">Choose input method</string>
<!-- Title of a button to open the settings for input methods [CHAR LIMIT=30] -->
<string name="configure_input_methods">Set up input methods</string>
+ <!-- Summary text of a toggle switch to enable/disable use of the physical keyboard in the input method selector [CHAR LIMIT=25] -->
+ <string name="use_physical_keyboard">Physical keyboard</string>
+ <!-- Title of the physical keyboard category in the input method selector [CHAR LIMIT=10] -->
+ <string name="hardware">Hardware</string>
<string name="fast_scroll_alphabet">\u0020ABCDEFGHIJKLMNOPQRSTUVWXYZ</string>
<string name="fast_scroll_numeric_alphabet">\u00200123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ</string>
diff --git a/packages/SystemUI/res/layout-sw600dp/status_bar_input_methods_panel.xml b/packages/SystemUI/res/layout-sw600dp/status_bar_input_methods_panel.xml
index f6ed804..b712dba 100644
--- a/packages/SystemUI/res/layout-sw600dp/status_bar_input_methods_panel.xml
+++ b/packages/SystemUI/res/layout-sw600dp/status_bar_input_methods_panel.xml
@@ -21,7 +21,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent"
- android:paddingBottom="28dip"
+ android:paddingBottom="7dip"
android:orientation="vertical"
android:visibility="gone">
<View
@@ -38,7 +38,7 @@
android:layout_height="wrap_content"
android:layout_marginLeft="20dip"
android:orientation="vertical"
- android:background="@*android:drawable/dialog_full_holo_dark">
+ android:background="@drawable/notify_panel_clock_bg">
<!-- Hard keyboard switch -->
<LinearLayout
android:id="@+id/hard_keyboard_section"
@@ -51,7 +51,7 @@
android:orientation="horizontal">
<TextView
android:id="@+id/use_physical_keyboard_label"
- android:layout_width="wrap_content"
+ android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:minHeight="?android:attr/listPreferredItemHeight"
@@ -82,7 +82,7 @@
<!-- Input method list -->
<ScrollView
android:layout_width="wrap_content"
- android:layout_height="wrap_content"
+ android:layout_height="0dip"
android:overScrollMode="ifContentScrolls"
android:layout_marginTop="3dip"
android:layout_weight="1"
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index fc81f8e..6dbe9d3 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -125,7 +125,7 @@
<string name="status_bar_input_method_settings_configure_input_methods">Set up input methods</string>
<!-- Label of a toggle switch to disable use of the physical keyboard in favor of the IME. [CHAR LIMIT=25] -->
- <string name="status_bar_use_physical_keyboard">Use physical keyboard</string>
+ <string name="status_bar_use_physical_keyboard">Physical keyboard</string>
<!-- Prompt for the USB device permission dialog [CHAR LIMIT=80] -->
<string name="usb_device_permission_prompt">Allow the app <xliff:g id="application">%1$s</xliff:g> to access the USB device?</string>
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/InputMethodsPanel.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/InputMethodsPanel.java
index f793af9..2171329 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/InputMethodsPanel.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/InputMethodsPanel.java
@@ -201,7 +201,6 @@
if (closeKeyboard) {
mImm.hideSoftInputFromWindow(getWindowToken(), 0);
}
- updateHardKeyboardEnabled();
}
private void startActivity(Intent intent) {
@@ -329,6 +328,7 @@
mHardKeyboardSection.setVisibility(View.VISIBLE);
if (mHardKeyboardSwitch.isChecked() != mHardKeyboardEnabled) {
mHardKeyboardSwitch.setChecked(mHardKeyboardEnabled);
+ updateHardKeyboardEnabled();
}
} else {
mHardKeyboardSection.setVisibility(View.GONE);
diff --git a/policy/src/com/android/internal/policy/impl/FaceUnlock.java b/policy/src/com/android/internal/policy/impl/FaceUnlock.java
index 985dcd3..31fbaafd 100644
--- a/policy/src/com/android/internal/policy/impl/FaceUnlock.java
+++ b/policy/src/com/android/internal/policy/impl/FaceUnlock.java
@@ -213,7 +213,8 @@
if (DEBUG) Log.d(TAG, "before bind to FaceLock service");
mContext.bindService(new Intent(IFaceLockInterface.class.getName()),
mConnection,
- Context.BIND_AUTO_CREATE);
+ Context.BIND_AUTO_CREATE,
+ mLockPatternUtils.getCurrentUser());
if (DEBUG) Log.d(TAG, "after bind to FaceLock service");
mBoundToService = true;
} else {
diff --git a/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java b/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java
index 596040c..d42f96a 100644
--- a/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java
+++ b/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java
@@ -703,6 +703,7 @@
@Override
public void onUserChanged(int userId) {
+ mFaceUnlock.stopAndUnbind();
mLockPatternUtils.setCurrentUser(userId);
updateScreen(getInitialMode(), true);
}
@@ -817,7 +818,9 @@
if (force || mUnlockScreen == null || unlockMode != mUnlockScreenMode) {
boolean restartFaceLock = mFaceUnlock.stopIfRunning();
recreateUnlockScreen(unlockMode);
- if (restartFaceLock) mFaceUnlock.activateIfAble(mHasOverlay);
+ if (restartFaceLock || force) {
+ mFaceUnlock.activateIfAble(mHasOverlay);
+ }
}
}
diff --git a/services/java/com/android/server/InputMethodManagerService.java b/services/java/com/android/server/InputMethodManagerService.java
index 96ee2f0..ca7241c 100644
--- a/services/java/com/android/server/InputMethodManagerService.java
+++ b/services/java/com/android/server/InputMethodManagerService.java
@@ -27,6 +27,7 @@
import com.android.internal.view.IInputMethodSession;
import com.android.internal.view.InputBindResult;
import com.android.server.EventLogTags;
+import com.android.server.wm.WindowManagerService;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
@@ -91,7 +92,10 @@
import android.view.inputmethod.InputMethodManager;
import android.view.inputmethod.InputMethodSubtype;
import android.widget.ArrayAdapter;
+import android.widget.CompoundButton;
+import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.RadioButton;
+import android.widget.Switch;
import android.widget.TextView;
import java.io.File;
@@ -134,6 +138,8 @@
static final int MSG_UNBIND_METHOD = 3000;
static final int MSG_BIND_METHOD = 3010;
+ static final int MSG_HARD_KEYBOARD_SWITCH_CHANGED = 4000;
+
static final long TIME_TO_RECONNECT = 10*1000;
static final int SECURE_SUGGESTION_SPANS_MAX_SIZE = 20;
@@ -156,6 +162,8 @@
final HandlerCaller mCaller;
private final InputMethodFileManager mFileManager;
private final InputMethodAndSubtypeListManager mImListManager;
+ private final HardKeyboardListener mHardKeyboardListener;
+ private final WindowManagerService mWindowManagerService;
final InputBindResult mNoBinding = new InputBindResult(null, null, -1);
@@ -360,6 +368,7 @@
private AlertDialog.Builder mDialogBuilder;
private AlertDialog mSwitchingDialog;
+ private View mSwitchingDialogTitleView;
private InputMethodInfo[] mIms;
private int[] mSubtypeIds;
@@ -528,7 +537,31 @@
}
}
- public InputMethodManagerService(Context context) {
+ private class HardKeyboardListener
+ implements WindowManagerService.OnHardKeyboardStatusChangeListener {
+ @Override
+ public void onHardKeyboardStatusChange(boolean available, boolean enabled) {
+ mHandler.sendMessage(mHandler.obtainMessage(
+ MSG_HARD_KEYBOARD_SWITCH_CHANGED, available ? 1 : 0, enabled ? 1 : 0));
+ }
+
+ public void handleHardKeyboardStatusChange(boolean available, boolean enabled) {
+ if (DEBUG) {
+ Slog.w(TAG, "HardKeyboardStatusChanged: available = " + available + ", enabled = "
+ + enabled);
+ }
+ synchronized(mMethodMap) {
+ if (mSwitchingDialog != null && mSwitchingDialogTitleView != null
+ && mSwitchingDialog.isShowing()) {
+ mSwitchingDialogTitleView.findViewById(
+ com.android.internal.R.id.hard_keyboard_section).setVisibility(
+ available ? View.VISIBLE : View.GONE);
+ }
+ }
+ }
+ }
+
+ public InputMethodManagerService(Context context, WindowManagerService windowManager) {
mContext = context;
mRes = context.getResources();
mHandler = new Handler(this);
@@ -540,6 +573,8 @@
handleMessage(msg);
}
});
+ mWindowManagerService = windowManager;
+ mHardKeyboardListener = new HardKeyboardListener();
mImeSwitcherNotification = new Notification();
mImeSwitcherNotification.icon = com.android.internal.R.drawable.ic_notification_ime_default;
@@ -633,6 +668,10 @@
updateImeWindowStatusLocked();
mShowOngoingImeSwitcherForPhones = mRes.getBoolean(
com.android.internal.R.bool.show_ongoing_ime_switcher);
+ if (mShowOngoingImeSwitcherForPhones) {
+ mWindowManagerService.setOnHardKeyboardStatusChangeListener(
+ mHardKeyboardListener);
+ }
try {
startInputInnerLocked();
} catch (RuntimeException e) {
@@ -1994,6 +2033,12 @@
Slog.w(TAG, "Client died receiving input method " + args.arg2);
}
return true;
+
+ // --------------------------------------------------------------
+ case MSG_HARD_KEYBOARD_SWITCH_CHANGED:
+ mHardKeyboardListener.handleHardKeyboardStatusChange(
+ msg.arg1 == 1, msg.arg2 == 1);
+ return true;
}
return false;
}
@@ -2204,12 +2249,10 @@
}
}
}
-
final TypedArray a = context.obtainStyledAttributes(null,
com.android.internal.R.styleable.DialogPreference,
com.android.internal.R.attr.alertDialogStyle, 0);
mDialogBuilder = new AlertDialog.Builder(context)
- .setTitle(com.android.internal.R.string.select_input_method)
.setOnCancelListener(new OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
@@ -2219,6 +2262,29 @@
.setIcon(a.getDrawable(
com.android.internal.R.styleable.DialogPreference_dialogTitle));
a.recycle();
+ final LayoutInflater inflater =
+ (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ final View tv = inflater.inflate(
+ com.android.internal.R.layout.input_method_switch_dialog_title, null);
+ mDialogBuilder.setCustomTitle(tv);
+
+ // Setup layout for a toggle switch of the hardware keyboard
+ mSwitchingDialogTitleView = tv;
+ mSwitchingDialogTitleView.findViewById(
+ com.android.internal.R.id.hard_keyboard_section).setVisibility(
+ mWindowManagerService.isHardKeyboardAvailable() ?
+ View.VISIBLE : View.GONE);
+ final Switch hardKeySwitch = ((Switch)mSwitchingDialogTitleView.findViewById(
+ com.android.internal.R.id.hard_keyboard_switch));
+ hardKeySwitch.setChecked(mWindowManagerService.isHardKeyboardEnabled());
+ hardKeySwitch.setOnCheckedChangeListener(
+ new OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(
+ CompoundButton buttonView, boolean isChecked) {
+ mWindowManagerService.setHardKeyboardEnabled(isChecked);
+ }
+ });
final ImeSubtypeListAdapter adapter = new ImeSubtypeListAdapter(context,
com.android.internal.R.layout.simple_list_item_2_single_choice, imList,
diff --git a/services/java/com/android/server/PowerManagerService.java b/services/java/com/android/server/PowerManagerService.java
index bebce7e..2d2a881 100644
--- a/services/java/com/android/server/PowerManagerService.java
+++ b/services/java/com/android/server/PowerManagerService.java
@@ -1795,7 +1795,7 @@
final boolean stateChanged = mPowerState != newState;
if (stateChanged && reason == WindowManagerPolicy.OFF_BECAUSE_OF_TIMEOUT) {
- if (mPolicy.isScreenSaverEnabled()) {
+ if (mPolicy != null && mPolicy.isScreenSaverEnabled()) {
if (mSpew) {
Slog.d(TAG, "setPowerState: running screen saver instead of turning off screen");
}
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
index 68bbb571..241d04ff 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -276,7 +276,7 @@
if (factoryTest != SystemServer.FACTORY_TEST_LOW_LEVEL) {
try {
Slog.i(TAG, "Input Method Service");
- imm = new InputMethodManagerService(context);
+ imm = new InputMethodManagerService(context, wm);
ServiceManager.addService(Context.INPUT_METHOD_SERVICE, imm);
} catch (Throwable e) {
reportWtf("starting Input Manager Service", e);
diff --git a/services/java/com/android/server/wm/WindowAnimator.java b/services/java/com/android/server/wm/WindowAnimator.java
index 1198a77..0be6612 100644
--- a/services/java/com/android/server/wm/WindowAnimator.java
+++ b/services/java/com/android/server/wm/WindowAnimator.java
@@ -453,7 +453,7 @@
mDimAnimator.updateParameters(mContext.getResources(), mDimParams, mCurrentTime);
}
if (mDimAnimator != null && mDimAnimator.mDimShown) {
- mAnimating |= mDimAnimator.updateSurface(mDimParams != null, mCurrentTime,
+ mAnimating |= mDimAnimator.updateSurface(isDimming(), mCurrentTime,
!mService.okToDisplay());
}
@@ -501,6 +501,10 @@
mService.mH.sendMessage(mService.mH.obtainMessage(SET_DIM_PARAMETERS, null));
}
+ boolean isDimming() {
+ return mDimParams != null;
+ }
+
public void dump(PrintWriter pw, String prefix, boolean dumpAll) {
if (mWindowDetachedWallpaper != null) {
pw.print(" mWindowDetachedWallpaper="); pw.println(mWindowDetachedWallpaper);
diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java
index 8d65dc3..d9425aab 100644
--- a/services/java/com/android/server/wm/WindowManagerService.java
+++ b/services/java/com/android/server/wm/WindowManagerService.java
@@ -8021,16 +8021,18 @@
if (!mInnerFields.mDimming) {
//Slog.i(TAG, "DIM BEHIND: " + w);
mInnerFields.mDimming = true;
- final int width, height;
- if (attrs.type == WindowManager.LayoutParams.TYPE_BOOT_PROGRESS) {
- width = mCurDisplayWidth;
- height = mCurDisplayHeight;
- } else {
- width = innerDw;
- height = innerDh;
+ if (!mAnimator.isDimming()) {
+ final int width, height;
+ if (attrs.type == WindowManager.LayoutParams.TYPE_BOOT_PROGRESS) {
+ width = mCurDisplayWidth;
+ height = mCurDisplayHeight;
+ } else {
+ width = innerDw;
+ height = innerDh;
+ }
+ mAnimator.startDimming(w.mWinAnimator, w.mExiting ? 0 : w.mAttrs.dimAmount,
+ width, height);
}
- mAnimator.startDimming(w.mWinAnimator, w.mExiting ? 0 : w.mAttrs.dimAmount,
- width, height);
}
}
}
@@ -8180,7 +8182,7 @@
updateWallpaperVisibilityLocked();
}
}
- if (!mInnerFields.mDimming && mAnimator.mDimParams != null) {
+ if (!mInnerFields.mDimming && mAnimator.isDimming()) {
mAnimator.stopDimming();
}
} catch (RuntimeException e) {