summaryrefslogtreecommitdiff
path: root/location/lib/java
diff options
context:
space:
mode:
author Neil Fuller <nfuller@google.com> 2020-12-14 21:13:55 +0000
committer Neil Fuller <nfuller@google.com> 2021-01-05 20:36:29 +0000
commit204b52a384f3f217ab2fcc16867a7f90291b41b5 (patch)
treefb55fc6fcd49b8e3f1a3ddafbe53688f87ac4ed3 /location/lib/java
parentfa2a82b01dd316d3aa60a4e10dd8de0e09b087fc (diff)
Delete location.timezone.provider API classes
Delete location.timezone.provider API classes and associated internal classes that are no longer used. Bug: 175633818 Test: build Change-Id: I66319e63e3150e3b71f31f8d9404e4114f802662
Diffstat (limited to 'location/lib/java')
-rw-r--r--location/lib/java/com/android/location/timezone/provider/LocationTimeZoneEventUnbundled.java164
-rw-r--r--location/lib/java/com/android/location/timezone/provider/LocationTimeZoneProviderBase.java119
-rw-r--r--location/lib/java/com/android/location/timezone/provider/LocationTimeZoneProviderRequestUnbundled.java83
3 files changed, 0 insertions, 366 deletions
diff --git a/location/lib/java/com/android/location/timezone/provider/LocationTimeZoneEventUnbundled.java b/location/lib/java/com/android/location/timezone/provider/LocationTimeZoneEventUnbundled.java
deleted file mode 100644
index 55f554554474..000000000000
--- a/location/lib/java/com/android/location/timezone/provider/LocationTimeZoneEventUnbundled.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Copyright (C) 2020 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 com.android.location.timezone.provider;
-
-import android.annotation.IntDef;
-import android.annotation.NonNull;
-import android.os.SystemClock;
-
-import com.android.internal.location.timezone.LocationTimeZoneEvent;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Objects;
-
-/**
- * An event from a {@link LocationTimeZoneProviderBase} sent while determining a device's time zone
- * using its location.
- */
-public final class LocationTimeZoneEventUnbundled {
-
- @IntDef({ EVENT_TYPE_PERMANENT_FAILURE, EVENT_TYPE_SUCCESS, EVENT_TYPE_UNCERTAIN })
- @interface EventType {}
-
- /**
- * Indicates there was a permanent failure. This is not generally expected, and probably means a
- * required backend service has been turned down, or the client is unreasonably old.
- */
- public static final int EVENT_TYPE_PERMANENT_FAILURE =
- LocationTimeZoneEvent.EVENT_TYPE_PERMANENT_FAILURE;
-
- /**
- * Indicates a successful geolocation time zone detection event. {@link #getTimeZoneIds()} will
- * be non-null but can legitimately be empty, e.g. for disputed areas, oceans.
- */
- public static final int EVENT_TYPE_SUCCESS = LocationTimeZoneEvent.EVENT_TYPE_SUCCESS;
-
- /**
- * Indicates the time zone is not known because of an expected runtime state or error, e.g. when
- * the provider is unable to detect location, or there was a problem when resolving the location
- * to a time zone.
- */
- public static final int EVENT_TYPE_UNCERTAIN = LocationTimeZoneEvent.EVENT_TYPE_UNCERTAIN;
-
- @NonNull
- private final LocationTimeZoneEvent mDelegate;
-
- private LocationTimeZoneEventUnbundled(@NonNull LocationTimeZoneEvent delegate) {
- mDelegate = Objects.requireNonNull(delegate);
- }
-
- /**
- * Returns the event type.
- */
- public @EventType int getEventType() {
- return mDelegate.getEventType();
- }
-
- /**
- * Gets the time zone IDs of this event. Contains zero or more IDs for a successful lookup.
- * The value is undefined for an unsuccessful lookup. See also {@link #getEventType()}.
- */
- @NonNull
- public List<String> getTimeZoneIds() {
- return mDelegate.getTimeZoneIds();
- }
-
- /**
- * Returns the information from this as a {@link LocationTimeZoneEvent}.
- * @hide
- */
- @NonNull
- public LocationTimeZoneEvent getInternalLocationTimeZoneEvent() {
- return mDelegate;
- }
-
- @Override
- public String toString() {
- return "LocationTimeZoneEventUnbundled{"
- + "mDelegate=" + mDelegate
- + '}';
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- LocationTimeZoneEventUnbundled that = (LocationTimeZoneEventUnbundled) o;
- return mDelegate.equals(that.mDelegate);
- }
-
- @Override
- public int hashCode() {
- return mDelegate.hashCode();
- }
-
- /**
- * A builder of {@link LocationTimeZoneEventUnbundled} instances.
- */
- public static final class Builder {
-
- private @EventType int mEventType;
- private @NonNull List<String> mTimeZoneIds = Collections.emptyList();
-
- /**
- * Set the time zone ID of this event.
- */
- @NonNull
- public Builder setEventType(@EventType int eventType) {
- checkValidEventType(eventType);
- mEventType = eventType;
- return this;
- }
-
- /**
- * Sets the time zone IDs of this event.
- */
- @NonNull
- public Builder setTimeZoneIds(@NonNull List<String> timeZoneIds) {
- mTimeZoneIds = Objects.requireNonNull(timeZoneIds);
- return this;
- }
-
- /**
- * Builds a {@link LocationTimeZoneEventUnbundled} instance.
- */
- @NonNull
- public LocationTimeZoneEventUnbundled build() {
- final int internalEventType = this.mEventType;
- LocationTimeZoneEvent event = new LocationTimeZoneEvent.Builder()
- .setEventType(internalEventType)
- .setTimeZoneIds(mTimeZoneIds)
- .setElapsedRealtimeMillis(SystemClock.elapsedRealtime())
- .build();
- return new LocationTimeZoneEventUnbundled(event);
- }
- }
-
- private static int checkValidEventType(int eventType) {
- if (eventType != EVENT_TYPE_SUCCESS
- && eventType != EVENT_TYPE_UNCERTAIN
- && eventType != EVENT_TYPE_PERMANENT_FAILURE) {
- throw new IllegalStateException("eventType=" + eventType);
- }
- return eventType;
- }
-}
diff --git a/location/lib/java/com/android/location/timezone/provider/LocationTimeZoneProviderBase.java b/location/lib/java/com/android/location/timezone/provider/LocationTimeZoneProviderBase.java
deleted file mode 100644
index 68ae722d703d..000000000000
--- a/location/lib/java/com/android/location/timezone/provider/LocationTimeZoneProviderBase.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Copyright (C) 2020 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 com.android.location.timezone.provider;
-
-import android.annotation.NonNull;
-import android.annotation.Nullable;
-import android.content.Context;
-import android.os.IBinder;
-import android.os.RemoteException;
-import android.util.Log;
-
-import com.android.internal.location.timezone.ILocationTimeZoneProvider;
-import com.android.internal.location.timezone.ILocationTimeZoneProviderManager;
-import com.android.internal.location.timezone.LocationTimeZoneProviderRequest;
-
-import java.util.Objects;
-
-/**
- * A base class for location time zone providers implemented as unbundled services.
- *
- * <p>Provider implementations are enabled / disabled via a call to {@link
- * #onSetRequest(LocationTimeZoneProviderRequestUnbundled)}.
- *
- * <p>Once enabled, providers are expected to detect the time zone if possible, and report the
- * result via {@link #reportLocationTimeZoneEvent(LocationTimeZoneEventUnbundled)} with a type of
- * either {@link LocationTimeZoneEventUnbundled#EVENT_TYPE_UNCERTAIN} or {@link
- * LocationTimeZoneEventUnbundled#EVENT_TYPE_SUCCESS}. Providers may also report that they have
- * permanently failed by sending an event of type {@link
- * LocationTimeZoneEventUnbundled#EVENT_TYPE_PERMANENT_FAILURE}. See the javadocs for each event
- * type for details.
- *
- * <p>Providers are expected to issue their first event within {@link
- * LocationTimeZoneProviderRequest#getInitializationTimeoutMillis()}.
- *
- * <p>Once disabled or have failed, providers are required to stop producing events.
- *
- * <p>Threading:
- *
- * <p>Calls to {@link #reportLocationTimeZoneEvent(LocationTimeZoneEventUnbundled)} can be made on
- * on any thread, but may be processed asynchronously by the system server. Similarly, calls to
- * {@link #onSetRequest(LocationTimeZoneProviderRequestUnbundled)} may occur on any thread.
- *
- * <p>IMPORTANT: This class is effectively a public API for unbundled applications, and must remain
- * API stable.
- */
-public abstract class LocationTimeZoneProviderBase {
-
- private final Context mContext;
- private final String mTag;
- private final IBinder mBinder;
-
- // write locked on mBinder, read lock is optional depending on atomicity requirements
- @Nullable private volatile ILocationTimeZoneProviderManager mManager;
-
- public LocationTimeZoneProviderBase(Context context, String tag) {
- mContext = context;
- mTag = tag;
- mBinder = new Service();
- mManager = null;
- }
-
- protected final Context getContext() {
- return mContext;
- }
-
- public final IBinder getBinder() {
- return mBinder;
- }
-
- /**
- * Reports a new location time zone event from this provider.
- */
- protected final void reportLocationTimeZoneEvent(
- @NonNull LocationTimeZoneEventUnbundled event) {
- ILocationTimeZoneProviderManager manager = mManager;
- if (manager != null) {
- try {
- manager.onLocationTimeZoneEvent(event.getInternalLocationTimeZoneEvent());
- } catch (RemoteException | RuntimeException e) {
- Log.w(mTag, e);
- }
- }
- }
-
- /**
- * Set the {@link LocationTimeZoneProviderRequestUnbundled} requirements for this provider. Each
- * call to this method overrides all previous requests. This method might trigger the provider
- * to start returning location time zones, or to stop returning location time zones, depending
- * on the parameters in the request.
- */
- protected abstract void onSetRequest(@NonNull LocationTimeZoneProviderRequestUnbundled request);
-
- private final class Service extends ILocationTimeZoneProvider.Stub {
-
- @Override
- public void setLocationTimeZoneProviderManager(ILocationTimeZoneProviderManager manager) {
- mManager = Objects.requireNonNull(manager);
- }
-
- @Override
- public void setRequest(LocationTimeZoneProviderRequest request) {
- onSetRequest(new LocationTimeZoneProviderRequestUnbundled(request));
- }
- }
-}
diff --git a/location/lib/java/com/android/location/timezone/provider/LocationTimeZoneProviderRequestUnbundled.java b/location/lib/java/com/android/location/timezone/provider/LocationTimeZoneProviderRequestUnbundled.java
deleted file mode 100644
index 10d103841bab..000000000000
--- a/location/lib/java/com/android/location/timezone/provider/LocationTimeZoneProviderRequestUnbundled.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (C) 2020 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 com.android.location.timezone.provider;
-
-import android.annotation.IntRange;
-import android.annotation.NonNull;
-
-import com.android.internal.location.timezone.LocationTimeZoneProviderRequest;
-
-import java.util.Objects;
-
-/**
- * This class is an interface to LocationTimeZoneProviderRequest for provider implementations.
- *
- * <p>IMPORTANT: This class is effectively a public API for unbundled code, and must remain API
- * stable.
- */
-public final class LocationTimeZoneProviderRequestUnbundled {
-
- private final LocationTimeZoneProviderRequest mRequest;
-
- /** @hide */
- public LocationTimeZoneProviderRequestUnbundled(
- @NonNull LocationTimeZoneProviderRequest request) {
- mRequest = Objects.requireNonNull(request);
- }
-
- /**
- * Returns {@code true} if the provider should report events related to the device's current
- * time zone, {@code false} otherwise.
- */
- public boolean getReportLocationTimeZone() {
- return mRequest.getReportLocationTimeZone();
- }
-
- /**
- * Returns the maximum time that the provider is allowed to initialize before it is expected to
- * send an event of any sort. Only valid when {@link #getReportLocationTimeZone()} is {@code
- * 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();
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- LocationTimeZoneProviderRequestUnbundled that =
- (LocationTimeZoneProviderRequestUnbundled) o;
- return mRequest.equals(that.mRequest);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(mRequest);
- }
-
- @Override
- public String toString() {
- return mRequest.toString();
- }
-}