Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
4800557
DO NOT MERGE
Mar 22, 2022
818899c
switch TelecomManager List getters to ParceledListSlice
Jun 23, 2022
f7c22a2
[RESTRICT AUTOMERGE] Do not send new Intent to non-exported activity …
Aug 2, 2022
0a5fd74
Do not send AccessibilityEvent if notification is for different user.
Daniel-Norman Aug 12, 2022
120f96c
DO NOT MERGE Fix auto-grant of AR runtime permission if device is upg…
Jul 29, 2022
82e77e2
Check rule package name in ZenModeHelper.addAutomaticRule
Aug 25, 2022
4a9fb26
Trim any long string inputs that come in to AutomaticZenRule
Aug 29, 2022
748ccf1
Fix system zen rules by using owner package name if caller is system
Sep 6, 2022
396226c
Make sure parallel broadcasts enforce excluded permissions
Jan 14, 2022
b246c92
Limit the number of concurrently snoozed notifications
Jul 1, 2022
0cb1977
Revert "Prevent non-admin users from deleting system apps."
Jul 19, 2022
341facd
Revert "Prevent exfiltration of system files via user image settings."
Jul 27, 2022
8f30d4c
Prevent non-admin users from deleting system apps.
Aug 9, 2022
27fcaba
Limit the size of NotificationChannel and NotificationChannelGroup
Aug 19, 2022
4802b6c
Include all enabled services when FEEDBACK_ALL_MASK.
Daniel-Norman Sep 1, 2022
6b01b63
[pm] forbid deletion of protected packages
schfan-1 Sep 9, 2022
6399531
Limit lengths of fields in Condition to a max length.
Sep 13, 2022
a223859
Fix NPE
Sep 6, 2022
eb47b2c
Fix a security issue in app widget service.
pinyaoting Jul 14, 2022
6171c91
[RESTRICT AUTOMERGE] Allow activity to be reparent while allowTaskRep…
Sep 14, 2022
e4385e0
[DO NOT MERGE] Update window with FLAG_SECURE when bouncer is showing
mpietal79 Mar 30, 2022
d0a144e
Prevent exfiltration of system files via avatar picker.
Aug 26, 2022
eeec6a9
[Do Not Merge] Ignore malformed shortcuts
pinyaoting Sep 21, 2022
f6c343d
Lower per-app notificationchannel limit
Aug 31, 2022
3021bb3
[DO NOT MERGE] Fix permanent denial of service via setComponentEnable…
Sep 26, 2022
6fae947
Add safety checks on KEY_INTENT mismatch.
Oct 4, 2022
824d285
Validate package name passed to setApplicationRestrictions.
Aug 19, 2022
068dce9
[DO NOT MERGE] Revert "Fix system zen rules by using owner package na…
Nov 7, 2022
cdefa69
[DO NOT MERGE] Revert "Check rule package name in ZenModeHelper.addAu…
Nov 7, 2022
521d3e3
Limit length and number of MIME types you can set
Aug 30, 2022
e9300a8
Disable all A11yServices from an uninstalled package.
Daniel-Norman Oct 5, 2022
847c626
[DO NOT MERGE] Fix conditionId string trimming in AutomaticZenRule
Oct 12, 2022
6f692e2
[RESTRICT AUTOMERGE] [SettingsProvider] mem limit should be checked b…
schfan-1 Aug 17, 2022
da9ce92
Backport missing permission check for querying main activity intent
Feb 8, 2022
2dc4541
RESTRICT AUTOMERGE Validate permission tree size on permission update
Sep 22, 2022
fd3e1a6
[RESTRICT AUTOMERGE][SettingsProvider] key size limit for mutating se…
schfan-1 Oct 12, 2022
3218617
[RESTRICT AUTOMERGE] Trim the activity info of another uid if no priv…
Sep 28, 2022
097ee0b
RESTRICT AUTOMERGE Revoke SYSTEM_ALERT_WINDOW on upgrade past api 23
Sep 23, 2022
ebc061f
Add protections against queueing a UsbRequest when the underlying Usb…
Sep 23, 2022
71f251b
Fix sharing to another profile where an app has multiple targets
Oct 11, 2022
fed72b2
Ensure that only SysUI can override pending intent launch flags
Oct 18, 2022
02a4ef7
PixelPropsUtils: Update fingerprints to January 2023 release
joeyhuab Jan 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions core/java/android/accounts/Account.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@

