Skip to content

Commit b3616bc

Browse files
author
Jessica Wagantall
committed
Merge tag 'android-6.0.1_r72' into HEAD
Android 6.0.1 Release 72 (M4B30X) # gpg: Signature made Tue 04 Oct 2016 09:47:40 AM PDT using DSA key ID 9AB10E78 # gpg: Can't check signature: public key not found
2 parents afc4f09 + 2dde02e commit b3616bc

10 files changed

Lines changed: 103 additions & 32 deletions

File tree

core/java/android/hardware/fingerprint/FingerprintManager.java

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ public long getOpId() {
258258
public static class AuthenticationResult {
259259
private Fingerprint mFingerprint;
260260
private CryptoObject mCryptoObject;
261+
private int mUserId;
261262

262263
/**
263264
* Authentication result
@@ -266,9 +267,10 @@ public static class AuthenticationResult {
266267
* @param fingerprint the recognized fingerprint data, if allowed.
267268
* @hide
268269
*/
269-
public AuthenticationResult(CryptoObject crypto, Fingerprint fingerprint) {
270+
public AuthenticationResult(CryptoObject crypto, Fingerprint fingerprint, int userId) {
270271
mCryptoObject = crypto;
271272
mFingerprint = fingerprint;
273+
mUserId = userId;
272274
}
273275

274276
/**
@@ -285,6 +287,12 @@ public AuthenticationResult(CryptoObject crypto, Fingerprint fingerprint) {
285287
* @hide
286288
*/
287289
public Fingerprint getFingerprint() { return mFingerprint; }
290+
291+
/**
292+
* Obtain the userId for which this fingerprint was authenticated.
293+
* @hide
294+
*/
295+
public int getUserId() { return mUserId; }
288296
};
289297

290298
/**
@@ -754,7 +762,7 @@ public void handleMessage(android.os.Message msg) {
754762
sendAcquiredResult((Long) msg.obj /* deviceId */, msg.arg1 /* acquire info */);
755763
break;
756764
case MSG_AUTHENTICATION_SUCCEEDED:
757-
sendAuthenticatedSucceeded((Fingerprint) msg.obj);
765+
sendAuthenticatedSucceeded((Fingerprint) msg.obj, msg.arg1 /* userId */);
758766
break;
759767
case MSG_AUTHENTICATION_FAILED:
760768
sendAuthenticatedFailed();
@@ -799,9 +807,10 @@ private void sendEnrollResult(Fingerprint fp, int remaining) {
799807
}
800808
}
801809

