Class ShadowContextWrapper

    • Constructor Detail

      • ShadowContextWrapper

        public ShadowContextWrapper()
    • Method Detail

      • getBroadcastIntents

        public List<Intent> getBroadcastIntents()
        Returns the broadcast intents sent during the tests (for all users).
      • getBroadcastOptions

        public Bundle getBroadcastOptions​(Intent intent)
        Returns the broadcast options when the intent was last sent.
      • getBroadcastIntentsForUser

        public List<Intent> getBroadcastIntentsForUser​(UserHandle userHandle)
        Returns the broadcast intents sent to the given user.
      • clearBroadcastIntents

        public void clearBroadcastIntents()
        Clears the broadcast intents sent during the tests (for all users).
      • getNextStartedActivityForResult

        public ShadowActivity.IntentForResult getNextStartedActivityForResult()
        Consumes the most recent IntentForResult started by {@link * ContextWrapper#startActivity(android.content.Intent, android.os.Bundle)} and returns it.
        Returns:
        the most recently started IntentForResult
      • getAllStartedServices

        public List<Intent> getAllStartedServices()
        Returns all Intent started by #startService(android.content.Intent) without consuming them.
        Returns:
        the list of Intent
      • grantPermissions

        public void grantPermissions​(String... permissionNames)
        Grant the given permissions for the current process and user.
      • grantPermissions

        public void grantPermissions​(int pid,
                                     int uid,
                                     String... permissions)
        Grant the given permissions for the given process and user.
      • denyPermissions

        public void denyPermissions​(String... permissionNames)
        Revoke the given permissions for the current process and user.

        Has no effect if permissions were not previously granted.

      • denyPermissions

        public void denyPermissions​(int pid,
                                    int uid,
                                    String... permissions)
        Revoke the given permissions for the given process and user.
      • removeSystemService

        public void removeSystemService​(String name)
        Makes Context.getSystemService(String) return null for the given system service name, mimicking a device that doesn't have that system service.