use of android.webkit.WebViewProviderResponse in project android_frameworks_base by ResurrectionRemix.
the class WebViewUpdateServiceTest method checkCertainPackageUsedAfterWebViewBootPreparation.
private void checkCertainPackageUsedAfterWebViewBootPreparation(String expectedProviderName, WebViewProviderInfo[] webviewPackages, int numRelros) {
setupWithPackages(webviewPackages, true, numRelros);
// Add (enabled and valid) package infos for each provider
setEnabledAndValidPackageInfos(webviewPackages);
mWebViewUpdateServiceImpl.prepareWebViewInSystemServer();
Mockito.verify(mTestSystemImpl).onWebViewProviderChanged(Mockito.argThat(new IsPackageInfoWithName(expectedProviderName)));
for (int n = 0; n < numRelros; n++) {
mWebViewUpdateServiceImpl.notifyRelroCreationCompleted();
}
WebViewProviderResponse response = mWebViewUpdateServiceImpl.waitForAndGetProvider();
assertEquals(WebViewFactory.LIBLOAD_SUCCESS, response.status);
assertEquals(expectedProviderName, response.packageInfo.packageName);
}
use of android.webkit.WebViewProviderResponse in project android_frameworks_base by ResurrectionRemix.
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.WebViewProviderResponse in project android_frameworks_base by ResurrectionRemix.
the class WebViewUpdateServiceTest method checkPreparationPhasesForPackage.
private void checkPreparationPhasesForPackage(String expectedPackage, int numPreparation) {
// Verify that onWebViewProviderChanged was called for the numPreparation'th time for the
// expected package
Mockito.verify(mTestSystemImpl, Mockito.times(numPreparation)).onWebViewProviderChanged(Mockito.argThat(new IsPackageInfoWithName(expectedPackage)));
mWebViewUpdateServiceImpl.notifyRelroCreationCompleted();
WebViewProviderResponse response = mWebViewUpdateServiceImpl.waitForAndGetProvider();
assertEquals(WebViewFactory.LIBLOAD_SUCCESS, response.status);
assertEquals(expectedPackage, response.packageInfo.packageName);
}
use of android.webkit.WebViewProviderResponse in project android_frameworks_base by crdroidandroid.
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);
}
use of android.webkit.WebViewProviderResponse in project android_frameworks_base by crdroidandroid.
the class WebViewUpdateServiceTest method checkRecoverAfterFailListingWebviewPackages.
/**
* Test that we can recover correctly from failing to list WebView packages.
* settingsChange: whether to fail during changeProviderAndSetting or packageStateChanged
*/
public void checkRecoverAfterFailListingWebviewPackages(boolean settingsChange) {
String firstPackage = "first";
String secondPackage = "second";
WebViewProviderInfo[] packages = new WebViewProviderInfo[] { new WebViewProviderInfo(firstPackage, "", true, /* default available */
false, /* fallback */
null), new WebViewProviderInfo(secondPackage, "", true, /* default available */
false, /* fallback */
null) };
checkCertainPackageUsedAfterWebViewBootPreparation(firstPackage, packages);
// Make both packages invalid so that we fail listing WebView packages
mTestSystemImpl.setPackageInfo(createPackageInfo(firstPackage, true, /* enabled */
false, /* valid */
true));
mTestSystemImpl.setPackageInfo(createPackageInfo(secondPackage, true, /* enabled */
false, /* valid */
true));
// Change package to hit the webview packages listing problem.
if (settingsChange) {
mWebViewUpdateServiceImpl.changeProviderAndSetting(secondPackage);
} else {
mWebViewUpdateServiceImpl.packageStateChanged(secondPackage, WebViewUpdateService.PACKAGE_ADDED_REPLACED, 0);
}
WebViewProviderResponse response = mWebViewUpdateServiceImpl.waitForAndGetProvider();
assertEquals(WebViewFactory.LIBLOAD_FAILED_LISTING_WEBVIEW_PACKAGES, response.status);
// Make second package valid and verify that we can load it again
mTestSystemImpl.setPackageInfo(createPackageInfo(secondPackage, true, /* enabled */
true, /* valid */
true));
mWebViewUpdateServiceImpl.packageStateChanged(secondPackage, WebViewUpdateService.PACKAGE_ADDED_REPLACED, 0);
checkPreparationPhasesForPackage(secondPackage, 1);
}
Aggregations