802-
private void sendAuthenticatedSucceeded(Fingerprint fp) {
810+
private void sendAuthenticatedSucceeded(Fingerprint fp, int userId) {
803811
if (mAuthenticationCallback != null) {
804-
final AuthenticationResult result = new AuthenticationResult(mCryptoObject, fp);
812+
final AuthenticationResult result =
813+
new AuthenticationResult(mCryptoObject, fp, userId);
805814
mAuthenticationCallback.onAuthenticationSucceeded(result);
806815
}
807816
}
@@ -941,8 +950,8 @@ public void onAcquired(long deviceId, int acquireInfo) {
941950
}
942951

943952
@Override // binder call
944-
public void onAuthenticationSucceeded(long deviceId, Fingerprint fp) {
945-
mHandler.obtainMessage(MSG_AUTHENTICATION_SUCCEEDED, fp).sendToTarget();
953+
public void onAuthenticationSucceeded(long deviceId, Fingerprint fp, int userId) {
954+
mHandler.obtainMessage(MSG_AUTHENTICATION_SUCCEEDED, userId, 0, fp).sendToTarget();
946955
}
947956

948957
@Override // binder call

core/java/android/hardware/fingerprint/IFingerprintServiceReceiver.aidl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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);

core/java/android/os/Process.java

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,15 @@ private static ProcessStartResult zygoteSendArgsAndGetResult(
539539
ZygoteState zygoteState, ArrayList<String> args)
540540
throws ZygoteStartFailedEx {
541541
try {
542+
// Throw early if any of the arguments are malformed. This means we can
543+
// avoid writing a partial response to the zygote.
544+
int sz = args.size();
545+
for (int i = 0; i < sz; i++) {
546+
if (args.get(i).indexOf('\n') >= 0) {
547+
throw new ZygoteStartFailedEx("embedded newlines not allowed");
548+
}
549+
}
550+
542551
/**
543552
* See com.android.internal.os.ZygoteInit.readArgumentList()
544553
* Presently the wire format to the zygote process is:
@@ -555,13 +564,8 @@ private static ProcessStartResult zygoteSendArgsAndGetResult(
555564
writer.write(Integer.toString(args.size()));
556565
writer.newLine();
557566

558-
int sz = args.size();
559567
for (int i = 0; i < sz; i++) {
560568
String arg = args.get(i);
561-
if (arg.indexOf('\n') >= 0) {
562-
throw new ZygoteStartFailedEx(
563-
"embedded newlines not allowed");
564-
}
565569
writer.write(arg);
566570
writer.newLine();
567571
}
@@ -570,11 +574,16 @@ private static ProcessStartResult zygoteSendArgsAndGetResult(
570574

571575
// Should there be a timeout on this?
572576
ProcessStartResult result = new ProcessStartResult();
577+
578+
// Always read the entire result from the input stream to avoid leaving
579+
// bytes in the stream for future process starts to accidentally stumble
580+
// upon.
573581
result.pid = inputStream.readInt();
582+
result.usingWrapper = inputStream.readBoolean();
583+
574584
if (result.pid < 0) {
575585
throw new ZygoteStartFailedEx("fork() failed");
576586
}
577-
result.usingWrapper = inputStream.readBoolean();
578587
return result;
579588
} catch (IOException ex) {
580589
zygoteState.close();

core/java/com/android/internal/widget/LockPatternUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ public boolean checkPattern(List<LockPatternView.Cell> pattern, int userId)
301301
return false;
302302
}
303303
} catch (RemoteException re) {
304-
return true;
304+
return false;
305305
}
306306
}
307307

@@ -350,7 +350,7 @@ public boolean checkPassword(String password, int userId) throws RequestThrottle
350350
return false;
351351
}
352352
} catch (RemoteException re) {
353-
return true;
353+
return false;
354354
}
355355
}
356356

packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,8 @@ private void handleFingerprintAcquired(int acquireInfo) {
462462
}
463463
}
464464

465-
private void handleFingerprintAuthenticated() {
465+
466+
private void handleFingerprintAuthenticated(int authUserId) {
466467
try {
467468
final int userId;
468469
try {
@@ -471,6 +472,10 @@ private void handleFingerprintAuthenticated() {
471472
Log.e(TAG, "Failed to get current user id: ", e);
472473
return;
473474
}
475+
if (userId != authUserId) {
476+
Log.d(TAG, "Fingerprint authenticated for wrong user: " + authUserId);
477+
return;
478+
}
474479
if (isFingerprintDisabled(userId)) {
475480
Log.d(TAG, "Fingerprint disabled by DPM for userId: " + userId);
476481
return;
@@ -737,7 +742,7 @@ public void onAuthenticationFailed() {
737742

738743
@Override
739744
public void onAuthenticationSucceeded(AuthenticationResult result) {
740-
handleFingerprintAuthenticated();
745+
handleFingerprintAuthenticated(result.getUserId());
741746
}
742747

743748
@Override

services/core/java/com/android/server/LockSettingsService.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,9 @@ public VerifyCredentialResponse verifyPattern(String pattern, long challenge, in
565565
private VerifyCredentialResponse doVerifyPattern(String pattern, boolean hasChallenge,
566566
long challenge, int userId) throws RemoteException {
567567
checkPasswordReadPermission(userId);
568+
if (TextUtils.isEmpty(pattern)) {
569+
throw new IllegalArgumentException("Pattern can't be null or empty");
570+
}
568571
CredentialHash storedHash = mStorage.readPatternHash(userId);
569572
boolean shouldReEnrollBaseZero = storedHash != null && storedHash.isBaseZeroPattern;
570573

@@ -628,6 +631,9 @@ public VerifyCredentialResponse verifyPassword(String password, long challenge,
628631
private VerifyCredentialResponse doVerifyPassword(String password, boolean hasChallenge,
629632
long challenge, int userId) throws RemoteException {
630633
checkPasswordReadPermission(userId);
634+
if (TextUtils.isEmpty(password)) {
635+
throw new IllegalArgumentException("Password can't be null or empty");
636+
}
631637
CredentialHash storedHash = mStorage.readPasswordHash(userId);
632638
return verifyCredential(userId, storedHash, password, hasChallenge, challenge,
633639
new CredentialUtil() {

services/core/java/com/android/server/am/ActivityManagerService.java

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3651,6 +3651,15 @@ private final void startProcessLocked(ProcessRecord app, String hostingType,
36513651
app.killedByAm = false;
36523652
checkTime(startTime, "startProcess: starting to update pids map");
36533653
synchronized (mPidsSelfLocked) {
3654+
ProcessRecord oldApp;
3655+
// If there is already an app occupying that pid that hasn't been cleaned up
3656+
if ((oldApp = mPidsSelfLocked.get(startResult.pid)) != null && !app.isolated) {
3657+
// Clean up anything relating to this pid first
3658+
Slog.w(TAG, "Reusing pid " + startResult.pid
3659+
+ " while app is still mapped to it");
3660+
cleanUpApplicationRecordLocked(oldApp, false, false, -1,
3661+
true /*replacingPid*/);
3662+
}
36543663
this.mPidsSelfLocked.put(startResult.pid, app);
36553664
if (isActivityProcess) {
36563665
Message msg = mHandler.obtainMessage(PROC_START_TIMEOUT_MSG);
@@ -4804,7 +4813,8 @@ public void overridePendingTransition(IBinder token, String packageName,
48044813
private final void handleAppDiedLocked(ProcessRecord app,
48054814
boolean restarting, boolean allowRestart) {
48064815
int pid = app.pid;
4807-
boolean kept = cleanUpApplicationRecordLocked(app, restarting, allowRestart, -1);
4816+
boolean kept = cleanUpApplicationRecordLocked(app, restarting, allowRestart, -1,
4817+
false /*replacingPid*/);
48084818
if (!kept && !restarting) {
48094819
removeLruProcessLocked(app);
48104820
if (pid > 0) {
@@ -15903,7 +15913,8 @@ private final boolean removeDyingProviderLocked(ProcessRecord proc,
1590315913
* app that was passed in must remain on the process lists.
1590415914
*/
1590515915
private final boolean cleanUpApplicationRecordLocked(ProcessRecord app,
15906-
boolean restarting, boolean allowRestart, int index) {
15916+
boolean restarting, boolean allowRestart, int index, boolean replacingPid) {
15917+
Slog.d(TAG, "cleanUpApplicationRecord -- " + app.pid);
1590715918
if (index >= 0) {
1590815919
removeLruProcessLocked(app);
1590915920
ProcessList.remove(app.pid);
@@ -16033,7 +16044,9 @@ private final boolean cleanUpApplicationRecordLocked(ProcessRecord app,
1603316044
if (!app.persistent || app.isolated) {
1603416045
if (DEBUG_PROCESSES || DEBUG_CLEANUP) Slog.v(TAG_CLEANUP,
1603516046
"Removing non-persistent process during cleanup: " + app);
16036-
removeProcessNameLocked(app.processName, app.uid);
16047+
if (!replacingPid) {
16048+
removeProcessNameLocked(app.processName, app.uid);
16049+
}
1603716050
if (mHeavyWeightProcess == app) {
1603816051
mHandler.sendMessage(mHandler.obtainMessage(CANCEL_HEAVY_NOTIFICATION_MSG,
1603916052
mHeavyWeightProcess.userId, 0));
@@ -20001,7 +20014,7 @@ final void trimApplications() {
2000120014
// Ignore exceptions.
2000220015
}
2000320016
}
20004-
cleanUpApplicationRecordLocked(app, false, true, -1);
20017+
cleanUpApplicationRecordLocked(app, false, true, -1, false /*replacingPid*/);
2000520018
mRemovedProcesses.remove(i);
2000620019

2000720020
if (app.persistent) {

services/core/java/com/android/server/am/BroadcastQueue.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,11 @@ public boolean sendPendingBroadcastsLocked(ProcessRecord app) {
297297
boolean didSomething = false;
298298
final BroadcastRecord br = mPendingBroadcast;
299299
if (br != null && br.curApp.pid == app.pid) {
300+
if (br.curApp != app) {
301+
Slog.e(TAG, "App mismatch when sending pending broadcast to "
302+
+ app.processName + ", intended target is " + br.curApp.processName);
303+
return false;
304+
}
300305
try {
301306
mPendingBroadcast = null;
302307
processCurBroadcastLocked(br, app);

services/core/java/com/android/server/fingerprint/FingerprintService.java

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ public void handleMessage(android.os.Message msg) {
127127
private IFingerprintDaemon mDaemon;
128128
private final PowerManager mPowerManager;
129129
private final AlarmManager mAlarmManager;
130+
private int mCurrentUserId = UserHandle.USER_NULL;
130131

131132
private final BroadcastReceiver mLockoutReceiver = new BroadcastReceiver() {
132133
@Override
@@ -340,7 +341,8 @@ void startEnrollment(IBinder token, byte[] cryptoToken, int groupId,
340341
return;
341342
}
342343
stopPendingOperations(true);
343-
mEnrollClient = new ClientMonitor(token, receiver, groupId, restricted, token.toString());
344+
mEnrollClient = new ClientMonitor(token, receiver, mCurrentUserId, groupId, restricted,
345+
token.toString());
344346
final int timeout = (int) (ENROLLMENT_TIMEOUT_MS / MS_PER_SEC);
345347
try {
346348
final int result = daemon.enroll(cryptoToken, groupId, timeout);
@@ -428,7 +430,8 @@ void startAuthentication(IBinder token, long opId, int groupId,
428430
return;
429431
}
430432
stopPendingOperations(true);
431-
mAuthClient = new ClientMonitor(token, receiver, groupId, restricted, opPackageName);
433+
mAuthClient = new ClientMonitor(token, receiver, mCurrentUserId, groupId, restricted,
434+
opPackageName);
432435
if (inLockoutMode()) {
433436
Slog.v(TAG, "In lockout mode; disallowing authentication");
434437
if (!mAuthClient.sendError(FingerprintManager.FINGERPRINT_ERROR_LOCKOUT)) {
@@ -485,7 +488,8 @@ void startRemove(IBinder token, int fingerId, int userId,
485488
}
486489

487490
stopPendingOperations(true);
488-
mRemoveClient = new ClientMonitor(token, receiver, userId, restricted, token.toString());
491+
mRemoveClient = new ClientMonitor(token, receiver, mCurrentUserId, userId, restricted,
492+
token.toString());
489493
// The fingerprint template ids will be removed when we get confirmation from the HAL
490494
try {
491495
final int result = daemon.remove(fingerId, userId);
@@ -623,15 +627,17 @@ private void notifyLockoutResetMonitors() {
623627
private class ClientMonitor implements IBinder.DeathRecipient {
624628
IBinder token;
625629
IFingerprintServiceReceiver receiver;
626-
int userId;
630+
int userId; // userId of the caller
631+
int currentUserId; // current user id when this was created
627632
boolean restricted; // True if client does not have MANAGE_FINGERPRINT permission
628633
String owner;
629634

630-
public ClientMonitor(IBinder token, IFingerprintServiceReceiver receiver, int userId,
631-
boolean restricted, String owner) {
635+
public ClientMonitor(IBinder token, IFingerprintServiceReceiver receiver,
636+
int currentUserId, int userId, boolean restricted, String owner) {
632637
this.token = token;
633638
this.receiver = receiver;
634639
this.userId = userId;
640+
this.currentUserId = currentUserId;
635641
this.restricted = restricted;
636642
this.owner = owner; // name of the client that owns this - for debugging
637643
try {
@@ -720,9 +726,9 @@ private boolean sendAuthenticated(int fpId, int groupId) {
720726
Slog.v(TAG, "onAuthenticated(owner=" + mAuthClient.owner
721727
+ ", id=" + fpId + ", gp=" + groupId + ")");
722728
}
723-
Fingerprint fp = !restricted ?
724-
new Fingerprint("" /* TODO */, groupId, fpId, mHalDeviceId) : null;
725-
receiver.onAuthenticationSucceeded(mHalDeviceId, fp);
729+
Fingerprint fp = !restricted ? new Fingerprint("" /* TODO */, groupId, fpId,
730+
mHalDeviceId) : null;
731+
receiver.onAuthenticationSucceeded(mHalDeviceId, fp, currentUserId);
726732
}
727733
} catch (RemoteException e) {
728734
Slog.w(TAG, "Failed to notify Authenticated:", e);
@@ -1147,6 +1153,7 @@ private void updateActiveGroup(int userId) {
11471153
Slog.e(TAG, "Failed to setActiveGroup():", e);
11481154
}
11491155
}
1156+
mCurrentUserId = userId;
11501157
}
11511158

11521159
private void listenForUserSwitches() {

services/core/java/com/android/server/location/GpsXtraDownloader.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@
2121

2222
import java.net.HttpURLConnection;
2323
import java.net.URL;
24-
import libcore.io.Streams;
2524

25+
import libcore.io.IoUtils;
26+
27+
import java.io.ByteArrayOutputStream;
28+
import java.io.InputStream;
2629
import java.io.IOException;
2730
import java.util.Properties;
2831
import java.util.Random;
@@ -36,6 +39,7 @@ public class GpsXtraDownloader {
3639

3740
private static final String TAG = "GpsXtraDownloader";
3841
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
42+
private static final long MAXIMUM_CONTENT_LENGTH_BYTES = 1000000; // 1MB.
3943
private static final String DEFAULT_USER_AGENT = "Android";
4044

4145
private final String[] mXtraServers;
@@ -121,7 +125,19 @@ protected byte[] doDownload(String url) {
121125
return null;
122126
}
123127

124-
return Streams.readFully(connection.getInputStream());
128+
try (InputStream in = connection.getInputStream()) {
129+
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
130+
byte[] buffer = new byte[1024];
131+
int count;
132+
while ((count = in.read(buffer)) != -1) {
133+
bytes.write(buffer, 0, count);
134+
if (bytes.size() > MAXIMUM_CONTENT_LENGTH_BYTES) {
135+
if (DEBUG) Log.d(TAG, "XTRA file too large");
136+
return null;
137+
}
138+
}
139+
return bytes.toByteArray();
140+
}
125141
} catch (IOException ioe) {
126142
if (DEBUG) Log.d(TAG, "Error downloading gps XTRA: ", ioe);
127143
} finally {
@@ -133,3 +149,4 @@ protected byte[] doDownload(String url) {
133149
}
134150

135151
}
152+

0 commit comments

Comments
 (0)