LocationProviderProxypublic class LocationProviderProxy extends Object implements LocationProviderInterfaceProxy for ILocationProvider implementations. |
Fields Summary |
---|
private static final String | TAG | private static final boolean | D | private final android.content.Context | mContext | private final String | mName | private final com.android.server.ServiceWatcher | mServiceWatcher | private Object | mLock | private com.android.internal.location.ProviderProperties | mProperties | private boolean | mEnabled | private com.android.internal.location.ProviderRequest | mRequest | private android.os.WorkSource | mWorksource | private Runnable | mNewServiceWorkWork to apply current state to a newly connected provider.
Remember we can switch the service that implements a providers
at run-time, so need to apply current state. |
Constructors Summary |
---|
private LocationProviderProxy(android.content.Context context, String name, String action, int overlaySwitchResId, int defaultServicePackageNameResId, int initialPackageNamesResId, android.os.Handler handler)
mContext = context;
mName = name;
mServiceWatcher = new ServiceWatcher(mContext, TAG + "-" + name, action, overlaySwitchResId,
defaultServicePackageNameResId, initialPackageNamesResId,
mNewServiceWork, handler);
|
Methods Summary |
---|
private boolean | bind()
return mServiceWatcher.start();
| public static com.android.server.location.LocationProviderProxy | createAndBind(android.content.Context context, java.lang.String name, java.lang.String action, int overlaySwitchResId, int defaultServicePackageNameResId, int initialPackageNamesResId, android.os.Handler handler)
LocationProviderProxy proxy = new LocationProviderProxy(context, name, action,
overlaySwitchResId, defaultServicePackageNameResId, initialPackageNamesResId,
handler);
if (proxy.bind()) {
return proxy;
} else {
return null;
}
| public void | disable()
synchronized (mLock) {
mEnabled = false;
}
ILocationProvider service = getService();
if (service == null) return;
try {
service.disable();
} catch (RemoteException e) {
Log.w(TAG, e);
} catch (Exception e) {
// never let remote service crash system server
Log.e(TAG, "Exception from " + mServiceWatcher.getBestPackageName(), e);
}
| public void | dump(java.io.FileDescriptor fd, java.io.PrintWriter pw, java.lang.String[] args)
pw.append("REMOTE SERVICE");
pw.append(" name=").append(mName);
pw.append(" pkg=").append(mServiceWatcher.getBestPackageName());
pw.append(" version=").append("" + mServiceWatcher.getBestVersion());
pw.append('\n");
ILocationProvider service = getService();
if (service == null) {
pw.println("service down (null)");
return;
}
pw.flush();
try {
service.asBinder().dump(fd, args);
} catch (RemoteException e) {
pw.println("service down (RemoteException)");
Log.w(TAG, e);
} catch (Exception e) {
pw.println("service down (Exception)");
// never let remote service crash system server
Log.e(TAG, "Exception from " + mServiceWatcher.getBestPackageName(), e);
}
| public void | enable()
synchronized (mLock) {
mEnabled = true;
}
ILocationProvider service = getService();
if (service == null) return;
try {
service.enable();
} catch (RemoteException e) {
Log.w(TAG, e);
} catch (Exception e) {
// never let remote service crash system server
Log.e(TAG, "Exception from " + mServiceWatcher.getBestPackageName(), e);
}
| public java.lang.String | getConnectedPackageName()
return mServiceWatcher.getBestPackageName();
| public java.lang.String | getName()
return mName;
| public com.android.internal.location.ProviderProperties | getProperties()
synchronized (mLock) {
return mProperties;
}
| private com.android.internal.location.ILocationProvider | getService()
return ILocationProvider.Stub.asInterface(mServiceWatcher.getBinder());
| public int | getStatus(android.os.Bundle extras)
ILocationProvider service = getService();
if (service == null) return LocationProvider.TEMPORARILY_UNAVAILABLE;
try {
return service.getStatus(extras);
} catch (RemoteException e) {
Log.w(TAG, e);
} catch (Exception e) {
// never let remote service crash system server
Log.e(TAG, "Exception from " + mServiceWatcher.getBestPackageName(), e);
}
return LocationProvider.TEMPORARILY_UNAVAILABLE;
| public long | getStatusUpdateTime()
ILocationProvider service = getService();
if (service == null) return 0;
try {
return service.getStatusUpdateTime();
} catch (RemoteException e) {
Log.w(TAG, e);
} catch (Exception e) {
// never let remote service crash system server
Log.e(TAG, "Exception from " + mServiceWatcher.getBestPackageName(), e);
}
return 0;
| public boolean | isEnabled()
synchronized (mLock) {
return mEnabled;
}
| public boolean | sendExtraCommand(java.lang.String command, android.os.Bundle extras)
ILocationProvider service = getService();
if (service == null) return false;
try {
return service.sendExtraCommand(command, extras);
} catch (RemoteException e) {
Log.w(TAG, e);
} catch (Exception e) {
// never let remote service crash system server
Log.e(TAG, "Exception from " + mServiceWatcher.getBestPackageName(), e);
}
return false;
| public void | setRequest(com.android.internal.location.ProviderRequest request, android.os.WorkSource source)
synchronized (mLock) {
mRequest = request;
mWorksource = source;
}
ILocationProvider service = getService();
if (service == null) return;
try {
service.setRequest(request, source);
} catch (RemoteException e) {
Log.w(TAG, e);
} catch (Exception e) {
// never let remote service crash system server
Log.e(TAG, "Exception from " + mServiceWatcher.getBestPackageName(), e);
}
|
|