Skip to content

Commit cd87e41

Browse files
Merge tag 'android-11.0.0_r38' of https://android.googlesource.com/platform/frameworks/base into r11.0
Android 11.0.0 Release 38 (RQ3A.210605.005)
1 parent 82ca685 commit cd87e41

File tree

443 files changed

+6009
-3346
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

443 files changed

+6009
-3346
lines changed

cmds/statsd/src/atoms.proto

+8-8
Original file line numberDiff line numberDiff line change
@@ -3612,11 +3612,11 @@ message AppStartOccurred {
36123612
// Empty if not set.
36133613
optional string launch_token = 13;
36143614

3615-
// The compiler filter used when when the package was optimized.
3616-
optional int32 package_optimization_compilation_filter = 14;
3617-
36183615
// The reason why the package was optimized.
3619-
optional int32 package_optimization_compilation_reason = 15;
3616+
optional int32 package_optimization_compilation_reason = 14;
3617+
3618+
// The compiler filter used when when the package was optimized.
3619+
optional int32 package_optimization_compilation_filter = 15;
36203620
}
36213621

36223622
message AppStartCanceled {
@@ -3662,11 +3662,11 @@ message AppStartFullyDrawn {
36623662
// App startup time (until call to Activity#reportFullyDrawn()).
36633663
optional int64 app_startup_time_millis = 6;
36643664

3665-
// The compiler filter used when when the package was optimized.
3666-
optional int32 package_optimization_compilation_filter = 7;
3667-
36683665
// The reason why the package was optimized.
3669-
optional int32 package_optimization_compilation_reason = 8;
3666+
optional int32 package_optimization_compilation_reason = 7;
3667+
3668+
// The compiler filter used when when the package was optimized.
3669+
optional int32 package_optimization_compilation_filter = 8;
36703670
}
36713671

36723672
/**

core/java/android/app/Activity.java

-6
Original file line numberDiff line numberDiff line change
@@ -5183,12 +5183,6 @@ protected void onApplyThemeResource(Resources.Theme theme, @StyleRes int resid,
51835183
* #checkSelfPermission(String)}.
51845184
* </p>
51855185
* <p>
5186-
* Calling this API for permissions already granted to your app would show UI
5187-
* to the user to decide whether the app can still hold these permissions. This
5188-
* can be useful if the way your app uses data guarded by the permissions
5189-
* changes significantly.
5190-
* </p>
5191-
* <p>
51925186
* You cannot request a permission if your activity sets {@link
51935187
* android.R.styleable#AndroidManifestActivity_noHistory noHistory} to
51945188
* <code>true</code> because in this case the activity would not receive

core/java/android/app/ActivityManagerInternal.java

+22
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,21 @@ public abstract void setDebugFlagsForStartingActivity(ActivityInfo aInfo, int st
377377
*/
378378
public abstract boolean hasRunningForegroundService(int uid, int foregroundServiceType);
379379

380+
/**
381+
* Returns {@code true} if the given notification channel currently has a
382+
* notification associated with a foreground service. This is an AMS check
383+
* because that is the source of truth for the FGS state.
384+
*/
385+
public abstract boolean hasForegroundServiceNotification(String pkg, @UserIdInt int userId,
386+
String channelId);
387+
388+
/**
389+
* If the given app has any FGSs whose notifications are in the given channel,
390+
* stop them.
391+
*/
392+
public abstract void stopForegroundServicesForChannel(String pkg, @UserIdInt int userId,
393+
String channelId);
394+
380395
/**
381396
* Registers the specified {@code processObserver} to be notified of future changes to
382397
* process state.
@@ -440,4 +455,11 @@ public abstract int broadcastIntent(Intent intent,
440455
* @return true if exists, false otherwise.
441456
*/
442457
public abstract boolean isPendingTopUid(int uid);
458+
459+
public abstract void tempAllowWhileInUsePermissionInFgs(int uid, long duration);
460+
461+
public abstract boolean isTempAllowlistedForFgsWhileInUse(int uid);
462+
463+
public abstract boolean canAllowWhileInUsePermissionInFgs(int pid, int uid,
464+
@NonNull String packageName);
443465
}

core/java/android/app/ActivityThread.java

+4
Original file line numberDiff line numberDiff line change
@@ -4603,6 +4603,10 @@ public void handleTopResumedActivityChanged(IBinder token, boolean onTop, String
46034603
}
46044604

46054605
if (r.isTopResumedActivity == onTop) {
4606+
if (!Build.IS_DEBUGGABLE) {
4607+
Slog.w(TAG, "Activity top position already set to onTop=" + onTop);
4608+
return;
4609+
}
46064610
throw new IllegalStateException("Activity top position already set to onTop=" + onTop);
46074611
}
46084612

