Debian Codegraph @

core/java/android/app/timedetector/ManualTimeSuggestion.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2019 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.app.timedetector;
18
19 import android.annotation.NonNull;
20 import android.annotation.Nullable;
21 import android.os.Parcel;
22 import android.os.Parcelable;
23 import android.os.ShellCommand;
24 import android.os.TimestampedValue;
25
26 import java.io.PrintWriter;
27 import java.util.List;
28 import java.util.Objects;
29
30 /**
31 * A time signal from a manual (user provided) source.
32 *
33 * <p>See {@link TimeSuggestionHelper} for property information.
34 *
35 * @hide
36 */
37 public final class ManualTimeSuggestion implements Parcelable {
38
39 public static final @NonNull Creator<ManualTimeSuggestion> CREATOR =
40 new Creator<ManualTimeSuggestion>() {
41 public ManualTimeSuggestion createFromParcel(Parcel in) {
42 TimeSuggestionHelper helper = TimeSuggestionHelper.handleCreateFromParcel(
43 ManualTimeSuggestion.class, in);
44 return new ManualTimeSuggestion(helper);
45 }
46
47 public ManualTimeSuggestion[] newArray(int size) {
48 return new ManualTimeSuggestion[size];
49 }
50 };
51
52 @NonNull private final TimeSuggestionHelper mTimeSuggestionHelper;
53
54 public ManualTimeSuggestion(@NonNull TimestampedValue<Long> unixEpochTime) {
55 mTimeSuggestionHelper = new TimeSuggestionHelper(ManualTimeSuggestion.class, unixEpochTime);
56 }
57
58 private ManualTimeSuggestion(@NonNull TimeSuggestionHelper helper) {
59 mTimeSuggestionHelper = Objects.requireNonNull(helper);
60 }
61
62 @Override
63 public int describeContents() {
64 return 0;
65 }
66
67 @Override
68 public void writeToParcel(@NonNull Parcel dest, int flags) {
69 mTimeSuggestionHelper.handleWriteToParcel(dest, flags);
70 }
71
72 @NonNull
73 public TimestampedValue<Long> getUnixEpochTime() {
74 return mTimeSuggestionHelper.getUnixEpochTime();
75 }
76
77 @NonNull
78 public List<String> getDebugInfo() {
79 return mTimeSuggestionHelper.getDebugInfo();
80 }
81
82 /**
83 * Associates information with the instance that can be useful for debugging / logging. The
84 * information is present in {@link #toString()} but is not considered for
85 * {@link #equals(Object)} and {@link #hashCode()}.
86 */
87 public void addDebugInfo(String... debugInfos) {
88 mTimeSuggestionHelper.addDebugInfo(debugInfos);
89 }
90
91 @Override
92 public boolean equals(@Nullable Object o) {
93 if (this == o) {
94 return true;
95 }
96 if (o == null || getClass() != o.getClass()) {
97 return false;
98 }
99 ManualTimeSuggestion that = (ManualTimeSuggestion) o;
100 return mTimeSuggestionHelper.handleEquals(that.mTimeSuggestionHelper);
101 }
102
103 @Override
104 public int hashCode() {
105 return mTimeSuggestionHelper.hashCode();
106 }
107
108 @Override
109 public String toString() {
110 return mTimeSuggestionHelper.handleToString();
111 }
112
113 /** @hide */
114 public static ManualTimeSuggestion parseCommandLineArg(@NonNull ShellCommand cmd)
115 throws IllegalArgumentException {
116 return new ManualTimeSuggestion(
117 TimeSuggestionHelper.handleParseCommandLineArg(ManualTimeSuggestion.class, cmd));
118 }
119
120 /** @hide */
121 public static void printCommandLineOpts(PrintWriter pw) {
122 TimeSuggestionHelper.handlePrintCommandLineOpts(pw, "Manual", ManualTimeSuggestion.class);
123 }
124 }