diff options
Diffstat (limited to 'services/java/com/android/server/InputMethodManagerService.java')
-rw-r--r-- | services/java/com/android/server/InputMethodManagerService.java | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/services/java/com/android/server/InputMethodManagerService.java b/services/java/com/android/server/InputMethodManagerService.java index 18d393f..2597978 100644 --- a/services/java/com/android/server/InputMethodManagerService.java +++ b/services/java/com/android/server/InputMethodManagerService.java @@ -35,6 +35,7 @@ import org.xmlpull.v1.XmlSerializer; import android.app.ActivityManagerNative; import android.app.AlertDialog; +import android.app.KeyguardManager; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; @@ -47,6 +48,7 @@ import android.content.Intent; import android.content.IntentFilter; import android.content.ServiceConnection; import android.content.pm.ApplicationInfo; +import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.pm.ServiceInfo; @@ -160,6 +162,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub // Ongoing notification private final NotificationManager mNotificationManager; + private final KeyguardManager mKeyguardManager; private final Notification mImeSwitcherNotification; private final PendingIntent mImeSwitchPendingIntent; private final boolean mShowOngoingImeSwitcherForPhones; @@ -520,6 +523,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } }); + mKeyguardManager = (KeyguardManager) + mContext.getSystemService(Context.KEYGUARD_SERVICE); mNotificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE); mImeSwitcherNotification = new Notification(); @@ -1632,19 +1637,27 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } @Override - public boolean setAdditionalInputMethodSubtypes(IBinder token, InputMethodSubtype[] subtypes) { - if (token == null || mCurToken != token) { - return false; - } - if (subtypes == null || subtypes.length == 0) return false; + public boolean setAdditionalInputMethodSubtypes(String imiId, InputMethodSubtype[] subtypes) { + // By this IPC call, only a process which shares the same uid with the IME can add + // additional input method subtypes to the IME. + if (TextUtils.isEmpty(imiId) || subtypes == null || subtypes.length == 0) return false; synchronized (mMethodMap) { - final InputMethodInfo imi = mMethodMap.get(mCurMethodId); + final InputMethodInfo imi = mMethodMap.get(imiId); if (imi == null) return false; - final int N = subtypes.length; - mFileManager.addInputMethodSubtypes(imi, subtypes); - buildInputMethodListLocked(mMethodList, mMethodMap); - return true; + final PackageManager pm = mContext.getPackageManager(); + final String[] packageInfos = pm.getPackagesForUid(Binder.getCallingUid()); + if (packageInfos != null) { + final int packageNum = packageInfos.length; + for (int i = 0; i < packageNum; ++i) { + if (packageInfos[i].equals(imi.getPackageName())) { + mFileManager.addInputMethodSubtypes(imi, subtypes); + buildInputMethodListLocked(mMethodList, mMethodMap); + return true; + } + } + } } + return false; } private void setInputMethodWithSubtypeId(IBinder token, String id, int subtypeId) { @@ -2118,7 +2131,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } }); - if (showSubtypes) { + if (showSubtypes && !(mKeyguardManager.isKeyguardLocked() + && mKeyguardManager.isKeyguardSecure())) { mDialogBuilder.setPositiveButton( com.android.internal.R.string.configure_input_methods, new DialogInterface.OnClickListener() { |