FileDocCategorySizeDatePackage
LocationProviderProxy.javaAPI DocAndroid 5.1 API9506Thu Mar 12 22:22:42 GMT 2015com.android.server.location

LocationProviderProxy

public class LocationProviderProxy extends Object implements LocationProviderInterface
Proxy 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
mNewServiceWork
Work 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 booleanbind()

        return mServiceWatcher.start();
    
public static com.android.server.location.LocationProviderProxycreateAndBind(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 voiddisable()

        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 voiddump(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 voidenable()

        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.StringgetConnectedPackageName()

        return mServiceWatcher.getBestPackageName();
    
public java.lang.StringgetName()


    
       
        return mName;
    
public com.android.internal.location.ProviderPropertiesgetProperties()

        synchronized (mLock) {
            return mProperties;
        }
    
private com.android.internal.location.ILocationProvidergetService()

        return ILocationProvider.Stub.asInterface(mServiceWatcher.getBinder());
    
public intgetStatus(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 longgetStatusUpdateTime()

        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 booleanisEnabled()

        synchronized (mLock) {
            return mEnabled;
        }
    
public booleansendExtraCommand(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 voidsetRequest(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);
        }