Merge "Remove ShadowUserManager.setSecurityErrorOnNextGetAccountsByTypeCall" into main
diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowAccountManagerTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowAccountManagerTest.java
index 1c61456..72277bb 100644
--- a/robolectric/src/test/java/org/robolectric/shadows/ShadowAccountManagerTest.java
+++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowAccountManagerTest.java
@@ -3,7 +3,6 @@
 import static android.os.Build.VERSION_CODES.LOLLIPOP_MR1;
 import static android.os.Build.VERSION_CODES.O;
 import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertThrows;
 import static org.junit.Assert.fail;
 import static org.robolectric.Shadows.shadowOf;
 import static org.robolectric.shadows.ShadowLooper.shadowMainLooper;
@@ -1100,33 +1099,14 @@
 
     shadowOf(am).setAuthenticationErrorOnNextResponse(true);
 
-    assertThrows(
-        AuthenticatorException.class,
-        () ->
-            am.getAccountsByTypeAndFeatures(
-                    /* type= */ null,
-                    /* features= */ null,
-                    /* callback= */ null,
-                    /* handler= */ null)
-                .getResult());
+    try {
+      am.getAccountsByTypeAndFeatures(null, null, null, null).getResult();
+      fail("should have thrown");
+    } catch (AuthenticatorException expected) {
+      // Expected
+    }
 
-    assertThat(
-            am.getAccountsByTypeAndFeatures(
-                    /* type= */ null,
-                    /* features= */ null,
-                    /* callback= */ null,
-                    /* handler= */ null)
-                .getResult())
-        .isEmpty();
-  }
-
-  @Test
-  public void setSecurityErrorOnNextGetAccountsByTypeCall() {
-    shadowOf(am).setSecurityErrorOnNextGetAccountsByTypeCall(true);
-
-    assertThrows(SecurityException.class, () -> am.getAccountsByType(null));
-
-    assertThat(am.getAccountsByType(null)).isEmpty();
+    am.getAccountsByTypeAndFeatures(null, null, null, null).getResult();
   }
 
   private static class TestAccountManagerCallback<T> implements AccountManagerCallback<T> {
diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowAccountManager.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowAccountManager.java
index 8ca8ee0..447b2dc 100644
--- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowAccountManager.java
+++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowAccountManager.java
@@ -57,7 +57,6 @@
   private Handler mainHandler;
   private RoboAccountManagerFuture pendingAddFuture;
   private boolean authenticationErrorOnNextResponse = false;
-  private boolean securityErrorOnNextGetAccountsByTypeCall = false;
   private Intent removeAccountIntent;
 
   @Implementation
@@ -77,11 +76,6 @@
 
   @Implementation
   protected Account[] getAccountsByType(String type) {
-    if (securityErrorOnNextGetAccountsByTypeCall) {
-      securityErrorOnNextGetAccountsByTypeCall = false;
-      throw new SecurityException();
-    }
-
     if (type == null) {
       return getAccounts();
     }
@@ -756,16 +750,6 @@
   }
 
   /**
-   * Sets flag which if {@code true} will cause an exception to be thrown by {@link
-   * #getAccountsByType}.
-   *
-   * @param shouldThrowException should an exception be thrown or not on the next method call.
-   */
-  public void setSecurityErrorOnNextGetAccountsByTypeCall(boolean shouldThrowException) {
-    this.securityErrorOnNextGetAccountsByTypeCall = shouldThrowException;
-  }
-
-  /**
    * Sets the intent to include in Bundle result from {@link #removeAccount} if Activity is given.
    *
    * @param removeAccountIntent the intent to surface as {@link AccountManager#KEY_INTENT}.