Closed grote closed 1 year ago
13 SeedVault builds in 14, launches, but crashes on "Backup Now" with
E FATAL EXCEPTION: main
E Process: com.stevesoltys.seedvault, PID: 17278
E java.lang.RuntimeException: Unable to start service com.stevesoltys.seedvault.storage.StorageBackupService@a68e85d with Intent
{ cmp=com.stevesoltys.seedvault/.storage.StorageBackupService }: java.lang.SecurityException: Starting FGS with type dataSync c
allerApp=ProcessRecord{2d21933 17278:com.stevesoltys.seedvault/u0a121} targetSDK=34 requires permissions: all of the permission
s allOf=true [android.permission.FOREGROUND_SERVICE_DATA_SYNC]
E at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4839)
E at android.app.ActivityThread.-$$Nest$mhandleServiceArgs(Unknown Source:0)
E at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2289)
E at android.os.Handler.dispatchMessage(Handler.java:106)
E at android.os.Looper.loopOnce(Looper.java:205)
E at android.os.Looper.loop(Looper.java:294)
E at android.app.ActivityThread.main(ActivityThread.java:8177)
E at java.lang.reflect.Method.invoke(Native Method)
E at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
E at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
E Caused by: java.lang.SecurityException: Starting FGS with type dataSync callerApp=ProcessRecord{2d21933 17278:com.stevesoltys.s
eedvault/u0a121} targetSDK=34 requires permissions: all of the permissions allOf=true [android.permission.FOREGROUND_SERVICE_DA
TA_SYNC]
E at android.os.Parcel.createExceptionOrNull(Parcel.java:3057)
E at android.os.Parcel.createException(Parcel.java:3041)
E at android.os.Parcel.readException(Parcel.java:3024)
E at android.os.Parcel.readException(Parcel.java:2966)
E at android.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManager.java:6761)
E at android.app.Service.startForeground(Service.java:775)
E at org.calyxos.backup.storage.backup.BackupService.onStartCommand(BackupService.kt:31)
E at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4821)
E ... 9 more
E Caused by: android.os.RemoteException: Remote stack trace:
E at com.android.server.am.ActiveServices.validateForegroundServiceType(ActiveServices.java:2611)
E at com.android.server.am.ActiveServices.setServiceForegroundInnerLocked(ActiveServices.java:2322)
E at com.android.server.am.ActiveServices.setServiceForegroundLocked(ActiveServices.java:1679)
E at com.android.server.am.ActivityManagerService.setServiceForeground(ActivityManagerService.java:13265)
E at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:3385)
Identify all upgraded libraries and find matching versions for the non-AOSP buildsystem, bumping their versions as needed.
Barely any changes. It'll actually be a good thing, to support Android 13 at the same time. Long term, I'd like to use AOSP libs as little as possible anyways, because going an year without an update is bad.
Doing the port in two steps
Long term, I'd like to use AOSP libs as little as possible anyways, because going an year without an update is bad.
How would we do this? AFAIK we need to build inside AOSP, right? So bundle all dependencies?
How would we do this? AFAIK we need to build inside AOSP, right? So bundle all dependencies?
Yes. Using https://github.com/lineage-next/gradle-generatebp
We don't have to do them all right now, but we can start with anything that's really old / needs upgrading due to some reason or the other.
First findings from going through commit messages:
BackupAndRestoreFeatureFlags
for setting custom timeouts via server syncs.
Maybe they noticed that the 5min sync was sometimes too short?
adb shell device_config put backup_and_restore backup_transport_callback_timeout_millis 1
https://gitlab.com/CalyxOS/platform_frameworks_base/-/commit/a7de6bf8bf195d300871dcd45d503240de32ba35backuplib
related feature confirmed cancelled: https://gitlab.com/CalyxOS/platform_frameworks_base/-/commit/b6faae9f7d1a9af3a4c548c5e01f72a53d1404ea
BackupAndRestoreFeatureFlags
for setting custom timeouts via server syncs. Maybe they noticed that the 5min sync was sometimes too short?adb shell device_config put backup_and_restore backup_transport_callback_timeout_millis 1
We can control this using https://github.com/CalyxOS/vendor_calyx/blob/android13/overlay/common/packages/apps/SimpleDeviceConfig/res/values/config.xml which uses on
More findings from going through commit messages:
BackupAgent
s via the BackupMonitor
https://gitlab.com/CalyxOS/platform_frameworks_base/-/commit/104604674f01be4cf4b9d35d38ed14bd1046e987OperationType
(used for d2d) is now BackupDestination
https://gitlab.com/CalyxOS/platform_frameworks_base/-/commit/0828847a7e690520c9e02675e1e6f2cd5bf92e09FeatureFlagUtils.SETTINGS_USE_NEW_BACKUP_ELIGIBILITY_RULES
the system may ask the backup transport for which BackupDestination
type it uses. This may make OS patches superfluous.CompatChanges.isChangeEnabled(IGNORE_ALLOW_BACKUP_IN_D2D)
which is probably enabled by default nowWe can now disable framework scheduling of backups :tada:
IBackupManager#setFrameworkSchedulingEnabledForUser()
We have currently have these use-cases lined up for this:
BackupDestination
without OS patchesDeviceConfig
for better performance:
https://gitlab.com/CalyxOS/platform_frameworks_base/-/commit/f859b257dc35342a95dea4d15d9ab2c7c887e188true
https://gitlab.com/CalyxOS/platform_frameworks_base/-/commit/cedd0bec7dceaf038d26fff91065f6b827dff11aBackupManagerMonitor
to the system for logging/debugging purposes
https://gitlab.com/CalyxOS/platform_frameworks_base/-/commit/c6215c0cf4bff479ca8d60aee8eca2c9df57f65b
https://gitlab.com/CalyxOS/platform_frameworks_base/-/commit/8c4d80519ba89297350d1a8498f023e7aa65c7eftl;dr nothing we need urgently react to before making a 14 release. The only thing we might want to check is the shorter timeouts, i.e. by doing a slow APK backup taking more than 5min.
The bad news is that we are affected by the timeouts. Our backup transport service gets destroyed and the backups fails.
Error during PM metadata backup
com.android.server.backup.keyvalue.TaskException
at com.android.server.backup.keyvalue.KeyValueBackupTask.handleTransportStatus(KeyValueBackupTask.java:1138)
at com.android.server.backup.keyvalue.KeyValueBackupTask.sendDataToTransport(KeyValueBackupTask.java:1072)
at com.android.server.backup.keyvalue.KeyValueBackupTask.sendDataToTransport(KeyValueBackupTask.java:577)
at com.android.server.backup.keyvalue.KeyValueBackupTask.backupPm(KeyValueBackupTask.java:682)
at com.android.server.backup.keyvalue.KeyValueBackupTask.run(KeyValueBackupTask.java:368)
However, our APK backup code (which I used for testing) keeps running and updates the notification which is bad.
There's two places we hook in to back up APKs:
1) When finishBackup()
gets called for @pm@
backup to back up APKs of apps that don't allow backup
2) When getBackupQuota()
gets called for apps that do allow backup
The second one is less likely to run into timeouts, but the first one is uploading potentially many large APKs to a slow network storage which may take longer than the timeout we have. Making a @pm@
backup fail let's the system react harshly usually asking for a full re-init of the backup location. So that's also not good.
As a temporary measure, we could increase both DeviceConfig
timeouts on a ROM level to a safer default:
device_config put backup_and_restore backup_transport_future_timeout_millis 900000
device_config put backup_and_restore backup_transport_callback_timeout_millis 900000
A long-term solution could be to move to our own backup scheduling and do APK backups as part of it, so we don't need to hack into places that are not mean to be hacked into. This would also help with the fact that our hacked in code in finishBackup()
survives destruction of the backup transport service.
As a temporary measure, we could increase both DeviceConfig timeouts on a ROM level to a safer default:
https://review.calyxos.org/c/CalyxOS/vendor_calyx/+/22132 overlay: SimpleDeviceConfig: Adjust values for SeedVault Backup usage
Related to https://github.com/seedvault-app/seedvault/issues/433