| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.view; |
| 18 |
|
| 19 |
import static android.view.Surface.ROTATION_0; |
| 20 |
|
| 21 |
import android.annotation.NonNull; |
| 22 |
import android.annotation.Nullable; |
| 23 |
import android.graphics.Rect; |
| 24 |
import android.os.Parcelable; |
| 25 |
|
| 26 |
import com.android.internal.util.ArrayUtils; |
| 27 |
import com.android.internal.util.DataClass; |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
@DataClass( |
| 35 |
genEqualsHashCode = true, |
| 36 |
genConstructor = false, |
| 37 |
genAidl = false, |
| 38 |
genGetters = false |
| 39 |
) |
| 40 |
public class PrivacyIndicatorBounds implements Parcelable { |
| 41 |
|
| 42 |
private final @NonNull Rect[] mStaticBounds; |
| 43 |
private final int mRotation; |
| 44 |
|
| 45 |
public PrivacyIndicatorBounds() { |
| 46 |
mStaticBounds = new Rect[4]; |
| 47 |
mRotation = ROTATION_0; |
| 48 |
} |
| 49 |
|
| 50 |
public PrivacyIndicatorBounds(@NonNull Rect[] staticBounds, @Surface.Rotation int rotation) { |
| 51 |
mStaticBounds = staticBounds; |
| 52 |
mRotation = rotation; |
| 53 |
} |
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
public PrivacyIndicatorBounds updateStaticBounds(@NonNull Rect[] staticPositions) { |
| 59 |
return new PrivacyIndicatorBounds(staticPositions, mRotation); |
| 60 |
} |
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
public PrivacyIndicatorBounds updateBoundsForRotation(@Nullable Rect bounds, |
| 67 |
@Surface.Rotation int rotation) { |
| 68 |
if (rotation >= mStaticBounds.length || rotation < 0) { |
| 69 |
return this; |
| 70 |
} |
| 71 |
Rect[] newBounds = ArrayUtils.cloneOrNull(mStaticBounds); |
| 72 |
newBounds[rotation] = bounds; |
| 73 |
return updateStaticBounds(newBounds); |
| 74 |
} |
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
public PrivacyIndicatorBounds inset(int insetLeft, int insetTop, int insetRight, |
| 80 |
int insetBottom) { |
| 81 |
if (insetLeft == 0 && insetTop == 0 && insetRight == 0 && insetBottom == 0) { |
| 82 |
return this; |
| 83 |
} |
| 84 |
Rect[] insetStaticBounds = new Rect[mStaticBounds.length]; |
| 85 |
for (int i = 0; i < mStaticBounds.length; i++) { |
| 86 |
insetStaticBounds[i] = |
| 87 |
insetRect(mStaticBounds[i], insetLeft, insetTop, insetRight, insetBottom); |
| 88 |
} |
| 89 |
return updateStaticBounds(insetStaticBounds); |
| 90 |
} |
| 91 |
|
| 92 |
private static Rect insetRect(Rect orig, int insetLeft, int insetTop, int insetRight, |
| 93 |
int insetBottom) { |
| 94 |
if (orig == null) { |
| 95 |
return null; |
| 96 |
} |
| 97 |
int left = Math.max(0, orig.left - insetLeft); |
| 98 |
int top = Math.max(0, orig.top - insetTop); |
| 99 |
int right = Math.max(left, orig.right - insetRight); |
| 100 |
int bottom = Math.max(top, orig.bottom - insetBottom); |
| 101 |
return new Rect(left, top, right, bottom); |
| 102 |
} |
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
public PrivacyIndicatorBounds rotate(@Surface.Rotation int rotation) { |
| 108 |
if (rotation == ROTATION_0) { |
| 109 |
return this; |
| 110 |
} |
| 111 |
return new PrivacyIndicatorBounds(mStaticBounds, rotation); |
| 112 |
} |
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
public PrivacyIndicatorBounds scale(float scale) { |
| 118 |
if (scale == 1f) { |
| 119 |
return this; |
| 120 |
} |
| 121 |
|
| 122 |
Rect[] scaledStaticPos = new Rect[mStaticBounds.length]; |
| 123 |
for (int i = 0; i < mStaticBounds.length; i++) { |
| 124 |
scaledStaticPos[i] = scaleRect(mStaticBounds[i], scale); |
| 125 |
} |
| 126 |
return new PrivacyIndicatorBounds(scaledStaticPos, mRotation); |
| 127 |
} |
| 128 |
|
| 129 |
private static Rect scaleRect(Rect orig, float scale) { |
| 130 |
if (orig == null) { |
| 131 |
return null; |
| 132 |
} |
| 133 |
|
| 134 |
Rect newRect = new Rect(orig); |
| 135 |
newRect.scale(scale); |
| 136 |
return newRect; |
| 137 |
} |
| 138 |
|
| 139 |
public Rect getStaticPrivacyIndicatorBounds() { |
| 140 |
return mStaticBounds[mRotation]; |
| 141 |
} |
| 142 |
|
| 143 |
@Override |
| 144 |
public String toString() { |
| 145 |
return "PrivacyIndicatorBounds {static bounds=" + getStaticPrivacyIndicatorBounds() |
| 146 |
+ " rotation=" + mRotation + "}"; |
| 147 |
} |
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
@Override |
| 165 |
@DataClass.Generated.Member |
| 166 |
public boolean equals(@Nullable Object o) { |
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
if (this == o) return true; |
| 172 |
if (o == null || getClass() != o.getClass()) return false; |
| 173 |
@SuppressWarnings("unchecked") |
| 174 |
PrivacyIndicatorBounds that = (PrivacyIndicatorBounds) o; |
| 175 |
|
| 176 |
return true |
| 177 |
&& java.util.Arrays.equals(mStaticBounds, that.mStaticBounds) |
| 178 |
&& mRotation == that.mRotation; |
| 179 |
} |
| 180 |
|
| 181 |
@Override |
| 182 |
@DataClass.Generated.Member |
| 183 |
public int hashCode() { |
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
int _hash = 1; |
| 188 |
_hash = 31 * _hash + java.util.Arrays.hashCode(mStaticBounds); |
| 189 |
_hash = 31 * _hash + mRotation; |
| 190 |
return _hash; |
| 191 |
} |
| 192 |
|
| 193 |
@Override |
| 194 |
@DataClass.Generated.Member |
| 195 |
public void writeToParcel(@NonNull android.os.Parcel dest, int flags) { |
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
dest.writeTypedArray(mStaticBounds, flags); |
| 200 |
dest.writeInt(mRotation); |
| 201 |
} |
| 202 |
|
| 203 |
@Override |
| 204 |
@DataClass.Generated.Member |
| 205 |
public int describeContents() { return 0; } |
| 206 |
|
| 207 |
|
| 208 |
@SuppressWarnings({"unchecked", "RedundantCast"}) |
| 209 |
@DataClass.Generated.Member |
| 210 |
protected PrivacyIndicatorBounds(@NonNull android.os.Parcel in) { |
| 211 |
|
| 212 |
|
| 213 |
|
| 214 |
Rect[] staticBounds = (Rect[]) in.createTypedArray(Rect.CREATOR); |
| 215 |
int rotation = in.readInt(); |
| 216 |
|
| 217 |
this.mStaticBounds = staticBounds; |
| 218 |
com.android.internal.util.AnnotationValidations.validate( |
| 219 |
NonNull.class, null, mStaticBounds); |
| 220 |
this.mRotation = rotation; |
| 221 |
|
| 222 |
|
| 223 |
} |
| 224 |
|
| 225 |
@DataClass.Generated.Member |
| 226 |
public static final @NonNull Parcelable.Creator<PrivacyIndicatorBounds> CREATOR |
| 227 |
= new Parcelable.Creator<PrivacyIndicatorBounds>() { |
| 228 |
@Override |
| 229 |
public PrivacyIndicatorBounds[] newArray(int size) { |
| 230 |
return new PrivacyIndicatorBounds[size]; |
| 231 |
} |
| 232 |
|
| 233 |
@Override |
| 234 |
public PrivacyIndicatorBounds createFromParcel(@NonNull android.os.Parcel in) { |
| 235 |
return new PrivacyIndicatorBounds(in); |
| 236 |
} |
| 237 |
}; |
| 238 |
|
| 239 |
@DataClass.Generated( |
| 240 |
time = 1621526273838L, |
| 241 |
codegenVersion = "1.0.23", |
| 242 |
sourceFile = "frameworks/base/core/java/android/view/PrivacyIndicatorBounds.java", |
| 243 |
inputSignatures = "private final @android.annotation.NonNull android.graphics.Rect[] mStaticBounds\nprivate final int mRotation\npublic android.view.PrivacyIndicatorBounds updateStaticBounds(android.graphics.Rect[])\npublic android.view.PrivacyIndicatorBounds updateBoundsForRotation(android.graphics.Rect,int)\npublic android.view.PrivacyIndicatorBounds inset(int,int,int,int)\nprivate static android.graphics.Rect insetRect(android.graphics.Rect,int,int,int,int)\npublic android.view.PrivacyIndicatorBounds rotate(int)\npublic android.view.PrivacyIndicatorBounds scale(float)\nprivate static android.graphics.Rect scaleRect(android.graphics.Rect,float)\npublic android.graphics.Rect getStaticPrivacyIndicatorBounds()\npublic @java.lang.Override java.lang.String toString()\nclass PrivacyIndicatorBounds extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genEqualsHashCode=true, genConstructor=false, genAidl=false, genGetters=false)") |
| 244 |
@Deprecated |
| 245 |
private void __metadata() {} |
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
|
| 250 |
|
| 251 |
} |