Search in sources :

Example 61 with ProxyInfo

use of android.net.ProxyInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class WifiConfigController method showProxyFields.

private void showProxyFields() {
    WifiConfiguration config = null;
    mView.findViewById(R.id.proxy_settings_fields).setVisibility(View.VISIBLE);
    if (mAccessPoint != null && mAccessPoint.isSaved()) {
        config = mAccessPoint.getConfig();
    }
    if (mProxySettingsSpinner.getSelectedItemPosition() == PROXY_STATIC) {
        setVisibility(R.id.proxy_warning_limited_support, View.VISIBLE);
        setVisibility(R.id.proxy_fields, View.VISIBLE);
        setVisibility(R.id.proxy_pac_field, View.GONE);
        if (mProxyHostView == null) {
            mProxyHostView = (TextView) mView.findViewById(R.id.proxy_hostname);
            mProxyHostView.addTextChangedListener(this);
            mProxyPortView = (TextView) mView.findViewById(R.id.proxy_port);
            mProxyPortView.addTextChangedListener(this);
            mProxyExclusionListView = (TextView) mView.findViewById(R.id.proxy_exclusionlist);
            mProxyExclusionListView.addTextChangedListener(this);
        }
        if (config != null) {
            ProxyInfo proxyProperties = config.getHttpProxy();
            if (proxyProperties != null) {
                mProxyHostView.setText(proxyProperties.getHost());
                mProxyPortView.setText(Integer.toString(proxyProperties.getPort()));
                mProxyExclusionListView.setText(proxyProperties.getExclusionListAsString());
            }
        }
    } else if (mProxySettingsSpinner.getSelectedItemPosition() == PROXY_PAC) {
        setVisibility(R.id.proxy_warning_limited_support, View.GONE);
        setVisibility(R.id.proxy_fields, View.GONE);
        setVisibility(R.id.proxy_pac_field, View.VISIBLE);
        if (mProxyPacView == null) {
            mProxyPacView = (TextView) mView.findViewById(R.id.proxy_pac);
            mProxyPacView.addTextChangedListener(this);
        }
        if (config != null) {
            ProxyInfo proxyInfo = config.getHttpProxy();
            if (proxyInfo != null) {
                mProxyPacView.setText(proxyInfo.getPacFileUrl().toString());
            }
        }
    } else {
        setVisibility(R.id.proxy_warning_limited_support, View.GONE);
        setVisibility(R.id.proxy_fields, View.GONE);
        setVisibility(R.id.proxy_pac_field, View.GONE);
    }
}
Also used : ProxyInfo(android.net.ProxyInfo) WifiConfiguration(android.net.wifi.WifiConfiguration) TextView(android.widget.TextView)

Example 62 with ProxyInfo

use of android.net.ProxyInfo in project AgentWeb by Justson.

the class WebViewProxySettings method printProxy.

/**
     * 打印系统代理设置
     *
     * @param context
     */
private static void printProxy(Context context) {
    StringBuilder sb = new StringBuilder();
    ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    ProxyInfo proxyInfo = (ProxyInfo) invokeMethod(cm, "getGlobalProxy", null);
    sb.append("\nconnectivityManager.getGlobalProxy.proxyInfo = " + proxyInfo);
    sb.append("\nProxy.getDefaultHost():Proxy.getDefaultPort() = " + Proxy.getDefaultHost() + ":" + Proxy.getDefaultPort());
    sb.append("\nSystem.getProperty(\"http.proxyHost\"):System.getProperty(\"http.proxyPort\") = " + System.getProperty("http.proxyHost") + ":" + System.getProperty("http.proxyPort"));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH && Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT_WATCH) {
        String host = (String) invokeStaticMethod("android.net.ProxyProperties", "getHost", null);
        int port = (int) invokeStaticMethod("android.net.ProxyProperties", "getPort", null);
        sb.append("\nProxyProperties.getHost():ProxyProperties.getPort() = " + host + ":" + port);
    }
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        Cursor cursor = null;
        try {
            cursor = context.getContentResolver().query(Uri.parse("content://telephony/carriers"), null, " apn = ? and current = 1", null, null);
            if (cursor != null && cursor.moveToFirst()) {
                cursor.moveToFirst();
                String apn = cursor.getString(cursor.getColumnIndex("apn"));
                String proxy = cursor.getString(cursor.getColumnIndex("proxy"));
                int port = cursor.getInt(cursor.getColumnIndex("port"));
                sb.append("\nAPN:proxy:port = " + apn + ":" + proxy + ":" + port);
            }
        } finally {
            if (cursor != null) {
                cursor.close();
            }
        }
    }
    if (DEBUG) {
        Log.d(TAG, "printProxy.proxy: " + sb);
    }
}
Also used : ProxyInfo(android.net.ProxyInfo) ConnectivityManager(android.net.ConnectivityManager) Cursor(android.database.Cursor)

