Skip to content

Commit 3947290

Browse files
Android Build Coastguard Workeranisassigoogle
authored andcommitted
Merge cherrypicks of [15800618, 15800895, 15800896, 15800898, 15800900, 15800902, 15800904, 15800906, 15800675, 15800677, 15800968, 15800798, 15800799, 15800801] into security-aosp-rvc-release
Change-Id: I5ee7ecc2ea2216aaf2cff64740c8638ed74c9e12
2 parents 846d7ec + fb173a0 commit 3947290

10 files changed

Lines changed: 90 additions & 52 deletions

File tree

core/java/android/bluetooth/BluetoothDevice.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1081,7 +1081,10 @@ public String getAlias() {
10811081
if (alias == null) {
10821082
return getName();
10831083
}
1084-
return alias;
1084+
return alias
1085+
.replace('\t', ' ')
1086+
.replace('\n', ' ')
1087+
.replace('\r', ' ');
10851088
} catch (RemoteException e) {
10861089
Log.e(TAG, "", e);
10871090
}

core/java/android/content/pm/parsing/ParsingPackageImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,7 +1005,7 @@ public void writeToParcel(Parcel dest, int flags) {
10051005
sForInternedStringList.parcel(this.requestedPermissions, dest, flags);
10061006
sForInternedStringList.parcel(this.implicitPermissions, dest, flags);
10071007
sForStringSet.parcel(this.upgradeKeySets, dest, flags);
1008-
dest.writeMap(this.keySetMapping);
1008+
ParsingPackageUtils.writeKeySetMapping(dest, this.keySetMapping);
10091009
sForInternedStringList.parcel(this.protectedBroadcasts, dest, flags);
10101010
dest.writeTypedList(this.activities);
10111011
dest.writeTypedList(this.receivers);
@@ -1024,7 +1024,7 @@ public void writeToParcel(Parcel dest, int flags) {
10241024
dest.writeBoolean(this.use32BitAbi);
10251025
dest.writeBoolean(this.visibleToInstantApps);
10261026
dest.writeBoolean(this.forceQueryable);
1027-
dest.writeParcelableList(this.queriesIntents, flags);
1027+
dest.writeTypedList(this.queriesIntents, flags);
10281028
sForInternedStringList.parcel(this.queriesPackages, dest, flags);
10291029
dest.writeString(this.appComponentFactory);
10301030
dest.writeString(this.backupAgentName);
@@ -1166,7 +1166,7 @@ public ParsingPackageImpl(Parcel in) {
11661166
this.requestedPermissions = sForInternedStringList.unparcel(in);
11671167
this.implicitPermissions = sForInternedStringList.unparcel(in);
11681168
this.upgradeKeySets = sForStringSet.unparcel(in);
1169-
this.keySetMapping = in.readHashMap(boot);
1169+
this.keySetMapping = ParsingPackageUtils.readKeySetMapping(in);
11701170
this.protectedBroadcasts = sForInternedStringList.unparcel(in);
11711171

11721172
this.activities = in.createTypedArrayList(ParsedActivity.CREATOR);

core/java/android/content/pm/parsing/ParsingPackageUtils.java

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
import android.os.Build;
8585
import android.os.Bundle;
8686
import android.os.FileUtils;
87+
import android.os.Parcel;
8788
import android.os.RemoteException;
8889
import android.os.Trace;
8990
import android.os.ext.SdkExtensions;
@@ -2834,6 +2835,68 @@ private static String nonResString(@StyleableRes int index, TypedArray sa) {
28342835
return sa.getNonResourceString(index);
28352836
}
28362837

2838+
/**
2839+
* Writes the keyset mapping to the provided package. {@code null} mappings are permitted.
2840+
*/
2841+
public static void writeKeySetMapping(@NonNull Parcel dest,
2842+
@NonNull Map<String, ArraySet<PublicKey>> keySetMapping) {
2843+
if (keySetMapping == null) {
2844+
dest.writeInt(-1);
2845+
return;
2846+
}
2847+
2848+
final int N = keySetMapping.size();
2849+
dest.writeInt(N);
2850+
2851+
for (String key : keySetMapping.keySet()) {
2852+
dest.writeString(key);
2853+
ArraySet<PublicKey> keys = keySetMapping.get(key);
2854+
if (keys == null) {
2855+
dest.writeInt(-1);
2856+
continue;
2857+
}
2858+
2859+
final int M = keys.size();
2860+
dest.writeInt(M);
2861+
for (int j = 0; j < M; j++) {
2862+
dest.writeSerializable(keys.valueAt(j));
2863+
}
2864+
}
2865+
}
2866+
2867+
/**
2868+
* Reads a keyset mapping from the given parcel at the given data position. May return
2869+
* {@code null} if the serialized mapping was {@code null}.
2870+
*/
2871+
@NonNull
2872+
public static ArrayMap<String, ArraySet<PublicKey>> readKeySetMapping(@NonNull Parcel in) {
2873+
final int N = in.readInt();
2874+
if (N == -1) {
2875+
return null;
2876+
}
2877+
2878+
ArrayMap<String, ArraySet<PublicKey>> keySetMapping = new ArrayMap<>();
2879+
for (int i = 0; i < N; ++i) {
2880+
String key = in.readString();
2881+
final int M = in.readInt();
2882+
if (M == -1) {
2883+
keySetMapping.put(key, null);
2884+
continue;
2885+
}
2886+
2887+
ArraySet<PublicKey> keys = new ArraySet<>(M);
2888+
for (int j = 0; j < M; ++j) {
2889+
PublicKey pk = (PublicKey) in.readSerializable();
2890+
keys.add(pk);
2891+
}
2892+
2893+
keySetMapping.put(key, keys);
2894+
}
2895+
2896+
return keySetMapping;
2897+
}
2898+
2899+
28372900
/**
28382901
* Callback interface for retrieving information that may be needed while parsing
28392902
* a package.

core/java/android/hardware/camera2/params/OutputConfiguration.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -631,13 +631,7 @@ public int getSurfaceGroupId() {
631631
new Parcelable.Creator<OutputConfiguration>() {
632632
@Override
633633
public OutputConfiguration createFromParcel(Parcel source) {
634-
try {
635-
OutputConfiguration outputConfiguration = new OutputConfiguration(source);
636-
return outputConfiguration;
637-
} catch (Exception e) {
638-
Log.e(TAG, "Exception creating OutputConfiguration from parcel", e);
639-
return null;
640-
}
634+
return new OutputConfiguration(source);
641635
}
642636

643637
@Override

core/java/android/hardware/camera2/params/SessionConfiguration.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,7 @@ private SessionConfiguration(@NonNull Parcel source) {
143143
new Parcelable.Creator<SessionConfiguration> () {
144144
@Override
145145
public SessionConfiguration createFromParcel(Parcel source) {
146-
try {
147-
SessionConfiguration sessionConfiguration = new SessionConfiguration(source);
148-
return sessionConfiguration;
149-
} catch (Exception e) {
150-
Log.e(TAG, "Exception creating SessionConfiguration from parcel", e);
151-
return null;
152-
}
146+
return new SessionConfiguration(source);
153147
}
154148

155149
@Override

core/java/android/hardware/camera2/params/VendorTagDescriptor.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,7 @@ private VendorTagDescriptor(Parcel source) {
3636
new Parcelable.Creator<VendorTagDescriptor>() {
3737
@Override
3838
public VendorTagDescriptor createFromParcel(Parcel source) {
39-
try {
40-
VendorTagDescriptor vendorDescriptor = new VendorTagDescriptor(source);
41-
return vendorDescriptor;
42-
} catch (Exception e) {
43-
Log.e(TAG, "Exception creating VendorTagDescriptor from parcel", e);
44-
return null;
45-
}
39+
return new VendorTagDescriptor(source);
4640
}
4741

4842
@Override

core/java/android/hardware/camera2/params/VendorTagDescriptorCache.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,7 @@ private VendorTagDescriptorCache(Parcel source) {
3636
new Parcelable.Creator<VendorTagDescriptorCache>() {
3737
@Override
3838
public VendorTagDescriptorCache createFromParcel(Parcel source) {
39-
try {
40-
VendorTagDescriptorCache vendorDescriptorCache = new VendorTagDescriptorCache(source);
41-
return vendorDescriptorCache;
42-
} catch (Exception e) {
43-
Log.e(TAG, "Exception creating VendorTagDescriptorCache from parcel", e);
44-
return null;
45-
}
39+
return new VendorTagDescriptorCache(source);
4640
}
4741

4842
@Override

packages/CompanionDeviceManager/src/com/android/companiondevicemanager/DeviceChooserActivity.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ public void onCreate(Bundle savedInstanceState) {
6464
final DeviceFilterPair selectedDevice = getService().mDevicesFound.get(0);
6565
setTitle(Html.fromHtml(getString(
6666
R.string.confirmation_title,
67-
getCallingAppName(),
68-
selectedDevice.getDisplayName()), 0));
67+
Html.escapeHtml(getCallingAppName()),
68+
Html.escapeHtml(selectedDevice.getDisplayName())), 0));
6969
mPairButton = findViewById(R.id.button_pair);
7070
mPairButton.setOnClickListener(v -> onDeviceConfirmed(getService().mSelectedDevice));
7171
getService().mSelectedDevice = selectedDevice;
@@ -74,7 +74,8 @@ public void onCreate(Bundle savedInstanceState) {
7474
setContentView(R.layout.device_chooser);
7575
mPairButton = findViewById(R.id.button_pair);
7676
mPairButton.setVisibility(View.GONE);
77-
setTitle(Html.fromHtml(getString(R.string.chooser_title, getCallingAppName()), 0));
77+
setTitle(Html.fromHtml(getString(R.string.chooser_title,
78+
Html.escapeHtml(getCallingAppName())), 0));
7879
mDeviceListView = findViewById(R.id.device_list);
7980
final DeviceDiscoveryService.DevicesAdapter adapter = getService().mDevicesAdapter;
8081
mDeviceListView.setAdapter(adapter);

services/core/java/com/android/server/pm/CrossProfileAppsServiceImpl.java

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -475,16 +475,16 @@ private void setInteractAcrossProfilesAppOpForUserOrThrow(
475475
// this particular app-op to be modified without the broader app-op permissions.
476476
mInjector.withCleanCallingIdentity(() ->
477477
mInjector.getAppOpsManager()
478-
.setMode(OP_INTERACT_ACROSS_PROFILES, uid, packageName, newMode));
478+
.setUidMode(OP_INTERACT_ACROSS_PROFILES, uid, newMode));
479479
} else {
480480
mInjector.getAppOpsManager()
481-
.setMode(OP_INTERACT_ACROSS_PROFILES, uid, packageName, newMode);
481+
.setUidMode(OP_INTERACT_ACROSS_PROFILES, uid, newMode);
482482
}
483483
// Kill the UID before sending the broadcast to ensure that apps can be informed when
484484
// their app-op has been revoked.
485485
maybeKillUid(packageName, uid, hadPermission);
486-
sendCanInteractAcrossProfilesChangedBroadcast(packageName, uid, UserHandle.of(userId));
487-
maybeLogSetInteractAcrossProfilesAppOp(packageName, newMode, userId, logMetrics, uid);
486+
sendCanInteractAcrossProfilesChangedBroadcast(packageName, UserHandle.of(userId));
487+
maybeLogSetInteractAcrossProfilesAppOp(packageName, newMode, userId, logMetrics);
488488
}
489489

490490
/**
@@ -503,11 +503,7 @@ private void maybeKillUid(
503503
}
504504

505505
private void maybeLogSetInteractAcrossProfilesAppOp(
506-
String packageName,
507-
@Mode int newMode,
508-
@UserIdInt int userId,
509-
boolean logMetrics,
510-
int uid) {
506+
String packageName, @Mode int newMode, @UserIdInt int userId, boolean logMetrics) {
511507
if (!logMetrics) {
512508
return;
513509
}
@@ -519,7 +515,7 @@ private void maybeLogSetInteractAcrossProfilesAppOp(
519515
.createEvent(DevicePolicyEnums.SET_INTERACT_ACROSS_PROFILES_APP_OP)
520516
.setStrings(packageName)
521517
.setInt(newMode)
522-
.setBoolean(appDeclaresCrossProfileAttribute(uid))
518+
.setBoolean(appDeclaresCrossProfileAttribute(packageName))
523519
.write();
524520
}
525521

@@ -536,10 +532,10 @@ private boolean currentModeEquals(@Mode int otherMode, String packageName, int u
536532
}
537533

538534
private void sendCanInteractAcrossProfilesChangedBroadcast(
539-
String packageName, int uid, UserHandle userHandle) {
535+
String packageName, UserHandle userHandle) {
540536
final Intent intent =
541537
new Intent(ACTION_CAN_INTERACT_ACROSS_PROFILES_CHANGED).setPackage(packageName);
542-
if (appDeclaresCrossProfileAttribute(uid)) {
538+
if (appDeclaresCrossProfileAttribute(packageName)) {
543539
intent.addFlags(
544540
Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND | Intent.FLAG_RECEIVER_FOREGROUND);
545541
} else {
@@ -556,8 +552,8 @@ private List<ResolveInfo> findBroadcastReceiversForUser(Intent intent, UserHandl
556552
.queryBroadcastReceiversAsUser(intent, /* flags= */ 0, userHandle);
557553
}
558554

559-
private boolean appDeclaresCrossProfileAttribute(int uid) {
560-
return mInjector.getPackageManagerInternal().getPackage(uid).isCrossProfile();
555+
private boolean appDeclaresCrossProfileAttribute(String packageName) {
556+
return mInjector.getPackageManagerInternal().getPackage(packageName).isCrossProfile();
561557
}
562558

563559
@Override

services/core/java/com/android/server/tv/TvInputManagerService.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2005,10 +2005,9 @@ private void ensureCaptureTvInputPermission() {
20052005
public void requestChannelBrowsable(Uri channelUri, int userId)
20062006
throws RemoteException {
20072007
final String callingPackageName = getCallingPackageName();
2008+
final int resolvedUserId = resolveCallingUserId(Binder.getCallingPid(),
2009+
Binder.getCallingUid(), userId, "requestChannelBrowsable");
20082010
final long identity = Binder.clearCallingIdentity();
2009-
final int callingUid = Binder.getCallingUid();
2010-
final int resolvedUserId = resolveCallingUserId(Binder.getCallingPid(), callingUid,
2011-
userId, "requestChannelBrowsable");
20122011
try {
20132012
Intent intent = new Intent(TvContract.ACTION_CHANNEL_BROWSABLE_REQUESTED);
20142013
List<ResolveInfo> list = getContext().getPackageManager()

0 commit comments

Comments
 (0)