1 /* 2 * Copyright (C) 2013 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.location.provider; 18 19 import android.hardware.location.GeofenceHardware; 20 import android.hardware.location.IGeofenceHardware; 21 import android.os.IBinder; 22 23 import android.location.IGeofenceProvider; 24 25 /** 26 * Base class for geofence providers implemented as unbundled services. 27 * 28 * <p>Geofence providers can be implemented as services and return the result of 29 * {@link com.android.location.provider.GeofenceProvider#getBinder()} in its getBinder() method. 30 * 31 * <p>IMPORTANT: This class is effectively a public API for unbundled 32 * applications, and must remain API stable. See README.txt in the root 33 * of this package for more information. 34 * @hide 35 */ 36 public abstract class GeofenceProvider { 37 38 private GeofenceHardware mGeofenceHardware; 39 40 private IGeofenceProvider.Stub mProvider = new IGeofenceProvider.Stub() { 41 public void setGeofenceHardware(IGeofenceHardware hardwareProxy) { 42 mGeofenceHardware = new GeofenceHardware(hardwareProxy); 43 onGeofenceHardwareChange(mGeofenceHardware); 44 } 45 }; 46 47 /** 48 * Returns the Binder interface for the geofence provider. 49 * This is intended to be used for the onBind() method of 50 * a service that implements a geofence service. 51 * 52 * @return the IBinder instance for the provider 53 */ getBinder()54 public IBinder getBinder() { 55 return mProvider; 56 } 57 58 /** 59 * Called when GeofenceHardware object becomes available. 60 * 61 * @param geofenceHardware Geofence Hardware object. This can be null 62 * when for some reason the service connection gets disconnected. 63 */ onGeofenceHardwareChange(GeofenceHardware geofenceHardware)64 public abstract void onGeofenceHardwareChange(GeofenceHardware geofenceHardware); 65 } 66