]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
android: Fix updating password for managed profiles
authorTobias Brunner <tobias@strongswan.org>
Fri, 31 Jan 2025 07:27:55 +0000 (08:27 +0100)
committerTobias Brunner <tobias@strongswan.org>
Tue, 18 Feb 2025 13:12:43 +0000 (14:12 +0100)
Without data source set on the profile, this caused the app to crash
with a null pointer dereference when it is updated.

src/frontends/android/app/src/main/java/org/strongswan/android/data/VpnProfileManagedDataSource.java

index 414d5bc4ef84472569822c30011afaa03c6ed3ba..a76241b4e502e76fff254fda6c200464a429b8b4 100644 (file)
@@ -98,7 +98,14 @@ public class VpnProfileManagedDataSource implements VpnProfileDataSource
        @Override
        public VpnProfile getVpnProfile(UUID uuid)
        {
-               return mManagedConfigurationService.getManagedProfiles().get(uuid.toString());
+               final VpnProfile vpnProfile = mManagedConfigurationService.getManagedProfiles().get(uuid.toString());
+               if (vpnProfile != null)
+               {
+                       final String password = mSharedPreferences.getString(uuid.toString(), vpnProfile.getPassword());
+                       vpnProfile.setPassword(password);
+                       vpnProfile.setDataSource(this);
+               }
+               return vpnProfile;
        }
 
        @Override