Loading Android.mk +2 −0 Original line number Diff line number Diff line Loading @@ -103,6 +103,8 @@ LOCAL_SRC_FILES += \ core/java/android/app/backup/IFullBackupRestoreObserver.aidl \ core/java/android/app/backup/IRestoreObserver.aidl \ core/java/android/app/backup/IRestoreSession.aidl \ core/java/android/app/timezone/ICallback.aidl \ core/java/android/app/timezone/IRulesManager.aidl \ core/java/android/app/usage/IUsageStatsManager.aidl \ core/java/android/bluetooth/IBluetooth.aidl \ core/java/android/bluetooth/IBluetoothA2dp.aidl \ Loading core/java/android/app/timezone/Callback.java 0 → 100644 +76 −0 Original line number Diff line number Diff line /* * Copyright (C) 2017 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.timezone; import android.annotation.IntDef; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; /** * Callback interface for receiving information about an async time zone operation. * The methods will be called on your application's main thread. * * @hide */ // TODO(nfuller): Expose necessary APIs for OEMs with @SystemApi. http://b/31008728 public abstract class Callback { @Retention(RetentionPolicy.SOURCE) @IntDef({SUCCESS, ERROR_UNKNOWN_FAILURE, ERROR_INSTALL_BAD_DISTRO_STRUCTURE, ERROR_INSTALL_BAD_DISTRO_FORMAT_VERSION, ERROR_INSTALL_RULES_TOO_OLD, ERROR_INSTALL_VALIDATION_ERROR}) public @interface AsyncResultCode {} /** * Indicates that an operation succeeded. */ public static final int SUCCESS = 0; /** * Indicates an install / uninstall did not fully succeed for an unknown reason. */ public static final int ERROR_UNKNOWN_FAILURE = 1; /** * Indicates an install failed because of a structural issue with the provided distro, * e.g. it wasn't in the right format or the contents were structured incorrectly. */ public static final int ERROR_INSTALL_BAD_DISTRO_STRUCTURE = 2; /** * Indicates an install failed because of a versioning issue with the provided distro, * e.g. it was created for a different version of Android. */ public static final int ERROR_INSTALL_BAD_DISTRO_FORMAT_VERSION = 3; /** * Indicates an install failed because the rules provided are too old for the device, * e.g. the Android device shipped with a newer rules version. */ public static final int ERROR_INSTALL_RULES_TOO_OLD = 4; /** * Indicates an install failed because the distro contents failed validation. */ public static final int ERROR_INSTALL_VALIDATION_ERROR = 5; /** * Reports the result of an async time zone operation. */ public abstract void onFinished(@AsyncResultCode int status); } core/java/android/app/timezone/DistroFormatVersion.java 0 → 100644 +120 −0 Original line number Diff line number Diff line /* * Copyright (C) 2017 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.timezone; import android.os.Parcel; import android.os.Parcelable; /** * Versioning information about a distro's format or a device's supported format. * * <p>The following properties are included: * <dl> * <dt>majorVersion</dt> * <dd>the major distro format version. Major versions differences are not compatible - e.g. * 2 is not compatible with 1 or 3.</dd> * <dt>minorVersion</dt> * <dd>the minor distro format version. Minor versions should be backwards compatible iff the * major versions match exactly, i.e. version 2.2 will be compatible with 2.1 devices but not * 2.3 devices.</dd> * </dl> * * @hide */ // TODO(nfuller): Expose necessary APIs for OEMs with @SystemApi. http://b/31008728 public final class DistroFormatVersion implements Parcelable { private final int mMajorVersion; private final int mMinorVersion; public DistroFormatVersion(int majorVersion, int minorVersion) { mMajorVersion = Utils.validateVersion("major", majorVersion); mMinorVersion = Utils.validateVersion("minor", minorVersion); } public static final Creator<DistroFormatVersion> CREATOR = new Creator<DistroFormatVersion>() { public DistroFormatVersion createFromParcel(Parcel in) { int majorVersion = in.readInt(); int minorVersion = in.readInt(); return new DistroFormatVersion(majorVersion, minorVersion); } public DistroFormatVersion[] newArray(int size) { return new DistroFormatVersion[size]; } }; public int getMajorVersion() { return mMajorVersion; } public int getMinorVersion() { return mMinorVersion; } @Override public int describeContents() { return 0; } @Override public void writeToParcel(Parcel out, int flags) { out.writeInt(mMajorVersion); out.writeInt(mMinorVersion); } /** * If this object describes a device's supported version and the parameter describes a distro's * version, this method returns whether the device would accept the distro. */ public boolean supports(DistroFormatVersion distroFormatVersion) { return mMajorVersion == distroFormatVersion.mMajorVersion && mMinorVersion <= distroFormatVersion.mMinorVersion; } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } DistroFormatVersion that = (DistroFormatVersion) o; if (mMajorVersion != that.mMajorVersion) { return false; } return mMinorVersion == that.mMinorVersion; } @Override public int hashCode() { int result = mMajorVersion; result = 31 * result + mMinorVersion; return result; } @Override public String toString() { return "DistroFormatVersion{" + "mMajorVersion=" + mMajorVersion + ", mMinorVersion=" + mMinorVersion + '}'; } } core/java/android/app/timezone/DistroRulesVersion.java 0 → 100644 +128 −0 Original line number Diff line number Diff line /* * Copyright (C) 2017 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.timezone; import static android.app.timezone.Utils.validateRulesVersion; import static android.app.timezone.Utils.validateVersion; import android.os.Parcel; import android.os.Parcelable; /** * Versioning information about a set of time zone rules. * * <p>The following properties are included: * <dl> * <dt>rulesVersion</dt> * <dd>the IANA rules version. e.g. "2017a"</dd> * <dt>revision</dt> * <dd>the revision for the rules. Allows there to be several revisions for a given IANA rules * release. Numerically higher is newer.</dd> * </dl> * * @hide */ // TODO(nfuller): Expose necessary APIs for OEMs with @SystemApi. http://b/31008728 public final class DistroRulesVersion implements Parcelable { private final String mRulesVersion; private final int mRevision; public DistroRulesVersion(String rulesVersion, int revision) { mRulesVersion = validateRulesVersion("rulesVersion", rulesVersion); mRevision = validateVersion("revision", revision); } public static final Creator<DistroRulesVersion> CREATOR = new Creator<DistroRulesVersion>() { public DistroRulesVersion createFromParcel(Parcel in) { String rulesVersion = in.readString(); int revision = in.readInt(); return new DistroRulesVersion(rulesVersion, revision); } public DistroRulesVersion[] newArray(int size) { return new DistroRulesVersion[size]; } }; public String getRulesVersion() { return mRulesVersion; } public int getRevision() { return mRevision; } /** * Returns true if this DistroRulesVersion is older than the one supplied. It returns false if * it is the same or newer. This method compares the {@code rulesVersion} and the * {@code revision}. */ public boolean isOlderThan(DistroRulesVersion distroRulesVersion) { int rulesComparison = mRulesVersion.compareTo(distroRulesVersion.mRulesVersion); if (rulesComparison < 0) { return true; } if (rulesComparison > 0) { return false; } return mRevision < distroRulesVersion.mRevision; } @Override public int describeContents() { return 0; } @Override public void writeToParcel(Parcel out, int flags) { out.writeString(mRulesVersion); out.writeInt(mRevision); } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } DistroRulesVersion that = (DistroRulesVersion) o; if (mRevision != that.mRevision) { return false; } return mRulesVersion.equals(that.mRulesVersion); } @Override public int hashCode() { int result = mRulesVersion.hashCode(); result = 31 * result + mRevision; return result; } @Override public String toString() { return "DistroRulesVersion{" + "mRulesVersion='" + mRulesVersion + '\'' + ", mRevision='" + mRevision + '\'' + '}'; } } core/java/android/app/timezone/ICallback.aidl 0 → 100644 +27 −0 Original line number Diff line number Diff line /* * Copyright (C) 2017 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.timezone; /** * Callback interface for a timezone updater to receive information about the success or failure of * an installation/uninstallation attempt. * * {@hide} */ oneway interface ICallback { void onFinished(int error); } No newline at end of file Loading
Android.mk +2 −0 Original line number Diff line number Diff line Loading @@ -103,6 +103,8 @@ LOCAL_SRC_FILES += \ core/java/android/app/backup/IFullBackupRestoreObserver.aidl \ core/java/android/app/backup/IRestoreObserver.aidl \ core/java/android/app/backup/IRestoreSession.aidl \ core/java/android/app/timezone/ICallback.aidl \ core/java/android/app/timezone/IRulesManager.aidl \ core/java/android/app/usage/IUsageStatsManager.aidl \ core/java/android/bluetooth/IBluetooth.aidl \ core/java/android/bluetooth/IBluetoothA2dp.aidl \ Loading
core/java/android/app/timezone/Callback.java 0 → 100644 +76 −0 Original line number Diff line number Diff line /* * Copyright (C) 2017 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.timezone; import android.annotation.IntDef; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; /** * Callback interface for receiving information about an async time zone operation. * The methods will be called on your application's main thread. * * @hide */ // TODO(nfuller): Expose necessary APIs for OEMs with @SystemApi. http://b/31008728 public abstract class Callback { @Retention(RetentionPolicy.SOURCE) @IntDef({SUCCESS, ERROR_UNKNOWN_FAILURE, ERROR_INSTALL_BAD_DISTRO_STRUCTURE, ERROR_INSTALL_BAD_DISTRO_FORMAT_VERSION, ERROR_INSTALL_RULES_TOO_OLD, ERROR_INSTALL_VALIDATION_ERROR}) public @interface AsyncResultCode {} /** * Indicates that an operation succeeded. */ public static final int SUCCESS = 0; /** * Indicates an install / uninstall did not fully succeed for an unknown reason. */ public static final int ERROR_UNKNOWN_FAILURE = 1; /** * Indicates an install failed because of a structural issue with the provided distro, * e.g. it wasn't in the right format or the contents were structured incorrectly. */ public static final int ERROR_INSTALL_BAD_DISTRO_STRUCTURE = 2; /** * Indicates an install failed because of a versioning issue with the provided distro, * e.g. it was created for a different version of Android. */ public static final int ERROR_INSTALL_BAD_DISTRO_FORMAT_VERSION = 3; /** * Indicates an install failed because the rules provided are too old for the device, * e.g. the Android device shipped with a newer rules version. */ public static final int ERROR_INSTALL_RULES_TOO_OLD = 4; /** * Indicates an install failed because the distro contents failed validation. */ public static final int ERROR_INSTALL_VALIDATION_ERROR = 5; /** * Reports the result of an async time zone operation. */ public abstract void onFinished(@AsyncResultCode int status); }
core/java/android/app/timezone/DistroFormatVersion.java 0 → 100644 +120 −0 Original line number Diff line number Diff line /* * Copyright (C) 2017 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.timezone; import android.os.Parcel; import android.os.Parcelable; /** * Versioning information about a distro's format or a device's supported format. * * <p>The following properties are included: * <dl> * <dt>majorVersion</dt> * <dd>the major distro format version. Major versions differences are not compatible - e.g. * 2 is not compatible with 1 or 3.</dd> * <dt>minorVersion</dt> * <dd>the minor distro format version. Minor versions should be backwards compatible iff the * major versions match exactly, i.e. version 2.2 will be compatible with 2.1 devices but not * 2.3 devices.</dd> * </dl> * * @hide */ // TODO(nfuller): Expose necessary APIs for OEMs with @SystemApi. http://b/31008728 public final class DistroFormatVersion implements Parcelable { private final int mMajorVersion; private final int mMinorVersion; public DistroFormatVersion(int majorVersion, int minorVersion) { mMajorVersion = Utils.validateVersion("major", majorVersion); mMinorVersion = Utils.validateVersion("minor", minorVersion); } public static final Creator<DistroFormatVersion> CREATOR = new Creator<DistroFormatVersion>() { public DistroFormatVersion createFromParcel(Parcel in) { int majorVersion = in.readInt(); int minorVersion = in.readInt(); return new DistroFormatVersion(majorVersion, minorVersion); } public DistroFormatVersion[] newArray(int size) { return new DistroFormatVersion[size]; } }; public int getMajorVersion() { return mMajorVersion; } public int getMinorVersion() { return mMinorVersion; } @Override public int describeContents() { return 0; } @Override public void writeToParcel(Parcel out, int flags) { out.writeInt(mMajorVersion); out.writeInt(mMinorVersion); } /** * If this object describes a device's supported version and the parameter describes a distro's * version, this method returns whether the device would accept the distro. */ public boolean supports(DistroFormatVersion distroFormatVersion) { return mMajorVersion == distroFormatVersion.mMajorVersion && mMinorVersion <= distroFormatVersion.mMinorVersion; } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } DistroFormatVersion that = (DistroFormatVersion) o; if (mMajorVersion != that.mMajorVersion) { return false; } return mMinorVersion == that.mMinorVersion; } @Override public int hashCode() { int result = mMajorVersion; result = 31 * result + mMinorVersion; return result; } @Override public String toString() { return "DistroFormatVersion{" + "mMajorVersion=" + mMajorVersion + ", mMinorVersion=" + mMinorVersion + '}'; } }
core/java/android/app/timezone/DistroRulesVersion.java 0 → 100644 +128 −0 Original line number Diff line number Diff line /* * Copyright (C) 2017 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.timezone; import static android.app.timezone.Utils.validateRulesVersion; import static android.app.timezone.Utils.validateVersion; import android.os.Parcel; import android.os.Parcelable; /** * Versioning information about a set of time zone rules. * * <p>The following properties are included: * <dl> * <dt>rulesVersion</dt> * <dd>the IANA rules version. e.g. "2017a"</dd> * <dt>revision</dt> * <dd>the revision for the rules. Allows there to be several revisions for a given IANA rules * release. Numerically higher is newer.</dd> * </dl> * * @hide */ // TODO(nfuller): Expose necessary APIs for OEMs with @SystemApi. http://b/31008728 public final class DistroRulesVersion implements Parcelable { private final String mRulesVersion; private final int mRevision; public DistroRulesVersion(String rulesVersion, int revision) { mRulesVersion = validateRulesVersion("rulesVersion", rulesVersion); mRevision = validateVersion("revision", revision); } public static final Creator<DistroRulesVersion> CREATOR = new Creator<DistroRulesVersion>() { public DistroRulesVersion createFromParcel(Parcel in) { String rulesVersion = in.readString(); int revision = in.readInt(); return new DistroRulesVersion(rulesVersion, revision); } public DistroRulesVersion[] newArray(int size) { return new DistroRulesVersion[size]; } }; public String getRulesVersion() { return mRulesVersion; } public int getRevision() { return mRevision; } /** * Returns true if this DistroRulesVersion is older than the one supplied. It returns false if * it is the same or newer. This method compares the {@code rulesVersion} and the * {@code revision}. */ public boolean isOlderThan(DistroRulesVersion distroRulesVersion) { int rulesComparison = mRulesVersion.compareTo(distroRulesVersion.mRulesVersion); if (rulesComparison < 0) { return true; } if (rulesComparison > 0) { return false; } return mRevision < distroRulesVersion.mRevision; } @Override public int describeContents() { return 0; } @Override public void writeToParcel(Parcel out, int flags) { out.writeString(mRulesVersion); out.writeInt(mRevision); } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } DistroRulesVersion that = (DistroRulesVersion) o; if (mRevision != that.mRevision) { return false; } return mRulesVersion.equals(that.mRulesVersion); } @Override public int hashCode() { int result = mRulesVersion.hashCode(); result = 31 * result + mRevision; return result; } @Override public String toString() { return "DistroRulesVersion{" + "mRulesVersion='" + mRulesVersion + '\'' + ", mRevision='" + mRevision + '\'' + '}'; } }
core/java/android/app/timezone/ICallback.aidl 0 → 100644 +27 −0 Original line number Diff line number Diff line /* * Copyright (C) 2017 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.timezone; /** * Callback interface for a timezone updater to receive information about the success or failure of * an installation/uninstallation attempt. * * {@hide} */ oneway interface ICallback { void onFinished(int error); } No newline at end of file