2866 Commits

Author SHA1 Message Date
Kweku Adams
4ca74041be Increase RESTRICTED timeout to 45 days.
Increase timeout to 45 days based on feedback.

Bug: 183103253
Test: atest AppStandbyControllerTests
Change-Id: I7a36c720dbf16c16940308576a3965384889e527
2021-05-10 10:42:11 -07:00
Anton Hansson
fd6c615054 Fix appsearch filegroups to match package
The "java" directory in appsearch contains both a package structure and
subdirectories that include a package structure. Update the build
structure to match that.

This is part of a chunk of work necessary to avoidi unintentional
classes being included in the public documentation.

Bug: 187386774
Test: diff docs with/without package filter applied
Change-Id: I312d5cef014557b02d5c015899944ffdea8ca168
2021-05-10 12:23:40 +01:00
Lorenzo Colitti
fd653deee6 Merge "Rename unwanted capabilities to forbidden capabilities." into sc-dev 2021-05-09 16:12:56 +00:00
Jing Ji
d5c7dc045b Merge "Kill process if it's cached & idle and in forced-app-standby mode" into sc-dev 2021-05-09 00:23:05 +00:00
Makoto Onuki
306ed287f4 Send a broadcast when an app is granted SCHEDULE_EXACT_ALARM
Bug: 187206399
Test: atest AlarmManagerServiceTest
Test: Manual test with a test app.
- Grant the permission to test app and make sure it can start FGS.
Log:
```
05-07 10:12:08.671  1000  1579  9475 I ActivityManager: Background started FGS: Allowed [callingPackage: com.google.omakoto.testapp; callingUid: 10294; uidState: RCVR; intent: Intent { act=fgs cmp=com.google.omakoto.testapp/.MyFgs }; code:(unknown:207); tempAllowListReason:<broadcast:1000:android.app.action.SCHEDULE_EXACT_ALARM_PERMISSION_STATE_CHANGED,reason:,reasonCode:(unknown:207),duration:10000,callingUid:1000>; targetSdkVersion:30; callerTargetSdkVersion:30; startForegroundCount:0]
```
- Grant the permission to a different app and make sure the test app
  won't receive the broadcast.

Test: CTS -- Incoming

Change-Id: Iefe3e12dcf51318d8433532ba3048caa69b1edcd
2021-05-07 17:34:12 -07:00
Jing Ji
6cf25139a0 Kill process if it's cached & idle and in forced-app-standby mode
This behavior could be turned OFF via the flag kill_fas_cached_idle
in device_config.

Bug: 152573287
Test: atest FrameworksServicesTests:ActivityManagerTest
Test: atest FrameworksMockingServicesTests:AppStateTrackerTest
Change-Id: Ifa6950582fbf6a24595b36163810f3c7e9345394
2021-05-07 14:27:30 -07:00
Tim Barron
6e797a5de7 Merge "Call persistToDisk after indexing VisibilityDoc" into sc-dev 2021-05-07 21:25:29 +00:00
Tim Barron
b10fd7d064 Call persistToDisk after indexing VisibilityDoc
In ag/13985751 [e62a4eb007fc0266be6955c837d188a204c11cc2], we added calls to persist LITE after each mutation api
call. However, VisibilityStore also creates a mutation in Icing lib - it
indexes a single VisibilityDoc. We should also call persist LITE after
this so that we can be sure not to lose the VisibilityDoc.

Bug: 180127220
Test: None

Change-Id: Ib8465a3b2f4adb8f4dc4308c3845fcc501f36c0b
2021-05-07 21:24:56 +00:00
TreeHugger Robot
a14dbb2b72 Merge "MediaTranscodeManager: delay getService" into sc-dev 2021-05-07 17:52:59 +00:00
Lorenzo Colitti
c7bbe93a36 Rename unwanted capabilities to forbidden capabilities.
Addresses API council feedback.

