Merge "Finish ConfirmDialog when another vpn app is always-on" into nyc-dev
am: 98801e9f2b
* commit '98801e9f2bec03faf9be0c8bb961150004d309ff':
Finish ConfirmDialog when another vpn app is always-on
Change-Id: I84db62a24c34bf8dea6f99d34e108cbb0fc0517f
This commit is contained in:
@@ -20,6 +20,7 @@
|
|||||||
package="com.android.vpndialogs">
|
package="com.android.vpndialogs">
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.CONTROL_VPN" />
|
<uses-permission android:name="android.permission.CONTROL_VPN" />
|
||||||
|
<uses-permission android:name="android.permission.CONNECTIVITY_INTERNAL" />
|
||||||
|
|
||||||
<application android:label="VpnDialogs"
|
<application android:label="VpnDialogs"
|
||||||
android:allowBackup="false" >
|
android:allowBackup="false" >
|
||||||
|
|||||||
@@ -60,6 +60,12 @@ public class ConfirmDialog extends AlertActivity
|
|||||||
finish();
|
finish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
final String alwaysOnVpnPackage = getAlwaysOnVpnPackage();
|
||||||
|
// Can't prepare new vpn app when another vpn is always-on
|
||||||
|
if (alwaysOnVpnPackage != null && !alwaysOnVpnPackage.equals(mPackage)) {
|
||||||
|
finish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
View view = View.inflate(this, R.layout.confirm, null);
|
View view = View.inflate(this, R.layout.confirm, null);
|
||||||
((TextView) view.findViewById(R.id.warning)).setText(
|
((TextView) view.findViewById(R.id.warning)).setText(
|
||||||
Html.fromHtml(getString(R.string.warning, getVpnLabel()),
|
Html.fromHtml(getString(R.string.warning, getVpnLabel()),
|
||||||
@@ -76,6 +82,16 @@ public class ConfirmDialog extends AlertActivity
|
|||||||
button.setFilterTouchesWhenObscured(true);
|
button.setFilterTouchesWhenObscured(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getAlwaysOnVpnPackage() {
|
||||||
|
try {
|
||||||
|
return mService.getAlwaysOnVpnPackage(UserHandle.myUserId());
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
Log.e(TAG, "fail to call getAlwaysOnVpnPackage", e);
|
||||||
|
// Fallback to null to show the dialog
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private boolean prepareVpn() {
|
private boolean prepareVpn() {
|
||||||
try {
|
try {
|
||||||
return mService.prepareVpn(mPackage, null, UserHandle.myUserId());
|
return mService.prepareVpn(mPackage, null, UserHandle.myUserId());
|
||||||
|
|||||||
Reference in New Issue
Block a user