From 0c59c9c1669ed5c3a89d08b95f9204173af40635 Mon Sep 17 00:00:00 2001 From: Neil Fuller Date: Thu, 24 Sep 2020 17:40:14 +0100 Subject: [PATCH] Expose the LTZP in the location provider API Expose the LocationTimeZoneProvider and associated classes in the location lib API. Bug: 152744911 Test: build only Change-Id: Ib577bbdee10d7778e28fc1c6003cc97fdb15acb3 --- location/lib/api/current.txt | 32 +++++++++++++++++++ .../LocationTimeZoneEventUnbundled.java | 6 ---- .../LocationTimeZoneProviderBase.java | 8 ++--- ...ationTimeZoneProviderRequestUnbundled.java | 4 +-- 4 files changed, 38 insertions(+), 12 deletions(-) diff --git a/location/lib/api/current.txt b/location/lib/api/current.txt index c00ff57889d1c..f43eb639ee23f 100644 --- a/location/lib/api/current.txt +++ b/location/lib/api/current.txt @@ -59,3 +59,35 @@ package com.android.location.provider { } +package com.android.location.timezone.provider { + + public final class LocationTimeZoneEventUnbundled { + method public int getEventType(); + method @NonNull public java.util.List getTimeZoneIds(); + field public static final int EVENT_TYPE_PERMANENT_FAILURE = 1; // 0x1 + field public static final int EVENT_TYPE_SUCCESS = 2; // 0x2 + field public static final int EVENT_TYPE_UNCERTAIN = 3; // 0x3 + } + + public static final class LocationTimeZoneEventUnbundled.Builder { + ctor public LocationTimeZoneEventUnbundled.Builder(); + method @NonNull public com.android.location.timezone.provider.LocationTimeZoneEventUnbundled build(); + method @NonNull public com.android.location.timezone.provider.LocationTimeZoneEventUnbundled.Builder setEventType(int); + method @NonNull public com.android.location.timezone.provider.LocationTimeZoneEventUnbundled.Builder setTimeZoneIds(@NonNull java.util.List); + } + + public abstract class LocationTimeZoneProviderBase { + ctor public LocationTimeZoneProviderBase(android.content.Context, String); + method public final android.os.IBinder getBinder(); + method protected final android.content.Context getContext(); + method protected abstract void onSetRequest(@NonNull com.android.location.timezone.provider.LocationTimeZoneProviderRequestUnbundled); + method protected final void reportLocationTimeZoneEvent(@NonNull com.android.location.timezone.provider.LocationTimeZoneEventUnbundled); + } + + public final class LocationTimeZoneProviderRequestUnbundled { + method @IntRange(from=0) public long getInitializationTimeoutMillis(); + method public boolean getReportLocationTimeZone(); + } + +} + diff --git a/location/lib/java/com/android/location/timezone/provider/LocationTimeZoneEventUnbundled.java b/location/lib/java/com/android/location/timezone/provider/LocationTimeZoneEventUnbundled.java index 367557442829c..aa0e8951f77cc 100644 --- a/location/lib/java/com/android/location/timezone/provider/LocationTimeZoneEventUnbundled.java +++ b/location/lib/java/com/android/location/timezone/provider/LocationTimeZoneEventUnbundled.java @@ -18,7 +18,6 @@ package com.android.location.timezone.provider; import android.annotation.IntDef; import android.annotation.NonNull; -import android.annotation.Nullable; import android.app.ActivityManager; import android.location.timezone.LocationTimeZoneEvent; import android.os.SystemClock; @@ -31,8 +30,6 @@ import java.util.Objects; /** * An event from a {@link LocationTimeZoneProviderBase} sent while determining a device's time zone * using its location. - * - * @hide */ public final class LocationTimeZoneEventUnbundled { @@ -69,7 +66,6 @@ public final class LocationTimeZoneEventUnbundled { /** * Returns the event type. */ - @Nullable public @EventType int getEventType() { return mDelegate.getEventType(); } @@ -118,8 +114,6 @@ public final class LocationTimeZoneEventUnbundled { /** * A builder of {@link LocationTimeZoneEventUnbundled} instances. - * - * @hide */ public static final class Builder { diff --git a/location/lib/java/com/android/location/timezone/provider/LocationTimeZoneProviderBase.java b/location/lib/java/com/android/location/timezone/provider/LocationTimeZoneProviderBase.java index 9df71664ee1bf..68ae722d703d0 100644 --- a/location/lib/java/com/android/location/timezone/provider/LocationTimeZoneProviderBase.java +++ b/location/lib/java/com/android/location/timezone/provider/LocationTimeZoneProviderBase.java @@ -16,6 +16,7 @@ package com.android.location.timezone.provider; +import android.annotation.NonNull; import android.annotation.Nullable; import android.content.Context; import android.os.IBinder; @@ -55,8 +56,6 @@ import java.util.Objects; * *

IMPORTANT: This class is effectively a public API for unbundled applications, and must remain * API stable. - * - * @hide */ public abstract class LocationTimeZoneProviderBase { @@ -85,7 +84,8 @@ public abstract class LocationTimeZoneProviderBase { /** * Reports a new location time zone event from this provider. */ - protected void reportLocationTimeZoneEvent(LocationTimeZoneEventUnbundled event) { + protected final void reportLocationTimeZoneEvent( + @NonNull LocationTimeZoneEventUnbundled event) { ILocationTimeZoneProviderManager manager = mManager; if (manager != null) { try { @@ -102,7 +102,7 @@ public abstract class LocationTimeZoneProviderBase { * to start returning location time zones, or to stop returning location time zones, depending * on the parameters in the request. */ - protected abstract void onSetRequest(LocationTimeZoneProviderRequestUnbundled request); + protected abstract void onSetRequest(@NonNull LocationTimeZoneProviderRequestUnbundled request); private final class Service extends ILocationTimeZoneProvider.Stub { diff --git a/location/lib/java/com/android/location/timezone/provider/LocationTimeZoneProviderRequestUnbundled.java b/location/lib/java/com/android/location/timezone/provider/LocationTimeZoneProviderRequestUnbundled.java index ab50dc3b00fce..10d103841bab6 100644 --- a/location/lib/java/com/android/location/timezone/provider/LocationTimeZoneProviderRequestUnbundled.java +++ b/location/lib/java/com/android/location/timezone/provider/LocationTimeZoneProviderRequestUnbundled.java @@ -16,6 +16,7 @@ package com.android.location.timezone.provider; +import android.annotation.IntRange; import android.annotation.NonNull; import com.android.internal.location.timezone.LocationTimeZoneProviderRequest; @@ -27,8 +28,6 @@ import java.util.Objects; * *

IMPORTANT: This class is effectively a public API for unbundled code, and must remain API * stable. - * - * @hide */ public final class LocationTimeZoneProviderRequestUnbundled { @@ -54,6 +53,7 @@ public final class LocationTimeZoneProviderRequestUnbundled { * true}. Failure to send an event in this time (with some fuzz) may be interpreted as if the * provider is uncertain of the time zone, and/or it could lead to the provider being disabled. */ + @IntRange(from = 0) public long getInitializationTimeoutMillis() { return mRequest.getInitializationTimeoutMillis(); }