1 /*
2  * Copyright (C) 2021 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 com.android.bedstead.testapp;
18 
19 import android.os.Bundle;
20 
21 import androidx.annotation.Nullable;
22 
23 import com.android.queryable.info.ActivityInfo;
24 import com.android.queryable.info.ServiceInfo;
25 
26 import java.util.HashSet;
27 import java.util.Set;
28 
29 /** Details about a queryable test app. */
30 class TestAppDetails {
31     TestappProtos.AndroidApp mApp;
32     int mResourceIdentifier;
33     final Bundle mMetadata = new Bundle();
34     final Set<String> mPermissions = new HashSet<>();
35     final Set<ActivityInfo> mActivities = new HashSet<>();
36     final Set<ServiceInfo> mServices = new HashSet<>();
37 
38     /**
39      * Get the shared user ID of the test app, or {@code Null} if none.
40      */
41     @Nullable
sharedUserId()42     public String sharedUserId() {
43         if (mApp.getSharedUserId().isEmpty()) {
44             return null;
45         }
46 
47         return mApp.getSharedUserId();
48     }
49 
50     @Override
toString()51     public String toString() {
52         return "TestAppDetails{"
53                 + "mApp=" + mApp
54                 + ", mResourceIdentifier=" + mResourceIdentifier
55                 + ", mMetadata=" + mMetadata
56                 + ", mPermissions=" + mPermissions
57                 + ", mActivities=" + mActivities
58                 + ", mServices=" + mServices
59                 + '}';
60     }
61 }
62