Android-x86
Fork
Spenden

  • R/O
  • HTTP
  • SSH
  • HTTPS

frameworks-base: Commit

frameworks/base


Commit MetaInfo

Revisiond888bf2d052fd89fbeb70c7829f9d0c6406c2cdd (tree)
Zeit2019-12-17 05:47:22
AutorYohei Yukawa <yukawa@goog...>
CommiterManjae Park

Log Message

DO NOT MERGE back porting for fixing sysui direct reply

Root cause: systemui run as user 0 service to handle all of users'
notifications. And, the users can user the copy/cut/paste
functionality.

Solution: To crate @hide API in TextView let SystemUI to mark the
TextView instance should check if the power of
INTERACT_ACROSS_USER_FULL is needed to be restricted.
e.x. Keyguard password textview/Notificaiton entries

Bug: 123232892
Test: manual test
Reference: I6d11e4d6a84570bc2991a8552349e8b216b0d139
Reference: Ibabe13e5b85e5bb91f9f8af6ec07c395c25c4393
Reference: I975baa748c821538e5a733bb98a33ac609bf40a7

Change-Id: I6d11e4d6a84570bc2991a8552349e8b216b0d139
Merged-In: Ie3daecd1e8fc2f7fdf37baeb5979da9f2e0b3937
(cherry picked from commit 08391b3da7e2da3b0220eb5766e0a1774d28e9a5)

Ändern Zusammenfassung

Diff

