FileDocCategorySizeDatePackage
ConfirmDialog.javaAPI DocAndroid 5.1 API3823Thu Mar 12 22:22:42 GMT 2015com.android.vpndialogs

ConfirmDialog

public class ConfirmDialog extends com.android.internal.app.AlertActivity implements android.text.Html.ImageGetter, DialogInterface.OnClickListener

Fields Summary
private static final String
TAG
private String
mPackage
private android.net.IConnectivityManager
mService
private android.widget.Button
mButton
Constructors Summary
Methods Summary
public android.graphics.drawable.DrawablegetDrawable(java.lang.String source)

        // Should only reach this when fetching the VPN icon for the warning string.
        Drawable icon = getDrawable(R.drawable.ic_vpn_dialog);
        icon.setBounds(0, 0, icon.getIntrinsicWidth(), icon.getIntrinsicHeight());
        return icon;
    
public voidonBackPressed()

    
public voidonClick(android.content.DialogInterface dialog, int which)

        try {
            if (mService.prepareVpn(null, mPackage)) {
                // Authorize this app to initiate VPN connections in the future without user
                // intervention.
                mService.setVpnPackageAuthorization(true);
                setResult(RESULT_OK);
            }
        } catch (Exception e) {
            Log.e(TAG, "onClick", e);
        }
    
protected voidonResume()


    
       
        super.onResume();
        try {
            mPackage = getCallingPackage();

            mService = IConnectivityManager.Stub.asInterface(
                    ServiceManager.getService(Context.CONNECTIVITY_SERVICE));

            if (mService.prepareVpn(mPackage, null)) {
                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)),
                    this, null /* tagHandler */));

            mAlertParams.mTitle = getText(R.string.prompt);
            mAlertParams.mPositiveButtonText = getText(android.R.string.ok);
            mAlertParams.mPositiveButtonListener = this;
            mAlertParams.mNegativeButtonText = getText(android.R.string.cancel);
            mAlertParams.mView = view;
            setupAlert();

            getWindow().setCloseOnTouchOutside(false);
            mButton = mAlert.getButton(DialogInterface.BUTTON_POSITIVE);
            mButton.setFilterTouchesWhenObscured(true);
        } catch (Exception e) {
            Log.e(TAG, "onResume", e);
            finish();
        }