Search in sources :

Example 16 with ProxyProperties

use of android.net.ProxyProperties in project XobotOS by xamarin.

the class ActivityThread method handleBindApplication.

private void handleBindApplication(AppBindData data) {
    mBoundApplication = data;
    mConfiguration = new Configuration(data.config);
    mCompatConfiguration = new Configuration(data.config);
    mProfiler = new Profiler();
    mProfiler.profileFile = data.initProfileFile;
    mProfiler.profileFd = data.initProfileFd;
    mProfiler.autoStopProfiler = data.initAutoStopProfiler;
    // send up app name; do this *before* waiting for debugger
    Process.setArgV0(data.processName);
    android.ddm.DdmHandleAppName.setAppName(data.processName);
    if (data.persistent) {
        // Persistent processes on low-memory devices do not get to
        // use hardware accelerated drawing, since this can add too much
        // overhead to the process.
        Display display = WindowManagerImpl.getDefault().getDefaultDisplay();
        if (!ActivityManager.isHighEndGfx(display)) {
            HardwareRenderer.disable(false);
        }
    }
    if (mProfiler.profileFd != null) {
        mProfiler.startProfiling();
    }
    // main thread so the main looper is set right.
    if (data.appInfo.targetSdkVersion <= 12) {
        AsyncTask.setDefaultExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    }
    /*
         * Before spawning a new process, reset the time zone to be the system time zone.
         * This needs to be done because the system time zone could have changed after the
         * the spawning of this process. Without doing this this process would have the incorrect
         * system time zone.
         */
    TimeZone.setDefault(null);
    /*
         * Initialize the default locale in this process for the reasons we set the time zone.
         */
    Locale.setDefault(data.config.locale);
    /*
         * Update the system configuration since its preloaded and might not
         * reflect configuration changes. The configuration object passed
         * in AppBindData can be safely assumed to be up to date
         */
    applyConfigurationToResourcesLocked(data.config, data.compatInfo);
    applyCompatConfiguration();
    data.info = getPackageInfoNoCheck(data.appInfo, data.compatInfo);
    /**
         * For system applications on userdebug/eng builds, log stack
         * traces of disk and network access to dropbox for analysis.
         */
    if ((data.appInfo.flags & (ApplicationInfo.FLAG_SYSTEM | ApplicationInfo.FLAG_UPDATED_SYSTEM_APP)) != 0) {
        StrictMode.conditionallyEnableDebugLogging();
    }
    /**
         * For apps targetting SDK Honeycomb or later, we don't allow
         * network usage on the main event loop / UI thread.
         *
         * Note to those grepping:  this is what ultimately throws
         * NetworkOnMainThreadException ...
         */
    if (data.appInfo.targetSdkVersion > 9) {
        StrictMode.enableDeathOnNetwork();
    }
    /**
         * Switch this process to density compatibility mode if needed.
         */
    if ((data.appInfo.flags & ApplicationInfo.FLAG_SUPPORTS_SCREEN_DENSITIES) == 0) {
        Bitmap.setDefaultDensity(DisplayMetrics.DENSITY_DEFAULT);
    }
    if (data.debugMode != IApplicationThread.DEBUG_OFF) {
        // XXX should have option to change the port.
        Debug.changeDebugPort(8100);
        if (data.debugMode == IApplicationThread.DEBUG_WAIT) {
            Slog.w(TAG, "Application " + data.info.getPackageName() + " is waiting for the debugger on port 8100...");
            IActivityManager mgr = ActivityManagerNative.getDefault();
            try {
                mgr.showWaitingForDebugger(mAppThread, true);
            } catch (RemoteException ex) {
            }
            Debug.waitForDebugger();
            try {
                mgr.showWaitingForDebugger(mAppThread, false);
            } catch (RemoteException ex) {
            }
        } else {
            Slog.w(TAG, "Application " + data.info.getPackageName() + " can be debugged on port 8100...");
        }
    }
    /**
         * Initialize the default http proxy in this process for the reasons we set the time zone.
         */
    IBinder b = ServiceManager.getService(Context.CONNECTIVITY_SERVICE);
    IConnectivityManager service = IConnectivityManager.Stub.asInterface(b);
    try {
        ProxyProperties proxyProperties = service.getProxy();
        Proxy.setHttpProxySystemProperty(proxyProperties);
    } catch (RemoteException e) {
    }
    if (data.instrumentationName != null) {
        ContextImpl appContext = new ContextImpl();
        appContext.init(data.info, null, this);
        InstrumentationInfo ii = null;
        try {
            ii = appContext.getPackageManager().getInstrumentationInfo(data.instrumentationName, 0);
        } catch (PackageManager.NameNotFoundException e) {
        }
        if (ii == null) {
            throw new RuntimeException("Unable to find instrumentation info for: " + data.instrumentationName);
        }
        mInstrumentationAppDir = ii.sourceDir;
        mInstrumentationAppPackage = ii.packageName;
        mInstrumentedAppDir = data.info.getAppDir();
        ApplicationInfo instrApp = new ApplicationInfo();
        instrApp.packageName = ii.packageName;
        instrApp.sourceDir = ii.sourceDir;
        instrApp.publicSourceDir = ii.publicSourceDir;
        instrApp.dataDir = ii.dataDir;
        instrApp.nativeLibraryDir = ii.nativeLibraryDir;
        LoadedApk pi = getPackageInfo(instrApp, data.compatInfo, appContext.getClassLoader(), false, true);
        ContextImpl instrContext = new ContextImpl();
        instrContext.init(pi, null, this);
        try {
            java.lang.ClassLoader cl = instrContext.getClassLoader();
            mInstrumentation = (Instrumentation) cl.loadClass(data.instrumentationName.getClassName()).newInstance();
        } catch (Exception e) {
            throw new RuntimeException("Unable to instantiate instrumentation " + data.instrumentationName + ": " + e.toString(), e);
        }
        mInstrumentation.init(this, instrContext, appContext, new ComponentName(ii.packageName, ii.name), data.instrumentationWatcher);
        if (mProfiler.profileFile != null && !ii.handleProfiling && mProfiler.profileFd == null) {
            mProfiler.handlingProfiling = true;
            File file = new File(mProfiler.profileFile);
            file.getParentFile().mkdirs();
            Debug.startMethodTracing(file.toString(), 8 * 1024 * 1024);
        }
        try {
            mInstrumentation.onCreate(data.instrumentationArgs);
        } catch (Exception e) {
            throw new RuntimeException("Exception thrown in onCreate() of " + data.instrumentationName + ": " + e.toString(), e);
        }
    } else {
        mInstrumentation = new Instrumentation();
    }
    if ((data.appInfo.flags & ApplicationInfo.FLAG_LARGE_HEAP) != 0) {
        dalvik.system.VMRuntime.getRuntime().clearGrowthLimit();
    }
    // If the app is being launched for full backup or restore, bring it up in
    // a restricted environment with the base application class.
    Application app = data.info.makeApplication(data.restrictedBackupMode, null);
    mInitialApplication = app;
    // app's custom Application class
    if (!data.restrictedBackupMode) {
        List<ProviderInfo> providers = data.providers;
        if (providers != null) {
            installContentProviders(app, providers);
            // For process that contains content providers, we want to
            // ensure that the JIT is enabled "at some point".
            mH.sendEmptyMessageDelayed(H.ENABLE_JIT, 10 * 1000);
        }
    }
    try {
        mInstrumentation.callApplicationOnCreate(app);
    } catch (Exception e) {
        if (!mInstrumentation.onException(app, e)) {
            throw new RuntimeException("Unable to create application " + app.getClass().getName() + ": " + e.toString(), e);
        }
    }
}
Also used : ProxyProperties(android.net.ProxyProperties) Configuration(android.content.res.Configuration) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) ApplicationInfo(android.content.pm.ApplicationInfo) AndroidRuntimeException(android.util.AndroidRuntimeException) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) RemoteException(android.os.RemoteException) IOException(java.io.IOException) IBinder(android.os.IBinder) AndroidRuntimeException(android.util.AndroidRuntimeException) PackageManager(android.content.pm.PackageManager) IPackageManager(android.content.pm.IPackageManager) ProviderInfo(android.content.pm.ProviderInfo) InstrumentationInfo(android.content.pm.InstrumentationInfo) IConnectivityManager(android.net.IConnectivityManager) ComponentName(android.content.ComponentName) RemoteException(android.os.RemoteException) File(java.io.File) Display(android.view.Display)

