am c0e0b1e3: am 646f9da9: am 4ff108f0: am 0526ee52: Merge "Don\'t rely on broadcast intent for waking up input method." into mnc-dev
* commit 'c0e0b1e3145bb26db2f41ac9d885c3368f2f6f75': Don't rely on broadcast intent for waking up input method.
This commit is contained in:
@@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2015 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package android.view.inputmethod;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Input method manager local system service interface.
|
||||||
|
*
|
||||||
|
* @hide Only for use within the system server.
|
||||||
|
*/
|
||||||
|
public interface InputMethodManagerInternal {
|
||||||
|
/**
|
||||||
|
* Called by the power manager to tell the input method manager whether it
|
||||||
|
* should start watching for wake events.
|
||||||
|
*/
|
||||||
|
public void setInteractive(boolean interactive);
|
||||||
|
}
|
||||||
@@ -114,6 +114,7 @@ import android.view.inputmethod.InputBinding;
|
|||||||
import android.view.inputmethod.InputMethod;
|
import android.view.inputmethod.InputMethod;
|
||||||
import android.view.inputmethod.InputMethodInfo;
|
import android.view.inputmethod.InputMethodInfo;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
|
import android.view.inputmethod.InputMethodManagerInternal;
|
||||||
import android.view.inputmethod.InputMethodSubtype;
|
import android.view.inputmethod.InputMethodSubtype;
|
||||||
import android.view.inputmethod.InputMethodSubtype.InputMethodSubtypeBuilder;
|
import android.view.inputmethod.InputMethodSubtype.InputMethodSubtypeBuilder;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
@@ -166,6 +167,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
static final int MSG_UNBIND_METHOD = 3000;
|
static final int MSG_UNBIND_METHOD = 3000;
|
||||||
static final int MSG_BIND_METHOD = 3010;
|
static final int MSG_BIND_METHOD = 3010;
|
||||||
static final int MSG_SET_ACTIVE = 3020;
|
static final int MSG_SET_ACTIVE = 3020;
|
||||||
|
static final int MSG_SET_INTERACTIVE = 3030;
|
||||||
static final int MSG_SET_USER_ACTION_NOTIFICATION_SEQUENCE_NUMBER = 3040;
|
static final int MSG_SET_USER_ACTION_NOTIFICATION_SEQUENCE_NUMBER = 3040;
|
||||||
|
|
||||||
static final int MSG_HARD_KEYBOARD_SWITCH_CHANGED = 4000;
|
static final int MSG_HARD_KEYBOARD_SWITCH_CHANGED = 4000;
|
||||||
@@ -394,9 +396,9 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
SessionState mEnabledSession;
|
SessionState mEnabledSession;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* True if the screen is on. The value is true initially.
|
* True if the device is currently interactive with user. The value is true initially.
|
||||||
*/
|
*/
|
||||||
boolean mScreenOn = true;
|
boolean mIsInteractive = true;
|
||||||
|
|
||||||
int mCurUserActionNotificationSequenceNumber = 0;
|
int mCurUserActionNotificationSequenceNumber = 0;
|
||||||
|
|
||||||
@@ -492,30 +494,12 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
class ImmsBroadcastReceiver extends android.content.BroadcastReceiver {
|
class ImmsBroadcastReceiver extends android.content.BroadcastReceiver {
|
||||||
private void updateActive() {
|
|
||||||
// Inform the current client of the change in active status
|
|
||||||
if (mCurClient != null && mCurClient.client != null) {
|
|
||||||
executeOrSendMessage(mCurClient.client, mCaller.obtainMessageIO(
|
|
||||||
MSG_SET_ACTIVE, mScreenOn ? 1 : 0, mCurClient));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
final String action = intent.getAction();
|
final String action = intent.getAction();
|
||||||
if (Intent.ACTION_SCREEN_ON.equals(action)) {
|
if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)) {
|
||||||
mScreenOn = true;
|
|
||||||
updateSystemUi(mCurToken, mImeWindowVis, mBackDisposition);
|
|
||||||
updateActive();
|
|
||||||
return;
|
|
||||||
} else if (Intent.ACTION_SCREEN_OFF.equals(action)) {
|
|
||||||
mScreenOn = false;
|
|
||||||
updateSystemUi(mCurToken, 0 /* vis */, mBackDisposition);
|
|
||||||
updateActive();
|
|
||||||
return;
|
|
||||||
} else if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)) {
|
|
||||||
hideInputMethodMenu();
|
hideInputMethodMenu();
|
||||||
// No need to updateActive
|
// No need to update mIsInteractive
|
||||||
return;
|
return;
|
||||||
} else if (Intent.ACTION_USER_ADDED.equals(action)
|
} else if (Intent.ACTION_USER_ADDED.equals(action)
|
||||||
|| Intent.ACTION_USER_REMOVED.equals(action)) {
|
|| Intent.ACTION_USER_REMOVED.equals(action)) {
|
||||||
@@ -817,8 +801,6 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
mShowOngoingImeSwitcherForPhones = false;
|
mShowOngoingImeSwitcherForPhones = false;
|
||||||
|
|
||||||
final IntentFilter broadcastFilter = new IntentFilter();
|
final IntentFilter broadcastFilter = new IntentFilter();
|
||||||
broadcastFilter.addAction(Intent.ACTION_SCREEN_ON);
|
|
||||||
broadcastFilter.addAction(Intent.ACTION_SCREEN_OFF);
|
|
||||||
broadcastFilter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
|
broadcastFilter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
|
||||||
broadcastFilter.addAction(Intent.ACTION_USER_ADDED);
|
broadcastFilter.addAction(Intent.ACTION_USER_ADDED);
|
||||||
broadcastFilter.addAction(Intent.ACTION_USER_REMOVED);
|
broadcastFilter.addAction(Intent.ACTION_USER_REMOVED);
|
||||||
@@ -938,6 +920,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, filter);
|
}, filter);
|
||||||
|
LocalServices.addService(InputMethodManagerInternal.class, new LocalServiceImpl(mHandler));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resetDefaultImeLocked(Context context) {
|
private void resetDefaultImeLocked(Context context) {
|
||||||
@@ -1379,9 +1362,9 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
+ cs.client.asBinder() + " keyguard=" + mCurClientInKeyguard);
|
+ cs.client.asBinder() + " keyguard=" + mCurClientInKeyguard);
|
||||||
|
|
||||||
// If the screen is on, inform the new client it is active
|
// If the screen is on, inform the new client it is active
|
||||||
if (mScreenOn) {
|
if (mIsInteractive) {
|
||||||
executeOrSendMessage(cs.client, mCaller.obtainMessageIO(
|
executeOrSendMessage(cs.client, mCaller.obtainMessageIO(
|
||||||
MSG_SET_ACTIVE, mScreenOn ? 1 : 0, cs));
|
MSG_SET_ACTIVE, mIsInteractive ? 1 : 0, cs));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2851,6 +2834,9 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
+ ((ClientState)msg.obj).uid);
|
+ ((ClientState)msg.obj).uid);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
case MSG_SET_INTERACTIVE:
|
||||||
|
handleSetInteractive(msg.arg1 != 0);
|
||||||
|
return true;
|
||||||
case MSG_SET_USER_ACTION_NOTIFICATION_SEQUENCE_NUMBER: {
|
case MSG_SET_USER_ACTION_NOTIFICATION_SEQUENCE_NUMBER: {
|
||||||
final int sequenceNumber = msg.arg1;
|
final int sequenceNumber = msg.arg1;
|
||||||
final ClientState clientState = (ClientState)msg.obj;
|
final ClientState clientState = (ClientState)msg.obj;
|
||||||
@@ -2874,6 +2860,19 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void handleSetInteractive(final boolean interactive) {
|
||||||
|
synchronized (mMethodMap) {
|
||||||
|
mIsInteractive = interactive;
|
||||||
|
updateSystemUiLocked(mCurToken, interactive ? mImeWindowVis : 0, mBackDisposition);
|
||||||
|
|
||||||
|
// Inform the current client of the change in active status
|
||||||
|
if (mCurClient != null && mCurClient.client != null) {
|
||||||
|
executeOrSendMessage(mCurClient.client, mCaller.obtainMessageIO(
|
||||||
|
MSG_SET_ACTIVE, mIsInteractive ? 1 : 0, mCurClient));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private boolean chooseNewDefaultIMELocked() {
|
private boolean chooseNewDefaultIMELocked() {
|
||||||
final InputMethodInfo imi = InputMethodUtils.getMostApplicableDefaultIME(
|
final InputMethodInfo imi = InputMethodUtils.getMostApplicableDefaultIME(
|
||||||
mSettings.getEnabledInputMethodListLocked());
|
mSettings.getEnabledInputMethodListLocked());
|
||||||
@@ -3734,6 +3733,22 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final class LocalServiceImpl implements InputMethodManagerInternal {
|
||||||
|
@NonNull
|
||||||
|
private final Handler mHandler;
|
||||||
|
|
||||||
|
LocalServiceImpl(@NonNull final Handler handler) {
|
||||||
|
mHandler = handler;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setInteractive(boolean interactive) {
|
||||||
|
// Do everything in handler so as not to block the caller.
|
||||||
|
mHandler.sendMessage(mHandler.obtainMessage(MSG_SET_INTERACTIVE,
|
||||||
|
interactive ? 1 : 0, 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
|
protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
|
||||||
if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
|
if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
|
||||||
@@ -3784,7 +3799,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
+ " mInputShown=" + mInputShown);
|
+ " mInputShown=" + mInputShown);
|
||||||
p.println(" mCurUserActionNotificationSequenceNumber="
|
p.println(" mCurUserActionNotificationSequenceNumber="
|
||||||
+ mCurUserActionNotificationSequenceNumber);
|
+ mCurUserActionNotificationSequenceNumber);
|
||||||
p.println(" mSystemReady=" + mSystemReady + " mInteractive=" + mScreenOn);
|
p.println(" mSystemReady=" + mSystemReady + " mInteractive=" + mIsInteractive);
|
||||||
p.println(" mSettingsObserver=" + mSettingsObserver);
|
p.println(" mSettingsObserver=" + mSettingsObserver);
|
||||||
p.println(" mSwitchingController:");
|
p.println(" mSwitchingController:");
|
||||||
mSwitchingController.dump(p);
|
mSwitchingController.dump(p);
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ import android.provider.Settings;
|
|||||||
import android.util.EventLog;
|
import android.util.EventLog;
|
||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
import android.view.WindowManagerPolicy;
|
import android.view.WindowManagerPolicy;
|
||||||
|
import android.view.inputmethod.InputMethodManagerInternal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends broadcasts about important power state changes.
|
* Sends broadcasts about important power state changes.
|
||||||
@@ -89,6 +90,7 @@ final class Notifier {
|
|||||||
private final WindowManagerPolicy mPolicy;
|
private final WindowManagerPolicy mPolicy;
|
||||||
private final ActivityManagerInternal mActivityManagerInternal;
|
private final ActivityManagerInternal mActivityManagerInternal;
|
||||||
private final InputManagerInternal mInputManagerInternal;
|
private final InputManagerInternal mInputManagerInternal;
|
||||||
|
private final InputMethodManagerInternal mInputMethodManagerInternal;
|
||||||
|
|
||||||
private final NotifierHandler mHandler;
|
private final NotifierHandler mHandler;
|
||||||
private final Intent mScreenOnIntent;
|
private final Intent mScreenOnIntent;
|
||||||
@@ -133,6 +135,7 @@ final class Notifier {
|
|||||||
mPolicy = policy;
|
mPolicy = policy;
|
||||||
mActivityManagerInternal = LocalServices.getService(ActivityManagerInternal.class);
|
mActivityManagerInternal = LocalServices.getService(ActivityManagerInternal.class);
|
||||||
mInputManagerInternal = LocalServices.getService(InputManagerInternal.class);
|
mInputManagerInternal = LocalServices.getService(InputManagerInternal.class);
|
||||||
|
mInputMethodManagerInternal = LocalServices.getService(InputMethodManagerInternal.class);
|
||||||
|
|
||||||
mHandler = new NotifierHandler(looper);
|
mHandler = new NotifierHandler(looper);
|
||||||
mScreenOnIntent = new Intent(Intent.ACTION_SCREEN_ON);
|
mScreenOnIntent = new Intent(Intent.ACTION_SCREEN_ON);
|
||||||
@@ -314,6 +317,7 @@ final class Notifier {
|
|||||||
|
|
||||||
// Start input as soon as we start waking up or going to sleep.
|
// Start input as soon as we start waking up or going to sleep.
|
||||||
mInputManagerInternal.setInteractive(interactive);
|
mInputManagerInternal.setInteractive(interactive);
|
||||||
|
mInputMethodManagerInternal.setInteractive(interactive);
|
||||||
|
|
||||||
// Notify battery stats.
|
// Notify battery stats.
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user