1 /* 2 * Copyright (C) 2019 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.internal.compat; 18 19 import android.annotation.Nullable; 20 import android.os.Parcel; 21 import android.os.Parcelable; 22 23 /** 24 * This class is a parcelable version of {@link com.android.server.compat.Change}. 25 * 26 * @hide 27 */ 28 public class CompatibilityChangeInfo implements Parcelable { 29 private final long mChangeId; 30 private final @Nullable String mName; 31 private final int mEnableAfterTargetSdk; 32 private final boolean mDisabled; 33 private final boolean mLoggingOnly; 34 private final @Nullable String mDescription; 35 getId()36 public long getId() { 37 return mChangeId; 38 } 39 40 @Nullable getName()41 public String getName() { 42 return mName; 43 } 44 getEnableAfterTargetSdk()45 public int getEnableAfterTargetSdk() { 46 return mEnableAfterTargetSdk; 47 } 48 getDisabled()49 public boolean getDisabled() { 50 return mDisabled; 51 } 52 getLoggingOnly()53 public boolean getLoggingOnly() { 54 return mLoggingOnly; 55 } 56 getDescription()57 public String getDescription() { 58 return mDescription; 59 } 60 CompatibilityChangeInfo( Long changeId, String name, int enableAfterTargetSdk, boolean disabled, boolean loggingOnly, String description)61 public CompatibilityChangeInfo( 62 Long changeId, String name, int enableAfterTargetSdk, boolean disabled, 63 boolean loggingOnly, String description) { 64 this.mChangeId = changeId; 65 this.mName = name; 66 this.mEnableAfterTargetSdk = enableAfterTargetSdk; 67 this.mDisabled = disabled; 68 this.mLoggingOnly = loggingOnly; 69 this.mDescription = description; 70 } 71 CompatibilityChangeInfo(Parcel in)72 private CompatibilityChangeInfo(Parcel in) { 73 mChangeId = in.readLong(); 74 mName = in.readString(); 75 mEnableAfterTargetSdk = in.readInt(); 76 mDisabled = in.readBoolean(); 77 mLoggingOnly = in.readBoolean(); 78 mDescription = in.readString(); 79 } 80 81 @Override describeContents()82 public int describeContents() { 83 return 0; 84 } 85 86 @Override writeToParcel(Parcel dest, int flags)87 public void writeToParcel(Parcel dest, int flags) { 88 dest.writeLong(mChangeId); 89 dest.writeString(mName); 90 dest.writeInt(mEnableAfterTargetSdk); 91 dest.writeBoolean(mDisabled); 92 dest.writeBoolean(mLoggingOnly); 93 dest.writeString(mDescription); 94 } 95 96 @Override toString()97 public String toString() { 98 StringBuilder sb = new StringBuilder("CompatibilityChangeInfo(") 99 .append(getId()); 100 if (getName() != null) { 101 sb.append("; name=").append(getName()); 102 } 103 if (getEnableAfterTargetSdk() != -1) { 104 sb.append("; enableAfterTargetSdk=").append(getEnableAfterTargetSdk()); 105 } 106 if (getDisabled()) { 107 sb.append("; disabled"); 108 } 109 if (getLoggingOnly()) { 110 sb.append("; loggingOnly"); 111 } 112 return sb.append(")").toString(); 113 } 114 115 @Override equals(Object o)116 public boolean equals(Object o) { 117 if (this == o) { 118 return true; 119 } 120 if (o == null || !(o instanceof CompatibilityChangeInfo)) { 121 return false; 122 } 123 CompatibilityChangeInfo that = (CompatibilityChangeInfo) o; 124 return this.mChangeId == that.mChangeId 125 && this.mName.equals(that.mName) 126 && this.mEnableAfterTargetSdk == that.mEnableAfterTargetSdk 127 && this.mDisabled == that.mDisabled 128 && this.mLoggingOnly == that.mLoggingOnly 129 && this.mDescription.equals(that.mDescription); 130 131 } 132 133 public static final Parcelable.Creator<CompatibilityChangeInfo> CREATOR = 134 new Parcelable.Creator<CompatibilityChangeInfo>() { 135 136 @Override 137 public CompatibilityChangeInfo createFromParcel(Parcel in) { 138 return new CompatibilityChangeInfo(in); 139 } 140 141 @Override 142 public CompatibilityChangeInfo[] newArray(int size) { 143 return new CompatibilityChangeInfo[size]; 144 } 145 }; 146 } 147