Merge "Support multiple Vpn ManageDialogs"
This commit is contained in:
committed by
Android (Google) Code Review
commit
1b6868cc4b
@@ -124,6 +124,8 @@ interface IConnectivityManager
|
||||
|
||||
ParcelFileDescriptor establishVpn(in VpnConfig config);
|
||||
|
||||
VpnConfig getVpnConfig();
|
||||
|
||||
void startLegacyVpn(in VpnProfile profile);
|
||||
|
||||
LegacyVpnInfo getLegacyVpnInfo();
|
||||
|
||||
@@ -21,6 +21,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.os.UserHandle;
|
||||
import android.net.RouteInfo;
|
||||
import android.net.LinkAddress;
|
||||
|
||||
@@ -50,15 +51,12 @@ public class VpnConfig implements Parcelable {
|
||||
return intent;
|
||||
}
|
||||
|
||||
public static PendingIntent getIntentForStatusPanel(Context context, VpnConfig config) {
|
||||
Preconditions.checkNotNull(config);
|
||||
|
||||
public static PendingIntent getIntentForStatusPanel(Context context) {
|
||||
Intent intent = new Intent();
|
||||
intent.setClassName(DIALOGS_PACKAGE, DIALOGS_PACKAGE + ".ManageDialog");
|
||||
intent.putExtra("config", config);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_HISTORY |
|
||||
Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
|
||||
return PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
|
||||
return PendingIntent.getActivityAsUser(context, 0, intent, 0, null, UserHandle.CURRENT);
|
||||
}
|
||||
|
||||
public String user;
|
||||
|
||||
@@ -65,11 +65,18 @@ public class ManageDialog extends AlertActivity implements
|
||||
}
|
||||
|
||||
try {
|
||||
mConfig = getIntent().getParcelableExtra("config");
|
||||
|
||||
mService = IConnectivityManager.Stub.asInterface(
|
||||
ServiceManager.getService(Context.CONNECTIVITY_SERVICE));
|
||||
|
||||
mConfig = mService.getVpnConfig();
|
||||
|
||||
// mConfig can be null if we are a restricted user, in that case don't show this dialog
|
||||
if (mConfig == null) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
View view = View.inflate(this, R.layout.manage, null);
|
||||
if (mConfig.session != null) {
|
||||
((TextView) view.findViewById(R.id.session)).setText(mConfig.session);
|
||||
|
||||
@@ -3446,6 +3446,20 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the information of the ongoing VPN. This method is used by VpnDialogs and
|
||||
* not available in ConnectivityManager.
|
||||
* Permissions are checked in Vpn class.
|
||||
* @hide
|
||||
*/
|
||||
@Override
|
||||
public VpnConfig getVpnConfig() {
|
||||
int user = UserHandle.getUserId(Binder.getCallingUid());
|
||||
synchronized(mVpns) {
|
||||
return mVpns.get(user).getVpnConfig();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for VPN subsystem. Currently VPN is not adapted to the service
|
||||
* through NetworkStateTracker since it works differently. For example, it
|
||||
|
||||
@@ -519,6 +519,14 @@ public class Vpn extends BaseNetworkStateTracker {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the configuration of the currently running VPN.
|
||||
*/
|
||||
public VpnConfig getVpnConfig() {
|
||||
enforceControlPermission();
|
||||
return mConfig;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public synchronized void interfaceStatusChanged(String iface, boolean up) {
|
||||
try {
|
||||
@@ -610,7 +618,7 @@ public class Vpn extends BaseNetworkStateTracker {
|
||||
|
||||
private void showNotification(String label, Bitmap icon, int user) {
|
||||
if (!mEnableNotif) return;
|
||||
mStatusIntent = VpnConfig.getIntentForStatusPanel(mContext, mConfig);
|
||||
mStatusIntent = VpnConfig.getIntentForStatusPanel(mContext);
|
||||
|
||||
NotificationManager nm = (NotificationManager)
|
||||
mContext.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
|
||||
Reference in New Issue
Block a user