am 5d4d23eb: Merge "Consolidate the initialization of InputMethodManagerService not to use resource values until system ready" into jb-dev
* commit '5d4d23ebdf42a90207a86fc258a44e9540f356ab': Consolidate the initialization of InputMethodManagerService not to use resource values until system ready
This commit is contained in:
@@ -195,6 +195,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
private PendingIntent mImeSwitchPendingIntent;
|
private PendingIntent mImeSwitchPendingIntent;
|
||||||
private boolean mShowOngoingImeSwitcherForPhones;
|
private boolean mShowOngoingImeSwitcherForPhones;
|
||||||
private boolean mNotificationShown;
|
private boolean mNotificationShown;
|
||||||
|
private final boolean mImeSelectedOnBoot;
|
||||||
|
|
||||||
class SessionState {
|
class SessionState {
|
||||||
final ClientState client;
|
final ClientState client;
|
||||||
@@ -590,7 +591,6 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
mImeSwitcherNotification.vibrate = null;
|
mImeSwitcherNotification.vibrate = null;
|
||||||
Intent intent = new Intent(Settings.ACTION_SHOW_INPUT_METHOD_PICKER);
|
Intent intent = new Intent(Settings.ACTION_SHOW_INPUT_METHOD_PICKER);
|
||||||
mImeSwitchPendingIntent = PendingIntent.getBroadcast(mContext, 0, intent, 0);
|
mImeSwitchPendingIntent = PendingIntent.getBroadcast(mContext, 0, intent, 0);
|
||||||
mLastSystemLocale = mRes.getConfiguration().locale;
|
|
||||||
|
|
||||||
mShowOngoingImeSwitcherForPhones = false;
|
mShowOngoingImeSwitcherForPhones = false;
|
||||||
|
|
||||||
@@ -612,11 +612,17 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
// mSettings should be created before buildInputMethodListLocked
|
// mSettings should be created before buildInputMethodListLocked
|
||||||
mSettings = new InputMethodSettings(
|
mSettings = new InputMethodSettings(
|
||||||
mRes, context.getContentResolver(), mMethodMap, mMethodList);
|
mRes, context.getContentResolver(), mMethodMap, mMethodList);
|
||||||
|
|
||||||
|
// Just checking if defaultImiId is empty or not
|
||||||
|
final String defaultImiId = Settings.Secure.getString(
|
||||||
|
mContext.getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD);
|
||||||
|
mImeSelectedOnBoot = !TextUtils.isEmpty(defaultImiId);
|
||||||
|
|
||||||
buildInputMethodListLocked(mMethodList, mMethodMap);
|
buildInputMethodListLocked(mMethodList, mMethodMap);
|
||||||
mSettings.enableAllIMEsIfThereIsNoEnabledIME();
|
mSettings.enableAllIMEsIfThereIsNoEnabledIME();
|
||||||
|
|
||||||
if (TextUtils.isEmpty(Settings.Secure.getString(
|
if (!mImeSelectedOnBoot) {
|
||||||
mContext.getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD))) {
|
Slog.w(TAG, "No IME selected. Choose the most applicable IME.");
|
||||||
resetDefaultImeLocked(context);
|
resetDefaultImeLocked(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -639,6 +645,10 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void checkCurrentLocaleChangedLocked() {
|
private void checkCurrentLocaleChangedLocked() {
|
||||||
|
if (!mSystemReady) {
|
||||||
|
// not system ready
|
||||||
|
return;
|
||||||
|
}
|
||||||
final Locale newLocale = mRes.getConfiguration().locale;
|
final Locale newLocale = mRes.getConfiguration().locale;
|
||||||
if (newLocale != null && !newLocale.equals(mLastSystemLocale)) {
|
if (newLocale != null && !newLocale.equals(mLastSystemLocale)) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
@@ -675,7 +685,10 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isValidSystemDefaultIme(InputMethodInfo imi, Context context) {
|
private boolean isValidSystemDefaultIme(InputMethodInfo imi, Context context) {
|
||||||
|
if (!mSystemReady) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (!isSystemIme(imi)) {
|
if (!isSystemIme(imi)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -738,7 +751,6 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
mContext.getSystemService(Context.KEYGUARD_SERVICE);
|
mContext.getSystemService(Context.KEYGUARD_SERVICE);
|
||||||
mNotificationManager = (NotificationManager)
|
mNotificationManager = (NotificationManager)
|
||||||
mContext.getSystemService(Context.NOTIFICATION_SERVICE);
|
mContext.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
mLastSystemLocale = mContext.getResources().getConfiguration().locale;
|
|
||||||
mStatusBar = statusBar;
|
mStatusBar = statusBar;
|
||||||
statusBar.setIconVisibility("ime", false);
|
statusBar.setIconVisibility("ime", false);
|
||||||
updateImeWindowStatusLocked();
|
updateImeWindowStatusLocked();
|
||||||
@@ -748,6 +760,12 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
mWindowManagerService.setOnHardKeyboardStatusChangeListener(
|
mWindowManagerService.setOnHardKeyboardStatusChangeListener(
|
||||||
mHardKeyboardListener);
|
mHardKeyboardListener);
|
||||||
}
|
}
|
||||||
|
buildInputMethodListLocked(mMethodList, mMethodMap);
|
||||||
|
if (!mImeSelectedOnBoot) {
|
||||||
|
Slog.w(TAG, "Reset the default IME as \"Resource\" is ready here.");
|
||||||
|
checkCurrentLocaleChangedLocked();
|
||||||
|
}
|
||||||
|
mLastSystemLocale = mRes.getConfiguration().locale;
|
||||||
try {
|
try {
|
||||||
startInputInnerLocked();
|
startInputInnerLocked();
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
@@ -2137,7 +2155,6 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
return subtypes;
|
return subtypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static ArrayList<InputMethodSubtype> getOverridingImplicitlyEnabledSubtypes(
|
private static ArrayList<InputMethodSubtype> getOverridingImplicitlyEnabledSubtypes(
|
||||||
InputMethodInfo imi, String mode) {
|
InputMethodInfo imi, String mode) {
|
||||||
ArrayList<InputMethodSubtype> subtypes = new ArrayList<InputMethodSubtype>();
|
ArrayList<InputMethodSubtype> subtypes = new ArrayList<InputMethodSubtype>();
|
||||||
@@ -2155,15 +2172,19 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
List<InputMethodInfo> enabled = mSettings.getEnabledInputMethodListLocked();
|
List<InputMethodInfo> enabled = mSettings.getEnabledInputMethodListLocked();
|
||||||
if (enabled != null && enabled.size() > 0) {
|
if (enabled != null && enabled.size() > 0) {
|
||||||
// We'd prefer to fall back on a system IME, since that is safer.
|
// We'd prefer to fall back on a system IME, since that is safer.
|
||||||
int i=enabled.size();
|
int i = enabled.size();
|
||||||
|
int firstFoundSystemIme = -1;
|
||||||
while (i > 0) {
|
while (i > 0) {
|
||||||
i--;
|
i--;
|
||||||
final InputMethodInfo imi = enabled.get(i);
|
final InputMethodInfo imi = enabled.get(i);
|
||||||
if (isSystemIme(imi) && !imi.isAuxiliaryIme()) {
|
if (isSystemImeThatHasEnglishSubtype(imi) && !imi.isAuxiliaryIme()) {
|
||||||
break;
|
return imi;
|
||||||
|
}
|
||||||
|
if (firstFoundSystemIme < 0 && isSystemIme(imi) && !imi.isAuxiliaryIme()) {
|
||||||
|
firstFoundSystemIme = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return enabled.get(i);
|
return enabled.get(Math.max(firstFoundSystemIme, 0));
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -2238,11 +2259,17 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String defaultIme = Settings.Secure.getString(mContext
|
final String defaultImiId = Settings.Secure.getString(mContext
|
||||||
.getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD);
|
.getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD);
|
||||||
if (!TextUtils.isEmpty(defaultIme) && !map.containsKey(defaultIme)) {
|
if (!TextUtils.isEmpty(defaultImiId)) {
|
||||||
if (chooseNewDefaultIMELocked()) {
|
if (!map.containsKey(defaultImiId)) {
|
||||||
updateFromSettingsLocked();
|
Slog.w(TAG, "Default IME is uninstalled. Choose new default IME.");
|
||||||
|
if (chooseNewDefaultIMELocked()) {
|
||||||
|
updateFromSettingsLocked();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Double check that the default IME is certainly enabled.
|
||||||
|
setInputMethodEnabledLocked(defaultImiId, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3007,8 +3034,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
mContext = context;
|
mContext = context;
|
||||||
mPm = context.getPackageManager();
|
mPm = context.getPackageManager();
|
||||||
mImms = imms;
|
mImms = imms;
|
||||||
mSystemLocaleStr =
|
final Locale locale = context.getResources().getConfiguration().locale;
|
||||||
imms.mLastSystemLocale != null ? imms.mLastSystemLocale.toString() : "";
|
mSystemLocaleStr = locale != null ? locale.toString() : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
private final TreeMap<InputMethodInfo, List<InputMethodSubtype>> mSortedImmis =
|
private final TreeMap<InputMethodInfo, List<InputMethodSubtype>> mSortedImmis =
|
||||||
|
|||||||
Reference in New Issue
Block a user