Handle legacy broadcasts from dumpstate logic in onFinished() callback

In legacy bugreport workflow dumpstate used to send BUGREPORT_STARTED,
BUGREPORT_FINISHED and REMOTE_BUGREPORT_FINISHED broadcasts.

BUGREPORT_FINISHED and REMOTE_BUGREPORT_FINISHED broadcasts contain
information about the bugreport file, this information is not with
dumpstate in the API WORKFLOW, and is passed to it by the API caller.

Hence these broadcasts need to be sent by the caller of the bugreport
API to share the bugreport file information in the onfinished() callback
function.

Send REMOTE_BUGREPORT_DISPATCH broadcast for DevicePolicyManager to
handle.

Add minimal information in these broadcasts. Not adding all fields that
dumpstate used to send, as most of those were used by Shell. Only
sending necessary fileds used by receivers of these broadcasts.

Handle clean up of old bugreports in onFinished() callback function

Bug: 137825297
Test: * Interactive/Full bugreports successfully created
      * Share notification appears as expected
      * Able to attach these to gmail
Test: * Trigger remote bugreport by hardcoding the value of remote
        bugreport when calling the API
      * Remote bugreport is created successfully
      * No share notification (same behavior as before)
      * Same logs in logcat as triggering remote bugreport using old flow:
          * adb shell setprop dumpstate.options bugreportremote
          * adb shell setprop ctl.start bugreport
Test: * TestDpc (go/testdpc):
          * Install TestDPC
          * Set it as Device Owner
      * Open TestDPC to trigger a remote bugreport ("Request bugreport")
      * Shows user consent for bugreport collection (indicating that the
        API workflow is triggered.
      * Once the collection is complete and you tap "Share" in the notification.
      * TestDPC shows another notification showing the received bugreport file
        path and hash.
      * Verify using adb shell to check if the bugreport file is present
        in the above specified file path
Change-Id: I07c0c64b74a723683601e53e3c68a374ca54f3cb
2 files changed