Commit Graph

10743 Commits

Author SHA1 Message Date
Felipe Leme
36e74d4db8 Initial implementation of UserManager.isUserVisible().
This API will be used to determine if the user is interacting with
the device and hence is able to do stuff like launching activities.

This initial version only returns true for the current foreground
user, but it will be expanded to also return true for:

- Background users associated with secondary displays
- (Running) profile of other visible users

Test: atest CtsMultiUserTestCases:android.multiuser.cts.UserManagerTest#testIsUserVisible_currentUser
Test: manual verification with Automotive's KitchenSink
Test: m update-api
Bug: 239824814

Change-Id: Ie8da07f69898d2b376bcf60d1da4221aed03ee3b
2022-08-09 02:42:37 +00:00
TreeHugger Robot
646dd4f125 Merge "Added UserManager.isUsersOnSecondaryDisplaysSupported()" 2022-08-08 21:54:32 +00:00
Felipe Leme
0fc2d3299a Added UserManager.isUsersOnSecondaryDisplaysSupported()
By default it reads the value from
config_multiuserUsersOnSecondaryDisplays
overridden by the system property for development purposes.

Test: adb shell setprop fw.users_on_secondary_displays true && \
      adb shell dumpsys user | grep -i "secondary display"

Fixes: 240613396

Change-Id: I1428a117a683e99fcaef71492be297c844d520e2
2022-08-08 09:14:08 -07:00
Hani Kazmi
a0d9fc3b28 BaseBundle.java:: Clear underlying parcel when no longer referernced.
Follow up to ag/18795008.
Lazy Bundles, (aosp/1787847), introduced a change in behavior where a Parcel
created as part of initializing a Bundle is dependent on the next ART GCrun to be
recycled, causing a short term memory-leak. We previously force recycled
the parcel when bundle.clear() was called.

This commit takes it a step further and adds  reference counting for the number of
lazy values in mMap. When this reaches 0, we can safely eager recycle the
underlying parcel.

This still does not work when parcel references have been shared outside
the owning bundle (i.e, when mOwnsLazyValues is false.) We have two
options here:

1. Allow the GC to eventually claim the parcel (current behaviour).
2. Track lazy values refs globally across bundles. High complexity cost,
   and likely high performance impact.

We can not unmwrap the lazy values before copying, in case the
originating classloader can not instantiate the given class type. See
go/lazy-bundle

In initializeFromParcelLocked(), renamed boolean parameter recycleParcel to ownsParcel since the method no longer recycles in all cases. Also, only create lazy values if ownsParcel = true so that we don't have lazy values referencing the passed in parcel in case the caller doesn't own the parcel (which means the parcel could be recycled out of our control).

Bug: 233216232
Test: Reproduced linked bug on-device
Test: atest android.os.cts.ParcelTest android.os.cts.BundleTest
android.os.BundleTest android.os.ParcelTest android.os.BundleRecylingTest

Change-Id: I8a878a6d0055b04b2611909b4b17977ba5677a4f
2022-08-05 12:25:39 +00:00
Steven Moreland
67c02504a9 Merge "Reword ambiguous documentation in Parcel" am: c2bd9f481f am: 231c243d45 am: 4783db4155 am: 487f6885e5 am: a64ec98da3
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2171073

Change-Id: Iaca7afc901e4325e66de172df5b59f64f9b161ad
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-08-02 22:26:39 +00:00
Steven Moreland
a64ec98da3 Merge "Reword ambiguous documentation in Parcel" am: c2bd9f481f am: 231c243d45 am: 4783db4155 am: 487f6885e5
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2171073

Change-Id: I70350af88cba7c17ac010b0eaa89169f42a000cd
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-08-02 21:26:55 +00:00
Steven Moreland
4783db4155 Merge "Reword ambiguous documentation in Parcel" am: c2bd9f481f am: 231c243d45
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2171073

Change-Id: I1a75c9e770366cd12c11358a89bda0d594f2e9d0
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-08-02 20:56:38 +00:00
Steven Moreland
231c243d45 Merge "Reword ambiguous documentation in Parcel" am: c2bd9f481f
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2171073

Change-Id: I645b073414031d43a90b097fc9454476b77ec0c3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-08-02 20:39:26 +00:00
TreeHugger Robot
a7d85cabf3 Merge "Support test skipping when power save modes aren't enabled." 2022-08-02 20:20:14 +00:00
Kweku Adams
ba3b5d7e53 Support test skipping when power save modes aren't enabled.
Some classes of devices will not have auto power save modes enabled. On
those devices, we should skip tests that require the modes be enabled.

