Search in sources :

Example 46 with WebViewProviderInfo

use of android.webkit.WebViewProviderInfo in project android_frameworks_base by ResurrectionRemix.

the class WebViewUpdateServiceImpl method handleNewUser.

/**
     * Called when a new user has been added to update the state of its fallback package.
     */
void handleNewUser(int userId) {
    if (!mSystemInterface.isFallbackLogicEnabled())
        return;
    WebViewProviderInfo[] webviewProviders = mSystemInterface.getWebViewPackages();
    WebViewProviderInfo fallbackProvider = getFallbackProvider(webviewProviders);
    if (fallbackProvider == null)
        return;
    mSystemInterface.enablePackageForUser(fallbackProvider.packageName, !existsValidNonFallbackProvider(webviewProviders), userId);
}
Also used : WebViewProviderInfo(android.webkit.WebViewProviderInfo)

Example 47 with WebViewProviderInfo

use of android.webkit.WebViewProviderInfo in project android_frameworks_base by ResurrectionRemix.

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

Example 48 with WebViewProviderInfo

use of android.webkit.WebViewProviderInfo in project android_frameworks_base by ResurrectionRemix.

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 49 with WebViewProviderInfo

use of android.webkit.WebViewProviderInfo in project android_frameworks_base by ResurrectionRemix.

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

Example 50 with WebViewProviderInfo

use of android.webkit.WebViewProviderInfo in project android_frameworks_base by ResurrectionRemix.

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);
}
Also used : Signature(android.content.pm.Signature) 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