use of android.webkit.WebViewProviderInfo in project android_frameworks_base by crdroidandroid.
the class WebViewUpdateServiceImpl method updateFallbackState.
private void updateFallbackState(WebViewProviderInfo[] webviewProviders, boolean isBoot) {
// If there exists a valid and enabled non-fallback package - disable the fallback
// package, otherwise, enable it.
WebViewProviderInfo fallbackProvider = getFallbackProvider(webviewProviders);
if (fallbackProvider == null)
return;
boolean existsValidNonFallbackProvider = existsValidNonFallbackProvider(webviewProviders);
boolean isFallbackEnabled = false;
try {
isFallbackEnabled = isEnabledPackage(mSystemInterface.getPackageInfoForProvider(fallbackProvider));
} catch (NameNotFoundException e) {
// No fallback package installed -> early out.
return;
}
if (existsValidNonFallbackProvider && // ignore the state of that user during boot.
(isFallbackEnabled || isBoot)) {
mSystemInterface.uninstallAndDisablePackageForAllUsers(mContext, fallbackProvider.packageName);
} else if (!existsValidNonFallbackProvider && // ignore the state of that user during boot.
(!isFallbackEnabled || isBoot)) {
// Enable the fallback package for all users.
mSystemInterface.enablePackageForAllUsers(mContext, fallbackProvider.packageName, true);
}
}
use of android.webkit.WebViewProviderInfo 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.WebViewProviderInfo in project android_frameworks_base by crdroidandroid.
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 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);
}
use of android.webkit.WebViewProviderInfo in project android_frameworks_base by crdroidandroid.
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) });
}
Aggregations