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

Commit 032aeafd authored by Jaikumar Ganesh's avatar Jaikumar Ganesh Committed by Android Git Automerger
Browse files

am d5af1724: am 176c245c: Merge "Hardware geofence API changes." into jb-mr2-dev

* commit 'd5af1724':
  Hardware geofence API changes.
parents 5faf1985 d5af1724
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -126,6 +126,7 @@ LOCAL_SRC_FILES += \
	core/java/android/hardware/input/IInputDevicesChangedListener.aidl \
	core/java/android/hardware/input/IInputDevicesChangedListener.aidl \
	core/java/android/hardware/location/IGeofenceHardware.aidl \
	core/java/android/hardware/location/IGeofenceHardware.aidl \
	core/java/android/hardware/location/IGeofenceHardwareCallback.aidl \
	core/java/android/hardware/location/IGeofenceHardwareCallback.aidl \
	core/java/android/hardware/location/IGeofenceHardwareMonitorCallback.aidl \
	core/java/android/hardware/usb/IUsbManager.aidl \
	core/java/android/hardware/usb/IUsbManager.aidl \
	core/java/android/net/IConnectivityManager.aidl \
	core/java/android/net/IConnectivityManager.aidl \
	core/java/android/net/INetworkManagementEventObserver.aidl \
	core/java/android/net/INetworkManagementEventObserver.aidl \
