Android-x86
Fork
Donation

  • R/O
  • HTTP
  • SSH
  • HTTPS

frameworks-base: 提交

frameworks/base


Commit MetaInfo

修订版47bf4965351ec0cfe650bb6877503f8fc537751f (tree)
时间2019-05-20 18:27:39
作者Chih-Wei Huang <cwhuang@linu...>
CommiterChih-Wei Huang

Log Message

Android 8.1.0 Release 64 (OPM8.190505.001)
-----BEGIN PGP SIGNATURE-----

iF0EABECAB0WIQRDQNE1cO+UXoOBCWTorT+BmrEOeAUCXNCVFAAKCRDorT+BmrEO
eBAqAKCC2xPt9cB+7Tlq2Ls3FpmxEy2rrACgjA+e4zhwpmxDrJHwh/B8xrgCn7c=
=kNTt
-----END PGP SIGNATURE-----

Merge tag 'android-8.1.0_r64' into oreo-x86

Android 8.1.0 Release 64 (OPM8.190505.001)

更改概述

差异

--- a/core/java/android/bluetooth/BluetoothHidDeviceAppSdpSettings.java
+++ b/core/java/android/bluetooth/BluetoothHidDeviceAppSdpSettings.java
@@ -18,12 +18,15 @@ package android.bluetooth;
1818
1919 import android.os.Parcel;
2020 import android.os.Parcelable;
21+import android.util.EventLog;
2122
2223 import java.util.Random;
2324
2425 /** @hide */
2526 public final class BluetoothHidDeviceAppSdpSettings implements Parcelable {
2627
28+ private static final int MAX_DESCRIPTOR_SIZE = 2048;
29+
2730 final public String name;
2831 final public String description;
2932 final public String provider;
@@ -36,6 +39,12 @@ public final class BluetoothHidDeviceAppSdpSettings implements Parcelable {
3639 this.description = description;
3740 this.provider = provider;
3841 this.subclass = subclass;
42+
43+ if (descriptors == null || descriptors.length > MAX_DESCRIPTOR_SIZE) {
44+ EventLog.writeEvent(0x534e4554, "119819889", -1, "");
45+ throw new IllegalArgumentException("descriptors must be not null and shorter than "
46+ + MAX_DESCRIPTOR_SIZE);
47+ }
3948 this.descriptors = descriptors.clone();
4049 }
4150
--- a/core/java/android/os/UserHandle.java
+++ b/core/java/android/os/UserHandle.java
@@ -132,6 +132,19 @@ public final class UserHandle implements Parcelable {
132132 }
133133
134134 /**
135+ * Whether a UID belongs to a system core component or not.
136+ * @hide
137+ */
138+ public static boolean isCore(int uid) {
139+ if (uid >= 0) {
140+ final int appId = getAppId(uid);
141+ return appId < Process.FIRST_APPLICATION_UID;
142+ } else {
143+ return false;
144+ }
145+ }
146+
147+ /**
135148 * Returns the user for a given uid.
136149 * @param uid A uid for an application running in a particular user.
137150 * @return A {@link UserHandle} for that user.
--- a/core/java/android/text/util/Linkify.java
+++ b/core/java/android/text/util/Linkify.java
@@ -28,6 +28,7 @@ import android.text.Spanned;
2828 import android.text.method.LinkMovementMethod;
2929 import android.text.method.MovementMethod;
3030 import android.text.style.URLSpan;
31+import android.util.Log;
3132 import android.util.Patterns;
3233 import android.webkit.WebView;
3334 import android.widget.TextView;
@@ -66,6 +67,9 @@ import java.util.regex.Pattern;
6667 */
6768
6869 public class Linkify {
70+
71+ private static final String LOG_TAG = "Linkify";
72+
6973 /**
7074 * Bit field indicating that web URLs should be matched in methods that
7175 * take an options mask
@@ -228,6 +232,11 @@ public class Linkify {
228232
229233 private static boolean addLinks(@NonNull Spannable text, @LinkifyMask int mask,
230234 @Nullable Context context) {
235+ if (text != null && containsUnsupportedCharacters(text.toString())) {
236+ android.util.EventLog.writeEvent(0x534e4554, "116321860", -1, "");
237+ return false;
238+ }
239+
231240 if (mask == 0) {
232241 return false;
233242 }
@@ -274,6 +283,29 @@ public class Linkify {
274283 }
275284
276285 /**
286+ * Returns true if the specified text contains at least one unsupported character for applying
287+ * links. Also logs the error.
288+ *
289+ * @param text the text to apply links to
290+ * @hide
291+ */
292+ public static boolean containsUnsupportedCharacters(String text) {
293+ if (text.contains("\u202C")) {
294+ Log.e(LOG_TAG, "Unsupported character for applying links: u202C");
295+ return true;
296+ }
297+ if (text.contains("\u202D")) {
298+ Log.e(LOG_TAG, "Unsupported character for applying links: u202D");
299+ return true;
300+ }
301+ if (text.contains("\u202E")) {
302+ Log.e(LOG_TAG, "Unsupported character for applying links: u202E");
303+ return true;
304+ }
305+ return false;
306+ }
307+
308+ /**
277309 * Scans the text of the provided TextView and turns all occurrences of
278310 * the link types indicated in the mask into clickable links. If matches
279311 * are found the movement method for the TextView is set to
@@ -420,6 +452,10 @@ public class Linkify {
420452 public static final boolean addLinks(@NonNull Spannable spannable, @NonNull Pattern pattern,
421453 @Nullable String scheme, @Nullable MatchFilter matchFilter,
422454 @Nullable TransformFilter transformFilter) {
455+ if (spannable != null && containsUnsupportedCharacters(spannable.toString())) {
456+ android.util.EventLog.writeEvent(0x534e4554, "116321860", -1, "");
457+ return false;
458+ }
423459 return addLinks(spannable, pattern, scheme, null, matchFilter,
424460 transformFilter);
425461 }
--- a/core/java/android/view/textclassifier/TextClassification.java
+++ b/core/java/android/view/textclassifier/TextClassification.java
@@ -38,7 +38,7 @@ public final class TextClassification {
3838 /**
3939 * @hide
4040 */
41- static final TextClassification EMPTY = new TextClassification.Builder().build();
41+ public static final TextClassification EMPTY = new TextClassification.Builder().build();
4242
4343 @NonNull private final String mText;
4444 @Nullable private final Drawable mIcon;
--- a/core/java/android/widget/SelectionActionModeHelper.java
+++ b/core/java/android/widget/SelectionActionModeHelper.java
@@ -25,6 +25,7 @@ import android.os.LocaleList;
2525 import android.text.Selection;
2626 import android.text.Spannable;
2727 import android.text.TextUtils;
28+import android.text.util.Linkify;
2829 import android.util.Log;
2930 import android.view.ActionMode;
3031 import android.view.textclassifier.TextClassification;
@@ -692,11 +693,19 @@ final class SelectionActionModeHelper {
692693 mLastClassificationLocales = mLocales;
693694
694695 trimText();
696+ final TextClassification classification;
697+ if (Linkify.containsUnsupportedCharacters(mText)) {
698+ // Do not show smart actions for text containing unsupported characters.
699+ android.util.EventLog.writeEvent(0x534e4554, "116321860", -1, "");
700+ classification = TextClassification.EMPTY;
701+ } else {
702+ classification = mTextClassifier.classifyText(
703+ mTrimmedText, mRelativeStart, mRelativeEnd, mLocales);
704+ }
695705 mLastClassificationResult = new SelectionResult(
696706 mSelectionStart,
697707 mSelectionEnd,
698- mTextClassifier.classifyText(
699- mTrimmedText, mRelativeStart, mRelativeEnd, mLocales),
708+ classification,
700709 selection);
701710
702711 }
--- a/core/tests/coretests/src/android/widget/TextViewActivityTest.java
+++ b/core/tests/coretests/src/android/widget/TextViewActivityTest.java
@@ -839,6 +839,19 @@ public class TextViewActivityTest {
839839 }
840840
841841 @Test
842+ public void testNoAssistItemForTextFieldWithUnsupportedCharacters() throws Throwable {
843+ useSystemDefaultTextClassifier();
844+ final String text = "\u202Emoc.diordna.com";
845+ final TextView textView = mActivity.findViewById(R.id.textview);
846+ mActivityRule.runOnUiThread(() -> textView.setText(text));
847+ mInstrumentation.waitForIdleSync();
848+
849+ onView(withId(R.id.textview)).perform(longPressOnTextAtIndex(text.indexOf('.')));
850+ sleepForFloatingToolbarPopup();
851+ assertFloatingToolbarDoesNotContainItem(android.R.id.textAssist);
852+ }
853+
854+ @Test
842855 public void testPastePlainText_menuAction() {
843856 initializeClipboardWithText(TextStyle.STYLED);
844857
--- a/location/java/com/android/internal/location/GpsNetInitiatedHandler.java
+++ b/location/java/com/android/internal/location/GpsNetInitiatedHandler.java
@@ -17,6 +17,7 @@
1717 package com.android.internal.location;
1818
1919 import java.io.UnsupportedEncodingException;
20+import java.util.concurrent.TimeUnit;
2021
2122 import android.app.Notification;
2223 import android.app.NotificationManager;
@@ -27,6 +28,7 @@ import android.content.Intent;
2728 import android.content.IntentFilter;
2829 import android.location.LocationManager;
2930 import android.location.INetInitiatedListener;
31+import android.os.SystemClock;
3032 import android.telephony.TelephonyManager;
3133 import android.telephony.PhoneNumberUtils;
3234 import android.telephony.PhoneStateListener;
@@ -50,8 +52,7 @@ public class GpsNetInitiatedHandler {
5052
5153 private static final String TAG = "GpsNetInitiatedHandler";
5254
53- private static final boolean DEBUG = true;
54- private static final boolean VERBOSE = false;
55+ private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
5556
5657 // NI verify activity for bringing up UI (not used yet)
5758 public static final String ACTION_NI_VERIFY = "android.intent.action.NETWORK_INITIATED_VERIFY";
@@ -94,6 +95,9 @@ public class GpsNetInitiatedHandler {
9495 public static final int GPS_ENC_SUPL_UCS2 = 3;
9596 public static final int GPS_ENC_UNKNOWN = -1;
9697
98+ // Limit on SUPL NI emergency mode time extension after emergency sessions ends
99+ private static final int MAX_EMERGENCY_MODE_EXTENSION_SECONDS = 300; // 5 minute maximum
100+
97101 private final Context mContext;
98102 private final TelephonyManager mTelephonyManager;
99103 private final PhoneStateListener mPhoneStateListener;
@@ -109,7 +113,7 @@ public class GpsNetInitiatedHandler {
109113 private volatile boolean mIsSuplEsEnabled;
110114
111115 // Set to true if the phone is having emergency call.
112- private volatile boolean mIsInEmergency;
116+ private volatile boolean mIsInEmergencyCall;
113117
114118 // If Location function is enabled.
115119 private volatile boolean mIsLocationEnabled = false;
@@ -119,6 +123,10 @@ public class GpsNetInitiatedHandler {
119123 // Set to true if string from HAL is encoded as Hex, e.g., "3F0039"
120124 static private boolean mIsHexInput = true;
121125
126+ // End time of emergency call, and extension, if set
127+ private volatile long mCallEndElapsedRealtimeMillis = 0;
128+ private volatile long mEmergencyExtensionMillis = 0;
129+
122130 public static class GpsNiNotification
123131 {
124132 public int notificationId;
@@ -146,16 +154,12 @@ public class GpsNetInitiatedHandler {
146154 if (action.equals(Intent.ACTION_NEW_OUTGOING_CALL)) {
147155 String phoneNumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
148156 /*
149- Emergency Mode is when during emergency call or in emergency call back mode.
150- For checking if it is during emergency call:
151- mIsInEmergency records if the phone is in emergency call or not. It will
157+ Tracks the emergency call:
158+ mIsInEmergencyCall records if the phone is in emergency call or not. It will
152159 be set to true when the phone is having emergency call, and then will
153160 be set to false by mPhoneStateListener when the emergency call ends.
154- For checking if it is in emergency call back mode:
155- Emergency call back mode will be checked by reading system properties
156- when necessary: SystemProperties.get(TelephonyProperties.PROPERTY_INECM_MODE)
157161 */
158- setInEmergency(PhoneNumberUtils.isEmergencyNumber(phoneNumber));
162+ mIsInEmergencyCall = PhoneNumberUtils.isEmergencyNumber(phoneNumber);
159163 if (DEBUG) Log.v(TAG, "ACTION_NEW_OUTGOING_CALL - " + getInEmergency());
160164 } else if (action.equals(LocationManager.MODE_CHANGED_ACTION)) {
161165 updateLocationMode();
@@ -195,7 +199,10 @@ public class GpsNetInitiatedHandler {
195199 if (DEBUG) Log.d(TAG, "onCallStateChanged(): state is "+ state);
196200 // listening for emergency call ends
197201 if (state == TelephonyManager.CALL_STATE_IDLE) {
198- setInEmergency(false);
202+ if (mIsInEmergencyCall) {
203+ mCallEndElapsedRealtimeMillis = SystemClock.elapsedRealtime();
204+ mIsInEmergencyCall = false;
205+ }
199206 }
200207 }
201208 };
@@ -229,22 +236,36 @@ public class GpsNetInitiatedHandler {
229236 return mIsLocationEnabled;
230237 }
231238
232- // Note: Currently, there are two mechanisms involved to determine if a
233- // phone is in emergency mode:
234- // 1. If the user is making an emergency call, this is provided by activly
235- // monitoring the outgoing phone number;
236- // 2. If the device is in a emergency callback state, this is provided by
237- // system properties.
238- // If either one of above exists, the phone is considered in an emergency
239- // mode. Because of this complexity, we need to be careful about how to set
240- // and clear the emergency state.
241- public void setInEmergency(boolean isInEmergency) {
242- mIsInEmergency = isInEmergency;
243- }
244-
239+ /**
240+ * Determines whether device is in user-initiated emergency session based on the following
241+ * 1. If the user is making an emergency call, this is provided by actively
242+ * monitoring the outgoing phone number;
243+ * 2. If the user has recently ended an emergency call, and the device is in a configured time
244+ * window after the end of that call.
245+ * 3. If the device is in a emergency callback state, this is provided by querying
246+ * TelephonyManager.
247+ * @return true if is considered in user initiated emergency mode for NI purposes
248+ */
245249 public boolean getInEmergency() {
250+ boolean isInEmergencyExtension =
251+ (mCallEndElapsedRealtimeMillis > 0)
252+ && ((SystemClock.elapsedRealtime() - mCallEndElapsedRealtimeMillis)
253+ < mEmergencyExtensionMillis);
246254 boolean isInEmergencyCallback = mTelephonyManager.getEmergencyCallbackMode();
247- return mIsInEmergency || isInEmergencyCallback;
255+ return mIsInEmergencyCall || isInEmergencyCallback || isInEmergencyExtension;
256+ }
257+
258+ public void setEmergencyExtensionSeconds(int emergencyExtensionSeconds) {
259+ if (emergencyExtensionSeconds > MAX_EMERGENCY_MODE_EXTENSION_SECONDS) {
260+ Log.w(TAG, "emergencyExtensionSeconds " + emergencyExtensionSeconds
261+ + " too high, reset to " + MAX_EMERGENCY_MODE_EXTENSION_SECONDS);
262+ emergencyExtensionSeconds = MAX_EMERGENCY_MODE_EXTENSION_SECONDS;
263+ } else if (emergencyExtensionSeconds < 0) {
264+ Log.w(TAG, "emergencyExtensionSeconds " + emergencyExtensionSeconds
265+ + " is negative, reset to zero.");
266+ emergencyExtensionSeconds = 0;
267+ }
268+ mEmergencyExtensionMillis = TimeUnit.SECONDS.toMillis(emergencyExtensionSeconds);
248269 }
249270
250271
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -8021,6 +8021,14 @@ public class ActivityManagerService extends IActivityManager.Stub
80218021
80228022 @Override
80238023 public boolean isAppForeground(int uid) throws RemoteException {
8024+ int callerUid = Binder.getCallingUid();
8025+ if (UserHandle.isCore(callerUid) || callerUid == uid) {
8026+ return isAppForegroundInternal(uid);
8027+ }
8028+ return false;
8029+ }
8030+
8031+ private boolean isAppForegroundInternal(int uid) {
80248032 synchronized (this) {
80258033 UidRecord uidRec = mActiveUids.get(uid);
80268034 if (uidRec == null || uidRec.idle) {
--- a/services/core/java/com/android/server/location/GnssLocationProvider.java
+++ b/services/core/java/com/android/server/location/GnssLocationProvider.java
@@ -651,6 +651,17 @@ public class GnssLocationProvider implements LocationProviderInterface {
651651 Log.e(TAG, "unable to parse SUPL_ES: " + suplESProperty);
652652 }
653653 }
654+
655+ String emergencyExtensionSecondsString
656+ = properties.getProperty("ES_EXTENSION_SEC", "0");
657+ try {
658+ int emergencyExtensionSeconds =
659+ Integer.parseInt(emergencyExtensionSecondsString);
660+ mNIHandler.setEmergencyExtensionSeconds(emergencyExtensionSeconds);
661+ } catch (NumberFormatException e) {
662+ Log.e(TAG, "unable to parse ES_EXTENSION_SEC: "
663+ + emergencyExtensionSecondsString);
664+ }
654665 }
655666
656667 private void loadPropertiesFromResource(Context context,
@@ -729,12 +740,11 @@ public class GnssLocationProvider implements LocationProviderInterface {
729740 // while IO initialization and registration is delegated to our internal handler
730741 // this approach is just fine because events are posted to our handler anyway
731742 mProperties = new Properties();
732- sendMessage(INITIALIZE_HANDLER, 0, null);
733-
734- // Create a GPS net-initiated handler.
743+ // Create a GPS net-initiated handler (also needed by handleInitialize)
735744 mNIHandler = new GpsNetInitiatedHandler(context,
736745 mNetInitiatedListener,
737746 mSuplEsEnabled);
747+ sendMessage(INITIALIZE_HANDLER, 0, null);
738748
739749 mListenerHelper = new GnssStatusListenerHelper(mHandler) {
740750 @Override
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -4352,18 +4352,16 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
43524352 quality = DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED;
43534353 }
43544354 final PasswordMetrics metrics = PasswordMetrics.computeForPassword(password);
4355- if (quality != DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED) {
4356- final int realQuality = metrics.quality;
4357- if (realQuality < quality
4358- && quality != DevicePolicyManager.PASSWORD_QUALITY_COMPLEX) {
4359- Slog.w(LOG_TAG, "resetPassword: password quality 0x"
4360- + Integer.toHexString(realQuality)
4361- + " does not meet required quality 0x"
4362- + Integer.toHexString(quality));
4363- return false;
4364- }
4365- quality = Math.max(realQuality, quality);
4355+ final int realQuality = metrics.quality;
4356+ if (realQuality < quality
4357+ && quality != DevicePolicyManager.PASSWORD_QUALITY_COMPLEX) {
4358+ Slog.w(LOG_TAG, "resetPassword: password quality 0x"
4359+ + Integer.toHexString(realQuality)
4360+ + " does not meet required quality 0x"
4361+ + Integer.toHexString(quality));
4362+ return false;
43664363 }
4364+ quality = Math.max(realQuality, quality);
43674365 int length = getPasswordMinimumLength(null, userHandle, /* parent */ false);
43684366 if (password.length() < length) {
43694367 Slog.w(LOG_TAG, "resetPassword: password length " + password.length()
@@ -4449,7 +4447,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
44494447 result = mLockPatternUtils.setLockCredentialWithToken(password,
44504448 TextUtils.isEmpty(password) ? LockPatternUtils.CREDENTIAL_TYPE_NONE
44514449 : LockPatternUtils.CREDENTIAL_TYPE_PASSWORD,
4452- quality, tokenHandle, token, userHandle);
4450+ quality, tokenHandle, token, userHandle);
44534451 }
44544452 boolean requireEntry = (flags & DevicePolicyManager.RESET_PASSWORD_REQUIRE_ENTRY) != 0;
44554453 if (requireEntry) {
--- a/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java
+++ b/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java
@@ -3654,7 +3654,7 @@ public class DevicePolicyManagerTest extends DpmTestBase {
36543654 // test reset password with token
36553655 when(getServices().lockPatternUtils.setLockCredentialWithToken(eq(password),
36563656 eq(LockPatternUtils.CREDENTIAL_TYPE_PASSWORD),
3657- eq(DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED), eq(handle), eq(token),
3657+ eq(DevicePolicyManager.PASSWORD_QUALITY_ALPHABETIC), eq(handle), eq(token),
36583658 eq(UserHandle.USER_SYSTEM)))
36593659 .thenReturn(true);
36603660 assertTrue(dpm.resetPasswordWithToken(admin1, password, token, 0));
Show on old repository browser