From 05542603dd4f1e0ea47a3dca01de3999a9a329a9 Mon Sep 17 00:00:00 2001 From: Jeff Davidson Date: Mon, 11 Aug 2014 14:07:27 -0700 Subject: Less intrusive VPN dialog and other UX tweaks. -The ability to launch VPNs is now sticky; once approved by the user, further approvals are not needed UNLESS the connection is revoked in Quick Settings. -The old persistent notification has been removed in favor of the new Quick Settings UI. -The name of the VPN app is now pulled from the label of the VPN service rather than the app itself, if one is set. Bug: 12878887 Bug: 16578022 Change-Id: I102a14c05db26ee3aef030cda971e5165f078a91 --- .../com/android/internal/net/LegacyVpnInfo.java | 3 --- core/java/com/android/internal/net/VpnConfig.java | 29 ++++++++++++++-------- 2 files changed, 19 insertions(+), 13 deletions(-) (limited to 'core/java/com') diff --git a/core/java/com/android/internal/net/LegacyVpnInfo.java b/core/java/com/android/internal/net/LegacyVpnInfo.java index d6f6d0b..f812ad6 100644 --- a/core/java/com/android/internal/net/LegacyVpnInfo.java +++ b/core/java/com/android/internal/net/LegacyVpnInfo.java @@ -40,7 +40,6 @@ public class LegacyVpnInfo implements Parcelable { public String key; public int state = -1; - public PendingIntent intent; @Override public int describeContents() { @@ -51,7 +50,6 @@ public class LegacyVpnInfo implements Parcelable { public void writeToParcel(Parcel out, int flags) { out.writeString(key); out.writeInt(state); - out.writeParcelable(intent, flags); } public static final Parcelable.Creator CREATOR = @@ -61,7 +59,6 @@ public class LegacyVpnInfo implements Parcelable { LegacyVpnInfo info = new LegacyVpnInfo(); info.key = in.readString(); info.state = in.readInt(); - info.intent = in.readParcelable(null); return info; } diff --git a/core/java/com/android/internal/net/VpnConfig.java b/core/java/com/android/internal/net/VpnConfig.java index 0099269..aa66d7d 100644 --- a/core/java/com/android/internal/net/VpnConfig.java +++ b/core/java/com/android/internal/net/VpnConfig.java @@ -20,17 +20,19 @@ import android.app.PendingIntent; import android.content.ComponentName; import android.content.Context; import android.content.Intent; +import android.content.pm.PackageManager; +import android.content.pm.PackageManager.NameNotFoundException; +import android.content.pm.ResolveInfo; import android.content.res.Resources; +import android.net.LinkAddress; +import android.net.RouteInfo; import android.os.Parcel; import android.os.Parcelable; -import android.os.UserHandle; -import android.net.RouteInfo; -import android.net.LinkAddress; import java.net.Inet4Address; import java.net.InetAddress; -import java.util.List; import java.util.ArrayList; +import java.util.List; /** * A simple container used to carry information in VpnBuilder, VpnDialogs, @@ -55,12 +57,19 @@ public class VpnConfig implements Parcelable { return intent; } - public static PendingIntent getIntentForStatusPanel(Context context) { - Intent intent = new Intent(); - intent.setClassName(DIALOGS_PACKAGE, DIALOGS_PACKAGE + ".ManageDialog"); - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_HISTORY | - Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); - return PendingIntent.getActivityAsUser(context, 0, intent, 0, null, UserHandle.CURRENT); + public static CharSequence getVpnLabel(Context context, String packageName) + throws NameNotFoundException { + PackageManager pm = context.getPackageManager(); + Intent intent = new Intent(SERVICE_INTERFACE); + intent.setPackage(packageName); + List services = pm.queryIntentServices(intent, 0 /* flags */); + if (services != null && services.size() == 1) { + // This app contains exactly one VPN service. Call loadLabel, which will attempt to + // load the service's label, and fall back to the app label if none is present. + return services.get(0).loadLabel(pm); + } else { + return pm.getApplicationInfo(packageName, 0).loadLabel(pm); + } } public String user; -- cgit v1.1