Commit Graph

229 Commits

Author SHA1 Message Date
Rubin Xu
094f486145 Merge "Secure REMOTE_BUGREPORT_DISPATCH" into tm-dev am: a441d81b3a
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17320104

Change-Id: I67dc59d95e36c64b6fe07b70cfdd5b0cdd4943ba
2022-03-23 11:32:46 +00:00
Rubin Xu
a4131c50d0 Secure REMOTE_BUGREPORT_DISPATCH
In remote bugreport collection, Shell sends REMOTE_BUGREPORT_DISPATCH to
DevicePolicyManagerService which in turn notifies Device Owners that a
bug report is ready for collection. There existed a threat where a
malicous user could spoof the REMOTE_BUGREPORT_DISPATCH broadcast via
ADB to send a crafted bugreport to the Device Owner. Securing
REMOTE_BUGREPORT_DISPATCH is not as easy as it appears: putting a
permission on REMOTE_BUGREPORT_DISPATCH does not work since both the
legitimate sender and the malicious user are UID_SHELL. Instead, we
introduces a nonce which was sent from DPMS to Shell when bugreport is
triggered, and DPM will only accept REMOTE_BUGREPORT_DISPATCH when
a matching nonce is seen.

Ignore-AOSP-First: security fix

Bug: 171495100
Test: atest DeviceOwnerTest#testRemoteBugreportWithTwoUsers
Test: atest DeviceOwnerTest#testAdminActionBookkeeping
Test: atest BugreportManagerTest
Change-Id: I7649b4f22b74647d152d76bb46d5ca70bfa3617d
2022-03-22 12:28:36 +00:00
Abhijit Nukalapati
a6774f8f5e remove redundant share intent for Wear bug report
In ag/13068228, we amended the bug report functionality for Wear to
include a share intent (ACTION_SEND_MULTIPLE) which would be sent once a
bug report is complete. However, this intent is not required as Wear
sends the bug report directly to WCS via TriggerBugReportService in
ClockworkShell.

TriggerBugReportService listens for the bug report finished action
"com.android.internal.intent.action.BUGREPORT_FINISHED" and sends the
bugreport files to WCS. A chooser activity is not launched on Wear.

This issue surfaced due to a silent FileNotFoundException in the logs.
This occurs because the bug report files are consumed and deleted by
TriggerBugReportService in the standard Wear bug repot flow.
By the time this share intent is read, the files no longer exist,
leading to the exception.

Most of the flow is illustrated in the following screenshot:
https://screenshot.googleplex.com/8kjMkirzvPyFHg7

The changes here does two things:
- remove code that introduced the share intent
- remove redundant code after above change
- add missing break statement

