Merge "DO NOT MERGE back porting for fixing sysui direct reply" into pi-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
da2466a36d
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package android.widget;
|
package android.widget;
|
||||||
|
|
||||||
|
import static android.Manifest.permission.INTERACT_ACROSS_USERS_FULL;
|
||||||
import static android.view.accessibility.AccessibilityNodeInfo.EXTRA_DATA_TEXT_CHARACTER_LOCATION_ARG_LENGTH;
|
import static android.view.accessibility.AccessibilityNodeInfo.EXTRA_DATA_TEXT_CHARACTER_LOCATION_ARG_LENGTH;
|
||||||
import static android.view.accessibility.AccessibilityNodeInfo.EXTRA_DATA_TEXT_CHARACTER_LOCATION_ARG_START_INDEX;
|
import static android.view.accessibility.AccessibilityNodeInfo.EXTRA_DATA_TEXT_CHARACTER_LOCATION_ARG_START_INDEX;
|
||||||
import static android.view.accessibility.AccessibilityNodeInfo.EXTRA_DATA_TEXT_CHARACTER_LOCATION_KEY;
|
import static android.view.accessibility.AccessibilityNodeInfo.EXTRA_DATA_TEXT_CHARACTER_LOCATION_KEY;
|
||||||
@@ -31,11 +32,13 @@ import android.annotation.IntRange;
|
|||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.annotation.Px;
|
import android.annotation.Px;
|
||||||
|
import android.annotation.RequiresPermission;
|
||||||
import android.annotation.Size;
|
import android.annotation.Size;
|
||||||
import android.annotation.StringRes;
|
import android.annotation.StringRes;
|
||||||
import android.annotation.StyleRes;
|
import android.annotation.StyleRes;
|
||||||
import android.annotation.XmlRes;
|
import android.annotation.XmlRes;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.app.ActivityManager;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.app.assist.AssistStructure;
|
import android.app.assist.AssistStructure;
|
||||||
import android.content.ClipData;
|
import android.content.ClipData;
|
||||||
@@ -72,6 +75,7 @@ import android.os.Parcel;
|
|||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import android.os.ParcelableParcel;
|
import android.os.ParcelableParcel;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
|
import android.os.UserHandle;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.text.BoringLayout;
|
import android.text.BoringLayout;
|
||||||
import android.text.DynamicLayout;
|
import android.text.DynamicLayout;
|
||||||
@@ -723,6 +727,19 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
|||||||
|
|
||||||
private InputFilter[] mFilters = NO_FILTERS;
|
private InputFilter[] mFilters = NO_FILTERS;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To keep the information to indicate if there is necessary to restrict the power of
|
||||||
|
* INTERACT_ACROSS_USERS_FULL.
|
||||||
|
* <p>
|
||||||
|
* SystemUI always run as user 0 to process all of direct reply. SystemUI has the poer of
|
||||||
|
* INTERACT_ACROSS_USERS_FULL. However, all of the notifications not only belong to user 0 but
|
||||||
|
* also to the other users in multiple user environment.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @see #setRestrictedAcrossUser(boolean)
|
||||||
|
*/
|
||||||
|
private boolean mIsRestrictedAcrossUser;
|
||||||
|
|
||||||
private volatile Locale mCurrentSpellCheckerLocaleCache;
|
private volatile Locale mCurrentSpellCheckerLocaleCache;
|
||||||
|
|
||||||
// It is possible to have a selection even when mEditor is null (programmatically set, like when
|
// It is possible to have a selection even when mEditor is null (programmatically set, like when
|
||||||
@@ -10439,6 +10456,24 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
|||||||
: mCurrentSpellCheckerLocaleCache;
|
: mCurrentSpellCheckerLocaleCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To notify the TextView to restricted the power of the app granted INTERACT_ACROSS_USERS_FULL
|
||||||
|
* permission.
|
||||||
|
* <p>
|
||||||
|
* Most of applications should not granted the INTERACT_ACROSS_USERS_FULL permssion.
|
||||||
|
* SystemUI is the special one that run in user 0 process to handle multiple user notification.
|
||||||
|
* Unforunately, the power of INTERACT_ACROSS_USERS_FULL should be limited or restricted for
|
||||||
|
* preventing from information leak.</p>
|
||||||
|
* <p>This function call is called for SystemUI Keyguard and Notification.</p>
|
||||||
|
*
|
||||||
|
* @param isRestricted is true if the power of INTERACT_ACROSS_USERS_FULL should be limited.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
@RequiresPermission(INTERACT_ACROSS_USERS_FULL)
|
||||||
|
public final void setRestrictedAcrossUser(boolean isRestricted) {
|
||||||
|
mIsRestrictedAcrossUser = isRestricted;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a temporary method. Future versions may support multi-locale text.
|
* This is a temporary method. Future versions may support multi-locale text.
|
||||||
* Caveat: This method may not return the latest text services locale, but this should be
|
* Caveat: This method may not return the latest text services locale, but this should be
|
||||||
@@ -11647,6 +11682,12 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
boolean canCut() {
|
boolean canCut() {
|
||||||
|
if (mIsRestrictedAcrossUser
|
||||||
|
&& UserHandle.myUserId() != ActivityManager.getCurrentUser()) {
|
||||||
|
// When it's restricted, and the curren user is not the process user. It can't cut
|
||||||
|
// because it may cut the text of the user 10 into the clipboard of user 0.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (hasPasswordTransformationMethod()) {
|
if (hasPasswordTransformationMethod()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -11660,6 +11701,12 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
boolean canCopy() {
|
boolean canCopy() {
|
||||||
|
if (mIsRestrictedAcrossUser
|
||||||
|
&& UserHandle.myUserId() != ActivityManager.getCurrentUser()) {
|
||||||
|
// When it's restricted, and the curren user is not the process user. It can't copy
|
||||||
|
// because it may copy the text of the user 10 to the clipboard of user 0.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (hasPasswordTransformationMethod()) {
|
if (hasPasswordTransformationMethod()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -11689,6 +11736,12 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
boolean canPaste() {
|
boolean canPaste() {
|
||||||
|
if (mIsRestrictedAcrossUser
|
||||||
|
&& UserHandle.myUserId() != ActivityManager.getCurrentUser()) {
|
||||||
|
// When it's restricted, and the curren user is not the process user. It can't paste
|
||||||
|
// because it may copy the text from the user 0 clipboard in current user is 10.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return (mText instanceof Editable
|
return (mText instanceof Editable
|
||||||
&& mEditor != null && mEditor.mKeyListener != null
|
&& mEditor != null && mEditor.mKeyListener != null
|
||||||
&& getSelectionStart() >= 0
|
&& getSelectionStart() >= 0
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ public class KeyguardPasswordView extends KeyguardAbsKeyInputView
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void resetState() {
|
protected void resetState() {
|
||||||
|
mPasswordEntry.setRestrictedAcrossUser(true);
|
||||||
mSecurityMessageDisplay.setMessage("");
|
mSecurityMessageDisplay.setMessage("");
|
||||||
final boolean wasDisabled = mPasswordEntry.isEnabled();
|
final boolean wasDisabled = mPasswordEntry.isEnabled();
|
||||||
setPasswordEntryEnabled(true);
|
setPasswordEntryEnabled(true);
|
||||||
@@ -169,6 +170,7 @@ public class KeyguardPasswordView extends KeyguardAbsKeyInputView
|
|||||||
Context.INPUT_METHOD_SERVICE);
|
Context.INPUT_METHOD_SERVICE);
|
||||||
|
|
||||||
mPasswordEntry = findViewById(getPasswordTextViewId());
|
mPasswordEntry = findViewById(getPasswordTextViewId());
|
||||||
|
mPasswordEntry.setRestrictedAcrossUser(true);
|
||||||
mPasswordEntryDisabler = new TextViewInputDisabler(mPasswordEntry);
|
mPasswordEntryDisabler = new TextViewInputDisabler(mPasswordEntry);
|
||||||
mPasswordEntry.setKeyListener(TextKeyListener.getInstance());
|
mPasswordEntry.setKeyListener(TextKeyListener.getInstance());
|
||||||
mPasswordEntry.setInputType(InputType.TYPE_CLASS_TEXT
|
mPasswordEntry.setInputType(InputType.TYPE_CLASS_TEXT
|
||||||
|
|||||||
@@ -192,6 +192,7 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene
|
|||||||
LayoutInflater.from(context).inflate(R.layout.remote_input, root, false);
|
LayoutInflater.from(context).inflate(R.layout.remote_input, root, false);
|
||||||
v.mController = controller;
|
v.mController = controller;
|
||||||
v.mEntry = entry;
|
v.mEntry = entry;
|
||||||
|
v.mEditText.setRestrictedAcrossUser(true);
|
||||||
v.setTag(VIEW_TAG);
|
v.setTag(VIEW_TAG);
|
||||||
|
|
||||||
// Disable the TextClassifier to avoid cross user interactions.
|
// Disable the TextClassifier to avoid cross user interactions.
|
||||||
|
|||||||
Reference in New Issue
Block a user