From 36d6b7df537d86631d56193af5d2c388f2e41210 Mon Sep 17 00:00:00 2001 From: Arne Schwabe Date: Tue, 9 May 2023 10:37:18 +0200 Subject: [PATCH] fixup! Allow setting remote control apps via managed configuration Signed-off-by: Arne Schwabe --- .../main/java/de/blinkt/openvpn/api/ExternalAppDatabase.java | 2 +- main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java | 4 ++-- .../ui/java/de/blinkt/openvpn/fragments/GeneralSettings.kt | 4 ++++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/main/src/main/java/de/blinkt/openvpn/api/ExternalAppDatabase.java b/main/src/main/java/de/blinkt/openvpn/api/ExternalAppDatabase.java index 1108387db..fe0afdb6c 100644 --- a/main/src/main/java/de/blinkt/openvpn/api/ExternalAppDatabase.java +++ b/main/src/main/java/de/blinkt/openvpn/api/ExternalAppDatabase.java @@ -74,7 +74,7 @@ public void addApp(String packagename) saveExtAppList(allowedapps); } - boolean checkAllowingModifyingRemoteControl(Context c) { + public boolean checkAllowingModifyingRemoteControl(Context c) { if (isManagedConfiguration()) { Toast.makeText(c, "Remote control apps are manged by managed configuration, cannot change", Toast.LENGTH_LONG).show(); VpnStatus.logError("Remote control apps are manged by managed configuration, cannot change"); diff --git a/main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java b/main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java index f10280be2..115d63195 100644 --- a/main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java +++ b/main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java @@ -184,8 +184,8 @@ public static String humanReadableByteCount(long bytes, boolean speed, Resources @Override public void addAllowedExternalApp(String packagename) throws RemoteException { - if(checkAllowingModifyingRemoteControl(this)) { - ExternalAppDatabase extapps = new ExternalAppDatabase(OpenVPNService.this); + ExternalAppDatabase extapps = new ExternalAppDatabase(OpenVPNService.this); + if(extapps.checkAllowingModifyingRemoteControl(this)) { extapps.addApp(packagename); } } diff --git a/main/src/ui/java/de/blinkt/openvpn/fragments/GeneralSettings.kt b/main/src/ui/java/de/blinkt/openvpn/fragments/GeneralSettings.kt index 7db8cba68..3c878d4d7 100644 --- a/main/src/ui/java/de/blinkt/openvpn/fragments/GeneralSettings.kt +++ b/main/src/ui/java/de/blinkt/openvpn/fragments/GeneralSettings.kt @@ -176,6 +176,10 @@ class GeneralSettings : PreferenceFragmentCompat(), Preference.OnPreferenceClick File("/system/lib/modules/tun.ko").length() > 10 override fun onPreferenceClick(preference: Preference): Boolean { + if (!mExtapp.checkAllowingModifyingRemoteControl(requireContext())) + { + return false; + } if (preference.key == "clearapi") { val builder = AlertDialog.Builder( requireContext()