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