1 /*
2  * Copyright (C) 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 com.android.server.pm.resolution;
18 
19 import android.annotation.NonNull;
20 import android.annotation.Nullable;
21 import android.annotation.UserIdInt;
22 import android.content.ComponentName;
23 import android.content.Intent;
24 import android.content.pm.ProviderInfo;
25 import android.content.pm.ResolveInfo;
26 
27 import com.android.internal.annotations.VisibleForTesting;
28 import com.android.internal.pm.pkg.component.ParsedActivity;
29 import com.android.internal.pm.pkg.component.ParsedProvider;
30 import com.android.internal.pm.pkg.component.ParsedService;
31 import com.android.server.pm.Computer;
32 import com.android.server.pm.DumpState;
33 
34 import java.io.PrintWriter;
35 import java.util.List;
36 
37 public interface ComponentResolverApi {
38 
isActivityDefined(@onNull ComponentName component)39     boolean isActivityDefined(@NonNull ComponentName component);
40 
41     @Nullable
getActivity(@onNull ComponentName component)42     ParsedActivity getActivity(@NonNull ComponentName component);
43 
44     @Nullable
getProvider(@onNull ComponentName component)45     ParsedProvider getProvider(@NonNull ComponentName component);
46 
47     @Nullable
getReceiver(@onNull ComponentName component)48     ParsedActivity getReceiver(@NonNull ComponentName component);
49 
50     @Nullable
getService(@onNull ComponentName component)51     ParsedService getService(@NonNull ComponentName component);
52 
53     @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
componentExists(@onNull ComponentName componentName)54     boolean componentExists(@NonNull ComponentName componentName);
55 
56     @Nullable
queryActivities(@onNull Computer computer, @NonNull Intent intent, @Nullable String resolvedType, long flags, @UserIdInt int userId)57     List<ResolveInfo> queryActivities(@NonNull Computer computer, @NonNull Intent intent,
58             @Nullable String resolvedType, long flags, @UserIdInt int userId);
59 
60     @Nullable
queryActivities(@onNull Computer computer, @NonNull Intent intent, @Nullable String resolvedType, long flags, @NonNull List<ParsedActivity> activities, @UserIdInt int userId)61     List<ResolveInfo> queryActivities(@NonNull Computer computer, @NonNull Intent intent,
62             @Nullable String resolvedType, long flags, @NonNull List<ParsedActivity> activities,
63             @UserIdInt int userId);
64 
65     @Nullable
queryProvider(@onNull Computer computer, @NonNull String authority, long flags, @UserIdInt int userId)66     ProviderInfo queryProvider(@NonNull Computer computer, @NonNull String authority, long flags,
67             @UserIdInt int userId);
68 
69     @Nullable
queryProviders(@onNull Computer computer, @NonNull Intent intent, @Nullable String resolvedType, long flags, @UserIdInt int userId)70     List<ResolveInfo> queryProviders(@NonNull Computer computer, @NonNull Intent intent,
71             @Nullable String resolvedType, long flags, @UserIdInt int userId);
72 
73     @Nullable
queryProviders(@onNull Computer computer, @NonNull Intent intent, @Nullable String resolvedType, long flags, @NonNull List<ParsedProvider> providers, @UserIdInt int userId)74     List<ResolveInfo> queryProviders(@NonNull Computer computer, @NonNull Intent intent,
75             @Nullable String resolvedType, long flags, @NonNull List<ParsedProvider> providers,
76             @UserIdInt int userId);
77 
78     @Nullable
queryProviders(@onNull Computer computer, @Nullable String processName, @Nullable String metaDataKey, int uid, long flags, @UserIdInt int userId)79     List<ProviderInfo> queryProviders(@NonNull Computer computer, @Nullable String processName,
80             @Nullable String metaDataKey, int uid, long flags, @UserIdInt int userId);
81 
82     @Nullable
queryReceivers(@onNull Computer computer, @NonNull Intent intent, @Nullable String resolvedType, long flags, @UserIdInt int userId)83     List<ResolveInfo> queryReceivers(@NonNull Computer computer, @NonNull Intent intent,
84             @Nullable String resolvedType, long flags, @UserIdInt int userId);
85 
86     @Nullable
queryReceivers(@onNull Computer computer, @NonNull Intent intent, @Nullable String resolvedType, long flags, @NonNull List<ParsedActivity> receivers, @UserIdInt int userId)87     List<ResolveInfo> queryReceivers(@NonNull Computer computer, @NonNull Intent intent,
88             @Nullable String resolvedType, long flags, @NonNull List<ParsedActivity> receivers,
89             @UserIdInt int userId);
90 
91     @Nullable
queryServices(@onNull Computer computer, @NonNull Intent intent, @Nullable String resolvedType, long flags, @UserIdInt int userId)92     List<ResolveInfo> queryServices(@NonNull Computer computer, @NonNull Intent intent,
93             @Nullable String resolvedType, long flags, @UserIdInt int userId);
94 
95     @Nullable
queryServices(@onNull Computer computer, @NonNull Intent intent, @Nullable String resolvedType, long flags, @NonNull List<ParsedService> services, @UserIdInt int userId)96     List<ResolveInfo> queryServices(@NonNull Computer computer, @NonNull Intent intent,
97             @Nullable String resolvedType, long flags, @NonNull List<ParsedService> services,
98             @UserIdInt int userId);
99 
querySyncProviders(@onNull Computer computer, @NonNull List<String> outNames, @NonNull List<ProviderInfo> outInfo, boolean safeMode, @UserIdInt int userId)100     void querySyncProviders(@NonNull Computer computer, @NonNull List<String> outNames,
101             @NonNull List<ProviderInfo> outInfo, boolean safeMode, @UserIdInt int userId);
102 
dumpActivityResolvers(@onNull PrintWriter pw, @NonNull DumpState dumpState, @NonNull String packageName)103     void dumpActivityResolvers(@NonNull PrintWriter pw, @NonNull DumpState dumpState,
104             @NonNull String packageName);
105 
dumpProviderResolvers(@onNull PrintWriter pw, @NonNull DumpState dumpState, @NonNull String packageName)106     void dumpProviderResolvers(@NonNull PrintWriter pw, @NonNull DumpState dumpState,
107             @NonNull String packageName);
108 
dumpReceiverResolvers(@onNull PrintWriter pw, @NonNull DumpState dumpState, @NonNull String packageName)109     void dumpReceiverResolvers(@NonNull PrintWriter pw, @NonNull DumpState dumpState,
110             @NonNull String packageName);
111 
dumpServiceResolvers(@onNull PrintWriter pw, @NonNull DumpState dumpState, @NonNull String packageName)112     void dumpServiceResolvers(@NonNull PrintWriter pw, @NonNull DumpState dumpState,
113             @NonNull String packageName);
114 
dumpContentProviders(@onNull Computer computer, @NonNull PrintWriter pw, @NonNull DumpState dumpState, @NonNull String packageName)115     void dumpContentProviders(@NonNull Computer computer, @NonNull PrintWriter pw,
116             @NonNull DumpState dumpState, @NonNull String packageName);
117 
dumpServicePermissions(@onNull PrintWriter pw, @NonNull DumpState dumpState)118     void dumpServicePermissions(@NonNull PrintWriter pw, @NonNull DumpState dumpState);
119 }
120