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 androidx.annotation.Nullable; 20 21 import com.android.queryable.info.ActivityInfo; 22 import com.android.queryable.info.MetadataInfo; 23 import com.android.queryable.info.ReceiverInfo; 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 final Set<MetadataInfo> mMetadata = new HashSet<>(); 33 final Set<String> mPermissions = new HashSet<>(); 34 final Set<ActivityInfo> mActivities = new HashSet<>(); 35 final Set<ActivityInfo> mActivityAliases = new HashSet<>(); 36 final Set<ServiceInfo> mServices = new HashSet<>(); 37 final Set<ReceiverInfo> mReceivers = new HashSet<>(); 38 final Set<Integer> mPolicies = new HashSet<>(); 39 40 /** 41 * Gets the shared user ID of the test app, or {@code Null} if none. 42 */ 43 @Nullable sharedUserId()44 public String sharedUserId() { 45 if (mApp.getSharedUserId().isEmpty()) { 46 return null; 47 } 48 49 return mApp.getSharedUserId(); 50 } 51 52 /** 53 * Gets the label of the test app, or {@code Null} if none. 54 */ 55 @Nullable label()56 public String label() { 57 if (mApp.getLabel().isEmpty()) { 58 return null; 59 } 60 61 return mApp.getLabel(); 62 } 63 crossProfile()64 public boolean crossProfile() { 65 return mApp.getCrossProfile(); 66 } 67 68 @Override toString()69 public String toString() { 70 return "TestAppDetails{" 71 + "mApp=" + mApp 72 + ", mMetadata=" + mMetadata 73 + ", mPermissions=" + mPermissions 74 + ", mActivities=" + mActivities 75 + ", mActivityAliases=" + mActivityAliases 76 + ", mServices=" + mServices 77 + ", mReceivers=" + mReceivers 78 + ", mPolicies=" + mPolicies 79 + '}'; 80 } 81 } 82