Commit Graph

52457 Commits

Author SHA1 Message Date
TreeHugger Robot
e7da6dd26e Merge "DO NOT MERGE Crash invalid FGS notifications" into qt-dev 2022-05-12 19:50:55 +00:00
Wenhao Wang
248bbf2dca Merge "DO NOT MERGE Suppress notifications when device enter lockdown" into qt-dev 2022-04-28 19:44:46 +00:00
Wenhao Wang
85c00b98a6 DO NOT MERGE Suppress notifications when device enter lockdown
This CL makes the following modifcations:
1. Add LockPatternUtils.StrongAuthTracker to monitor
the lockdown mode status of the phone.
2. Call mListeners.notifyRemovedLocked with all the
notifications in the mNotificationList when entering
the lockdown mode.
3. Call mListeners.notifyPostedLocked with all the
notifications in the mNotificationList when exiting
the lockdown mode.
4. Dismiss the function calls of notifyPostedLocked,
notifyRemovedLocked, and notifyRankingUpdateLocked
during the lockdown mode.

The CL also adds corresponding tests.

Bug: 173721373
Test: atest NotificationManagerServiceTest
Test: atest NotificationListenersTest
Test: manually verify the paired device cannot receive
notifications when the host phone is in lockdown mode.
Ignore-AOSP-First: pending fix for a security issue.

Change-Id: I7e83544863eeadf8272b6ff8a9bb8136d6466203
Merged-In: I7e83544863eeadf8272b6ff8a9bb8136d6466203
(cherry picked from commit 3cb6842a05)
2022-04-25 15:29:35 -07:00
Eric Biggers
a318c254f7 Merge changes from topic "unencrypted-dirs-q" into qt-dev
* changes:
  [RESTRICT AUTOMERGE] Log to EventLog on prepareUserStorage failure
  [RESTRICT AUTOMERGE] Ignore errors preparing user storage for existing users
  [RESTRICT AUTOMERGE] UserDataPreparer: reboot to recovery for system user only
  [RESTRICT AUTOMERGE] UserDataPreparer: reboot to recovery if preparing user storage fails
  [RESTRICT AUTOMERGE] StorageManagerService: don't ignore failures to prepare user storage
  Check user unlocked before write to /data/system_ce/0/snapshots
2022-04-25 17:11:39 +00:00
Julia Reynolds
b6b2906ea6 DO NOT MERGE Crash invalid FGS notifications
Test: CTS, ActivityManagerProcessStateTest
Fixes: 191981182
Change-Id: I13a0202b25c8118db47edba11a93c1939c94b392
Merged-In: I13a0202b25c8118db47edba11a93c1939c94b392
(cherry picked from commit 6f657f8f5b)
2022-04-20 18:16:44 +00:00
JW Wang
f562aadd77 Fix NPE
NPE happens when there is an orphaned session which we've
tried to prevent in all cases.

Log an error message if this situation happens.

Bug: 227342978
Test: atest CtsRootPackageInstallerHostTestCases
Change-Id: Ia21323926bd9db1a6f05461904deb45b4c3dd0bc
(cherry picked from commit 07e31dfb1e)
Merged-In: Ia21323926bd9db1a6f05461904deb45b4c3dd0bc
2022-04-05 19:50:59 +00:00
Oli Lan
a7621e0ce0 RESTRICT AUTOMERGE Prevent non-admin users from deleting system apps.
This addresses a security issue where the guest user can remove updates
for system apps.

With this CL, attempts to uninstall/downgrade system apps will fail if
attempted by a non-admin user.

This is a backport of ag/17352264.

Bug: 170646036
Test: manual, try uninstalling system app update as guest
Change-Id: I5bbaaf83d035c500bfc02ff4b9b0e7fb1e7c2feb
Merged-In: I4e959e296cca9bbdfc8fccc5e5e0e654ca524165
2022-03-30 14:02:19 +00:00
Eric Biggers
2f2e7d84f8 [RESTRICT AUTOMERGE] Log to EventLog on prepareUserStorage failure
Bug: 224585613
Change-Id: Id6dfb4f4c48d5cf4e71f54bdb6d0d6eea527caf5
(cherry picked from commit fbb632ea95)
Merged-In: Id6dfb4f4c48d5cf4e71f54bdb6d0d6eea527caf5
2022-03-29 20:53:11 +00:00
Eric Biggers
493aa93b84 [RESTRICT AUTOMERGE] Ignore errors preparing user storage for existing users
Unfortunately we can't rule out the existence of devices where the user
storage wasn't properly prepared, due to StorageManagerService
previously ignoring errors from mVold.prepareUserStorage, combined with
OEMs potentially creating files in per-user directories too early.  And
forcing these broken devices to be factory reset upon taking an OTA is
not currently considered to be acceptable.

