1 /* 2 * Copyright 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.credentials.ui; 18 19 import android.annotation.NonNull; 20 import android.annotation.SuppressLint; 21 import android.annotation.TestApi; 22 import android.os.Parcel; 23 import android.os.Parcelable; 24 25 import com.android.internal.util.AnnotationValidations; 26 27 /** 28 * Super class for data structures that hold metadata and credential entries for a single provider. 29 * 30 * @hide 31 */ 32 @TestApi 33 @SuppressLint({"ParcelCreator", "ParcelNotFinal"}) 34 public abstract class ProviderData implements Parcelable { 35 36 /** 37 * The intent extra key for the list of {@code ProviderData} from active providers when 38 * launching the UX activities. 39 */ 40 public static final String EXTRA_ENABLED_PROVIDER_DATA_LIST = 41 "android.credentials.ui.extra.ENABLED_PROVIDER_DATA_LIST"; 42 /** 43 * The intent extra key for the list of {@code ProviderData} from disabled providers when 44 * launching the UX activities. 45 */ 46 public static final String EXTRA_DISABLED_PROVIDER_DATA_LIST = 47 "android.credentials.ui.extra.DISABLED_PROVIDER_DATA_LIST"; 48 49 @NonNull 50 private final String mProviderFlattenedComponentName; 51 ProviderData( @onNull String providerFlattenedComponentName)52 public ProviderData( 53 @NonNull String providerFlattenedComponentName) { 54 mProviderFlattenedComponentName = providerFlattenedComponentName; 55 } 56 57 /** 58 * Returns provider component name. 59 * It also serves as the unique identifier for this provider. 60 */ 61 @NonNull getProviderFlattenedComponentName()62 public String getProviderFlattenedComponentName() { 63 return mProviderFlattenedComponentName; 64 } 65 ProviderData(@onNull Parcel in)66 protected ProviderData(@NonNull Parcel in) { 67 String providerFlattenedComponentName = in.readString8(); 68 mProviderFlattenedComponentName = providerFlattenedComponentName; 69 AnnotationValidations.validate(NonNull.class, null, mProviderFlattenedComponentName); 70 } 71 72 @Override writeToParcel(@onNull Parcel dest, int flags)73 public void writeToParcel(@NonNull Parcel dest, int flags) { 74 dest.writeString8(mProviderFlattenedComponentName); 75 } 76 77 @Override describeContents()78 public int describeContents() { 79 return 0; 80 } 81 } 82