Work on issue #17506095: Plumb a new configuration to IMMS
This CL makes a plumbing from SystemConfig to IMMS.
Change-Id: Ia70b870723acf647e0c27f24aff91b40d6f85543
diff --git a/services/core/java/com/android/server/InputMethodManagerService.java b/services/core/java/com/android/server/InputMethodManagerService.java
index 060c8e3..1623eac 100644
--- a/services/core/java/com/android/server/InputMethodManagerService.java
+++ b/services/core/java/com/android/server/InputMethodManagerService.java
@@ -40,6 +40,7 @@
import android.app.ActivityManagerNative;
import android.app.AppGlobals;
import android.app.AlertDialog;
+import android.app.AppOpsManager;
import android.app.IUserSwitchObserver;
import android.app.KeyguardManager;
import android.app.Notification;
@@ -175,6 +176,7 @@
private InputMethodFileManager mFileManager;
private final HardKeyboardListener mHardKeyboardListener;
private final WindowManagerService mWindowManagerService;
+ private final AppOpsManager mAppOpsManager;
final InputBindResult mNoBinding = new InputBindResult(null, null, null, -1, -1);
@@ -643,6 +645,7 @@
}
}, true /*asyncHandler*/);
mWindowManagerService = windowManager;
+ mAppOpsManager = (AppOpsManager) mContext.getSystemService(Context.APP_OPS_SERVICE);
mHardKeyboardListener = new HardKeyboardListener();
mHasFeature = context.getPackageManager().hasSystemFeature(
PackageManager.FEATURE_INPUT_METHODS);
@@ -1746,6 +1749,20 @@
throw new IllegalArgumentException("Unknown id: " + id);
}
+ if (mCurClient != null && mCurAttribute != null) {
+ final int uid = mCurClient.uid;
+ final String packageName = mCurAttribute.packageName;
+ if (SystemConfig.getInstance().getFixedImeApps().contains(packageName)) {
+ if (InputMethodUtils.checkIfPackageBelongsToUid(mAppOpsManager, uid, packageName)) {
+ return;
+ }
+ // TODO: Do we need to lock the input method when the application reported an
+ // incorrect package name?
+ Slog.e(TAG, "Ignoring FixedImeApps due to the validation failure. uid=" + uid
+ + " package=" + packageName);
+ }
+ }
+
// See if we need to notify a subtype change within the same IME.
if (id.equals(mCurMethodId)) {
final int subtypeCount = info.getSubtypeCount();