From a5866c647e8cc5fff695bec2262ea697475409cd Mon Sep 17 00:00:00 2001 From: Stanley Tng Date: Tue, 19 Jun 2018 08:48:10 -0700 Subject: Add Feature Flag for Hearing Aid Profile Using the Settings App-Developer Options-Feature Flag, allow the user to enable or disable the Hearing Aid Profile. Bug: 116317072 Bug: 116044083 Test: Manual testing using Settings App Merged-In: I58a9d339941e235242c443c85b6f4194b5a296c9 (cherry picked from commit fe8c8337edc5e9d6b61d0942873538912d523db7) Change-Id: I7d0b6759e7acba3fb2a4d1afdba35d5a95387777 --- core/java/android/util/FeatureFlagUtils.java | 3 +++ 1 file changed, 3 insertions(+) (limited to 'core/java/android') diff --git a/core/java/android/util/FeatureFlagUtils.java b/core/java/android/util/FeatureFlagUtils.java index cec0df02247c..959534d24f59 100644 --- a/core/java/android/util/FeatureFlagUtils.java +++ b/core/java/android/util/FeatureFlagUtils.java @@ -34,6 +34,8 @@ public class FeatureFlagUtils { public static final String FFLAG_PREFIX = "sys.fflag."; public static final String FFLAG_OVERRIDE_PREFIX = FFLAG_PREFIX + "override."; public static final String EMERGENCY_DIAL_SHORTCUTS = "settings_emergency_dial_shortcuts"; + public static final String PERSIST_PREFIX = "persist." + FFLAG_OVERRIDE_PREFIX; + public static final String HEARING_AID_SETTINGS = "settings_bluetooth_hearing_aid"; private static final Map DEFAULT_FLAGS; static { @@ -46,6 +48,7 @@ public class FeatureFlagUtils { DEFAULT_FLAGS.put("settings_audio_switcher", "true"); DEFAULT_FLAGS.put("settings_systemui_theme", "true"); DEFAULT_FLAGS.put(EMERGENCY_DIAL_SHORTCUTS, "false"); + DEFAULT_FLAGS.put(HEARING_AID_SETTINGS, "true"); } /** -- cgit v1.2.3 From 55581d99b56ea0d7b9e6cdcfca412ef8ae146201 Mon Sep 17 00:00:00 2001 From: Nan Zhang Date: Thu, 11 Oct 2018 17:54:36 -0700 Subject: Fix the incorrect javadoc links A lot of unresolved link errors showing up after go/ag/5172152. Test: m -j docs with -lerror enabled Bug: b/116163454 Change-Id: I74d1f75e0f00015410a63e13103c28a9c84b4fe0 --- core/java/android/bluetooth/BluetoothDevice.java | 4 +--- core/java/android/bluetooth/BluetoothServerSocket.java | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) (limited to 'core/java/android') diff --git a/core/java/android/bluetooth/BluetoothDevice.java b/core/java/android/bluetooth/BluetoothDevice.java index fc0c1dc43874..b8e7e3044ca4 100644 --- a/core/java/android/bluetooth/BluetoothDevice.java +++ b/core/java/android/bluetooth/BluetoothDevice.java @@ -1971,9 +1971,7 @@ public final class BluetoothDevice implements Parcelable { *

The remote device will be authenticated and communication on this socket will be * encrypted. *

Use this socket if an authenticated socket link is possible. Authentication refers - * to the authentication of the link key to prevent man-in-the-middle type of attacks. When a - * secure socket connection is not possible, use {@link createInsecureLeL2capCocSocket(int, - * int)}. + * to the authentication of the link key to prevent man-in-the-middle type of attacks. * * @param psm dynamic PSM value from remote device * @return a CoC #BluetoothSocket ready for an outgoing connection diff --git a/core/java/android/bluetooth/BluetoothServerSocket.java b/core/java/android/bluetooth/BluetoothServerSocket.java index 758c68db1c5f..4e886250b4fa 100644 --- a/core/java/android/bluetooth/BluetoothServerSocket.java +++ b/core/java/android/bluetooth/BluetoothServerSocket.java @@ -203,8 +203,8 @@ public final class BluetoothServerSocket implements Closeable { /** * Returns the assigned dynamic protocol/service multiplexer (PSM) value for the listening L2CAP * Connection-oriented Channel (CoC) server socket. This server socket must be returned by the - * {@link BluetoothAdapter.listenUsingL2capChannel()} or {@link - * BluetoothAdapter.listenUsingInsecureL2capChannel()}. The returned value is undefined if this + * {@link BluetoothAdapter#listenUsingL2capChannel()} or {@link + * BluetoothAdapter#listenUsingInsecureL2capChannel()}. The returned value is undefined if this * method is called on non-L2CAP server sockets. * * @return the assigned PSM or LE_PSM value depending on transport -- cgit v1.2.3 From 63519217e8c0682369b5b3dc11417f79b3b48b7e Mon Sep 17 00:00:00 2001 From: Jakub Pawlowski Date: Thu, 29 Nov 2018 18:54:21 +0100 Subject: Bluetooth: Check descriptors size in BluetoothHidDeviceAppSdpSettings Bug: 119819889 Test: compilation Change-Id: If51d0e2af74d99758f79a603d40cc2f5c84e4dde --- .../java/android/bluetooth/BluetoothHidDeviceAppSdpSettings.java | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'core/java/android') diff --git a/core/java/android/bluetooth/BluetoothHidDeviceAppSdpSettings.java b/core/java/android/bluetooth/BluetoothHidDeviceAppSdpSettings.java index 237082e4cb66..2f0b44f76ffb 100644 --- a/core/java/android/bluetooth/BluetoothHidDeviceAppSdpSettings.java +++ b/core/java/android/bluetooth/BluetoothHidDeviceAppSdpSettings.java @@ -18,6 +18,7 @@ package android.bluetooth; import android.os.Parcel; import android.os.Parcelable; +import android.util.EventLog; /** @@ -30,6 +31,8 @@ import android.os.Parcelable; */ public final class BluetoothHidDeviceAppSdpSettings implements Parcelable { + private static final int MAX_DESCRIPTOR_SIZE = 2048; + private final String mName; private final String mDescription; private final String mProvider; @@ -55,6 +58,12 @@ public final class BluetoothHidDeviceAppSdpSettings implements Parcelable { mDescription = description; mProvider = provider; mSubclass = subclass; + + if (descriptors == null || descriptors.length > MAX_DESCRIPTOR_SIZE) { + EventLog.writeEvent(0x534e4554, "119819889", -1, ""); + throw new IllegalArgumentException("descriptors must be not null and shorter than " + + MAX_DESCRIPTOR_SIZE); + } mDescriptors = descriptors.clone(); } -- cgit v1.2.3 From 8a788f409423bf0e3badce3c8436eb9886084eaa Mon Sep 17 00:00:00 2001 From: Andrew Solovay Date: Wed, 12 Dec 2018 14:25:47 -0800 Subject: docs: Fixing malformed @links Several @link javadoc directives were malformed, resulting in the Javadoc code being output to the HTML. Staged to: http://go/dac-stage/reference/android/app/Activity http://go/dac-stage/reference/android/app/RemoteInput http://go/dac-stage/android/os/UserManager Bug: 120743732 Test: make ds-docs Change-Id: I2c00c7e1e3adcff696e6d000206aeeaea61e7ecd Exempt-From-Owner-Approval: Doc-only change --- core/java/android/app/Activity.java | 2 +- core/java/android/app/RemoteInput.java | 2 +- core/java/android/os/UserManager.java | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'core/java/android') diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java index 5cc35ce01ecb..85a969b80032 100644 --- a/core/java/android/app/Activity.java +++ b/core/java/android/app/Activity.java @@ -2154,7 +2154,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/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. * *

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). * *

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. */ -- cgit v1.2.3 From 6eaf48ea5720a901249dddd390b78e6a1efe14aa Mon Sep 17 00:00:00 2001 From: Andrew Solovay Date: Wed, 12 Dec 2018 15:38:06 -0800 Subject: docs: Fixing malformed javadoc Several @link & @see javadoc directives were malformed, resulting in the Javadoc code being output to the HTML. Staged to: http://go/dac-stage/reference/android/app/slice/Slice.Builder http://go/dac-stage/reference/android/app/slice/SliceProvider http://go/dac-stage/reference/android/text/style/ImageSpan http://go/dac-stage/reference/android/content/ContentProvider Bug: 120743732 Test: make ds-docs Change-Id: I589644f8d266a116441409fbdaf7a0c533e0e356 Merged-In: I589644f8d266a116441409fbdaf7a0c533e0e356 Exempt-From-Owner-Approval: Doc-only change --- core/java/android/app/slice/Slice.java | 16 ++++++++-------- core/java/android/app/slice/SliceProvider.java | 2 +- core/java/android/content/ContentProvider.java | 12 ++++++------ core/java/android/text/style/ImageSpan.java | 3 ++- 4 files changed, 17 insertions(+), 16 deletions(-) (limited to 'core/java/android') 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 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 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 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 hints) { @@ -525,7 +525,7 @@ public final class Slice implements Parcelable { *

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 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 supportedSpecs) { diff --git a/core/java/android/content/ContentProvider.java b/core/java/android/content/ContentProvider.java index abc1481dabaf..0d1d2d3478ee 100644 --- a/core/java/android/content/ContentProvider.java +++ b/core/java/android/content/ContentProvider.java @@ -1062,12 +1062,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)}. * *

