am 3c89f6d1
: Merge "Add "Use physical keyboard" option to system bar IME button." into honeycomb
* commit '3c89f6d1bd0821d0ae0205a5b48176156735aaac': Add "Use physical keyboard" option to system bar IME button.
This commit is contained in:
@ -33,5 +33,6 @@ oneway interface IStatusBar
|
||||
void setLightsOn(boolean on);
|
||||
void setMenuKeyVisible(boolean visible);
|
||||
void setImeWindowStatus(in IBinder token, int vis, int backDisposition);
|
||||
void setHardKeyboardStatus(boolean available, boolean enabled);
|
||||
}
|
||||
|
||||
|
@ -45,4 +45,5 @@ interface IStatusBarService
|
||||
void onClearAllNotifications();
|
||||
void onNotificationClear(String pkg, String tag, int id);
|
||||
void setSystemUiVisibility(int vis);
|
||||
void setHardKeyboardEnabled(boolean enabled);
|
||||
}
|
||||
|
@ -38,6 +38,47 @@
|
||||
android:layout_marginLeft="20dip"
|
||||
android:orientation="vertical"
|
||||
android:background="@*android:drawable/dialog_full_holo_dark">
|
||||
<!-- Hard keyboard switch -->
|
||||
<LinearLayout
|
||||
android:id="@+id/hard_keyboard_section"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:orientation="vertical">
|
||||
<LinearLayout
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:orientation="horizontal">
|
||||
<TextView
|
||||
android:id="@+id/use_physical_keyboard_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:orientation="vertical"
|
||||
android:paddingRight="6dip"
|
||||
android:paddingLeft="30dip"
|
||||
android:paddingTop="5dip"
|
||||
android:paddingBottom="5dip"
|
||||
android:gravity="center_vertical"
|
||||
android:singleLine="true"
|
||||
android:text="@string/status_bar_use_physical_keyboard"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:ellipsize="marquee" />
|
||||
<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="16dip" />
|
||||
</LinearLayout>
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dip"
|
||||
android:background="@android:drawable/divider_horizontal_dark" />
|
||||
</LinearLayout>
|
||||
|
||||
<!-- Input method list -->
|
||||
<ScrollView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
@ -50,6 +91,8 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical" />
|
||||
</ScrollView>
|
||||
|
||||
<!-- Configure input methods -->
|
||||
<TextView
|
||||
android:id="@+id/ime_settings_shortcut"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -43,4 +43,5 @@
|
||||
<!-- outdated translation 5550538721034982973 --> <string name="recent_tasks_app_label" msgid="3796483981246752469">"Google Apps"</string>
|
||||
<!-- outdated translation 8017158699581472359 --> <string name="bluetooth_tethered" msgid="7094101612161133267">"Bluetooth anclado"</string>
|
||||
<!-- outdated translation 3875357213648023768 --> <string name="status_bar_input_method_settings_configure_input_methods" msgid="737483394044014246">"Configurar métodos de entrada"</string>
|
||||
<string name="status_bar_use_physical_keyboard">"Usar un teclado externo"</string>
|
||||
</resources>
|
||||
|
@ -112,4 +112,7 @@
|
||||
<string name="bluetooth_tethered">Bluetooth tethered</string>
|
||||
<!-- Title of a button to open the settings for input methods [CHAR LIMIT=30] -->
|
||||
<string name="status_bar_input_method_settings_configure_input_methods">Configure 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>
|
||||
</resources>
|
||||
|
@ -56,6 +56,7 @@ public class CommandQueue extends IStatusBar.Stub {
|
||||
|
||||
private static final int MSG_SHOW_MENU = 0x00080000;
|
||||
private static final int MSG_SHOW_IME_BUTTON = 0x00090000;
|
||||
private static final int MSG_SET_HARD_KEYBOARD_STATUS = 0x000a0000;
|
||||
|
||||
private StatusBarIconList mList;
|
||||
private Callbacks mCallbacks;
|
||||
@ -83,6 +84,7 @@ public class CommandQueue extends IStatusBar.Stub {
|
||||
public void setLightsOn(boolean on);
|
||||
public void setMenuKeyVisible(boolean visible);
|
||||
public void setImeWindowStatus(IBinder token, int vis, int backDisposition);
|
||||
public void setHardKeyboardStatus(boolean available, boolean enabled);
|
||||
}
|
||||
|
||||
public CommandQueue(Callbacks callbacks, StatusBarIconList list) {
|
||||
@ -173,6 +175,14 @@ public class CommandQueue extends IStatusBar.Stub {
|
||||
}
|
||||
}
|
||||
|
||||
public void setHardKeyboardStatus(boolean available, boolean enabled) {
|
||||
synchronized (mList) {
|
||||
mHandler.removeMessages(MSG_SET_HARD_KEYBOARD_STATUS);
|
||||
mHandler.obtainMessage(MSG_SET_HARD_KEYBOARD_STATUS,
|
||||
available ? 1 : 0, enabled ? 1 : 0).sendToTarget();
|
||||
}
|
||||
}
|
||||
|
||||
private final class H extends Handler {
|
||||
public void handleMessage(Message msg) {
|
||||
final int what = msg.what & MSG_MASK;
|
||||
@ -236,6 +246,9 @@ public class CommandQueue extends IStatusBar.Stub {
|
||||
case MSG_SHOW_IME_BUTTON:
|
||||
mCallbacks.setImeWindowStatus((IBinder)msg.obj, msg.arg1, msg.arg2);
|
||||
break;
|
||||
case MSG_SET_HARD_KEYBOARD_STATUS:
|
||||
mCallbacks.setHardKeyboardStatus(msg.arg1 != 0, msg.arg2 != 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ public abstract class StatusBar extends SystemUI implements CommandQueue.Callbac
|
||||
mCommandQueue = new CommandQueue(this, iconList);
|
||||
mBarService = IStatusBarService.Stub.asInterface(
|
||||
ServiceManager.getService(Context.STATUS_BAR_SERVICE));
|
||||
int[] switches = new int[5];
|
||||
int[] switches = new int[7];
|
||||
ArrayList<IBinder> binders = new ArrayList<IBinder>();
|
||||
try {
|
||||
mBarService.registerStatusBar(mCommandQueue, iconList, notificationKeys, notifications,
|
||||
@ -81,6 +81,7 @@ public abstract class StatusBar extends SystemUI implements CommandQueue.Callbac
|
||||
setMenuKeyVisible(switches[2] != 0);
|
||||
// StatusBarManagerService has a back up of IME token and it's restored here.
|
||||
setImeWindowStatus(binders.get(0), switches[3], switches[4]);
|
||||
setHardKeyboardStatus(switches[5] != 0, switches[6] != 0);
|
||||
|
||||
// Set up the initial icon state
|
||||
int N = iconList.size();
|
||||
|
@ -1021,6 +1021,8 @@ public class PhoneStatusBar extends StatusBar {
|
||||
// Not supported
|
||||
public void setMenuKeyVisible(boolean visible) { }
|
||||
public void setImeWindowStatus(IBinder token, int vis, int backDisposition) { }
|
||||
@Override
|
||||
public void setHardKeyboardStatus(boolean available, boolean enabled) { }
|
||||
|
||||
private class Launcher implements View.OnClickListener {
|
||||
private PendingIntent mIntent;
|
||||
|
@ -17,32 +17,23 @@
|
||||
package com.android.systemui.statusbar.tablet;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.IBinder;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.inputmethod.InputMethodInfo;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.view.inputmethod.InputMethodSubtype;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.android.systemui.R;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class InputMethodButton extends ImageView {
|
||||
|
||||
private static final String TAG = "StatusBar/InputMethodButton";
|
||||
private static final boolean DEBUG = false;
|
||||
|
||||
private static final int ID_IME_SWITCH_BUTTON = R.id.imeSwitchButton;
|
||||
// IME shortcut button is disabled.
|
||||
private static final int ID_IME_SHORTCUT_BUTTON = 0;
|
||||
|
||||
// These values are defined in Settings application.
|
||||
private static final int ID_IME_BUTTON_VISIBILITY_AUTO = 0;
|
||||
private static final int ID_IME_BUTTON_VISIBILITY_ALWAYS_SHOW = 1;
|
||||
@ -55,8 +46,7 @@ public class InputMethodButton extends ImageView {
|
||||
private IBinder mToken;
|
||||
private boolean mShowButton = false;
|
||||
private boolean mScreenLocked = false;
|
||||
private InputMethodInfo mShortcutInfo;
|
||||
private InputMethodSubtype mShortcutSubtype;
|
||||
private boolean mHardKeyboardAvailable;
|
||||
|
||||
public InputMethodButton(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
@ -65,26 +55,6 @@ public class InputMethodButton extends ImageView {
|
||||
mId = getId();
|
||||
// IME hookup
|
||||
mImm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
// TODO: read the current icon & visibility state directly from the service
|
||||
|
||||
// TODO: register for notifications about changes to visibility & subtype from service
|
||||
|
||||
setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (mId) {
|
||||
case ID_IME_SWITCH_BUTTON:
|
||||
mImm.showInputMethodPicker();
|
||||
break;
|
||||
case ID_IME_SHORTCUT_BUTTON:
|
||||
if (mToken != null && mShortcutInfo != null) {
|
||||
mImm.setInputMethodAndSubtype(
|
||||
mToken, mShortcutInfo.getId(), mShortcutSubtype);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -94,57 +64,17 @@ public class InputMethodButton extends ImageView {
|
||||
refreshStatusIcon();
|
||||
}
|
||||
|
||||
// TODO: Need to show an appropriate drawable for this shortcut button,
|
||||
// if there are two or more shortcut input methods contained in this button.
|
||||
// And need to add other methods to handle multiple shortcuts as appropriate.
|
||||
private Drawable getShortcutInputMethodAndSubtypeDrawable() {
|
||||
Map<InputMethodInfo, List<InputMethodSubtype>> shortcuts =
|
||||
mImm.getShortcutInputMethodsAndSubtypes();
|
||||
if (shortcuts.size() > 0) {
|
||||
for (InputMethodInfo imi: shortcuts.keySet()) {
|
||||
List<InputMethodSubtype> subtypes = shortcuts.get(imi);
|
||||
// TODO: Returns the first found IMI for now. Should handle all shortcuts as
|
||||
// appropriate.
|
||||
mShortcutInfo = imi;
|
||||
// TODO: Pick up the first found subtype for now. Should handle all subtypes
|
||||
// as appropriate.
|
||||
mShortcutSubtype = subtypes.size() > 0 ? subtypes.get(0) : null;
|
||||
return getSubtypeIcon(mShortcutInfo, mShortcutSubtype);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private Drawable getSubtypeIcon(InputMethodInfo imi, InputMethodSubtype subtype) {
|
||||
final PackageManager pm = getContext().getPackageManager();
|
||||
if (imi != null) {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "Update icons of IME: " + imi.getPackageName());
|
||||
}
|
||||
if (subtype != null) {
|
||||
return pm.getDrawable(imi.getPackageName(), subtype.getIconResId(),
|
||||
imi.getServiceInfo().applicationInfo);
|
||||
} else if (imi.getSubtypeCount() > 0) {
|
||||
return pm.getDrawable(imi.getPackageName(),
|
||||
imi.getSubtypeAt(0).getIconResId(),
|
||||
imi.getServiceInfo().applicationInfo);
|
||||
} else {
|
||||
try {
|
||||
return pm.getApplicationInfo(imi.getPackageName(), 0).loadIcon(pm);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
Log.w(TAG, "IME can't be found: " + imi.getPackageName());
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Display IME switcher icon only when all of the followings are true:
|
||||
// * There is only one enabled IME on the device. (Note that the IME should be the system IME)
|
||||
// * There are no explicitly enabled (by the user) subtypes of the IME, or the IME doesn't have
|
||||
// its subtypes at all
|
||||
private boolean needsToShowIMEButton() {
|
||||
if (!mShowButton || mScreenLocked) return false;
|
||||
|
||||
if (mHardKeyboardAvailable) {
|
||||
return true;
|
||||
}
|
||||
|
||||
List<InputMethodInfo> imis = mImm.getEnabledInputMethodList();
|
||||
final int size = imis.size();
|
||||
final int visibility = loadInputMethodSelectorVisibility();
|
||||
@ -170,17 +100,7 @@ public class InputMethodButton extends ImageView {
|
||||
} else {
|
||||
setVisibility(View.VISIBLE);
|
||||
}
|
||||
Drawable icon = null;
|
||||
switch (mId) {
|
||||
case ID_IME_SHORTCUT_BUTTON:
|
||||
icon = getShortcutInputMethodAndSubtypeDrawable();
|
||||
break;
|
||||
}
|
||||
if (icon == null) {
|
||||
mIcon.setImageResource(R.drawable.ic_sysbar_ime);
|
||||
} else {
|
||||
mIcon.setImageDrawable(icon);
|
||||
}
|
||||
mIcon.setImageResource(R.drawable.ic_sysbar_ime);
|
||||
}
|
||||
|
||||
private int loadInputMethodSelectorVisibility() {
|
||||
@ -200,6 +120,13 @@ public class InputMethodButton extends ImageView {
|
||||
refreshStatusIcon();
|
||||
}
|
||||
|
||||
public void setHardKeyboardStatus(boolean available) {
|
||||
if (mHardKeyboardAvailable != available) {
|
||||
mHardKeyboardAvailable = available;
|
||||
refreshStatusIcon();
|
||||
}
|
||||
}
|
||||
|
||||
public void setScreenLocked(boolean locked) {
|
||||
mScreenLocked = locked;
|
||||
refreshStatusIcon();
|
||||
|
@ -23,11 +23,13 @@ import android.content.IntentFilter;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
import android.util.Slog;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.inputmethod.InputMethodInfo;
|
||||
@ -36,6 +38,7 @@ import android.view.inputmethod.InputMethodSubtype;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.Switch;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.Comparator;
|
||||
@ -45,6 +48,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import com.android.internal.statusbar.IStatusBarService;
|
||||
import com.android.systemui.R;
|
||||
|
||||
public class InputMethodsPanel extends LinearLayout implements StatusBarPanel, OnClickListener {
|
||||
@ -73,6 +77,11 @@ public class InputMethodsPanel extends LinearLayout implements StatusBarPanel, O
|
||||
private IBinder mToken;
|
||||
private InputMethodButton mInputMethodSwitchButton;
|
||||
private LinearLayout mInputMethodMenuList;
|
||||
private boolean mHardKeyboardAvailable;
|
||||
private boolean mHardKeyboardEnabled;
|
||||
private OnHardKeyboardEnabledChangeListener mHardKeyboardEnabledChangeListener;
|
||||
private LinearLayout mHardKeyboardSection;
|
||||
private Switch mHardKeyboardSwitch;
|
||||
private PackageManager mPackageManager;
|
||||
private String mEnabledInputMethodAndSubtypesCacheStr;
|
||||
private String mLastSystemLocaleString;
|
||||
@ -107,6 +116,11 @@ public class InputMethodsPanel extends LinearLayout implements StatusBarPanel, O
|
||||
mIntentFilter.addDataScheme("package");
|
||||
}
|
||||
|
||||
public void setHardKeyboardEnabledChangeListener(
|
||||
OnHardKeyboardEnabledChangeListener listener) {
|
||||
mHardKeyboardEnabledChangeListener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
@ -128,6 +142,9 @@ public class InputMethodsPanel extends LinearLayout implements StatusBarPanel, O
|
||||
@Override
|
||||
public void onFinishInflate() {
|
||||
mInputMethodMenuList = (LinearLayout) findViewById(R.id.input_method_menu_list);
|
||||
mHardKeyboardSection = (LinearLayout) findViewById(R.id.hard_keyboard_section);
|
||||
mHardKeyboardSwitch = (Switch) findViewById(R.id.hard_keyboard_switch);
|
||||
mHardKeyboardSwitch.setOnClickListener(this);
|
||||
mConfigureImeShortcut = ((View) findViewById(R.id.ime_settings_shortcut));
|
||||
mConfigureImeShortcut.setOnClickListener(this);
|
||||
// TODO: If configurations for IME are not changed, do not update
|
||||
@ -162,7 +179,9 @@ public class InputMethodsPanel extends LinearLayout implements StatusBarPanel, O
|
||||
if (view == mConfigureImeShortcut) {
|
||||
showConfigureInputMethods();
|
||||
onFinishPanel(true);
|
||||
return;
|
||||
} else if (view == mHardKeyboardSwitch) {
|
||||
mHardKeyboardEnabled = mHardKeyboardSwitch.isChecked();
|
||||
mHardKeyboardEnabledChangeListener.onHardKeyboardEnabledChange(mHardKeyboardEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
@ -239,6 +258,8 @@ public class InputMethodsPanel extends LinearLayout implements StatusBarPanel, O
|
||||
}
|
||||
|
||||
private void updateUiElements() {
|
||||
updateHardKeyboardSection();
|
||||
|
||||
// TODO: Reuse subtype views.
|
||||
mInputMethodMenuList.removeAllViews();
|
||||
mRadioViewAndImiMap.clear();
|
||||
@ -278,6 +299,23 @@ public class InputMethodsPanel extends LinearLayout implements StatusBarPanel, O
|
||||
}
|
||||
}
|
||||
|
||||
public void setHardKeyboardStatus(boolean available, boolean enabled) {
|
||||
if (mHardKeyboardAvailable != available || mHardKeyboardEnabled != enabled) {
|
||||
mHardKeyboardAvailable = available;
|
||||
mHardKeyboardEnabled = enabled;
|
||||
updateHardKeyboardSection();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateHardKeyboardSection() {
|
||||
if (mHardKeyboardAvailable) {
|
||||
mHardKeyboardSection.setVisibility(View.VISIBLE);
|
||||
mHardKeyboardSwitch.setChecked(mHardKeyboardEnabled);
|
||||
} else {
|
||||
mHardKeyboardSection.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
// Turn on the selected radio button when the user chooses the item
|
||||
private Pair<InputMethodInfo, InputMethodSubtype> updateRadioButtonsByView(View selectedView) {
|
||||
Pair<InputMethodInfo, InputMethodSubtype> selectedImiAndSubtype = null;
|
||||
@ -423,4 +461,8 @@ public class InputMethodsPanel extends LinearLayout implements StatusBarPanel, O
|
||||
}
|
||||
mPackageChanged = true;
|
||||
}
|
||||
|
||||
public interface OnHardKeyboardEnabledChangeListener {
|
||||
public void onHardKeyboardEnabledChange(boolean enabled);
|
||||
}
|
||||
}
|
||||
|
@ -76,7 +76,8 @@ import com.android.systemui.statusbar.policy.NetworkController;
|
||||
import com.android.systemui.recent.RecentApplicationsActivity;
|
||||
|
||||
public class TabletStatusBar extends StatusBar implements
|
||||
HeightReceiver.OnBarHeightChangedListener {
|
||||
HeightReceiver.OnBarHeightChangedListener,
|
||||
InputMethodsPanel.OnHardKeyboardEnabledChangeListener {
|
||||
public static final boolean DEBUG = false;
|
||||
public static final String TAG = "TabletStatusBar";
|
||||
|
||||
@ -268,6 +269,7 @@ public class TabletStatusBar extends StatusBar implements
|
||||
// Input methods Panel
|
||||
mInputMethodsPanel = (InputMethodsPanel) View.inflate(context,
|
||||
R.layout.status_bar_input_methods_panel, null);
|
||||
mInputMethodsPanel.setHardKeyboardEnabledChangeListener(this);
|
||||
mInputMethodsPanel.setVisibility(View.GONE);
|
||||
mInputMethodsPanel.setOnTouchListener(new TouchOutsideListener(
|
||||
MSG_CLOSE_INPUT_METHODS_PANEL, mInputMethodsPanel));
|
||||
@ -905,6 +907,25 @@ public class TabletStatusBar extends StatusBar implements
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHardKeyboardStatus(boolean available, boolean enabled) {
|
||||
if (DEBUG) {
|
||||
Slog.d(TAG, "Set hard keyboard status: available=" + available
|
||||
+ ", enabled=" + enabled);
|
||||
}
|
||||
mInputMethodSwitchButton.setHardKeyboardStatus(available);
|
||||
updateNotificationIcons();
|
||||
mInputMethodsPanel.setHardKeyboardStatus(available, enabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHardKeyboardEnabledChange(boolean enabled) {
|
||||
try {
|
||||
mBarService.setHardKeyboardEnabled(enabled);
|
||||
} catch (RemoteException ex) {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isImmersive() {
|
||||
try {
|
||||
return ActivityManagerNative.getDefault().isTopActivityImmersive();
|
||||
|
@ -53,11 +53,13 @@ import java.util.Map;
|
||||
* if they are local, that they just enqueue messages to not deadlock.
|
||||
*/
|
||||
public class StatusBarManagerService extends IStatusBarService.Stub
|
||||
implements WindowManagerService.OnHardKeyboardStatusChangeListener
|
||||
{
|
||||
static final String TAG = "StatusBarManagerService";
|
||||
static final boolean SPEW = false;
|
||||
|
||||
final Context mContext;
|
||||
final WindowManagerService mWindowManager;
|
||||
Handler mHandler = new Handler();
|
||||
NotificationCallbacks mNotificationCallbacks;
|
||||
volatile IStatusBar mBar;
|
||||
@ -103,8 +105,10 @@ public class StatusBarManagerService extends IStatusBarService.Stub
|
||||
/**
|
||||
* Construct the service, add the status bar view to the window manager
|
||||
*/
|
||||
public StatusBarManagerService(Context context) {
|
||||
public StatusBarManagerService(Context context, WindowManagerService windowManager) {
|
||||
mContext = context;
|
||||
mWindowManager = windowManager;
|
||||
mWindowManager.setOnHardKeyboardStatusChangeListener(this);
|
||||
|
||||
final Resources res = context.getResources();
|
||||
mIcons.defineSlots(res.getStringArray(com.android.internal.R.array.config_statusBarIcons));
|
||||
@ -320,6 +324,28 @@ public class StatusBarManagerService extends IStatusBarService.Stub
|
||||
}
|
||||
}
|
||||
|
||||
public void setHardKeyboardEnabled(final boolean enabled) {
|
||||
mHandler.post(new Runnable() {
|
||||
public void run() {
|
||||
mWindowManager.setHardKeyboardEnabled(enabled);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHardKeyboardStatusChange(final boolean available, final boolean enabled) {
|
||||
mHandler.post(new Runnable() {
|
||||
public void run() {
|
||||
if (mBar != null) {
|
||||
try {
|
||||
mBar.setHardKeyboardStatus(available, enabled);
|
||||
} catch (RemoteException ex) {
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void enforceStatusBar() {
|
||||
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.STATUS_BAR,
|
||||
"StatusBarManagerService");
|
||||
@ -335,7 +361,6 @@ public class StatusBarManagerService extends IStatusBarService.Stub
|
||||
"StatusBarManagerService");
|
||||
}
|
||||
|
||||
|
||||
// ================================================================================
|
||||
// Callbacks from the status bar service.
|
||||
// ================================================================================
|
||||
@ -363,6 +388,8 @@ public class StatusBarManagerService extends IStatusBarService.Stub
|
||||
switches[4] = mImeBackDisposition;
|
||||
binders.add(mImeToken);
|
||||
}
|
||||
switches[5] = mWindowManager.isHardKeyboardAvailable() ? 1 : 0;
|
||||
switches[6] = mWindowManager.isHardKeyboardEnabled() ? 1 : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -248,7 +248,7 @@ class ServerThread extends Thread {
|
||||
|
||||
try {
|
||||
Slog.i(TAG, "Status Bar");
|
||||
statusBar = new StatusBarManagerService(context);
|
||||
statusBar = new StatusBarManagerService(context, wm);
|
||||
ServiceManager.addService(Context.STATUS_BAR_SERVICE, statusBar);
|
||||
} catch (Throwable e) {
|
||||
Slog.e(TAG, "Failure starting StatusBarManagerService", e);
|
||||
|
@ -454,6 +454,10 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
WindowState mInputMethodWindow = null;
|
||||
final ArrayList<WindowState> mInputMethodDialogs = new ArrayList<WindowState>();
|
||||
|
||||
boolean mHardKeyboardAvailable;
|
||||
boolean mHardKeyboardEnabled;
|
||||
OnHardKeyboardStatusChangeListener mHardKeyboardStatusChangeListener;
|
||||
|
||||
final ArrayList<WindowToken> mWallpaperTokens = new ArrayList<WindowToken>();
|
||||
|
||||
// If non-null, this is the currently visible window that is associated
|
||||
@ -5776,9 +5780,64 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
config.keyboardHidden = Configuration.KEYBOARDHIDDEN_NO;
|
||||
config.hardKeyboardHidden = Configuration.HARDKEYBOARDHIDDEN_NO;
|
||||
mPolicy.adjustConfigurationLw(config);
|
||||
|
||||
// Adjust the hard keyboard configuration based on whether the hard keyboard is enabled.
|
||||
boolean hardKeyboardAvailable = config.keyboard != Configuration.KEYBOARD_NOKEYS;
|
||||
if (hardKeyboardAvailable != mHardKeyboardAvailable) {
|
||||
mHardKeyboardAvailable = hardKeyboardAvailable;
|
||||
mHardKeyboardEnabled = hardKeyboardAvailable;
|
||||
|
||||
mH.removeMessages(H.REPORT_HARD_KEYBOARD_STATUS_CHANGE);
|
||||
mH.sendEmptyMessage(H.REPORT_HARD_KEYBOARD_STATUS_CHANGE);
|
||||
}
|
||||
if (!mHardKeyboardEnabled) {
|
||||
config.keyboard = Configuration.KEYBOARD_NOKEYS;
|
||||
config.hardKeyboardHidden = Configuration.HARDKEYBOARDHIDDEN_NO;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isHardKeyboardAvailable() {
|
||||
synchronized (mWindowMap) {
|
||||
return mHardKeyboardAvailable;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isHardKeyboardEnabled() {
|
||||
synchronized (mWindowMap) {
|
||||
return mHardKeyboardEnabled;
|
||||
}
|
||||
}
|
||||
|
||||
public void setHardKeyboardEnabled(boolean enabled) {
|
||||
synchronized (mWindowMap) {
|
||||
if (mHardKeyboardEnabled != enabled) {
|
||||
mHardKeyboardEnabled = enabled;
|
||||
mH.sendEmptyMessage(H.SEND_NEW_CONFIGURATION);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setOnHardKeyboardStatusChangeListener(
|
||||
OnHardKeyboardStatusChangeListener listener) {
|
||||
synchronized (mWindowMap) {
|
||||
mHardKeyboardStatusChangeListener = listener;
|
||||
}
|
||||
}
|
||||
|
||||
void notifyHardKeyboardStatusChange() {
|
||||
final boolean available, enabled;
|
||||
final OnHardKeyboardStatusChangeListener listener;
|
||||
synchronized (mWindowMap) {
|
||||
listener = mHardKeyboardStatusChangeListener;
|
||||
available = mHardKeyboardAvailable;
|
||||
enabled = mHardKeyboardEnabled;
|
||||
}
|
||||
if (listener != null) {
|
||||
listener.onHardKeyboardStatusChange(available, enabled);
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------
|
||||
// Drag and drop
|
||||
// -------------------------------------------------------------
|
||||
@ -8869,6 +8928,7 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
public static final int REPORT_WINDOWS_CHANGE = 19;
|
||||
public static final int DRAG_START_TIMEOUT = 20;
|
||||
public static final int DRAG_END_TIMEOUT = 21;
|
||||
public static final int REPORT_HARD_KEYBOARD_STATUS_CHANGE = 22;
|
||||
|
||||
private Session mLastReportedHold;
|
||||
|
||||
@ -9242,6 +9302,11 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case REPORT_HARD_KEYBOARD_STATUS_CHANGE: {
|
||||
notifyHardKeyboardStatusChange();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -11988,4 +12053,8 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
return Animation.ZORDER_TOP;
|
||||
}
|
||||
}
|
||||
|
||||
public interface OnHardKeyboardStatusChangeListener {
|
||||
public void onHardKeyboardStatusChange(boolean available, boolean enabled);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user