use of android.webkit.WebViewProviderInfo in project platform_frameworks_base by android.
the class WebViewUpdateServiceTest method testFailWaitingForRelro.
@Test
public void testFailWaitingForRelro() {
WebViewProviderInfo[] packages = new WebViewProviderInfo[] { new WebViewProviderInfo("packagename", "", true, true, null) };
setupWithPackages(packages);
setEnabledAndValidPackageInfos(packages);
runWebViewBootPreparationOnMainSync();
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 platform_frameworks_base by android.
the class WebViewUpdateService method onStart.
@Override
public void onStart() {
mWebViewUpdatedReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
int userId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, UserHandle.USER_NULL);
switch(intent.getAction()) {
case Intent.ACTION_PACKAGE_REMOVED:
// run the update-logic twice.
if (intent.getExtras().getBoolean(Intent.EXTRA_REPLACING))
return;
mImpl.packageStateChanged(packageNameFromIntent(intent), PACKAGE_REMOVED, userId);
break;
case Intent.ACTION_PACKAGE_CHANGED:
// entire package, not just a component
if (entirePackageChanged(intent)) {
mImpl.packageStateChanged(packageNameFromIntent(intent), PACKAGE_CHANGED, userId);
}
break;
case Intent.ACTION_PACKAGE_ADDED:
mImpl.packageStateChanged(packageNameFromIntent(intent), (intent.getExtras().getBoolean(Intent.EXTRA_REPLACING) ? PACKAGE_ADDED_REPLACED : PACKAGE_ADDED), userId);
break;
case Intent.ACTION_USER_ADDED:
mImpl.handleNewUser(userId);
break;
}
}
};
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_PACKAGE_ADDED);
filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
filter.addDataScheme("package");
// Make sure we only receive intents for WebView packages from our config file.
for (WebViewProviderInfo provider : mImpl.getWebViewPackages()) {
filter.addDataSchemeSpecificPart(provider.packageName, PatternMatcher.PATTERN_LITERAL);
}
getContext().registerReceiverAsUser(mWebViewUpdatedReceiver, UserHandle.ALL, filter, null, /* broadcast permission */
null);
IntentFilter userAddedFilter = new IntentFilter();
userAddedFilter.addAction(Intent.ACTION_USER_ADDED);
getContext().registerReceiverAsUser(mWebViewUpdatedReceiver, UserHandle.ALL, userAddedFilter, null, /* broadcast permission */
null);
publishBinderService("webviewupdate", new BinderService(), true);
}
use of android.webkit.WebViewProviderInfo in project platform_frameworks_base by android.
the class WebViewUpdateServiceImpl method isFallbackPackage.
boolean isFallbackPackage(String packageName) {
if (packageName == null || !mSystemInterface.isFallbackLogicEnabled())
return false;
WebViewProviderInfo[] webviewPackages = mSystemInterface.getWebViewPackages();
WebViewProviderInfo fallbackProvider = getFallbackProvider(webviewPackages);
return (fallbackProvider != null && packageName.equals(fallbackProvider.packageName));
}
use of android.webkit.WebViewProviderInfo in project android_frameworks_base by ResurrectionRemix.
the class WebViewUpdateService method onStart.
@Override
public void onStart() {
mWebViewUpdatedReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
int userId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, UserHandle.USER_NULL);
switch(intent.getAction()) {
case Intent.ACTION_PACKAGE_REMOVED:
// run the update-logic twice.
if (intent.getExtras().getBoolean(Intent.EXTRA_REPLACING))
return;
mImpl.packageStateChanged(packageNameFromIntent(intent), PACKAGE_REMOVED, userId);
break;
case Intent.ACTION_PACKAGE_CHANGED:
// entire package, not just a component
if (entirePackageChanged(intent)) {
mImpl.packageStateChanged(packageNameFromIntent(intent), PACKAGE_CHANGED, userId);
}
break;
case Intent.ACTION_PACKAGE_ADDED:
mImpl.packageStateChanged(packageNameFromIntent(intent), (intent.getExtras().getBoolean(Intent.EXTRA_REPLACING) ? PACKAGE_ADDED_REPLACED : PACKAGE_ADDED), userId);
break;
case Intent.ACTION_USER_ADDED:
mImpl.handleNewUser(userId);
break;
}
}
};
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_PACKAGE_ADDED);
filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
filter.addDataScheme("package");
// Make sure we only receive intents for WebView packages from our config file.
for (WebViewProviderInfo provider : mImpl.getWebViewPackages()) {
filter.addDataSchemeSpecificPart(provider.packageName, PatternMatcher.PATTERN_LITERAL);
}
getContext().registerReceiverAsUser(mWebViewUpdatedReceiver, UserHandle.ALL, filter, null, /* broadcast permission */
null);
IntentFilter userAddedFilter = new IntentFilter();
userAddedFilter.addAction(Intent.ACTION_USER_ADDED);
getContext().registerReceiverAsUser(mWebViewUpdatedReceiver, UserHandle.ALL, userAddedFilter, null, /* broadcast permission */
null);
publishBinderService("webviewupdate", new BinderService(), true);
}
use of android.webkit.WebViewProviderInfo in project android_frameworks_base by ResurrectionRemix.
the class WebViewUpdateServiceImpl method updateFallbackStateOnPackageChange.
/**
* Handle the enabled-state of our fallback package, i.e. if there exists some non-fallback
* package that is valid (and available by default) then disable the fallback package,
* otherwise, enable the fallback package.
*/
private void updateFallbackStateOnPackageChange(String changedPackage, int changedState) {
if (!mSystemInterface.isFallbackLogicEnabled())
return;
WebViewProviderInfo[] webviewProviders = mSystemInterface.getWebViewPackages();
// A package was changed / updated / downgraded, early out if it is not one of the
// webview packages that are available by default.
boolean changedPackageAvailableByDefault = false;
for (WebViewProviderInfo provider : webviewProviders) {
if (provider.packageName.equals(changedPackage)) {
if (provider.availableByDefault) {
changedPackageAvailableByDefault = true;
}
break;
}
}
if (!changedPackageAvailableByDefault)
return;
updateFallbackState(webviewProviders, false);
}
Aggregations