Traditional SQL arguments can be found in the bundle using the following keys: - *

  • {@link ContentResolver#QUERY_ARG_SQL_SELECTION} - *
  • {@link ContentResolver#QUERY_ARG_SQL_SELECTION_ARGS} - *
  • {@link ContentResolver#QUERY_ARG_SQL_SORT_ORDER} + *
  • {@link android.content.ContentResolver#QUERY_ARG_SQL_SELECTION} + *
  • {@link android.content.ContentResolver#QUERY_ARG_SQL_SELECTION_ARGS} + *
  • {@link android.content.ContentResolver#QUERY_ARG_SQL_SORT_ORDER} * *

    This method can be called from multiple threads, as described in * Processes @@ -1124,8 +1124,8 @@ public abstract class ContentProvider implements ComponentCallbacks2 { return cursor; *

    - * @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/text/style/ImageSpan.java b/core/java/android/text/style/ImageSpan.java index 95f0b43341a2..1cb1634a67bd 100644 --- a/core/java/android/text/style/ImageSpan.java +++ b/core/java/android/text/style/ImageSpan.java @@ -257,7 +257,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() { -- cgit v1.2.3 From c848639f0809223ddb71d54c4a93f3ad8cf574a5 Mon Sep 17 00:00:00 2001 From: "Torne (Richard Coles)" Date: Wed, 12 Dec 2018 11:11:33 -0500 Subject: Clarify WebResourceResponse parameter documentation. Developers commonly misuse the mimeType and encoding parameters in the WebResourceResponse constructor as the meaning is different to the similarly named HTTP headers. Explain more carefully what valid/invalid inputs look like and mention that this is different to HTTP. Change-Id: I14d159bc50c89c2215f7de5f4732569e5e246930 Fixes: 64765685 Test: m offline-sdk-docs --- core/java/android/webkit/WebResourceResponse.java | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'core/java/android') diff --git a/core/java/android/webkit/WebResourceResponse.java b/core/java/android/webkit/WebResourceResponse.java index 7bc7b07d2fc1..e2d65e5a494f 100644 --- a/core/java/android/webkit/WebResourceResponse.java +++ b/core/java/android/webkit/WebResourceResponse.java @@ -38,13 +38,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 + *

    Note: 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. */ @@ -60,8 +68,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 + *

    Note: 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 -- cgit v1.2.3 From e0938b86aeb9609739a9c1dc05d05707e6cf08c2 Mon Sep 17 00:00:00 2001 From: Nate Fischer Date: Wed, 26 Dec 2018 15:36:35 -0800 Subject: WebView: no bars in javadoc No change to logic, only docs change. The bar/pipe symbols have no meaning in javadoc. We should mark this with {@code} instead. Bug: 122046530 Test: None Change-Id: I594480ea3bf4fec9c87a48275364c7c616a0e3ea --- core/java/android/webkit/WebView.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core/java/android') diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index 9371342ae1a0..a9781e397946 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -837,7 +837,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. *

    -- cgit v1.2.3 From a69950ce18f85ea8514083a5e175450e17e93565 Mon Sep 17 00:00:00 2001 From: Abodunrinwa Toki Date: Thu, 29 Nov 2018 13:51:56 +0000 Subject: RESTRICT AUTOMERGE Do not linkify text with RLO/LRO characters. Also don't show smart actions for selections in text with unsupported characters. Bug: 116321860 Test: atest android.view.textclassifier.TextClassificationManagerTest \ android.text.util.cts.LinkifyTest \ android.text.util.LinkifyTest \ android.widget.TextViewActivityTest Change-Id: I01b5e936aa4dfc937a98f50e9fc8171666861a61 --- core/java/android/text/util/Linkify.java | 37 ++++++++++++++++++++++ .../view/textclassifier/TextClassification.java | 2 +- .../view/textclassifier/TextLinksParams.java | 7 ++++ .../android/widget/SelectionActionModeHelper.java | 8 ++++- 4 files changed, 52 insertions(+), 2 deletions(-) (limited to 'core/java/android') diff --git a/core/java/android/text/util/Linkify.java b/core/java/android/text/util/Linkify.java index c905f49569d7..dc68da0310b6 100644 --- a/core/java/android/text/util/Linkify.java +++ b/core/java/android/text/util/Linkify.java @@ -29,6 +29,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; @@ -77,6 +78,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 @@ -246,6 +250,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; } @@ -291,6 +300,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 @@ -461,6 +493,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/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) -- cgit v1.2.3 From 8a39bb142b3955053591e390371e7617485006cb Mon Sep 17 00:00:00 2001 From: Raman Tenneti Date: Tue, 5 Feb 2019 16:34:43 -0800 Subject: Fix merge problems with cherry-picking "Add notification settings to backup&restore" change into pi-dev On 9/28 CL https://googleplex-android-review.git.corp.google.com/5116913 was checked into pi-dev. Merge was bad(couple of lines were lost during merge). https://b.corp.google.com/issues/35655737#comment34 Adding LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS and LOCK_SCREEN_SHOW_NOTIFICATIONS to SETTINGS_TO_BACKUP array. This fixes apct/framework/presubmit test failure. Bug: 35655737 Bug: 118674794 Test: presubmit unit tests Change-Id: I2e9cc95e8827e72ef3c09910d4d3e089bde375e5 Merged-In: I421c7487955ee339f88e3957c973375d0f87e2ff (cherry picked from commit 33a11bd0e3c29937af311bc55bbbe36ee63608f4) --- core/java/android/provider/Settings.java | 2 ++ 1 file changed, 2 insertions(+) (limited to 'core/java/android') diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index af1a83d0fab7..e945c5fb12fb 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -8146,6 +8146,8 @@ public final class Settings { VOLUME_HUSH_GESTURE, MANUAL_RINGER_TOGGLE_COUNT, HUSH_GESTURE_USED, + LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, + LOCK_SCREEN_SHOW_NOTIFICATIONS, }; /** -- cgit v1.2.3