Merge "DO NOT MERGE - Merge pi-dev@5234907 into stage-aosp-master" into stage-aosp-master

This commit is contained in:
Xin Li
2019-02-23 00:39:16 +00:00
committed by Android (Google) Code Review
1374 changed files with 20567 additions and 39364 deletions

View File

@@ -2185,7 +2185,7 @@ public class Activity extends ContextThemeWrapper
* picture-in-picture.
*
* @return true if the system successfully put this activity into picture-in-picture mode or was
* already in picture-in-picture mode (@see {@link #isInPictureInPictureMode()). If the device
* already in picture-in-picture mode (see {@link #isInPictureInPictureMode()}). If the device
* does not support picture-in-picture, return false.
*/
public boolean enterPictureInPictureMode(@NonNull PictureInPictureParams params) {

View File

@@ -149,7 +149,7 @@ public final class RemoteInput implements Parcelable {
/**
* Returns true if the input only accepts data, meaning {@link #getAllowFreeFormInput}
* is false, {@link #getChoices} is null or empty, and {@link #getAllowedDataTypes is
* is false, {@link #getChoices} is null or empty, and {@link #getAllowedDataTypes} is
* non-null and not empty.
*/
public boolean isDataOnly() {

View File

@@ -425,7 +425,7 @@ public final class Slice implements Parcelable {
/**
* Add a sub-slice to the slice being constructed
* @param subType Optional template-specific type information
* @see {@link SliceItem#getSubType()}
* @see SliceItem#getSubType()
*/
public Builder addSubSlice(@NonNull Slice slice, @Nullable @SliceSubtype String subType) {
Preconditions.checkNotNull(slice);
@@ -437,7 +437,7 @@ public final class Slice implements Parcelable {
/**
* Add an action to the slice being constructed
* @param subType Optional template-specific type information
* @see {@link SliceItem#getSubType()}
* @see SliceItem#getSubType()
*/
public Slice.Builder addAction(@NonNull PendingIntent action, @NonNull Slice s,
@Nullable @SliceSubtype String subType) {
@@ -453,7 +453,7 @@ public final class Slice implements Parcelable {
/**
* Add text to the slice being constructed
* @param subType Optional template-specific type information
* @see {@link SliceItem#getSubType()}
* @see SliceItem#getSubType()
*/
public Builder addText(CharSequence text, @Nullable @SliceSubtype String subType,
@SliceHint List<String> hints) {
@@ -464,7 +464,7 @@ public final class Slice implements Parcelable {
/**
* Add an image to the slice being constructed
* @param subType Optional template-specific type information
* @see {@link SliceItem#getSubType()}
* @see SliceItem#getSubType()
*/
public Builder addIcon(Icon icon, @Nullable @SliceSubtype String subType,
@SliceHint List<String> hints) {
@@ -476,7 +476,7 @@ public final class Slice implements Parcelable {
/**
* Add remote input to the slice being constructed
* @param subType Optional template-specific type information
* @see {@link SliceItem#getSubType()}
* @see SliceItem#getSubType()
*/
public Slice.Builder addRemoteInput(RemoteInput remoteInput,
@Nullable @SliceSubtype String subType,
@@ -490,7 +490,7 @@ public final class Slice implements Parcelable {
/**
* Add an integer to the slice being constructed
* @param subType Optional template-specific type information
* @see {@link SliceItem#getSubType()}
* @see SliceItem#getSubType()
*/
public Builder addInt(int value, @Nullable @SliceSubtype String subType,
@SliceHint List<String> hints) {
@@ -511,7 +511,7 @@ public final class Slice implements Parcelable {
/**
* Add a long to the slice being constructed
* @param subType Optional template-specific type information
* @see {@link SliceItem#getSubType()}
* @see SliceItem#getSubType()
*/
public Slice.Builder addLong(long value, @Nullable @SliceSubtype String subType,
@SliceHint List<String> hints) {
@@ -525,7 +525,7 @@ public final class Slice implements Parcelable {
* <p>Expected to be used for support library extension, should not be used for general
* development
* @param subType Optional template-specific type information
* @see {@link SliceItem#getSubType()}
* @see SliceItem#getSubType()
*/
public Slice.Builder addBundle(Bundle bundle, @Nullable @SliceSubtype String subType,
@SliceHint List<String> hints) {

View File

@@ -209,7 +209,7 @@ public abstract class SliceProvider extends ContentProvider {
*
* @param sliceUri Uri to bind.
* @param supportedSpecs List of supported specs.
* @see {@link Slice}.
* @see {@link Slice}
* @see {@link Slice#HINT_PARTIAL}
*/
public Slice onBindSlice(Uri sliceUri, Set<SliceSpec> supportedSpecs) {

View File

@@ -1073,12 +1073,12 @@ public abstract class ContentProvider implements ComponentCallbacks2 {
* Implement this to handle query requests where the arguments are packed into a {@link Bundle}.
* Arguments may include traditional SQL style query arguments. When present these
* should be handled according to the contract established in
* {@link #query(Uri, String[], String, String[], String, CancellationSignal).
* {@link #query(Uri, String[], String, String[], String, CancellationSignal)}.
*
* <p>Traditional SQL arguments can be found in the bundle using the following keys:
* <li>{@link ContentResolver#QUERY_ARG_SQL_SELECTION}
* <li>{@link ContentResolver#QUERY_ARG_SQL_SELECTION_ARGS}
* <li>{@link ContentResolver#QUERY_ARG_SQL_SORT_ORDER}
* <li>{@link android.content.ContentResolver#QUERY_ARG_SQL_SELECTION}
* <li>{@link android.content.ContentResolver#QUERY_ARG_SQL_SELECTION_ARGS}
* <li>{@link android.content.ContentResolver#QUERY_ARG_SQL_SORT_ORDER}
*
* <p>This method can be called from multiple threads, as described in
* <a href="{@docRoot}guide/topics/fundamentals/processes-and-threads.html#Threads">Processes
@@ -1135,8 +1135,8 @@ public abstract class ContentProvider implements ComponentCallbacks2 {
return cursor;</pre>
* <p>
* @see #query(Uri, String[], String, String[], String, CancellationSignal) for
* implementation details.
* See {@link #query(Uri, String[], String, String[], String, CancellationSignal)}
* for implementation details.
*
* @param uri The URI to query. This will be the full URI sent by the client.
* @param projection The list of columns to put into the cursor.

View File

@@ -27,7 +27,6 @@ import android.os.CancellationSignal;
import android.os.OperationCanceledException;
import android.provider.BaseColumns;
import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.Log;
import libcore.util.EmptyArray;
@@ -44,8 +43,7 @@ import java.util.regex.Pattern;
* This is a convenience class that helps build SQL queries to be sent to
* {@link SQLiteDatabase} objects.
*/
public class SQLiteQueryBuilder
{
public class SQLiteQueryBuilder {
private static final String TAG = "SQLiteQueryBuilder";
private static final Pattern sLimitPattern =
Pattern.compile("\\s*\\d+\\s*(,\\s*\\d+\\s*)?");
@@ -498,12 +496,12 @@ public class SQLiteQueryBuilder
if (selectionArgs == null) {
selectionArgs = EmptyArray.STRING;
}
final ArrayMap<String, Object> rawValues = values.getValues();
final int valuesLength = rawValues.size();
final String[] rawKeys = values.keySet().toArray(EmptyArray.STRING);
final int valuesLength = rawKeys.length;
final Object[] sqlArgs = new Object[valuesLength + selectionArgs.length];
for (int i = 0; i < sqlArgs.length; i++) {
if (i < valuesLength) {
sqlArgs[i] = rawValues.valueAt(i);
sqlArgs[i] = values.get(rawKeys[i]);
} else {
sqlArgs[i] = selectionArgs[i - valuesLength];
}
@@ -629,7 +627,7 @@ public class SQLiteQueryBuilder
/** {@hide} */
public String buildUpdate(ContentValues values, String selection) {
if (values == null || values.isEmpty()) {
if (values == null || values.size() == 0) {
throw new IllegalArgumentException("Empty values");
}
@@ -638,12 +636,12 @@ public class SQLiteQueryBuilder
sql.append(mTables);
sql.append(" SET ");
final ArrayMap<String, Object> rawValues = values.getValues();
for (int i = 0; i < rawValues.size(); i++) {
final String[] rawKeys = values.keySet().toArray(EmptyArray.STRING);
for (int i = 0; i < rawKeys.length; i++) {
if (i > 0) {
sql.append(',');
}
sql.append(rawValues.keyAt(i));
sql.append(rawKeys[i]);
sql.append("=?");
}

View File

@@ -1445,11 +1445,11 @@ public class UserManager {
* background user; the result here does not distinguish between the two.
*
* <p>Note prior to Android Nougat MR1 (SDK version <= 24;
* {@link android.os.Build.VERSION_CODES#N), this API required a system permission
* {@link android.os.Build.VERSION_CODES#N}, this API required a system permission
* in order to check other profile's status.
* Since Android Nougat MR1 (SDK version >= 25;
* {@link android.os.Build.VERSION_CODES#N_MR1)), the restriction has been relaxed, and now
* it'll accept any {@link UserHandle} within the same profile group as the caller.
* {@link android.os.Build.VERSION_CODES#N_MR1}), the restriction has been relaxed, and now
* it'll accept any {@link android.os.UserHandle} within the same profile group as the caller.
*
* @param user The user to retrieve the running state for.
*/
@@ -1474,11 +1474,11 @@ public class UserManager {
* (but is not yet fully stopped, and still running some code).
*
* <p>Note prior to Android Nougat MR1 (SDK version <= 24;
* {@link android.os.Build.VERSION_CODES#N), this API required a system permission
* {@link android.os.Build.VERSION_CODES#N}, this API required a system permission
* in order to check other profile's status.
* Since Android Nougat MR1 (SDK version >= 25;
* {@link android.os.Build.VERSION_CODES#N_MR1)), the restriction has been relaxed, and now
* it'll accept any {@link UserHandle} within the same profile group as the caller.
* {@link android.os.Build.VERSION_CODES#N_MR1}), the restriction has been relaxed, and now
* it'll accept any {@link android.os.UserHandle} within the same profile group as the caller.
*
* @param user The user to retrieve the running state for.
*/

View File

@@ -259,7 +259,8 @@ public class ImageSpan extends DynamicDrawableSpan {
* Returns the source string that was saved during construction.
*
* @return the source string that was saved during construction
* @see #ImageSpan(Drawable, String) and this{@link #ImageSpan(Context, Uri)}
* @see #ImageSpan(Drawable, String)
* @see #ImageSpan(Context, Uri)
*/
@Nullable
public String getSource() {

View File

@@ -30,6 +30,7 @@ import android.text.Spanned;
import android.text.method.LinkMovementMethod;
import android.text.method.MovementMethod;
import android.text.style.URLSpan;
import android.util.Log;
import android.util.Patterns;
import android.view.textclassifier.TextClassifier;
import android.view.textclassifier.TextLinks;
@@ -78,6 +79,9 @@ import java.util.regex.Pattern;
*/
public class Linkify {
private static final String LOG_TAG = "Linkify";
/**
* Bit field indicating that web URLs should be matched in methods that
* take an options mask
@@ -247,6 +251,11 @@ public class Linkify {
private static boolean addLinks(@NonNull Spannable text, @LinkifyMask int mask,
@Nullable Context context) {
if (text != null && containsUnsupportedCharacters(text.toString())) {
android.util.EventLog.writeEvent(0x534e4554, "116321860", -1, "");
return false;
}
if (mask == 0) {
return false;
}
@@ -292,6 +301,29 @@ public class Linkify {
return true;
}
/**
* Returns true if the specified text contains at least one unsupported character for applying
* links. Also logs the error.
*
* @param text the text to apply links to
* @hide
*/
public static boolean containsUnsupportedCharacters(String text) {
if (text.contains("\u202C")) {
Log.e(LOG_TAG, "Unsupported character for applying links: u202C");
return true;
}
if (text.contains("\u202D")) {
Log.e(LOG_TAG, "Unsupported character for applying links: u202D");
return true;
}
if (text.contains("\u202E")) {
Log.e(LOG_TAG, "Unsupported character for applying links: u202E");
return true;
}
return false;
}
/**
* Scans the text of the provided TextView and turns all occurrences of
* the link types indicated in the mask into clickable links. If matches
@@ -462,6 +494,11 @@ public class Linkify {
public static final boolean addLinks(@NonNull Spannable spannable, @NonNull Pattern pattern,
@Nullable String defaultScheme, @Nullable String[] schemes,
@Nullable MatchFilter matchFilter, @Nullable TransformFilter transformFilter) {
if (spannable != null && containsUnsupportedCharacters(spannable.toString())) {
android.util.EventLog.writeEvent(0x534e4554, "116321860", -1, "");
return false;
}
final String[] schemesCopy;
if (defaultScheme == null) defaultScheme = "";
if (schemes == null || schemes.length < 1) {

View File

@@ -104,7 +104,7 @@ public final class TextClassification implements Parcelable {
/**
* @hide
*/
static final TextClassification EMPTY = new TextClassification.Builder().build();
public static final TextClassification EMPTY = new TextClassification.Builder().build();
private static final String LOG_TAG = "TextClassification";
// TODO(toki): investigate a way to derive this based on device properties.

View File

@@ -107,6 +107,13 @@ public final class TextLinksParams {
Preconditions.checkNotNull(textLinks);
final String textString = text.toString();
if (Linkify.containsUnsupportedCharacters(textString)) {
// Do not apply links to text containing unsupported characters.
android.util.EventLog.writeEvent(0x534e4554, "116321860", -1, "");
return TextLinks.STATUS_NO_LINKS_APPLIED;
}
if (!textString.startsWith(textLinks.getText())) {
return TextLinks.STATUS_DIFFERENT_TEXT;
}

View File

@@ -41,13 +41,21 @@ public class WebResourceResponse {
private InputStream mInputStream;
/**
* Constructs a resource response with the given MIME type, encoding, and
* input stream. Callers must implement
* Constructs a resource response with the given MIME type, character encoding,
* and input stream. Callers must implement
* {@link InputStream#read(byte[]) InputStream.read(byte[])} for the input
* stream.
*
* @param mimeType the resource response's MIME type, for example text/html
* @param encoding the resource response's encoding
* <p class="note"><b>Note:</b> The MIME type and character encoding must
* be specified as separate parameters (for example {@code "text/html"} and
* {@code "utf-8"}), not a single value like the {@code "text/html; charset=utf-8"}
* format used in the HTTP Content-Type header. Do not use the value of a HTTP
* Content-Encoding header for {@code encoding}, as that header does not specify a
* character encoding. Content without a defined character encoding (for example
* image resources) should pass {@code null} for {@code encoding}.
*
* @param mimeType the resource response's MIME type, for example {@code "text/html"}.
* @param encoding the resource response's character encoding, for example {@code "utf-8"}.
* @param data the input stream that provides the resource response's data. Must not be a
* StringBufferInputStream.
*/
@@ -63,8 +71,11 @@ public class WebResourceResponse {
* implement {@link InputStream#read(byte[]) InputStream.read(byte[])} for
* the input stream.
*
* @param mimeType the resource response's MIME type, for example text/html
* @param encoding the resource response's encoding
* <p class="note"><b>Note:</b> See {@link #WebResourceResponse(String,String,InputStream)}
* for details on what should be specified for {@code mimeType} and {@code encoding}.
*
* @param mimeType the resource response's MIME type, for example {@code "text/html"}.
* @param encoding the resource response's character encoding, for example {@code "utf-8"}.
* @param statusCode the status code needs to be in the ranges [100, 299], [400, 599].
* Causing a redirect by specifying a 3xx code is not supported.
* @param reasonPhrase the phrase describing the status code, for example "OK". Must be

View File

@@ -847,7 +847,7 @@ public class WebView extends AbsoluteLayout
/**
* Asynchronously evaluates JavaScript in the context of the currently displayed page.
* If non-null, |resultCallback| will be invoked with any result returned from that
* If non-null, {@code resultCallback} will be invoked with any result returned from that
* execution. This method must be called on the UI thread and the callback will
* be made on the UI thread.
* <p>

View File

@@ -31,6 +31,7 @@ import android.text.Layout;
import android.text.Selection;
import android.text.Spannable;
import android.text.TextUtils;
import android.text.util.Linkify;
import android.util.Log;
import android.view.ActionMode;
import android.view.textclassifier.SelectionEvent;
@@ -1045,7 +1046,12 @@ public final class SelectionActionModeHelper {
trimText();
final TextClassification classification;
if (mContext.getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.P) {
if (Linkify.containsUnsupportedCharacters(mText)) {
// Do not show smart actions for text containing unsupported characters.
android.util.EventLog.writeEvent(0x534e4554, "116321860", -1, "");
classification = TextClassification.EMPTY;
} else if (mContext.getApplicationInfo().targetSdkVersion
>= Build.VERSION_CODES.P) {
final TextClassification.Request request =
new TextClassification.Request.Builder(
mTrimmedText, mRelativeStart, mRelativeEnd)