Merge "Expose time / time zone system apis for telephony"
This commit is contained in:
@@ -1 +1,81 @@
|
|||||||
// Signature format: 2.0
|
// Signature format: 2.0
|
||||||
|
package android.app.timedetector {
|
||||||
|
|
||||||
|
public final class PhoneTimeSuggestion implements android.os.Parcelable {
|
||||||
|
method public void addDebugInfo(@NonNull String);
|
||||||
|
method public void addDebugInfo(@NonNull java.util.List<java.lang.String>);
|
||||||
|
method public int describeContents();
|
||||||
|
method @NonNull public java.util.List<java.lang.String> getDebugInfo();
|
||||||
|
method public int getPhoneId();
|
||||||
|
method @Nullable public android.os.TimestampedValue<java.lang.Long> getUtcTime();
|
||||||
|
method public void writeToParcel(@NonNull android.os.Parcel, int);
|
||||||
|
field @NonNull public static final android.os.Parcelable.Creator<android.app.timedetector.PhoneTimeSuggestion> CREATOR;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class PhoneTimeSuggestion.Builder {
|
||||||
|
ctor public PhoneTimeSuggestion.Builder(int);
|
||||||
|
method @NonNull public android.app.timedetector.PhoneTimeSuggestion.Builder addDebugInfo(@NonNull String);
|
||||||
|
method @NonNull public android.app.timedetector.PhoneTimeSuggestion build();
|
||||||
|
method @NonNull public android.app.timedetector.PhoneTimeSuggestion.Builder setUtcTime(@Nullable android.os.TimestampedValue<java.lang.Long>);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class TimeDetector {
|
||||||
|
method @RequiresPermission("android.permission.SUGGEST_PHONE_TIME_AND_ZONE") public void suggestPhoneTime(@NonNull android.app.timedetector.PhoneTimeSuggestion);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
package android.app.timezonedetector {
|
||||||
|
|
||||||
|
public final class PhoneTimeZoneSuggestion implements android.os.Parcelable {
|
||||||
|
method public void addDebugInfo(@NonNull String);
|
||||||
|
method public void addDebugInfo(@NonNull java.util.List<java.lang.String>);
|
||||||
|
method @NonNull public static android.app.timezonedetector.PhoneTimeZoneSuggestion createEmptySuggestion(int, @NonNull String);
|
||||||
|
method public int describeContents();
|
||||||
|
method @NonNull public java.util.List<java.lang.String> getDebugInfo();
|
||||||
|
method public int getMatchType();
|
||||||
|
method public int getPhoneId();
|
||||||
|
method public int getQuality();
|
||||||
|
method @Nullable public String getZoneId();
|
||||||
|
method public void writeToParcel(@NonNull android.os.Parcel, int);
|
||||||
|
field @NonNull public static final android.os.Parcelable.Creator<android.app.timezonedetector.PhoneTimeZoneSuggestion> CREATOR;
|
||||||
|
field public static final int MATCH_TYPE_EMULATOR_ZONE_ID = 4; // 0x4
|
||||||
|
field public static final int MATCH_TYPE_NA = 0; // 0x0
|
||||||
|
field public static final int MATCH_TYPE_NETWORK_COUNTRY_AND_OFFSET = 3; // 0x3
|
||||||
|
field public static final int MATCH_TYPE_NETWORK_COUNTRY_ONLY = 2; // 0x2
|
||||||
|
field public static final int MATCH_TYPE_TEST_NETWORK_OFFSET_ONLY = 5; // 0x5
|
||||||
|
field public static final int QUALITY_MULTIPLE_ZONES_WITH_DIFFERENT_OFFSETS = 3; // 0x3
|
||||||
|
field public static final int QUALITY_MULTIPLE_ZONES_WITH_SAME_OFFSET = 2; // 0x2
|
||||||
|
field public static final int QUALITY_NA = 0; // 0x0
|
||||||
|
field public static final int QUALITY_SINGLE_ZONE = 1; // 0x1
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class PhoneTimeZoneSuggestion.Builder {
|
||||||
|
ctor public PhoneTimeZoneSuggestion.Builder(int);
|
||||||
|
method @NonNull public android.app.timezonedetector.PhoneTimeZoneSuggestion.Builder addDebugInfo(@NonNull String);
|
||||||
|
method @NonNull public android.app.timezonedetector.PhoneTimeZoneSuggestion build();
|
||||||
|
method @NonNull public android.app.timezonedetector.PhoneTimeZoneSuggestion.Builder setMatchType(int);
|
||||||
|
method @NonNull public android.app.timezonedetector.PhoneTimeZoneSuggestion.Builder setQuality(int);
|
||||||
|
method @NonNull public android.app.timezonedetector.PhoneTimeZoneSuggestion.Builder setZoneId(@Nullable String);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class TimeZoneDetector {
|
||||||
|
method @RequiresPermission("android.permission.SUGGEST_PHONE_TIME_AND_ZONE") public void suggestPhoneTimeZone(@NonNull android.app.timezonedetector.PhoneTimeZoneSuggestion);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
package android.os {
|
||||||
|
|
||||||
|
public final class TimestampedValue<T> implements android.os.Parcelable {
|
||||||
|
ctor public TimestampedValue(long, @Nullable T);
|
||||||
|
method public int describeContents();
|
||||||
|
method public long getReferenceTimeMillis();
|
||||||
|
method @Nullable public T getValue();
|
||||||
|
method public static long referenceTimeDifference(@NonNull android.os.TimestampedValue<?>, @NonNull android.os.TimestampedValue<?>);
|
||||||
|
method public void writeToParcel(@NonNull android.os.Parcel, int);
|
||||||
|
field @NonNull public static final android.os.Parcelable.Creator<android.os.TimestampedValue<?>> CREATOR;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -200,6 +200,7 @@ package android {
|
|||||||
field public static final String STOP_APP_SWITCHES = "android.permission.STOP_APP_SWITCHES";
|
field public static final String STOP_APP_SWITCHES = "android.permission.STOP_APP_SWITCHES";
|
||||||
field public static final String SUBSTITUTE_NOTIFICATION_APP_NAME = "android.permission.SUBSTITUTE_NOTIFICATION_APP_NAME";
|
field public static final String SUBSTITUTE_NOTIFICATION_APP_NAME = "android.permission.SUBSTITUTE_NOTIFICATION_APP_NAME";
|
||||||
field public static final String SUBSTITUTE_SHARE_TARGET_APP_NAME_AND_ICON = "android.permission.SUBSTITUTE_SHARE_TARGET_APP_NAME_AND_ICON";
|
field public static final String SUBSTITUTE_SHARE_TARGET_APP_NAME_AND_ICON = "android.permission.SUBSTITUTE_SHARE_TARGET_APP_NAME_AND_ICON";
|
||||||
|
field public static final String SUGGEST_PHONE_TIME_AND_ZONE = "android.permission.SUGGEST_PHONE_TIME_AND_ZONE";
|
||||||
field public static final String SUSPEND_APPS = "android.permission.SUSPEND_APPS";
|
field public static final String SUSPEND_APPS = "android.permission.SUSPEND_APPS";
|
||||||
field public static final String TETHER_PRIVILEGED = "android.permission.TETHER_PRIVILEGED";
|
field public static final String TETHER_PRIVILEGED = "android.permission.TETHER_PRIVILEGED";
|
||||||
field public static final String TV_INPUT_HARDWARE = "android.permission.TV_INPUT_HARDWARE";
|
field public static final String TV_INPUT_HARDWARE = "android.permission.TV_INPUT_HARDWARE";
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ package android.app.timedetector;
|
|||||||
|
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
|
import android.annotation.SystemApi;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import android.os.TimestampedValue;
|
import android.os.TimestampedValue;
|
||||||
@@ -28,17 +29,23 @@ import java.util.List;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A time signal from a telephony source. The value can be {@code null} to indicate that the
|
* A time suggestion from an identified telephony source. e.g. from NITZ information from a specific
|
||||||
* telephony source has entered an "un-opinionated" state and any previously sent suggestions are
|
* radio.
|
||||||
* being withdrawn. When not {@code null}, the value consists of the number of milliseconds elapsed
|
*
|
||||||
* since 1/1/1970 00:00:00 UTC and the time according to the elapsed realtime clock when that number
|
* <p>The time value can be {@code null} to indicate that the telephony source has entered an
|
||||||
* was established. The elapsed realtime clock is considered accurate but volatile, so time signals
|
* "un-opinionated" state and any previous suggestions from the source are being withdrawn. When not
|
||||||
* must not be persisted across device resets.
|
* {@code null}, the value consists of the number of milliseconds elapsed since 1/1/1970 00:00:00
|
||||||
|
* UTC and the time according to the elapsed realtime clock when that number was established. The
|
||||||
|
* elapsed realtime clock is considered accurate but volatile, so time suggestions must not be
|
||||||
|
* persisted across device resets.
|
||||||
*
|
*
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
|
@SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
|
||||||
public final class PhoneTimeSuggestion implements Parcelable {
|
public final class PhoneTimeSuggestion implements Parcelable {
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
@SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
|
||||||
public static final @NonNull Parcelable.Creator<PhoneTimeSuggestion> CREATOR =
|
public static final @NonNull Parcelable.Creator<PhoneTimeSuggestion> CREATOR =
|
||||||
new Parcelable.Creator<PhoneTimeSuggestion>() {
|
new Parcelable.Creator<PhoneTimeSuggestion>() {
|
||||||
public PhoneTimeSuggestion createFromParcel(Parcel in) {
|
public PhoneTimeSuggestion createFromParcel(Parcel in) {
|
||||||
@@ -85,15 +92,27 @@ public final class PhoneTimeSuggestion implements Parcelable {
|
|||||||
dest.writeList(mDebugInfo);
|
dest.writeList(mDebugInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an identifier for the source of this suggestion. When a device has several "phones",
|
||||||
|
* i.e. sim slots or equivalent, it is used to identify which one.
|
||||||
|
*/
|
||||||
public int getPhoneId() {
|
public int getPhoneId() {
|
||||||
return mPhoneId;
|
return mPhoneId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the suggestion. {@code null} means that the caller is no longer sure what time it
|
||||||
|
* is.
|
||||||
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public TimestampedValue<Long> getUtcTime() {
|
public TimestampedValue<Long> getUtcTime() {
|
||||||
return mUtcTime;
|
return mUtcTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns debug metadata for the suggestion. The information is present in {@link #toString()}
|
||||||
|
* but is not considered for {@link #equals(Object)} and {@link #hashCode()}.
|
||||||
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
public List<String> getDebugInfo() {
|
public List<String> getDebugInfo() {
|
||||||
return mDebugInfo == null
|
return mDebugInfo == null
|
||||||
@@ -105,7 +124,7 @@ public final class PhoneTimeSuggestion implements Parcelable {
|
|||||||
* information is present in {@link #toString()} but is not considered for
|
* information is present in {@link #toString()} but is not considered for
|
||||||
* {@link #equals(Object)} and {@link #hashCode()}.
|
* {@link #equals(Object)} and {@link #hashCode()}.
|
||||||
*/
|
*/
|
||||||
public void addDebugInfo(String debugInfo) {
|
public void addDebugInfo(@NonNull String debugInfo) {
|
||||||
if (mDebugInfo == null) {
|
if (mDebugInfo == null) {
|
||||||
mDebugInfo = new ArrayList<>();
|
mDebugInfo = new ArrayList<>();
|
||||||
}
|
}
|
||||||
@@ -156,16 +175,19 @@ public final class PhoneTimeSuggestion implements Parcelable {
|
|||||||
*
|
*
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public static class Builder {
|
@SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
|
||||||
|
public static final class Builder {
|
||||||
private final int mPhoneId;
|
private final int mPhoneId;
|
||||||
private TimestampedValue<Long> mUtcTime;
|
@Nullable private TimestampedValue<Long> mUtcTime;
|
||||||
private List<String> mDebugInfo;
|
@Nullable private List<String> mDebugInfo;
|
||||||
|
|
||||||
|
/** Creates a builder with the specified {@code phoneId}. */
|
||||||
public Builder(int phoneId) {
|
public Builder(int phoneId) {
|
||||||
mPhoneId = phoneId;
|
mPhoneId = phoneId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the builder for call chaining. */
|
/** Returns the builder for call chaining. */
|
||||||
|
@NonNull
|
||||||
public Builder setUtcTime(@Nullable TimestampedValue<Long> utcTime) {
|
public Builder setUtcTime(@Nullable TimestampedValue<Long> utcTime) {
|
||||||
if (utcTime != null) {
|
if (utcTime != null) {
|
||||||
// utcTime can be null, but the value it holds cannot.
|
// utcTime can be null, but the value it holds cannot.
|
||||||
@@ -177,6 +199,7 @@ public final class PhoneTimeSuggestion implements Parcelable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the builder for call chaining. */
|
/** Returns the builder for call chaining. */
|
||||||
|
@NonNull
|
||||||
public Builder addDebugInfo(@NonNull String debugInfo) {
|
public Builder addDebugInfo(@NonNull String debugInfo) {
|
||||||
if (mDebugInfo == null) {
|
if (mDebugInfo == null) {
|
||||||
mDebugInfo = new ArrayList<>();
|
mDebugInfo = new ArrayList<>();
|
||||||
@@ -186,6 +209,7 @@ public final class PhoneTimeSuggestion implements Parcelable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the {@link PhoneTimeSuggestion}. */
|
/** Returns the {@link PhoneTimeSuggestion}. */
|
||||||
|
@NonNull
|
||||||
public PhoneTimeSuggestion build() {
|
public PhoneTimeSuggestion build() {
|
||||||
return new PhoneTimeSuggestion(this);
|
return new PhoneTimeSuggestion(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ package android.app.timedetector;
|
|||||||
|
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.annotation.RequiresPermission;
|
import android.annotation.RequiresPermission;
|
||||||
|
import android.annotation.SystemApi;
|
||||||
import android.annotation.SystemService;
|
import android.annotation.SystemService;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
@@ -29,8 +30,11 @@ import android.util.Log;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The interface through which system components can send signals to the TimeDetectorService.
|
* The interface through which system components can send signals to the TimeDetectorService.
|
||||||
|
*
|
||||||
|
* <p>This class is marked non-final for mockito.
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
|
@SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
|
||||||
@SystemService(Context.TIME_DETECTOR_SERVICE)
|
@SystemService(Context.TIME_DETECTOR_SERVICE)
|
||||||
public class TimeDetector {
|
public class TimeDetector {
|
||||||
private static final String TAG = "timedetector.TimeDetector";
|
private static final String TAG = "timedetector.TimeDetector";
|
||||||
@@ -38,6 +42,7 @@ public class TimeDetector {
|
|||||||
|
|
||||||
private final ITimeDetectorService mITimeDetectorService;
|
private final ITimeDetectorService mITimeDetectorService;
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
public TimeDetector() throws ServiceNotFoundException {
|
public TimeDetector() throws ServiceNotFoundException {
|
||||||
mITimeDetectorService = ITimeDetectorService.Stub.asInterface(
|
mITimeDetectorService = ITimeDetectorService.Stub.asInterface(
|
||||||
ServiceManager.getServiceOrThrow(Context.TIME_DETECTOR_SERVICE));
|
ServiceManager.getServiceOrThrow(Context.TIME_DETECTOR_SERVICE));
|
||||||
@@ -62,6 +67,8 @@ public class TimeDetector {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Suggests the user's manually entered current time to the detector.
|
* Suggests the user's manually entered current time to the detector.
|
||||||
|
*
|
||||||
|
* @hide
|
||||||
*/
|
*/
|
||||||
@RequiresPermission(android.Manifest.permission.SUGGEST_MANUAL_TIME_AND_ZONE)
|
@RequiresPermission(android.Manifest.permission.SUGGEST_MANUAL_TIME_AND_ZONE)
|
||||||
public void suggestManualTime(@NonNull ManualTimeSuggestion timeSuggestion) {
|
public void suggestManualTime(@NonNull ManualTimeSuggestion timeSuggestion) {
|
||||||
@@ -77,6 +84,8 @@ public class TimeDetector {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A shared utility method to create a {@link ManualTimeSuggestion}.
|
* A shared utility method to create a {@link ManualTimeSuggestion}.
|
||||||
|
*
|
||||||
|
* @hide
|
||||||
*/
|
*/
|
||||||
public static ManualTimeSuggestion createManualTimeSuggestion(long when, String why) {
|
public static ManualTimeSuggestion createManualTimeSuggestion(long when, String why) {
|
||||||
TimestampedValue<Long> utcTime =
|
TimestampedValue<Long> utcTime =
|
||||||
@@ -88,6 +97,8 @@ public class TimeDetector {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Suggests the time according to a network time source like NTP.
|
* Suggests the time according to a network time source like NTP.
|
||||||
|
*
|
||||||
|
* @hide
|
||||||
*/
|
*/
|
||||||
@RequiresPermission(android.Manifest.permission.SET_TIME)
|
@RequiresPermission(android.Manifest.permission.SET_TIME)
|
||||||
public void suggestNetworkTime(NetworkTimeSuggestion timeSuggestion) {
|
public void suggestNetworkTime(NetworkTimeSuggestion timeSuggestion) {
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package android.app.timezonedetector;
|
|||||||
import android.annotation.IntDef;
|
import android.annotation.IntDef;
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
|
import android.annotation.SystemApi;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
|
||||||
@@ -30,12 +31,27 @@ import java.util.List;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A suggested time zone from a Phone-based signal, e.g. from MCC and NITZ information.
|
* A time zone suggestion from an identified telephony source, e.g. from MCC and NITZ information
|
||||||
|
* associated with a specific radio.
|
||||||
|
*
|
||||||
|
* <p>The time zone ID can be {@code null} to indicate that the telephony source has entered an
|
||||||
|
* "un-opinionated" state and any previous suggestions from that source are being withdrawn.
|
||||||
|
* When not {@code null}, the value consists of a suggested time zone ID and metadata that can be
|
||||||
|
* used to judge quality / certainty of the suggestion.
|
||||||
|
*
|
||||||
|
* <p>{@code matchType} must be set to {@link #MATCH_TYPE_NA} when {@code zoneId} is {@code null},
|
||||||
|
* and one of the other {@code MATCH_TYPE_} values when it is not {@code null}.
|
||||||
|
*
|
||||||
|
* <p>{@code quality} must be set to {@link #QUALITY_NA} when {@code zoneId} is {@code null},
|
||||||
|
* and one of the other {@code QUALITY_} values when it is not {@code null}.
|
||||||
*
|
*
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
|
@SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
|
||||||
public final class PhoneTimeZoneSuggestion implements Parcelable {
|
public final class PhoneTimeZoneSuggestion implements Parcelable {
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
@SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
|
||||||
@NonNull
|
@NonNull
|
||||||
public static final Creator<PhoneTimeZoneSuggestion> CREATOR =
|
public static final Creator<PhoneTimeZoneSuggestion> CREATOR =
|
||||||
new Creator<PhoneTimeZoneSuggestion>() {
|
new Creator<PhoneTimeZoneSuggestion>() {
|
||||||
@@ -58,6 +74,7 @@ public final class PhoneTimeZoneSuggestion implements Parcelable {
|
|||||||
return new Builder(phoneId).addDebugInfo(debugInfo).build();
|
return new Builder(phoneId).addDebugInfo(debugInfo).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
@IntDef({ MATCH_TYPE_NA, MATCH_TYPE_NETWORK_COUNTRY_ONLY, MATCH_TYPE_NETWORK_COUNTRY_AND_OFFSET,
|
@IntDef({ MATCH_TYPE_NA, MATCH_TYPE_NETWORK_COUNTRY_ONLY, MATCH_TYPE_NETWORK_COUNTRY_AND_OFFSET,
|
||||||
MATCH_TYPE_EMULATOR_ZONE_ID, MATCH_TYPE_TEST_NETWORK_OFFSET_ONLY })
|
MATCH_TYPE_EMULATOR_ZONE_ID, MATCH_TYPE_TEST_NETWORK_OFFSET_ONLY })
|
||||||
@Retention(RetentionPolicy.SOURCE)
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
@@ -90,6 +107,7 @@ public final class PhoneTimeZoneSuggestion implements Parcelable {
|
|||||||
*/
|
*/
|
||||||
public static final int MATCH_TYPE_TEST_NETWORK_OFFSET_ONLY = 5;
|
public static final int MATCH_TYPE_TEST_NETWORK_OFFSET_ONLY = 5;
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
@IntDef({ QUALITY_NA, QUALITY_SINGLE_ZONE, QUALITY_MULTIPLE_ZONES_WITH_SAME_OFFSET,
|
@IntDef({ QUALITY_NA, QUALITY_SINGLE_ZONE, QUALITY_MULTIPLE_ZONES_WITH_SAME_OFFSET,
|
||||||
QUALITY_MULTIPLE_ZONES_WITH_DIFFERENT_OFFSETS })
|
QUALITY_MULTIPLE_ZONES_WITH_DIFFERENT_OFFSETS })
|
||||||
@Retention(RetentionPolicy.SOURCE)
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
@@ -115,7 +133,7 @@ public final class PhoneTimeZoneSuggestion implements Parcelable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The ID of the phone this suggestion is associated with. For multiple-sim devices this
|
* The ID of the phone this suggestion is associated with. For multiple-sim devices this
|
||||||
* helps to establish origin so filtering / stickiness can be implemented.
|
* helps to establish source so filtering / stickiness can be implemented.
|
||||||
*/
|
*/
|
||||||
private final int mPhoneId;
|
private final int mPhoneId;
|
||||||
|
|
||||||
@@ -123,6 +141,7 @@ public final class PhoneTimeZoneSuggestion implements Parcelable {
|
|||||||
* The suggestion. {@code null} means there is no current suggestion and any previous suggestion
|
* The suggestion. {@code null} means there is no current suggestion and any previous suggestion
|
||||||
* should be forgotten.
|
* should be forgotten.
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
private final String mZoneId;
|
private final String mZoneId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -139,9 +158,10 @@ public final class PhoneTimeZoneSuggestion implements Parcelable {
|
|||||||
private final int mQuality;
|
private final int mQuality;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Free-form debug information about how the signal was derived. Used for debug only,
|
* Free-form debug information about how the suggestion was derived. Used for debug only,
|
||||||
* intentionally not used in equals(), etc.
|
* intentionally not used in equals(), etc.
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
private List<String> mDebugInfo;
|
private List<String> mDebugInfo;
|
||||||
|
|
||||||
private PhoneTimeZoneSuggestion(Builder builder) {
|
private PhoneTimeZoneSuggestion(Builder builder) {
|
||||||
@@ -182,25 +202,47 @@ public final class PhoneTimeZoneSuggestion implements Parcelable {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an identifier for the source of this suggestion. When a device has several "phones",
|
||||||
|
* i.e. sim slots or equivalent, it is used to identify which one.
|
||||||
|
*/
|
||||||
public int getPhoneId() {
|
public int getPhoneId() {
|
||||||
return mPhoneId;
|
return mPhoneId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the suggested time zone Olson ID, e.g. "America/Los_Angeles". {@code null} means that
|
||||||
|
* the caller is no longer sure what the current time zone is. See
|
||||||
|
* {@link PhoneTimeZoneSuggestion} for the associated {@code matchType} / {@code quality} rules.
|
||||||
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public String getZoneId() {
|
public String getZoneId() {
|
||||||
return mZoneId;
|
return mZoneId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns information about how the suggestion was determined which could be used to rank
|
||||||
|
* suggestions when several are available from different sources. See
|
||||||
|
* {@link PhoneTimeZoneSuggestion} for the associated rules.
|
||||||
|
*/
|
||||||
@MatchType
|
@MatchType
|
||||||
public int getMatchType() {
|
public int getMatchType() {
|
||||||
return mMatchType;
|
return mMatchType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns information about the likelihood of the suggested zone being correct. See
|
||||||
|
* {@link PhoneTimeZoneSuggestion} for the associated rules.
|
||||||
|
*/
|
||||||
@Quality
|
@Quality
|
||||||
public int getQuality() {
|
public int getQuality() {
|
||||||
return mQuality;
|
return mQuality;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns debug metadata for the suggestion. The information is present in {@link #toString()}
|
||||||
|
* but is not considered for {@link #equals(Object)} and {@link #hashCode()}.
|
||||||
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
public List<String> getDebugInfo() {
|
public List<String> getDebugInfo() {
|
||||||
return mDebugInfo == null
|
return mDebugInfo == null
|
||||||
@@ -267,36 +309,43 @@ public final class PhoneTimeZoneSuggestion implements Parcelable {
|
|||||||
*
|
*
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public static class Builder {
|
@SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
|
||||||
|
public static final class Builder {
|
||||||
private final int mPhoneId;
|
private final int mPhoneId;
|
||||||
private String mZoneId;
|
@Nullable private String mZoneId;
|
||||||
@MatchType private int mMatchType;
|
@MatchType private int mMatchType;
|
||||||
@Quality private int mQuality;
|
@Quality private int mQuality;
|
||||||
private List<String> mDebugInfo;
|
@Nullable private List<String> mDebugInfo;
|
||||||
|
|
||||||
public Builder(int phoneId) {
|
public Builder(int phoneId) {
|
||||||
mPhoneId = phoneId;
|
mPhoneId = phoneId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the builder for call chaining. */
|
/**
|
||||||
public Builder setZoneId(String zoneId) {
|
* Returns the builder for call chaining.
|
||||||
|
*/
|
||||||
|
@NonNull
|
||||||
|
public Builder setZoneId(@Nullable String zoneId) {
|
||||||
mZoneId = zoneId;
|
mZoneId = zoneId;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the builder for call chaining. */
|
/** Returns the builder for call chaining. */
|
||||||
|
@NonNull
|
||||||
public Builder setMatchType(@MatchType int matchType) {
|
public Builder setMatchType(@MatchType int matchType) {
|
||||||
mMatchType = matchType;
|
mMatchType = matchType;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the builder for call chaining. */
|
/** Returns the builder for call chaining. */
|
||||||
|
@NonNull
|
||||||
public Builder setQuality(@Quality int quality) {
|
public Builder setQuality(@Quality int quality) {
|
||||||
mQuality = quality;
|
mQuality = quality;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the builder for call chaining. */
|
/** Returns the builder for call chaining. */
|
||||||
|
@NonNull
|
||||||
public Builder addDebugInfo(@NonNull String debugInfo) {
|
public Builder addDebugInfo(@NonNull String debugInfo) {
|
||||||
if (mDebugInfo == null) {
|
if (mDebugInfo == null) {
|
||||||
mDebugInfo = new ArrayList<>();
|
mDebugInfo = new ArrayList<>();
|
||||||
@@ -333,6 +382,7 @@ public final class PhoneTimeZoneSuggestion implements Parcelable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the {@link PhoneTimeZoneSuggestion}. */
|
/** Returns the {@link PhoneTimeZoneSuggestion}. */
|
||||||
|
@NonNull
|
||||||
public PhoneTimeZoneSuggestion build() {
|
public PhoneTimeZoneSuggestion build() {
|
||||||
validate();
|
validate();
|
||||||
return new PhoneTimeZoneSuggestion(this);
|
return new PhoneTimeZoneSuggestion(this);
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ package android.app.timezonedetector;
|
|||||||
|
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.annotation.RequiresPermission;
|
import android.annotation.RequiresPermission;
|
||||||
|
import android.annotation.SystemApi;
|
||||||
import android.annotation.SystemService;
|
import android.annotation.SystemService;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
@@ -28,8 +29,10 @@ import android.util.Log;
|
|||||||
/**
|
/**
|
||||||
* The interface through which system components can send signals to the TimeZoneDetectorService.
|
* The interface through which system components can send signals to the TimeZoneDetectorService.
|
||||||
*
|
*
|
||||||
|
* <p>This class is non-final for mockito.
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
|
@SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
|
||||||
@SystemService(Context.TIME_ZONE_DETECTOR_SERVICE)
|
@SystemService(Context.TIME_ZONE_DETECTOR_SERVICE)
|
||||||
public class TimeZoneDetector {
|
public class TimeZoneDetector {
|
||||||
private static final String TAG = "timezonedetector.TimeZoneDetector";
|
private static final String TAG = "timezonedetector.TimeZoneDetector";
|
||||||
@@ -37,6 +40,7 @@ public class TimeZoneDetector {
|
|||||||
|
|
||||||
private final ITimeZoneDetectorService mITimeZoneDetectorService;
|
private final ITimeZoneDetectorService mITimeZoneDetectorService;
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
public TimeZoneDetector() throws ServiceNotFoundException {
|
public TimeZoneDetector() throws ServiceNotFoundException {
|
||||||
mITimeZoneDetectorService = ITimeZoneDetectorService.Stub.asInterface(
|
mITimeZoneDetectorService = ITimeZoneDetectorService.Stub.asInterface(
|
||||||
ServiceManager.getServiceOrThrow(Context.TIME_ZONE_DETECTOR_SERVICE));
|
ServiceManager.getServiceOrThrow(Context.TIME_ZONE_DETECTOR_SERVICE));
|
||||||
@@ -46,7 +50,10 @@ public class TimeZoneDetector {
|
|||||||
* Suggests the current time zone, determined using telephony signals, to the detector. The
|
* Suggests the current time zone, determined using telephony signals, to the detector. The
|
||||||
* detector may ignore the signal based on system settings, whether better information is
|
* detector may ignore the signal based on system settings, whether better information is
|
||||||
* available, and so on.
|
* available, and so on.
|
||||||
|
*
|
||||||
|
* @hide
|
||||||
*/
|
*/
|
||||||
|
@SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
|
||||||
@RequiresPermission(android.Manifest.permission.SUGGEST_PHONE_TIME_AND_ZONE)
|
@RequiresPermission(android.Manifest.permission.SUGGEST_PHONE_TIME_AND_ZONE)
|
||||||
public void suggestPhoneTimeZone(@NonNull PhoneTimeZoneSuggestion timeZoneSuggestion) {
|
public void suggestPhoneTimeZone(@NonNull PhoneTimeZoneSuggestion timeZoneSuggestion) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
@@ -62,6 +69,8 @@ public class TimeZoneDetector {
|
|||||||
/**
|
/**
|
||||||
* Suggests the current time zone, determined for the user's manually information, to the
|
* Suggests the current time zone, determined for the user's manually information, to the
|
||||||
* detector. The detector may ignore the signal based on system settings.
|
* detector. The detector may ignore the signal based on system settings.
|
||||||
|
*
|
||||||
|
* @hide
|
||||||
*/
|
*/
|
||||||
@RequiresPermission(android.Manifest.permission.SUGGEST_MANUAL_TIME_AND_ZONE)
|
@RequiresPermission(android.Manifest.permission.SUGGEST_MANUAL_TIME_AND_ZONE)
|
||||||
public void suggestManualTimeZone(@NonNull ManualTimeZoneSuggestion timeZoneSuggestion) {
|
public void suggestManualTimeZone(@NonNull ManualTimeZoneSuggestion timeZoneSuggestion) {
|
||||||
@@ -77,6 +86,8 @@ public class TimeZoneDetector {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A shared utility method to create a {@link ManualTimeZoneSuggestion}.
|
* A shared utility method to create a {@link ManualTimeZoneSuggestion}.
|
||||||
|
*
|
||||||
|
* @hide
|
||||||
*/
|
*/
|
||||||
public static ManualTimeZoneSuggestion createManualTimeZoneSuggestion(String tzId, String why) {
|
public static ManualTimeZoneSuggestion createManualTimeZoneSuggestion(String tzId, String why) {
|
||||||
ManualTimeZoneSuggestion suggestion = new ManualTimeZoneSuggestion(tzId);
|
ManualTimeZoneSuggestion suggestion = new ManualTimeZoneSuggestion(tzId);
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ package android.os;
|
|||||||
|
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
|
import android.annotation.SystemApi;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@@ -35,19 +36,27 @@ import java.util.Objects;
|
|||||||
* @param <T> the type of the value with an associated timestamp
|
* @param <T> the type of the value with an associated timestamp
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
|
@SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
|
||||||
public final class TimestampedValue<T> implements Parcelable {
|
public final class TimestampedValue<T> implements Parcelable {
|
||||||
private final long mReferenceTimeMillis;
|
private final long mReferenceTimeMillis;
|
||||||
|
@Nullable
|
||||||
private final T mValue;
|
private final T mValue;
|
||||||
|
|
||||||
public TimestampedValue(long referenceTimeMillis, T value) {
|
public TimestampedValue(long referenceTimeMillis, @Nullable T value) {
|
||||||
mReferenceTimeMillis = referenceTimeMillis;
|
mReferenceTimeMillis = referenceTimeMillis;
|
||||||
mValue = value;
|
mValue = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Returns the reference time value. See {@link TimestampedValue} for more information. */
|
||||||
public long getReferenceTimeMillis() {
|
public long getReferenceTimeMillis() {
|
||||||
return mReferenceTimeMillis;
|
return mReferenceTimeMillis;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the value associated with the timestamp. See {@link TimestampedValue} for more
|
||||||
|
* information.
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
public T getValue() {
|
public T getValue() {
|
||||||
return mValue;
|
return mValue;
|
||||||
}
|
}
|
||||||
@@ -86,6 +95,8 @@ public final class TimestampedValue<T> implements Parcelable {
|
|||||||
return one.mReferenceTimeMillis - two.mReferenceTimeMillis;
|
return one.mReferenceTimeMillis - two.mReferenceTimeMillis;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
@SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
|
||||||
public static final @NonNull Parcelable.Creator<TimestampedValue<?>> CREATOR =
|
public static final @NonNull Parcelable.Creator<TimestampedValue<?>> CREATOR =
|
||||||
new Parcelable.ClassLoaderCreator<TimestampedValue<?>>() {
|
new Parcelable.ClassLoaderCreator<TimestampedValue<?>>() {
|
||||||
|
|
||||||
|
|||||||
@@ -2551,7 +2551,7 @@
|
|||||||
|
|
||||||
<!-- Allows telephony to suggest the time / time zone.
|
<!-- Allows telephony to suggest the time / time zone.
|
||||||
<p>Not for use by third-party applications.
|
<p>Not for use by third-party applications.
|
||||||
@hide
|
@SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) @hide
|
||||||
-->
|
-->
|
||||||
<permission android:name="android.permission.SUGGEST_PHONE_TIME_AND_ZONE"
|
<permission android:name="android.permission.SUGGEST_PHONE_TIME_AND_ZONE"
|
||||||
android:protectionLevel="signature|telephony" />
|
android:protectionLevel="signature|telephony" />
|
||||||
|
|||||||
Reference in New Issue
Block a user