diff options
| author | Xin Li <delphij@google.com> | 2019-02-23 00:39:16 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2019-02-23 00:39:16 +0000 |
| commit | f90d07b1b34bc63dfa7e72035f73680a54787ecc (patch) | |
| tree | e275779136a1b9b310e5df30f77641337a027f24 /core/java | |
| parent | bcaf7945791830a045273d7a6f7007b419f2e2bd (diff) | |
| parent | b455c3a7f3e98f7a576cdc21bdc96ae8ec30c8f0 (diff) | |
Merge "DO NOT MERGE - Merge pi-dev@5234907 into stage-aosp-master" into stage-aosp-master
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/app/Activity.java | 2 | ||||
| -rw-r--r-- | core/java/android/app/RemoteInput.java | 2 | ||||
| -rw-r--r-- | core/java/android/app/slice/Slice.java | 16 | ||||
| -rw-r--r-- | core/java/android/app/slice/SliceProvider.java | 2 | ||||
| -rw-r--r-- | core/java/android/content/ContentProvider.java | 12 | ||||
| -rw-r--r-- | core/java/android/database/sqlite/SQLiteQueryBuilder.java | 18 | ||||
| -rw-r--r-- | core/java/android/os/UserManager.java | 12 | ||||
| -rw-r--r-- | core/java/android/text/style/ImageSpan.java | 3 | ||||
| -rw-r--r-- | core/java/android/text/util/Linkify.java | 37 | ||||
| -rw-r--r-- | core/java/android/view/textclassifier/TextClassification.java | 2 | ||||
| -rw-r--r-- | core/java/android/view/textclassifier/TextLinksParams.java | 7 | ||||
| -rw-r--r-- | core/java/android/webkit/WebResourceResponse.java | 23 | ||||
| -rw-r--r-- | core/java/android/webkit/WebView.java | 2 | ||||
| -rw-r--r-- | core/java/android/widget/SelectionActionModeHelper.java | 8 | ||||
| -rw-r--r-- | core/java/com/android/internal/app/AssistUtils.java | 17 |
15 files changed, 104 insertions, 59 deletions
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java index 4b4611ee4f84..fd63cc77b28d 100644 --- a/core/java/android/app/Activity.java +++ b/core/java/android/app/Activity.java @@ -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) { diff --git a/core/java/android/app/RemoteInput.java b/core/java/android/app/RemoteInput.java index 85fe99d95969..b1c71209948d 100644 --- a/core/java/android/app/RemoteInput.java +++ b/core/java/android/app/RemoteInput.java @@ -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() { diff --git a/core/java/android/app/slice/Slice.java b/core/java/android/app/slice/Slice.java index e54d3b64f780..d1aec048bdf1 100644 --- a/core/java/android/app/slice/Slice.java +++ b/core/java/android/app/slice/Slice.java @@ -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) { diff --git a/core/java/android/app/slice/SliceProvider.java b/core/java/android/app/slice/SliceProvider.java index 4c22c94266d7..ea9c9dab21ee 100644 --- a/core/java/android/app/slice/SliceProvider.java +++ b/core/java/android/app/slice/SliceProvider.java @@ -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) { diff --git a/core/java/android/content/ContentProvider.java b/core/java/android/content/ContentProvider.java index 2997e984add4..f1b8d1e46449 100644 --- a/core/java/android/content/ContentProvider.java +++ b/core/java/android/content/ContentProvider.java @@ -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. diff --git a/core/java/android/database/sqlite/SQLiteQueryBuilder.java b/core/java/android/database/sqlite/SQLiteQueryBuilder.java index 982c10ae7fae..71760f28782b 100644 --- a/core/java/android/database/sqlite/SQLiteQueryBuilder.java +++ b/core/java/android/database/sqlite/SQLiteQueryBuilder.java @@ -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("=?"); } diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java index b5918519d872..9628c9562533 100644 --- a/core/java/android/os/UserManager.java +++ b/core/java/android/os/UserManager.java @@ -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. */ diff --git a/core/java/android/text/style/ImageSpan.java b/core/java/android/text/style/ImageSpan.java index d4edde9ec589..13ac9ff2ddaf 100644 --- a/core/java/android/text/style/ImageSpan.java +++ b/core/java/android/text/style/ImageSpan.java @@ -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() { diff --git a/core/java/android/text/util/Linkify.java b/core/java/android/text/util/Linkify.java index 9c8148de1e61..6a9119196744 100644 --- a/core/java/android/text/util/Linkify.java +++ b/core/java/android/text/util/Linkify.java @@ -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; } @@ -293,6 +302,29 @@ public class Linkify { } /** + * 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 * are found the movement method for the TextView is set to @@ -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) { diff --git a/core/java/android/view/textclassifier/TextClassification.java b/core/java/android/view/textclassifier/TextClassification.java index 9511a9efb3d5..49ca969fa7af 100644 --- a/core/java/android/view/textclassifier/TextClassification.java +++ b/core/java/android/view/textclassifier/TextClassification.java @@ -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. diff --git a/core/java/android/view/textclassifier/TextLinksParams.java b/core/java/android/view/textclassifier/TextLinksParams.java index be4c3bcdff67..c21206ca0258 100644 --- a/core/java/android/view/textclassifier/TextLinksParams.java +++ b/core/java/android/view/textclassifier/TextLinksParams.java @@ -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; } diff --git a/core/java/android/webkit/WebResourceResponse.java b/core/java/android/webkit/WebResourceResponse.java index aae3056f6191..e66596b5c0e9 100644 --- a/core/java/android/webkit/WebResourceResponse.java +++ b/core/java/android/webkit/WebResourceResponse.java @@ -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 diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index 8f03b693e587..91340925da95 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -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> diff --git a/core/java/android/widget/SelectionActionModeHelper.java b/core/java/android/widget/SelectionActionModeHelper.java index 6cb0eaa7f47d..0d88e6986f11 100644 --- a/core/java/android/widget/SelectionActionModeHelper.java +++ b/core/java/android/widget/SelectionActionModeHelper.java @@ -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) diff --git a/core/java/com/android/internal/app/AssistUtils.java b/core/java/com/android/internal/app/AssistUtils.java index fed0a89a4d75..4f742843eb12 100644 --- a/core/java/com/android/internal/app/AssistUtils.java +++ b/core/java/com/android/internal/app/AssistUtils.java @@ -32,8 +32,6 @@ import android.os.ServiceManager; import android.provider.Settings; import android.util.Log; -import com.android.internal.R; - /** * Utility method for dealing with the assistant aspects of * {@link com.android.internal.app.IVoiceInteractionManagerService IVoiceInteractionManagerService}. @@ -42,14 +40,6 @@ public class AssistUtils { private static final String TAG = "AssistUtils"; - /** - * Sentinel value for "no default assistant specified." - * - * Empty string is already used to represent an explicit setting of No Assistant. null cannot - * be used because we can't represent a null value in XML. - */ - private static final String UNSET = "#+UNSET"; - private final Context mContext; private final IVoiceInteractionManagerService mVoiceInteractionManagerService; @@ -164,7 +154,7 @@ public class AssistUtils { final String defaultSetting = mContext.getResources().getString( R.string.config_defaultAssistantComponentName); - if (defaultSetting != null && !defaultSetting.equals(UNSET)) { + if (defaultSetting != null) { return ComponentName.unflattenFromString(defaultSetting); } @@ -172,11 +162,6 @@ public class AssistUtils { if (activeServiceSupportsAssistGesture()) { return getActiveServiceComponentName(); } - - if (UNSET.equals(defaultSetting)) { - return null; - } - final SearchManager searchManager = (SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE); if (searchManager == null) { |
