Merge "RESTRICT AUTOMERGE Disable TextClassifier for RemoteInputView." into pi-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
4828033816
@@ -36,6 +36,7 @@ import android.text.SpannedString;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.ActionMode;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
@@ -48,6 +49,7 @@ import android.view.inputmethod.CompletionInfo;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.view.inputmethod.InputConnection;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.view.textclassifier.TextClassifier;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.LinearLayout;
|
||||
@@ -192,9 +194,32 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene
|
||||
v.mEntry = entry;
|
||||
v.setTag(VIEW_TAG);
|
||||
|
||||
// Disable the TextClassifier to avoid cross user interactions.
|
||||
v.mEditText.setTextClassifier(TextClassifier.NO_OP);
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionMode startActionMode(ActionMode.Callback callback, int type) {
|
||||
try {
|
||||
UserHandle notificationUser = mEntry.notification.getUser();
|
||||
UserHandle currentUser = UserHandle.of(ActivityManager.getCurrentUser());
|
||||
if (!UserHandle.ALL.equals(notificationUser)
|
||||
&& !currentUser.equals(notificationUser)) {
|
||||
// If this happens to be a selection action mode, a non-NO_OP TextClassifier could
|
||||
// leak data across users. This widget uses TextClassifier.NO_OP so this is fine.
|
||||
// Log the security fix.
|
||||
android.util.EventLog.writeEvent(0x534e4554, "123232892", -1, "");
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
// Avoid crashing because of this log attempt.
|
||||
Log.i(TAG, "Error attempting to log security fix for bug 123232892", t);
|
||||
|
||||
}
|
||||
return super.startActionMode(callback, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (v == mSendButton) {
|
||||
|
||||
@@ -26,6 +26,7 @@ import android.support.test.filters.SmallTest;
|
||||
import android.testing.AndroidTestingRunner;
|
||||
import android.testing.TestableLooper;
|
||||
import android.view.View;
|
||||
import android.view.textclassifier.TextClassifier;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
|
||||
@@ -109,4 +110,13 @@ public class RemoteInputViewTest extends SysuiTestCase {
|
||||
mView.setVisibility(View.INVISIBLE);
|
||||
mView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUsesNoOpTextClassifier() {
|
||||
RemoteInput input = new RemoteInput.Builder(TEST_RESULT_KEY).build();
|
||||
mView.setRemoteInput(new RemoteInput[]{input}, input);
|
||||
|
||||
EditText editText = mView.findViewById(R.id.remote_input_text);
|
||||
assertEquals(TextClassifier.NO_OP, editText.getTextClassifier());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user