Commit Graph

198 Commits

Author SHA1 Message Date
Gavin Corkery
a335516ab2 Add immutability flag to PendingIntents
Explicitly set FLAG_IMMUTABLE for all PendingIntents
in BugreportProgressService.

Test: Builds
Bug: 170165227
Bug: 171830604
Bug: 178803845
Change-Id: Iae1489b9c8fa323448e60615e99ad96aee1cd1d7
Merged-in: Iae1489b9c8fa323448e60615e99ad96aee1cd1d7
(cherry picked from commit 2d38f6e4f0)
2021-02-24 21:37:23 +00:00
Robin Lee
1d22ea4eca Merge "Take interactive bugreports on Android TV" into rvc-dev 2020-05-22 09:58:53 +00:00
Robin Lee
93059d2f0b Take interactive bugreports on Android TV
We want to take a screenshot immediately, not after dumpsys finished.
This also gives the user some feedback that we took a screenshot when
they were paying attention, whereas the notification might go under
the radar if posted the 30-90 seconds later it will be shown
otherwise.

Also gives us the progress notification in the Android TV notification
tray, which helps the user keep track of what is going on and how long
it is expected to take.

Previously either no feedback was shown at all on key press, or a simple
Toast was shown on selecting the bugreport option from the TV Settings
app.

Test: Press DPAD_CENTER + BACK, observe screenshot and progress.
Fix: 151865303
Change-Id: I78753697a7867042d28364a6b6d61fdb96f8bc96
2020-05-21 20:19:03 +00:00
TreeHugger Robot
6351c72746 Merge "Revert "Add a null home activity to Shell.apk"" into rvc-dev 2020-05-18 17:28:46 +00:00
Isaac Chen
539298c1b9 Revert "Add a null home activity to Shell.apk"
This reverts commit 6b1c4a9e09.

Bug: 149226068
Bug: 149307007
Bug: 149780604
Test: $ lunch aosp_crosshatch-userdebug; m
      # flash and boot on a crosshatch
      # Settings -> Apps & notifications -> Default apps -> Home apps
      # Only Quickstep home is there; no Shell home any more
      $ lunch csi_arm64-userdebug; m
      # flash the resulted system.img on a crosshatch and boot
      $ atest DeviceHealthTests # all passed
Change-Id: I927b7dae779da25589f2198e0480c0f2a788a7e4
2020-05-08 14:35:24 +08:00
Abhijeet Kaur
1a5687df2c Delete empty bugreport files onError
Bug: 152839953
Test: Take another bugreport, while one is in progress.
Without this change: bugreport files for the second bugreport can be
seen in /bugreports
With this change: no file for the second bugreport can be seen. This
is the expected behavior.

Change-Id: I45c1f66f3a52ba9a31413cf9748bc5504eaa65d0
2020-04-06 12:35:19 +01:00
TreeHugger Robot
abfb1b0eda Merge "Follow best practices for Atomic variables" into rvc-dev 2020-04-03 11:43:33 +00:00
Abhijeet Kaur
98deae1551 Follow best practices for Atomic variables
* Make Atomic variables final so it can never be re-assigned to a null
object and hence avoid NPE.
* Set the value of the variables instead of re-assigning the object.

Test: Manual
Bug: 152479372
Change-Id: I58279d589d6247c53155755223fd8863f1049257
2020-04-02 16:52:54 +00:00
Abhijeet Kaur
8449e85f3c Track bugreports immediately after triggering a bugreport
Remove an old hack that was put in place as bugreport ID was updated
a bit later in the bugreport generation phase.
This change removes the race condition around triggering bugreports
almost instantly.

Bug: 152292912
Test: Trigger consecutive bugreports from ActivityManager WAI. (Fails
without this change)

Change-Id: Ib08bc2c7d8ae765894998e5bfa0d9b6f3efa088b
2020-04-02 15:02:29 +01:00
TreeHugger Robot
8f08b1cd40 Merge "Delete bugreport file on bugreport cancel" into rvc-dev 2020-03-31 18:38:51 +00:00
Abhijeet Kaur
982b104755 Delete bugreport file on bugreport cancel
Note: bugreport Cancel is not the same as bugreport onError. Files are not
deleted onError, as it still has some information before the bugreport
crashed/stopped. Bugreport Cancel is triggered by the user, hence clean
up all the files.

Bug: 146994281
Test: Cancel interactive bugreport from UI, deletes the current
bugreport files