Bug: 184890428
Test: atest FrameworksNetTests CtsNetTestCases
Test: atest CtsNetTestCasesLatestSdk:NetworkCapabilitiesTest on R device
Change-Id: Id7c68fbf56ee08fcad8e8e3aacf037fa1885936b
2021-05-08 01:48:01 +09:00
Kweku Adams
cefde1b88e Merge "Avoid using stale sessions for cleanup alarm." into sc-dev 2021-05-06 21:58:52 +00:00
Kweku Adams
061f335321 Avoid using stale sessions for cleanup alarm.
Remove old EJ timing sessions before we schedule the next cleanup alarm.
If we don't remove them, then we will continue to use stale sessions as
the basis for the next cleanup alarm, which would eventually result in
scheduling alarms in the past.

Bug: 187351354
Test: atest FrameworksMockingServicesTest:QuotaControllerTest
Change-Id: I1b968e0461efe9aad3e785760a3cd2f5d8d4de8b
2021-05-06 21:58:13 +00:00
Suprabh Shukla
9b8ab9c13a Add rtc fields to pushed alarm atoms
Test: statsd_testdrive 368 10106

Bug: 177556103
Change-Id: Iaf7f04370b73118723cd2fbb08fd18b43aa70d8d
2021-05-06 21:20:25 +00:00
Chong Zhang
5113027706 MediaTranscodeManager: delay getService
Remove getService from the constructor, delay
getting the service until it's used.

bug: 187425268
test: CTS MediaTranscodeManagerTest
Change-Id: I502bb428fcde96874a1af431af07413feea64d7a
2021-05-06 14:17:18 -07:00
TreeHugger Robot
a071ad396d Merge "Make sure RESTRICTED quota is properly counted." into sc-dev 2021-05-06 20:26:51 +00:00
TreeHugger Robot
8c62b2ba7c Merge "Rename OnProjectionStateChangeListener -> OnProjectionStateChangedListener" into sc-dev 2021-05-06 18:36:32 +00:00
Hui Yu
32bf836de3 Merge "Exempt some broadcasts from FGS start restriction." into sc-dev 2021-05-06 03:33:18 +00:00
Kurt Dresner
81f2994f35 Rename OnProjectionStateChangeListener -> OnProjectionStateChangedListener
Bug: 175130323
Test: Presubmits
Change-Id: Ica48cd073e256055d5cac0f12e9ce814227eb0d6
2021-05-05 15:27:31 -07:00
Hui Yu
0daa76ed40 Exempt some broadcasts from FGS start restriction.
1. Exempt broadcasts ACTION_TIMEZONE_CHANGED, ACTION_TIME_CHANGED, ACTION_LOCALE_CHANGED
from FGS start restriction.
2. Add test case AlarmManagerServiceTest#setTimeZoneImpl.

Bug: 184111171
Test: atest frameworks/base/services/tests/mockingservicestests/src/com/android/server/alarm/AlarmManagerServiceTest.java
Change-Id: I80ce830d1bd98d69f35fdc6bcc041de173083fba
2021-05-05 14:33:35 -07:00
Suprabh Shukla
f25a518355 Use BinderDeathDispatcher for alarm listeners
This ensures only one JNI strong reference for the death recipient when
the same binder is used for multiple linkToDeath calls.

Test: atest CtsAlarmManagerTestCases
atest FrameworksCoreTests:BinderDeathDispatcherTest
atest FrameworksMockingServicesTests:com.android.server.alarm

Fixes: 162961981
Bug: 182971683
Change-Id: Ieea2d8f4e495a4c4687378db9d0b8c6949a0406a
2021-05-05 20:04:07 +00:00
Kweku Adams
b76da7cb82 Make sure RESTRICTED quota is properly counted.
Make sure that quota is counted properly for RESTRICTED jobs when the
device is charging but not idle.

Also add some GuardedBy annotations and update some method names. It's
not exhaustive, but a start.

