Search in sources :

Example 16 with WebViewProviderInfo

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

the class WebViewUpdateServiceTest method testNotifyRelroDoesntCrashIfNoPackages.

/**
     * Timing dependent test where we verify that the list of valid webview packages becoming empty
     * at a certain point doesn't crash us or break our state.
     */
public void testNotifyRelroDoesntCrashIfNoPackages() {
    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) };
    setupWithPackages(packages);
    // Add (enabled and valid) package infos for each provider
    setEnabledAndValidPackageInfos(packages);
    mWebViewUpdateServiceImpl.prepareWebViewInSystemServer();
    Mockito.verify(mTestSystemImpl).onWebViewProviderChanged(Mockito.argThat(new IsPackageInfoWithName(firstPackage)));
    // Change provider during relro creation to enter a state where we are
    // waiting for relro creation to complete just to re-run relro creation.
    // (so that in next notifyRelroCreationCompleted() call we have to list webview packages)
    mWebViewUpdateServiceImpl.changeProviderAndSetting(secondPackage);
    // Make packages invalid to cause exception to be thrown
    mTestSystemImpl.setPackageInfo(createPackageInfo(firstPackage, true, /* enabled */
    false, /* valid */
    true, /* installed */
    null, /* signatures */
    0));
    mTestSystemImpl.setPackageInfo(createPackageInfo(secondPackage, true, /* enabled */
    false, /* valid */
    true));
    // This shouldn't throw an exception!
    mWebViewUpdateServiceImpl.notifyRelroCreationCompleted();
    WebViewProviderResponse response = mWebViewUpdateServiceImpl.waitForAndGetProvider();
    assertEquals(WebViewFactory.LIBLOAD_FAILED_LISTING_WEBVIEW_PACKAGES, response.status);
    // Now make a package valid again and verify that we can switch back to that
    mTestSystemImpl.setPackageInfo(createPackageInfo(firstPackage, true, /* enabled */
    true, /* valid */
    true, /* installed */
    null, /* signatures */
    1));
    mWebViewUpdateServiceImpl.packageStateChanged(firstPackage, WebViewUpdateService.PACKAGE_ADDED_REPLACED, 0);
    // Ensure we use firstPackage
    checkPreparationPhasesForPackage(firstPackage, 2);
}
Also used : WebViewProviderInfo(android.webkit.WebViewProviderInfo) WebViewProviderResponse(android.webkit.WebViewProviderResponse)

Example 17 with WebViewProviderInfo

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

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

Example 18 with WebViewProviderInfo

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

the class WebViewUpdateServiceTest method testFailListingEmptyWebviewPackages.

public void testFailListingEmptyWebviewPackages() {
    WebViewProviderInfo[] packages = new WebViewProviderInfo[0];
    setupWithPackages(packages);
    setEnabledAndValidPackageInfos(packages);
    mWebViewUpdateServiceImpl.prepareWebViewInSystemServer();
    Mockito.verify(mTestSystemImpl, Mockito.never()).onWebViewProviderChanged(Matchers.anyObject());
    WebViewProviderResponse response = mWebViewUpdateServiceImpl.waitForAndGetProvider();
    assertEquals(WebViewFactory.LIBLOAD_FAILED_LISTING_WEBVIEW_PACKAGES, response.status);
}
Also used : WebViewProviderInfo(android.webkit.WebViewProviderInfo) WebViewProviderResponse(android.webkit.WebViewProviderResponse)

Example 19 with WebViewProviderInfo

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

the class WebViewUpdateServiceTest method testSeveralRelros.

public void testSeveralRelros() {
    String singlePackage = "singlePackage";
    checkCertainPackageUsedAfterWebViewBootPreparation(singlePackage, new WebViewProviderInfo[] { new WebViewProviderInfo(singlePackage, "", true, /*def av*/
    false, null) }, 2);
}
Also used : WebViewProviderInfo(android.webkit.WebViewProviderInfo)

Example 20 with WebViewProviderInfo

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

the class WebViewUpdateServiceTest method testNotifyRelroDoesntCrashIfNoPackages.

/**
     * Timing dependent test where we verify that the list of valid webview packages becoming empty
     * at a certain point doesn't crash us or break our state.
     */
public void testNotifyRelroDoesntCrashIfNoPackages() {
    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) };
    setupWithPackages(packages);
    // Add (enabled and valid) package infos for each provider
    setEnabledAndValidPackageInfos(packages);
    mWebViewUpdateServiceImpl.prepareWebViewInSystemServer();
    Mockito.verify(mTestSystemImpl).onWebViewProviderChanged(Mockito.argThat(new IsPackageInfoWithName(firstPackage)));
    // Change provider during relro creation to enter a state where we are
    // waiting for relro creation to complete just to re-run relro creation.
    // (so that in next notifyRelroCreationCompleted() call we have to list webview packages)
    mWebViewUpdateServiceImpl.changeProviderAndSetting(secondPackage);
    // Make packages invalid to cause exception to be thrown
    mTestSystemImpl.setPackageInfo(createPackageInfo(firstPackage, true, /* enabled */
    false, /* valid */
    true, /* installed */
    null, /* signatures */
    0));
    mTestSystemImpl.setPackageInfo(createPackageInfo(secondPackage, true, /* enabled */
    false, /* valid */
    true));
    // This shouldn't throw an exception!
    mWebViewUpdateServiceImpl.notifyRelroCreationCompleted();
    WebViewProviderResponse response = mWebViewUpdateServiceImpl.waitForAndGetProvider();
    assertEquals(WebViewFactory.LIBLOAD_FAILED_LISTING_WEBVIEW_PACKAGES, response.status);
    // Now make a package valid again and verify that we can switch back to that
    mTestSystemImpl.setPackageInfo(createPackageInfo(firstPackage, true, /* enabled */
    true, /* valid */
    true, /* installed */
    null, /* signatures */
    1));
    mWebViewUpdateServiceImpl.packageStateChanged(firstPackage, WebViewUpdateService.PACKAGE_ADDED_REPLACED, 0);
    // Ensure we use firstPackage
    checkPreparationPhasesForPackage(firstPackage, 2);
}
Also used : WebViewProviderInfo(android.webkit.WebViewProviderInfo) WebViewProviderResponse(android.webkit.WebViewProviderResponse)

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