One option is to only check for prepareUserStorage errors on devices
that launched with T or later.  However, this is a serious issue and it
would be strongly preferable to do more than that.

Therefore, this CL makes it so that errors are checked for all new
users, rather than all new devices.  A field ignorePrepareStorageErrors
is added to the user record; it is only ever set to true implicitly,
when reading a user record from disk that lacks this field.  This field
is used by StorageManagerService to decide whether to check for errors.

Bug: 164488924
Bug: 224585613
Test: Intentionally made a device affected by this issue by reverting
      the CLs that introduced the error checks, and changing vold to
      inject an error into prepareUserStorage.   Then, flashed a build
      with this CL without wiping userdata.  The device still boots, as
      expected, and the log shows that the error was intentionally
      ignored.  Tested that if a second user is added, the error is
      *not* ignored and the second user's storage is destroyed before it
      can be used.  Finally, wiped the device and verified that it won't
      boot up anymore, as expected since error checking is enabled for
      the system user in that case.
Change-Id: I9bdd1a4bf5b14542adb901f264a91d489115c89b
(cherry picked from commit 60d8318c47)
Merged-In: I9bdd1a4bf5b14542adb901f264a91d489115c89b
2022-03-29 20:52:58 +00:00
Eric Biggers
a296a2b724 [RESTRICT AUTOMERGE] UserDataPreparer: reboot to recovery for system user only
With the next CL, old devices might contain a combination of old users
with prepareUserStorage error checking disabled and new users with
prepareUserStorage error checking enabled.  Factory resetting the whole
device when any user fails to prepare may be too aggressive.  Also,
UserDataPreparer already destroys the affected user's storage when it
fails to prepare, which seems to be fairly effective at breaking things
for that user (absent proper error handling by upper layers).

Therefore, let's only factory reset the device if the failing user is
the system user.

Bug: 164488924
Bug: 224585613
Change-Id: Ia1db01ab4ec6b3b17d725f391c3500d92aa00f97
(cherry picked from commit 4c76da76c9)
Merged-In: Ia1db01ab4ec6b3b17d725f391c3500d92aa00f97
2022-03-29 20:52:56 +00:00
Eric Biggers
ea010f3dd2 [RESTRICT AUTOMERGE] UserDataPreparer: reboot to recovery if preparing user storage fails
StorageManager.prepareUserStorage() can throw an exception if a
directory cannot be encrypted, for example due to already being
nonempty.  In this case, usage of the directory must not be allowed to
proceed.  UserDataPreparer currently handles this by deleting the user's
directories, but the error is still ultimately suppressed and starting
the user is still allowed to proceed.

The correct behavior in this case is to reboot into recovery to ask the
user to factory reset the device.  This is already what happens when
'init' fails to encrypt a directory with the system DE policy.  However,
this was overlooked for the user directories.  Start doing this.

Bug: 164488924
Bug: 224585613
Change-Id: Ib5e91d2510b25780d7a161b91b5cee2f6f7a2e54
(cherry picked from commit 5256365e65)
Merged-In: Ib5e91d2510b25780d7a161b91b5cee2f6f7a2e54
2022-03-29 20:52:53 +00:00
Eric Biggers
f80dd3ecd4 [RESTRICT AUTOMERGE] StorageManagerService: don't ignore failures to prepare user storage
We must never leave directories unencrypted.

Bug: 164488924
Bug: 224585613
Change-Id: I9a38ab5cca1ae9c9ebff81fca04615fd83ebe4b2
(cherry picked from commit 50946dd15f)
Merged-In: I9a38ab5cca1ae9c9ebff81fca04615fd83ebe4b2
2022-03-29 20:52:43 +00:00
Guo Li
3ab9dc113e Check user unlocked before write to /data/system_ce/0/snapshots
When reboot device. TaskSnapshotPersister create directory
"/data/system_ce/0/snapshots" before FBE decrypt.
Then WTF occur.