core/java/android/app/AppOpsManager.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -2436,9 +2436,9 @@ public static String flagsToString(@OpFlags int flags) {
24362436
false, // READ_MEDIA_AUDIO
24372437
false, // WRITE_MEDIA_AUDIO
24382438
false, // READ_MEDIA_VIDEO
2439-
false, // WRITE_MEDIA_VIDEO
2439+
true, // WRITE_MEDIA_VIDEO
24402440
false, // READ_MEDIA_IMAGES
2441-
false, // WRITE_MEDIA_IMAGES
2441+
true, // WRITE_MEDIA_IMAGES
24422442
true, // LEGACY_STORAGE
24432443
false, // ACCESS_ACCESSIBILITY
24442444
false, // READ_DEVICE_IDENTIFIERS

core/java/android/app/admin/DevicePolicyManagerInternal.java

+7
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package android.app.admin;
1818

19+
import android.annotation.Nullable;
1920
import android.annotation.UserIdInt;
2021
import android.content.ComponentName;
2122
import android.content.Intent;
@@ -221,6 +222,7 @@ public abstract void broadcastIntentToCrossProfileManifestReceiversAsUser(Intent
221222
/**
222223
* Returns the profile owner component for the given user, or {@code null} if there is not one.
223224
*/
225+
@Nullable
224226
public abstract ComponentName getProfileOwnerAsUser(int userHandle);
225227

226228
/**
@@ -234,4 +236,9 @@ public abstract void broadcastIntentToCrossProfileManifestReceiversAsUser(Intent
234236
* {@link #supportsResetOp(int)} is true.
235237
*/
236238
public abstract void resetOp(int op, String packageName, @UserIdInt int userId);
239+
240+
/**
241+
* Returns whether the given package is a device owner or a profile owner in the calling user.
242+
*/
243+
public abstract boolean isDeviceOrProfileOwnerInCallingUser(String packageName);
237244
}

core/java/android/app/backup/BackupManager.java

+20-2
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,14 @@
2121
import android.annotation.RequiresPermission;
2222
import android.annotation.SystemApi;
2323
import android.annotation.TestApi;
24+
import android.app.compat.CompatChanges;
25+
import android.compat.annotation.ChangeId;
26+
import android.compat.annotation.EnabledAfter;
2427
import android.compat.annotation.UnsupportedAppUsage;
2528
import android.content.ComponentName;
2629
import android.content.Context;
2730
import android.content.Intent;
31+
import android.os.Build;
2832
import android.os.Bundle;
2933
import android.os.Handler;
3034
import android.os.Message;
@@ -391,6 +395,17 @@ public boolean isBackupEnabled() {
391395
return false;
392396
}
393397

398+
399+
/**
400+
* If this change is enabled, the {@code BACKUP} permission needed for
401+
* {@code isBackupServiceActive()} will be enforced on the service end
402+
* rather than client-side in {@link BackupManager}.
403+
* @hide
404+
*/
405+
@ChangeId
406+
@EnabledAfter(targetSdkVersion = Build.VERSION_CODES.R)
407+
public static final long IS_BACKUP_SERVICE_ACTIVE_ENFORCE_PERMISSION_IN_SERVICE = 158482162;
408+
394409
/**
395410
* Report whether the backup mechanism is currently active.
396411
* When it is inactive, the device will not perform any backup operations, nor will it
@@ -401,8 +416,11 @@ public boolean isBackupEnabled() {
401416
@SystemApi
402417
@RequiresPermission(android.Manifest.permission.BACKUP)
403418
public boolean isBackupServiceActive(UserHandle user) {
404-
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.BACKUP,
405-
"isBackupServiceActive");
419+
if (!CompatChanges.isChangeEnabled(
420+
IS_BACKUP_SERVICE_ACTIVE_ENFORCE_PERMISSION_IN_SERVICE)) {
421+
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.BACKUP,
422+
"isBackupServiceActive");
423+
}
406424
checkServiceBinder();
407425
if (sService != null) {
408426
try {

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

+4
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ public class ParsingPackageImpl implements ParsingPackage, Parcelable {
9898
public static ForInternedStringValueMap sForInternedStringValueMap =
9999
Parcelling.Cache.getOrCreate(ForInternedStringValueMap.class);
100100
public static ForStringSet sForStringSet = Parcelling.Cache.getOrCreate(ForStringSet.class);
101+
public static ForInternedStringSet sForInternedStringSet =
102+
Parcelling.Cache.getOrCreate(ForInternedStringSet.class);
101103
protected static ParsedIntentInfo.StringPairListParceler sForIntentInfoPairs =
102104
Parcelling.Cache.getOrCreate(ParsedIntentInfo.StringPairListParceler.class);
103105

@@ -1026,6 +1028,7 @@ public void writeToParcel(Parcel dest, int flags) {
10261028
dest.writeBoolean(this.forceQueryable);
10271029
dest.writeParcelableList(this.queriesIntents, flags);
10281030
sForInternedStringList.parcel(this.queriesPackages, dest, flags);
1031+
sForInternedStringSet.parcel(this.queriesProviders, dest, flags);
10291032
dest.writeString(this.appComponentFactory);
10301033
dest.writeString(this.backupAgentName);
10311034
dest.writeInt(this.banner);
@@ -1188,6 +1191,7 @@ public ParsingPackageImpl(Parcel in) {
11881191
this.forceQueryable = in.readBoolean();
11891192
this.queriesIntents = in.createTypedArrayList(Intent.CREATOR);
11901193
this.queriesPackages = sForInternedStringList.unparcel(in);
1194+
this.queriesProviders = sForInternedStringSet.unparcel(in);
11911195
this.appComponentFactory = in.readString();
11921196
this.backupAgentName = in.readString();
11931197
this.banner = in.readInt();

core/java/android/hardware/camera2/CameraManager.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -1367,6 +1367,8 @@ public void onCameraClosed(String id) {
13671367
// devices going offline (in real world scenarios, these permissions aren't
13681368
// changeable). Future calls to getCameraIdList() will reflect the changes in
13691369
// the camera id list after getCameraIdListNoLazy() is called.
1370+
// We need to remove the torch ids which may have been associated with the
1371+
// devices removed as well. This is the same situation.
13701372
cameraStatuses = mCameraService.addListener(testListener);
13711373
mCameraService.removeListener(testListener);
13721374
for (CameraStatus c : cameraStatuses) {
@@ -1385,6 +1387,7 @@ public void onCameraClosed(String id) {
13851387
}
13861388
for (String id : deviceIdsToRemove) {
13871389
onStatusChangedLocked(ICameraServiceListener.STATUS_NOT_PRESENT, id);
1390+
mTorchStatus.remove(id);
13881391
}
13891392
} catch (ServiceSpecificException e) {
13901393
// Unexpected failure
@@ -2051,7 +2054,9 @@ public void binderDied() {
20512054
// Tell listeners that the cameras and torch modes are unavailable and schedule a
20522055
// reconnection to camera service. When camera service is reconnected, the camera
20532056
// and torch statuses will be updated.
2054-
for (int i = 0; i < mDeviceStatus.size(); i++) {
2057+
// Iterate from the end to the beginning befcause onStatusChangedLocked removes
2058+
// entries from the ArrayMap.
2059+
for (int i = mDeviceStatus.size() - 1; i >= 0; i--) {
20552060
String cameraId = mDeviceStatus.keyAt(i);
20562061
onStatusChangedLocked(ICameraServiceListener.STATUS_NOT_PRESENT, cameraId);
20572062
}

core/java/android/hardware/display/DisplayManager.java

+50-8
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ public final class DisplayManager {
6161
* {@link #EXTRA_WIFI_DISPLAY_STATUS} extra.
6262
* </p><p>
6363
* This broadcast is only sent to registered receivers and can only be sent by the system.
64+
* </p><p>
65+
* {@link android.Manifest.permission#ACCESS_FINE_LOCATION} permission is required to
66+
* receive this broadcast.
6467
* </p>
6568
* @hide
6669
*/
@@ -875,37 +878,76 @@ public interface DisplayListener {
875878
public interface DeviceConfig {
876879

877880
/**
878-
* Key for refresh rate in the zone defined by thresholds.
881+
* Key for refresh rate in the low zone defined by thresholds.
879882
*
883+
* Note that the name and value don't match because they were added before we had a high
884+
* zone to consider.
880885
* @see android.provider.DeviceConfig#NAMESPACE_DISPLAY_MANAGER
881886
* @see android.R.integer#config_defaultZoneBehavior
882887
*/
883-
String KEY_REFRESH_RATE_IN_ZONE = "refresh_rate_in_zone";
888+
String KEY_REFRESH_RATE_IN_LOW_ZONE = "refresh_rate_in_zone";
884889

885890
/**
886-
* Key for accessing the display brightness thresholds for the configured refresh rate zone.
891+
* Key for accessing the low display brightness thresholds for the configured refresh
892+
* rate zone.
887893
* The value will be a pair of comma separated integers representing the minimum and maximum
888894
* thresholds of the zone, respectively, in display backlight units (i.e. [0, 255]).
895+
*
896+
* Note that the name and value don't match because they were added before we had a high
897+
* zone to consider.
889898
*
890899
* @see android.provider.DeviceConfig#NAMESPACE_DISPLAY_MANAGER
891900
* @see android.R.array#config_brightnessThresholdsOfPeakRefreshRate
892901
* @hide
893902
*/
894-
String KEY_PEAK_REFRESH_RATE_DISPLAY_BRIGHTNESS_THRESHOLDS =
903+
String KEY_FIXED_REFRESH_RATE_LOW_DISPLAY_BRIGHTNESS_THRESHOLDS =
895904
"peak_refresh_rate_brightness_thresholds";
896905

897906
/**
898-
* Key for accessing the ambient brightness thresholds for the configured refresh rate zone.
899-
* The value will be a pair of comma separated integers representing the minimum and maximum
900-
* thresholds of the zone, respectively, in lux.
907+
* Key for accessing the low ambient brightness thresholds for the configured refresh
908+
* rate zone. The value will be a pair of comma separated integers representing the minimum
909+
* and maximum thresholds of the zone, respectively, in lux.
901910
*
911+
* Note that the name and value don't match because they were added before we had a high
912+
* zone to consider.
913+
*
902914
* @see android.provider.DeviceConfig#NAMESPACE_DISPLAY_MANAGER
903915
* @see android.R.array#config_ambientThresholdsOfPeakRefreshRate
904916
* @hide
905917
*/
906-
String KEY_PEAK_REFRESH_RATE_AMBIENT_BRIGHTNESS_THRESHOLDS =
918+
String KEY_FIXED_REFRESH_RATE_LOW_AMBIENT_BRIGHTNESS_THRESHOLDS =
907919
"peak_refresh_rate_ambient_thresholds";
920+
/**
921+
* Key for refresh rate in the high zone defined by thresholds.
922+
*
923+
* @see android.provider.DeviceConfig#NAMESPACE_DISPLAY_MANAGER
924+
* @see android.R.integer#config_fixedRefreshRateInHighZone
925+
*/
926+
String KEY_REFRESH_RATE_IN_HIGH_ZONE = "refresh_rate_in_high_zone";
927+
928+
/**
929+
* Key for accessing the display brightness thresholds for the configured refresh rate zone.
930+
* The value will be a pair of comma separated integers representing the minimum and maximum
931+
* thresholds of the zone, respectively, in display backlight units (i.e. [0, 255]).
932+
*
933+
* @see android.provider.DeviceConfig#NAMESPACE_DISPLAY_MANAGER
934+
* @see android.R.array#config_brightnessHighThresholdsOfFixedRefreshRate
935+
* @hide
936+
*/
937+
String KEY_FIXED_REFRESH_RATE_HIGH_DISPLAY_BRIGHTNESS_THRESHOLDS =
938+
"fixed_refresh_rate_high_display_brightness_thresholds";
908939

940+
/**
941+
* Key for accessing the ambient brightness thresholds for the configured refresh rate zone.
942+
* The value will be a pair of comma separated integers representing the minimum and maximum
943+
* thresholds of the zone, respectively, in lux.
944+
*
945+
* @see android.provider.DeviceConfig#NAMESPACE_DISPLAY_MANAGER
946+
* @see android.R.array#config_ambientHighThresholdsOfFixedRefreshRate
947+
* @hide
948+
*/
949+
String KEY_FIXED_REFRESH_RATE_HIGH_AMBIENT_BRIGHTNESS_THRESHOLDS =
950+
"fixed_refresh_rate_high_ambient_brightness_thresholds";
909951
/**
910952
* Key for default peak refresh rate
911953
*

core/java/android/hardware/usb/AccessoryFilter.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public void write(XmlSerializer serializer)throws IOException {
101101
public boolean matches(UsbAccessory acc) {
102102
if (mManufacturer != null && !acc.getManufacturer().equals(mManufacturer)) return false;
103103
if (mModel != null && !acc.getModel().equals(mModel)) return false;
104-
return !(mVersion != null && !acc.getVersion().equals(mVersion));
104+
return !(mVersion != null && !mVersion.equals(acc.getVersion()));
105105
}
106106

107107
/**

core/java/android/nfc/NfcAdapter.java

+6
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,12 @@ public static NfcAdapter getDefaultAdapter(Context context) {
677677
throw new IllegalArgumentException(
678678
"context not associated with any application (using a mock context?)");
679679
}
680+
681+
if (getServiceInterface() == null) {
682+
// NFC is not available
683+
return null;
684+
}
685+
680686
/* use getSystemService() for consistency */
681687
NfcManager manager = (NfcManager) context.getSystemService(Context.NFC_SERVICE);
682688
if (manager == null) {

0 commit comments

Comments
 (0)