Example 17 with ProxyProperties

use of android.net.ProxyProperties in project XobotOS by xamarin.

the class GsmDataConnectionTracker method onDataSetupComplete.

@Override
protected void onDataSetupComplete(AsyncResult ar) {
    ApnContext apnContext = null;
    if (ar.userObj instanceof ApnContext) {
        apnContext = (ApnContext) ar.userObj;
    } else {
        throw new RuntimeException("onDataSetupComplete: No apnContext");
    }
    if (isDataSetupCompleteOk(ar)) {
        DataConnectionAc dcac = apnContext.getDataConnectionAc();
        if (dcac == null) {
            throw new RuntimeException("onDataSetupCompete: No dcac");
        }
        DataConnection dc = apnContext.getDataConnection();
        if (DBG) {
            log(String.format("onDataSetupComplete: success apn=%s", apnContext.getWaitingApns().get(0).apn));
        }
        ApnSetting apn = apnContext.getApnSetting();
        if (apn.proxy != null && apn.proxy.length() != 0) {
            try {
                String port = apn.port;
                if (TextUtils.isEmpty(port))
                    port = "8080";
                ProxyProperties proxy = new ProxyProperties(apn.proxy, Integer.parseInt(port), null);
                dcac.setLinkPropertiesHttpProxySync(proxy);
            } catch (NumberFormatException e) {
                loge("onDataSetupComplete: NumberFormatException making ProxyProperties (" + apn.port + "): " + e);
            }
        }
        // everything is setup
        if (TextUtils.equals(apnContext.getApnType(), Phone.APN_TYPE_DEFAULT)) {
            SystemProperties.set("gsm.defaultpdpcontext.active", "true");
            if (canSetPreferApn && mPreferredApn == null) {
                if (DBG)
                    log("onDataSetupComplete: PREFERED APN is null");
                mPreferredApn = apnContext.getApnSetting();
                if (mPreferredApn != null) {
                    setPreferredApn(mPreferredApn.id);
                }
            }
        } else {
            SystemProperties.set("gsm.defaultpdpcontext.active", "false");
        }
        notifyDefaultData(apnContext);
    } else {
        String apnString;
        DataConnection.FailCause cause;
        cause = (DataConnection.FailCause) (ar.result);
        if (DBG) {
            try {
                apnString = apnContext.getWaitingApns().get(0).apn;
            } catch (Exception e) {
                apnString = "<unknown>";
            }
            log(String.format("onDataSetupComplete: error apn=%s cause=%s", apnString, cause));
        }
        if (cause.isEventLoggable()) {
            // Log this failure to the Event Logs.
            int cid = getCellLocationId();
            EventLog.writeEvent(EventLogTags.PDP_SETUP_FAIL, cause.ordinal(), cid, TelephonyManager.getDefault().getNetworkType());
        }
        // Count permanent failures and remove the APN we just tried
        if (cause.isPermanentFail())
            apnContext.decWaitingApnsPermFailCount();
        apnContext.removeNextWaitingApn();
        if (DBG) {
            log(String.format("onDataSetupComplete: WaitingApns.size=%d" + " WaitingApnsPermFailureCountDown=%d", apnContext.getWaitingApns().size(), apnContext.getWaitingApnsPermFailCount()));
        }
        // See if there are more APN's to try
        if (apnContext.getWaitingApns().isEmpty()) {
            if (apnContext.getWaitingApnsPermFailCount() == 0) {
                if (DBG) {
                    log("onDataSetupComplete: All APN's had permanent failures, stop retrying");
                }
                apnContext.setState(State.FAILED);
                mPhone.notifyDataConnection(Phone.REASON_APN_FAILED, apnContext.getApnType());
                apnContext.setDataConnection(null);
                apnContext.setDataConnectionAc(null);
                if (DBG) {
                    log("onDataSetupComplete: permanent error apn=%s" + apnString);
                }
            } else {
                if (DBG)
                    log("onDataSetupComplete: Not all permanent failures, retry");
                // check to see if retry should be overridden for this failure.
                int retryOverride = -1;
                if (ar.exception instanceof DataConnection.CallSetupException) {
                    retryOverride = ((DataConnection.CallSetupException) ar.exception).getRetryOverride();
                }
                if (retryOverride == RILConstants.MAX_INT) {
                    if (DBG)
                        log("No retry is suggested.");
                } else {
                    startDelayedRetry(cause, apnContext, retryOverride);
                }
            }
        } else {
            if (DBG)
                log("onDataSetupComplete: Try next APN");
            apnContext.setState(State.SCANNING);
            // Wait a bit before trying the next APN, so that
            // we're not tying up the RIL command channel
            startAlarmForReconnect(APN_DELAY_MILLIS, apnContext);
        }
    }
}
Also used : ProxyProperties(android.net.ProxyProperties) DataConnection(com.android.internal.telephony.DataConnection) ApnContext(com.android.internal.telephony.ApnContext) DataConnectionAc(com.android.internal.telephony.DataConnectionAc) FailCause(com.android.internal.telephony.DataConnection.FailCause) ApnSetting(com.android.internal.telephony.ApnSetting)