BUG: 208822859
Change-Id: I38d1ee961caf2eead105acb9e84101eef45df9b0
2022-02-24 20:59:18 +00:00
Calvin Pan
4ffb7e8884 Clean <plurals> in BugreportProgressService
Bug: 199230228
Test: make
Change-Id: I888c65c8819eb5443178ddfc2097d3519b89cefb
2022-01-26 11:55:10 +08:00
Josh Yang
2e6243d900 Merge "update bug report notification title" 2022-01-11 17:37:40 +00:00
Josh Yang
f9965004c0 Merge "Support adding System Traces to Wear Bugreports" 2022-01-11 17:33:44 +00:00
Yeabkal Wubshit
5837e45717 Share Wear bugreport right after it is taken
In rvc-wear-dev, bugreports were not shared to phone until user tapped
on the bugreport-complete notification. Now, we are sending bugreports
to phones immediately after bugreport is taken. We still retain the
bugreport-complete notification. The bugreport-complete notification
will have an action button that leads the user to a bugreport-warning
screen as long as the user has not opted out from seeing the warning.
If the user chooses not to see that message again (which they can do
in the warning screen), there will not be any action button on the
bugreport-complete notification, and the user can just swipe to
delete it. Refer to the look of the notification when no warning message
is to be displayed (https://screenshot.googleplex.com/JStqotLwCaTXeL9)
and when a warning message is to be displayed (https://screenshot.googleplex.com/AdGKWFqbky8Ad8s)
Note: this change does NOT affect the functionality of the
BugreportProgressService for any other device except Wear devices.

Bug: 163083307
Test: the described feature tested with salmon running rvc-wear-dev
Change-Id: If6890ef8cada60e454c9232d402bbdb8a1b0315e
2021-11-24 23:45:21 +00:00
Abhijit Nukalapati
f55cffb820 update bug report notification title
Since the existing notification style sets maxLines to 2, the title was
being truncated and the percentage was thus not visible to the user.

As recommended by UX, we are updating the string so that it is no longer
truncated and the percentage text is visible.

Screenshots:
Before - https://screenshot.googleplex.com/9U6RKuMcnECQ3pV
After - https://screenshot.googleplex.com/8U9NCJHhR5qkRCD

BUG: 198747050
Change-Id: I2b94cc65e2b9c3af860dd35532e1060814f6a68e
(cherry picked from commit 262e835016e340e5fd7b5eb00b7ac6579ca127ae)
2021-11-16 22:42:25 +00:00
Yeabkal Wubshit
c4e31b8d9e Support adding System Traces to Wear Bugreports
System Traces collected with the native System Tracing App (Traceur) are
now added under a separate directory (systraces) for Wear bugreports.
Note that this change is functionally no-op for non-Wear form-factors (changes only one log's wordings for non-Wear form-factors).

Bug: 183239853
Test: manual
Change-Id: Id6b9aa0d38a0d465b763ec86fb1192875379431c
(cherry picked from commit 7111510c691ccf20baf372dab5cea2ac30ae0c23)
2021-11-16 22:19:24 +00:00
Yi Kong
ca33a22bc6 profcollect/betterbug integration with content uri
Test: manual
Bug: 183487233
Bug: 194155753
Change-Id: I6bdec2d090126c53d3cf2fa9deece2441eeafd98
2021-10-13 05:34:00 +00:00
Varun Shah
d172b896ae Don't allow non-system window overlays for bug report warnings.
Bug: 175614079
Test: test PoC app
Change-Id: Ie4543c95a6b2d7de47360737b82a6dadde704053
2021-05-12 15:11:14 -07:00
Rhed Jao
f949e8aef9 Merge "Fix missing fields when parceling the BugreportInfo" am: 2042ea04aa am: 77d5168388 am: ffcba92063
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1540911

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ifa5d63a7d7951bb9fcf337e859df786688ac2c6a
2021-01-07 13:58:51 +00:00
Rhed Jao
2042ea04aa Merge "Fix missing fields when parceling the BugreportInfo" 2021-01-07 12:05:46 +00:00
Rhed Jao
fe41c8a0ce Fix missing fields when parceling the BugreportInfo
Shell app exception resulted from two missing fields in BugreportInfo
when it's parceling. Application ran into the duplicate logic to send
notification and start foreground service then caused the exception.

Bug: 176624074
Test: Request a bugreport; kill the com.android.shell; \
      tap the share notification
Change-Id: Ia80f5e77f5486addf9ea7822f566c3fd7d75f42a
2021-01-07 14:19:18 +08:00
Rhed Jao
7cb78fdf34 Returns immediately if the bugreport file already exists
There's a case that BugreportProgressService is invoked twice quickly,
and both services create the same bugreport file name. The later one
may delete current running bugreport file in its clean function,
when it detects another bugreport is running.

Bug: 174314124
Bug: 175287931
Test: atest BugreportReceiverTest
Change-Id: I5e1802c5912f4414f1ad3b8bdaf7c7420332b9d6
Merged-In: I5e1802c5912f4414f1ad3b8bdaf7c7420332b9d6
2020-12-21 04:20:03 +00:00
Rhed Jao
39b6acbb55 Fixes an error handling in BugreportProgressService
Calls onError function when bugreport is finished and file is empty.

Bug: 174314124
Bug: 175287931
Test: atest BugreportReceiverTest
Change-Id: I4542568fd2d2ad1c75c7c3b223accca4995938a3
Merged-In: I4542568fd2d2ad1c75c7c3b223accca4995938a3
2020-12-21 04:19:52 +00:00
Rhed Jao
2150ce56db Fix BugreportReceiverTest
- Implements a local binder and #onBind in the service to return the
  service instance.
- Mocks BugreportManager in the service to avoid service interacting
  with the dumpstate.
- Fixes dialog name field did not disable after service is finished.
- Fixes screenshot did not remove if the name is empty.
- Extends screenshot delay timeout in tests.
- Fine tune the UiBot to fit new bugreport notification.
- Removes obsolete cases in the tests.

Bug: 143130523
Bug: 175287931
Test: atest BugreportReceiverTest
Change-Id: Iae89206da1d08a10891503869bbbf1ce18d4e31f
Merged-In: Iae89206da1d08a10891503869bbbf1ce18d4e31f
2020-12-21 04:19:36 +00:00
Rhed Jao
52e7d23f53 Do not buzzing for each progress of bugreport notification
Only alert bugreport notification at the begining and end.

Bug: 146135200
Bug: 175287931
Test: Manually changing the notification settings to default
      from silent.
Change-Id: Ie955266ad8a7a27a9dc74743e276b5e9c7a2d6fb
Merged-In: Ie955266ad8a7a27a9dc74743e276b5e9c7a2d6fb
2020-12-21 04:18:18 +00:00
Rhed Jao
1893959cf1 Returns immediately if the bugreport file already exists
There's a case that BugreportProgressService is invoked twice quickly,
and both services create the same bugreport file name. The later one
may delete current running bugreport file in its clean function,
when it detects another bugreport is running.

Bug: 174314124
Test: atest BugreportReceiverTest
Change-Id: I5e1802c5912f4414f1ad3b8bdaf7c7420332b9d6
2020-12-10 20:10:02 +08:00
Rhed Jao
8ba3c84cff Fixes an error handling in BugreportProgressService
Calls onError function when bugreport is finished and file is empty.

Bug: 174314124
Test: atest BugreportReceiverTest
Change-Id: I4542568fd2d2ad1c75c7c3b223accca4995938a3
2020-12-10 19:51:29 +08:00
Paul Chang
00dff9634c Replace broadcast with adding a method in BugreportCallback
BUG: 154298410
Test: BetterBug can work normally in bug report shortcut flow
Change-Id: Ibc1a5a8ac308c303399d28eb8c177096b805fdf9
Merged-In: Ibc1a5a8ac308c303399d28eb8c177096b805fdf9
(cherry picked from commit ec91d7700d)
2020-11-23 12:55:46 +00:00
Paul Chang
ec91d7700d Replace broadcast with adding a method in BugreportCallback
BUG: 154298410
Test: BetterBug can work normally in bug report shortcut flow
Change-Id: Ibc1a5a8ac308c303399d28eb8c177096b805fdf9
2020-11-14 12:11:34 +00:00
Kweku Adams
39d93256cc Add FLAG_IMMUTABLE to heap dump notification PendingIntent.
Bug: 171987666
Test: Android builds
Change-Id: I0be6f837e7948db8d7a50c5ef6497aeb1854acde
2020-11-11 14:04:52 -08:00
Gavin Corkery
2d38f6e4f0 Add immutability flag to PendingIntents
Explicitly set FLAG_IMMUTABLE for all PendingIntents
in BugreportProgressService.

Test: Builds
Bug: 170165227
Bug: 171830604
Change-Id: Iae1489b9c8fa323448e60615e99ad96aee1cd1d7
2020-10-28 11:23:41 +00:00
Jeff Sharkey
864524af17 Apply FLAG_IMMUTABLE to various PendingIntents.
Some careful spot-checking has revealed common cases where it's
reasonable to blanket apply the new FLAG_IMMUTABLE option to newly
created PendingIntents.  Specifically these situations:

-- Simple notification content clicks are immutable; there's no need
to communicate customized data back to the creator
-- Simple notification action clicks are immutable; there's no need
to communicate customized data back to the creator
-- Broadcast intents sent by AlarmManager are immutable; the system
dispatches them without customization.

Bug: 170165227, 170424283, 170425388, 170425877
Bug: 169791183, 170771965, 170226088, 170224928, 170767530
Test: none
Change-Id: I5ed68710d2ccad4635a30fd91136a9e6ad76a01d
2020-10-20 16:20:54 -06:00
Treehugger Robot
ee6cd5fc5b Merge "Update language to comply with Android's inclusive language guidance" am: 986e49df72 am: 21e5a00fb3 am: bc3cef1dce am: 91d640572f am: 58ebc4f303
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1382481

Change-Id: I23744e158143a09d887e0ff1de912f687ffd0ded
2020-09-28 16:12:12 +00:00
Treehugger Robot
986e49df72 Merge "Update language to comply with Android's inclusive language guidance" 2020-09-28 14:11:49 +00:00
chaviw
ca2eb0182f Remove rotation and use flag useIdentityTransform for screenshots.
There's a lot of confusing logic where 90 and 270 rotation values need
to be flipped to ensure the screenshot is taken the correct orientation.
There's also confusion what useIdentityTransform means, especially if a
non 0 rotation value is sent.

The cases screenshot cares about is the following:
1. Take screenshot in current display orientation
2. Take screenshot with 0 rotation so the caller can handle rotating the
screenshot themselves.

With these two cases in mind, remove the rotation value passed in for
screenshots. If useIdentityTransform is true, it will rotate the
screenshot so it's in the 0 orientation. If useIdentityTransform is
false, it will use the current display rotation.

This simplifies the caller logic since they no longer have to find the
current display rotation to ensure the screenshot is taken in the
current rotation. The callers can just request the screenshot with
useIdentityTransform set to false.

Test: adb shell screencap
Test: Power + volume screenshot
Test: Screen rotation
Fixes: 135942984
Change-Id: I3435ee8b5dac05e910ec1e695f398c5dcdcff9e9
2020-08-06 11:30:59 -07:00
Alice Kuo
5c75720453 Update language to comply with Android's inclusive language guidance
See https://source.android.com/setup/contribute/respectful-code for reference

 #inclusivefixit

Bug: 162536543
Change-Id: I468147a439c1a60488def7db3e44bfc361bddbe4
2020-08-03 15:42:39 +00:00
Rhed Jao
45c7d94d7a Fix BugreportReceiverTest
- Implements a local binder and #onBind in the service to return the
  service instance.
- Mocks BugreportManager in the service to avoid service interacting
  with the dumpstate.
- Fixes dialog name field did not disable after service is finished.
- Fixes screenshot did not remove if the name is empty.
- Extends screenshot delay timeout in tests.
- Fine tune the UiBot to fit new bugreport notification.
- Removes obsolete cases in the tests.

Bug: 143130523
Test: atest BugreportReceiverTest
Change-Id: Iae89206da1d08a10891503869bbbf1ce18d4e31f
2020-06-18 20:40:41 +08:00
Rhed Jao
d8b3398edf Do not buzzing for each progress of bugreport notification
Only alert bugreport notification at the begining and end.

Bug: 146135200
Test: Manually changing the notification settings to default
      from silent.
Change-Id: Ie955266ad8a7a27a9dc74743e276b5e9c7a2d6fb
2020-06-09 19:36:18 +08: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
Isaac Chen
5bc026a72d 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
Merged-In: I927b7dae779da25589f2198e0480c0f2a788a7e4
(cherry picked from commit 539298c1b9)
2020-05-19 10:30:23 +08: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