Change-Id: I2606e491cbaa20eaa60980e98af56a194bae2280
2020-03-30 17:25:04 +01:00
TreeHugger Robot
937e786319 Merge "Initialize progress and lastProgress AtomicIntegers" into rvc-dev 2020-03-27 12:03:54 +00:00
Abhijeet Kaur
5f49375c4e Initialize progress and lastProgress AtomicIntegers
This is essential for bugreports that do not send progress updates.

Bug: 152343458
Test: Take and share full bugreport
Change-Id: Id634afd82a92c02d1cf96ffd719fff8670fb8709
2020-03-26 11:12:11 +00:00
Abhijeet Kaur
0b304c36f6 Show predefined title and description in finished notification
shareTitle and shareDescription is passed by the caller of the
bugreport. Show these in the finished bugreport notification.

Pre-set shareTitle takes precedence over user modified title.

shareDescription and description are not related/dependant on each other
in any way.

Bug: 150333444
Test: Manual (by passing EXTRA_TITLE and EXTRA_DESCRIPTION from
ActivityManagerService when trigerring a bugreport)

Change-Id: I2bfd080aeee677cdc8d0af339d7ad4a29451c3e0
2020-03-25 15:55:27 +00:00
Abhijeet Kaur
e1be940b84 Clean up code in BugreportProgressService
* Make fields (progress, lastUpdate and finished) atomic to make them
thread safe and also reduce getters/setters.
* Make lastProgress a private field in BugreportInfo.
* Move deleteScreenshots to BugreportInfo class.
* Make fields with lock protected getters/setters as private.
* Make fields that should not be changed as final.

Bug: 147033613
Test: manual
Merged-In: I8f0fb4865c1b7c5d62bebca3e250eee59b4e71f4
Change-Id: I8f0fb4865c1b7c5d62bebca3e250eee59b4e71f4
(cherry picked from commit fe7d1ab0cb)
2020-03-18 15:16:52 +00:00
Paul Chang
46ab985f41 Clean up code of starting bug report
- Let screenshot fd be null if Shell doesn't want to take default screenshot when bug report is triggered.

BUG:149525300
Test: Flash and test interactive/full bugreports generated using Shell, and Shell flow does not break during tests
Change-Id: I50908af63d74ed66156354ec0b5a237f7131061a
Merged-In: I50908af63d74ed66156354ec0b5a237f7131061a
2020-02-28 17:14:11 +00:00
Abhijeet Kaur
5cbf58e33c Merge "Add synchronization locks to shared objects" 2020-02-17 13:02:01 +00:00
Abhijeet Kaur
8425e266d1 Add synchronization locks to shared objects
Make methods that read/write mBugreportInfos lock protected and add
"Locked" suffix to the method name. BugreportInfo objects are read/write
in different functions, to keep the code clean, add lock protected
getter/setter methods.

Bug: 142217059
Test: Takes interactive/full bugreports as expected
Change-Id: Iaadd6c9dce5009e40dd015e3b62bcd6e36966e00
2020-02-14 17:07:25 +00:00
Abhijeet Kaur
6688e62e93 Refactor bugreport files creation and getfd methods
Handle Exceptions around file creation/open fd more gracefully inside
BugreportInfo class. This is communicated to the caller of BugreportInfo
by returning null for getFd() methods.

Test: builds

Change-Id: Ie241dce0810645e04b2492dc8b1bcbc3e9f8f664
2020-02-14 09:34:31 +00:00
Abhijeet Kaur
7f99ea08eb Merge "Remove duplicate directory variables with the same value" 2020-02-07 18:33:31 +00:00
Abhijeet Kaur
2c53c192d7 Remove duplicate directory variables with the same value
Bugreport files and screenshot files are saved in the same directory.
Use common variable for consistency and to avoid duplicacy.

Move bugreport file and default screenshot file creation to the
constructor as for each bugreportInfo object a bugreportFile must exist.

Bug:123617758
Test: Takes interactive/full bugreports as expected
Change-Id: I338e852c543e63b403536cd852518b6601ea32f0
2020-02-07 14:38:23 +00:00
Automerger Merge Worker
d99acdae3b Merge "Add a null home activity to Shell.apk" am: fd2ba540df am: 24f93a2b48 am: 26f49e7b75
Change-Id: I77be28465d8fe8439877859e3e630103efe69c4f
2020-02-07 09:03:13 +00:00
Isaac Chen
6b1c4a9e09 Add a null home activity to Shell.apk
In configurations where AOSP Settings.apk is not included, there might
not be any home activity. E.g. CSI doesn't have Settings.apk.

This CL adds a null home activity to Shell.apk, which is in CSI,
so the framework can be in a sane state. Without such null home
activity in CSI, package manager fails to install any APKs.

