admin管理员组

文章数量:1388153

I’m developing a standalone timer app for Wear OS with targetSdk 35. The app has an ongoingActivity notification and a watch face complication. When the user taps the notification or the complication, it should open the app via a PendingIntent.

Everything is working correctly, but I see the following warning in the logs:

"With Android 14 BAL hardening, this activity start will be blocked if the PI sender upgrades target_sdk to 34+! (missing opt-in by PI sender)!" [callingPackage: com.example.timer; callingPackageTargetSdk: 35; callingUid: 10083; callingPid: -1; appSwitchState: 2; callingUidHasAnyVisibleWindow: false; callingUidProcState: FOREGROUND_SERVICE; isCallingUidPersistentSystemProcess: false; forcedBalByPiSender: BSP.NONE; intent: Intent { cmp=com.example.timer/.presentation.ui.MainActivity }; callerApp: null; balAllowedByPiCreator: BSP.ALLOW_BAL; balAllowedByPiCreatorWithHardening: BSP.ALLOW_BAL; resultIfPiCreatorAllowsBal: BAL_BLOCK; callerStartMode: MODE_BACKGROUND_ACTIVITY_START_SYSTEM_DEFINED; hasRealCaller: true; isCallForResult: false; isPendingIntent: true; autoOptInReason: null; realCallingPackage: com.google.android.wearable.sysui; realCallingPackageTargetSdk: 33; realCallingUid: 10020; realCallingPid: 970; realCallingUidHasAnyVisibleWindow: true; realCallingUidProcState: TOP; isRealCallingUidPersistentSystemProcess: false; originatingPendingIntent: PendingIntentRecord{6fcd2d6 com.example.timer startActivity (allowlist: 289f7e5:+30s0ms/0/NOTIFICATION_SERVICE/NotificationManagerService)}; realCallerApp: ProcessRecord{9c7f6f7 970:com.google.android.wearable.sysui/u0a20}; realInVisibleTask: true; balAllowedByPiSender: BSP.ALLOW_BAL; resultIfPiSenderAllowsBal: BAL_ALLOW_VISIBLE_WINDOW; realCallerStartMode: MODE_BACKGROUND_ACTIVITY_START_ALLOWED; balImproveRealCallerVisibilityCheck: true; balRequireOptInByPendingIntentCreator: true; balRequireOptInSameUid: false; balRespectAppSwitchStateWhenCheckBoundByForegroundUid: true; balDontBringExistingBackgroundTaskStackToFg: true]

Based on the Android background activity starts documentation, I expected that using:

val activityOptions = ActivityOptions.makeBasic().apply {
    setPendingIntentCreatorBackgroundActivityStartMode(
        ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED
    )
}

val launchActivityPendingIntent: PendingIntent = PendingIntent.getActivity(
    this,
    0,
    Intent(this, MainActivity::class.java),
    PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE,
    activityOptions.toBundle() // Attempted to resolve the warning
)

would resolve the warning, but it still appears in the logs.

Question:

  • Is this warning expected even if the PendingIntent works?
  • How can I properly opt in to avoid this warning when targeting SDK 34+? Any insights would be appreciated!

本文标签: notificationsAndroid 14 BAL Hardening Warning for PendingIntent in Wear OS (Target SDK 34)Stack Overflow