diff options
| author | satok <satok@google.com> | 2011-07-18 20:42:54 -0700 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-07-18 20:42:54 -0700 |
| commit | 4273ed652ae9ea2af0a77b6d59a183ebce53a680 (patch) | |
| tree | f266c898cd8b72f6819d049d2ab6d3cdf3dec98b /services/java/com/android/server/InputMethodManagerService.java | |
| parent | d61752d7e6f546dcd41018bd8371a9a9617fe66d (diff) | |
| parent | 91e88122cf28a48fd2e2260da7d3d87dd437227a (diff) | |
Merge "Enable IMEs to set additional subtypes in background"
Diffstat (limited to 'services/java/com/android/server/InputMethodManagerService.java')
| -rw-r--r-- | services/java/com/android/server/InputMethodManagerService.java | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/services/java/com/android/server/InputMethodManagerService.java b/services/java/com/android/server/InputMethodManagerService.java index 18d393fde2f7..1a2cecdcff94 100644 --- a/services/java/com/android/server/InputMethodManagerService.java +++ b/services/java/com/android/server/InputMethodManagerService.java @@ -47,6 +47,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; @@ -1632,19 +1633,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) { |