Bug: 148044842
Test: $ lunch csi_arm64-userdebug; m -j
      # Flash CSI to a Pixel (with AVB disabled) and reboot
      $ m DeviceHealthChecks
      $ adb install $OUT/testcases/DeviceHealthTests/arm64/DeviceHealthTests.apk
      Performing Streamed Install
      Success

Change-Id: I87999e30298bbe42af64f28e88fc6dc5975f1ca3
2020-02-07 12:50:39 +08:00
Abhijeet Kaur
d501142a64 Remove legacy-flow no-op variables: max, realMax and realProgress
Legacy onProgress aidl listener callback function used to take 2 params:
progress and max. So, the client had to calculate the percentage
progress. This legacy onProgress method is removed.

Now dumpstate sends the actual progress in percentage without requiring
the client to calculate it.

Bug: 123617758
Test: Takes interactive bugreport as expected. And shows progress
notification as expected.

Change-Id: Ic5a355cc886e51b964f73c227f5f657173e99420
2020-01-26 21:43:00 +00:00
Kweku Adams
3ff32e0892 Merge "Move heap dump sharing to SHELL." am: c29b5cba29 am: 2cdf2d5ad7
am: 215d92f880

Change-Id: Ic092f2d5c0c0a1497c19e73417c68b8e8616cc63
2019-10-30 21:15:56 -07:00
Kweku Adams
4d345d7af1 Move heap dump sharing to SHELL.
The system shouldn't be granting read URI permissions as itself. This
means that heap dumps aren't successfully shared. Moving the heap dump
sharing mechanism to SHELL, which already has the permission to dump
heaps so that dumps can be shared properly.

The ActivityManagerService changes are submitted separately.

Bug: 126885951
Bug: 135150619
Test: collect a heap dump and confirm it's successfully shared with an app
Test: do manual test on a secondary user & confirm it's not available to
other user

Change-Id: I6fad69280b5124c8ec2d3b4bef0f7dddb6a9422c
2019-10-29 15:17:42 -07:00
Abhijeet Kaur
72be2e113e Remove unused broadcasts/functions/variables from Shell
Bugreport is now triggered using API and not via broadcasts from
dumpstate. As migration to API flow is stable, we can remove methods and
broadcasts that were used in non-API bugreport flow. Now, callbacks are used
for communication between dumpsate and Shell instead of broadcasts.

* Remove BugreportReceiver.java as it used to handle BUGREPORT_STARTED and
  BUGREPORT_FINISHED intents which are not required by Shell anymore to
  track bugreports.
* Remove RemoteBugreportReceiver.java as it used to handle
  REMOTE_BUGREPORT_FINISHED intent which is not required by Shell
  anymore.
* Remove methods that were being used when processing these broadcasts.
* Remove pid as that is not used anymore.
* Since Shell owns the file now, don't need mTempName, mSavedName,
  onFocusListener and disable file name after the bugreport is finished.
  File name can be sanitized and updated even after bugreport finished.

Bug: 136066578
Test: Build and flash. Interactive/Full bugreports from Settings/Power button.
Test: Rename workflow for interactive bugreports works as expected.
Test: * Build and flash
      * Install TestDPC
      * Make it device owner
      * Take a remote bugreport. Works as expected

Change-Id: I5e0f829631cb63074c41c914236e78abe95ba162
2019-10-22 12:26:23 +01:00
Abhijeet Kaur
5735c6a247 Read screenshot file from screenshotFiles array
Regression from merge issue that was created when merging ag/9489200 and ag/9502526.

Previously, before saving the screenshot file in the array, it had to be
created each time it was required.

Bug: 123617758
Test: manual
Change-Id: I2dc2924aa20609d2445af00025580b2752935903
2019-10-10 16:29:54 +01:00
Abhijeet Kaur
451d9c9ace Add synchronized locks to bugreport callback methods
BugreportCallbackImpl class methods modify (read/write) the private
variable mInfo. Add synchronized locks for consistency.

Make other methods static to be thread-safe, and operate only on its
arguments.

Bug: 123617758
Test: Build and flash. Takes bugreport as expected
Change-Id: I237fd940f5ccd4833d053558cf1b014883d59791
2019-10-07 16:34:23 +01:00
Abhijeet Kaur
396a0acbdb Fix bugreport rename in API workflow
In the current implementation of API flow of bugreport, renaming bugreports
works fine but it changes the entire name. In legacy flow, the user is only
able to rename the suffix of the file. The prefix of the name
(bugreport-deviceName-buildID) remains unchanged. Also, wifi and
telephony bugreports have the type of the bugreport specified explicitly
in the name.

