| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.hardware.location; |
| 18 |
|
| 19 |
import android.annotation.SystemApi; |
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
@SystemApi |
| 29 |
public final class GeofenceHardwareRequest { |
| 30 |
static final int GEOFENCE_TYPE_CIRCLE = 0; |
| 31 |
private int mType; |
| 32 |
private double mLatitude; |
| 33 |
private double mLongitude; |
| 34 |
private double mRadius; |
| 35 |
private int mLastTransition = GeofenceHardware.GEOFENCE_UNCERTAIN; |
| 36 |
private int mUnknownTimer = 30000; |
| 37 |
private int mMonitorTransitions = GeofenceHardware.GEOFENCE_UNCERTAIN | |
| 38 |
GeofenceHardware.GEOFENCE_ENTERED | GeofenceHardware.GEOFENCE_EXITED; |
| 39 |
private int mNotificationResponsiveness = 5000; |
| 40 |
private int mSourceTechnologies = GeofenceHardware.SOURCE_TECHNOLOGY_GNSS; |
| 41 |
|
| 42 |
private void setCircularGeofence(double latitude, double longitude, double radius) { |
| 43 |
mLatitude = latitude; |
| 44 |
mLongitude = longitude; |
| 45 |
mRadius = radius; |
| 46 |
mType = GEOFENCE_TYPE_CIRCLE; |
| 47 |
} |
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
public static GeofenceHardwareRequest createCircularGeofence(double latitude, |
| 57 |
double longitude, double radius) { |
| 58 |
GeofenceHardwareRequest geofenceRequest = new GeofenceHardwareRequest(); |
| 59 |
geofenceRequest.setCircularGeofence(latitude, longitude, radius); |
| 60 |
return geofenceRequest; |
| 61 |
} |
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
public void setLastTransition(int lastTransition) { |
| 71 |
mLastTransition = lastTransition; |
| 72 |
} |
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
public void setUnknownTimer(int unknownTimer) { |
| 82 |
mUnknownTimer = unknownTimer; |
| 83 |
} |
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
public void setMonitorTransitions(int monitorTransitions) { |
| 92 |
mMonitorTransitions = monitorTransitions; |
| 93 |
} |
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
public void setNotificationResponsiveness(int notificationResponsiveness) { |
| 106 |
mNotificationResponsiveness = notificationResponsiveness; |
| 107 |
} |
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
public void setSourceTechnologies(int sourceTechnologies) { |
| 117 |
int sourceTechnologiesAll = GeofenceHardware.SOURCE_TECHNOLOGY_GNSS |
| 118 |
| GeofenceHardware.SOURCE_TECHNOLOGY_WIFI |
| 119 |
| GeofenceHardware.SOURCE_TECHNOLOGY_SENSORS |
| 120 |
| GeofenceHardware.SOURCE_TECHNOLOGY_CELL |
| 121 |
| GeofenceHardware.SOURCE_TECHNOLOGY_BLUETOOTH; |
| 122 |
|
| 123 |
int sanitizedSourceTechnologies = (sourceTechnologies & sourceTechnologiesAll); |
| 124 |
if (sanitizedSourceTechnologies == 0) { |
| 125 |
throw new IllegalArgumentException("At least one valid source technology must be set."); |
| 126 |
} |
| 127 |
|
| 128 |
mSourceTechnologies = sanitizedSourceTechnologies; |
| 129 |
} |
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
public double getLatitude() { |
| 135 |
return mLatitude; |
| 136 |
} |
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
public double getLongitude() { |
| 142 |
return mLongitude; |
| 143 |
} |
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
public double getRadius() { |
| 149 |
return mRadius; |
| 150 |
} |
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
public int getMonitorTransitions() { |
| 156 |
return mMonitorTransitions; |
| 157 |
} |
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
public int getUnknownTimer() { |
| 163 |
return mUnknownTimer; |
| 164 |
} |
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
public int getNotificationResponsiveness() { |
| 170 |
return mNotificationResponsiveness; |
| 171 |
} |
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
public int getLastTransition() { |
| 177 |
return mLastTransition; |
| 178 |
} |
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
public int getSourceTechnologies() { |
| 184 |
return mSourceTechnologies; |
| 185 |
} |
| 186 |
|
| 187 |
int getType() { |
| 188 |
return mType; |
| 189 |
} |
| 190 |
} |