Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a48ad8bd authored by Wink Saville's avatar Wink Saville
Browse files

PROXY_SERVICE may be missing and its reference null.

Protect ourselves from when PROXY_SERVICE is missing
and mProxyService is null.

Bug: 10267814
Change-Id: Ia329376218e246cdde3d70b578c18466d48a6383
parent 7a7c35e2
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@ package android.net;

import android.os.RemoteException;
import android.os.ServiceManager;
import android.util.Log;

import com.android.net.IProxyService;
import com.google.android.collect.Lists;
@@ -21,16 +22,25 @@ import java.util.List;
 * @hide
 */
public class PacProxySelector extends ProxySelector {
    private static final String TAG = "PacProxySelector";
    public static final String PROXY_SERVICE = "com.android.net.IProxyService";
    private IProxyService mProxyService;

    public PacProxySelector() {
        mProxyService = IProxyService.Stub.asInterface(
                ServiceManager.getService(PROXY_SERVICE));
        if (mProxyService == null) {
            // Added because of b10267814 where mako is restarting.
            Log.e(TAG, "PackManager: no proxy service");
        }
    }

    @Override
    public List<Proxy> select(URI uri) {
        if (mProxyService == null) {
            Log.e(TAG, "select: no proxy service return NO_PROXY");
            return Lists.newArrayList(java.net.Proxy.NO_PROXY);
        }
        String response = null;
        String urlString;
        try {
+14 −0
Original line number Diff line number Diff line
@@ -83,6 +83,12 @@ public class PacManager implements Runnable {
        mContext = context;
        mProxyService = IProxyService.Stub.asInterface(
                ServiceManager.getService(PROXY_SERVICE));
        if (mProxyService == null) {
            // Added because of b10267814 where mako is restarting.
            Log.e(TAG, "PacManager: no proxy service");
        } else {
            Log.d(TAG, "PacManager: mProxyService available");
        }

        mPacRefreshIntent = PendingIntent.getBroadcast(
                context, 0, new Intent(ACTION_PAC_REFRESH), 0);
@@ -98,6 +104,10 @@ public class PacManager implements Runnable {
    }

    public void setCurrentProxyScriptUrl(ProxyProperties proxy) {
        if (mProxyService == null) {
            Log.e(TAG, "setCurrentProxyScriptUrl: no proxy service");
            return;
        }
        if (!TextUtils.isEmpty(proxy.getPacFileUrl())) {
            try {
                mProxyService.startPacSystem();
@@ -212,6 +222,10 @@ public class PacManager implements Runnable {
    }

    private boolean setCurrentProxyScript(String script) {
        if (mProxyService == null) {
            Log.e(TAG, "setCurrentProxyScript: no proxy service");
            return false;
        }
        try {
            if (mProxyService.setPacFile(script) != NO_ERROR) {
                Log.e(TAG, "Unable to parse proxy script.");