1 /* 2 * Copyright (C) 2022 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.app.admin; 18 19 20 import android.annotation.NonNull; 21 import android.annotation.Nullable; 22 import android.annotation.TestApi; 23 import android.os.Parcel; 24 import android.os.Parcelable; 25 26 /** 27 * Class to identify a most-recent-setter wins resolution mechanism that is used to resolve the 28 * enforced policy when being set by multiple admins (see 29 * {@link PolicyState#getResolutionMechanism()}). 30 * 31 * @hide 32 */ 33 @TestApi 34 public final class MostRecent<V> extends ResolutionMechanism<V> { 35 36 /** 37 * Indicates that the most recent setter of the policy wins the resolution. 38 */ 39 @NonNull 40 public static final MostRecent<?> MOST_RECENT = new MostRecent<>(); 41 42 @Override equals(@ullable Object o)43 public boolean equals(@Nullable Object o) { 44 if (this == o) return true; 45 return o != null && getClass() == o.getClass(); 46 } 47 48 @Override hashCode()49 public int hashCode() { 50 return 0; 51 } 52 53 @Override toString()54 public String toString() { 55 return "MostRecent {}"; 56 } 57 58 @Override describeContents()59 public int describeContents() { 60 return 0; 61 } 62 63 @Override writeToParcel(@onNull Parcel dest, int flags)64 public void writeToParcel(@NonNull Parcel dest, int flags) {} 65 66 @NonNull 67 public static final Parcelable.Creator<MostRecent<?>> CREATOR = 68 new Parcelable.Creator<MostRecent<?>>() { 69 @Override 70 public MostRecent<?> createFromParcel(Parcel source) { 71 return new MostRecent<>(); 72 } 73 74 @Override 75 public MostRecent<?>[] newArray(int size) { 76 return new MostRecent[size]; 77 } 78 }; 79 } 80