Bug: 154787951
Bug: 224585613
Test: Device boots without WTF error
Change-Id: Ie9d4a28008adc93e27bc8ab015a3a6507428c3e4
(cherry picked from commit 2f9987f507)
Merged-In: Ie9d4a28008adc93e27bc8ab015a3a6507428c3e4
2022-03-28 19:25:16 +00:00
TreeHugger Robot
81f051eff4 Merge "DO NOT MERGE Add an OEM configurable limit for zen rules" into qt-dev 2022-03-22 20:12:47 +00:00
Julia Reynolds
3072d98c2d DO NOT MERGE Add an OEM configurable limit for zen rules
Test: ZenModeHelperTest
Bug: 220735360
Change-Id: I3da105951af90007bf48dc6cf00aed3e28778b36
Merged-In: I3da105951af90007bf48dc6cf00aed3e28778b36
2022-03-22 14:36:52 +00:00
TreeHugger Robot
1adea76f46 Merge "Always restart apps if base.apk gets updated." into qt-dev 2022-03-09 06:09:58 +00:00
TreeHugger Robot
3d226b76c1 Merge "Verify caller before auto granting slice permission" into qt-dev 2022-03-09 05:41:31 +00:00
Alex Buynytskyy
a5dd59db6d Always restart apps if base.apk gets updated.
Bug: 219044664
Fixes: 219044664
Test: atest PackageManagerShellCommandTest
Change-Id: I27a0c5009b2d5f1ea51618b9acfa1e6ccee71296
Merged-In: I27a0c5009b2d5f1ea51618b9acfa1e6ccee71296
2022-03-09 00:48:11 +00:00
TreeHugger Robot
88bdf80af8 Merge "[RESTRICT AUTOMERGE] Do not resume activity if behind a translucent task" into qt-dev 2022-03-07 05:40:46 +00:00
Pinyao Ting
3c92d74d7d Verify caller before auto granting slice permission
Currently SliceManagerService#checkSlicePermission does not verify the
caller's identity. This leads to a security vulnerability because
checkSlicePermission does more than checking the permission as opposed
to simply return a boolean value -- it additionally grants slice access
under a certain condition. A malicious app can spoof the calling package
to acquire slice access.

This CL verifies the caller before granting slice access.

Bug: 208232850, 179699767
Test: manual
Change-Id: I2539c9ff5ea977c91bb58185c95280b4d533a520
Merged-In: I2539c9ff5ea977c91bb58185c95280b4d533a520
(cherry picked from commit 5bd2196c53)
2022-03-05 05:02:49 +00:00
Julia Reynolds
4d7ca1dbce Filter notification APIs by user
Specifically getActiveNotifications and
getHistoricalNotifications

Test: atest NotificationManagerServiceTest
Bug: 214999128
Change-Id: I2eba0a592fa33ed25e1ac3919f1b2631e5db4258
Merged-In: I2eba0a592fa33ed25e1ac3919f1b2631e5db4258
2022-02-16 16:46:32 +00:00
Jeff Chang
f2d4787451 [RESTRICT AUTOMERGE] Do not resume activity if behind a translucent task
The top-focusable activity resides in the RESUMED state while the app
process is newly created and attached. The behavior may enable UI
hijacking attacks against apps implementing authentication.

This CL disallows the system to resume the activity for the case if it
is not visible or is occluded by other translucent tasks.

Bug: 211481342
Test: atest CtsWindowManagerDeviceTestCases:ActivityLifecycleTests
Change-Id: I7903494cf928b5b5613700262b7c5fff10f3c5a0
2022-02-08 18:04:03 +08:00
Julia Reynolds
b993531c0d DO NOT MERGE Prevent apps from creating blocked channel groups
setBlocked is a hidden API, so apps should not be calling
the method, but fix up the data in case they do

Test: PreferencesHelperTest; manual with ApiDemos FGS
Bug: 209966086
Change-Id: Icc709a6b0d0a8c5f2d9243959992f1b6764354db
Merged-In: I8a27853c7ed05d9dfd38a3142fbbe185946c3992
2022-01-20 16:42:59 +00:00
TreeHugger Robot
768bf858bb Merge "[RESTRICT AUTOMERGE]Only allow system and same app to apply relinquishTaskIdentity" into qt-dev 2022-01-12 10:25:27 +00:00
Songchun Fan
30348d5cdc Merge "Persist destroyed staged sessions until they are cleaned up" into qt-dev 2022-01-11 23:31:01 +00:00
Songchun Fan
5bf4a3f29e Merge "Don't abandon child sessions (1/n)" into qt-dev 2022-01-11 23:31:01 +00:00
Mohammad Samiul Islam
6151941007 Persist destroyed staged sessions until they are cleaned up
Currently, when we abandon a staged session we mark it as destroyed and
then immediately clean it up. Cleaning up a staged session immediately
causes racing condition with pre-reboot verification.

In order to avoid the racing condition, we want to delay cleanup of
staged session until it is safe to do so. This means, the system will
be carrying around destroyed staged sessions internally.

