From 02df328f0cd12f2af87ca96ecf5819c8a3470dc8 Mon Sep 17 00:00:00 2001 From: Yohei Yukawa Date: Wed, 3 Jun 2015 15:58:59 -0700 Subject: Report EditorInfo#packageName based on the actual uid. This is a follow up CL for Ib871141e3381e45c2623c5f4d692da7a7e78fcc5, which introduced a verification mechanism between the applicaiton uid and EditorInfo#packageName reported from the application by using AppOpsManager#checkPackage. Regression Bug 21408239 caused by above change is really similar to the situation we saw in Bug 10688644. As well explained in the CL description of Ic04f77b3938585b02fccabbc12d2f0dc62b9ef25, the system has a special ability to run in the processes of other uids. Hence we need to use Context#getOpPackageName() instead of Context#getPackageName() in case components declared by the system is loaded into another process. Bug: 18931038 Bug: 21408239 Change-Id: I78510a2ea6ac06cfd5813a23c42f09f70c468493 --- core/java/android/view/inputmethod/InputMethodManager.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java index 053b35c4a8eb..1c8a79b99d31 100644 --- a/core/java/android/view/inputmethod/InputMethodManager.java +++ b/core/java/android/view/inputmethod/InputMethodManager.java @@ -1169,7 +1169,10 @@ public final class InputMethodManager { // do its stuff. // Life is good: let's hook everything up! EditorInfo tba = new EditorInfo(); - tba.packageName = view.getContext().getPackageName(); + // Note: Use Context#getOpPackageName() rather than Context#getPackageName() so that the + // system can verify the consistency between the uid of this process and package name passed + // from here. See comment of Context#getOpPackageName() for details. + tba.packageName = view.getContext().getOpPackageName(); tba.fieldId = view.getId(); InputConnection ic = view.onCreateInputConnection(tba); if (DEBUG) Log.v(TAG, "Starting input: tba=" + tba + " ic=" + ic); -- cgit v1.2.3-59-g8ed1b