Bug: 240108412
Bug: 240630396
Test: Manually go through CTS-V "Ignore Battery Optimizations Test"
Test: atest CtsUsageStatsTestCases:UsageStatsTest
Change-Id: Icc64fbe75213386a1f41fae258e50c4032920b0a
2022-08-02 14:57:16 +00:00
danielzhang130
c63f3f259c Reword ambiguous documentation in Parcel
- original documentation for Parcel.unmarshall could be understood
  both ways: Parcel written with bytes of data, data written with
  bytes of Parcel

Test: Not applicable
Signed-off-by: danielzhang130 <danielzhang130@gmail.com>
Change-Id: I9afd3ae66ca03f391b272ac0524593395ffe53fa
2022-08-01 23:47:47 +00:00
Matt Gilbride
bf5d6f3e9c Merge "@EnforcePermission migrations - services.core" 2022-07-27 15:46:03 +00:00
Guojing Yuan
6707d97eae Merge "Remove OutcomeReceiver.noResult NonNull annotation" 2022-07-25 16:57:36 +00:00
TreeHugger Robot
31d259d371 Merge "Remove BatteryStats parcelability and some unused code" 2022-07-21 20:53:12 +00:00
Guojing Yuan
5fb0d9aa51 Remove OutcomeReceiver.noResult NonNull annotation
Bug: 239455439

Test: make
Change-Id: I3b783a01f6decd646223af884da4b066d9e087fd
2022-07-21 19:50:34 +00:00
Dmitri Plotnikov
d9fd8fc27b Remove BatteryStats parcelability and some unused code
Bug: 235635119
Test: presubmit
Change-Id: I9fa4b27e2e5e3679924c64a3747f9e6e560df465
2022-07-20 17:19:31 -07:00
Victor Chang
2bb34d954c Merge "Deprecate Debug.enableEmulatorTraceOutput()" am: 3f007c4dea am: b0bbe9b5f3 am: fd818a3610 am: 27f8e8943b am: d3fb6ef1a4
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2154934

Change-Id: I5506aeea08ce347d6201dc22fd9a3bfa86a17867
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-20 11:56:26 +00:00
Victor Chang
d3fb6ef1a4 Merge "Deprecate Debug.enableEmulatorTraceOutput()" am: 3f007c4dea am: b0bbe9b5f3 am: fd818a3610 am: 27f8e8943b
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2154934

Change-Id: Ie3ce9234b41dc9b32a2f97a70298f6cf6dd8e744
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-20 11:39:04 +00:00
Victor Chang
fd818a3610 Merge "Deprecate Debug.enableEmulatorTraceOutput()" am: 3f007c4dea am: b0bbe9b5f3
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2154934

Change-Id: I73022c7c3840483af31390c297ded5d904de51fa
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-20 10:41:35 +00:00
Victor Chang
b0bbe9b5f3 Merge "Deprecate Debug.enableEmulatorTraceOutput()" am: 3f007c4dea
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2154934

Change-Id: I254df58123db32e542a75176544313776c55d20b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-20 10:23:51 +00:00
Victor Chang
3f007c4dea Merge "Deprecate Debug.enableEmulatorTraceOutput()" 2022-07-20 09:57:40 +00:00
mattgilbride
95c4dc01cd @EnforcePermission migrations - services.core
Immediate calls to Context.enforceCallingOrSelfPermission.  Fixes
applied by Android Lint (cl/18432857).

Bug: 232058525
Test: Existing tests still pass
Change-Id: I4c3c70241ac18d1435af4b13c1b7da90f0b8bb70
2022-07-18 15:13:42 +00:00
Victor Chang
6ec9edf868 Deprecate Debug.enableEmulatorTraceOutput()
The API has been no-op for 2 releases.
https://r.android.com/1352354

We should officially deprecate the API.

Bug: 238895989
Test: atest CtsOsTestCases:android.os.cts.DebugTest
Change-Id: Ib1454b200a0ae0da557de02c49c482145deb97df
2022-07-15 11:38:38 +01:00
TreeHugger Robot
572e04448b Merge "Add tiltToWake to wake reasons and frameworks log. Bug: 118177017 Test: manual" 2022-07-14 19:06:59 +00:00
Hongguang Chen
63baeffded Merge "Use elapsed real time for sleep duration for the wake up with home intent" 2022-07-13 15:31:27 +00:00
mattgilbride
53f1bcf670 @EnforcePermission migrations - services.core
Immediate calls to helper methods that themselves call
Context.enforceCallingOrSelfPermission.
Fixes applied by Android Lint (cl/18432857).

Bug: 232058525
Test: N/A
Change-Id: I2b233caac7ee6db04f674f0143c79973847336c2
2022-07-11 20:22:03 +00:00
Neil Fuller
33e893f9b0 Merge "Move network time logic out of AlarmManagerService" 2022-07-08 08:27:04 +00:00
Neil Fuller
83ad73ecdc Move network time logic out of AlarmManagerService
Move network time logic out of AlarmManagerService in preparation for
a future refactoring. The TimeDetectorService is now a better home for
functionality associated with time signals, as it should receive most
time signals from various sources so it can determine whether the
device's system clock needs to change.

