Debian Codegraph @

core/java/android/content/pm/AuxiliaryResolveInfo.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2016 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 android.content.pm;
18
19 import android.annotation.NonNull;
20 import android.annotation.Nullable;
21 import android.content.ComponentName;
22 import android.content.Intent;
23 import android.content.IntentFilter;
24 import android.os.Bundle;
25
26 import java.util.Collections;
27 import java.util.List;
28
29 /**
30 * Auxiliary application resolution response.
31 * <p>
32 * Used when resolution occurs, but, the target is not actually on the device.
33 * This happens resolving instant apps that haven't been installed yet or if
34 * the application consists of multiple feature splits and the needed split
35 * hasn't been installed.
36 * @hide
37 */
38 public final class AuxiliaryResolveInfo {
39 /** The activity to launch if there's an installation failure. */
40 public final ComponentName installFailureActivity;
41 /** Whether or not instant resolution needs the second phase */
42 public final boolean needsPhaseTwo;
43 /** Opaque token to track the instant application resolution */
44 public final String token;
45 /** An intent to start upon failure to install */
46 public final Intent failureIntent;
47 /** The matching filters for this resolve info. */
48 public final List<AuxiliaryFilter> filters;
49 /** Stored {@link InstantAppRequest#hostDigestPrefixSecure} to prevent re-generation */
50 public final int[] hostDigestPrefixSecure;
51
52 /** Create a response for installing an instant application. */
53 public AuxiliaryResolveInfo(@NonNull String token,
54 boolean needsPhase2,
55 @Nullable Intent failureIntent,
56 @Nullable List<AuxiliaryFilter> filters,
57 @Nullable int[] hostDigestPrefix) {
58 this.token = token;
59 this.needsPhaseTwo = needsPhase2;
60 this.failureIntent = failureIntent;
61 this.filters = filters;
62 this.installFailureActivity = null;
63 this.hostDigestPrefixSecure = hostDigestPrefix;
64 }
65
66 /** Create a response for installing a split on demand. */
67 public AuxiliaryResolveInfo(@Nullable ComponentName failureActivity,
68 @Nullable Intent failureIntent,
69 @Nullable List<AuxiliaryFilter> filters) {
70 super();
71 this.installFailureActivity = failureActivity;
72 this.filters = filters;
73 this.token = null;
74 this.needsPhaseTwo = false;
75 this.failureIntent = failureIntent;
76 this.hostDigestPrefixSecure = null;
77 }
78
79 /** Create a response for installing a split on demand. */
80 public AuxiliaryResolveInfo(@Nullable ComponentName failureActivity,
81 String packageName, long versionCode, String splitName) {
82 this(failureActivity, null, Collections.singletonList(
83 new AuxiliaryResolveInfo.AuxiliaryFilter(packageName, versionCode, splitName)));
84 }
85
86 /** @hide */
87 public static final class AuxiliaryFilter extends IntentFilter {
88 /** Resolved information returned from the external instant resolver */
89 public final InstantAppResolveInfo resolveInfo;
90 /** The resolved package. Copied from {@link #resolveInfo}. */
91 public final String packageName;
92 /** The version code of the package */
93 public final long versionCode;
94 /** The resolve split. Copied from the matched filter in {@link #resolveInfo}. */
95 public final String splitName;
96 /** The extras to pass on to the installer for this filter. */
97 public final Bundle extras;
98
99 public AuxiliaryFilter(IntentFilter orig, InstantAppResolveInfo resolveInfo,
100 String splitName, Bundle extras) {
101 super(orig);
102 this.resolveInfo = resolveInfo;
103 this.packageName = resolveInfo.getPackageName();
104 this.versionCode = resolveInfo.getLongVersionCode();
105 this.splitName = splitName;
106 this.extras = extras;
107 }
108
109 public AuxiliaryFilter(InstantAppResolveInfo resolveInfo,
110 String splitName, Bundle extras) {
111 this.resolveInfo = resolveInfo;
112 this.packageName = resolveInfo.getPackageName();
113 this.versionCode = resolveInfo.getLongVersionCode();
114 this.splitName = splitName;
115 this.extras = extras;
116 }
117
118 public AuxiliaryFilter(String packageName, long versionCode, String splitName) {
119 this.resolveInfo = null;
120 this.packageName = packageName;
121 this.versionCode = versionCode;
122 this.splitName = splitName;
123 this.extras = null;
124 }
125
126 @Override
127 public String toString() {
128 return "AuxiliaryFilter{"
129 + "packageName='" + packageName + '\''
130 + ", versionCode=" + versionCode
131 + ", splitName='" + splitName + '\'' + '}';
132 }
133 }
134 }