Brian Duddie | cfa5b5b | 2019-01-22 18:01:40 +0000 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package android.hardware.location; |
| 18 | |
| 19 | import android.os.Parcel; |
| 20 | import android.os.Parcelable; |
| 21 | |
| 22 | /** |
| 23 | * A class that represents an Activity Recognition Event. |
| 24 | * |
| 25 | * @hide |
| 26 | */ |
| 27 | public 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 Sharkey | 9e8f83d | 2019-02-28 12:06:45 -0700 | [diff] [blame^] | 50 | public static final @android.annotation.NonNull Creator<ActivityRecognitionEvent> CREATOR = |
Brian Duddie | cfa5b5b | 2019-01-22 18:01:40 +0000 | [diff] [blame] | 51 | 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 | } |