Although the TimeDetectorService is not currently informed every time
the NtpTrustedTime obtains a new time, it should be in future after
further work in later commits.

This change modifies the logic in SystemClock to match the GNSS time
logic in the same class, i.e. rather than calculating the "current time"
in the system server and then sending it over binder (introducing a
delay), the latest information needed to compute the time is sent to the
client, which then calculates the current time.

Bug: 219693030
Bug: 222295093
Test: atest services/tests/servicestests/src/com/android/server/timedetector/TimeDetectorServiceTest.java
Test: atest cts/tests/tests/os/src/android/os/cts/SystemClockSntpTest.java
Test: Treehugger
Change-Id: I80ea52877352122b52ac54daed8b092f3cc18e02
2022-07-07 13:11:21 +01:00
Steven Moreland
6c700dd35a Merge "Binder: clearCallingIdentity is kernel binder" am: bc67752894 am: eddf8c7625 am: 4b295a3e22 am: e43b9a5748
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2147360

Change-Id: I32d921041e0109f90e5b0627a11e8c1bd9c812b7
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-07 01:20:32 +00:00
Steven Moreland
4b295a3e22 Merge "Binder: clearCallingIdentity is kernel binder" am: bc67752894 am: eddf8c7625
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2147360

Change-Id: I331269726340c8d83d4486123743bdace740ddd3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-07 00:46:43 +00:00
Steven Moreland
eddf8c7625 Merge "Binder: clearCallingIdentity is kernel binder" am: bc67752894
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2147360

Change-Id: Ic6643d23d94fe5673243c46663a3ac7a42235734
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-07 00:26:42 +00:00
Steven Moreland
5d7100a43b Binder: clearCallingIdentity is kernel binder
This method clears the calling identity of a kernel
binder call. However, there is now a generic API to
disallow the use of kernel binder calling identities.
This is used by RPC binder calls in order to ensure
that code doesn't accidentally assume the default
(<pid>, <uid>) calling identity means that the call
originated from another process.

In the C++ layer, this API is attached to
IPCThreadState. In the future, we could consider
expanding the scope of this API to code and restore
many types of calling IDs, but the current return
type may not have enough space, and I want to
push people away from thread locals (globals)
for now.

Bug: 237245600
Test: N/A
Change-Id: I6e293814769cbd3c41e72afd95385af31ceb099f
2022-07-06 21:48:46 +00:00
Hani Kazmi
6bda874dc9 Merge "Parcel.java: Fix bug where non-nested creators threw NullPointer" am: 97211945a8 am: 715e417609 am: d74c99a05f am: 5005c4a93d am: 48e0ac1311
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2139755

Change-Id: I933d9734bbd5d30f8cca9ff5c8d38d2a940b72f9
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-05 12:19:50 +00:00
Hani Kazmi
48e0ac1311 Merge "Parcel.java: Fix bug where non-nested creators threw NullPointer" am: 97211945a8 am: 715e417609 am: d74c99a05f am: 5005c4a93d
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2139755

Change-Id: I92798cf63fdff3ea5163137740286a2e1b66ad2b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-05 12:18:03 +00:00
Hani Kazmi
d74c99a05f Merge "Parcel.java: Fix bug where non-nested creators threw NullPointer" am: 97211945a8 am: 715e417609
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2139755

Change-Id: I5b2d68cebbff65183c9c854d43bd1da817fe8eea
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-05 11:36:59 +00:00
Hani Kazmi
715e417609 Merge "Parcel.java: Fix bug where non-nested creators threw NullPointer" am: 97211945a8
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2139755

Change-Id: I0c74786d36b73d8c7812750dac5b6af55fb96ff9
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-05 11:11:31 +00:00
Hani Kazmi
4f221e5c51 Migrate Bundle/Intent APIs to new, type checked, variants
Part of go/safer-parcel. Follow up to ag/16639043. Migrates the following unsafe APIs:

* Parcel.readArray()
* Parcel.readParcelableArray()
* Bundle.getSerializable()
* Bundle.getParcelable()
* Bundle.getParcelableArrayList()
* Bundle.getParcelableArray()
* Bundle.getSparseParcelableArray()
* Intent.getSerializableExtra()
* Intent.getParcelableExtra()
* Intent.getParcelableArrayExtra()
* Intent.getParcelableArrayListExtra

Bug: 227458983
Test: m and presubmit pass
Change-Id: I72f206cb18eb5c669a7fff07a6845bed1c433fdb
2022-07-01 10:53:53 +00:00
Hani Kazmi
03c34f57c0 Parcel.java: Fix bug where non-nested creators threw NullPointer
Upon deserialization, various APIs would check that the passed in class
was assignable from the creator's enclosing class - which was assumed to
always be the Parcelable type.