Since there is now a gap between when a session is destroyed and when it
is cleaned up, the user can reboot in this window. As such, we need to
persist the mDestroyed field of session so that we know session is
destroyed after reboot and act accordingly.

Also, once a session is destroyed, theoretically it doesn't exist.
Carrying it around internally is an implementation details which
shouldn't be exposed externally. As such, we filter out destroyed
sessions before surfacing them to users.

Bug: 145925842
Bug: 67862680
Test: atest PackageInstallerSessionTest
Test: atest StagedInstallTest
Change-Id: I4ede6b7a4b5d861e5c73f13884c7aa86cf7633a2
Merged-In: I4ede6b7a4b5d861e5c73f13884c7aa86cf7633a2
(cherry picked from commit 731bd965fb)
2022-01-11 22:54:46 +00:00
Julia Reynolds
331b617949 Check group channels for FGSes
Before allowing the group to be deleted, by updating
the current check to the method that populates the channel
list

Test: NotificationManagerServiceTest
Bug: 209965481
Change-Id: I9db781c300e96e9c80bd5d21585b8be9b4db08c8
Merged-In: I9db781c300e96e9c80bd5d21585b8be9b4db08c8
2022-01-10 21:45:07 +00:00
JW Wang
a4ef9e0e00 Don't abandon child sessions (1/n)
It will throw if abandon() is called on a child session.

Bug: 211944991
Bug: 67862680
Test: to be added
Change-Id: Ib0ba9f3786dda2d3174f3ea8c65d1061a3fcb586
Merged-In: Ib0ba9f3786dda2d3174f3ea8c65d1061a3fcb586
(cherry picked from commit 8b67e7db79)
2022-01-10 20:38:54 +00:00
Jeff Chang
cd1f9e72cf [RESTRICT AUTOMERGE]Only allow system and same app to apply relinquishTaskIdentity
Any malicious application could hijack tasks by
android:relinquishTaskIdentity. This vulnerability can perform UI
spoofing or spy on user’s activities.

This CL limit the usage which only allow system and same app to apply
relinquishTaskIdentity

Bug: 185810717
Test: atest IntentTests
      atest ActivityStarterTests
Change-Id: I55fe8938cd9a0dd7c0268e1cfec89d4e95eee049
2022-01-06 17:46:33 +08:00
Dmitry Dementyev
8e8fbc8927 Merge "Force-set a ClipData to prevent later migration." into pi-dev am: d5c2fb380a
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16094504

Change-Id: I0d01e8325beae6a69b88a38887863b222be01b95
2021-11-09 14:52:24 +00:00
Dmitry Dementyev
d5c2fb380a Merge "Force-set a ClipData to prevent later migration." into pi-dev 2021-11-09 14:24:20 +00:00
Jeff Sharkey
3cf2b04986 Force-set a ClipData to prevent later migration.
migrateExtraStreamToClipData() will only offer to promote Uri values
if a ClipData isn't already defined, so we ensure that a ClipData
value is always defined.  This blocks later promotion and granting.

Bug: 200683077
Bug: 123700107
Test: manual
Change-Id: I99c1411e8b4eb01eb27ac4306e3bf6cc88cb4273
(cherry picked from commit 6ebf410b81)
2021-11-03 19:53:42 +00:00
Songchun Fan
bd25f70623 Revert "Revert "[pm] remove old stage dirs on low storage""
This reverts commit b45ebca772.

Reason for revert: adding the fix for system to abandon sessions

BUG: 67862680
Test: manual
Change-Id: I2b735e4860dce6eb6d5d8ddc158e8b3165910dc7
Merged-In: I91170ba399b3a596320b3bd9c8188912e5c4f1be
2021-10-14 10:40:29 -07:00
Songchun Fan
3e28df68fa Revert "Revert "[pm] remove old stage dirs on low storage""
This reverts commit b45ebca772.

Reason for revert: adding the fix for system to abandon sessions

BUG: 67862680
Test: manual
Change-Id: Ia798eb776eb1d05347514a238a6dd75e7c89e872
Merged-In: I91170ba399b3a596320b3bd9c8188912e5c4f1be
2021-10-14 09:26:28 -07:00
shubang
e55bc91578 TIF: fix issue of using caller-aware methods after clearCallingIdentity() am: 05363ef193
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15752564

Change-Id: Iaa3b040cc8e47a3a36496b1de033b341a0e9e2e3
2021-09-08 00:37:10 +00:00
shubang
05363ef193 TIF: fix issue of using caller-aware methods after clearCallingIdentity()
Bug: 189824175
Test: atest android.media.tv.cts.TvInputManagerTest
Change-Id: Iced6c2245c0099bc4bcdaceb51f8cce4dbc0a392
(cherry picked from commit a2ab2772d7)
2021-09-07 19:15:05 +00:00
Aseem Kumar
551d70e1c8 Prevent apps from spamming addAccountExplicitly.
See comment here for the discussion on solution
https://b.corp.google.com/issues/169762606#comment14