Bug: 141645789
Bug: 187189316
Test: atest frameworks/base/services/tests/mockingservicestests/src/com/android/server/job
Test: atest frameworks/base/services/tests/servicestests/src/com/android/server/job
Test: atest CtsJobSchedulerTestCases
Change-Id: I75fae5e3ae71435367db7dd9fa2c14f5d1029a67
2021-05-05 11:39:40 -07:00
Kweku Adams
f587556611 Merge "Fix QuotaController dump." into sc-dev 2021-05-05 15:44:55 +00:00
Suprabh Shukla
a94c55f2f4 Merge changes Ia8c656a0,I01f98255 into sc-dev
* changes:
  Change device-idle alarm fuzzing
  Hold wakeup alarms for as long as possible
2021-05-05 02:45:38 +00:00
Suprabh Shukla
faa2caf0ee Change device-idle alarm fuzzing
- Removing fuzz in the absence of an alarm clock alarm.
- Adding a minimum duration that the alarm should be fuzzed before an
alarm clock - currently 2 minutes.
- The maximum fuzz is now a linear function of futurity of the alarm
with the maximum capped at 15 minutes.
- If the futurity is less than the minimum fuzz, the alarm goes off
immediately, bringing the device out of idle.

Also, fixing a bug with re-evaluating alarm deliverability in doze and
battery saver.

Test: atest FrameworksMockingServicesTests:com.android.server.alarm

Bug: 170279979
Bug: 166693547
Change-Id: Ia8c656a0336cc0b72f0b3901de96d4aa440186d4
2021-05-04 19:37:40 -07:00
Suprabh Shukla
74b85211fa Hold wakeup alarms for as long as possible
If the screen is off, but the CPU is awake and epoll_wait returns for a
non-wakeup alarm, sending any wakeup alarm within its eligibility window
would cause all the held non-wakeup alarms to also fire, which could:
1. Elongate the length of the time the CPU is awake.
2. Cause apps to wake up and perform work.

This change defers sending any wakeup alarm as long as it is possible to
defer all such eligible alarms to later.

Also, fixed a bug in sorting after adding multiple alarms to the store.

Test: atest CtsAlarmManagerTestCases
atest FrameworksMockingServicesTests:com.android.server.alarm

Bug: 161497385
Change-Id: I01f98255091baddf4e7529f88733776e27d090d7
2021-05-04 19:37:40 -07:00
Kweku Adams
ed82890fa7 Fix QuotaController dump.
1. Remove extra space before "EJ" in the timer dump.
2. Actually print out the list of system installers. SparseSetArray
   doesn't have toString() implemented.

Bug: 141645789
Bug: 141495777
Test: adb shell dumpsys jobscheduler
Change-Id: Ia6e88b0b1177dc585fcca4a29d658b5a9370b60b
2021-05-04 17:32:08 -07:00
Kweku Adams
0ec65b00b6 Merge "Fix EJ syncs." into sc-dev 2021-05-04 23:05:21 +00:00
Kweku Adams
d23ce9610b Fix EJ syncs.
1. Only downgrade an EJ that doesn't have the IGNORE_BACKOFF extra when
   we are actually attempting to back off the job.
2. Allow EJs to have the FLAG_EXEMPT_FROM_APP_STANDBY flag since that
   can only be set by the system and won't cause issues.

Also propagate the scheduleEjAsRegularJob bit through the job extras to
help with debugging.

Bug: 178852366
Test: atest ContentResolverTest (all)
Test: atest CtsJobSchedulerTestCases:JobInfoTest
Test: atest CtsSyncManagerTest
Test: atest SyncOperationTest
Test: atest SyncManagerTest
Test: atest SyncRequestTest
Change-Id: I133d089a4d770a3cc37df72f8b38d234b24077df
2021-05-04 14:37:02 -07:00
Alexander Dorokhine
2ee7641af7 Refactor how AppSearchResult and AppSearchBatchResult are parcelled.
Mainline modules seem to be metalava'd differently, causing the CREATOR,
describeContents(), and other parcelling methods to become part of the
public API.

Additionally, AppSearchResult and AppSearchBatchResult were forked from
Jetpack with parcelling added, and manually maintained.

Additionally, the parcelling wouldn't work properly if the keys and
values are not themselves parcelable, but this was not clearly
documented or called out.