--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -16,6 +16,7 @@
1616
1717 package android.widget;
1818
19+import static android.Manifest.permission.INTERACT_ACROSS_USERS_FULL;
1920 import static android.view.accessibility.AccessibilityNodeInfo.EXTRA_DATA_TEXT_CHARACTER_LOCATION_ARG_LENGTH;
2021 import static android.view.accessibility.AccessibilityNodeInfo.EXTRA_DATA_TEXT_CHARACTER_LOCATION_ARG_START_INDEX;
2122 import static android.view.accessibility.AccessibilityNodeInfo.EXTRA_DATA_TEXT_CHARACTER_LOCATION_KEY;
@@ -31,11 +32,13 @@ import android.annotation.IntRange;
3132 import android.annotation.NonNull;
3233 import android.annotation.Nullable;
3334 import android.annotation.Px;
35+import android.annotation.RequiresPermission;
3436 import android.annotation.Size;
3537 import android.annotation.StringRes;
3638 import android.annotation.StyleRes;
3739 import android.annotation.XmlRes;
3840 import android.app.Activity;
41+import android.app.ActivityManager;
3942 import android.app.PendingIntent;
4043 import android.app.assist.AssistStructure;
4144 import android.content.ClipData;
@@ -72,6 +75,7 @@ import android.os.Parcel;
7275 import android.os.Parcelable;
7376 import android.os.ParcelableParcel;
7477 import android.os.SystemClock;
78+import android.os.UserHandle;
7579 import android.provider.Settings;
7680 import android.text.BoringLayout;
7781 import android.text.DynamicLayout;
@@ -723,6 +727,19 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
723727
724728 private InputFilter[] mFilters = NO_FILTERS;
725729
730+ /**
731+ * To keep the information to indicate if there is necessary to restrict the power of
732+ * INTERACT_ACROSS_USERS_FULL.
733+ * <p>
734+ * SystemUI always run as user 0 to process all of direct reply. SystemUI has the poer of
735+ * INTERACT_ACROSS_USERS_FULL. However, all of the notifications not only belong to user 0 but
736+ * also to the other users in multiple user environment.
737+ * </p>
738+ *
739+ * @see #setRestrictedAcrossUser(boolean)
740+ */
741+ private boolean mIsRestrictedAcrossUser;
742+
726743 private volatile Locale mCurrentSpellCheckerLocaleCache;
727744
728745 // It is possible to have a selection even when mEditor is null (programmatically set, like when
@@ -10440,6 +10457,24 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
1044010457 }
1044110458
1044210459 /**
10460+ * To notify the TextView to restricted the power of the app granted INTERACT_ACROSS_USERS_FULL
10461+ * permission.
10462+ * <p>
10463+ * Most of applications should not granted the INTERACT_ACROSS_USERS_FULL permssion.
10464+ * SystemUI is the special one that run in user 0 process to handle multiple user notification.
10465+ * Unforunately, the power of INTERACT_ACROSS_USERS_FULL should be limited or restricted for
10466+ * preventing from information leak.</p>
10467+ * <p>This function call is called for SystemUI Keyguard and Notification.</p>
10468+ *
10469+ * @param isRestricted is true if the power of INTERACT_ACROSS_USERS_FULL should be limited.
10470+ * @hide
10471+ */
10472+ @RequiresPermission(INTERACT_ACROSS_USERS_FULL)
10473+ public final void setRestrictedAcrossUser(boolean isRestricted) {
10474+ mIsRestrictedAcrossUser = isRestricted;
10475+ }
10476+
10477+ /**
1044310478 * This is a temporary method. Future versions may support multi-locale text.
1044410479 * Caveat: This method may not return the latest text services locale, but this should be
1044510480 * acceptable and it's more important to make this method asynchronous.
@@ -11647,6 +11682,12 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
1164711682 }
1164811683
1164911684 boolean canCut() {
11685+ if (mIsRestrictedAcrossUser
11686+ && UserHandle.myUserId() != ActivityManager.getCurrentUser()) {
11687+ // When it's restricted, and the curren user is not the process user. It can't cut
11688+ // because it may cut the text of the user 10 into the clipboard of user 0.
11689+ return false;
11690+ }
1165011691 if (hasPasswordTransformationMethod()) {
1165111692 return false;
1165211693 }
@@ -11660,6 +11701,12 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
1166011701 }
1166111702
1166211703 boolean canCopy() {
11704+ if (mIsRestrictedAcrossUser
11705+ && UserHandle.myUserId() != ActivityManager.getCurrentUser()) {
11706+ // When it's restricted, and the curren user is not the process user. It can't copy
11707+ // because it may copy the text of the user 10 to the clipboard of user 0.
11708+ return false;
11709+ }
1166311710 if (hasPasswordTransformationMethod()) {
1166411711 return false;
1166511712 }
@@ -11689,6 +11736,12 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
1168911736 }
1169011737
1169111738 boolean canPaste() {
11739+ if (mIsRestrictedAcrossUser
11740+ && UserHandle.myUserId() != ActivityManager.getCurrentUser()) {
11741+ // When it's restricted, and the curren user is not the process user. It can't paste
11742+ // because it may copy the text from the user 0 clipboard in current user is 10.
11743+ return false;
11744+ }
1169211745 return (mText instanceof Editable
1169311746 && mEditor != null && mEditor.mKeyListener != null
1169411747 && getSelectionStart() >= 0
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardPasswordView.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardPasswordView.java
@@ -79,6 +79,7 @@ public class KeyguardPasswordView extends KeyguardAbsKeyInputView
7979
8080 @Override
8181 protected void resetState() {
82+ mPasswordEntry.setRestrictedAcrossUser(true);
8283 mSecurityMessageDisplay.setMessage("");
8384 final boolean wasDisabled = mPasswordEntry.isEnabled();
8485 setPasswordEntryEnabled(true);
@@ -169,6 +170,7 @@ public class KeyguardPasswordView extends KeyguardAbsKeyInputView
169170 Context.INPUT_METHOD_SERVICE);
170171
171172 mPasswordEntry = findViewById(getPasswordTextViewId());
173+ mPasswordEntry.setRestrictedAcrossUser(true);
172174 mPasswordEntryDisabler = new TextViewInputDisabler(mPasswordEntry);
173175 mPasswordEntry.setKeyListener(TextKeyListener.getInstance());
174176 mPasswordEntry.setInputType(InputType.TYPE_CLASS_TEXT
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java
@@ -192,6 +192,7 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene
192192 LayoutInflater.from(context).inflate(R.layout.remote_input, root, false);
193193 v.mController = controller;
194194 v.mEntry = entry;
195+ v.mEditText.setRestrictedAcrossUser(true);
195196 v.setTag(VIEW_TAG);
196197
197198 // Disable the TextClassifier to avoid cross user interactions.
Show on old repository browser