Loading core/java/android/window/flags/responsible_apis.aconfig +6 −1 Original line number Diff line number Diff line Loading @@ -75,4 +75,9 @@ flag { bug: "362575865" } flag { name: "bal_strict_mode_grace_period" namespace: "responsible_apis" description: "Strict mode violation triggered by grace period usage" bug: "384807495" } services/core/java/com/android/server/wm/BackgroundActivityStartController.java +15 −2 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ import static com.android.window.flags.Flags.balImprovedMetrics; import static com.android.window.flags.Flags.balRequireOptInByPendingIntentCreator; import static com.android.window.flags.Flags.balShowToastsBlocked; import static com.android.window.flags.Flags.balStrictModeRo; import static com.android.window.flags.Flags.balStrictModeGracePeriod; import static java.lang.annotation.RetentionPolicy.SOURCE; import static java.util.Objects.requireNonNull; Loading Loading @@ -1912,7 +1913,14 @@ public class BackgroundActivityStartController { (state.mOriginatingPendingIntent != null)); } logIfOnlyAllowedBy(finalVerdict, state, BAL_ALLOW_GRACE_PERIOD); if (logIfOnlyAllowedBy(finalVerdict, state, BAL_ALLOW_GRACE_PERIOD)) { if (balStrictModeRo() && balStrictModeGracePeriod()) { String abortDebugMessage = "Activity start is only allowed by grace period. " + "This may stop working in the future. " + "intent: " + state.mIntent; strictModeLaunchAborted(state.mRealCallingUid, abortDebugMessage); } } logIfOnlyAllowedBy(finalVerdict, state, BAL_ALLOW_NON_APP_VISIBLE_WINDOW); if (balImprovedMetrics()) { Loading Loading @@ -1956,24 +1964,29 @@ public class BackgroundActivityStartController { * Logs details about the activity starts if the only reason it is allowed is the provided * {@code balCode}. */ private static void logIfOnlyAllowedBy(BalVerdict finalVerdict, BalState state, int balCode) { private static boolean logIfOnlyAllowedBy(BalVerdict finalVerdict, BalState state, int balCode) { if (finalVerdict.getRawCode() == balCode) { if (state.realCallerExplicitOptInOrAutoOptIn() && state.mResultForRealCaller != null && state.mResultForRealCaller.allows() && state.mResultForRealCaller.getRawCode() != balCode) { // real caller could allow with a different exemption return false; } else if (state.callerExplicitOptInOrAutoOptIn() && state.mResultForCaller != null && state.mResultForCaller.allows() && state.mResultForCaller.getRawCode() != balCode) { // caller could allow with a different exemption return false; } else { // log to determine grace period length distribution Slog.wtf(TAG, "Activity start ONLY allowed by " + balCodeToString(balCode) + " " + finalVerdict.mMessage + ": " + state); return true; } } return false; } @VisibleForTesting Loading Loading
core/java/android/window/flags/responsible_apis.aconfig +6 −1 Original line number Diff line number Diff line Loading @@ -75,4 +75,9 @@ flag { bug: "362575865" } flag { name: "bal_strict_mode_grace_period" namespace: "responsible_apis" description: "Strict mode violation triggered by grace period usage" bug: "384807495" }
services/core/java/com/android/server/wm/BackgroundActivityStartController.java +15 −2 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ import static com.android.window.flags.Flags.balImprovedMetrics; import static com.android.window.flags.Flags.balRequireOptInByPendingIntentCreator; import static com.android.window.flags.Flags.balShowToastsBlocked; import static com.android.window.flags.Flags.balStrictModeRo; import static com.android.window.flags.Flags.balStrictModeGracePeriod; import static java.lang.annotation.RetentionPolicy.SOURCE; import static java.util.Objects.requireNonNull; Loading Loading @@ -1912,7 +1913,14 @@ public class BackgroundActivityStartController { (state.mOriginatingPendingIntent != null)); } logIfOnlyAllowedBy(finalVerdict, state, BAL_ALLOW_GRACE_PERIOD); if (logIfOnlyAllowedBy(finalVerdict, state, BAL_ALLOW_GRACE_PERIOD)) { if (balStrictModeRo() && balStrictModeGracePeriod()) { String abortDebugMessage = "Activity start is only allowed by grace period. " + "This may stop working in the future. " + "intent: " + state.mIntent; strictModeLaunchAborted(state.mRealCallingUid, abortDebugMessage); } } logIfOnlyAllowedBy(finalVerdict, state, BAL_ALLOW_NON_APP_VISIBLE_WINDOW); if (balImprovedMetrics()) { Loading Loading @@ -1956,24 +1964,29 @@ public class BackgroundActivityStartController { * Logs details about the activity starts if the only reason it is allowed is the provided * {@code balCode}. */ private static void logIfOnlyAllowedBy(BalVerdict finalVerdict, BalState state, int balCode) { private static boolean logIfOnlyAllowedBy(BalVerdict finalVerdict, BalState state, int balCode) { if (finalVerdict.getRawCode() == balCode) { if (state.realCallerExplicitOptInOrAutoOptIn() && state.mResultForRealCaller != null && state.mResultForRealCaller.allows() && state.mResultForRealCaller.getRawCode() != balCode) { // real caller could allow with a different exemption return false; } else if (state.callerExplicitOptInOrAutoOptIn() && state.mResultForCaller != null && state.mResultForCaller.allows() && state.mResultForCaller.getRawCode() != balCode) { // caller could allow with a different exemption return false; } else { // log to determine grace period length distribution Slog.wtf(TAG, "Activity start ONLY allowed by " + balCodeToString(balCode) + " " + finalVerdict.mMessage + ": " + state); return true; } } return false; } @VisibleForTesting Loading