-
Notifications
You must be signed in to change notification settings - Fork 486
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mdm: update MDMSettings (and syspolicy) when application restrictions…
… change (#571) In this PR, we update the Android app to register a broadcast receiver that listens for android.content.Intent.ACTION_APPLICATION_RESTRICTIONS_CHANGED and updates MDMSettings whenever a change occurs. This, in turn, notifies the Go backend and causes it to reload syspolicy, ensuring it reflects the updated MDM settings. Updates tailscale/tailscale#12687 Signed-off-by: Nick Khyl <[email protected]>
- Loading branch information
Showing
2 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
android/src/main/java/com/tailscale/ipn/mdm/MDMSettingsChangedReceiver.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright (c) Tailscale Inc & AUTHORS | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
package com.tailscale.ipn.mdm | ||
|
||
import android.content.BroadcastReceiver | ||
import android.content.Context | ||
import android.content.Intent | ||
import android.content.RestrictionsManager | ||
import com.tailscale.ipn.App | ||
import com.tailscale.ipn.util.TSLog | ||
|
||
class MDMSettingsChangedReceiver : BroadcastReceiver() { | ||
override fun onReceive(context: Context?, intent: Intent?) { | ||
if (intent?.action == android.content.Intent.ACTION_APPLICATION_RESTRICTIONS_CHANGED) { | ||
TSLog.d("syspolicy", "MDM settings changed") | ||
val restrictionsManager = context?.getSystemService(Context.RESTRICTIONS_SERVICE) as RestrictionsManager | ||
MDMSettings.update(App.get(), restrictionsManager) | ||
} | ||
} | ||
} |