1 /* 2 * Copyright (C) 2022 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 com.android.server.timedetector; 18 19 import android.annotation.NonNull; 20 import android.annotation.Nullable; 21 import android.app.time.TimeCapabilitiesAndConfig; 22 import android.app.time.TimeConfiguration; 23 import android.app.timedetector.ManualTimeSuggestion; 24 25 import com.android.server.timezonedetector.StateChangeListener; 26 27 /** 28 * The internal (in-process) system server API for the time detector service. 29 * 30 * <p>The methods on this class can be called from any thread. 31 * 32 * <p>Methods marked with "[For device policy manager only]" are for use by the device policy 33 * manager to set device state and must not enforce device policy restrictions. 34 * 35 * @hide 36 */ 37 public interface TimeDetectorInternal { 38 39 /** 40 * [For device policy manager only] Returns a snapshot of the configuration that controls time 41 * detector behavior for the current user. 42 */ 43 @NonNull getCapabilitiesAndConfigForDpm()44 TimeCapabilitiesAndConfig getCapabilitiesAndConfigForDpm(); 45 46 /** 47 * [For device policy manager only] Updates the configuration properties that control a device's 48 * time behavior for the current user. 49 * 50 * <p>This method returns {@code true} if the configuration was changed, {@code false} 51 * otherwise. 52 */ updateConfigurationForDpm(@onNull TimeConfiguration configuration)53 boolean updateConfigurationForDpm(@NonNull TimeConfiguration configuration); 54 55 /** 56 * [For device policy manager only] Attempts to set the device to a manually entered time. 57 * Returns {@code false} if the suggestion is invalid, or the device configuration prevents the 58 * suggestion being used, {@code true} if the suggestion has been accepted. A suggestion that is 59 * valid but does not change the time because it matches the current device time is considered 60 * accepted. 61 */ setManualTimeForDpm(@onNull ManualTimeSuggestion suggestion)62 boolean setManualTimeForDpm(@NonNull ManualTimeSuggestion suggestion); 63 64 /** 65 * Suggests a network time to the time detector. The suggestion may not be used by the time 66 * detector to set the device's time depending on device configuration and user settings, but 67 * can replace previous network suggestions received. See also 68 * {@link #addNetworkTimeUpdateListener(StateChangeListener)} and 69 * {@link #getLatestNetworkSuggestion()}. 70 */ suggestNetworkTime(@onNull NetworkTimeSuggestion suggestion)71 void suggestNetworkTime(@NonNull NetworkTimeSuggestion suggestion); 72 73 /** 74 * Adds a listener that will be notified when a new network time is available. See {@link 75 * #getLatestNetworkSuggestion()}. 76 */ addNetworkTimeUpdateListener( @onNull StateChangeListener networkSuggestionUpdateListener)77 void addNetworkTimeUpdateListener( 78 @NonNull StateChangeListener networkSuggestionUpdateListener); 79 80 /** 81 * Returns the latest / best network time received by the time detector. 82 */ 83 @Nullable getLatestNetworkSuggestion()84 NetworkTimeSuggestion getLatestNetworkSuggestion(); 85 86 /** 87 * Suggests a GNSS-derived time to the time detector. The suggestion may not be used by the time 88 * detector to set the device's time depending on device configuration and user settings, but 89 * can replace previous GNSS suggestions received. 90 */ suggestGnssTime(@onNull GnssTimeSuggestion suggestion)91 void suggestGnssTime(@NonNull GnssTimeSuggestion suggestion); 92 } 93