• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.timezonedetector;
18 
19 import android.annotation.NonNull;
20 import android.annotation.RequiresPermission;
21 import android.annotation.SystemService;
22 import android.content.Context;
23 
24 /**
25  * The interface through which system components can send signals to the TimeZoneDetectorService.
26  *
27  * @hide
28  */
29 @SystemService(Context.TIME_ZONE_DETECTOR_SERVICE)
30 public interface TimeZoneDetector {
31 
32     /**
33      * The name of the service for shell commands.
34      * @hide
35      */
36     String SHELL_COMMAND_SERVICE_NAME = "time_zone_detector";
37 
38     /**
39      * A shell command that prints the current "auto time zone detection" global setting value.
40      * @hide
41      */
42     String SHELL_COMMAND_IS_AUTO_DETECTION_ENABLED = "is_auto_detection_enabled";
43 
44     /**
45      * A shell command that sets the current "auto time zone detection" global setting value.
46      * @hide
47      */
48     String SHELL_COMMAND_SET_AUTO_DETECTION_ENABLED = "set_auto_detection_enabled";
49 
50     /**
51      * A shell command that prints whether the telephony-based time zone detection feature is
52      * supported on the device.
53      * @hide
54      */
55     String SHELL_COMMAND_IS_TELEPHONY_DETECTION_SUPPORTED = "is_telephony_detection_supported";
56 
57     /**
58      * A shell command that prints whether the geolocation-based time zone detection feature is
59      * supported on the device.
60      * @hide
61      */
62     String SHELL_COMMAND_IS_GEO_DETECTION_SUPPORTED = "is_geo_detection_supported";
63 
64     /**
65      * A shell command that prints the current user's "location-based time zone detection enabled"
66      * setting.
67      * @hide
68      */
69     String SHELL_COMMAND_IS_GEO_DETECTION_ENABLED = "is_geo_detection_enabled";
70 
71     /**
72      * A shell command that sets the current user's "location-based time zone detection enabled"
73      * setting.
74      * @hide
75      */
76     String SHELL_COMMAND_SET_GEO_DETECTION_ENABLED = "set_geo_detection_enabled";
77 
78     /**
79      * A shell command that injects a geolocation time zone suggestion (as if from the
80      * location_time_zone_manager).
81      * @hide
82      */
83     String SHELL_COMMAND_SUGGEST_GEO_LOCATION_TIME_ZONE = "suggest_geo_location_time_zone";
84 
85     /**
86      * A shell command that injects a manual time zone suggestion (as if from the SettingsUI or
87      * similar).
88      * @hide
89      */
90     String SHELL_COMMAND_SUGGEST_MANUAL_TIME_ZONE = "suggest_manual_time_zone";
91 
92     /**
93      * A shell command that injects a telephony time zone suggestion (as if from the phone app).
94      * @hide
95      */
96     String SHELL_COMMAND_SUGGEST_TELEPHONY_TIME_ZONE = "suggest_telephony_time_zone";
97 
98     /**
99      * A shared utility method to create a {@link ManualTimeZoneSuggestion}.
100      *
101      * @hide
102      */
createManualTimeZoneSuggestion(String tzId, String debugInfo)103     static ManualTimeZoneSuggestion createManualTimeZoneSuggestion(String tzId, String debugInfo) {
104         ManualTimeZoneSuggestion suggestion = new ManualTimeZoneSuggestion(tzId);
105         suggestion.addDebugInfo(debugInfo);
106         return suggestion;
107     }
108 
109     /**
110      * Suggests the current time zone, determined from the user's manually entered information, to
111      * the detector. Returns {@code false} if the suggestion was invalid, or the device
112      * configuration / user capabilities prevents the suggestion being used (even if it is the same
113      * as the current device time zone), {@code true} if the suggestion was accepted. A suggestion
114      * that is valid but does not change the time zone because it matches the current device time
115      * zone is considered accepted.
116      *
117      * @hide
118      */
119     @RequiresPermission(android.Manifest.permission.SUGGEST_MANUAL_TIME_AND_ZONE)
suggestManualTimeZone(@onNull ManualTimeZoneSuggestion timeZoneSuggestion)120     boolean suggestManualTimeZone(@NonNull ManualTimeZoneSuggestion timeZoneSuggestion);
121 
122     /**
123      * Suggests the current time zone, determined using telephony signals, to the detector. The
124      * detector may ignore the signal based on system settings, whether better information is
125      * available, and so on.
126      *
127      * @hide
128      */
129     @RequiresPermission(android.Manifest.permission.SUGGEST_TELEPHONY_TIME_AND_ZONE)
suggestTelephonyTimeZone(@onNull TelephonyTimeZoneSuggestion timeZoneSuggestion)130     void suggestTelephonyTimeZone(@NonNull TelephonyTimeZoneSuggestion timeZoneSuggestion);
131 }
132