import com.android.internal.annotations.GuardedBy;

import java.util.Objects;
import java.util.Set;

/**
Expand Down Expand Up @@ -87,12 +86,6 @@ public Account(String name, String type, String accessId) {
if (TextUtils.isEmpty(type)) {
throw new IllegalArgumentException("the type must not be empty: " + type);
}
if (name.length() > 200) {
throw new IllegalArgumentException("account name is longer than 200 characters");
}
if (type.length() > 200) {
throw new IllegalArgumentException("account type is longer than 200 characters");
}
this.name = name;
this.type = type;
this.accessId = accessId;
Expand Down
60 changes: 49 additions & 11 deletions core/java/android/app/AutomaticZenRule.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ public final class AutomaticZenRule implements Parcelable {
private boolean mModified = false;
private String mPkg;

/**
* The maximum string length for any string contained in this automatic zen rule. This pertains
* both to fields in the rule itself (such as its name) and items with sub-fields.
* @hide
*/
public static final int MAX_STRING_LENGTH = 1000;

/**
* Creates an automatic zen rule.
*
Expand Down Expand Up @@ -93,10 +100,10 @@ public AutomaticZenRule(String name, ComponentName owner, Uri conditionId,
public AutomaticZenRule(@NonNull String name, @Nullable ComponentName owner,
@Nullable ComponentName configurationActivity, @NonNull Uri conditionId,
@Nullable ZenPolicy policy, int interruptionFilter, boolean enabled) {
this.name = name;
this.owner = owner;
this.configurationActivity = configurationActivity;
this.conditionId = conditionId;
this.name = getTrimmedString(name);
this.owner = getTrimmedComponentName(owner);
this.configurationActivity = getTrimmedComponentName(configurationActivity);
this.conditionId = getTrimmedUri(conditionId);
this.interruptionFilter = interruptionFilter;
this.enabled = enabled;
this.mZenPolicy = policy;
Expand All @@ -115,12 +122,12 @@ public AutomaticZenRule(String name, ComponentName owner, ComponentName configur
public AutomaticZenRule(Parcel source) {
enabled = source.readInt() == ENABLED;
if (source.readInt() == ENABLED) {
name = source.readString();
name = getTrimmedString(source.readString());
}
interruptionFilter = source.readInt();
conditionId = source.readParcelable(null);
owner = source.readParcelable(null);
configurationActivity = source.readParcelable(null);
conditionId = getTrimmedUri(source.readParcelable(null));
owner = getTrimmedComponentName(source.readParcelable(null));
configurationActivity = getTrimmedComponentName(source.readParcelable(null));
creationTime = source.readLong();
mZenPolicy = source.readParcelable(null);
mModified = source.readInt() == ENABLED;
Expand Down Expand Up @@ -196,7 +203,7 @@ public long getCreationTime() {
* Sets the representation of the state that causes this rule to become active.
*/
public void setConditionId(Uri conditionId) {
this.conditionId = conditionId;
this.conditionId = getTrimmedUri(conditionId);
}

/**
Expand All @@ -211,7 +218,7 @@ public void setInterruptionFilter(@InterruptionFilter int interruptionFilter) {
* Sets the name of this rule.
*/
public void setName(String name) {
this.name = name;
this.name = getTrimmedString(name);
}

/**
Expand Down Expand Up @@ -243,7 +250,7 @@ public void setZenPolicy(ZenPolicy zenPolicy) {
* that are not backed by {@link android.service.notification.ConditionProviderService}.
*/
public void setConfigurationActivity(@Nullable ComponentName componentName) {
this.configurationActivity = componentName;
this.configurationActivity = getTrimmedComponentName(componentName);
}

/**
Expand Down Expand Up @@ -333,4 +340,35 @@ public AutomaticZenRule[] newArray(int size) {
return new AutomaticZenRule[size];
}
};

/**
* If the package or class name of the provided ComponentName are longer than MAX_STRING_LENGTH,
* return a trimmed version that truncates each of the package and class name at the max length.
*/
private static ComponentName getTrimmedComponentName(ComponentName cn) {
if (cn == null) return null;
return new ComponentName(getTrimmedString(cn.getPackageName()),
getTrimmedString(cn.getClassName()));
}