Change-Id: If212df3a3b7be1de0fb26b8e88b2fcbb8077c253

Bug: 169762606
(cherry picked from commit 11053c17b3)

Change-Id: I424e098dd70ae31bbbc7cb2f3eccd1ccc287064b
Merged-In: If212df3a3b7be1de0fb26b8e88b2fcbb8077c253
2021-09-03 19:08:23 +00:00
TreeHugger Robot
b65ac540d2 Merge "Prevent apps from spamming addAccountExplicitly. See comment here for the discussion on solution https://b.corp.google.com/issues/169762606#comment14" into pi-dev am: a0226b4d47
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15405290

Change-Id: I0073721ed49e40043625eae71f37e7e95b987340
2021-09-01 00:34:01 +00:00
TreeHugger Robot
a0226b4d47 Merge "Prevent apps from spamming addAccountExplicitly. See comment here for the discussion on solution https://b.corp.google.com/issues/169762606#comment14" into pi-dev 2021-09-01 00:11:36 +00:00
Aseem Kumar
5beff34b57 Prevent apps from spamming addAccountExplicitly.
See comment here for the discussion on solution
https://b.corp.google.com/issues/169762606#comment14

Change-Id: If212df3a3b7be1de0fb26b8e88b2fcbb8077c253

Bug: 169762606
(cherry picked from commit 11053c17b3)

Change-Id: I6494366a5695daedc3f4f0046da9e130a5363f5f
Merged-In: If212df3a3b7be1de0fb26b8e88b2fcbb8077c253
2021-08-19 09:52:26 +00:00
Sudheer Shanka
98adfca8a6 Merge "Add SafetyNet logging if a certain broadcast is received by apps." into pi-dev 2021-08-11 02:55:31 +00:00
Sudheer Shanka
e8426090a6 Merge "Add SafetyNet logging if a certain broadcast is received by apps." into qt-dev 2021-08-11 02:51:07 +00:00
Sudheer Shanka
df8ca125d6 Merge "Send targeted broadcasts to prevent other apps from receiving them." into pi-dev 2021-08-11 02:29:11 +00:00
Sudheer Shanka
0925f07c25 Merge "Send targeted broadcasts to prevent other apps from receiving them." into qt-dev 2021-08-11 02:27:05 +00:00
Sudheer Shanka
ad79043436 Add SafetyNet logging if a certain broadcast is received by apps.
In case the broadcast intents "com.android.server.net.action.SNOOZE_WARNING"
or "com.android.server.net.action.SNOOZE_RAPID" are dispatched to apps,
then add a SafetyNet log.

Bug: 177931370
Test: manual
Change-Id: I65b2e96ff1230b2051dd1e5bd9c21e5ba3e1146a
Merged-In: I65b2e96ff1230b2051dd1e5bd9c21e5ba3e1146a
(cherry picked from commit a22e341ac2)
2021-07-15 18:04:32 +00:00
Sudheer Shanka
452a5aeec5 Add SafetyNet logging if a certain broadcast is received by apps.
In case the broadcast intents "com.android.server.net.action.SNOOZE_WARNING"
or "com.android.server.net.action.SNOOZE_RAPID" are dispatched to apps,
then add a SafetyNet log.

Bug: 177931370
Test: manual
Change-Id: I65b2e96ff1230b2051dd1e5bd9c21e5ba3e1146a
Merged-In: I65b2e96ff1230b2051dd1e5bd9c21e5ba3e1146a
(cherry picked from commit a22e341ac2)
2021-07-15 18:04:10 +00:00
Bernardo Rufino
22500563c1 Merge "Fix background bypass via notifications" into qt-dev 2021-06-30 07:18:28 +00:00
Dmitry Dementyev
1d8503c538 Merge "Change ownership of the account request notification." into oc-mr1-dev am: aaccd1b152 am: c9fdb5f38e
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15016192

Change-Id: I9958960adcd72f402c545763ff89b67fb0af66a1
2021-06-29 20:04:26 +00:00
Dmitry Dementyev
c9fdb5f38e Merge "Change ownership of the account request notification." into oc-mr1-dev am: aaccd1b152
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15016192

Change-Id: I6aca96a54021efb9d212dbb18490482b11f60f5e
2021-06-29 19:50:37 +00:00