Skip to content

Commit 8f9ef19

Browse files
author
Android Build Coastguard Worker
committed
Snap for 9839160 from 984a78d to tm-platform-release
Change-Id: I1529566871d603a6a4868e3491162acee59565e8
2 parents 052ac3d + 984a78d commit 8f9ef19

18 files changed

Lines changed: 245 additions & 37 deletions

File tree

core/api/test-current.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3452,7 +3452,7 @@ package android.window {
34523452

34533453
public class WindowOrganizer {
34543454
ctor public WindowOrganizer();
3455-
method @RequiresPermission(value=android.Manifest.permission.MANAGE_ACTIVITY_TASKS, conditional=true) public int applySyncTransaction(@NonNull android.window.WindowContainerTransaction, @NonNull android.window.WindowContainerTransactionCallback);
3455+
method @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_TASKS) public int applySyncTransaction(@NonNull android.window.WindowContainerTransaction, @NonNull android.window.WindowContainerTransactionCallback);
34563456
method @RequiresPermission(value=android.Manifest.permission.MANAGE_ACTIVITY_TASKS, conditional=true) public void applyTransaction(@NonNull android.window.WindowContainerTransaction);
34573457
}
34583458

core/java/android/accessibilityservice/AccessibilityService.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2523,6 +2523,10 @@ private void sendServiceInfo() {
25232523
IAccessibilityServiceConnection connection =
25242524
AccessibilityInteractionClient.getInstance(this).getConnection(mConnectionId);
25252525
if (mInfo != null && connection != null) {
2526+
if (!mInfo.isWithinParcelableSize()) {
2527+
throw new IllegalStateException(
2528+
"Cannot update service info: size is larger than safe parcelable limits.");
2529+
}
25262530
try {
25272531
connection.setServiceInfo(mInfo);
25282532
mInfo = null;

core/java/android/accessibilityservice/AccessibilityServiceInfo.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import android.graphics.drawable.Drawable;
4141
import android.hardware.fingerprint.FingerprintManager;
4242
import android.os.Build;
43+
import android.os.IBinder;
4344
import android.os.Parcel;
4445
import android.os.Parcelable;
4546
import android.os.RemoteException;
@@ -1128,6 +1129,15 @@ public int describeContents() {
11281129
return 0;
11291130
}
11301131

1132+
/** @hide */
1133+
public final boolean isWithinParcelableSize() {
1134+
final Parcel parcel = Parcel.obtain();
1135+
writeToParcel(parcel, 0);
1136+
final boolean result = parcel.dataSize() <= IBinder.MAX_IPC_SIZE;
1137+
parcel.recycle();
1138+
return result;
1139+
}
1140+
11311141
public void writeToParcel(Parcel parcel, int flagz) {
11321142
parcel.writeInt(eventTypes);
11331143
parcel.writeStringArray(packageNames);

core/java/android/window/WindowOrganizer.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,7 @@ public void applyTransaction(@NonNull WindowContainerTransaction t) {
6161
* Apply multiple WindowContainer operations at once.
6262
*
6363
* Note that using this API requires the caller to hold
64-
* {@link android.Manifest.permission#MANAGE_ACTIVITY_TASKS}, unless the caller is using
65-
* {@link TaskFragmentOrganizer}, in which case it is allowed to change TaskFragment that is
66-
* created by itself.
64+
* {@link android.Manifest.permission#MANAGE_ACTIVITY_TASKS}.
6765
*
6866
* @param t The transaction to apply.
6967
* @param callback This transaction will use the synchronization scheme described in
@@ -72,8 +70,7 @@ public void applyTransaction(@NonNull WindowContainerTransaction t) {
7270
* @return An ID for the sync operation which will later be passed to transactionReady callback.
7371
* This lets the caller differentiate overlapping sync operations.
7472
*/
75-
@RequiresPermission(value = android.Manifest.permission.MANAGE_ACTIVITY_TASKS,
76-
conditional = true)
73+
@RequiresPermission(value = android.Manifest.permission.MANAGE_ACTIVITY_TASKS)
7774
public int applySyncTransaction(@NonNull WindowContainerTransaction t,
7875
@NonNull WindowContainerTransactionCallback callback) {
7976
try {

core/java/com/android/internal/app/ChooserActivity.java

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import static android.app.admin.DevicePolicyResources.Strings.Core.RESOLVER_CANT_SHARE_WITH_PERSONAL;
2222
import static android.app.admin.DevicePolicyResources.Strings.Core.RESOLVER_CANT_SHARE_WITH_WORK;
2323
import static android.app.admin.DevicePolicyResources.Strings.Core.RESOLVER_CROSS_PROFILE_BLOCKED_TITLE;
24+
import static android.content.ContentProvider.getUserIdFromUri;
2425
import static android.stats.devicepolicy.DevicePolicyEnums.RESOLVER_EMPTY_STATE_NO_SHARING_TO_PERSONAL;
2526
import static android.stats.devicepolicy.DevicePolicyEnums.RESOLVER_EMPTY_STATE_NO_SHARING_TO_WORK;
2627

@@ -161,6 +162,7 @@
161162
import java.util.Map;
162163
import java.util.Objects;
163164
import java.util.function.Supplier;
165+
import java.util.stream.Collectors;
164166

165167
/**
166168
* The Chooser Activity handles intent resolution specifically for sharing intents -
@@ -1424,7 +1426,11 @@ private ViewGroup displayImageContentPreview(Intent targetIntent, LayoutInflater
14241426

14251427
String action = targetIntent.getAction();
14261428
if (Intent.ACTION_SEND.equals(action)) {
1427-
Uri uri = targetIntent.getParcelableExtra(Intent.EXTRA_STREAM);
1429+
Uri uri = targetIntent.getParcelableExtra(Intent.EXTRA_STREAM, android.net.Uri.class);
1430+
if (!validForContentPreview(uri)) {
1431+
contentPreviewLayout.setVisibility(View.GONE);
1432+
return contentPreviewLayout;
1433+
}
14281434
imagePreview.findViewById(R.id.content_preview_image_1_large)
14291435
.setTransitionName(ChooserActivity.FIRST_IMAGE_PREVIEW_TRANSITION_NAME);
14301436
mPreviewCoord.loadUriIntoView(R.id.content_preview_image_1_large, uri, 0);
@@ -1434,7 +1440,7 @@ private ViewGroup displayImageContentPreview(Intent targetIntent, LayoutInflater
14341440
List<Uri> uris = targetIntent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
14351441
List<Uri> imageUris = new ArrayList<>();
14361442
for (Uri uri : uris) {
1437-
if (isImageType(resolver.getType(uri))) {
1443+
if (validForContentPreview(uri) && isImageType(resolver.getType(uri))) {
14381444
imageUris.add(uri);
14391445
}
14401446
}
@@ -1544,9 +1550,16 @@ private ViewGroup displayFileContentPreview(Intent targetIntent, LayoutInflater
15441550
String action = targetIntent.getAction();
15451551
if (Intent.ACTION_SEND.equals(action)) {
15461552
Uri uri = targetIntent.getParcelableExtra(Intent.EXTRA_STREAM);
1553+
if (!validForContentPreview(uri)) {
1554+
contentPreviewLayout.setVisibility(View.GONE);
1555+
return contentPreviewLayout;
1556+
}
15471557
loadFileUriIntoView(uri, contentPreviewLayout);
15481558
} else {
15491559
List<Uri> uris = targetIntent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
1560+
uris = uris.stream()
1561+
.filter(ChooserActivity::validForContentPreview)
1562+
.collect(Collectors.toList());
15501563
int uriCount = uris.size();
15511564

15521565
if (uriCount == 0) {
@@ -1605,6 +1618,24 @@ private void loadFileUriIntoView(final Uri uri, final View parent) {
16051618
}
16061619
}
16071620

1621+
/**
1622+
* Indicate if the incoming content URI should be allowed.
1623+
*
1624+
* @param uri the uri to test
1625+
* @return true if the URI is allowed for content preview
1626+
*/
1627+
private static boolean validForContentPreview(Uri uri) throws SecurityException {
1628+
if (uri == null) {
1629+
return false;
1630+
}
1631+
int userId = getUserIdFromUri(uri, UserHandle.USER_CURRENT);
1632+
if (userId != UserHandle.USER_CURRENT && userId != UserHandle.myUserId()) {
1633+
Log.e(TAG, "dropped invalid content URI belonging to user " + userId);
1634+
return false;
1635+
}
1636+
return true;
1637+
}
1638+
16081639
@VisibleForTesting
16091640
protected boolean isImageType(String mimeType) {
16101641
return mimeType != null && mimeType.startsWith("image/");

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2735,7 +2735,8 @@ protected boolean shouldListenForFingerprint(boolean isUdfps) {
27352735

27362736
boolean shouldListen = shouldListenKeyguardState && shouldListenUserState
27372737
&& shouldListenBouncerState && shouldListenUdfpsState
2738-
&& shouldListenSideFpsState;
2738+
&& shouldListenSideFpsState
2739+
&& !isFingerprintLockedOut();
27392740
logListenerModelData(
27402741
new KeyguardFingerprintListenModel(
27412742
System.currentTimeMillis(),

packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_BOOT;
2929
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_USER_LOCKDOWN;
3030
import static com.android.keyguard.FaceAuthApiRequestReason.NOTIFICATION_PANEL_CLICKED;
31+
import static com.android.keyguard.KeyguardUpdateMonitor.BIOMETRIC_STATE_CANCELLING;
3132
import static com.android.keyguard.KeyguardUpdateMonitor.BIOMETRIC_STATE_CANCELLING_RESTARTING;
3233
import static com.android.keyguard.KeyguardUpdateMonitor.DEFAULT_CANCEL_SIGNAL_TIMEOUT;
3334
import static com.android.keyguard.KeyguardUpdateMonitor.HAL_POWER_PRESS_TIMEOUT;
@@ -1040,10 +1041,11 @@ private void testMultiUserLockout_whenUserSwitches(
10401041
assertThat(mKeyguardUpdateMonitor.isFingerprintLockedOut()).isEqualTo(fpLocked);
10411042
assertThat(mKeyguardUpdateMonitor.isFaceLockedOut()).isEqualTo(faceLocked);
10421043

1043-
// Fingerprint should be restarted once its cancelled bc on lockout, the device
1044-
// can still detectFingerprint (and if it's not locked out, fingerprint can listen)
1044+
// Fingerprint should be cancelled on lockout if going to lockout state, else
1045+
// restarted if it's not
10451046
assertThat(mKeyguardUpdateMonitor.mFingerprintRunningState)
1046-
.isEqualTo(BIOMETRIC_STATE_CANCELLING_RESTARTING);
1047+
.isEqualTo(fpLocked
1048+
? BIOMETRIC_STATE_CANCELLING : BIOMETRIC_STATE_CANCELLING_RESTARTING);
10471049
}
10481050

10491051
@Test

services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1848,6 +1848,12 @@ private boolean readInstalledAccessibilityServiceLocked(AccessibilityUserState u
18481848
AccessibilityServiceInfo accessibilityServiceInfo;
18491849
try {
18501850
accessibilityServiceInfo = new AccessibilityServiceInfo(resolveInfo, mContext);
1851+
if (!accessibilityServiceInfo.isWithinParcelableSize()) {
1852+
Slog.e(LOG_TAG, "Skipping service "
1853+
+ accessibilityServiceInfo.getResolveInfo().getComponentInfo()
1854+
+ " because service info size is larger than safe parcelable limits.");
1855+
continue;
1856+
}
18511857
if (userState.mCrashedServices.contains(serviceInfo.getComponentName())) {
18521858
// Restore the crashed attribute.
18531859
accessibilityServiceInfo.crashed = true;

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13087,12 +13087,17 @@ public Intent registerReceiver(IApplicationThread caller, String callerPackage,
1308713087
public Intent registerReceiverWithFeature(IApplicationThread caller, String callerPackage,
1308813088
String callerFeatureId, String receiverId, IIntentReceiver receiver,
1308913089
IntentFilter filter, String permission, int userId, int flags) {
13090+
enforceNotIsolatedCaller("registerReceiver");
13091+
1309013092
// Allow Sandbox process to register only unexported receivers.
13091-
if ((flags & Context.RECEIVER_NOT_EXPORTED) != 0) {
13092-
enforceNotIsolatedCaller("registerReceiver");
13093-
} else if (mSdkSandboxSettings.isBroadcastReceiverRestrictionsEnforced()) {
13094-
enforceNotIsolatedOrSdkSandboxCaller("registerReceiver");
13093+
boolean unexported = (flags & Context.RECEIVER_NOT_EXPORTED) != 0;
13094+
if (mSdkSandboxSettings.isBroadcastReceiverRestrictionsEnforced()
13095+
&& Process.isSdkSandboxUid(Binder.getCallingUid())
13096+
&& !unexported) {
13097+
throw new SecurityException("SDK sandbox process not allowed to call "
13098+
+ "registerReceiver");
1309513099
}
13100+
1309613101
ArrayList<Intent> stickyIntents = null;
1309713102
ProcessRecord callerApp = null;
1309813103
final boolean visibleToInstantApps

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,13 @@ public long detectFingerprint(final IBinder token, final int userId,
452452
return -1;
453453
}
454454

455+
if (!Utils.isUserEncryptedOrLockdown(mLockPatternUtils, userId)) {
456+
// If this happens, something in KeyguardUpdateMonitor is wrong. This should only
457+
// ever be invoked when the user is encrypted or lockdown.
458+
Slog.e(TAG, "detectFingerprint invoked when user is not encrypted or lockdown");
459+
return -1;
460+
}
461+
455462
final Pair<Integer, ServiceProvider> provider = getSingleProvider();
456463
if (provider == null) {
457464
Slog.w(TAG, "Null provider for detectFingerprint");

0 commit comments

Comments
 (0)