• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2020 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.app.search;
18 
19 /**
20  * Constants to be used with {@link android.app.search.SearchContext} and
21  * {@link android.app.search.SearchTarget}.
22  *
23  * Note, a result type could be a of two types.
24  * For example, unpublished settings result type could be in slices:
25  * <code> resultType = SETTING | SLICE </code>
26  */
27 public class ResultType {
28 
29     // published corpus by 3rd party app, supported by SystemService
30     public static final int APPLICATION = 1 << 0;
31     public static final int SHORTCUT = 1 << 1;
32     public static final int SLICE = 1 << 6;
33     public static final int WIDGETS = 1 << 7;
34 
35     // Not extracted from any of the SystemService
36     public static final int PEOPLE = 1 << 2;
37     public static final int ACTION = 1 << 3;
38     public static final int SETTING = 1 << 4;
39     public static final int IMAGE = 1 << 5;
40     public static final int PLAY = 1 << 8;
41     public static final int SUGGEST = 1 << 9;
42     public static final int ASSISTANT = 1 << 10;
43     public static final int CHROMETAB = 1 << 11;
44     public static final int NAVVYSITE = 1 << 12;
45     public static final int TIPS = 1 << 13;
46     public static final int PEOPLE_TILE = 1 << 14;
47     public static final int LEGACY_SHORTCUT = 1 << 15;
48     public static final int MEMORY = 1 << 16;
49     public static final int WEB_SUGGEST = 1 << 17;
50     public static final int NO_FULFILLMENT = 1 << 18;
51     public static final int EDUCARD = 1 << 19;
52     public static final int SYSTEM_POINTER = 1 << 20;
53     public static final int VIDEO = 1 << 21;
54 
55     public static final int PUBLIC_DATA_TYPE = APPLICATION | SETTING | PLAY | WEB_SUGGEST;
56     public static final int PRIMITIVE_TYPE = APPLICATION | SLICE | SHORTCUT | WIDGETS | ACTION |
57             LEGACY_SHORTCUT;
58     public static final int CORPUS_TYPE =
59             PEOPLE | SETTING | IMAGE | PLAY | SUGGEST | ASSISTANT | CHROMETAB | NAVVYSITE | TIPS
60                     | PEOPLE_TILE | MEMORY | WEB_SUGGEST | VIDEO;
61     public static final int RANK_TYPE = SYSTEM_POINTER;
62     public static final int UI_TYPE = EDUCARD | NO_FULFILLMENT;
63 
isSlice(int resultType)64     public static boolean isSlice(int resultType) {
65         return (resultType & SLICE) != 0;
66     }
67 
isSystemPointer(int resultType)68     public static boolean isSystemPointer(int resultType) {
69         return (resultType & SYSTEM_POINTER) != 0;
70     }
71 
72     /**
73      * Returns result type integer where only {@code #CORPUS_TYPE} bit will turned on.
74      */
getCorpusType(int resultType)75     public static int getCorpusType(int resultType) {
76         return (resultType & CORPUS_TYPE);
77     }
78 
79     /**
80      * Returns result type integer where only {@code #PRIMITIVE_TYPE} bit will be turned on.
81      */
getPrimitiveType(int resultType)82     public static int getPrimitiveType(int resultType) {
83         return (resultType & PRIMITIVE_TYPE);
84     }
85 
86     /**
87      * Returns whether the given result type is privacy safe or not.
88      */
isPrivacySafe(int resultType)89     public static boolean isPrivacySafe(int resultType) {
90         return (resultType & PUBLIC_DATA_TYPE) != 0;
91     }
92 }
93