diff options
author | Chia-chi Yeh <chiachi@android.com> | 2011-06-30 23:52:29 -0700 |
---|---|---|
committer | Chia-chi Yeh <chiachi@android.com> | 2011-07-01 00:10:32 -0700 |
commit | 5db03df1fff4900eb485304d4fd185110bea1a0c (patch) | |
tree | a533a708b80a7a714254cf2ebf54371a05a51f92 /packages/VpnDialogs/src | |
parent | 2e46061cd2ff93e04461fdae4198c1d40d660e08 (diff) | |
download | frameworks_base-5db03df1fff4900eb485304d4fd185110bea1a0c.zip frameworks_base-5db03df1fff4900eb485304d4fd185110bea1a0c.tar.gz frameworks_base-5db03df1fff4900eb485304d4fd185110bea1a0c.tar.bz2 |
VpnDialogs: prepare for the usages of legacy VPN.
- Use PendingIntent to start activities.
- Handle configs without package names.
- Switch to system UID.
Change-Id: Ia78112a97e3628b603d9e059705e32694ebe142b
Diffstat (limited to 'packages/VpnDialogs/src')
-rw-r--r-- | packages/VpnDialogs/src/com/android/vpndialogs/ManageDialog.java | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/packages/VpnDialogs/src/com/android/vpndialogs/ManageDialog.java b/packages/VpnDialogs/src/com/android/vpndialogs/ManageDialog.java index ba3f344..c076ba0 100644 --- a/packages/VpnDialogs/src/com/android/vpndialogs/ManageDialog.java +++ b/packages/VpnDialogs/src/com/android/vpndialogs/ManageDialog.java @@ -64,9 +64,6 @@ public class ManageDialog extends Activity implements Handler.Callback, mService = IConnectivityManager.Stub.asInterface( ServiceManager.getService(Context.CONNECTIVITY_SERVICE)); - PackageManager pm = getPackageManager(); - ApplicationInfo app = pm.getApplicationInfo(mConfig.packageName, 0); - View view = View.inflate(this, R.layout.manage, null); if (mConfig.sessionName != null) { ((TextView) view.findViewById(R.id.session)).setText(mConfig.sessionName); @@ -75,15 +72,29 @@ public class ManageDialog extends Activity implements Handler.Callback, mDataTransmitted = (TextView) view.findViewById(R.id.data_transmitted); mDataReceived = (TextView) view.findViewById(R.id.data_received); - mDialog = new AlertDialog.Builder(this) - .setIcon(app.loadIcon(pm)) - .setTitle(app.loadLabel(pm)) - .setView(view) - .setNeutralButton(R.string.disconnect, this) - .setNegativeButton(android.R.string.cancel, this) - .create(); + if (mConfig.packageName == null) { + // Legacy VPN does not have a package name. + mDialog = new AlertDialog.Builder(this) + .setIcon(android.R.drawable.ic_dialog_info) + .setTitle(R.string.legacy_title) + .setView(view) + .setNeutralButton(R.string.disconnect, this) + .setNegativeButton(android.R.string.cancel, this) + .create(); + } else { + PackageManager pm = getPackageManager(); + ApplicationInfo app = pm.getApplicationInfo(mConfig.packageName, 0); + + mDialog = new AlertDialog.Builder(this) + .setIcon(app.loadIcon(pm)) + .setTitle(app.loadLabel(pm)) + .setView(view) + .setNeutralButton(R.string.disconnect, this) + .setNegativeButton(android.R.string.cancel, this) + .create(); + } - if (mConfig.configureActivity != null) { + if (mConfig.configureIntent != null) { mDialog.setButton(DialogInterface.BUTTON_POSITIVE, getText(R.string.configure), this); } @@ -113,9 +124,7 @@ public class ManageDialog extends Activity implements Handler.Callback, public void onClick(DialogInterface dialog, int which) { try { if (which == AlertDialog.BUTTON_POSITIVE) { - Intent intent = new Intent(); - intent.setClassName(mConfig.packageName, mConfig.configureActivity); - startActivity(intent); + mConfig.configureIntent.send(); } else if (which == AlertDialog.BUTTON_NEUTRAL) { mService.prepareVpn(""); } |