Example 18 with ProxyProperties

use of android.net.ProxyProperties in project XobotOS by xamarin.

the class WifiConfigStore method readIpAndProxyConfigurations.

private static void readIpAndProxyConfigurations() {
    DataInputStream in = null;
    try {
        in = new DataInputStream(new BufferedInputStream(new FileInputStream(ipConfigFile)));
        int version = in.readInt();
        if (version != 2 && version != 1) {
            loge("Bad version on IP configuration file, ignore read");
            return;
        }
        while (true) {
            int id = -1;
            IpAssignment ipAssignment = IpAssignment.UNASSIGNED;
            ProxySettings proxySettings = ProxySettings.UNASSIGNED;
            LinkProperties linkProperties = new LinkProperties();
            String proxyHost = null;
            int proxyPort = -1;
            String exclusionList = null;
            String key;
            do {
                key = in.readUTF();
                try {
                    if (key.equals(ID_KEY)) {
                        id = in.readInt();
                    } else if (key.equals(IP_ASSIGNMENT_KEY)) {
                        ipAssignment = IpAssignment.valueOf(in.readUTF());
                    } else if (key.equals(LINK_ADDRESS_KEY)) {
                        LinkAddress linkAddr = new LinkAddress(NetworkUtils.numericToInetAddress(in.readUTF()), in.readInt());
                        linkProperties.addLinkAddress(linkAddr);
                    } else if (key.equals(GATEWAY_KEY)) {
                        LinkAddress dest = null;
                        InetAddress gateway = null;
                        if (version == 1) {
                            // only supported default gateways - leave the dest/prefix empty
                            gateway = NetworkUtils.numericToInetAddress(in.readUTF());
                        } else {
                            if (in.readInt() == 1) {
                                dest = new LinkAddress(NetworkUtils.numericToInetAddress(in.readUTF()), in.readInt());
                            }
                            if (in.readInt() == 1) {
                                gateway = NetworkUtils.numericToInetAddress(in.readUTF());
                            }
                        }
                        linkProperties.addRoute(new RouteInfo(dest, gateway));
                    } else if (key.equals(DNS_KEY)) {
                        linkProperties.addDns(NetworkUtils.numericToInetAddress(in.readUTF()));
                    } else if (key.equals(PROXY_SETTINGS_KEY)) {
                        proxySettings = ProxySettings.valueOf(in.readUTF());
                    } else if (key.equals(PROXY_HOST_KEY)) {
                        proxyHost = in.readUTF();
                    } else if (key.equals(PROXY_PORT_KEY)) {
                        proxyPort = in.readInt();
                    } else if (key.equals(EXCLUSION_LIST_KEY)) {
                        exclusionList = in.readUTF();
                    } else if (key.equals(EOS)) {
                        break;
                    } else {
                        loge("Ignore unknown key " + key + "while reading");
                    }
                } catch (IllegalArgumentException e) {
                    loge("Ignore invalid address while reading" + e);
                }
            } while (true);
            if (id != -1) {
                synchronized (sConfiguredNetworks) {
                    WifiConfiguration config = sConfiguredNetworks.get(sNetworkIds.get(id));
                    if (config == null) {
                        loge("configuration found for missing network, ignored");
                    } else {
                        config.linkProperties = linkProperties;
                        switch(ipAssignment) {
                            case STATIC:
                            case DHCP:
                                config.ipAssignment = ipAssignment;
                                break;
                            case UNASSIGNED:
                                //Ignore
                                break;
                            default:
                                loge("Ignore invalid ip assignment while reading");
                                break;
                        }
                        switch(proxySettings) {
                            case STATIC:
                                config.proxySettings = proxySettings;
                                ProxyProperties proxyProperties = new ProxyProperties(proxyHost, proxyPort, exclusionList);
                                linkProperties.setHttpProxy(proxyProperties);
                                break;
                            case NONE:
                                config.proxySettings = proxySettings;
                                break;
                            case UNASSIGNED:
                                //Ignore
                                break;
                            default:
                                loge("Ignore invalid proxy settings while reading");
                                break;
                        }
                    }
                }
            } else {
                loge("Missing id while parsing configuration");
            }
        }
    } catch (EOFException ignore) {
    } catch (IOException e) {
        loge("Error parsing configuration" + e);
    } finally {
        if (in != null) {
            try {
                in.close();
            } catch (Exception e) {
            }
        }
    }
}
Also used : LinkAddress(android.net.LinkAddress) ProxyProperties(android.net.ProxyProperties) IpAssignment(android.net.wifi.WifiConfiguration.IpAssignment) ProxySettings(android.net.wifi.WifiConfiguration.ProxySettings) IOException(java.io.IOException) DataInputStream(java.io.DataInputStream) LinkProperties(android.net.LinkProperties) FileInputStream(java.io.FileInputStream) IOException(java.io.IOException) EOFException(java.io.EOFException) UnknownHostException(java.net.UnknownHostException) BufferedInputStream(java.io.BufferedInputStream) EOFException(java.io.EOFException) RouteInfo(android.net.RouteInfo) InetAddress(java.net.InetAddress)

