Loading packages/VpnDialogs/src/com/android/vpndialogs/ConfirmDialog.java +41 −34 Original line number Diff line number Diff line Loading @@ -18,8 +18,11 @@ package com.android.vpndialogs; import android.content.Context; import android.content.DialogInterface; import android.content.pm.PackageManager; import android.graphics.drawable.Drawable; import android.net.IConnectivityManager; import android.os.Bundle; import android.os.RemoteException; import android.os.ServiceManager; import android.os.UserHandle; import android.text.Html; Loading @@ -40,30 +43,22 @@ public class ConfirmDialog extends AlertActivity private IConnectivityManager mService; private Button mButton; @Override protected void onResume() { super.onResume(); try { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mPackage = getCallingPackage(); mService = IConnectivityManager.Stub.asInterface( ServiceManager.getService(Context.CONNECTIVITY_SERVICE)); if (mService.prepareVpn(mPackage, null, UserHandle.myUserId())) { if (prepareVpn()) { setResult(RESULT_OK); finish(); return; } View view = View.inflate(this, R.layout.confirm, null); ((TextView) view.findViewById(R.id.warning)).setText( Html.fromHtml( getString(R.string.warning, VpnConfig.getVpnLabel(this, mPackage)), Html.fromHtml(getString(R.string.warning, getVpnLabel()), this, null /* tagHandler */)); mAlertParams.mTitle = getText(R.string.prompt); mAlertParams.mPositiveButtonText = getText(android.R.string.ok); mAlertParams.mPositiveButtonListener = this; Loading @@ -72,11 +67,23 @@ public class ConfirmDialog extends AlertActivity setupAlert(); getWindow().setCloseOnTouchOutside(false); mButton = mAlert.getButton(DialogInterface.BUTTON_POSITIVE); mButton.setFilterTouchesWhenObscured(true); } catch (Exception e) { Log.e(TAG, "onResume", e); finish(); Button button = mAlert.getButton(DialogInterface.BUTTON_POSITIVE); button.setFilterTouchesWhenObscured(true); } private boolean prepareVpn() { try { return mService.prepareVpn(mPackage, null, UserHandle.myUserId()); } catch (RemoteException e) { throw new IllegalStateException(e); } } private CharSequence getVpnLabel() { try { return VpnConfig.getVpnLabel(this, mPackage); } catch (PackageManager.NameNotFoundException e) { throw new IllegalStateException(e); } } Loading Loading
packages/VpnDialogs/src/com/android/vpndialogs/ConfirmDialog.java +41 −34 Original line number Diff line number Diff line Loading @@ -18,8 +18,11 @@ package com.android.vpndialogs; import android.content.Context; import android.content.DialogInterface; import android.content.pm.PackageManager; import android.graphics.drawable.Drawable; import android.net.IConnectivityManager; import android.os.Bundle; import android.os.RemoteException; import android.os.ServiceManager; import android.os.UserHandle; import android.text.Html; Loading @@ -40,30 +43,22 @@ public class ConfirmDialog extends AlertActivity private IConnectivityManager mService; private Button mButton; @Override protected void onResume() { super.onResume(); try { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mPackage = getCallingPackage(); mService = IConnectivityManager.Stub.asInterface( ServiceManager.getService(Context.CONNECTIVITY_SERVICE)); if (mService.prepareVpn(mPackage, null, UserHandle.myUserId())) { if (prepareVpn()) { setResult(RESULT_OK); finish(); return; } View view = View.inflate(this, R.layout.confirm, null); ((TextView) view.findViewById(R.id.warning)).setText( Html.fromHtml( getString(R.string.warning, VpnConfig.getVpnLabel(this, mPackage)), Html.fromHtml(getString(R.string.warning, getVpnLabel()), this, null /* tagHandler */)); mAlertParams.mTitle = getText(R.string.prompt); mAlertParams.mPositiveButtonText = getText(android.R.string.ok); mAlertParams.mPositiveButtonListener = this; Loading @@ -72,11 +67,23 @@ public class ConfirmDialog extends AlertActivity setupAlert(); getWindow().setCloseOnTouchOutside(false); mButton = mAlert.getButton(DialogInterface.BUTTON_POSITIVE); mButton.setFilterTouchesWhenObscured(true); } catch (Exception e) { Log.e(TAG, "onResume", e); finish(); Button button = mAlert.getButton(DialogInterface.BUTTON_POSITIVE); button.setFilterTouchesWhenObscured(true); } private boolean prepareVpn() { try { return mService.prepareVpn(mPackage, null, UserHandle.myUserId()); } catch (RemoteException e) { throw new IllegalStateException(e); } } private CharSequence getVpnLabel() { try { return VpnConfig.getVpnLabel(this, mPackage); } catch (PackageManager.NameNotFoundException e) { throw new IllegalStateException(e); } } Loading