1 /* 2 * Copyright (C) 2023 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 import android.annotation.NonNull; 20 import android.annotation.Nullable; 21 import android.annotation.SystemApi; 22 import android.annotation.TestApi; 23 import android.os.Parcel; 24 25 /** 26 * Class used to identify a default value for the authority of the {@link EnforcingAdmin} setting 27 * a policy, meaning it is not one of the other known subclasses of {@link Authority}, this would be 28 * the case for example for a system component setting the policy. 29 * 30 * @hide 31 */ 32 @SystemApi 33 public final class UnknownAuthority extends Authority { 34 35 /** 36 * Object representing an unknown authority. 37 * 38 * @hide 39 */ 40 @TestApi 41 @NonNull 42 public static final UnknownAuthority UNKNOWN_AUTHORITY = new UnknownAuthority(); 43 44 /** 45 * Creates an authority that represents an admin that can set a policy but 46 * doesn't have a known authority (e.g. a system components). 47 */ UnknownAuthority()48 public UnknownAuthority() {} 49 50 @Override toString()51 public String toString() { 52 return "DefaultAuthority {}"; 53 } 54 55 @Override equals(@ullable Object o)56 public boolean equals(@Nullable Object o) { 57 if (this == o) return true; 58 return o != null && getClass() == o.getClass(); 59 } 60 61 @Override hashCode()62 public int hashCode() { 63 return 0; 64 } 65 66 @Override describeContents()67 public int describeContents() { 68 return 0; 69 } 70 71 @Override writeToParcel(@onNull Parcel dest, int flags)72 public void writeToParcel(@NonNull Parcel dest, int flags) {} 73 74 @NonNull 75 public static final Creator<UnknownAuthority> CREATOR = 76 new Creator<UnknownAuthority>() { 77 @Override 78 public UnknownAuthority createFromParcel(Parcel source) { 79 return UNKNOWN_AUTHORITY; 80 } 81 82 @Override 83 public UnknownAuthority[] newArray(int size) { 84 return new UnknownAuthority[size]; 85 } 86 }; 87 } 88