Example 19 with ProxyProperties

use of android.net.ProxyProperties in project XobotOS by xamarin.

the class WifiConfigStore method writeIpAndProxyConfigurationsOnChange.

/* Compare current and new configuration and write to file on change */
private static NetworkUpdateResult writeIpAndProxyConfigurationsOnChange(WifiConfiguration currentConfig, WifiConfiguration newConfig) {
    boolean ipChanged = false;
    boolean proxyChanged = false;
    LinkProperties linkProperties = new LinkProperties();
    switch(newConfig.ipAssignment) {
        case STATIC:
            Collection<LinkAddress> currentLinkAddresses = currentConfig.linkProperties.getLinkAddresses();
            Collection<LinkAddress> newLinkAddresses = newConfig.linkProperties.getLinkAddresses();
            Collection<InetAddress> currentDnses = currentConfig.linkProperties.getDnses();
            Collection<InetAddress> newDnses = newConfig.linkProperties.getDnses();
            Collection<RouteInfo> currentRoutes = currentConfig.linkProperties.getRoutes();
            Collection<RouteInfo> newRoutes = newConfig.linkProperties.getRoutes();
            boolean linkAddressesDiffer = (currentLinkAddresses.size() != newLinkAddresses.size()) || !currentLinkAddresses.containsAll(newLinkAddresses);
            boolean dnsesDiffer = (currentDnses.size() != newDnses.size()) || !currentDnses.containsAll(newDnses);
            boolean routesDiffer = (currentRoutes.size() != newRoutes.size()) || !currentRoutes.containsAll(newRoutes);
            if ((currentConfig.ipAssignment != newConfig.ipAssignment) || linkAddressesDiffer || dnsesDiffer || routesDiffer) {
                ipChanged = true;
            }
            break;
        case DHCP:
            if (currentConfig.ipAssignment != newConfig.ipAssignment) {
                ipChanged = true;
            }
            break;
        case UNASSIGNED:
            /* Ignore */
            break;
        default:
            loge("Ignore invalid ip assignment during write");
            break;
    }
    switch(newConfig.proxySettings) {
        case STATIC:
            ProxyProperties newHttpProxy = newConfig.linkProperties.getHttpProxy();
            ProxyProperties currentHttpProxy = currentConfig.linkProperties.getHttpProxy();
            if (newHttpProxy != null) {
                proxyChanged = !newHttpProxy.equals(currentHttpProxy);
            } else {
                proxyChanged = (currentHttpProxy != null);
            }
            break;
        case NONE:
            if (currentConfig.proxySettings != newConfig.proxySettings) {
                proxyChanged = true;
            }
            break;
        case UNASSIGNED:
            /* Ignore */
            break;
        default:
            loge("Ignore invalid proxy configuration during write");
            break;
    }
    if (!ipChanged) {
        addIpSettingsFromConfig(linkProperties, currentConfig);
    } else {
        currentConfig.ipAssignment = newConfig.ipAssignment;
        addIpSettingsFromConfig(linkProperties, newConfig);
        log("IP config changed SSID = " + currentConfig.SSID + " linkProperties: " + linkProperties.toString());
    }
    if (!proxyChanged) {
        linkProperties.setHttpProxy(currentConfig.linkProperties.getHttpProxy());
    } else {
        currentConfig.proxySettings = newConfig.proxySettings;
        linkProperties.setHttpProxy(newConfig.linkProperties.getHttpProxy());
        log("proxy changed SSID = " + currentConfig.SSID);
        if (linkProperties.getHttpProxy() != null) {
            log(" proxyProperties: " + linkProperties.getHttpProxy().toString());
        }
    }
    if (ipChanged || proxyChanged) {
        currentConfig.linkProperties = linkProperties;
        writeIpAndProxyConfigurations();
        sendConfiguredNetworksChangedBroadcast();
    }
    return new NetworkUpdateResult(ipChanged, proxyChanged);
}
Also used : LinkAddress(android.net.LinkAddress) ProxyProperties(android.net.ProxyProperties) NetworkUpdateResult(android.net.wifi.NetworkUpdateResult) RouteInfo(android.net.RouteInfo) LinkProperties(android.net.LinkProperties) InetAddress(java.net.InetAddress)

