am a48ad8bd: PROXY_SERVICE may be missing and its reference null.
* commit 'a48ad8bd858d6ffe77838a282dbf71e01967957c': PROXY_SERVICE may be missing and its reference null.
This commit is contained in:
@@ -3,6 +3,7 @@ package android.net;
|
|||||||
|
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import com.android.net.IProxyService;
|
import com.android.net.IProxyService;
|
||||||
import com.google.android.collect.Lists;
|
import com.google.android.collect.Lists;
|
||||||
@@ -21,16 +22,25 @@ import java.util.List;
|
|||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public class PacProxySelector extends ProxySelector {
|
public class PacProxySelector extends ProxySelector {
|
||||||
|
private static final String TAG = "PacProxySelector";
|
||||||
public static final String PROXY_SERVICE = "com.android.net.IProxyService";
|
public static final String PROXY_SERVICE = "com.android.net.IProxyService";
|
||||||
private IProxyService mProxyService;
|
private IProxyService mProxyService;
|
||||||
|
|
||||||
public PacProxySelector() {
|
public PacProxySelector() {
|
||||||
mProxyService = IProxyService.Stub.asInterface(
|
mProxyService = IProxyService.Stub.asInterface(
|
||||||
ServiceManager.getService(PROXY_SERVICE));
|
ServiceManager.getService(PROXY_SERVICE));
|
||||||
|
if (mProxyService == null) {
|
||||||
|
// Added because of b10267814 where mako is restarting.
|
||||||
|
Log.e(TAG, "PackManager: no proxy service");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Proxy> select(URI uri) {
|
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 response = null;
|
||||||
String urlString;
|
String urlString;
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -83,6 +83,12 @@ public class PacManager implements Runnable {
|
|||||||
mContext = context;
|
mContext = context;
|
||||||
mProxyService = IProxyService.Stub.asInterface(
|
mProxyService = IProxyService.Stub.asInterface(
|
||||||
ServiceManager.getService(PROXY_SERVICE));
|
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(
|
mPacRefreshIntent = PendingIntent.getBroadcast(
|
||||||
context, 0, new Intent(ACTION_PAC_REFRESH), 0);
|
context, 0, new Intent(ACTION_PAC_REFRESH), 0);
|
||||||
@@ -98,6 +104,10 @@ public class PacManager implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setCurrentProxyScriptUrl(ProxyProperties proxy) {
|
public void setCurrentProxyScriptUrl(ProxyProperties proxy) {
|
||||||
|
if (mProxyService == null) {
|
||||||
|
Log.e(TAG, "setCurrentProxyScriptUrl: no proxy service");
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!TextUtils.isEmpty(proxy.getPacFileUrl())) {
|
if (!TextUtils.isEmpty(proxy.getPacFileUrl())) {
|
||||||
try {
|
try {
|
||||||
mProxyService.startPacSystem();
|
mProxyService.startPacSystem();
|
||||||
@@ -212,6 +222,10 @@ public class PacManager implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean setCurrentProxyScript(String script) {
|
private boolean setCurrentProxyScript(String script) {
|
||||||
|
if (mProxyService == null) {
|
||||||
|
Log.e(TAG, "setCurrentProxyScript: no proxy service");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
if (mProxyService.setPacFile(script) != NO_ERROR) {
|
if (mProxyService.setPacFile(script) != NO_ERROR) {
|
||||||
Log.e(TAG, "Unable to parse proxy script.");
|
Log.e(TAG, "Unable to parse proxy script.");
|
||||||
|
|||||||
Reference in New Issue
Block a user