This assumption is not always true, so updating the check to explicitely
store the parcelable type

Fix: 232589966
Test: m && atest ParcelTest && atest BundleTest
Change-Id: I59b650a854944e9020615a65798c5e54f5540aaa
2022-06-30 13:04:11 +00:00
Hani Kazmi
ace5dfd5d1 Merge "BaseBundle.java: Adding tests for 'Recycle underlying parcel for bundle'" into tm-dev am: 6b07af5e83 am: c388f2b9d0 am: ad4244ec44
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18929334

Change-Id: I6885f5c782117963028be3404ce49dbf0f8b8697
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-29 11:58:43 +00:00
Hani Kazmi
ad4244ec44 Merge "BaseBundle.java: Adding tests for 'Recycle underlying parcel for bundle'" into tm-dev am: 6b07af5e83 am: c388f2b9d0
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18929334

Change-Id: Iee33adbe2a5efcdad1b18bac03b2cae81ebda658
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-29 11:42:12 +00:00
Hani Kazmi
17656fbd3c Merge "BaseBundle.java: Adding tests for 'Recycle underlying parcel for bundle'" into tm-dev am: 6b07af5e83 am: aef01f7d13
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18929334

Change-Id: Ib40f12a259eba4563ee466c5b42504efa2d48cdc
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-29 11:41:34 +00:00
Hani Kazmi
bfa7ecc279 Merge "BaseBundle.java: Adding tests for 'Recycle underlying parcel for bundle'" into tm-dev am: 6b07af5e83
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18929334

Change-Id: I5f81f71ccdd368a37653e31399d435570870350f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-29 10:58:29 +00:00
Xin Li
14543d1ec7 Merge tm-dev-plus-aosp-without-vendor@8763363
Bug: 236760014
Merged-In: I5705ac7586cb73b7bc2bd60bb792d0a0a951ed74
Change-Id: I59a4fd917c95c8c9e258cd743cee2d950a46d9cd
2022-06-28 21:24:28 +00:00
Philip Junker
2e33f59217 Merge "Restrict device wakeup via PowerManager.ACQUIRE_CAUSES_WAKEUP." 2022-06-28 07:30:28 +00:00
Treehugger Robot
ce718c5622 Merge "Update VibrationAttributes javadocs for FLAG_BYPASS_INTERRUPTION_POLICY" am: c3560c6c68 am: fb98ab119d am: 1c88dd6b6d am: 27ea0bba2e am: 16f0c1c426
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2133773

Change-Id: I2a93b5f287081a814a235e071adeb5e61fdb37cc
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-27 20:15:06 +00:00
Treehugger Robot
16f0c1c426 Merge "Update VibrationAttributes javadocs for FLAG_BYPASS_INTERRUPTION_POLICY" am: c3560c6c68 am: fb98ab119d am: 1c88dd6b6d am: 27ea0bba2e
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2133773

Change-Id: I8839c903b24dcdf67fb6e1a526489980dad67e67
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-27 20:00:59 +00:00
Steven Moreland
6db478c840 Merge "Parcel: better debug recycle" 2022-06-24 21:53:32 +00:00
Steven Moreland
710f817286 Parcel: better debug recycle
Detect recycle called twice always (and when DEBUG_RECYCLE is on, we
detect recycle called twice or called zero times, and we show a stack).

Bug: 231799394
Test: manual (calling recycle twice)
Change-Id: I1dd9f392ee916edd9c598085a1c19dbdd3ce957f
Merged-In: I1dd9f392ee916edd9c598085a1c19dbdd3ce957f
2022-06-24 20:43:45 +00:00
Treehugger Robot
1c88dd6b6d Merge "Update VibrationAttributes javadocs for FLAG_BYPASS_INTERRUPTION_POLICY" am: c3560c6c68 am: fb98ab119d
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2133773

Change-Id: I46739270ddbd6d5b7354bfa4878be1fabad52835
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-24 19:35:42 +00:00
Hani Kazmi
621dc99968 BaseBundle.java: Adding tests for 'Recycle underlying parcel for bundle'
Follow up to ag/18795008. Adding tests for new behaviour.

As it is not possible to directly check on the bundle if the parcel has been recycled,
we inject a spy into it. Mocking static methods is not possible in
FrameworkCoreTests, so we introduce a new test class in
FrameworksMockingCoreTests which is run when any parcel or bundle source
file changes.

Bug: 233216232
Test: atest BundleRecyclingTest

Change-Id: If691b68a8db1f0110d131ec620935f566cc9367b
2022-06-24 12:07:29 +00:00