• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

frameworks/base


Commit MetaInfo

修訂d369253fab4986f4136f5035c10abc0f5f52c947 (tree)
時間2016-10-06 00:46:44
作者Chih-Wei Huang <cwhuang@linu...>
CommiterChih-Wei Huang

Log Message

Android 7.0.0 Release 7 (NRD91D)
-----BEGIN PGP SIGNATURE-----

iEYEABECAAYFAlfzAGEACgkQ6K0/gZqxDnh/gQCfWRCR7QmLvwbmY8cyR88fNNoS
FvwAnjqncP+SFkJFfWL2Af9qbnudBvbW
=KDKZ
-----END PGP SIGNATURE-----

Merge tag 'android-7.0.0_r7' into nougat-x86

Android 7.0.0 Release 7 (NRD91D)

Change Summary

差異

--- a/core/java/android/accessibilityservice/AccessibilityService.java
+++ b/core/java/android/accessibilityservice/AccessibilityService.java
@@ -628,8 +628,8 @@ public abstract class AccessibilityService extends Service {
628628 if (connection == null) {
629629 return false;
630630 }
631- List<MotionEvent> events = MotionEventGenerator.getMotionEventsFromGestureDescription(
632- gesture, 100);
631+ List<GestureDescription.GestureStep> steps =
632+ MotionEventGenerator.getGestureStepsFromGestureDescription(gesture, 100);
633633 try {
634634 synchronized (mLock) {
635635 mGestureStatusCallbackSequence++;
@@ -641,8 +641,8 @@ public abstract class AccessibilityService extends Service {
641641 callback, handler);
642642 mGestureStatusCallbackInfos.put(mGestureStatusCallbackSequence, callbackInfo);
643643 }
644- connection.sendMotionEvents(mGestureStatusCallbackSequence,
645- new ParceledListSlice<>(events));
644+ connection.sendGesture(mGestureStatusCallbackSequence,
645+ new ParceledListSlice<>(steps));
646646 }
647647 } catch (RemoteException re) {
648648 throw new RuntimeException(re);
--- a/core/java/android/accessibilityservice/GestureDescription.java
+++ b/core/java/android/accessibilityservice/GestureDescription.java
@@ -21,6 +21,8 @@ import android.annotation.NonNull;
2121 import android.graphics.Path;
2222 import android.graphics.PathMeasure;
2323 import android.graphics.RectF;
24+import android.os.Parcel;
25+import android.os.Parcelable;
2426 import android.view.InputDevice;
2527 import android.view.MotionEvent;
2628 import android.view.MotionEvent.PointerCoords;
@@ -303,13 +305,37 @@ public final class GestureDescription {
303305 }
304306 }
305307
306- private static class TouchPoint {
308+ /**
309+ * The location of a finger for gesture dispatch
310+ *
311+ * @hide
312+ */
313+ public static class TouchPoint implements Parcelable {
314+ private static final int FLAG_IS_START_OF_PATH = 0x01;
315+ private static final int FLAG_IS_END_OF_PATH = 0x02;
316+
307317 int mPathIndex;
308318 boolean mIsStartOfPath;
309319 boolean mIsEndOfPath;
310320 float mX;
311321 float mY;
312322
323+ public TouchPoint() {
324+ }
325+
326+ public TouchPoint(TouchPoint pointToCopy) {
327+ copyFrom(pointToCopy);
328+ }
329+
330+ public TouchPoint(Parcel parcel) {
331+ mPathIndex = parcel.readInt();
332+ int startEnd = parcel.readInt();
333+ mIsStartOfPath = (startEnd & FLAG_IS_START_OF_PATH) != 0;
334+ mIsEndOfPath = (startEnd & FLAG_IS_END_OF_PATH) != 0;
335+ mX = parcel.readFloat();
336+ mY = parcel.readFloat();
337+ }
338+
313339 void copyFrom(TouchPoint other) {
314340 mPathIndex = other.mPathIndex;
315341 mIsStartOfPath = other.mIsStartOfPath;
@@ -317,12 +343,94 @@ public final class GestureDescription {
317343 mX = other.mX;
318344 mY = other.mY;
319345 }
346+
347+ @Override
348+ public int describeContents() {
349+ return 0;
350+ }
351+
352+ @Override
353+ public void writeToParcel(Parcel dest, int flags) {
354+ dest.writeInt(mPathIndex);
355+ int startEnd = mIsStartOfPath ? FLAG_IS_START_OF_PATH : 0;
356+ startEnd |= mIsEndOfPath ? FLAG_IS_END_OF_PATH : 0;
357+ dest.writeInt(startEnd);
358+ dest.writeFloat(mX);
359+ dest.writeFloat(mY);
360+ }
361+
362+ public static final Parcelable.Creator<TouchPoint> CREATOR
363+ = new Parcelable.Creator<TouchPoint>() {
364+ public TouchPoint createFromParcel(Parcel in) {
365+ return new TouchPoint(in);
366+ }
367+
368+ public TouchPoint[] newArray(int size) {
369+ return new TouchPoint[size];
370+ }
371+ };
372+ }
373+
374+ /**
375+ * A step along a gesture. Contains all of the touch points at a particular time
376+ *
377+ * @hide
378+ */
379+ public static class GestureStep implements Parcelable {
380+ public long timeSinceGestureStart;
381+ public int numTouchPoints;
382+ public TouchPoint[] touchPoints;
383+
384+ public GestureStep(long timeSinceGestureStart, int numTouchPoints,
385+ TouchPoint[] touchPointsToCopy) {
386+ this.timeSinceGestureStart = timeSinceGestureStart;
387+ this.numTouchPoints = numTouchPoints;
388+ this.touchPoints = new TouchPoint[numTouchPoints];
389+ for (int i = 0; i < numTouchPoints; i++) {
390+ this.touchPoints[i] = new TouchPoint(touchPointsToCopy[i]);
391+ }
392+ }
393+
394+ public GestureStep(Parcel parcel) {
395+ timeSinceGestureStart = parcel.readLong();
396+ Parcelable[] parcelables =
397+ parcel.readParcelableArray(TouchPoint.class.getClassLoader());
398+ numTouchPoints = (parcelables == null) ? 0 : parcelables.length;
399+ touchPoints = new TouchPoint[numTouchPoints];
400+ for (int i = 0; i < numTouchPoints; i++) {
401+ touchPoints[i] = (TouchPoint) parcelables[i];
402+ }
403+ }
404+
405+ @Override
406+ public int describeContents() {
407+ return 0;
408+ }
409+
410+ @Override
411+ public void writeToParcel(Parcel dest, int flags) {
412+ dest.writeLong(timeSinceGestureStart);
413+ dest.writeParcelableArray(touchPoints, flags);
414+ }
415+
416+ public static final Parcelable.Creator<GestureStep> CREATOR
417+ = new Parcelable.Creator<GestureStep>() {
418+ public GestureStep createFromParcel(Parcel in) {
419+ return new GestureStep(in);
420+ }
421+
422+ public GestureStep[] newArray(int size) {
423+ return new GestureStep[size];
424+ }
425+ };
320426 }
321427
322428 /**
323429 * Class to convert a GestureDescription to a series of MotionEvents.
430+ *
431+ * @hide
324432 */
325- static class MotionEventGenerator {
433+ public static class MotionEventGenerator {
326434 /**
327435 * Constants used to initialize all MotionEvents
328436 */
@@ -341,38 +449,52 @@ public final class GestureDescription {
341449 private static PointerCoords[] sPointerCoords;
342450 private static PointerProperties[] sPointerProps;
343451
344- static List<MotionEvent> getMotionEventsFromGestureDescription(
452+ static List<GestureStep> getGestureStepsFromGestureDescription(
345453 GestureDescription description, int sampleTimeMs) {
346- final List<MotionEvent> motionEvents = new ArrayList<>();
454+ final List<GestureStep> gestureSteps = new ArrayList<>();
347455
348456 // Point data at each time we generate an event for
349457 final TouchPoint[] currentTouchPoints =
350458 getCurrentTouchPoints(description.getStrokeCount());
351- // Point data sent in last touch event
352- int lastTouchPointSize = 0;
353- final TouchPoint[] lastTouchPoints =
354- getLastTouchPoints(description.getStrokeCount());
355-
459+ int currentTouchPointSize = 0;
356460 /* Loop through each time slice where there are touch points */
357461 long timeSinceGestureStart = 0;
358462 long nextKeyPointTime = description.getNextKeyPointAtLeast(timeSinceGestureStart);
359463 while (nextKeyPointTime >= 0) {
360- timeSinceGestureStart = (lastTouchPointSize == 0) ? nextKeyPointTime
464+ timeSinceGestureStart = (currentTouchPointSize == 0) ? nextKeyPointTime
361465 : Math.min(nextKeyPointTime, timeSinceGestureStart + sampleTimeMs);
362- int currentTouchPointSize = description.getPointsForTime(timeSinceGestureStart,
466+ currentTouchPointSize = description.getPointsForTime(timeSinceGestureStart,
363467 currentTouchPoints);
468+ gestureSteps.add(new GestureStep(timeSinceGestureStart, currentTouchPointSize,
469+ currentTouchPoints));
470+
471+ /* Move to next time slice */
472+ nextKeyPointTime = description.getNextKeyPointAtLeast(timeSinceGestureStart + 1);
473+ }
474+ return gestureSteps;
475+ }
476+
477+ public static List<MotionEvent> getMotionEventsFromGestureSteps(List<GestureStep> steps) {
478+ final List<MotionEvent> motionEvents = new ArrayList<>();
479+
480+ // Number of points in last touch event
481+ int lastTouchPointSize = 0;
482+ TouchPoint[] lastTouchPoints;
483+
484+ for (int i = 0; i < steps.size(); i++) {
485+ GestureStep step = steps.get(i);
486+ int currentTouchPointSize = step.numTouchPoints;
487+ lastTouchPoints = getLastTouchPoints(
488+ Math.max(lastTouchPointSize, currentTouchPointSize));
364489
365490 appendMoveEventIfNeeded(motionEvents, lastTouchPoints, lastTouchPointSize,
366- currentTouchPoints, currentTouchPointSize, timeSinceGestureStart);
491+ step.touchPoints, currentTouchPointSize, step.timeSinceGestureStart);
367492 lastTouchPointSize = appendUpEvents(motionEvents, lastTouchPoints,
368- lastTouchPointSize, currentTouchPoints, currentTouchPointSize,
369- timeSinceGestureStart);
493+ lastTouchPointSize, step.touchPoints, currentTouchPointSize,
494+ step.timeSinceGestureStart);
370495 lastTouchPointSize = appendDownEvents(motionEvents, lastTouchPoints,
371- lastTouchPointSize, currentTouchPoints, currentTouchPointSize,
372- timeSinceGestureStart);
373-
374- /* Move to next time slice */
375- nextKeyPointTime = description.getNextKeyPointAtLeast(timeSinceGestureStart + 1);
496+ lastTouchPointSize, step.touchPoints, currentTouchPointSize,
497+ step.timeSinceGestureStart);
376498 }
377499 return motionEvents;
378500 }
--- a/core/java/android/accessibilityservice/IAccessibilityServiceConnection.aidl
+++ b/core/java/android/accessibilityservice/IAccessibilityServiceConnection.aidl
@@ -88,5 +88,5 @@ interface IAccessibilityServiceConnection {
8888
8989 void setSoftKeyboardCallbackEnabled(boolean enabled);
9090
91- void sendMotionEvents(int sequence, in ParceledListSlice events);
91+ void sendGesture(int sequence, in ParceledListSlice gestureSteps);
9292 }
--- a/core/java/android/hardware/fingerprint/FingerprintManager.java
+++ b/core/java/android/hardware/fingerprint/FingerprintManager.java
@@ -259,6 +259,7 @@ public class FingerprintManager {
259259 public static class AuthenticationResult {
260260 private Fingerprint mFingerprint;
261261 private CryptoObject mCryptoObject;
262+ private int mUserId;
262263
263264 /**
264265 * Authentication result
@@ -267,9 +268,10 @@ public class FingerprintManager {
267268 * @param fingerprint the recognized fingerprint data, if allowed.
268269 * @hide
269270 */
270- public AuthenticationResult(CryptoObject crypto, Fingerprint fingerprint) {
271+ public AuthenticationResult(CryptoObject crypto, Fingerprint fingerprint, int userId) {
271272 mCryptoObject = crypto;
272273 mFingerprint = fingerprint;
274+ mUserId = userId;
273275 }
274276
275277 /**
@@ -286,6 +288,12 @@ public class FingerprintManager {
286288 * @hide
287289 */
288290 public Fingerprint getFingerprint() { return mFingerprint; }
291+
292+ /**
293+ * Obtain the userId for which this fingerprint was authenticated.
294+ * @hide
295+ */
296+ public int getUserId() { return mUserId; }
289297 };
290298
291299 /**
@@ -792,7 +800,7 @@ public class FingerprintManager {
792800 sendAcquiredResult((Long) msg.obj /* deviceId */, msg.arg1 /* acquire info */);
793801 break;
794802 case MSG_AUTHENTICATION_SUCCEEDED:
795- sendAuthenticatedSucceeded((Fingerprint) msg.obj);
803+ sendAuthenticatedSucceeded((Fingerprint) msg.obj, msg.arg1 /* userId */);
796804 break;
797805 case MSG_AUTHENTICATION_FAILED:
798806 sendAuthenticatedFailed();
@@ -840,9 +848,10 @@ public class FingerprintManager {
840848 }
841849 }
842850
843- private void sendAuthenticatedSucceeded(Fingerprint fp) {
851+ private void sendAuthenticatedSucceeded(Fingerprint fp, int userId) {
844852 if (mAuthenticationCallback != null) {
845- final AuthenticationResult result = new AuthenticationResult(mCryptoObject, fp);
853+ final AuthenticationResult result =
854+ new AuthenticationResult(mCryptoObject, fp, userId);
846855 mAuthenticationCallback.onAuthenticationSucceeded(result);
847856 }
848857 }
@@ -981,8 +990,8 @@ public class FingerprintManager {
981990 }
982991
983992 @Override // binder call
984- public void onAuthenticationSucceeded(long deviceId, Fingerprint fp) {
985- mHandler.obtainMessage(MSG_AUTHENTICATION_SUCCEEDED, fp).sendToTarget();
993+ public void onAuthenticationSucceeded(long deviceId, Fingerprint fp, int userId) {
994+ mHandler.obtainMessage(MSG_AUTHENTICATION_SUCCEEDED, userId, 0, fp).sendToTarget();
986995 }
987996
988997 @Override // binder call
--- a/core/java/android/hardware/fingerprint/IFingerprintServiceReceiver.aidl
+++ b/core/java/android/hardware/fingerprint/IFingerprintServiceReceiver.aidl
@@ -26,7 +26,7 @@ import android.os.UserHandle;
2626 oneway interface IFingerprintServiceReceiver {
2727 void onEnrollResult(long deviceId, int fingerId, int groupId, int remaining);
2828 void onAcquired(long deviceId, int acquiredInfo);
29- void onAuthenticationSucceeded(long deviceId, in Fingerprint fp);
29+ void onAuthenticationSucceeded(long deviceId, in Fingerprint fp, int userId);
3030 void onAuthenticationFailed(long deviceId);
3131 void onError(long deviceId, int error);
3232 void onRemoved(long deviceId, int fingerId, int groupId);
--- a/core/java/android/os/Process.java
+++ b/core/java/android/os/Process.java
@@ -559,6 +559,15 @@ public class Process {
559559 ZygoteState zygoteState, ArrayList<String> args)
560560 throws ZygoteStartFailedEx {
561561 try {
562+ // Throw early if any of the arguments are malformed. This means we can
563+ // avoid writing a partial response to the zygote.
564+ int sz = args.size();
565+ for (int i = 0; i < sz; i++) {
566+ if (args.get(i).indexOf('\n') >= 0) {
567+ throw new ZygoteStartFailedEx("embedded newlines not allowed");
568+ }
569+ }
570+
562571 /**
563572 * See com.android.internal.os.ZygoteInit.readArgumentList()
564573 * Presently the wire format to the zygote process is:
@@ -575,13 +584,8 @@ public class Process {
575584 writer.write(Integer.toString(args.size()));
576585 writer.newLine();
577586
578- int sz = args.size();
579587 for (int i = 0; i < sz; i++) {
580588 String arg = args.get(i);
581- if (arg.indexOf('\n') >= 0) {
582- throw new ZygoteStartFailedEx(
583- "embedded newlines not allowed");
584- }
585589 writer.write(arg);
586590 writer.newLine();
587591 }
@@ -590,11 +594,16 @@ public class Process {
590594
591595 // Should there be a timeout on this?
592596 ProcessStartResult result = new ProcessStartResult();
597+
598+ // Always read the entire result from the input stream to avoid leaving
599+ // bytes in the stream for future process starts to accidentally stumble
600+ // upon.
593601 result.pid = inputStream.readInt();
602+ result.usingWrapper = inputStream.readBoolean();
603+
594604 if (result.pid < 0) {
595605 throw new ZygoteStartFailedEx("fork() failed");
596606 }
597- result.usingWrapper = inputStream.readBoolean();
598607 return result;
599608 } catch (IOException ex) {
600609 zygoteState.close();
--- a/core/java/com/android/internal/widget/LockPatternUtils.java
+++ b/core/java/com/android/internal/widget/LockPatternUtils.java
@@ -354,7 +354,7 @@ public class LockPatternUtils {
354354 return false;
355355 }
356356 } catch (RemoteException re) {
357- return true;
357+ return false;
358358 }
359359 }
360360
@@ -435,7 +435,7 @@ public class LockPatternUtils {
435435 return false;
436436 }
437437 } catch (RemoteException re) {
438- return true;
438+ return false;
439439 }
440440 }
441441
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java
@@ -433,7 +433,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
433433 }
434434 }
435435
436- private void handleFingerprintAuthenticated() {
436+ private void handleFingerprintAuthenticated(int authUserId) {
437437 try {
438438 final int userId;
439439 try {
@@ -442,6 +442,10 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
442442 Log.e(TAG, "Failed to get current user id: ", e);
443443 return;
444444 }
445+ if (userId != authUserId) {
446+ Log.d(TAG, "Fingerprint authenticated for wrong user: " + authUserId);
447+ return;
448+ }
445449 if (isFingerprintDisabled(userId)) {
446450 Log.d(TAG, "Fingerprint disabled by DPM for userId: " + userId);
447451 return;
@@ -725,7 +729,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
725729
726730 @Override
727731 public void onAuthenticationSucceeded(AuthenticationResult result) {
728- handleFingerprintAuthenticated();
732+ handleFingerprintAuthenticated(result.getUserId());
729733 }
730734
731735 @Override
--- a/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java
+++ b/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java
@@ -21,6 +21,7 @@ import static android.accessibilityservice.AccessibilityServiceInfo.DEFAULT;
2121 import android.Manifest;
2222 import android.accessibilityservice.AccessibilityService;
2323 import android.accessibilityservice.AccessibilityServiceInfo;
24+import android.accessibilityservice.GestureDescription;
2425 import android.accessibilityservice.IAccessibilityServiceClient;
2526 import android.accessibilityservice.IAccessibilityServiceConnection;
2627 import android.annotation.NonNull;
@@ -2755,7 +2756,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
27552756 }
27562757
27572758 @Override
2758- public void sendMotionEvents(int sequence, ParceledListSlice events) {
2759+ public void sendGesture(int sequence, ParceledListSlice gestureSteps) {
27592760 synchronized (mLock) {
27602761 if (mSecurityPolicy.canPerformGestures(this)) {
27612762 final long endMillis =
@@ -2769,9 +2770,16 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
27692770 }
27702771 }
27712772 if (mMotionEventInjector != null) {
2772- mMotionEventInjector.injectEvents((List<MotionEvent>) events.getList(),
2773- mServiceInterface, sequence);
2774- return;
2773+ List<GestureDescription.GestureStep> steps = gestureSteps.getList();
2774+ List<MotionEvent> events = GestureDescription.MotionEventGenerator
2775+ .getMotionEventsFromGestureSteps(steps);
2776+ // Confirm that the motion events end with an UP event.
2777+ if (events.get(events.size() - 1).getAction() == MotionEvent.ACTION_UP) {
2778+ mMotionEventInjector.injectEvents(events, mServiceInterface, sequence);
2779+ return;
2780+ } else {
2781+ Slog.e(LOG_TAG, "Gesture is not well-formed");
2782+ }
27752783 } else {
27762784 Slog.e(LOG_TAG, "MotionEventInjector installation timed out");
27772785 }
--- a/services/core/java/com/android/server/LockSettingsService.java
+++ b/services/core/java/com/android/server/LockSettingsService.java
@@ -1215,6 +1215,9 @@ public class LockSettingsService extends ILockSettings.Stub {
12151215 private VerifyCredentialResponse doVerifyPattern(String pattern, boolean hasChallenge,
12161216 long challenge, int userId) throws RemoteException {
12171217 checkPasswordReadPermission(userId);
1218+ if (TextUtils.isEmpty(pattern)) {
1219+ throw new IllegalArgumentException("Pattern can't be null or empty");
1220+ }
12181221 CredentialHash storedHash = mStorage.readPatternHash(userId);
12191222 return doVerifyPattern(pattern, storedHash, hasChallenge, challenge, userId);
12201223 }
@@ -1306,6 +1309,9 @@ public class LockSettingsService extends ILockSettings.Stub {
13061309 private VerifyCredentialResponse doVerifyPassword(String password, boolean hasChallenge,
13071310 long challenge, int userId) throws RemoteException {
13081311 checkPasswordReadPermission(userId);
1312+ if (TextUtils.isEmpty(password)) {
1313+ throw new IllegalArgumentException("Password can't be null or empty");
1314+ }
13091315 CredentialHash storedHash = mStorage.readPasswordHash(userId);
13101316 return doVerifyPassword(password, storedHash, hasChallenge, challenge, userId);
13111317 }
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -3797,6 +3797,15 @@ public final class ActivityManagerService extends ActivityManagerNative
37973797 app.killedByAm = false;
37983798 checkTime(startTime, "startProcess: starting to update pids map");
37993799 synchronized (mPidsSelfLocked) {
3800+ ProcessRecord oldApp;
3801+ // If there is already an app occupying that pid that hasn't been cleaned up
3802+ if ((oldApp = mPidsSelfLocked.get(startResult.pid)) != null && !app.isolated) {
3803+ // Clean up anything relating to this pid first
3804+ Slog.w(TAG, "Reusing pid " + startResult.pid
3805+ + " while app is still mapped to it");
3806+ cleanUpApplicationRecordLocked(oldApp, false, false, -1,
3807+ true /*replacingPid*/);
3808+ }
38003809 this.mPidsSelfLocked.put(startResult.pid, app);
38013810 if (isActivityProcess) {
38023811 Message msg = mHandler.obtainMessage(PROC_START_TIMEOUT_MSG);
@@ -5012,7 +5021,8 @@ public final class ActivityManagerService extends ActivityManagerNative
50125021 private final void handleAppDiedLocked(ProcessRecord app,
50135022 boolean restarting, boolean allowRestart) {
50145023 int pid = app.pid;
5015- boolean kept = cleanUpApplicationRecordLocked(app, restarting, allowRestart, -1);
5024+ boolean kept = cleanUpApplicationRecordLocked(app, restarting, allowRestart, -1,
5025+ false /*replacingPid*/);
50165026 if (!kept && !restarting) {
50175027 removeLruProcessLocked(app);
50185028 if (pid > 0) {
@@ -16654,7 +16664,8 @@ public final class ActivityManagerService extends ActivityManagerNative
1665416664 * app that was passed in must remain on the process lists.
1665516665 */
1665616666 private final boolean cleanUpApplicationRecordLocked(ProcessRecord app,
16657- boolean restarting, boolean allowRestart, int index) {
16667+ boolean restarting, boolean allowRestart, int index, boolean replacingPid) {
16668+ Slog.d(TAG, "cleanUpApplicationRecord -- " + app.pid);
1665816669 if (index >= 0) {
1665916670 removeLruProcessLocked(app);
1666016671 ProcessList.remove(app.pid);
@@ -16785,7 +16796,9 @@ public final class ActivityManagerService extends ActivityManagerNative
1678516796 if (!app.persistent || app.isolated) {
1678616797 if (DEBUG_PROCESSES || DEBUG_CLEANUP) Slog.v(TAG_CLEANUP,
1678716798 "Removing non-persistent process during cleanup: " + app);
16788- removeProcessNameLocked(app.processName, app.uid);
16799+ if (!replacingPid) {
16800+ removeProcessNameLocked(app.processName, app.uid);
16801+ }
1678916802 if (mHeavyWeightProcess == app) {
1679016803 mHandler.sendMessage(mHandler.obtainMessage(CANCEL_HEAVY_NOTIFICATION_MSG,
1679116804 mHeavyWeightProcess.userId, 0));
@@ -20996,7 +21009,7 @@ public final class ActivityManagerService extends ActivityManagerNative
2099621009 // Ignore exceptions.
2099721010 }
2099821011 }
20999- cleanUpApplicationRecordLocked(app, false, true, -1);
21012+ cleanUpApplicationRecordLocked(app, false, true, -1, false /*replacingPid*/);
2100021013 mRemovedProcesses.remove(i);
2100121014
2100221015 if (app.persistent) {
--- a/services/core/java/com/android/server/am/BroadcastQueue.java
+++ b/services/core/java/com/android/server/am/BroadcastQueue.java
@@ -302,6 +302,11 @@ public final class BroadcastQueue {
302302 boolean didSomething = false;
303303 final BroadcastRecord br = mPendingBroadcast;
304304 if (br != null && br.curApp.pid == app.pid) {
305+ if (br.curApp != app) {
306+ Slog.e(TAG, "App mismatch when sending pending broadcast to "
307+ + app.processName + ", intended target is " + br.curApp.processName);
308+ return false;
309+ }
305310 try {
306311 mPendingBroadcast = null;
307312 processCurBroadcastLocked(br, app);
--- a/services/core/java/com/android/server/fingerprint/AuthenticationClient.java
+++ b/services/core/java/com/android/server/fingerprint/AuthenticationClient.java
@@ -39,9 +39,9 @@ public abstract class AuthenticationClient extends ClientMonitor {
3939 public abstract void resetFailedAttempts();
4040
4141 public AuthenticationClient(Context context, long halDeviceId, IBinder token,
42- IFingerprintServiceReceiver receiver, int callingUserId, int groupId, long opId,
42+ IFingerprintServiceReceiver receiver, int targetUserId, int groupId, long opId,
4343 boolean restricted, String owner) {
44- super(context, halDeviceId, token, receiver, callingUserId, groupId, restricted, owner);
44+ super(context, halDeviceId, token, receiver, targetUserId, groupId, restricted, owner);
4545 mOpId = opId;
4646 }
4747
@@ -65,7 +65,7 @@ public abstract class AuthenticationClient extends ClientMonitor {
6565 Fingerprint fp = !getIsRestricted()
6666 ? new Fingerprint("" /* TODO */, groupId, fingerId, getHalDeviceId())
6767 : null;
68- receiver.onAuthenticationSucceeded(getHalDeviceId(), fp);
68+ receiver.onAuthenticationSucceeded(getHalDeviceId(), fp, getTargetUserId());
6969 }
7070 } catch (RemoteException e) {
7171 Slog.w(TAG, "Failed to notify Authenticated:", e);
--- a/services/core/java/com/android/server/fingerprint/FingerprintService.java
+++ b/services/core/java/com/android/server/fingerprint/FingerprintService.java
@@ -501,7 +501,7 @@ public class FingerprintService extends SystemService implements IBinder.DeathRe
501501 if (DEBUG) Slog.v(TAG, "startAuthentication(" + opPackageName + ")");
502502
503503 AuthenticationClient client = new AuthenticationClient(getContext(), mHalDeviceId, token,
504- receiver, callingUserId, groupId, opId, restricted, opPackageName) {
504+ receiver, mCurrentUserId, groupId, opId, restricted, opPackageName) {
505505 @Override
506506 public boolean handleFailedAttempt() {
507507 mFailedAttempts++;
--- a/services/core/java/com/android/server/location/GpsXtraDownloader.java
+++ b/services/core/java/com/android/server/location/GpsXtraDownloader.java
@@ -22,6 +22,12 @@ import android.util.Log;
2222 import java.io.IOException;
2323 import java.net.HttpURLConnection;
2424 import java.net.URL;
25+
26+import libcore.io.IoUtils;
27+
28+import java.io.ByteArrayOutputStream;
29+import java.io.InputStream;
30+import java.io.IOException;
2531 import java.util.Properties;
2632 import java.util.Random;
2733 import java.util.concurrent.TimeUnit;
@@ -37,6 +43,7 @@ public class GpsXtraDownloader {
3743
3844 private static final String TAG = "GpsXtraDownloader";
3945 private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
46+ private static final long MAXIMUM_CONTENT_LENGTH_BYTES = 1000000; // 1MB.
4047 private static final String DEFAULT_USER_AGENT = "Android";
4148 private static final int CONNECTION_TIMEOUT_MS = (int) TimeUnit.SECONDS.toMillis(30);
4249
@@ -124,7 +131,19 @@ public class GpsXtraDownloader {
124131 return null;
125132 }
126133
127- return Streams.readFully(connection.getInputStream());
134+ try (InputStream in = connection.getInputStream()) {
135+ ByteArrayOutputStream bytes = new ByteArrayOutputStream();
136+ byte[] buffer = new byte[1024];
137+ int count;
138+ while ((count = in.read(buffer)) != -1) {
139+ bytes.write(buffer, 0, count);
140+ if (bytes.size() > MAXIMUM_CONTENT_LENGTH_BYTES) {
141+ if (DEBUG) Log.d(TAG, "XTRA file too large");
142+ return null;
143+ }
144+ }
145+ return bytes.toByteArray();
146+ }
128147 } catch (IOException ioe) {
129148 if (DEBUG) Log.d(TAG, "Error downloading gps XTRA: ", ioe);
130149 } finally {
@@ -136,3 +155,4 @@ public class GpsXtraDownloader {
136155 }
137156
138157 }
158+