diff options
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/app/time/Capabilities.java | 78 | ||||
| -rw-r--r-- | core/java/android/app/time/TimeCapabilities.aidl | 19 | ||||
| -rw-r--r-- | core/java/android/app/time/TimeCapabilities.java | 186 | ||||
| -rw-r--r-- | core/java/android/app/time/TimeCapabilitiesAndConfig.aidl | 19 | ||||
| -rw-r--r-- | core/java/android/app/time/TimeCapabilitiesAndConfig.java | 119 | ||||
| -rw-r--r-- | core/java/android/app/time/TimeConfiguration.aidl | 19 | ||||
| -rw-r--r-- | core/java/android/app/time/TimeConfiguration.java | 141 | ||||
| -rw-r--r-- | core/java/android/app/time/TimeManager.java | 48 | ||||
| -rw-r--r-- | core/java/android/app/time/TimeZoneCapabilities.java | 55 | ||||
| -rw-r--r-- | core/java/android/app/time/TimeZoneCapabilitiesAndConfig.java | 2 | ||||
| -rw-r--r-- | core/java/android/app/timedetector/ITimeDetectorService.aidl | 5 |
11 files changed, 636 insertions, 55 deletions
diff --git a/core/java/android/app/time/Capabilities.java b/core/java/android/app/time/Capabilities.java new file mode 100644 index 000000000000..33db7211f3b4 --- /dev/null +++ b/core/java/android/app/time/Capabilities.java @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2021 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.time; + +import android.annotation.IntDef; +import android.annotation.SystemApi; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/** + * A capability is the ability for the user to configure something or perform an action. This + * information is exposed so that system apps like SettingsUI can be dynamic, rather than + * hard-coding knowledge of when configuration or actions are applicable / available to the user. + * + * <p>Capabilities have states that users cannot change directly. They may influence some + * capabilities indirectly by agreeing to certain device-wide behaviors such as location sharing, or + * by changing the configuration. See the {@code CAPABILITY_} constants for details. + * + * <p>Actions have associated methods, see the documentation for each action for details. + * + * <p>Note: Capabilities are independent of app permissions required to call the associated APIs. + * + * @hide + */ +@SystemApi +public final class Capabilities { + + /** @hide */ + @IntDef({ CAPABILITY_NOT_SUPPORTED, CAPABILITY_NOT_ALLOWED, CAPABILITY_NOT_APPLICABLE, + CAPABILITY_POSSESSED }) + @Retention(RetentionPolicy.SOURCE) + public @interface CapabilityState {} + + /** + * Indicates that a capability is not supported on this device, e.g. because of form factor or + * hardware. The associated UI should usually not be shown to the user. + */ + public static final int CAPABILITY_NOT_SUPPORTED = 10; + + /** + * Indicates that a capability is supported on this device, but not allowed for the user, e.g. + * if the capability relates to the ability to modify settings the user is not able to. + * This could be because of the user's type (e.g. maybe it applies to the primary user only) or + * device policy. Depending on the capability, this could mean the associated UI + * should be hidden, or displayed but disabled. + */ + public static final int CAPABILITY_NOT_ALLOWED = 20; + + /** + * Indicates that a capability is possessed but not currently applicable, e.g. if the + * capability relates to the ability to modify settings, the user has the ability to modify + * it, but it is currently rendered irrelevant by other settings or other device state (flags, + * resource config, etc.). The associated UI may be hidden, disabled, or left visible (but + * ineffective) depending on requirements. + */ + public static final int CAPABILITY_NOT_APPLICABLE = 30; + + /** Indicates that a capability is possessed by the user. */ + public static final int CAPABILITY_POSSESSED = 40; + + private Capabilities() {} + +} diff --git a/core/java/android/app/time/TimeCapabilities.aidl b/core/java/android/app/time/TimeCapabilities.aidl new file mode 100644 index 000000000000..f44b791e6ce7 --- /dev/null +++ b/core/java/android/app/time/TimeCapabilities.aidl @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2021 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.time; + +parcelable TimeCapabilities; diff --git a/core/java/android/app/time/TimeCapabilities.java b/core/java/android/app/time/TimeCapabilities.java new file mode 100644 index 000000000000..fff36c4a7096 --- /dev/null +++ b/core/java/android/app/time/TimeCapabilities.java @@ -0,0 +1,186 @@ +/* + * Copyright (C) 2021 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.time; + +import android.annotation.NonNull; +import android.app.time.Capabilities.CapabilityState; +import android.os.Parcel; +import android.os.Parcelable; +import android.os.UserHandle; + +import java.util.Objects; + +/** + * Time-relate capabilities for a user. + * + * <p>For configuration settings capabilities, the associated settings value can be found via + * {@link TimeManager#getTimeCapabilitiesAndConfig()} and may be changed using {@link + * TimeManager#updateTimeConfiguration(TimeConfiguration)} (if the user's capabilities + * allow). + * + * @hide + */ +public final class TimeCapabilities implements Parcelable { + + public static final @NonNull Creator<TimeCapabilities> CREATOR = + new Creator<TimeCapabilities>() { + public TimeCapabilities createFromParcel(Parcel in) { + return TimeCapabilities.createFromParcel(in); + } + + public TimeCapabilities[] newArray(int size) { + return new TimeCapabilities[size]; + } + }; + + + /** + * The user the capabilities are for. This is used for object equality and debugging but there + * is no accessor. + */ + @NonNull + private final UserHandle mUserHandle; + private final @CapabilityState int mConfigureAutoTimeDetectionEnabledCapability; + private final @CapabilityState int mSuggestTimeManuallyCapability; + + private TimeCapabilities(@NonNull Builder builder) { + this.mUserHandle = Objects.requireNonNull(builder.mUserHandle); + this.mConfigureAutoTimeDetectionEnabledCapability = + builder.mConfigureAutoDetectionEnabledCapability; + this.mSuggestTimeManuallyCapability = + builder.mSuggestTimeManuallyCapability; + } + + @NonNull + private static TimeCapabilities createFromParcel(Parcel in) { + UserHandle userHandle = UserHandle.readFromParcel(in); + return new TimeCapabilities.Builder(userHandle) + .setConfigureAutoTimeDetectionEnabledCapability(in.readInt()) + .setSuggestTimeManuallyCapability(in.readInt()) + .build(); + } + + @Override + public void writeToParcel(@NonNull Parcel dest, int flags) { + UserHandle.writeToParcel(mUserHandle, dest); + dest.writeInt(mConfigureAutoTimeDetectionEnabledCapability); + dest.writeInt(mSuggestTimeManuallyCapability); + } + + /** + * Returns the capability state associated with the user's ability to modify the automatic time + * detection setting. + */ + @CapabilityState + public int getConfigureAutoTimeDetectionEnabledCapability() { + return mConfigureAutoTimeDetectionEnabledCapability; + } + + /** + * Returns the capability state associated with the user's ability to manually set time on a + * device. + */ + @CapabilityState + public int getSuggestTimeManuallyCapability() { + return mSuggestTimeManuallyCapability; + } + + @Override + public int describeContents() { + return 0; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + TimeCapabilities that = (TimeCapabilities) o; + return mConfigureAutoTimeDetectionEnabledCapability + == that.mConfigureAutoTimeDetectionEnabledCapability + && mSuggestTimeManuallyCapability == that.mSuggestTimeManuallyCapability + && mUserHandle.equals(that.mUserHandle); + } + + @Override + public int hashCode() { + return Objects.hash(mUserHandle, mConfigureAutoTimeDetectionEnabledCapability, + mSuggestTimeManuallyCapability); + } + + @Override + public String toString() { + return "TimeCapabilities{" + + "mUserHandle=" + mUserHandle + + ", mConfigureAutoTimeDetectionEnabledCapability=" + + mConfigureAutoTimeDetectionEnabledCapability + + ", mSuggestTimeManuallyCapability=" + mSuggestTimeManuallyCapability + + '}'; + } + + /** + * A builder of {@link TimeCapabilities} objects. + * + * @hide + */ + public static class Builder { + @NonNull private final UserHandle mUserHandle; + private @CapabilityState int mConfigureAutoDetectionEnabledCapability; + private @CapabilityState int mSuggestTimeManuallyCapability; + + public Builder(@NonNull TimeCapabilities timeCapabilities) { + Objects.requireNonNull(timeCapabilities); + this.mUserHandle = timeCapabilities.mUserHandle; + this.mConfigureAutoDetectionEnabledCapability = + timeCapabilities.mConfigureAutoTimeDetectionEnabledCapability; + this.mSuggestTimeManuallyCapability = + timeCapabilities.mSuggestTimeManuallyCapability; + } + + public Builder(@NonNull UserHandle userHandle) { + this.mUserHandle = Objects.requireNonNull(userHandle); + } + + /** Sets the state for automatic time detection config. */ + public Builder setConfigureAutoTimeDetectionEnabledCapability( + @CapabilityState int setConfigureAutoTimeDetectionEnabledCapability) { + this.mConfigureAutoDetectionEnabledCapability = + setConfigureAutoTimeDetectionEnabledCapability; + return this; + } + + /** Sets the state for manual time change. */ + public Builder setSuggestTimeManuallyCapability( + @CapabilityState int suggestTimeManuallyCapability) { + this.mSuggestTimeManuallyCapability = suggestTimeManuallyCapability; + return this; + } + + /** Returns the {@link TimeCapabilities}. */ + public TimeCapabilities build() { + verifyCapabilitySet(mConfigureAutoDetectionEnabledCapability, + "configureAutoDetectionEnabledCapability"); + verifyCapabilitySet(mSuggestTimeManuallyCapability, "suggestTimeManuallyCapability"); + return new TimeCapabilities(this); + } + + private void verifyCapabilitySet(int value, String name) { + if (value == 0) { + throw new IllegalStateException(name + " was not set"); + } + } + } +} diff --git a/core/java/android/app/time/TimeCapabilitiesAndConfig.aidl b/core/java/android/app/time/TimeCapabilitiesAndConfig.aidl new file mode 100644 index 000000000000..183dcaf6e2e6 --- /dev/null +++ b/core/java/android/app/time/TimeCapabilitiesAndConfig.aidl @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2021 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.time; + +parcelable TimeCapabilitiesAndConfig;
\ No newline at end of file diff --git a/core/java/android/app/time/TimeCapabilitiesAndConfig.java b/core/java/android/app/time/TimeCapabilitiesAndConfig.java new file mode 100644 index 000000000000..4a1044760064 --- /dev/null +++ b/core/java/android/app/time/TimeCapabilitiesAndConfig.java @@ -0,0 +1,119 @@ +/* + * Copyright (C) 2021 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.time; + +import android.annotation.NonNull; +import android.os.Parcel; +import android.os.Parcelable; + +import java.util.Objects; + +/** + * A pair containing a user's {@link TimeCapabilities} and {@link TimeConfiguration}. + * + * @hide + */ +public final class TimeCapabilitiesAndConfig implements Parcelable { + + public static final @NonNull Creator<TimeCapabilitiesAndConfig> CREATOR = + new Creator<TimeCapabilitiesAndConfig>() { + @Override + public TimeCapabilitiesAndConfig createFromParcel(Parcel source) { + return TimeCapabilitiesAndConfig.readFromParcel(source); + } + + @Override + public TimeCapabilitiesAndConfig[] newArray(int size) { + return new TimeCapabilitiesAndConfig[size]; + } + }; + + @NonNull + private final TimeCapabilities mTimeCapabilities; + + @NonNull + private final TimeConfiguration mTimeConfiguration; + + /** + * @hide + */ + public TimeCapabilitiesAndConfig(@NonNull TimeCapabilities timeCapabilities, + @NonNull TimeConfiguration timeConfiguration) { + mTimeCapabilities = Objects.requireNonNull(timeCapabilities); + mTimeConfiguration = Objects.requireNonNull(timeConfiguration); + } + + @NonNull + private static TimeCapabilitiesAndConfig readFromParcel(Parcel in) { + TimeCapabilities capabilities = in.readParcelable(null); + TimeConfiguration configuration = in.readParcelable(null); + return new TimeCapabilitiesAndConfig(capabilities, configuration); + } + + /** + * Returns the user's time behaviour capabilities. + * + * @hide + */ + @NonNull + public TimeCapabilities getTimeCapabilities() { + return mTimeCapabilities; + } + + /** + * Returns the user's time behaviour configuration. + * + * @hide + */ + @NonNull + public TimeConfiguration getTimeConfiguration() { + return mTimeConfiguration; + } + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(@NonNull Parcel dest, int flags) { + dest.writeParcelable(mTimeCapabilities, flags); + dest.writeParcelable(mTimeConfiguration, flags); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + TimeCapabilitiesAndConfig that = (TimeCapabilitiesAndConfig) o; + return mTimeCapabilities.equals(that.mTimeCapabilities) + && mTimeConfiguration.equals(that.mTimeConfiguration); + } + + @Override + public int hashCode() { + return Objects.hash(mTimeCapabilities, mTimeConfiguration); + } + + @Override + public String toString() { + return "TimeCapabilitiesAndConfig{" + + "mTimeCapabilities=" + mTimeCapabilities + + ", mTimeConfiguration=" + mTimeConfiguration + + '}'; + } +} diff --git a/core/java/android/app/time/TimeConfiguration.aidl b/core/java/android/app/time/TimeConfiguration.aidl new file mode 100644 index 000000000000..eb5bfd6d2272 --- /dev/null +++ b/core/java/android/app/time/TimeConfiguration.aidl @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2021 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.time; + +parcelable TimeConfiguration; diff --git a/core/java/android/app/time/TimeConfiguration.java b/core/java/android/app/time/TimeConfiguration.java new file mode 100644 index 000000000000..70aede034d27 --- /dev/null +++ b/core/java/android/app/time/TimeConfiguration.java @@ -0,0 +1,141 @@ +/* + * Copyright (C) 2021 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.time; + +import android.annotation.NonNull; +import android.annotation.StringDef; +import android.os.Bundle; +import android.os.Parcel; +import android.os.Parcelable; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.util.Objects; + +/** + * User visible settings that control the behavior of the time zone detector / manual time zone + * entry. + * + * @hide + */ +public final class TimeConfiguration implements Parcelable { + + public static final @NonNull Creator<TimeConfiguration> CREATOR = + new Creator<TimeConfiguration>() { + @Override + public TimeConfiguration createFromParcel(Parcel source) { + return TimeConfiguration.readFromParcel(source); + } + + @Override + public TimeConfiguration[] newArray(int size) { + return new TimeConfiguration[size]; + } + }; + + @StringDef(SETTING_AUTO_DETECTION_ENABLED) + @Retention(RetentionPolicy.SOURCE) + @interface Setting {} + + @Setting + private static final String SETTING_AUTO_DETECTION_ENABLED = "autoDetectionEnabled"; + + @NonNull + private final Bundle mBundle; + + private TimeConfiguration(Builder builder) { + this.mBundle = builder.mBundle; + } + + /** + * Returns the value of the {@link #SETTING_AUTO_DETECTION_ENABLED} setting. This + * controls whether a device will attempt to determine the time automatically using + * contextual information if the device supports auto detection. + */ + public boolean isAutoDetectionEnabled() { + return mBundle.getBoolean(SETTING_AUTO_DETECTION_ENABLED); + } + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(@NonNull Parcel dest, int flags) { + dest.writeBundle(mBundle); + } + + private static TimeConfiguration readFromParcel(Parcel in) { + return new TimeConfiguration.Builder() + .merge(in.readBundle()) + .build(); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + TimeConfiguration that = (TimeConfiguration) o; + return mBundle.kindofEquals(that.mBundle); + } + + @Override + public int hashCode() { + return Objects.hash(mBundle); + } + + @Override + public String toString() { + return "TimeConfiguration{" + + "mBundle=" + mBundle + + '}'; + } + + /** + * A builder for {@link TimeConfiguration} objects. + * + * @hide + */ + public static final class Builder { + private final Bundle mBundle = new Bundle(); + + public Builder() {} + + public Builder(@NonNull TimeConfiguration configuration) { + mBundle.putAll(configuration.mBundle); + } + + /** Sets whether auto detection is enabled or not. */ + @NonNull + public Builder setAutoDetectionEnabled(boolean enabled) { + mBundle.putBoolean(SETTING_AUTO_DETECTION_ENABLED, enabled); + return this; + } + + Builder merge(@NonNull Bundle bundle) { + mBundle.putAll(bundle); + return this; + } + + /** Returns {@link TimeConfiguration} object. */ + @NonNull + public TimeConfiguration build() { + return new TimeConfiguration(this); + } + } +} diff --git a/core/java/android/app/time/TimeManager.java b/core/java/android/app/time/TimeManager.java index 430960fb11a8..c8fa5c8f28e2 100644 --- a/core/java/android/app/time/TimeManager.java +++ b/core/java/android/app/time/TimeManager.java @@ -75,7 +75,7 @@ public final class TimeManager { @NonNull public TimeZoneCapabilitiesAndConfig getTimeZoneCapabilitiesAndConfig() { if (DEBUG) { - Log.d(TAG, "getTimeZoneCapabilities called"); + Log.d(TAG, "getTimeZoneCapabilitiesAndConfig called"); } try { return mITimeZoneDetectorService.getCapabilitiesAndConfig(); @@ -85,6 +85,44 @@ public final class TimeManager { } /** + * Returns the calling user's time capabilities and configuration. + * + * @hide + */ + @RequiresPermission(android.Manifest.permission.MANAGE_TIME_AND_ZONE_DETECTION) + @NonNull + public TimeCapabilitiesAndConfig getTimeCapabilitiesAndConfig() { + if (DEBUG) { + Log.d(TAG, "getTimeCapabilitiesAndConfig called"); + } + try { + return mITimeDetectorService.getCapabilitiesAndConfig(); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + + /** + * Modifies the time detection configuration. + * + * @return {@code true} if all the configuration settings specified have been set to the + * new values, {@code false} if none have + * + * @hide + */ + @RequiresPermission(android.Manifest.permission.MANAGE_TIME_AND_ZONE_DETECTION) + public boolean updateTimeConfiguration(@NonNull TimeConfiguration configuration) { + if (DEBUG) { + Log.d(TAG, "updateTimeConfiguration called: " + configuration); + } + try { + return mITimeDetectorService.updateConfiguration(configuration); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + + /** * Modifies the time zone detection configuration. * * <p>Configuration settings vary in scope: some may be global (affect all users), others may be @@ -97,11 +135,11 @@ public final class TimeManager { * capabilities. * * <p>Attempts to modify configuration settings with capabilities that are {@link - * TimeZoneCapabilities#CAPABILITY_NOT_SUPPORTED} or {@link - * TimeZoneCapabilities#CAPABILITY_NOT_ALLOWED} will have no effect and a {@code false} + * Capabilities#CAPABILITY_NOT_SUPPORTED} or {@link + * Capabilities#CAPABILITY_NOT_ALLOWED} will have no effect and a {@code false} * will be returned. Modifying configuration settings with capabilities that are {@link - * TimeZoneCapabilities#CAPABILITY_NOT_APPLICABLE} or {@link - * TimeZoneCapabilities#CAPABILITY_POSSESSED} will succeed. See {@link + * Capabilities#CAPABILITY_NOT_APPLICABLE} or {@link + * Capabilities#CAPABILITY_POSSESSED} will succeed. See {@link * TimeZoneCapabilities} for further details. * * <p>If the supplied configuration only has some values set, then only the specified settings diff --git a/core/java/android/app/time/TimeZoneCapabilities.java b/core/java/android/app/time/TimeZoneCapabilities.java index a27be96e6e69..433b4200eece 100644 --- a/core/java/android/app/time/TimeZoneCapabilities.java +++ b/core/java/android/app/time/TimeZoneCapabilities.java @@ -16,77 +16,33 @@ package android.app.time; -import android.annotation.IntDef; +import static android.app.time.Capabilities.CAPABILITY_NOT_APPLICABLE; + import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.SystemApi; +import android.app.time.Capabilities.CapabilityState; import android.app.timezonedetector.ManualTimeZoneSuggestion; import android.app.timezonedetector.TimeZoneDetector; import android.os.Parcel; import android.os.Parcelable; import android.os.UserHandle; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; import java.util.Objects; /** - * Time zone-related capabilities for a user. A capability is the ability for the user to configure - * something or perform an action. This information is exposed so that system apps like SettingsUI - * can be dynamic, rather than hard-coding knowledge of when configuration or actions are applicable - * / available to the user. - * - * <p>Capabilities have states that users cannot change directly. They may influence some - * capabilities indirectly by agreeing to certain device-wide behaviors such as location sharing, or - * by changing the configuration. See the {@code CAPABILITY_} constants for details. - * - * <p>Actions have associated methods, see the documentation for each action for details. + * Time zone-related capabilities for a user. * * <p>For configuration settings capabilities, the associated settings value can be found via * {@link TimeManager#getTimeZoneCapabilitiesAndConfig()} and may be changed using {@link * TimeManager#updateTimeZoneConfiguration(TimeZoneConfiguration)} (if the user's capabilities * allow). * - * <p>Note: Capabilities are independent of app permissions required to call the associated APIs. - * * @hide */ @SystemApi public final class TimeZoneCapabilities implements Parcelable { - /** @hide */ - @IntDef({ CAPABILITY_NOT_SUPPORTED, CAPABILITY_NOT_ALLOWED, CAPABILITY_NOT_APPLICABLE, - CAPABILITY_POSSESSED }) - @Retention(RetentionPolicy.SOURCE) - public @interface CapabilityState {} - - /** - * Indicates that a capability is not supported on this device, e.g. because of form factor or - * hardware. The associated UI should usually not be shown to the user. - */ - public static final int CAPABILITY_NOT_SUPPORTED = 10; - - /** - * Indicates that a capability is supported on this device, but not allowed for the user, e.g. - * if the capability relates to the ability to modify settings the user is not able to. - * This could be because of the user's type (e.g. maybe it applies to the primary user only) or - * device policy. Depending on the capability, this could mean the associated UI - * should be hidden, or displayed but disabled. - */ - public static final int CAPABILITY_NOT_ALLOWED = 20; - - /** - * Indicates that a capability is possessed but not currently applicable, e.g. if the - * capability relates to the ability to modify settings, the user has the ability to modify - * it, but it is currently rendered irrelevant by other settings or other device state (flags, - * resource config, etc.). The associated UI may be hidden, disabled, or left visible (but - * ineffective) depending on requirements. - */ - public static final int CAPABILITY_NOT_APPLICABLE = 30; - - /** Indicates that a capability is possessed by the user. */ - public static final int CAPABILITY_POSSESSED = 40; - public static final @NonNull Creator<TimeZoneCapabilities> CREATOR = new Creator<TimeZoneCapabilities>() { public TimeZoneCapabilities createFromParcel(Parcel in) { @@ -159,7 +115,8 @@ public final class TimeZoneCapabilities implements Parcelable { * on a device via {@link TimeZoneDetector#suggestManualTimeZone(ManualTimeZoneSuggestion)}. * * <p>The suggestion will be ignored in all cases unless the value is {@link - * #CAPABILITY_POSSESSED}. See also {@link TimeZoneConfiguration#isAutoDetectionEnabled()}. + * Capabilities#CAPABILITY_POSSESSED}. See also + * {@link TimeZoneConfiguration#isAutoDetectionEnabled()}. * * @hide */ diff --git a/core/java/android/app/time/TimeZoneCapabilitiesAndConfig.java b/core/java/android/app/time/TimeZoneCapabilitiesAndConfig.java index f9a0c74312fc..a9ea76f77958 100644 --- a/core/java/android/app/time/TimeZoneCapabilitiesAndConfig.java +++ b/core/java/android/app/time/TimeZoneCapabilitiesAndConfig.java @@ -113,7 +113,7 @@ public final class TimeZoneCapabilitiesAndConfig implements Parcelable { @Override public String toString() { - return "TimeZoneDetectorCapabilitiesAndConfig{" + return "TimeZoneCapabilitiesAndConfig{" + "mCapabilities=" + mCapabilities + ", mConfiguration=" + mConfiguration + '}'; diff --git a/core/java/android/app/timedetector/ITimeDetectorService.aidl b/core/java/android/app/timedetector/ITimeDetectorService.aidl index c4546be10601..9a6c33589123 100644 --- a/core/java/android/app/timedetector/ITimeDetectorService.aidl +++ b/core/java/android/app/timedetector/ITimeDetectorService.aidl @@ -17,6 +17,8 @@ package android.app.timedetector; import android.app.time.ExternalTimeSuggestion; +import android.app.time.TimeCapabilitiesAndConfig; +import android.app.time.TimeConfiguration; import android.app.timedetector.GnssTimeSuggestion; import android.app.timedetector.ManualTimeSuggestion; import android.app.timedetector.NetworkTimeSuggestion; @@ -36,6 +38,9 @@ import android.app.timedetector.TelephonyTimeSuggestion; * {@hide} */ interface ITimeDetectorService { + TimeCapabilitiesAndConfig getCapabilitiesAndConfig(); + boolean updateConfiguration(in TimeConfiguration timeConfiguration); + void suggestExternalTime( in ExternalTimeSuggestion timeSuggestion); void suggestGnssTime(in GnssTimeSuggestion timeSuggestion); boolean suggestManualTime(in ManualTimeSuggestion timeSuggestion); |