This CL fixes these problems by creating parcelable wrappers around the
upstream Jetpack AppSearchResult and AppSearchBatchResult, usable only
when they contain parcelable keys and values.

Bug: 146218515
Test: Presubmit
Change-Id: I828a22dc6dae3e46f5d167f1a9d12627ba15d9fd
2021-05-04 13:24:47 -07:00
Alexander Dorokhine
b10c5162c4 Temporarily re-add methods and classes removed in ag/1420175.
The methods and classes are hidden and marked with @UnsupportedAppUsage.
This fixes broken dogfooders while the new SDK is being propagated.

Bug: 181887768
Test: Jetpack unit tests against old SDK
Change-Id: Ibc8aaed6ffa751b75bf5b23e04547eba2a4cda86
2021-04-30 19:05:16 -07:00
Kweku Adams
9c3d74f7e0 Merge "Expand JS documentation." into sc-dev 2021-04-30 16:10:42 +00:00
Hui Yu
e37fdc9e8a Merge "Do not allow FGS start when temp allowlist reasonCode is REASON_PUSH_MESSAGING_OVER_QUOTA" into sc-dev 2021-04-30 06:26:39 +00:00
Alexander Dorokhine
9e85c65e03 Merge "Update Framework from Jetpack." into sc-dev 2021-04-30 01:07:39 +00:00
Alexander Dorokhine
45bb21c98d Update Framework from Jetpack.
Included changes:
* 4c1b251: Sync AppSearch with google3 update ag/14342999 (8f8b43)
* cdf1913: Add a GenericDocument#toBuilder API.
* 64f80f3: Improve snippeting and matching per API feedback.
* 23dd35c: Move AppSearchEmail out of the prod tree into the test utils.

Bug: 171882200
Bug: 186520196
Bug: 186717514
Test: Presubmit
Change-Id: I9d8e1fb87e6e74c57a38f3a27cdd04a1a3ccf90b
2021-04-29 18:00:32 -07:00
Hui Yu
a6b92260d3 Do not allow FGS start when temp allowlist reasonCode is REASON_PUSH_MESSAGING_OVER_QUOTA
If temp allowlist reasonCode is REASON_PUSH_MESSAGING_OVER_QUOTA, check
DeviceConfig key "push_messaging_over_quota_behavior" to decide if
temp allowlist and FGS start are allowed. Three options:
1. -1, temp allowlist not allowed, FGS start not allowed.
2. 0, temp allowlist allowed, FGS start allowed.
3. 1, temp allowlist allowed, FGS start not allowed. This is default.

The device config command to change the behavior:
adb shell device_config set activity_manager push_messaging_over_quota_behavior <-1|0|1>

If temp allowlist reasonCode is REASON_DENIED, do not allow temp allowlist
at all.

Also, in DeviceIdleController.addPowerSaveTempAllowlistAppInternal(),
there used to be a check if the callingUid is on the mPowerSaveWhitelistSystemAppIds list,
this is unnecessary because upstream callers already checked if callingUid has
 permission CHANGE_DEVICE_IDLE_TEMP_WHITELIST, and this permission is a privileged permission,
so removing the check of mPowerSaveWhitelistSystemAppIds should be safe.

Bug: 182796372
Test: atest cts/tests/app/src/android/app/cts/ActivityManagerFgsBgStartTest.java#testPushMessagingOverQuota
Test: atest cts/tests/app/src/android/app/cts/ActivityManagerFgsBgStartTest.java#testTempAllowListReasonCode

Change-Id: Id34b1c26c819dc4fe07838eb2e3a8f0138cbcf8f
2021-04-29 16:27:41 -07:00
TreeHugger Robot
ea1b5d878c Merge "Fixing empty PendingAlarmInfo after alarm store changes" into sc-dev 2021-04-29 21:51:18 +00:00
Alexander Dorokhine
1ddbd46377 Merge "Remove AndroidFuture from AppSearch." into sc-dev 2021-04-29 19:43:17 +00:00
Kweku Adams
fbab1fcc18 Expand JS documentation.
1. Make it clear that "minimum latency" != "run ASAP after latency"
2. Note that deadline constraints are dropped from rescheduled jobs
3. Clarify that jobFinished does not need to be called if onStopJob is called

