diff options
author | Chia-chi Yeh <chiachi@android.com> | 2011-07-03 16:52:38 -0700 |
---|---|---|
committer | Chia-chi Yeh <chiachi@android.com> | 2011-07-03 17:03:27 -0700 |
commit | 100155a310fbb5028fc48e359bdfb7c4d3531843 (patch) | |
tree | 15aa54e35b879307c2272faf7ba6028113ac2a5c /packages/VpnDialogs/src/com | |
parent | 34e7813e962de99df9813014678ef5901227c5f1 (diff) | |
download | frameworks_base-100155a310fbb5028fc48e359bdfb7c4d3531843.zip frameworks_base-100155a310fbb5028fc48e359bdfb7c4d3531843.tar.gz frameworks_base-100155a310fbb5028fc48e359bdfb7c4d3531843.tar.bz2 |
VPN: convert prepare() into a form which helps solve race conditions.
When someone tries to revoke packageA, it is possible that packageA is
already revoked by packageB. In this case packageB should not be revoked,
and the new prepare() can help solve this problem.
Change-Id: Iee056a191dd99467b8ad1b5379a17b02d404bad1
Diffstat (limited to 'packages/VpnDialogs/src/com')
-rw-r--r-- | packages/VpnDialogs/src/com/android/vpndialogs/ConfirmDialog.java | 11 | ||||
-rw-r--r-- | packages/VpnDialogs/src/com/android/vpndialogs/ManageDialog.java | 2 |
2 files changed, 6 insertions, 7 deletions
diff --git a/packages/VpnDialogs/src/com/android/vpndialogs/ConfirmDialog.java b/packages/VpnDialogs/src/com/android/vpndialogs/ConfirmDialog.java index c54e719..c7b4a5f 100644 --- a/packages/VpnDialogs/src/com/android/vpndialogs/ConfirmDialog.java +++ b/packages/VpnDialogs/src/com/android/vpndialogs/ConfirmDialog.java @@ -36,7 +36,7 @@ public class ConfirmDialog extends Activity implements CompoundButton.OnCheckedC DialogInterface.OnClickListener, DialogInterface.OnDismissListener { private static final String TAG = "VpnConfirm"; - private String mPackageName; + private String mPackage; private IConnectivityManager mService; @@ -47,19 +47,19 @@ public class ConfirmDialog extends Activity implements CompoundButton.OnCheckedC protected void onResume() { super.onResume(); try { - mPackageName = getCallingPackage(); + mPackage = getCallingPackage(); mService = IConnectivityManager.Stub.asInterface( ServiceManager.getService(Context.CONNECTIVITY_SERVICE)); - if (mPackageName.equals(mService.prepareVpn(null))) { + if (mService.prepareVpn(mPackage, null)) { setResult(RESULT_OK); finish(); return; } PackageManager pm = getPackageManager(); - ApplicationInfo app = pm.getApplicationInfo(mPackageName, 0); + ApplicationInfo app = pm.getApplicationInfo(mPackage, 0); View view = View.inflate(this, R.layout.confirm, null); ((ImageView) view.findViewById(R.id.icon)).setImageDrawable(app.loadIcon(pm)); @@ -103,8 +103,7 @@ public class ConfirmDialog extends Activity implements CompoundButton.OnCheckedC @Override public void onClick(DialogInterface dialog, int which) { try { - if (which == AlertDialog.BUTTON_POSITIVE && - mPackageName.equals(mService.prepareVpn(mPackageName))) { + if (which == AlertDialog.BUTTON_POSITIVE && mService.prepareVpn(null, mPackage)) { setResult(RESULT_OK); } } catch (Exception e) { diff --git a/packages/VpnDialogs/src/com/android/vpndialogs/ManageDialog.java b/packages/VpnDialogs/src/com/android/vpndialogs/ManageDialog.java index 5559c3d..21e916b 100644 --- a/packages/VpnDialogs/src/com/android/vpndialogs/ManageDialog.java +++ b/packages/VpnDialogs/src/com/android/vpndialogs/ManageDialog.java @@ -125,7 +125,7 @@ public class ManageDialog extends Activity implements Handler.Callback, if (which == AlertDialog.BUTTON_POSITIVE) { mConfig.configureIntent.send(); } else if (which == AlertDialog.BUTTON_NEUTRAL) { - mService.prepareVpn(VpnConfig.LEGACY_VPN); + mService.prepareVpn(mConfig.packagz, VpnConfig.LEGACY_VPN); } } catch (Exception e) { Log.e(TAG, "onClick", e); |