diff options
author | Ram Periathiruvadi <ramperry@google.com> | 2018-04-04 17:01:59 -0700 |
---|---|---|
committer | Ram Periathiruvadi <ramperry@google.com> | 2018-04-06 13:51:36 -0700 |
commit | ac7e979b7e23c917b2cec15262f256831e43a4a6 (patch) | |
tree | 0038167112cf0ae56996a976fac258752e2d433c /car-lib/src/android/car/drivingstate | |
parent | 1267e280e57506ece9f94f96b56d69e352591429 (diff) | |
download | Car-ac7e979b7e23c917b2cec15262f256831e43a4a6.tar.gz |
Restriction parameters reported via CarUxRestrictions.
Moved the APIs to report CarUxRestrictions paramaters from
CarUxRestrictionaManager to CarUxRestrictions to make it easy for
clients to consume.
Bug: 77480435
Test: UXR changes can be observed and the parameter values are
retrieved.
Change-Id: Icf686fe49b18a5b4c01f5bf0a5bd817b4e37c574
Diffstat (limited to 'car-lib/src/android/car/drivingstate')
3 files changed, 124 insertions, 67 deletions
diff --git a/car-lib/src/android/car/drivingstate/CarUxRestrictions.java b/car-lib/src/android/car/drivingstate/CarUxRestrictions.java index c97c60eb70..f0a894e7d5 100644 --- a/car-lib/src/android/car/drivingstate/CarUxRestrictions.java +++ b/car-lib/src/android/car/drivingstate/CarUxRestrictions.java @@ -61,6 +61,13 @@ import java.lang.annotation.RetentionPolicy; */ public class CarUxRestrictions implements Parcelable { + // Default fallback values for the restriction related parameters if the information is + // not available from the underlying service. + // TODO(b/77606226): Finalize default values. + private static final int DEFAULT_MAX_LENGTH = 80; + private static final int DEFAULT_MAX_CUMULATIVE_ITEMS = 50; + private static final int DEFAULT_MAX_CONTENT_DEPTH = 3; + /** * No specific restrictions in place, but baseline distraction optimization guidelines need to * be adhered to when {@link #isRequiresDistractionOptimization()} is true. @@ -80,7 +87,7 @@ public class CarUxRestrictions implements Parcelable { /** * General purpose strings length cannot exceed the character limit provided by - * {@link CarUxRestrictionsManager#getMaxRestrictedStringLength()} + * {@link #getMaxRestrictedStringLength()} */ public static final int UX_RESTRICTIONS_LIMIT_STRING_LENGTH = 0x1 << 2; @@ -96,8 +103,8 @@ public class CarUxRestrictions implements Parcelable { /** * Limit the number of items displayed on the screen. - * Refer to {@link CarUxRestrictionsManager#getMaxCumulativeContentItems()} and - * {@link CarUxRestrictionsManager#getMaxContentDepth()} for the upper bounds on content + * Refer to {@link #getMaxCumulativeContentItems()} and + * {@link #getMaxContentDepth()} for the upper bounds on content * serving. */ public static final int UX_RESTRICTIONS_LIMIT_CONTENT = 0x1 << 5; @@ -129,7 +136,7 @@ public class CarUxRestrictions implements Parcelable { | UX_RESTRICTIONS_NO_VOICE_TRANSCRIPTION; @IntDef(flag = true, - prefix = { "UX_RESTRICTIONS_" }, + prefix = {"UX_RESTRICTIONS_"}, value = {UX_RESTRICTIONS_BASELINE, UX_RESTRICTIONS_NO_DIALPAD, UX_RESTRICTIONS_NO_FILTERING, @@ -148,6 +155,65 @@ public class CarUxRestrictions implements Parcelable { private final boolean mRequiresDistractionOptimization; @CarUxRestrictionsInfo private final int mActiveRestrictions; + // Restriction Parameters + private final int mMaxStringLength; + private final int mMaxCumulativeContentItems; + private final int mMaxContentDepth; + + /** + * Builder class for {@link CarUxRestrictions} + */ + public static class Builder { + private final long mTimeStamp; + private final boolean mRequiresDistractionOptimization; + @CarUxRestrictionsInfo + private final int mActiveRestrictions; + // Restriction Parameters + private int mMaxStringLength = DEFAULT_MAX_LENGTH; + private int mMaxCumulativeContentItems = DEFAULT_MAX_CUMULATIVE_ITEMS; + private int mMaxContentDepth = DEFAULT_MAX_CONTENT_DEPTH; + + public Builder(boolean reqOpt, @CarUxRestrictionsInfo int restrictions, long time) { + mRequiresDistractionOptimization = reqOpt; + mActiveRestrictions = restrictions; + mTimeStamp = time; + } + + /** + * Set the maximum length of general purpose strings that can be displayed when + * {@link CarUxRestrictions#UX_RESTRICTIONS_LIMIT_STRING_LENGTH} is imposed. + */ + public Builder setMaxStringLength(int length) { + mMaxStringLength = length; + return this; + } + + /** + * Set the maximum number of cumulative content items that can be displayed when + * {@link CarUxRestrictions#UX_RESTRICTIONS_LIMIT_CONTENT} is imposed. + */ + public Builder setMaxCumulativeContentItems(int number) { + mMaxCumulativeContentItems = number; + return this; + } + + /** + * Set the maximum number of levels that the user can navigate to when + * {@link CarUxRestrictions#UX_RESTRICTIONS_LIMIT_CONTENT} is imposed. + */ + public Builder setMaxContentDepth(int depth) { + mMaxContentDepth = depth; + return this; + } + + /** + * Build and return the {@link CarUxRestrictions} object + */ + public CarUxRestrictions build() { + return new CarUxRestrictions(this); + } + + } /** * Time at which this UX restriction event was deduced based on the car's driving state. @@ -183,6 +249,42 @@ public class CarUxRestrictions implements Parcelable { return mActiveRestrictions; } + /** + * Get the maximum length of general purpose strings that can be displayed when + * {@link CarUxRestrictions#UX_RESTRICTIONS_LIMIT_STRING_LENGTH} is imposed. + * + * @return the maximum length of string that can be displayed + */ + public int getMaxRestrictedStringLength() { + return mMaxStringLength; + } + + /** + * Get the maximum number of cumulative content items that can be displayed when + * {@link CarUxRestrictions#UX_RESTRICTIONS_LIMIT_CONTENT} is imposed. + * <p> + * Please refer to this and {@link #getMaxContentDepth()} to know the upper bounds of + * content serving when the restriction is in place. + * + * @return maximum number of cumulative items that can be displayed + */ + public int getMaxCumulativeContentItems() { + return mMaxCumulativeContentItems; + } + + /** + * Get the maximum number of levels that the user can navigate to when + * {@link CarUxRestrictions#UX_RESTRICTIONS_LIMIT_CONTENT} is imposed. + * <p> + * Please refer to this and {@link #getMaxCumulativeContentItems()} to know the upper bounds of + * content serving when the restriction is in place. + * + * @return maximum number of cumulative items that can be displayed + */ + public int getMaxContentDepth() { + return mMaxContentDepth; + } + @Override public int describeContents() { return 0; @@ -193,6 +295,9 @@ public class CarUxRestrictions implements Parcelable { dest.writeInt(mActiveRestrictions); dest.writeLong(mTimeStamp); dest.writeInt(mRequiresDistractionOptimization ? 1 : 0); + dest.writeInt(mMaxStringLength); + dest.writeInt(mMaxCumulativeContentItems); + dest.writeInt(mMaxContentDepth); } public static final Parcelable.Creator<CarUxRestrictions> CREATOR @@ -206,22 +311,31 @@ public class CarUxRestrictions implements Parcelable { } }; - public CarUxRestrictions(boolean reqOpt, @CarUxRestrictionsInfo int restrictions, long time) { - mRequiresDistractionOptimization = reqOpt; - mActiveRestrictions = restrictions; - mTimeStamp = time; - } - public CarUxRestrictions(CarUxRestrictions uxRestrictions) { mTimeStamp = uxRestrictions.getTimeStamp(); mRequiresDistractionOptimization = uxRestrictions.isRequiresDistractionOptimization(); mActiveRestrictions = uxRestrictions.getActiveRestrictions(); + mMaxStringLength = uxRestrictions.mMaxStringLength; + mMaxCumulativeContentItems = uxRestrictions.mMaxCumulativeContentItems; + mMaxContentDepth = uxRestrictions.mMaxContentDepth; + } + + private CarUxRestrictions(Builder builder) { + mTimeStamp = builder.mTimeStamp; + mActiveRestrictions = builder.mActiveRestrictions; + mRequiresDistractionOptimization = builder.mRequiresDistractionOptimization; + mMaxStringLength = builder.mMaxStringLength; + mMaxCumulativeContentItems = builder.mMaxCumulativeContentItems; + mMaxContentDepth = builder.mMaxContentDepth; } private CarUxRestrictions(Parcel in) { mActiveRestrictions = in.readInt(); mTimeStamp = in.readLong(); mRequiresDistractionOptimization = in.readInt() != 0; + mMaxStringLength = in.readInt(); + mMaxCumulativeContentItems = in.readInt(); + mMaxContentDepth = in.readInt(); } @Override diff --git a/car-lib/src/android/car/drivingstate/CarUxRestrictionsManager.java b/car-lib/src/android/car/drivingstate/CarUxRestrictionsManager.java index 354172668c..1c2c334f4f 100644 --- a/car-lib/src/android/car/drivingstate/CarUxRestrictionsManager.java +++ b/car-lib/src/android/car/drivingstate/CarUxRestrictionsManager.java @@ -153,60 +153,6 @@ public final class CarUxRestrictionsManager implements CarManagerBase { } /** - * Get the maximum length of general purpose strings that can be displayed when - * {@link CarUxRestrictions#UX_RESTRICTIONS_LIMIT_STRING_LENGTH} is imposed. - * - * @return the maximum length of string that can be displayed - * @throws CarNotConnectedException - */ - public int getMaxRestrictedStringLength() throws CarNotConnectedException { - try { - return mUxRService.getMaxRestrictedStringLength(); - } catch (RemoteException e) { - Log.e(TAG, "Could not get the Max restricted String length " + e); - throw new CarNotConnectedException(e); - } - } - - /** - * Get the maximum number of cumulative content items that can be displayed when - * {@link CarUxRestrictions#UX_RESTRICTIONS_LIMIT_CONTENT} is imposed. - * <p> - * Please refer to this and {@link #getMaxContentDepth()} to know the upper bounds of - * content serving when the restriction is in place. - * - * @return maximum number of cumulative items that can be displayed - * @throws CarNotConnectedException - */ - public int getMaxCumulativeContentItems() throws CarNotConnectedException { - try { - return mUxRService.getMaxCumulativeContentItems(); - } catch (RemoteException e) { - Log.e(TAG, "Could not get the Max Cumulative content items " + e); - throw new CarNotConnectedException(e); - } - } - - /** - * Get the maximum number of levels that the user can navigate to when - * {@link CarUxRestrictions#UX_RESTRICTIONS_LIMIT_CONTENT} is imposed. - * <p> - * Please refer to this and {@link #getMaxCumulativeContentItems()} to know the upper bounds of - * content serving when the restriction is in place. - * - * @return maximum number of cumulative items that can be displayed - * @throws CarNotConnectedException - */ - public int getMaxContentDepth() throws CarNotConnectedException { - try { - return mUxRService.getMaxContentDepth(); - } catch (RemoteException e) { - Log.e(TAG, "Could not get the Max content depth " + e); - throw new CarNotConnectedException(e); - } - } - - /** * Class that implements the listener interface and gets called back from the * {@link com.android.car.CarDrivingStateService} across the binder interface. */ diff --git a/car-lib/src/android/car/drivingstate/ICarUxRestrictionsManager.aidl b/car-lib/src/android/car/drivingstate/ICarUxRestrictionsManager.aidl index c5af38e5a1..e5c69b89a0 100644 --- a/car-lib/src/android/car/drivingstate/ICarUxRestrictionsManager.aidl +++ b/car-lib/src/android/car/drivingstate/ICarUxRestrictionsManager.aidl @@ -30,7 +30,4 @@ interface ICarUxRestrictionsManager { void registerUxRestrictionsChangeListener(in ICarUxRestrictionsChangeListener listener) = 0; void unregisterUxRestrictionsChangeListener(in ICarUxRestrictionsChangeListener listener) = 1; CarUxRestrictions getCurrentUxRestrictions() = 2; - int getMaxRestrictedStringLength() = 3; - int getMaxCumulativeContentItems() = 4; - int getMaxContentDepth() = 5; } |