• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 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.appsearch.appsindexer;
18 
19 import android.annotation.NonNull;
20 import android.annotation.Nullable;
21 import android.content.pm.ResolveInfo;
22 
23 import java.util.Objects;
24 
25 /**
26  * Contains information about components in a package that will be indexed by the app indexer.
27  *
28  * @hide
29  */
30 public class ResolveInfos {
31     @Nullable private ResolveInfo mAppFunctionServiceInfo;
32     @Nullable private ResolveInfo mLaunchActivityResolveInfo;
33 
ResolveInfos( @ullable ResolveInfo appFunctionServiceInfo, @Nullable ResolveInfo launchActivityResolveInfo)34     public ResolveInfos(
35             @Nullable ResolveInfo appFunctionServiceInfo,
36             @Nullable ResolveInfo launchActivityResolveInfo) {
37         mAppFunctionServiceInfo = appFunctionServiceInfo;
38         mLaunchActivityResolveInfo = launchActivityResolveInfo;
39     }
40 
41     /**
42      * Return {@link ResolveInfo} for the packages AppFunction service. If {@code null}, it means
43      * this app doesn't have an app function service.
44      */
45     @Nullable
getAppFunctionServiceInfo()46     public ResolveInfo getAppFunctionServiceInfo() {
47         return mAppFunctionServiceInfo;
48     }
49 
50     /**
51      * Return {@link ResolveInfo} for the packages launch activity. If {@code null}, it means this
52      * app doesn't have a launch activity.
53      */
54     @Nullable
getLaunchActivityResolveInfo()55     public ResolveInfo getLaunchActivityResolveInfo() {
56         return mLaunchActivityResolveInfo;
57     }
58 
59     public static class Builder {
60         @Nullable private ResolveInfo mAppFunctionServiceInfo;
61         @Nullable private ResolveInfo mLaunchActivityResolveInfo;
62 
63         /** Sets the {@link ResolveInfo} for the packages AppFunction service */
64         @NonNull
setAppFunctionServiceResolveInfo(@onNull ResolveInfo resolveInfo)65         public Builder setAppFunctionServiceResolveInfo(@NonNull ResolveInfo resolveInfo) {
66             mAppFunctionServiceInfo = Objects.requireNonNull(resolveInfo);
67             return this;
68         }
69 
70         /** Sets the {@link ResolveInfo} for the packages launch activity. */
71         @NonNull
setLaunchActivityResolveInfo(@onNull ResolveInfo resolveInfo)72         public Builder setLaunchActivityResolveInfo(@NonNull ResolveInfo resolveInfo) {
73             mLaunchActivityResolveInfo = Objects.requireNonNull(resolveInfo);
74             return this;
75         }
76 
77         /** Builds the {@link ResolveInfos} object. */
78         @NonNull
build()79         public ResolveInfos build() {
80             return new ResolveInfos(mAppFunctionServiceInfo, mLaunchActivityResolveInfo);
81         }
82     }
83 }
84