diff options
| author | Neil Fuller <nfuller@google.com> | 2018-06-25 18:47:39 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2018-06-25 18:47:39 +0000 |
| commit | 4d9f7a8bc34a3944e4b3b4922dfe2be47b46da85 (patch) | |
| tree | 54180730bfa3e94c65bd2481c011d263cf5eebf6 /core/java | |
| parent | 67f17cd6903127605cbae91198f52c1c514146ac (diff) | |
| parent | 7fb88c3928b6fef1f3d559ea23468ccd1379bd49 (diff) | |
Merge "Minimum viable TimeZoneDetectorService"
Diffstat (limited to 'core/java')
4 files changed, 109 insertions, 0 deletions
diff --git a/core/java/android/app/SystemServiceRegistry.java b/core/java/android/app/SystemServiceRegistry.java index 98dc237d93a1..b432baad04e6 100644 --- a/core/java/android/app/SystemServiceRegistry.java +++ b/core/java/android/app/SystemServiceRegistry.java @@ -26,6 +26,7 @@ import android.app.job.JobScheduler; import android.app.slice.SliceManager; import android.app.timedetector.TimeDetector; import android.app.timezone.RulesManager; +import android.app.timezonedetector.TimeZoneDetector; import android.app.trust.TrustManager; import android.app.usage.IStorageStatsManager; import android.app.usage.IUsageStatsManager; @@ -1033,6 +1034,13 @@ final class SystemServiceRegistry { throws ServiceNotFoundException { return new TimeDetector(); }}); + registerService(Context.TIME_ZONE_DETECTOR_SERVICE, TimeZoneDetector.class, + new CachedServiceFetcher<TimeZoneDetector>() { + @Override + public TimeZoneDetector createService(ContextImpl ctx) + throws ServiceNotFoundException { + return new TimeZoneDetector(); + }}); } /** diff --git a/core/java/android/app/timezonedetector/ITimeZoneDetectorService.aidl b/core/java/android/app/timezonedetector/ITimeZoneDetectorService.aidl new file mode 100644 index 000000000000..ef2cbab137dc --- /dev/null +++ b/core/java/android/app/timezonedetector/ITimeZoneDetectorService.aidl @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2018 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.timezonedetector; + +/** + * System private API to comunicate with time zone detector service. + * + * <p>Used by parts of the Android system with signals associated with the device's time zone to + * provide information to the Time Zone Detector Service. + * + * <p>Use the {@link android.app.timezonedetector.TimeZoneDetector} class rather than going through + * this Binder interface directly. See {@link android.app.timezonedetector.TimeZoneDetectorService} + * for more complete documentation. + * + * + * {@hide} + */ +interface ITimeZoneDetectorService { + void stubbedCall(); +} diff --git a/core/java/android/app/timezonedetector/TimeZoneDetector.java b/core/java/android/app/timezonedetector/TimeZoneDetector.java new file mode 100644 index 000000000000..be3c7649a486 --- /dev/null +++ b/core/java/android/app/timezonedetector/TimeZoneDetector.java @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2018 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.timezonedetector; + +import android.annotation.SystemService; +import android.content.Context; +import android.os.RemoteException; +import android.os.ServiceManager; +import android.os.ServiceManager.ServiceNotFoundException; +import android.util.Log; + +/** + * The interface through which system components can send signals to the TimeZoneDetectorService. + * @hide + */ +@SystemService(Context.TIME_ZONE_DETECTOR_SERVICE) +public final class TimeZoneDetector { + + private static final String TAG = "timezonedetector.TimeZoneDetector"; + private static final boolean DEBUG = false; + + private final ITimeZoneDetectorService mITimeZoneDetectorService; + + public TimeZoneDetector() throws ServiceNotFoundException { + mITimeZoneDetectorService = ITimeZoneDetectorService.Stub.asInterface( + ServiceManager.getServiceOrThrow(Context.TIME_ZONE_DETECTOR_SERVICE)); + + } + /** + * Does nothing. + * TODO: Remove this when the service implementation is built out. + */ + public void stubbedCall() { + if (DEBUG) { + Log.d(TAG, "stubbedCall called"); + } + try { + mITimeZoneDetectorService.stubbedCall(); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } +} diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java index 5e96b92a429c..c515bce6eb6f 100644 --- a/core/java/android/content/Context.java +++ b/core/java/android/content/Context.java @@ -3061,6 +3061,7 @@ public abstract class Context { CROSS_PROFILE_APPS_SERVICE, //@hide: SYSTEM_UPDATE_SERVICE, //@hide: TIME_DETECTOR_SERVICE, + //@hide: TIME_ZONE_DETECTOR_SERVICE, }) @Retention(RetentionPolicy.SOURCE) public @interface ServiceName {} @@ -4244,6 +4245,15 @@ public abstract class Context { public static final String TIME_DETECTOR_SERVICE = "time_detector"; /** + * Use with {@link #getSystemService(String)} to retrieve an + * {@link android.app.timezonedetector.ITimeZoneDetectorService}. + * @hide + * + * @see #getSystemService(String) + */ + public static final String TIME_ZONE_DETECTOR_SERVICE = "time_zone_detector"; + + /** * Determine whether the given permission is allowed for a particular * process and user ID running in the system. * |