Fix Shell's rename implementation to follow legacy logic. Also stop setting
name property in the API flow since it's a functional no-op anyway, and we
want all communications to dumpstate be through the API when possible.

No need to call trackInfoWithId() for remote bugreports as Shell does not
process any notification related to it.

Bug: 123617758
Test: * Take interactive bugreport, rename and save. (work as expected)
Test: Corner case:
      * Take interactive bugreport, rename and save.
      * Click on the progress notification again and keep the edit box
        open.
      * Wait for bugreport to finish, filename edit box would be disabled
        and autofilled with last saved rename. You will still be able to
        edit title and summary. (works as expected)

Change-Id: I0016ef4fc1e80fb792712c45439e2b0d348f5249
2019-10-07 13:56:44 +01:00
Abhijeet Kaur
2f0ff57798 Merge "Handle legacy broadcasts from dumpstate logic in onFinished() callback" 2019-09-26 09:48:42 +00:00
Abhijeet Kaur
af9fbc3946 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
2019-09-24 16:42:29 +01:00
Dan Sandler
630f991cf2 Merge "Bugreport progress notification should use the bug icon." am: cb783ea2ee am: 704b11756a am: 777b2325be
am: 362e959c7d

Change-Id: I161186cbfef27ace50349d60b1726ef3ba6d1932
2019-09-18 12:16:32 -07:00
Dan Sandler
bc20d4e79f Bugreport progress notification should use the bug icon.
(Don't worry, stat_sys_adb isn't going away, but it will
only be used by the ADB notification now.)

Bug: 138661761
Test: initiate bugreport from globalactions
Change-Id: I238659d50f70bfbc047133d89afb76f78ec841f9
2019-09-12 23:11:36 -04:00
Abhijeet Kaur
725a25f7f5 Set up to migrate requestBugreport flavors to use bugreport API
Add initial set up code to migrate requestBugreport,
requestBugreportWithDescription, requestWifiBugreport and
requestTelephonyBugreport to use the new Bugreport API.

Prepare the intent (to trigger API workflow) but do not send. Not
sending the intent keeps the workflow same as before.

This set up helps to move away from directly setting system properties
(dumpstate.options.title and dumpstate.options.description).

Bug: 139415553
Test: build and flash. Taking a bugreport works as usual
Change-Id: I0b57643ff8f4eadb281e1d7788171ef751a01b79
2019-08-19 12:20:48 +01:00
Nandana Dutt
b745860a3e Merge "Remove obsolete methods from DumpstateListener implementations"
am: cbdb10f982

Change-Id: Ia746b0cdadd0c4d652c373763f7a12266b080e3b
2019-08-07 07:08:27 -07:00
Nandana Dutt
47c5ecc50a Remove obsolete methods from DumpstateListener implementations
Note that with the new Bugreporting API, SystemServer is the only
expected DumpstateListener implementation. Once we fully migrate Shell
app, we can remove the implementation in BugreportService as well.

BUG: 128980174
Test: bugreport from power menu, observe progress bar

Change-Id: I40d654a70bd9ceb3a29f8a0113b85616100f4ee9
Merged-In: I40d654a70bd9ceb3a29f8a0113b85616100f4ee9
2019-08-06 17:43:11 +00:00
Nandana Dutt
ecc40227b6 Merge "Remove obsolete methods from DumpstateListener implementations" 2019-08-06 16:21:34 +00:00
TreeHugger Robot
120820d66b Merge "Add logic to handle screenshot file creation failure" 2019-08-05 17:33:42 +00:00
Abhijeet Kaur
1b1d614e63 Add logic to handle screenshot file creation failure
Delete the bugreport file to free the space before returning.

Delete unnecessary if blocks as the File constructor would never return
null

Bug:123617758
Test: Force code to execute the if (screenshotFd == null) block.
      Bugreport file gets deleted successfully

Change-Id: Ib88278a8a56799ef562b8b06e5e530a8e31e85d5
2019-08-05 15:24:16 +01:00
Nandana Dutt
56659ae22f Remove obsolete methods from DumpstateListener implementations
Note that with the new Bugreporting API, SystemServer is the only
expected DumpstateListener implementation. Once we fully migrate Shell
app, we can remove the implementation in BugreportService as well.

BUG: 128980174
Test: bugreport from power menu, observe progress bar

