OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.webapk.lib.client; | 5 package org.chromium.webapk.lib.client; |
6 | 6 |
7 import static org.junit.Assert.assertEquals; | 7 import static org.junit.Assert.assertEquals; |
| 8 import static org.junit.Assert.assertFalse; |
8 import static org.junit.Assert.assertNull; | 9 import static org.junit.Assert.assertNull; |
| 10 import static org.junit.Assert.assertTrue; |
| 11 |
| 12 import static org.chromium.webapk.lib.common.WebApkMetaDataKeys.START_URL; |
9 | 13 |
10 import android.content.Intent; | 14 import android.content.Intent; |
11 import android.content.pm.ActivityInfo; | 15 import android.content.pm.ActivityInfo; |
| 16 import android.content.pm.ApplicationInfo; |
12 import android.content.pm.PackageInfo; | 17 import android.content.pm.PackageInfo; |
13 import android.content.pm.PackageManager.NameNotFoundException; | 18 import android.content.pm.PackageManager.NameNotFoundException; |
14 import android.content.pm.ResolveInfo; | 19 import android.content.pm.ResolveInfo; |
15 import android.content.pm.Signature; | 20 import android.content.pm.Signature; |
| 21 import android.os.Bundle; |
16 | 22 |
17 import org.chromium.testing.local.LocalRobolectricTestRunner; | |
18 import org.junit.Assert; | 23 import org.junit.Assert; |
19 import org.junit.Before; | 24 import org.junit.Before; |
20 import org.junit.Test; | 25 import org.junit.Test; |
21 import org.junit.runner.RunWith; | 26 import org.junit.runner.RunWith; |
22 import org.robolectric.RuntimeEnvironment; | 27 import org.robolectric.RuntimeEnvironment; |
23 import org.robolectric.annotation.Config; | 28 import org.robolectric.annotation.Config; |
24 import org.robolectric.res.builder.RobolectricPackageManager; | 29 import org.robolectric.res.builder.RobolectricPackageManager; |
25 | 30 |
| 31 import org.chromium.testing.local.LocalRobolectricTestRunner; |
| 32 import org.chromium.testing.local.TestDir; |
| 33 |
26 import java.net.URISyntaxException; | 34 import java.net.URISyntaxException; |
27 import java.util.ArrayList; | 35 import java.util.ArrayList; |
28 import java.util.List; | 36 import java.util.List; |
29 | 37 |
30 /** | 38 /** Unit tests for {@link org.chromium.webapk.lib.client.WebApkValidator}. */ |
31 * Unit tests for {@link org.chromium.webapk.lib.client.WebApkValidator}. | |
32 */ | |
33 @RunWith(LocalRobolectricTestRunner.class) | 39 @RunWith(LocalRobolectricTestRunner.class) |
34 @Config(manifest = Config.NONE) | 40 @Config(manifest = Config.NONE) |
35 public class WebApkValidatorTest { | 41 public class WebApkValidatorTest { |
36 private static final String WEBAPK_PACKAGE_NAME = "org.chromium.webapk.foo"; | 42 private static final String WEBAPK_PACKAGE_NAME = "org.chromium.webapk.foo"; |
37 private static final String INVALID_WEBAPK_PACKAGE_NAME = "invalid.org.chrom
ium.webapk.foo"; | 43 private static final String INVALID_WEBAPK_PACKAGE_NAME = "invalid.org.chrom
ium.webapk.foo"; |
38 private static final String URL_OF_WEBAPK = "https://www.foo.com"; | 44 private static final String URL_OF_WEBAPK = "https://www.foo.com"; |
39 private static final String URL_WITHOUT_WEBAPK = "https://www.other.com"; | 45 private static final String URL_WITHOUT_WEBAPK = "https://www.other.com"; |
| 46 private static final String TEST_DATA_DIR = "webapks/"; |
40 | 47 |
41 private static final byte[] EXPECTED_SIGNATURE = new byte[] { | 48 private static final byte[] EXPECTED_SIGNATURE = new byte[] {48, -126, 3, -1
21, 48, -126, 2, |
42 48, -126, 3, -121, 48, -126, 2, 111, -96, 3, 2, 1, 2, 2, 4, 20, -104, -6
6, -126, 48, 13, | 49 111, -96, 3, 2, 1, 2, 2, 4, 20, -104, -66, -126, 48, 13, 6, 9, 42, -
122, 72, -122, -9, |
43 6, 9, 42, -122, 72, -122, -9, 13, 1, 1, 11, 5, 0, 48, 116, 49, 11, 48, 9
, 6, 3, 85, 4, | 50 13, 1, 1, 11, 5, 0, 48, 116, 49, 11, 48, 9, 6, 3, 85, 4, 6, 19, 2, 6
7, 65, 49, 16, 48, |
44 6, 19, 2, 67, 65, 49, 16, 48, 14, 6, 3, 85, 4, 8, 19, 7, 79, 110, 116, 9
7, 114, 105, | 51 14, 6, 3, 85, 4, 8, 19, 7, 79, 110, 116, 97, 114, 105, 111, 49, 17,
48, 15, 6, 3, 85, 4, |
45 111, 49, 17, 48, 15, 6, 3, 85, 4, 7, 19, 8, 87, 97, 116, 101, 114, 108,
111, 111, 49, | 52 7, 19, 8, 87, 97, 116, 101, 114, 108, 111, 111, 49, 17, 48, 15, 6, 3
, 85, 4, 10, 19, 8, |
46 17, 48, 15, 6, 3, 85, 4, 10, 19, 8, 67, 104, 114, 111, 109, 105, 117, 10
9, 49, 17, 48}; | 53 67, 104, 114, 111, 109, 105, 117, 109, 49, 17, 48}; |
47 | 54 |
48 private static final byte[] SIGNATURE_1 = new byte[] { | 55 private static final byte[] SIGNATURE_1 = new byte[] {13, 52, 51, 48, 51, 48
, 51, 49, 53, 49, |
49 13, 52, 51, 48, 51, 48, 51, 49, 53, 49, 54, 52, 52, 90, 48, 116, 49, 11,
48, 9, 6, 3, | 56 54, 52, 52, 90, 48, 116, 49, 11, 48, 9, 6, 3, 85, 4, 6, 19, 2, 67, 6
5, 49, 16, 48, 14, |
50 85, 4, 6, 19, 2, 67, 65, 49, 16, 48, 14, 6, 3, 85, 4, 8, 19, 7, 79, 110,
116, 97, 114}; | 57 6, 3, 85, 4, 8, 19, 7, 79, 110, 116, 97, 114}; |
51 | 58 |
52 private static final byte[] SIGNATURE_2 = new byte[] { | 59 private static final byte[] SIGNATURE_2 = new byte[] {49, 17, 48, 15, 6, 3,
85, 4, 10, 19, 8, |
53 49, 17, 48, 15, 6, 3, 85, 4, 10, 19, 8, 67, 104, 114, 111, 109, 105, 117
, 109, 49, 17, | 60 67, 104, 114, 111, 109, 105, 117, 109, 49, 17, 48, 15, 6, 3, 85, 4,
11, 19, 8, 67, 104, |
54 48, 15, 6, 3, 85, 4, 11, 19, 8, 67, 104, 114, 111, 109, 105, 117, 109, 4
9, 26, 48, 24}; | 61 114, 111, 109, 105, 117, 109, 49, 26, 48, 24}; |
| 62 |
| 63 // This is the public key used for the test files (chrome/test/data/webapks/
public.der) |
| 64 private static final byte[] PUBLIC_KEY = new byte[] {48, 89, 48, 19, 6, 7, 4
2, -122, 72, -50, |
| 65 61, 2, 1, 6, 8, 42, -122, 72, -50, 61, 3, 1, 7, 3, 66, 0, 4, -67, 14
, 37, -20, 103, 121, |
| 66 124, -60, -21, 83, -114, -120, -87, -38, 26, 78, 82, 55, 44, -23, -2
, 104, 115, 82, -55, |
| 67 -104, 105, -19, -48, 89, -65, 12, -31, 16, -35, 4, -121, -70, -89, 2
3, 56, 115, 112, 78, |
| 68 -65, 114, -103, 120, -88, -112, -102, -61, 72, -16, 74, 53, 50, 49,
-56, -48, -90, 5, |
| 69 -116, 78}; |
55 | 70 |
56 private RobolectricPackageManager mPackageManager; | 71 private RobolectricPackageManager mPackageManager; |
57 | 72 |
58 @Before | 73 @Before |
59 public void setUp() { | 74 public void setUp() { |
60 mPackageManager = (RobolectricPackageManager) RuntimeEnvironment | 75 mPackageManager = |
61 .application.getPackageManager(); | 76 (RobolectricPackageManager) RuntimeEnvironment.application.getPa
ckageManager(); |
62 WebApkValidator.initWithBrowserHostSignature(EXPECTED_SIGNATURE); | 77 WebApkValidator.init(true, EXPECTED_SIGNATURE, PUBLIC_KEY); |
63 } | 78 } |
64 | 79 |
65 /** | 80 /** |
66 * Tests {@link WebApkValidator.queryWebApkPackage()} returns a WebAPK's pac
kage name if the | 81 * Tests {@link WebApkValidator.queryWebApkPackage()} returns a WebAPK's pac
kage name if the |
67 * WebAPK can handle the given URL and the WebAPK is valid. | 82 * WebAPK can handle the given URL and the WebAPK is valid. |
68 */ | 83 */ |
69 @Test | 84 @Test |
70 public void testQueryWebApkPackageReturnsPackageIfTheURLCanBeHandled() { | 85 public void testQueryWebApkPackageReturnsPackageIfTheURLCanBeHandled() { |
71 try { | 86 try { |
72 Intent intent = Intent.parseUri(URL_OF_WEBAPK, Intent.URI_INTENT_SCH
EME); | 87 Intent intent = Intent.parseUri(URL_OF_WEBAPK, Intent.URI_INTENT_SCH
EME); |
73 intent.addCategory(Intent.CATEGORY_BROWSABLE); | 88 intent.addCategory(Intent.CATEGORY_BROWSABLE); |
74 | 89 |
75 mPackageManager.addResolveInfoForIntent(intent, newResolveInfo(WEBAP
K_PACKAGE_NAME)); | 90 mPackageManager.addResolveInfoForIntent(intent, newResolveInfo(WEBAP
K_PACKAGE_NAME)); |
76 mPackageManager.addPackage(newPackageInfoWithBrowserSignature( | 91 mPackageManager.addPackage(newPackageInfoWithBrowserSignature( |
77 WEBAPK_PACKAGE_NAME, new Signature(EXPECTED_SIGNATURE))); | 92 WEBAPK_PACKAGE_NAME, new Signature(EXPECTED_SIGNATURE))); |
78 | 93 |
79 assertEquals(WEBAPK_PACKAGE_NAME, WebApkValidator.queryWebApkPackage
( | 94 assertEquals(WEBAPK_PACKAGE_NAME, |
80 RuntimeEnvironment.application, URL_OF_WEBAPK)); | 95 WebApkValidator.queryWebApkPackage( |
| 96 RuntimeEnvironment.application, URL_OF_WEBAPK)); |
81 } catch (URISyntaxException e) { | 97 } catch (URISyntaxException e) { |
82 Assert.fail("URI is invalid."); | 98 Assert.fail("URI is invalid."); |
83 } | 99 } |
84 } | 100 } |
85 | 101 |
86 /** | 102 /** |
87 * Tests {@link WebApkValidator.queryWebApkPackage()} returns null for a non
-browsable Intent. | 103 * Tests {@link WebApkValidator.queryWebApkPackage()} returns null for a non
-browsable Intent. |
88 */ | 104 */ |
89 @Test | 105 @Test |
90 public void testQueryWebApkPackageReturnsNullForNonBrowsableIntent() { | 106 public void testQueryWebApkPackageReturnsNullForNonBrowsableIntent() { |
91 try { | 107 try { |
92 Intent intent = Intent.parseUri(URL_OF_WEBAPK, Intent.URI_INTENT_SCH
EME); | 108 Intent intent = Intent.parseUri(URL_OF_WEBAPK, Intent.URI_INTENT_SCH
EME); |
93 | 109 |
94 mPackageManager.addResolveInfoForIntent(intent, newResolveInfo(WEBAP
K_PACKAGE_NAME)); | 110 mPackageManager.addResolveInfoForIntent(intent, newResolveInfo(WEBAP
K_PACKAGE_NAME)); |
95 mPackageManager.addPackage(newPackageInfoWithBrowserSignature( | 111 mPackageManager.addPackage(newPackageInfoWithBrowserSignature( |
96 WEBAPK_PACKAGE_NAME, new Signature(EXPECTED_SIGNATURE))); | 112 WEBAPK_PACKAGE_NAME, new Signature(EXPECTED_SIGNATURE))); |
97 | 113 |
98 assertNull(WebApkValidator.queryWebApkPackage( | 114 assertNull(WebApkValidator.queryWebApkPackage( |
99 RuntimeEnvironment.application, URL_OF_WEBAPK)); | 115 RuntimeEnvironment.application, URL_OF_WEBAPK)); |
100 } catch (URISyntaxException e) { | 116 } catch (URISyntaxException e) { |
101 Assert.fail("URI is invalid."); | 117 Assert.fail("URI is invalid."); |
102 } | 118 } |
103 } | 119 } |
104 | 120 |
105 /** | 121 /** |
106 * Tests {@link WebApkValidator.queryWebApkPackage()} returns null if no Web
APK handles | 122 * Tests {@link WebApkValidator.queryWebApkPackage()} returns null if no Web
APK handles the |
107 * the given URL. | 123 * given URL. |
108 */ | 124 */ |
109 @Test | 125 @Test |
110 public void testQueryWebApkPackageReturnsNullWhenNoWebApkHandlesTheURL() { | 126 public void testQueryWebApkPackageReturnsNullWhenNoWebApkHandlesTheURL() { |
111 try { | 127 try { |
112 Intent intent = Intent.parseUri(URL_OF_WEBAPK, Intent.URI_INTENT_SCH
EME); | 128 Intent intent = Intent.parseUri(URL_OF_WEBAPK, Intent.URI_INTENT_SCH
EME); |
113 intent.addCategory(Intent.CATEGORY_BROWSABLE); | 129 intent.addCategory(Intent.CATEGORY_BROWSABLE); |
114 | 130 |
115 mPackageManager.addResolveInfoForIntent(intent, newResolveInfo(WEBAP
K_PACKAGE_NAME)); | 131 mPackageManager.addResolveInfoForIntent(intent, newResolveInfo(WEBAP
K_PACKAGE_NAME)); |
116 mPackageManager.addPackage(newPackageInfoWithBrowserSignature( | 132 mPackageManager.addPackage(newPackageInfoWithBrowserSignature( |
117 WEBAPK_PACKAGE_NAME, new Signature(EXPECTED_SIGNATURE))); | 133 WEBAPK_PACKAGE_NAME, new Signature(EXPECTED_SIGNATURE))); |
(...skipping 14 matching lines...) Expand all Loading... |
132 List<ResolveInfo> infos = new ArrayList<ResolveInfo>(); | 148 List<ResolveInfo> infos = new ArrayList<ResolveInfo>(); |
133 infos.add(newResolveInfo(WEBAPK_PACKAGE_NAME)); | 149 infos.add(newResolveInfo(WEBAPK_PACKAGE_NAME)); |
134 mPackageManager.addPackage(newPackageInfoWithBrowserSignature( | 150 mPackageManager.addPackage(newPackageInfoWithBrowserSignature( |
135 WEBAPK_PACKAGE_NAME, new Signature(EXPECTED_SIGNATURE))); | 151 WEBAPK_PACKAGE_NAME, new Signature(EXPECTED_SIGNATURE))); |
136 | 152 |
137 assertEquals(WEBAPK_PACKAGE_NAME, | 153 assertEquals(WEBAPK_PACKAGE_NAME, |
138 WebApkValidator.findWebApkPackage(RuntimeEnvironment.application
, infos)); | 154 WebApkValidator.findWebApkPackage(RuntimeEnvironment.application
, infos)); |
139 } | 155 } |
140 | 156 |
141 /** | 157 /** |
142 * Tests {@link WebApkValidator.findWebApkPackage} returns null if none of t
he packages for the | 158 * Tests {@link WebApkValidator.findWebApkPackage} returns null if null if t
he package |
143 * ResolveInfos start with {@link WebApkConstants.WEBAPK_PACKAGE_PREFIX}. | 159 * name is invalid. |
144 */ | 160 */ |
145 @Test | 161 @Test |
146 public void testFindWebApkPackageReturnsNullForInvalidPackageName() { | 162 public void testFindWebApkPackageReturnsNullForInvalidPackageName() { |
147 List<ResolveInfo> infos = new ArrayList<ResolveInfo>(); | 163 List<ResolveInfo> infos = new ArrayList<ResolveInfo>(); |
148 infos.add(newResolveInfo(INVALID_WEBAPK_PACKAGE_NAME)); | 164 infos.add(newResolveInfo(INVALID_WEBAPK_PACKAGE_NAME)); |
149 mPackageManager.addPackage(newPackageInfoWithBrowserSignature( | 165 mPackageManager.addPackage(newPackageInfoWithBrowserSignature( |
150 INVALID_WEBAPK_PACKAGE_NAME, new Signature(EXPECTED_SIGNATURE)))
; | 166 INVALID_WEBAPK_PACKAGE_NAME, new Signature(EXPECTED_SIGNATURE)))
; |
151 | 167 |
152 assertNull(WebApkValidator.findWebApkPackage(RuntimeEnvironment.applicat
ion, infos)); | 168 assertNull(WebApkValidator.findWebApkPackage(RuntimeEnvironment.applicat
ion, infos)); |
153 } | 169 } |
154 | 170 |
155 /** | 171 /** |
156 * Tests {@link WebApkValidator.findWebApkPackage} returns null if a WebAPK
has more than 2 | 172 * Tests {@link WebApkValidator.findWebApkPackage} returns null if a WebAPK
has more than 2 |
157 * signatures, even if the second one matches the expected signature. | 173 * signatures, even if the second one matches the expected signature. |
158 */ | 174 */ |
159 @Test | 175 @Test |
160 public void testFindWebApkPackageReturnsNullForMoreThanTwoSignatures() | 176 public void testFindWebApkPackageReturnsNullForMoreThanTwoSignatures() |
161 throws NameNotFoundException { | 177 throws NameNotFoundException { |
162 List<ResolveInfo> infos = new ArrayList<ResolveInfo>(); | 178 List<ResolveInfo> infos = new ArrayList<ResolveInfo>(); |
163 infos.add(newResolveInfo(WEBAPK_PACKAGE_NAME)); | 179 infos.add(newResolveInfo(WEBAPK_PACKAGE_NAME)); |
164 Signature[] signatures = new Signature[] {new Signature(SIGNATURE_1), | 180 Signature[] signatures = new Signature[] {new Signature(SIGNATURE_1), |
165 new Signature(EXPECTED_SIGNATURE), new Signature(SIGNATURE_2)}; | 181 new Signature(EXPECTED_SIGNATURE), new Signature(SIGNATURE_2)}; |
166 mPackageManager.addPackage(newPackageInfo(WEBAPK_PACKAGE_NAME, signature
s)); | 182 mPackageManager.addPackage(newPackageInfo(WEBAPK_PACKAGE_NAME, signature
s, null)); |
167 | 183 |
168 assertNull(WebApkValidator.findWebApkPackage(RuntimeEnvironment.applicat
ion, infos)); | 184 assertNull(WebApkValidator.findWebApkPackage(RuntimeEnvironment.applicat
ion, infos)); |
169 } | 185 } |
170 | 186 |
171 /** | 187 /** |
172 * Tests {@link WebApkValidator.findWebApkPackage} returns null if a WebAPK
has multiple | 188 * Tests {@link WebApkValidator.findWebApkPackage} returns null if a WebAPK
has multiple |
173 * signatures but none of the signatures match the expected signature. | 189 * signatures but none of the signatures match the expected signature. |
174 */ | 190 */ |
175 @Test | 191 @Test |
176 public void testFindWebApkPackageReturnsNullForWebApkWithMultipleSignaturesW
ithoutAnyMatched() | 192 public void testFindWebApkPackageReturnsNullForWebApkWithMultipleSignaturesW
ithoutAnyMatched() |
177 throws NameNotFoundException { | 193 throws NameNotFoundException { |
178 List<ResolveInfo> infos = new ArrayList<ResolveInfo>(); | 194 List<ResolveInfo> infos = new ArrayList<ResolveInfo>(); |
179 infos.add(newResolveInfo(WEBAPK_PACKAGE_NAME)); | 195 infos.add(newResolveInfo(WEBAPK_PACKAGE_NAME)); |
180 Signature signatures[] = | 196 Signature signatures[] = |
181 new Signature[] {new Signature(SIGNATURE_1), new Signature(SIGNA
TURE_2)}; | 197 new Signature[] {new Signature(SIGNATURE_1), new Signature(SIGNA
TURE_2)}; |
182 mPackageManager.addPackage(newPackageInfo(WEBAPK_PACKAGE_NAME, signature
s)); | 198 mPackageManager.addPackage(newPackageInfo(WEBAPK_PACKAGE_NAME, signature
s, null)); |
183 | 199 |
184 assertNull(WebApkValidator.findWebApkPackage(RuntimeEnvironment.applicat
ion, infos)); | 200 assertNull(WebApkValidator.findWebApkPackage(RuntimeEnvironment.applicat
ion, infos)); |
185 } | 201 } |
186 | 202 |
| 203 /** |
| 204 * Tests {@link WebApkValidator#isValidWebApk()} for valid comment signed we
bapks. |
| 205 */ |
| 206 @Test |
| 207 public void testIsValidWebApkCommentSigned() { |
| 208 String[] filenames = {"example.apk", "java-example.apk"}; |
| 209 String packageName = "com.webapk.a9c419502bb98fcb7"; |
| 210 Signature[] signature = new Signature[] {new Signature(SIGNATURE_1)}; |
| 211 |
| 212 for (String filename : filenames) { |
| 213 mPackageManager.removePackage(packageName); |
| 214 mPackageManager.addPackage( |
| 215 newPackageInfo(packageName, signature, testFilePath(filename
))); |
| 216 assertTrue(filename + " did not verify", |
| 217 WebApkValidator.isValidWebApk(RuntimeEnvironment.application
, packageName)); |
| 218 } |
| 219 } |
| 220 |
| 221 /** |
| 222 * Tests {@link WebApkValidator#isValidWebApk()} for failing comment signed
webapks. |
| 223 * These WebAPKs were modified to fail in specific ways. |
| 224 */ |
| 225 @Test |
| 226 public void testIsValidWebApkCommentSignedFailures() { |
| 227 String[] filenames = { |
| 228 "bad-sig.apk", "bad-utf8-fname.apk", "empty.apk", "extra-len-too
-large.apk", |
| 229 "fcomment-too-large.apk", "no-cd.apk", "no-comment.apk", "no-eoc
d.apk", |
| 230 "no-lfh.apk", "not-an.apk", "too-many-metainf.apk", "truncated.a
pk", "zeros.apk", |
| 231 "zeros-at-end.apk", |
| 232 }; |
| 233 String packageName = "com.webapk.a9c419502bb98fcb7"; |
| 234 Signature[] signature = new Signature[] {new Signature(SIGNATURE_1)}; |
| 235 |
| 236 for (String filename : filenames) { |
| 237 mPackageManager.removePackage(packageName); |
| 238 mPackageManager.addPackage( |
| 239 newPackageInfo(packageName, signature, testFilePath(filename
))); |
| 240 assertFalse(filename, |
| 241 WebApkValidator.isValidWebApk(RuntimeEnvironment.application
, packageName)); |
| 242 } |
| 243 } |
| 244 |
| 245 // Get the full test file path. |
| 246 private static String testFilePath(String fileName) { |
| 247 return TestDir.getTestFilePath(TEST_DATA_DIR + fileName); |
| 248 } |
| 249 |
187 private static ResolveInfo newResolveInfo(String packageName) { | 250 private static ResolveInfo newResolveInfo(String packageName) { |
188 ActivityInfo activityInfo = new ActivityInfo(); | 251 ActivityInfo activityInfo = new ActivityInfo(); |
189 activityInfo.packageName = packageName; | 252 activityInfo.packageName = packageName; |
190 ResolveInfo resolveInfo = new ResolveInfo(); | 253 ResolveInfo resolveInfo = new ResolveInfo(); |
191 resolveInfo.activityInfo = activityInfo; | 254 resolveInfo.activityInfo = activityInfo; |
192 return resolveInfo; | 255 return resolveInfo; |
193 } | 256 } |
194 | 257 |
195 private static PackageInfo newPackageInfo(String packageName, Signature[] si
gnatures) { | 258 private static PackageInfo newPackageInfo( |
| 259 String packageName, Signature[] signatures, String sourceDir) { |
196 PackageInfo packageInfo = new PackageInfo(); | 260 PackageInfo packageInfo = new PackageInfo(); |
197 packageInfo.packageName = packageName; | 261 packageInfo.packageName = packageName; |
198 packageInfo.signatures = signatures; | 262 packageInfo.signatures = signatures; |
| 263 packageInfo.applicationInfo = new ApplicationInfo(); |
| 264 packageInfo.applicationInfo.metaData = new Bundle(); |
| 265 packageInfo.applicationInfo.metaData.putString(START_URL, "https://non-e
mpty.com/starturl"); |
| 266 packageInfo.applicationInfo.sourceDir = sourceDir; |
199 return packageInfo; | 267 return packageInfo; |
200 } | 268 } |
201 | 269 |
202 // The browser signature is expected to always be the second signature - the
first (and any | 270 // The browser signature is expected to always be the second signature - the
first (and any |
203 // additional ones after the second) are ignored. | 271 // additional ones after the second) are ignored. |
204 private static PackageInfo newPackageInfoWithBrowserSignature( | 272 private static PackageInfo newPackageInfoWithBrowserSignature( |
205 String packageName, Signature signature) { | 273 String packageName, Signature signature) { |
206 return newPackageInfo(packageName, new Signature[] {new Signature(""), s
ignature}); | 274 return newPackageInfo(packageName, new Signature[] {new Signature(""), s
ignature}, null); |
207 } | 275 } |
208 } | 276 } |
OLD | NEW |