Switch Settings from IConnectivityManager to VpnManager.

The VPN code is moving out of ConnectivityService to a new
VpnManagerService. Update Settings to call into the VpnManager
class instead of using the AIDL interface directly. This way,
the VPN code can be moved without touching Settings.

Bug: 173331190
Test: builds, boots
Test: manually verified VPN settings page
Change-Id: Id2731a166b5d6783acb1c711a54604b69aa8c0d7
This commit is contained in:
Lorenzo Colitti
2021-02-04 17:44:56 +09:00
parent bff5a89842
commit 04d34ced59
6 changed files with 56 additions and 108 deletions

View File

@@ -21,10 +21,9 @@ import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.DialogInterface;
import android.net.ConnectivityManager;
import android.net.IConnectivityManager;
import android.net.VpnManager;
import android.os.Bundle;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserHandle;
import android.security.Credentials;
import android.security.KeyStore;
@@ -52,9 +51,8 @@ public class ConfigDialogFragment extends InstrumentedDialogFragment implements
private static final String ARG_EDITING = "editing";
private static final String ARG_EXISTS = "exists";
private final IConnectivityManager mService = IConnectivityManager.Stub.asInterface(
ServiceManager.getService(Context.CONNECTIVITY_SERVICE));
private Context mContext;
private VpnManager mService;
@Override
@@ -80,6 +78,7 @@ public class ConfigDialogFragment extends InstrumentedDialogFragment implements
public void onAttach(final Context context) {
super.onAttach(context);
mContext = context;
mService = context.getSystemService(VpnManager.class);
}
@Override
@@ -212,8 +211,6 @@ public class ConfigDialogFragment extends InstrumentedDialogFragment implements
mService.startLegacyVpn(profile);
} catch (IllegalStateException e) {
Toast.makeText(mContext, R.string.vpn_no_network, Toast.LENGTH_LONG).show();
} catch (RemoteException e) {
Log.e(TAG, "Failed to connect", e);
}
}
}