/* * Copyright (C) 2021 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.app.time; import android.annotation.CurrentTimeMillisLong; import android.annotation.ElapsedRealtimeLong; import android.annotation.NonNull; import android.annotation.SystemApi; import android.app.timedetector.TimeSuggestionHelper; import android.os.Parcel; import android.os.Parcelable; import android.os.ShellCommand; import java.io.PrintWriter; import java.util.List; import java.util.Objects; /** * A time signal from an External source. * *
External time suggestions are for use in situations where the Android device is part of a * wider network of devices that are required to use a single time source, and where authority for * the time is external to the Android device. For example, for the Android Auto use case where the * Android device is part of a wider in-car network of devices that should display the same time. * *
Android allows for a single external source for time. If there are several external sources * then it is left to the caller to prioritize / filter accordingly to ensure consistency. * *
External is one of several time "origins" that the Android platform supports. Stock Android * allows for configuration of which origins can be used and the prioritization between them. Until * an external suggestion is made, the Android device may use its own RTC to initialize the system * clock during boot, and then accept suggestions from the configured origins. * *
The creator of an external suggestion is expected to be separate Android process, e.g. a * process integrating with the external time source via a HAL or local network. The creator must * capture the elapsed realtime clock value, e.g. via {@link SystemClock#elapsedRealtime()}, when * the Unix epoch time is first obtained (usually under a wakelock). This enables Android to adjust * for latency introduced between suggestion creation and eventual use. Adjustments for other * sources of latency, i.e. those before the external time suggestion is created, must be handled by * the creator. * *
{@code elapsedRealtimeMillis} and {@code suggestionMillis} represent the suggested time. * {@code suggestionMillis} is the number of milliseconds elapsed since 1/1/1970 00:00:00 UTC * according to the Unix time scale. {@code elapsedRealtimeMillis} is the value of the elapsed * realtime clock when {@code suggestionMillis} was established. Note that the elapsed realtime * clock is considered accurate but it is volatile, so time suggestions cannot be persisted across * device resets. * *
{@code debugInfo} contains debugging metadata associated with the suggestion. This is used to
* record why the suggestion exists and how it was entered. This information exists only to aid in
* debugging and therefore is used by {@link #toString()}, but it is not for use in detection logic
* and is not considered in {@link #hashCode()} or {@link #equals(Object)}.
*
* @hide
*/
@SystemApi
public final class ExternalTimeSuggestion implements Parcelable {
public static final @NonNull Creator