+26 −5
Original line number Original line Diff line number Diff line
@@ -10474,13 +10474,14 @@ package android.hardware.input {
package android.hardware.location {
package android.hardware.location {
  public final class GeofenceHardware {
  public final class GeofenceHardware {
    method public boolean addCircularFence(int, double, double, double, int, int, int, int, int, android.hardware.location.GeofenceHardwareCallback);
    method public boolean addGeofence(int, int, android.hardware.location.GeofenceHardwareRequest, android.hardware.location.GeofenceHardwareCallback);
    method public int[] getMonitoringTypesAndStatus();
    method public int[] getMonitoringTypes();
    method public int getStatusOfMonitoringType(int);
    method public boolean pauseGeofence(int, int);
    method public boolean pauseGeofence(int, int);
    method public boolean registerForMonitorStateChangeCallback(int, android.hardware.location.GeofenceHardwareCallback);
    method public boolean registerForMonitorStateChangeCallback(int, android.hardware.location.GeofenceHardwareMonitorCallback);
    method public boolean removeGeofence(int, int);
    method public boolean removeGeofence(int, int);
    method public boolean resumeGeofence(int, int, int);
    method public boolean resumeGeofence(int, int, int);
    method public boolean unregisterForMonitorStateChangeCallback(int, android.hardware.location.GeofenceHardwareCallback);
    method public boolean unregisterForMonitorStateChangeCallback(int, android.hardware.location.GeofenceHardwareMonitorCallback);
    field public static final int GEOFENCE_ENTERED = 1; // 0x1
    field public static final int GEOFENCE_ENTERED = 1; // 0x1
    field public static final int GEOFENCE_ERROR_ID_EXISTS = 2; // 0x2
    field public static final int GEOFENCE_ERROR_ID_EXISTS = 2; // 0x2
    field public static final int GEOFENCE_ERROR_ID_UNKNOWN = 3; // 0x3
    field public static final int GEOFENCE_ERROR_ID_UNKNOWN = 3; // 0x3
@@ -10499,13 +10500,33 @@ package android.hardware.location {
  public abstract class GeofenceHardwareCallback {
  public abstract class GeofenceHardwareCallback {
    ctor public GeofenceHardwareCallback();
    ctor public GeofenceHardwareCallback();
    method public void onGeofenceAdd(int, int);
    method public void onGeofenceAdd(int, int);
    method public void onGeofenceChange(int, int, android.location.Location, long, int);
    method public void onGeofencePause(int, int);
    method public void onGeofencePause(int, int);
    method public void onGeofenceRemove(int, int);
    method public void onGeofenceRemove(int, int);
    method public void onGeofenceResume(int, int);
    method public void onGeofenceResume(int, int);
    method public void onGeofenceTransition(int, int, android.location.Location, long, int);
  }
  public abstract class GeofenceHardwareMonitorCallback {
    ctor public GeofenceHardwareMonitorCallback();
    method public void onMonitoringSystemChange(int, boolean, android.location.Location);
    method public void onMonitoringSystemChange(int, boolean, android.location.Location);
  }
  }
  public final class GeofenceHardwareRequest {
    ctor public GeofenceHardwareRequest();
    method public static android.hardware.location.GeofenceHardwareRequest createCircularGeofence(double, double, double);
    method public int getLastTransition();
    method public double getLatitude();
    method public double getLongitude();
    method public int getMonitorTransitions();
    method public int getNotificationResponsiveness();
    method public double getRadius();
    method public int getUnknownTimer();
    method public void setLastTransition(int);
    method public void setMonitorTransitions(int);
    method public void setNotificationResponsiveness(int);
    method public void setUnknownTimer(int);
  }
}
}
package android.hardware.usb {
package android.hardware.usb {
+120 −58
Original line number Original line Diff line number Diff line
@@ -129,6 +129,9 @@ public final class GeofenceHardware {


    private HashMap<GeofenceHardwareCallback, GeofenceHardwareCallbackWrapper>
    private HashMap<GeofenceHardwareCallback, GeofenceHardwareCallbackWrapper>
            mCallbacks = new HashMap<GeofenceHardwareCallback, GeofenceHardwareCallbackWrapper>();
            mCallbacks = new HashMap<GeofenceHardwareCallback, GeofenceHardwareCallbackWrapper>();
    private HashMap<GeofenceHardwareMonitorCallback, GeofenceHardwareMonitorCallbackWrapper>
            mMonitorCallbacks = new HashMap<GeofenceHardwareMonitorCallback,
                    GeofenceHardwareMonitorCallbackWrapper>();
    /**
    /**
     * @hide
     * @hide
     */
     */
@@ -137,8 +140,29 @@ public final class GeofenceHardware {
    }
    }


    /**
    /**
     * Returns all the hardware geofence monitoring systems and their status.
     * Returns all the hardware geofence monitoring systems which are supported
     * Status can be one of {@link #MONITOR_CURRENTLY_AVAILABLE},
     *
     * <p> Call {@link #getStatusOfMonitoringType(int)} to know the current state
     * of a monitoring system.
     *
     * <p> Requires {@link android.Manifest.permission#LOCATION_HARDWARE} permission to access
     * geofencing in hardware.
     *
     * @return An array of all the monitoring types.
     *         An array of length 0 is returned in case of errors.
     */
    public int[] getMonitoringTypes() {
        try {
            return mService.getMonitoringTypes();
        } catch (RemoteException e) {
        }
        return new int[0];
    }

    /**
     * Returns current status of a hardware geofence monitoring system.
     *
     * <p>Status can be one of {@link #MONITOR_CURRENTLY_AVAILABLE},
     * {@link #MONITOR_CURRENTLY_UNAVAILABLE} or {@link #MONITOR_UNSUPPORTED}
     * {@link #MONITOR_CURRENTLY_UNAVAILABLE} or {@link #MONITOR_UNSUPPORTED}
     *
     *
     * <p> Some supported hardware monitoring systems might not be available
     * <p> Some supported hardware monitoring systems might not be available
@@ -147,18 +171,15 @@ public final class GeofenceHardware {
     * geofences and will change from {@link #MONITOR_CURRENTLY_AVAILABLE} to
     * geofences and will change from {@link #MONITOR_CURRENTLY_AVAILABLE} to
     * {@link #MONITOR_CURRENTLY_UNAVAILABLE}.
     * {@link #MONITOR_CURRENTLY_UNAVAILABLE}.
     *
     *
     * <p> Requires {@link android.Manifest.permission#LOCATION_HARDWARE} permission to access
     * @param monitoringType
     * geofencing in hardware.
     * @return Current status of the monitoring type.
     *
     * @return An array indexed by the various monitoring types and their status.
     *         An array of length 0 is returned in case of errors.
     */
     */
    public int[] getMonitoringTypesAndStatus() {
    public int getStatusOfMonitoringType(int monitoringType) {
        try {
        try {
            return mService.getMonitoringTypesAndStatus();
            return mService.getStatusOfMonitoringType(monitoringType);
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            return MONITOR_UNSUPPORTED;
        }
        }
        return new int[0];
    }
    }


    /**
    /**
@@ -167,8 +188,10 @@ public final class GeofenceHardware {
     * <p> When the device detects that is has entered, exited or is uncertain
     * <p> When the device detects that is has entered, exited or is uncertain
     * about the area specified by the geofence, the given callback will be called.
     * about the area specified by the geofence, the given callback will be called.
     *
     *
     * <p> The {@link GeofenceHardwareCallback#onGeofenceChange} callback will be called,
     * <p> If this call returns true, it means that the geofence has been sent to the hardware.
     * with the following parameters
     * {@link GeofenceHardwareCallback#onGeofenceAdd} will be called with the result of the
     * add call from the hardware. The {@link GeofenceHardwareCallback#onGeofenceAdd} will be
     * called with the following parameters when a transition event occurs.
     * <ul>
     * <ul>
     * <li> The geofence Id
     * <li> The geofence Id
     * <li> The location object indicating the last known location.
     * <li> The location object indicating the last known location.
@@ -195,43 +218,46 @@ public final class GeofenceHardware {
     * which abstracts the hardware should be used instead. All the checks are done by the higher
     * which abstracts the hardware should be used instead. All the checks are done by the higher
     * level public API. Any needed locking should be handled by the higher level API.
     * level public API. Any needed locking should be handled by the higher level API.
     *
     *
     * @param latitude Latitude of the area to be monitored.
     * <p> Create a geofence request object using the methods in {@link GeofenceHardwareRequest} to
     * @param longitude Longitude of the area to be monitored.
     * set all the characteristics of the geofence. Use the created GeofenceHardwareRequest object
     * @param radius Radius (in meters) of the area to be monitored.
     * in this call.
     * @param lastTransition The current state of the geofence. Can be one of
     *
     *        {@link #GEOFENCE_ENTERED}, {@link #GEOFENCE_EXITED},
     * @param geofenceId The id associated with the geofence.
     *        {@link #GEOFENCE_UNCERTAIN}.
     * @param monitorTransitions Bitwise OR of {@link #GEOFENCE_ENTERED},
     *        {@link #GEOFENCE_EXITED}, {@link #GEOFENCE_UNCERTAIN}
     * @param notificationResponsivenes Defines the best-effort description
     *        of how soon should the callback be called when the transition
     *        associated with the Geofence is triggered. For instance, if
     *        set to 1000 millseconds with {@link #GEOFENCE_ENTERED},
     *        the callback will be called 1000 milliseconds within entering
     *        the geofence. This parameter is defined in milliseconds.
     * @param unknownTimer The time limit after which the
     *        {@link #GEOFENCE_UNCERTAIN} transition
     *        should be triggered. This paramter is defined in milliseconds.
     * @param monitoringType The type of the hardware subsystem that should be used
     * @param monitoringType The type of the hardware subsystem that should be used
     *        to monitor the geofence.
     *        to monitor the geofence.
     * @param geofenceRequest The {@link GeofenceHardwareRequest} object associated with the
     *        geofence.
     * @param callback {@link GeofenceHardwareCallback} that will be use to notify the
     * @param callback {@link GeofenceHardwareCallback} that will be use to notify the
     *        transition.
     *        transition.
     * @return true on success.
     * @return true when the geofence is successfully sent to the hardware for addition.
     * @throws IllegalArgumentException when the geofence request type is not supported.
     */
     */
    public boolean addCircularFence(int geofenceId, double latitude, double longitude,
    public boolean addGeofence(int geofenceId, int monitoringType, GeofenceHardwareRequest
            double radius, int lastTransition,int monitorTransitions, int notificationResponsivenes,
            geofenceRequest, GeofenceHardwareCallback callback) {
            int unknownTimer, int monitoringType, GeofenceHardwareCallback callback) {
        try {
        try {
            return mService.addCircularFence(geofenceId, latitude, longitude, radius,
            if (geofenceRequest.getType() == GeofenceHardwareRequest.GEOFENCE_TYPE_CIRCLE) {
                    lastTransition, monitorTransitions, notificationResponsivenes, unknownTimer,
                return mService.addCircularFence(geofenceId, monitoringType,
                    monitoringType, getCallbackWrapper(callback));
                        geofenceRequest.getLatitude(),
                        geofenceRequest.getLongitude(), geofenceRequest.getRadius(),
                        geofenceRequest.getLastTransition(),
                        geofenceRequest.getMonitorTransitions(),
                        geofenceRequest.getNotificationResponsiveness(),
                        geofenceRequest.getUnknownTimer(),
                        getCallbackWrapper(callback));
            } else {
                throw new IllegalArgumentException("Geofence Request type not supported");
            }
        } catch (RemoteException e) {
        } catch (RemoteException e) {
        }
        }
        return false;
        return false;
    }
    }


    /**
    /**
     * Removes a geofence added by {@link #addCircularFence} call.
     * Removes a geofence added by {@link #addGeofence} call.
     *
     * <p> If this call returns true, it means that the geofence has been sent to the hardware.
     * {@link GeofenceHardwareCallback#onGeofenceRemove} will be called with the result of the
     * remove call from the hardware.
     *
     *
     * <p> Requires {@link android.Manifest.permission#ACCESS_FINE_LOCATION} permission when
     * <p> Requires {@link android.Manifest.permission#ACCESS_FINE_LOCATION} permission when
     * {@link #MONITORING_TYPE_GPS_HARDWARE} is used.
     * {@link #MONITORING_TYPE_GPS_HARDWARE} is used.
@@ -246,7 +272,7 @@ public final class GeofenceHardware {
     * @param geofenceId The id of the geofence.
     * @param geofenceId The id of the geofence.
     * @param monitoringType The type of the hardware subsystem that should be used
     * @param monitoringType The type of the hardware subsystem that should be used
     *        to monitor the geofence.
     *        to monitor the geofence.
     * @return true on success.
     * @return true when the geofence is successfully sent to the hardware for removal.                     .
     */
     */
   public boolean removeGeofence(int geofenceId, int monitoringType) {
   public boolean removeGeofence(int geofenceId, int monitoringType) {
       try {
       try {
@@ -257,7 +283,11 @@ public final class GeofenceHardware {
   }
   }


    /**
    /**
     * Pauses the monitoring of a geofence added by {@link #addCircularFence} call.
     * Pauses the monitoring of a geofence added by {@link #addGeofence} call.
     *
     * <p> If this call returns true, it means that the geofence has been sent to the hardware.
     * {@link GeofenceHardwareCallback#onGeofencePause} will be called with the result of the
     * pause call from the hardware.
     *
     *
     * <p> Requires {@link android.Manifest.permission#ACCESS_FINE_LOCATION} permission when
     * <p> Requires {@link android.Manifest.permission#ACCESS_FINE_LOCATION} permission when
     * {@link #MONITORING_TYPE_GPS_HARDWARE} is used.
     * {@link #MONITORING_TYPE_GPS_HARDWARE} is used.
@@ -272,7 +302,7 @@ public final class GeofenceHardware {
     * @param geofenceId The id of the geofence.
     * @param geofenceId The id of the geofence.
     * @param monitoringType The type of the hardware subsystem that should be used
     * @param monitoringType The type of the hardware subsystem that should be used
     *        to monitor the geofence.
     *        to monitor the geofence.
     * @return true on success.
     * @return true when the geofence is successfully sent to the hardware for pausing.
     */
     */
    public boolean pauseGeofence(int geofenceId, int monitoringType) {
    public boolean pauseGeofence(int geofenceId, int monitoringType) {
        try {
        try {
@@ -285,6 +315,10 @@ public final class GeofenceHardware {
    /**
    /**
     * Resumes the monitoring of a geofence added by {@link #pauseGeofence} call.
     * Resumes the monitoring of a geofence added by {@link #pauseGeofence} call.
     *
     *
     * <p> If this call returns true, it means that the geofence has been sent to the hardware.
     * {@link GeofenceHardwareCallback#onGeofenceResume} will be called with the result of the
     * resume call from the hardware.
     *
     * <p> Requires {@link android.Manifest.permission#ACCESS_FINE_LOCATION} permission when
     * <p> Requires {@link android.Manifest.permission#ACCESS_FINE_LOCATION} permission when
     * {@link #MONITORING_TYPE_GPS_HARDWARE} is used.
     * {@link #MONITORING_TYPE_GPS_HARDWARE} is used.
     *
     *
@@ -296,15 +330,15 @@ public final class GeofenceHardware {
     * level public API. Any needed locking should be handled by the higher level API.
     * level public API. Any needed locking should be handled by the higher level API.
     *
     *
     * @param geofenceId The id of the geofence.
     * @param geofenceId The id of the geofence.
     * @param monitorTransition Bitwise OR of {@link #GEOFENCE_ENTERED},
     *        {@link #GEOFENCE_EXITED}, {@link #GEOFENCE_UNCERTAIN}
     * @param monitoringType The type of the hardware subsystem that should be used
     * @param monitoringType The type of the hardware subsystem that should be used
     *        to monitor the geofence.
     *        to monitor the geofence.
     * @return true on success.
     * @param monitorTransition Bitwise OR of {@link #GEOFENCE_ENTERED},
     *        {@link #GEOFENCE_EXITED}, {@link #GEOFENCE_UNCERTAIN}
     * @return true when the geofence is successfully sent to the hardware for resumption.
     */
     */
    public boolean resumeGeofence(int geofenceId, int monitorTransition, int monitoringType) {
    public boolean resumeGeofence(int geofenceId, int monitoringType, int monitorTransition) {
        try {
        try {
            return mService.resumeGeofence(geofenceId, monitorTransition, monitoringType);
            return mService.resumeGeofence(geofenceId, monitoringType, monitorTransition);
        } catch (RemoteException e) {
        } catch (RemoteException e) {
        }
        }
        return false;
        return false;
@@ -333,10 +367,10 @@ public final class GeofenceHardware {
     * @return true on success
     * @return true on success
     */
     */
    public boolean registerForMonitorStateChangeCallback(int monitoringType,
    public boolean registerForMonitorStateChangeCallback(int monitoringType,
            GeofenceHardwareCallback callback) {
            GeofenceHardwareMonitorCallback callback) {
        try {
        try {
            return mService.registerForMonitorStateChangeCallback(monitoringType,
            return mService.registerForMonitorStateChangeCallback(monitoringType,
                    getCallbackWrapper(callback));
                    getMonitorCallbackWrapper(callback));
        } catch (RemoteException e) {
        } catch (RemoteException e) {
        }
        }
        return false;
        return false;
@@ -361,12 +395,12 @@ public final class GeofenceHardware {
     * @return true on success
     * @return true on success
     */
     */
    public boolean unregisterForMonitorStateChangeCallback(int monitoringType,
    public boolean unregisterForMonitorStateChangeCallback(int monitoringType,
            GeofenceHardwareCallback callback) {
            GeofenceHardwareMonitorCallback callback) {
        boolean  result = false;
        boolean  result = false;
        try {
        try {
            result = mService.unregisterForMonitorStateChangeCallback(monitoringType,
            result = mService.unregisterForMonitorStateChangeCallback(monitoringType,
                    getCallbackWrapper(callback));
                    getMonitorCallbackWrapper(callback));
            if (result) removeCallback(callback);
            if (result) removeMonitorCallback(callback);


        } catch (RemoteException e) {
        } catch (RemoteException e) {
        }
        }
@@ -391,24 +425,50 @@ public final class GeofenceHardware {
        }
        }
    }
    }


    class GeofenceHardwareCallbackWrapper extends IGeofenceHardwareCallback.Stub {
    private void removeMonitorCallback(GeofenceHardwareMonitorCallback callback) {
        private WeakReference<GeofenceHardwareCallback> mCallback;
        synchronized (mMonitorCallbacks) {
            mMonitorCallbacks.remove(callback);
        }
    }


        GeofenceHardwareCallbackWrapper(GeofenceHardwareCallback c) {
    private GeofenceHardwareMonitorCallbackWrapper getMonitorCallbackWrapper(
            mCallback = new WeakReference<GeofenceHardwareCallback>(c);
            GeofenceHardwareMonitorCallback callback) {
        synchronized (mMonitorCallbacks) {
            GeofenceHardwareMonitorCallbackWrapper wrapper = mMonitorCallbacks.get(callback);
            if (wrapper == null) {
                wrapper = new GeofenceHardwareMonitorCallbackWrapper(callback);
                mMonitorCallbacks.put(callback, wrapper);
            }
            return wrapper;
        }
    }

    class GeofenceHardwareMonitorCallbackWrapper extends IGeofenceHardwareMonitorCallback.Stub {
        private WeakReference<GeofenceHardwareMonitorCallback> mCallback;

        GeofenceHardwareMonitorCallbackWrapper(GeofenceHardwareMonitorCallback c) {
            mCallback = new WeakReference<GeofenceHardwareMonitorCallback>(c);
        }
        }


        public void onMonitoringSystemChange(int monitoringType, boolean available,
        public void onMonitoringSystemChange(int monitoringType, boolean available,
                Location location) {
                Location location) {
            GeofenceHardwareCallback c = mCallback.get();
            GeofenceHardwareMonitorCallback c = mCallback.get();
            if (c != null) c.onMonitoringSystemChange(monitoringType, available, location);
            if (c != null) c.onMonitoringSystemChange(monitoringType, available, location);
        }
        }
    }

    class GeofenceHardwareCallbackWrapper extends IGeofenceHardwareCallback.Stub {
        private WeakReference<GeofenceHardwareCallback> mCallback;

        GeofenceHardwareCallbackWrapper(GeofenceHardwareCallback c) {
            mCallback = new WeakReference<GeofenceHardwareCallback>(c);
        }


        public void onGeofenceChange(int geofenceId, int transition, Location location,
        public void onGeofenceTransition(int geofenceId, int transition, Location location,
                long timestamp, int monitoringType) {
                long timestamp, int monitoringType) {
            GeofenceHardwareCallback c = mCallback.get();
            GeofenceHardwareCallback c = mCallback.get();
            if (c != null) {
            if (c != null) {
                c.onGeofenceChange(geofenceId, transition, location, timestamp,
                c.onGeofenceTransition(geofenceId, transition, location, timestamp,
                        monitoringType);
                        monitoringType);
            }
            }
        }
        }
@@ -428,7 +488,9 @@ public final class GeofenceHardware {


        public void onGeofencePause(int geofenceId, int status) {
        public void onGeofencePause(int geofenceId, int status) {
            GeofenceHardwareCallback c = mCallback.get();
            GeofenceHardwareCallback c = mCallback.get();
            if (c != null) c.onGeofencePause(geofenceId, status);
            if (c != null) {
                c.onGeofencePause(geofenceId, status);
            }
        }
        }


        public void onGeofenceResume(int geofenceId, int status) {
        public void onGeofenceResume(int geofenceId, int status) {
+1 −14
Original line number Original line Diff line number Diff line
@@ -22,19 +22,6 @@ import android.location.Location;
 * The callback class associated with the APIs in {@link GeofenceHardware}
 * The callback class associated with the APIs in {@link GeofenceHardware}
 */
 */
public abstract class GeofenceHardwareCallback {
public abstract class GeofenceHardwareCallback {

    /**
     * The callback called when the state of a monitoring system changes.
     * {@link GeofenceHardware#MONITORING_TYPE_GPS_HARDWARE} is an example of a
     * monitoring system.
     *
     * @param monitoringType The type of the monitoring system.
     * @param available Indicates whether the system is currently available or not.
     * @param location The last known location according to the monitoring system.
     */
    public void onMonitoringSystemChange(int monitoringType, boolean available, Location location) {
    }

    /**
    /**
     * The callback called when there is a transition to report for the specific
     * The callback called when there is a transition to report for the specific
     * geofence.
     * geofence.
@@ -47,7 +34,7 @@ public abstract class GeofenceHardwareCallback {
     *        detected
     *        detected
     * @param monitoringType Type of the monitoring system.
     * @param monitoringType Type of the monitoring system.
     */
     */
    public void onGeofenceChange(int geofenceId, int transition, Location location,
    public void onGeofenceTransition(int geofenceId, int transition, Location location,
            long timestamp, int monitoringType) {
            long timestamp, int monitoringType) {
    }
    }


+161 −17

File changed.

Preview size limit exceeded, changes collapsed.

Loading