diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2024-04-25 01:26:32 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2024-04-25 01:26:32 +0000 |
commit | c078aa79777799fd00b25d55ff2ab063e08d27f0 (patch) | |
tree | 66643625c17ca2b7040ff36fa12c31b239f0d6c6 | |
parent | cfb8b9d369380dad1674bf1d6e629caa78bde915 (diff) | |
parent | 54cea85c51d85aec89cb81c6c95e75b16e6669d4 (diff) | |
download | base-sdk-release.tar.gz |
Merge "Snap for 11762235 from 548ee3851e394f9eeac1f105904cba9f2a6f2d10 to sdk-release" into sdk-releasesdk-release
7 files changed, 92 insertions, 53 deletions
diff --git a/media/jni/android_media_MediaCodec.cpp b/media/jni/android_media_MediaCodec.cpp index 8a13c034995d..4492c858c084 100644 --- a/media/jni/android_media_MediaCodec.cpp +++ b/media/jni/android_media_MediaCodec.cpp @@ -2088,31 +2088,27 @@ static status_t extractInfosFromObject( } return BAD_VALUE; } - size_t offset = static_cast<size_t>(env->GetIntField(param, gFields.bufferInfoOffset)); - size_t size = static_cast<size_t>(env->GetIntField(param, gFields.bufferInfoSize)); + ssize_t offset = static_cast<ssize_t>(env->GetIntField(param, gFields.bufferInfoOffset)); + ssize_t size = static_cast<ssize_t>(env->GetIntField(param, gFields.bufferInfoSize)); uint32_t flags = static_cast<uint32_t>(env->GetIntField(param, gFields.bufferInfoFlags)); - if (flags == 0 && size == 0) { - if (errorDetailMsg) { - *errorDetailMsg = "Error: Queuing an empty BufferInfo"; - } - return BAD_VALUE; - } if (i == 0) { *initialOffset = offset; - if (CC_UNLIKELY(*initialOffset < 0)) { - if (errorDetailMsg) { - *errorDetailMsg = "Error: offset/size in BufferInfo"; - } - return BAD_VALUE; - } } - if (CC_UNLIKELY(((ssize_t)(UINT32_MAX - offset) < (ssize_t)size) - || ((offset - *initialOffset) != *totalSize))) { + if (CC_UNLIKELY((offset < 0) + || (size < 0) + || ((INT32_MAX - offset) < size) + || ((offset - (*initialOffset)) != *totalSize))) { if (errorDetailMsg) { *errorDetailMsg = "Error: offset/size in BufferInfo"; } return BAD_VALUE; } + if (flags == 0 && size == 0) { + if (errorDetailMsg) { + *errorDetailMsg = "Error: Queuing an empty BufferInfo"; + } + return BAD_VALUE; + } infos->emplace_back( flags, size, diff --git a/packages/CrashRecovery/aconfig/flags.aconfig b/packages/CrashRecovery/aconfig/flags.aconfig index 563626634068..8cdef38356da 100644 --- a/packages/CrashRecovery/aconfig/flags.aconfig +++ b/packages/CrashRecovery/aconfig/flags.aconfig @@ -1,9 +1,26 @@ package: "android.crashrecovery.flags" +container: "system" flag { name: "recoverability_detection" - namespace: "package_watchdog" + namespace: "package_manager_service" description: "Feature flag for recoverability detection" bug: "310236690" is_fixed_read_only: true -}
\ No newline at end of file +} + +flag { + name: "enable_crashrecovery" + is_exported: true + namespace: "crashrecovery" + description: "Enables various dependencies of crashrecovery module" + bug: "289203818" +} + +flag { + name: "allow_rescue_party_flag_resets" + namespace: "crashrecovery" + description: "Enables rescue party flag resets" + bug: "287618292" + is_fixed_read_only: true +} diff --git a/packages/SystemUI/Android.bp b/packages/SystemUI/Android.bp index d50b596228b7..b48cac58d7ba 100644 --- a/packages/SystemUI/Android.bp +++ b/packages/SystemUI/Android.bp @@ -420,6 +420,7 @@ android_app { kotlincflags: ["-Xjvm-default=all"], optimize: { shrink_resources: false, + optimized_shrink_resources: false, proguard_flags_files: ["proguard.flags"], }, @@ -477,6 +478,7 @@ systemui_optimized_java_defaults { optimize: true, shrink: true, shrink_resources: true, + optimized_shrink_resources: true, ignore_warnings: false, proguard_compatibility: false, }, diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarterLogger.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarterLogger.kt index 4211cabcbc56..66e909c64c6c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarterLogger.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarterLogger.kt @@ -70,7 +70,7 @@ class StatusBarNotificationActivityStarterLogger @Inject constructor( fun logSendPendingIntent(entry: NotificationEntry, pendingIntent: PendingIntent, result: Int) { buffer.log(TAG, INFO, { str1 = entry.logKey - str2 = pendingIntent.intent.toString() + str2 = pendingIntent.intent?.toString() int1 = result }, { "(5/5) Started intent $str2 for notification $str1 with result code $int1" @@ -120,7 +120,7 @@ class StatusBarNotificationActivityStarterLogger @Inject constructor( fun logSendingFullScreenIntent(entry: NotificationEntry, pendingIntent: PendingIntent) { buffer.log(TAG, INFO, { str1 = entry.logKey - str2 = pendingIntent.intent.toString() + str2 = pendingIntent.intent?.toString() }, { "Notification $str1 has fullScreenIntent; sending fullScreenIntent $str2" }) diff --git a/services/core/java/com/android/server/RescueParty.java b/services/core/java/com/android/server/RescueParty.java index 271d552fc574..37c2d263d14f 100644 --- a/services/core/java/com/android/server/RescueParty.java +++ b/services/core/java/com/android/server/RescueParty.java @@ -494,10 +494,10 @@ public class RescueParty { private static void executeRescueLevelInternalOld(Context context, int level, @Nullable String failedPackage) throws Exception { - if (level <= LEVEL_RESET_SETTINGS_TRUSTED_DEFAULTS) { - // Disabling flag resets on master branch for trunk stable launch. - // TODO(b/287618292): Re-enable them after the trunk stable is launched and we - // figured out a way to reset flags without interfering with trunk development. + // Note: DeviceConfig reset is disabled currently and would be enabled using the flag, + // after we have figured out a way to reset flags without interfering with trunk + // development. TODO: b/287618292 For enabling flag resets. + if (!Flags.allowRescuePartyFlagResets() && level <= LEVEL_RESET_SETTINGS_TRUSTED_DEFAULTS) { return; } @@ -572,12 +572,16 @@ public class RescueParty { level, levelToString(level)); switch (level) { case RESCUE_LEVEL_SCOPED_DEVICE_CONFIG_RESET: - // Temporary disable deviceConfig reset - // resetDeviceConfig(context, /*isScoped=*/true, failedPackage); + // Enable deviceConfig reset behind flag + if (Flags.allowRescuePartyFlagResets()) { + resetDeviceConfig(context, /*isScoped=*/true, failedPackage); + } break; case RESCUE_LEVEL_ALL_DEVICE_CONFIG_RESET: - // Temporary disable deviceConfig reset - // resetDeviceConfig(context, /*isScoped=*/false, failedPackage); + // Enable deviceConfig reset behind flag + if (Flags.allowRescuePartyFlagResets()) { + resetDeviceConfig(context, /*isScoped=*/false, failedPackage); + } break; case RESCUE_LEVEL_WARM_REBOOT: executeWarmReboot(context, level, failedPackage); diff --git a/services/core/java/com/android/server/pm/UserManagerService.java b/services/core/java/com/android/server/pm/UserManagerService.java index 0e873963c55f..06e9daba63ea 100644 --- a/services/core/java/com/android/server/pm/UserManagerService.java +++ b/services/core/java/com/android/server/pm/UserManagerService.java @@ -1677,26 +1677,27 @@ public class UserManagerService extends IUserManager.Stub { public void setUserAdmin(@UserIdInt int userId) { checkManageUserAndAcrossUsersFullPermission("set user admin"); mUserJourneyLogger.logUserJourneyBegin(userId, USER_JOURNEY_GRANT_ADMIN); - UserInfo info; + UserData user; synchronized (mPackagesLock) { synchronized (mUsersLock) { - info = getUserInfoLU(userId); - } - if (info == null) { - // Exit if no user found with that id, - mUserJourneyLogger.logNullUserJourneyError(USER_JOURNEY_GRANT_ADMIN, + user = getUserDataLU(userId); + if (user == null) { + // Exit if no user found with that id, + mUserJourneyLogger.logNullUserJourneyError(USER_JOURNEY_GRANT_ADMIN, getCurrentUserId(), userId, /* userType */ "", /* userFlags */ -1); - return; - } else if (info.isAdmin()) { - // Exit if the user is already an Admin. - mUserJourneyLogger.logUserJourneyFinishWithError(getCurrentUserId(), info, - USER_JOURNEY_GRANT_ADMIN, ERROR_CODE_USER_ALREADY_AN_ADMIN); - return; + return; + } else if (user.info.isAdmin()) { + // Exit if the user is already an Admin. + mUserJourneyLogger.logUserJourneyFinishWithError(getCurrentUserId(), + user.info, USER_JOURNEY_GRANT_ADMIN, + ERROR_CODE_USER_ALREADY_AN_ADMIN); + return; + } + user.info.flags ^= UserInfo.FLAG_ADMIN; + writeUserLP(user); } - info.flags ^= UserInfo.FLAG_ADMIN; - writeUserLP(getUserDataLU(info.id)); } - mUserJourneyLogger.logUserJourneyFinishWithError(getCurrentUserId(), info, + mUserJourneyLogger.logUserJourneyFinishWithError(getCurrentUserId(), user.info, USER_JOURNEY_GRANT_ADMIN, ERROR_CODE_UNSPECIFIED); } diff --git a/services/tests/mockingservicestests/src/com/android/server/RescuePartyTest.java b/services/tests/mockingservicestests/src/com/android/server/RescuePartyTest.java index 697548cbe2b4..4a2164582890 100644 --- a/services/tests/mockingservicestests/src/com/android/server/RescuePartyTest.java +++ b/services/tests/mockingservicestests/src/com/android/server/RescuePartyTest.java @@ -25,6 +25,7 @@ import static com.android.dx.mockito.inline.extended.ExtendedMockito.doAnswer; import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn; import static com.android.dx.mockito.inline.extended.ExtendedMockito.verify; import static com.android.dx.mockito.inline.extended.ExtendedMockito.when; +import static com.android.server.RescueParty.DEFAULT_FACTORY_RESET_THROTTLE_DURATION_MIN; import static com.android.server.RescueParty.LEVEL_FACTORY_RESET; import static com.android.server.RescueParty.RESCUE_LEVEL_FACTORY_RESET; @@ -103,8 +104,6 @@ public class RescuePartyTest { private static final String PROP_DISABLE_FACTORY_RESET_FLAG = "persist.device_config.configuration.disable_rescue_party_factory_reset"; - private static final int THROTTLING_DURATION_MIN = 10; - @Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule(); @@ -228,6 +227,9 @@ public class RescuePartyTest { setCrashRecoveryPropRescueBootCount(0); SystemProperties.set(RescueParty.PROP_ENABLE_RESCUE, Boolean.toString(true)); SystemProperties.set(PROP_DEVICE_CONFIG_DISABLE_FLAG, Boolean.toString(false)); + + // enable flag resets for tests + mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_RESCUE_PARTY_FLAG_RESETS); } @After @@ -312,6 +314,9 @@ public class RescuePartyTest { @Test public void testPersistentAppCrashDetectionWithExecutionForAllRescueLevels() { + // this is old test where the flag needs to be disabled + mSetFlagsRule.disableFlags(Flags.FLAG_RECOVERABILITY_DETECTION); + noteAppCrash(1, true); verifySettingsResets(Settings.RESET_MODE_UNTRUSTED_DEFAULTS, /*resetNamespaces=*/ null, @@ -378,6 +383,9 @@ public class RescuePartyTest { @Test public void testNonPersistentAppOnlyPerformsFlagResets() { + // this is old test where the flag needs to be disabled + mSetFlagsRule.disableFlags(Flags.FLAG_RECOVERABILITY_DETECTION); + noteAppCrash(1, false); verifySettingsResets(Settings.RESET_MODE_UNTRUSTED_DEFAULTS, /*resetNamespaces=*/ null, @@ -628,7 +636,8 @@ public class RescuePartyTest { public void testThrottlingOnBootFailures() { setCrashRecoveryPropAttemptingReboot(false); long now = System.currentTimeMillis(); - long beforeTimeout = now - TimeUnit.MINUTES.toMillis(THROTTLING_DURATION_MIN - 1); + long beforeTimeout = now - TimeUnit.MINUTES.toMillis( + DEFAULT_FACTORY_RESET_THROTTLE_DURATION_MIN - 1); setCrashRecoveryPropLastFactoryReset(beforeTimeout); for (int i = 1; i <= LEVEL_FACTORY_RESET; i++) { noteBoot(i); @@ -641,7 +650,8 @@ public class RescuePartyTest { mSetFlagsRule.enableFlags(Flags.FLAG_RECOVERABILITY_DETECTION); setCrashRecoveryPropAttemptingReboot(false); long now = System.currentTimeMillis(); - long beforeTimeout = now - TimeUnit.MINUTES.toMillis(THROTTLING_DURATION_MIN - 1); + long beforeTimeout = now - TimeUnit.MINUTES.toMillis( + DEFAULT_FACTORY_RESET_THROTTLE_DURATION_MIN - 1); setCrashRecoveryPropLastFactoryReset(beforeTimeout); for (int i = 1; i <= RESCUE_LEVEL_FACTORY_RESET; i++) { noteBoot(i); @@ -653,7 +663,8 @@ public class RescuePartyTest { public void testThrottlingOnAppCrash() { setCrashRecoveryPropAttemptingReboot(false); long now = System.currentTimeMillis(); - long beforeTimeout = now - TimeUnit.MINUTES.toMillis(THROTTLING_DURATION_MIN - 1); + long beforeTimeout = now - TimeUnit.MINUTES.toMillis( + DEFAULT_FACTORY_RESET_THROTTLE_DURATION_MIN - 1); setCrashRecoveryPropLastFactoryReset(beforeTimeout); for (int i = 0; i <= LEVEL_FACTORY_RESET; i++) { noteAppCrash(i + 1, true); @@ -666,7 +677,8 @@ public class RescuePartyTest { mSetFlagsRule.enableFlags(Flags.FLAG_RECOVERABILITY_DETECTION); setCrashRecoveryPropAttemptingReboot(false); long now = System.currentTimeMillis(); - long beforeTimeout = now - TimeUnit.MINUTES.toMillis(THROTTLING_DURATION_MIN - 1); + long beforeTimeout = now - TimeUnit.MINUTES.toMillis( + DEFAULT_FACTORY_RESET_THROTTLE_DURATION_MIN - 1); setCrashRecoveryPropLastFactoryReset(beforeTimeout); for (int i = 0; i <= RESCUE_LEVEL_FACTORY_RESET; i++) { noteAppCrash(i + 1, true); @@ -678,7 +690,8 @@ public class RescuePartyTest { public void testNotThrottlingAfterTimeoutOnBootFailures() { setCrashRecoveryPropAttemptingReboot(false); long now = System.currentTimeMillis(); - long afterTimeout = now - TimeUnit.MINUTES.toMillis(THROTTLING_DURATION_MIN + 1); + long afterTimeout = now - TimeUnit.MINUTES.toMillis( + DEFAULT_FACTORY_RESET_THROTTLE_DURATION_MIN + 1); setCrashRecoveryPropLastFactoryReset(afterTimeout); for (int i = 1; i <= LEVEL_FACTORY_RESET; i++) { noteBoot(i); @@ -691,7 +704,8 @@ public class RescuePartyTest { mSetFlagsRule.enableFlags(Flags.FLAG_RECOVERABILITY_DETECTION); setCrashRecoveryPropAttemptingReboot(false); long now = System.currentTimeMillis(); - long afterTimeout = now - TimeUnit.MINUTES.toMillis(THROTTLING_DURATION_MIN + 1); + long afterTimeout = now - TimeUnit.MINUTES.toMillis( + DEFAULT_FACTORY_RESET_THROTTLE_DURATION_MIN + 1); setCrashRecoveryPropLastFactoryReset(afterTimeout); for (int i = 1; i <= RESCUE_LEVEL_FACTORY_RESET; i++) { noteBoot(i); @@ -703,7 +717,8 @@ public class RescuePartyTest { public void testNotThrottlingAfterTimeoutOnAppCrash() { setCrashRecoveryPropAttemptingReboot(false); long now = System.currentTimeMillis(); - long afterTimeout = now - TimeUnit.MINUTES.toMillis(THROTTLING_DURATION_MIN + 1); + long afterTimeout = now - TimeUnit.MINUTES.toMillis( + DEFAULT_FACTORY_RESET_THROTTLE_DURATION_MIN + 1); setCrashRecoveryPropLastFactoryReset(afterTimeout); for (int i = 0; i <= LEVEL_FACTORY_RESET; i++) { noteAppCrash(i + 1, true); @@ -716,7 +731,8 @@ public class RescuePartyTest { mSetFlagsRule.enableFlags(Flags.FLAG_RECOVERABILITY_DETECTION); setCrashRecoveryPropAttemptingReboot(false); long now = System.currentTimeMillis(); - long afterTimeout = now - TimeUnit.MINUTES.toMillis(THROTTLING_DURATION_MIN + 1); + long afterTimeout = now - TimeUnit.MINUTES.toMillis( + DEFAULT_FACTORY_RESET_THROTTLE_DURATION_MIN + 1); setCrashRecoveryPropLastFactoryReset(afterTimeout); for (int i = 0; i <= RESCUE_LEVEL_FACTORY_RESET; i++) { noteAppCrash(i + 1, true); @@ -794,6 +810,9 @@ public class RescuePartyTest { @Test public void testHealthCheckLevels() { + // this is old test where the flag needs to be disabled + mSetFlagsRule.disableFlags(Flags.FLAG_RECOVERABILITY_DETECTION); + RescuePartyObserver observer = RescuePartyObserver.getInstance(mMockContext); // Ensure that no action is taken for cases where the failure reason is unknown |