/**
* Returns a truncated copy of the string if the string is longer than MAX_STRING_LENGTH.
*/
private static String getTrimmedString(String input) {
if (input != null && input.length() > MAX_STRING_LENGTH) {
return input.substring(0, MAX_STRING_LENGTH);
}
return input;
}

/**
* Returns a truncated copy of the Uri by trimming the string representation to the maximum
* string length.
*/
private static Uri getTrimmedUri(Uri input) {
if (input != null && input.toString().length() > MAX_STRING_LENGTH) {
return Uri.parse(getTrimmedString(input.toString()));
}
return input;
}
}
23 changes: 16 additions & 7 deletions core/java/android/app/NotificationChannel.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,13 @@ public final class NotificationChannel implements Parcelable {
/**
* The maximum length for text fields in a NotificationChannel. Fields will be truncated at this
* limit.
* @hide
*/
private static final int MAX_TEXT_LENGTH = 1000;
public static final int MAX_TEXT_LENGTH = 1000;
/**
* @hide
*/
public static final int MAX_VIBRATION_LENGTH = 1000;

private static final String TAG_CHANNEL = "channel";
private static final String ATT_NAME = "name";
Expand Down Expand Up @@ -290,17 +295,17 @@ public NotificationChannel(String id, CharSequence name, @Importance int importa
*/
protected NotificationChannel(Parcel in) {
if (in.readByte() != 0) {
mId = in.readString();
mId = getTrimmedString(in.readString());
} else {
mId = null;
}
if (in.readByte() != 0) {
mName = in.readString();
mName = getTrimmedString(in.readString());
} else {
mName = null;
}
if (in.readByte() != 0) {
mDesc = in.readString();
mDesc = getTrimmedString(in.readString());
} else {
mDesc = null;
}
Expand All @@ -309,18 +314,22 @@ protected NotificationChannel(Parcel in) {
mLockscreenVisibility = in.readInt();
if (in.readByte() != 0) {
mSound = Uri.CREATOR.createFromParcel(in);
mSound = Uri.parse(getTrimmedString(mSound.toString()));
} else {
mSound = null;
}
mLights = in.readByte() != 0;
mVibration = in.createLongArray();
if (mVibration != null && mVibration.length > MAX_VIBRATION_LENGTH) {
mVibration = Arrays.copyOf(mVibration, MAX_VIBRATION_LENGTH);
}
mUserLockedFields = in.readInt();
mFgServiceShown = in.readByte() != 0;
mVibrationEnabled = in.readByte() != 0;
mShowBadge = in.readByte() != 0;
mDeleted = in.readByte() != 0;
if (in.readByte() != 0) {
mGroup = in.readString();
mGroup = getTrimmedString(in.readString());
} else {
mGroup = null;
}
Expand All @@ -332,8 +341,8 @@ protected NotificationChannel(Parcel in) {
mAllowBubbles = in.readInt();
mImportanceLockedByOEM = in.readBoolean();
mOriginalImportance = in.readInt();
mParentId = in.readString();
mConversationId = in.readString();
mParentId = getTrimmedString(in.readString());
mConversationId = getTrimmedString(in.readString());
mDemoted = in.readBoolean();
mImportantConvo = in.readBoolean();
mDeletedTime = in.readLong();
Expand Down
20 changes: 15 additions & 5 deletions core/java/android/app/NotificationChannelGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ public final class NotificationChannelGroup implements Parcelable {
/**
* The maximum length for text fields in a NotificationChannelGroup. Fields will be truncated at
* this limit.
* @hide
*/
private static final int MAX_TEXT_LENGTH = 1000;
public static final int MAX_TEXT_LENGTH = 1000;

private static final String TAG_GROUP = "channelGroup";
private static final String ATT_NAME = "name";
Expand Down Expand Up @@ -90,13 +91,17 @@ public NotificationChannelGroup(String id, CharSequence name) {
*/
protected NotificationChannelGroup(Parcel in) {
if (in.readByte() != 0) {
mId = in.readString();
mId = getTrimmedString(in.readString());
} else {
mId = null;
}
mName = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
if (in.readByte() != 0) {
mDescription = in.readString();
mName = getTrimmedString(in.readString());
} else {
mName = "";
}
if (in.readByte() != 0) {
mDescription = getTrimmedString(in.readString());
} else {
mDescription = null;
}
Expand All @@ -120,7 +125,12 @@ public void writeToParcel(Parcel dest, int flags) {
} else {
dest.writeByte((byte) 0);
}
TextUtils.writeToParcel(mName, dest, flags);
if (mName != null) {
dest.writeByte((byte) 1);
dest.writeString(mName.toString());
} else {
dest.writeByte((byte) 0);
}
if (mDescription != null) {
dest.writeByte((byte) 1);
dest.writeString(mDescription);
Expand Down
4 changes: 3 additions & 1 deletion core/java/android/appwidget/AppWidgetManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -1130,7 +1130,9 @@ public void setBindAppWidgetPermission(
* @param intent The intent of the service which will be providing the data to the
* RemoteViewsAdapter.
* @param connection The callback interface to be notified when a connection is made or lost.
* @param flags Flags used for binding to the service
* @param flags Flags used for binding to the service. Currently only
* {@link Context#BIND_AUTO_CREATE} and
* {@link Context#BIND_FOREGROUND_SERVICE_WHILE_AWAKE} are supported.
*
* @see Context#getServiceDispatcher(ServiceConnection, Handler, int)
* @hide
Expand Down
4 changes: 2 additions & 2 deletions core/java/android/content/pm/ILauncherApps.aidl
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ interface ILauncherApps {
void startActivityAsUser(in IApplicationThread caller, String callingPackage,
String callingFeatureId, in ComponentName component, in Rect sourceBounds,
in Bundle opts, in UserHandle user);
PendingIntent getActivityLaunchIntent(in ComponentName component, in Bundle opts,
in UserHandle user);
PendingIntent getActivityLaunchIntent(String callingPackage, in ComponentName component,
in Bundle opts, in UserHandle user);
void showAppDetailsAsUser(in IApplicationThread caller, String callingPackage,
String callingFeatureId, in ComponentName component, in Rect sourceBounds,
in Bundle opts, in UserHandle user);
Expand Down
3 changes: 2 additions & 1 deletion core/java/android/content/pm/LauncherApps.java
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,8 @@ public PendingIntent getMainActivityLaunchIntent(@NonNull ComponentName componen
}
try {
// due to b/209607104, startActivityOptions will be ignored
return mService.getActivityLaunchIntent(component, null /* opts */, user);
return mService.getActivityLaunchIntent(mContext.getPackageName(), component,
null /* opts */, user);
} catch (RemoteException re) {
throw re.rethrowFromSystemServer();
}
Expand Down
3 changes: 3 additions & 0 deletions core/java/android/content/pm/parsing/ParsingPackageImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -1695,6 +1695,9 @@ private void addMimeGroupsFromComponent(ParsedComponent component) {
for (int i = component.getIntents().size() - 1; i >= 0; i--) {
IntentFilter filter = component.getIntents().get(i);
for (int groupIndex = filter.countMimeGroups() - 1; groupIndex >= 0; groupIndex--) {
if (mimeGroups != null && mimeGroups.size() > 500) {
throw new IllegalStateException("Max limit on number of MIME Groups reached");
}
mimeGroups = ArrayUtils.add(mimeGroups, filter.getMimeGroup(groupIndex));
}
}
Expand Down
28 changes: 28 additions & 0 deletions core/java/android/hardware/usb/UsbDeviceConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,34 @@ boolean isOpen() {
}
}

/**
* This is meant to be called by UsbRequest's queue() in order to synchronize on
* UsbDeviceConnection's mLock to prevent the connection being closed while queueing.
*/
/* package */ boolean queueRequest(UsbRequest request, ByteBuffer buffer, int length) {
synchronized (mLock) {
if (!isOpen()) {
return false;
}

return request.queueIfConnectionOpen(buffer, length);
}
}

/**
* This is meant to be called by UsbRequest's queue() in order to synchronize on
* UsbDeviceConnection's mLock to prevent the connection being closed while queueing.
*/
/* package */ boolean queueRequest(UsbRequest request, @Nullable ByteBuffer buffer) {
synchronized (mLock) {
if (!isOpen()) {
return false;
}

return request.queueIfConnectionOpen(buffer);
}
}

/**
* Releases all system resources related to the device.
* Once the object is closed it cannot be used again.
Expand Down
Loading