• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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;
18 
19 import android.annotation.NonNull;
20 import android.os.Parcel;
21 import android.os.Parcelable;
22 
23 import com.android.internal.util.Preconditions;
24 
25 import java.util.List;
26 import java.util.Objects;
27 
28 /**
29  * Sets the enabled list of credential manager providers.
30  *
31  * @hide
32  */
33 public final class SetEnabledProvidersRequest implements Parcelable {
34 
35     /** List of providers. */
36     @NonNull private final List<String> mProviders;
37 
38     /**
39      * Creates a {@link SetEnabledProvidersRequest} with a list of providers. The list is made up of
40      * strings that are flattened component names of the service that is the credman provider.
41      *
42      * @throws NullPointerException If args are null.
43      */
SetEnabledProvidersRequest(@onNull List<String> providers)44     public SetEnabledProvidersRequest(@NonNull List<String> providers) {
45         Objects.requireNonNull(providers, "providers must not be null");
46         Preconditions.checkCollectionElementsNotNull(providers, /* valueName= */ "providers");
47         mProviders = providers;
48     }
49 
SetEnabledProvidersRequest(@onNull Parcel in)50     private SetEnabledProvidersRequest(@NonNull Parcel in) {
51         mProviders = in.createStringArrayList();
52     }
53 
54     public static final @NonNull Creator<SetEnabledProvidersRequest> CREATOR =
55             new Creator<SetEnabledProvidersRequest>() {
56                 @Override
57                 public SetEnabledProvidersRequest createFromParcel(Parcel in) {
58                     return new SetEnabledProvidersRequest(in);
59                 }
60 
61                 @Override
62                 public SetEnabledProvidersRequest[] newArray(int size) {
63                     return new SetEnabledProvidersRequest[size];
64                 }
65             };
66 
67     @Override
describeContents()68     public int describeContents() {
69         return 0;
70     }
71 
72     @Override
writeToParcel(@onNull Parcel dest, int flags)73     public void writeToParcel(@NonNull Parcel dest, int flags) {
74         dest.writeStringList(mProviders);
75     }
76 
77     /** Returns the list of flattened Credential Manager provider component names as strings. */
getProviderComponentNames()78     public @NonNull List<String> getProviderComponentNames() {
79         return mProviders;
80     }
81 }
82