1 /* 2 * Copyright (C) 2024 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 android.window; 18 19 import android.annotation.NonNull; 20 import android.annotation.Nullable; 21 import android.os.Parcel; 22 import android.os.Parcelable; 23 24 import java.util.Objects; 25 26 /** 27 * Data object of params for Keyguard related {@link WindowContainerTransaction} operation. 28 * 29 * @hide 30 */ 31 public final class KeyguardState implements Parcelable { 32 33 private final boolean mKeyguardShowing; 34 35 private final boolean mAodShowing; 36 37 KeyguardState(boolean keyguardShowing, boolean aodShowing)38 private KeyguardState(boolean keyguardShowing, boolean aodShowing) { 39 mKeyguardShowing = keyguardShowing; 40 mAodShowing = aodShowing; 41 } 42 KeyguardState(Parcel in)43 private KeyguardState(Parcel in) { 44 mKeyguardShowing = in.readBoolean(); 45 mAodShowing = in.readBoolean(); 46 } 47 48 @Override writeToParcel(@onNull Parcel dest, int flags)49 public void writeToParcel(@NonNull Parcel dest, int flags) { 50 dest.writeBoolean(mKeyguardShowing); 51 dest.writeBoolean(mAodShowing); 52 } 53 54 @NonNull 55 public static final Creator<KeyguardState> CREATOR = 56 new Creator<KeyguardState>() { 57 @Override 58 public KeyguardState createFromParcel(Parcel in) { 59 return new KeyguardState(in); 60 } 61 62 @Override 63 public KeyguardState[] newArray(int size) { 64 return new KeyguardState[size]; 65 } 66 }; 67 68 /** Returns the keyguard showing value. */ getKeyguardShowing()69 public boolean getKeyguardShowing() { 70 return mKeyguardShowing; 71 } 72 73 /** Returns the aod showing value. */ getAodShowing()74 public boolean getAodShowing() { 75 return mAodShowing; 76 } 77 78 @Override toString()79 public String toString() { 80 return "KeyguardState{ keyguardShowing=" + mKeyguardShowing 81 + ", aodShowing=" + mAodShowing 82 + '}'; 83 } 84 85 @Override hashCode()86 public int hashCode() { 87 return Objects.hash(mKeyguardShowing, mAodShowing); 88 } 89 90 @Override equals(@ullable Object obj)91 public boolean equals(@Nullable Object obj) { 92 if (!(obj instanceof KeyguardState other)) { 93 return false; 94 } 95 return mKeyguardShowing == other.mKeyguardShowing 96 && mAodShowing == other.mAodShowing; 97 } 98 99 @Override describeContents()100 public int describeContents() { 101 return 0; 102 } 103 104 /** Builder to construct the {@link KeyguardState}. */ 105 public static final class Builder { 106 private boolean mKeyguardShowing; 107 108 private boolean mAodShowing; 109 Builder()110 public Builder() { 111 } 112 113 /** 114 * Sets the boolean value for this operation. 115 */ 116 @NonNull setKeyguardShowing(boolean keyguardShowing)117 public Builder setKeyguardShowing(boolean keyguardShowing) { 118 mKeyguardShowing = keyguardShowing; 119 return this; 120 } 121 122 /** 123 * Sets the boolean value for this operation. 124 */ 125 @NonNull setAodShowing(boolean aodShowing)126 public Builder setAodShowing(boolean aodShowing) { 127 mAodShowing = aodShowing; 128 return this; 129 } 130 131 /** 132 * Constructs the {@link KeyguardState}. 133 */ 134 @NonNull build()135 public KeyguardState build() { 136 return new KeyguardState(mKeyguardShowing, mAodShowing); 137 } 138 } 139 } 140