blob: 08ce86ff4378acc81f6b368e1dafb33cdee81c96 [file] [log] [blame]
Brian Duddiecfa5b5b2019-01-22 18:01:40 +00001/*
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
19import android.os.Parcel;
20import android.os.Parcelable;
21
22/**
23 * A class that represents an Activity Recognition Event.
24 *
25 * @hide
26 */
27public class ActivityRecognitionEvent implements Parcelable {
28 private final String mActivity;
29 private final int mEventType;
30 private final long mTimestampNs;
31
32 public ActivityRecognitionEvent(String activity, int eventType, long timestampNs) {
33 mActivity = activity;
34 mEventType = eventType;
35 mTimestampNs = timestampNs;
36 }
37
38 public String getActivity() {
39 return mActivity;
40 }
41
42 public int getEventType() {
43 return mEventType;
44 }
45
46 public long getTimestampNs() {
47 return mTimestampNs;
48 }
49
Jeff Sharkey9e8f83d2019-02-28 12:06:45 -070050 public static final @android.annotation.NonNull Creator<ActivityRecognitionEvent> CREATOR =
Brian Duddiecfa5b5b2019-01-22 18:01:40 +000051 new Creator<ActivityRecognitionEvent>() {
52 @Override
53 public ActivityRecognitionEvent createFromParcel(Parcel source) {
54 String activity = source.readString();
55 int eventType = source.readInt();
56 long timestampNs = source.readLong();
57
58 return new ActivityRecognitionEvent(activity, eventType, timestampNs);
59 }
60
61 @Override
62 public ActivityRecognitionEvent[] newArray(int size) {
63 return new ActivityRecognitionEvent[size];
64 }
65 };
66
67 @Override
68 public int describeContents() {
69 return 0;
70 }
71
72 @Override
73 public void writeToParcel(Parcel parcel, int flags) {
74 parcel.writeString(mActivity);
75 parcel.writeInt(mEventType);
76 parcel.writeLong(mTimestampNs);
77 }
78
79 @Override
80 public String toString() {
81 return String.format(
82 "Activity='%s', EventType=%s, TimestampNs=%s",
83 mActivity,
84 mEventType,
85 mTimestampNs);
86 }
87}