Example 20 with ProxyProperties

use of android.net.ProxyProperties in project XobotOS by xamarin.

the class WifiConfigStore method writeIpAndProxyConfigurations.

private static void writeIpAndProxyConfigurations() {
    DataOutputStream out = null;
    try {
        out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(ipConfigFile)));
        out.writeInt(IPCONFIG_FILE_VERSION);
        synchronized (sConfiguredNetworks) {
            for (WifiConfiguration config : sConfiguredNetworks.values()) {
                boolean writeToFile = false;
                try {
                    LinkProperties linkProperties = config.linkProperties;
                    switch(config.ipAssignment) {
                        case STATIC:
                            out.writeUTF(IP_ASSIGNMENT_KEY);
                            out.writeUTF(config.ipAssignment.toString());
                            for (LinkAddress linkAddr : linkProperties.getLinkAddresses()) {
                                out.writeUTF(LINK_ADDRESS_KEY);
                                out.writeUTF(linkAddr.getAddress().getHostAddress());
                                out.writeInt(linkAddr.getNetworkPrefixLength());
                            }
                            for (RouteInfo route : linkProperties.getRoutes()) {
                                out.writeUTF(GATEWAY_KEY);
                                LinkAddress dest = route.getDestination();
                                if (dest != null) {
                                    out.writeInt(1);
                                    out.writeUTF(dest.getAddress().getHostAddress());
                                    out.writeInt(dest.getNetworkPrefixLength());
                                } else {
                                    out.writeInt(0);
                                }
                                if (route.getGateway() != null) {
                                    out.writeInt(1);
                                    out.writeUTF(route.getGateway().getHostAddress());
                                } else {
                                    out.writeInt(0);
                                }
                            }
                            for (InetAddress inetAddr : linkProperties.getDnses()) {
                                out.writeUTF(DNS_KEY);
                                out.writeUTF(inetAddr.getHostAddress());
                            }
                            writeToFile = true;
                            break;
                        case DHCP:
                            out.writeUTF(IP_ASSIGNMENT_KEY);
                            out.writeUTF(config.ipAssignment.toString());
                            writeToFile = true;
                            break;
                        case UNASSIGNED:
                            /* Ignore */
                            break;
                        default:
                            loge("Ignore invalid ip assignment while writing");
                            break;
                    }
                    switch(config.proxySettings) {
                        case STATIC:
                            ProxyProperties proxyProperties = linkProperties.getHttpProxy();
                            String exclusionList = proxyProperties.getExclusionList();
                            out.writeUTF(PROXY_SETTINGS_KEY);
                            out.writeUTF(config.proxySettings.toString());
                            out.writeUTF(PROXY_HOST_KEY);
                            out.writeUTF(proxyProperties.getHost());
                            out.writeUTF(PROXY_PORT_KEY);
                            out.writeInt(proxyProperties.getPort());
                            out.writeUTF(EXCLUSION_LIST_KEY);
                            out.writeUTF(exclusionList);
                            writeToFile = true;
                            break;
                        case NONE:
                            out.writeUTF(PROXY_SETTINGS_KEY);
                            out.writeUTF(config.proxySettings.toString());
                            writeToFile = true;
                            break;
                        case UNASSIGNED:
                            /* Ignore */
                            break;
                        default:
                            loge("Ignore invalid proxy settings while writing");
                            break;
                    }
                    if (writeToFile) {
                        out.writeUTF(ID_KEY);
                        out.writeInt(configKey(config));
                    }
                } catch (NullPointerException e) {
                    loge("Failure in writing " + config.linkProperties + e);
                }
                out.writeUTF(EOS);
            }
        }
    } catch (IOException e) {
        loge("Error writing data file");
    } finally {
        if (out != null) {
            try {
                out.close();
            } catch (Exception e) {
            }
        }
    }
}
Also used : LinkAddress(android.net.LinkAddress) ProxyProperties(android.net.ProxyProperties) DataOutputStream(java.io.DataOutputStream) IOException(java.io.IOException) LinkProperties(android.net.LinkProperties) IOException(java.io.IOException) EOFException(java.io.EOFException) UnknownHostException(java.net.UnknownHostException) FileOutputStream(java.io.FileOutputStream) RouteInfo(android.net.RouteInfo) BufferedOutputStream(java.io.BufferedOutputStream) InetAddress(java.net.InetAddress)

Aggregations

ProxyProperties (android.net.ProxyProperties)20 LinkAddress (android.net.LinkAddress)5 LinkProperties (android.net.LinkProperties)5 RouteInfo (android.net.RouteInfo)5 IOException (java.io.IOException)5 InetAddress (java.net.InetAddress)5 RemoteException (android.os.RemoteException)4 PendingIntent (android.app.PendingIntent)3 Intent (android.content.Intent)3 EOFException (java.io.EOFException)3 UnknownHostException (java.net.UnknownHostException)3 ComponentName (android.content.ComponentName)2 ContentResolver (android.content.ContentResolver)2 ApplicationInfo (android.content.pm.ApplicationInfo)2 IPackageManager (android.content.pm.IPackageManager)2 InstrumentationInfo (android.content.pm.InstrumentationInfo)2 PackageManager (android.content.pm.PackageManager)2 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)2 ProviderInfo (android.content.pm.ProviderInfo)2 ResolveInfo (android.content.pm.ResolveInfo)2