• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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      * Gets 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     /**
51      * Gets the label of the test app, or {@code Null} if none.
52      */
53     @Nullable
label()54     public String label() {
55         if (mApp.getLabel().isEmpty()) {
56             return null;
57         }
58 
59         return mApp.getLabel();
60     }
61 
crossProfile()62     public boolean crossProfile() {
63         return mApp.getCrossProfile();
64     }
65 
66     @Override
toString()67     public String toString() {
68         return "TestAppDetails{"
69                 + "mApp=" + mApp
70                 + ", mResourceIdentifier=" + mResourceIdentifier
71                 + ", mMetadata=" + mMetadata
72                 + ", mPermissions=" + mPermissions
73                 + ", mActivities=" + mActivities
74                 + ", mServices=" + mServices
75                 + '}';
76     }
77 }
78