blob: fbbf6870bd5a2795beffa8a666d164414e2cab23 [file] [log] [blame]
destradaaf9a274c2014-07-25 15:11:56 -07001/*
2 * Copyright (C) 2014 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
17package android.hardware.location;
18
destradaac4e1e592014-08-15 11:33:57 -070019import android.annotation.SystemApi;
destradaaf9a274c2014-07-25 15:11:56 -070020import android.location.Location;
21import android.os.Parcel;
22import android.os.Parcelable;
23
24/**
25 * A class that represents an event for each change in the state of a monitoring system.
destradaac4e1e592014-08-15 11:33:57 -070026 *
27 * @hide
destradaaf9a274c2014-07-25 15:11:56 -070028 */
destradaac4e1e592014-08-15 11:33:57 -070029@SystemApi
destradaaf9a274c2014-07-25 15:11:56 -070030public class GeofenceHardwareMonitorEvent implements Parcelable {
31 private final int mMonitoringType;
32 private final int mMonitoringStatus;
33 private final int mSourceTechnologies;
34 private final Location mLocation;
35
36 public GeofenceHardwareMonitorEvent(
37 int monitoringType,
38 int monitoringStatus,
39 int sourceTechnologies,
40 Location location) {
41 mMonitoringType = monitoringType;
42 mMonitoringStatus = monitoringStatus;
43 mSourceTechnologies = sourceTechnologies;
44 mLocation = location;
45 }
46
47 /**
48 * Returns the type of the monitoring system that has a change on its state.
49 */
50 public int getMonitoringType() {
51 return mMonitoringType;
52 }
53
54 /**
55 * Returns the new status associated with the monitoring system.
56 */
57 public int getMonitoringStatus() {
58 return mMonitoringStatus;
59 }
60
61 /**
62 * Returns the source technologies that the status is associated to.
63 */
64 public int getSourceTechnologies() {
65 return mSourceTechnologies;
66 }
67
68 /**
69 * Returns the last known location according to the monitoring system.
70 */
71 public Location getLocation() {
72 return mLocation;
73 }
74
Jeff Sharkey9e8f83d2019-02-28 12:06:45 -070075 public static final @android.annotation.NonNull Creator<GeofenceHardwareMonitorEvent> CREATOR =
destradaaf9a274c2014-07-25 15:11:56 -070076 new Creator<GeofenceHardwareMonitorEvent>() {
77 @Override
78 public GeofenceHardwareMonitorEvent createFromParcel(Parcel source) {
79 ClassLoader classLoader = GeofenceHardwareMonitorEvent.class.getClassLoader();
80 int monitoringType = source.readInt();
81 int monitoringStatus = source.readInt();
82 int sourceTechnologies = source.readInt();
83 Location location = source.readParcelable(classLoader);
84
85 return new GeofenceHardwareMonitorEvent(
86 monitoringType,
87 monitoringStatus,
88 sourceTechnologies,
89 location);
90 }
91
92 @Override
93 public GeofenceHardwareMonitorEvent[] newArray(int size) {
94 return new GeofenceHardwareMonitorEvent[size];
95 }
96 };
97
98 @Override
99 public int describeContents() {
100 return 0;
101 }
102
103 @Override
104 public void writeToParcel(Parcel parcel, int flags) {
105 parcel.writeInt(mMonitoringType);
106 parcel.writeInt(mMonitoringStatus);
107 parcel.writeInt(mSourceTechnologies);
108 parcel.writeParcelable(mLocation, flags);
109 }
110
111 @Override
112 public String toString() {
113 return String.format(
114 "GeofenceHardwareMonitorEvent: type=%d, status=%d, sources=%d, location=%s",
115 mMonitoringType,
116 mMonitoringStatus,
117 mSourceTechnologies,
118 mLocation);
119 }
120}