Change-Id: I40d654a70bd9ceb3a29f8a0113b85616100f4ee9
2019-08-01 16:08:56 +01:00
TreeHugger Robot
9f3eb4a130 Merge "Leave error handling the same as old workflow using dumpstate" 2019-08-01 12:19:34 +00:00
Abhijeet Kaur
0d61c4f89d Leave error handling the same as old workflow using dumpstate
Removing the TODO as won't be working on improving error handling as
part of this bug. Created another bug (b/138576498) to work on better
error handling.

Bug: 123617758
Bug: 127431371
Test: builds (only removing comment)
Change-Id: I8a7fea416e9871909cfb3cc801232bff6056536e
2019-07-31 11:18:55 +01:00
Abhijeet Kaur
af0279c991 Merge "Make shell bugreport file names consistent with dumpstate" 2019-07-29 13:41:13 +00:00
Abhijeet Kaur
906b937b42 Make shell bugreport file names consistent with dumpstate
Since bugreport API workflow will be replacing old workflow of directly
starting dumpstate, we aim that the resulting file names be the same as
the users are used to the old file names (that dumpstate used to decide).

Bug:126862297
Test: * Build and flash to the device
      * Turn on Settings feature flag to use the bugreport API
      * Take interactive and full bugreports
      * Output file names same as before

Change-Id: I24d800e26a8cc4f739038ac0f27da13bd83f7f47
2019-07-29 10:54:32 +01:00
Abhijeet Kaur
ac834969a3 Set id for bugreports after dumpstate increments it.
dumpstate increments system property PROPERTY_LAST_ID when a bugreport
is triggered.

In the old workflow for bugreports, dumpstate used to get triggered
before Shell, and dumpstate would send the 'id' to Shell. Hence Shell
always assumed that it has a known value for 'id', that is why
'id' is declared as a final variable which could be assigned value in
the constructor.

In new workflow using API, the 'id' is incremented after dumpstate gets
triggered. Hence making the following changes:
* Changing 'id' variable to be not final
* Reading 'id' after dumpstate has incremented the system property

Bug: 123617758
Test:  	Build and flash to device.
	Turn on the feature flaggenerate bugreports
	Check the progress and Finish notifications.

Change-Id: I44762190391c128cba135bf0ef795a1ae872dbb7
2019-07-25 14:04:56 +01:00
TreeHugger Robot
deda6a1bd9 Merge "Progress notification for interactive bugreports" 2019-07-22 10:14:44 +00:00
Abhijeet Kaur
1a5030cc7d Add logic to create screenshot file
* Creating screenshot file for all types of bugreport
* The logic to populate the screenshot file is in dumpstate (few
bugreport types that do not need screenshots will leave the file
untouched/empty)
* Delete the empty screenshot file and set the file to null so that
empty file does not get shared
* This TODO was previously left as binder did not allow to send null
screenshotfd, which was recently fixed. While fixing and testing the
optional screenshot fd CL with these changes, left the value "null" by
default. Fixed now.

* Not adding any logic here on the basis of the type of bugreport as
all that is already in dumpstate

* Making the names of bugreport (.zip file) and bugreport screenshot
(.png file) consistent. In the old flow also both have the same names.

Bug: 123617758
Test: * Build and flash to the device
      * Turn on use bugreport API feature flag from Settings
      * Take interactive bugreport
      Expectation: On clicking the notification to "Share the bugreport"
      only 1 file (the bugreport zip file) gets shared. Also, there is
      no screenshot file in /bugreports/ in the device
      * Take full bugreport
      Expectation: On clicking the notification to "Share the bugreport"
      2 files (bugreport zip and screenshot png file) get shared. Also
      we can see the screenshot file in /bugreports/ in the device

Change-Id: I39cb6913033b6e3c61bd0c6655a76524c12d2428
2019-07-18 16:53:06 +01:00
Abhijeet Kaur
97a8f0f5db Progress notification for interactive bugreports
Send instant progress notification for interactive bugreports (when
using bugreport API), starting notification when progress = 0

Bug: 123617758

Test: * Build and flash to the device
      * Turn on use bugreport API feature flag from Settings
      * Take interactive bugreport
      Expectation: Progress notification is shown instantly

Change-Id: Icd834c05324108430ee6cb9c3d8539f91059e563
2019-06-04 15:36:16 +01:00
Abhijeet Kaur
0a295724f2 Merge "Add dark theme for Shell app." into qt-dev am: 190e99cf3a am: 1cceacc469
am: 2c90394b5d

Change-Id: I8c913dfa6823f9c9cfee1a68a3f61000e5594b57
2019-05-29 07:27:37 -07:00