Example 63 with ProxyInfo

use of android.net.ProxyInfo in project android_frameworks_base by ResurrectionRemix.

the class PacManager method sendProxyIfNeeded.

private synchronized void sendProxyIfNeeded() {
    if (!mHasDownloaded || (mLastPort == -1)) {
        return;
    }
    if (!mHasSentBroadcast) {
        sendPacBroadcast(new ProxyInfo(mPacUrl, mLastPort));
        mHasSentBroadcast = true;
    }
}
Also used : ProxyInfo(android.net.ProxyInfo)

Example 64 with ProxyInfo

use of android.net.ProxyInfo in project android_frameworks_base by crdroidandroid.

the class ConnectivityService method getProxyForNetwork.

@Override
public ProxyInfo getProxyForNetwork(Network network) {
    if (network == null)
        return getDefaultProxy();
    final ProxyInfo globalProxy = getGlobalProxy();
    if (globalProxy != null)
        return globalProxy;
    if (!NetworkUtils.queryUserAccess(Binder.getCallingUid(), network.netId))
        return null;
    // Don't call getLinkProperties() as it requires ACCESS_NETWORK_STATE permission, which
    // caller may not have.
    final NetworkAgentInfo nai = getNetworkAgentInfoForNetwork(network);
    if (nai == null)
        return null;
    synchronized (nai) {
        final ProxyInfo proxyInfo = nai.linkProperties.getHttpProxy();
        if (proxyInfo == null)
            return null;
        return new ProxyInfo(proxyInfo);
    }
}
Also used : ProxyInfo(android.net.ProxyInfo) NetworkAgentInfo(com.android.server.connectivity.NetworkAgentInfo)

Example 65 with ProxyInfo

use of android.net.ProxyInfo in project android_frameworks_base by crdroidandroid.

the class ConnectivityService method updateProxy.

// If the proxy has changed from oldLp to newLp, resend proxy broadcast with default proxy.
// This method gets called when any network changes proxy, but the broadcast only ever contains
// the default proxy (even if it hasn't changed).
// TODO: Deprecate the broadcast extras as they aren't necessarily applicable in a multi-network
// world where an app might be bound to a non-default network.
private void updateProxy(LinkProperties newLp, LinkProperties oldLp, NetworkAgentInfo nai) {
    ProxyInfo newProxyInfo = newLp == null ? null : newLp.getHttpProxy();
    ProxyInfo oldProxyInfo = oldLp == null ? null : oldLp.getHttpProxy();
    if (!proxyInfoEqual(newProxyInfo, oldProxyInfo)) {
        sendProxyBroadcast(getDefaultProxy());
    }
}
Also used : ProxyInfo(android.net.ProxyInfo)

Aggregations

ProxyInfo (android.net.ProxyInfo)66 NetworkPolicyManager.uidRulesToString (android.net.NetworkPolicyManager.uidRulesToString)15 StaticIpConfiguration (android.net.StaticIpConfiguration)11 ContentResolver (android.content.ContentResolver)10 LinkAddress (android.net.LinkAddress)10 IOException (java.io.IOException)10 InetAddress (java.net.InetAddress)10 Intent (android.content.Intent)8 PendingIntent (android.app.PendingIntent)7 ApplicationInfo (android.content.pm.ApplicationInfo)7 RemoteException (android.os.RemoteException)7 ProxySettings (android.net.IpConfiguration.ProxySettings)6 ComponentName (android.content.ComponentName)5 Context (android.content.Context)5 IPackageManager (android.content.pm.IPackageManager)5 InstrumentationInfo (android.content.pm.InstrumentationInfo)5 IpConfiguration (android.net.IpConfiguration)5 IpAssignment (android.net.IpConfiguration.IpAssignment)5 RouteInfo (android.net.RouteInfo)5 SparseArray (android.util.SparseArray)5