use of android.webkit.WebViewProviderInfo in project android_frameworks_base by DirtyUnicorns.
the class WebViewUpdateServiceTest method testFailWaitingForRelro.
public void testFailWaitingForRelro() {
WebViewProviderInfo[] packages = new WebViewProviderInfo[] { new WebViewProviderInfo("packagename", "", true, true, null) };
setupWithPackages(packages);
setEnabledAndValidPackageInfos(packages);
mWebViewUpdateServiceImpl.prepareWebViewInSystemServer();
Mockito.verify(mTestSystemImpl).onWebViewProviderChanged(Mockito.argThat(new IsPackageInfoWithName(packages[0].packageName)));
// Never call notifyRelroCreation()
WebViewProviderResponse response = mWebViewUpdateServiceImpl.waitForAndGetProvider();
assertEquals(WebViewFactory.LIBLOAD_FAILED_WAITING_FOR_RELRO, response.status);
}
use of android.webkit.WebViewProviderInfo in project android_frameworks_base by DirtyUnicorns.
the class WebViewUpdateServiceTest method testPreparationRunsIffNewPackage.
public void testPreparationRunsIffNewPackage() {
String primaryPackage = "primary";
String fallbackPackage = "fallback";
WebViewProviderInfo[] packages = new WebViewProviderInfo[] { new WebViewProviderInfo(primaryPackage, "", true, /* default available */
false, /* fallback */
null), new WebViewProviderInfo(fallbackPackage, "", true, /* default available */
true, /* fallback */
null) };
setupWithPackages(packages, true);
mTestSystemImpl.setPackageInfo(createPackageInfo(primaryPackage, true, /* enabled */
true, /* valid */
true, /* installed */
null, /* signatures */
10));
mTestSystemImpl.setPackageInfo(createPackageInfo(fallbackPackage, true, /* enabled */
true, /* valid */
true));
mWebViewUpdateServiceImpl.prepareWebViewInSystemServer();
checkPreparationPhasesForPackage(primaryPackage, 1);
Mockito.verify(mTestSystemImpl, Mockito.times(1)).enablePackageForUser(Mockito.eq(fallbackPackage), Mockito.eq(false), /* enable */
Matchers.anyInt());
mWebViewUpdateServiceImpl.packageStateChanged(primaryPackage, WebViewUpdateService.PACKAGE_ADDED_REPLACED, 0);
mWebViewUpdateServiceImpl.packageStateChanged(primaryPackage, WebViewUpdateService.PACKAGE_ADDED_REPLACED, 1);
mWebViewUpdateServiceImpl.packageStateChanged(primaryPackage, WebViewUpdateService.PACKAGE_ADDED_REPLACED, 2);
// package still has the same update-time so we shouldn't run preparation here
Mockito.verify(mTestSystemImpl, Mockito.times(1)).onWebViewProviderChanged(Mockito.argThat(new IsPackageInfoWithName(primaryPackage)));
Mockito.verify(mTestSystemImpl, Mockito.times(1)).enablePackageForUser(Mockito.eq(fallbackPackage), Mockito.eq(false), /* enable */
Matchers.anyInt());
// Ensure we can still load the package
WebViewProviderResponse response = mWebViewUpdateServiceImpl.waitForAndGetProvider();
assertEquals(WebViewFactory.LIBLOAD_SUCCESS, response.status);
assertEquals(primaryPackage, response.packageInfo.packageName);
mTestSystemImpl.setPackageInfo(createPackageInfo(primaryPackage, true, /* enabled */
true, /* valid */
true, /* installed */
null, /* signatures */
20));
mWebViewUpdateServiceImpl.packageStateChanged(primaryPackage, WebViewUpdateService.PACKAGE_ADDED_REPLACED, 0);
// The package has now changed - ensure that we have run the preparation phase a second time
checkPreparationPhasesForPackage(primaryPackage, 2);
mTestSystemImpl.setPackageInfo(createPackageInfo(primaryPackage, true, /* enabled */
true, /* valid */
true, /* installed */
null, /* signatures */
50));
// Receive intent for different user
mWebViewUpdateServiceImpl.packageStateChanged(primaryPackage, WebViewUpdateService.PACKAGE_ADDED_REPLACED, 2);
checkPreparationPhasesForPackage(primaryPackage, 3);
}
use of android.webkit.WebViewProviderInfo in project android_frameworks_base by DirtyUnicorns.
the class WebViewUpdateServiceTest method testWithSinglePackage.
// ****************
// Tests
// ****************
public void testWithSinglePackage() {
String testPackageName = "test.package.name";
checkCertainPackageUsedAfterWebViewBootPreparation(testPackageName, new WebViewProviderInfo[] { new WebViewProviderInfo(testPackageName, "", true, /*default available*/
false, /* fallback */
null) });
}
use of android.webkit.WebViewProviderInfo in project android_frameworks_base by DirtyUnicorns.
the class WebViewUpdateServiceTest method testWithSignatures.
// Ensure that package with valid signatures is chosen rather than package with invalid
// signatures.
public void testWithSignatures() {
String validPackage = "valid package";
String invalidPackage = "invalid package";
Signature validSignature = new Signature("11");
Signature invalidExpectedSignature = new Signature("22");
Signature invalidPackageSignature = new Signature("33");
WebViewProviderInfo[] packages = new WebViewProviderInfo[] { new WebViewProviderInfo(invalidPackage, "", true, false, new String[] { Base64.encodeToString(invalidExpectedSignature.toByteArray(), Base64.DEFAULT) }), new WebViewProviderInfo(validPackage, "", true, false, new String[] { Base64.encodeToString(validSignature.toByteArray(), Base64.DEFAULT) }) };
setupWithPackages(packages, true, /* fallback logic enabled */
1, /* numRelros */
false);
mTestSystemImpl.setPackageInfo(createPackageInfo(invalidPackage, true, /* enabled */
true, /* valid */
true, /* installed */
new Signature[] { invalidPackageSignature }, 0));
mTestSystemImpl.setPackageInfo(createPackageInfo(validPackage, true, /* enabled */
true, /* valid */
true, /* installed */
new Signature[] { validSignature }, 0));
mWebViewUpdateServiceImpl.prepareWebViewInSystemServer();
checkPreparationPhasesForPackage(validPackage, 1);
WebViewProviderInfo[] validPackages = mWebViewUpdateServiceImpl.getValidWebViewPackages();
assertEquals(1, validPackages.length);
assertEquals(validPackage, validPackages[0].packageName);
}
use of android.webkit.WebViewProviderInfo in project android_frameworks_base by DirtyUnicorns.
the class WebViewUpdateServiceTest method testFailListingInvalidWebviewPackage.
public void testFailListingInvalidWebviewPackage() {
WebViewProviderInfo wpi = new WebViewProviderInfo("package", "", true, true, null);
WebViewProviderInfo[] packages = new WebViewProviderInfo[] { wpi };
setupWithPackages(packages);
mTestSystemImpl.setPackageInfo(createPackageInfo(wpi.packageName, true, /* enabled */
false, /* valid */
true));
mWebViewUpdateServiceImpl.prepareWebViewInSystemServer();
Mockito.verify(mTestSystemImpl, Mockito.never()).onWebViewProviderChanged(Matchers.anyObject());
WebViewProviderResponse response = mWebViewUpdateServiceImpl.waitForAndGetProvider();
assertEquals(WebViewFactory.LIBLOAD_FAILED_LISTING_WEBVIEW_PACKAGES, response.status);
// Verify that we can recover from failing to list webview packages.
mTestSystemImpl.setPackageInfo(createPackageInfo(wpi.packageName, true, /* enabled */
true, /* valid */
true));
mWebViewUpdateServiceImpl.packageStateChanged(wpi.packageName, WebViewUpdateService.PACKAGE_ADDED_REPLACED, 0);
checkPreparationPhasesForPackage(wpi.packageName, 1);
}
Aggregations