Search in sources :

Example 6 with WebViewProviderInfo

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);
}
Also used : WebViewProviderInfo(android.webkit.WebViewProviderInfo) WebViewProviderResponse(android.webkit.WebViewProviderResponse) MediumTest(android.test.suitebuilder.annotation.MediumTest) Test(org.junit.Test)

Example 7 with WebViewProviderInfo

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);
}
Also used : Context(android.content.Context) IntentFilter(android.content.IntentFilter) WebViewProviderInfo(android.webkit.WebViewProviderInfo) Intent(android.content.Intent) BroadcastReceiver(android.content.BroadcastReceiver)

Example 8 with WebViewProviderInfo

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));
}
Also used : WebViewProviderInfo(android.webkit.WebViewProviderInfo)

Example 9 with WebViewProviderInfo

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);
}
Also used : Context(android.content.Context) IntentFilter(android.content.IntentFilter) WebViewProviderInfo(android.webkit.WebViewProviderInfo) Intent(android.content.Intent) BroadcastReceiver(android.content.BroadcastReceiver)

Example 10 with WebViewProviderInfo

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);
}
Also used : WebViewProviderInfo(android.webkit.WebViewProviderInfo)

Aggregations

WebViewProviderInfo (android.webkit.WebViewProviderInfo)61 WebViewProviderResponse (android.webkit.WebViewProviderResponse)28 MediumTest (android.test.suitebuilder.annotation.MediumTest)8 Test (org.junit.Test)8 BroadcastReceiver (android.content.BroadcastReceiver)4 Context (android.content.Context)4 Intent (android.content.Intent)4 IntentFilter (android.content.IntentFilter)4 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)4 Signature (android.content.pm.Signature)4 CountDownLatch (java.util.concurrent.CountDownLatch)4 DialogInterface (android.content.DialogInterface)1 OnClickListener (android.content.DialogInterface.OnClickListener)1 RemoteException (android.os.RemoteException)1 ArrayList (java.util.ArrayList)1