Bug: 19536175
Test: Run `m offline-sdk-docs` and check site at out/target/common/docs/offline-sdk/reference/android/app/job/JobInfo.html
Change-Id: I051feb0ebfcb0a24c452a38b91a751bbeef581f8
2021-04-29 17:47:49 +00:00
Alexander Dorokhine
91568a6dfa Remove AndroidFuture from AppSearch.
It is a hidden API and cannot be used in mainline.

Bug: 181787682
Test: Presubmit
Change-Id: I74a1aafdad8dec110b19ecc61a0668ae380196e7
2021-04-28 23:10:42 -07:00
Kyunglyul Hyun
b82f38cf3e Merge "Clean up Session2Record in MCS" into sc-dev 2021-04-29 05:37:00 +00:00
TreeHugger Robot
f941b5a2f4 Merge "Recording alarm removal reasons for debugging" into sc-dev 2021-04-29 01:14:40 +00:00
Suprabh Shukla
d77b127e37 Fixing empty PendingAlarmInfo after alarm store changes
The alarm store implementation might change, leaving the pointer passed
to MetricsHelper with an empty instance.

Also reordered some code to reduce unnecessary locking.

Test: Manually, run:
adb shell device_config put alarm_manager lazy_batching false
Then:
./out/host/linux-x86/bin/statsd_testdrive 10106
should show non-zero values.

Bug: 177556103
Change-Id: I55b4318d14632f227adfd79f7a08bb50af98f03a
2021-04-28 14:59:11 -07:00
Suprabh Shukla
a8e003f538 Recording alarm removal reasons for debugging
If an alarm is removed from the service for some reason, the bugreport
contains no useful information about it. Recording the last 10 removes
with their reason. For now, the set of reasons includes:
 - Data cleared on the calling app.
 - App requested to cancel it.
 - Exact alarm permission revoked.
 - PendingIntent used to set the alarm was cancelled.
More reasons can be added as seen useful in the future.

Test: adb shell dumpsys alarm
atest FrameworksMockingServicesTests:com.android.server.alarm
atest CtsAlarmManagerTestCases

Fixes: 184677899
Change-Id: I9d67b90572b5d731ad5d224ae7d537ae176508d5
2021-04-28 13:51:08 -07:00
Kweku Adams
c49760fc63 Merge "Updating proto enums." into sc-dev 2021-04-28 16:09:35 +00:00
Kweku Adams
88cf226a2d Merge "Remove isForegroundJob." into sc-dev 2021-04-28 16:08:38 +00:00
TreeHugger Robot
f1f615d992 Merge "Note that user engagement replenishes EJ quota." into sc-dev 2021-04-28 15:11:46 +00:00
Alexander Dorokhine
5d3d644cbc Merge "Update framework from jetpack." into sc-dev 2021-04-28 03:33:15 +00:00
Kyunglyul Hyun
ae983d49ab Clean up Session2Record in MCS
This CL cleans up how MediaCommunicationService
manages Session2Record instances.

It removes unnecessary codes and refactor locks.
It also adds/clean up tests for MCM.SessionCallback.

Bug: 183289655
Bug: 182907935
Test: atest MediaCommunicationManagerTest 10 times
Change-Id: Iff4643c7dc207ea14c752bdfb815598dc34f2368
2021-04-28 00:18:11 +00:00
Kweku Adams
b2fa0cabc1 Note that user engagement replenishes EJ quota.
Make sure developers are aware that user interaction will replenish EJ
quota so they are less concerned about running out of quota for valid
use cases.

Bug: 171305774
Test: N/A
Change-Id: Iec231522dbc7fe83c65956b59ca3e4fbda072b97
2021-04-27 17:10:55 -07:00
TreeHugger Robot
d1293fc9a7 Merge "Removing non-wakeup alarms on user-removed" into sc-dev 2021-04-27 22:44:28 +00:00