diff options
author | Yohei Yukawa <yukawa@google.com> | 2015-06-22 17:59:41 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-06-22 17:59:42 +0000 |
commit | 648abe156596a5f76e6bd883c4d25d0380bbd469 (patch) | |
tree | d751231cd46f4980195891359f731c5befa0856b /core/java | |
parent | 7c781124763cf50ede30e6836234046bf3ec0a92 (diff) | |
parent | 094c71fd5c0b6b7ce4cd71d097d226a6a1acfc90 (diff) | |
download | frameworks_base-648abe156596a5f76e6bd883c4d25d0380bbd469.zip frameworks_base-648abe156596a5f76e6bd883c4d25d0380bbd469.tar.gz frameworks_base-648abe156596a5f76e6bd883c4d25d0380bbd469.tar.bz2 |
Merge "Set DISABLED_UNTIL_USED for the correct user in IMMS." into mnc-dev
Diffstat (limited to 'core/java')
-rw-r--r-- | core/java/com/android/internal/inputmethod/InputMethodUtils.java | 39 |
1 files changed, 29 insertions, 10 deletions
diff --git a/core/java/com/android/internal/inputmethod/InputMethodUtils.java b/core/java/com/android/internal/inputmethod/InputMethodUtils.java index 042db71..ac17cbe 100644 --- a/core/java/com/android/internal/inputmethod/InputMethodUtils.java +++ b/core/java/com/android/internal/inputmethod/InputMethodUtils.java @@ -22,9 +22,10 @@ import android.app.AppOpsManager; import android.content.ContentResolver; import android.content.Context; import android.content.pm.ApplicationInfo; +import android.content.pm.IPackageManager; import android.content.pm.PackageManager; -import android.content.pm.PackageManager.NameNotFoundException; import android.content.res.Resources; +import android.os.RemoteException; import android.provider.Settings; import android.provider.Settings.SettingNotFoundException; import android.text.TextUtils; @@ -646,7 +647,8 @@ public class InputMethodUtils { } public static void setNonSelectedSystemImesDisabledUntilUsed( - PackageManager packageManager, List<InputMethodInfo> enabledImis) { + IPackageManager packageManager, List<InputMethodInfo> enabledImis, + int userId, String callingPackage) { if (DEBUG) { Slog.d(TAG, "setNonSelectedSystemImesDisabledUntilUsed"); } @@ -685,9 +687,11 @@ public class InputMethodUtils { ApplicationInfo ai = null; try { ai = packageManager.getApplicationInfo(packageName, - PackageManager.GET_DISABLED_UNTIL_USED_COMPONENTS); - } catch (NameNotFoundException e) { - Slog.w(TAG, "NameNotFoundException: " + packageName, e); + PackageManager.GET_DISABLED_UNTIL_USED_COMPONENTS, userId); + } catch (RemoteException e) { + Slog.w(TAG, "getApplicationInfo failed. packageName=" + packageName + + " userId=" + userId, e); + continue; } if (ai == null) { // No app found for packageName @@ -697,19 +701,34 @@ public class InputMethodUtils { if (!isSystemPackage) { continue; } - setDisabledUntilUsed(packageManager, packageName); + setDisabledUntilUsed(packageManager, packageName, userId, callingPackage); } } - private static void setDisabledUntilUsed(PackageManager packageManager, String packageName) { - final int state = packageManager.getApplicationEnabledSetting(packageName); + private static void setDisabledUntilUsed(IPackageManager packageManager, String packageName, + int userId, String callingPackage) { + final int state; + try { + state = packageManager.getApplicationEnabledSetting(packageName, userId); + } catch (RemoteException e) { + Slog.w(TAG, "getApplicationEnabledSetting failed. packageName=" + packageName + + " userId=" + userId, e); + return; + } if (state == PackageManager.COMPONENT_ENABLED_STATE_DEFAULT || state == PackageManager.COMPONENT_ENABLED_STATE_ENABLED) { if (DEBUG) { Slog.d(TAG, "Update state(" + packageName + "): DISABLED_UNTIL_USED"); } - packageManager.setApplicationEnabledSetting(packageName, - PackageManager.COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED, 0); + try { + packageManager.setApplicationEnabledSetting(packageName, + PackageManager.COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED, + 0 /* newState */, userId, callingPackage); + } catch (RemoteException e) { + Slog.w(TAG, "setApplicationEnabledSetting failed. packageName=" + packageName + + " userId=" + userId + " callingPackage=" + callingPackage, e); + return; + } } else { if (DEBUG) { Slog.d(TAG, packageName + " is already DISABLED_UNTIL_USED"); |