Skip to content

Commit 38abb03

Browse files
authored
android: specify whether or not receivers are exported (#579)
Per https://developer.android.com/about/versions/14/behavior-changes-14#runtime-receivers-exported, we need to register all receivers. Fixes tailscale/corp#25021 Signed-off-by: kari-ts <[email protected]>
1 parent f96b632 commit 38abb03

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

android/src/main/AndroidManifest.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,14 @@
9999
</intent-filter>
100100
</receiver>
101101

102+
<receiver
103+
android:name=".MDMSettingsChangedReceiver"
104+
android:exported="false">
105+
<intent-filter>
106+
<action android:name="android.intent.action.APPLICATION_RESTRICTIONS_CHANGED" />
107+
</intent-filter>
108+
</receiver>
109+
102110
<service
103111
android:name=".IPNService"
104112
android:exported="false"

android/src/main/java/com/tailscale/ipn/App.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ open class UninitializedApp : Application() {
461461

462462
// Register the receiver before stopping VPN
463463
val intentFilter = IntentFilter(IPNService.ACTION_STOP_VPN)
464-
this.registerReceiver(stopReceiver, intentFilter)
464+
this.registerReceiver(stopReceiver, intentFilter, Context.RECEIVER_NOT_EXPORTED)
465465

466466
stopVPN()
467467
}

android/src/main/java/com/tailscale/ipn/mdm/MDMSettingsChangedReceiver.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import com.tailscale.ipn.util.TSLog
1212

1313
class MDMSettingsChangedReceiver : BroadcastReceiver() {
1414
override fun onReceive(context: Context?, intent: Intent?) {
15-
if (intent?.action == android.content.Intent.ACTION_APPLICATION_RESTRICTIONS_CHANGED) {
15+
if (intent?.action == Intent.ACTION_APPLICATION_RESTRICTIONS_CHANGED) {
1616
TSLog.d("syspolicy", "MDM settings changed")
1717
val restrictionsManager = context?.getSystemService(Context.RESTRICTIONS_SERVICE) as RestrictionsManager
1818
MDMSettings.update(App.get(), restrictionsManager)

0 commit comments

Comments
 (0)