Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port to Android 14 #564

Closed
5 tasks done
grote opened this issue Sep 25, 2023 · 11 comments · Fixed by #581, #579, #576 or #574
Closed
5 tasks done

Port to Android 14 #564

grote opened this issue Sep 25, 2023 · 11 comments · Fixed by #581, #579, #576 or #574
Assignees

Comments

@grote
Copy link
Collaborator

grote commented Sep 25, 2023

  • Build Android and Java libraries from AOSP source code that include the hidden APIs required for Seedvault and add them to the (gradle) buildsystem
  • Identify all upgraded libraries and find matching versions for the non-AOSP buildsystem, bumping their versions as needed.
  • Upgrade other libraries and include jar binaries as needed.
  • Go through all backup related AOSP commits since last Android release and learn about changes, adapting Seedvault code as needed, especially for breaking changes preventing compilation.
  • Include all work in a new pull request creating a new android14 branch of Seedvault.

Related to #433

@grote grote self-assigned this Sep 25, 2023
@chirayudesai
Copy link
Member

chirayudesai commented Oct 6, 2023

  • targetSdk 34 - default with Android.bp

@chirayudesai
Copy link
Member

chirayudesai commented Oct 6, 2023

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)

@chirayudesai
Copy link
Member

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.

@chirayudesai
Copy link
Member

chirayudesai commented Oct 7, 2023

Doing the port in two steps

  1. Android.bp - it mostly seems to work, may just need minor changes. Easy to do as we work on it. Android 14 - Basic updates, Android.bp  #574
  2. gradle - looks like this will need a bit more work and testing. WiP Gradle updates to match AOSP 14 #576

@grote
Copy link
Collaborator Author

grote commented Oct 9, 2023

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?

@chirayudesai
Copy link
Member

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.

@grote
Copy link
Collaborator Author

grote commented Oct 9, 2023

First findings from going through commit messages:

@chirayudesai
Copy link
Member

  • 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

@grote
Copy link
Collaborator Author

grote commented Oct 10, 2023

More findings from going through commit messages:

tl;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.

@grote
Copy link
Collaborator Author

grote commented Oct 11, 2023

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.

@chirayudesai
Copy link
Member

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

calyxos-gerrit pushed a commit to CalyxOS/vendor_calyx that referenced this issue Oct 13, 2023
* https://android.googlesource.com/platform/frameworks/base/+/3f82689d2b59f1437479ccb3fb69e662a98ac2fb
  timeout reduced to 5min (from 10min) "our data shows this is a reasonable value."
* However, this affects us, our backup transport service gets destroyed and the backups fails.
* Android 13 had 600000, this is even a bit higher to make it less likely that users run into this problem.

Ref:
* seedvault-app/seedvault#564 (comment)
* seedvault-app/seedvault#583

Test: adb shell device_config list backup_and_restore
Change-Id: Iefe7d5f2ef53300e3368aa6e809b72dd0b0d1db5
@grote grote mentioned this issue Sep 5, 2024
5 tasks
lineageos-gerrit pushed a commit to LineageOS/android_vendor_lineage that referenced this issue Oct 18, 2024
* https://android.googlesource.com/platform/frameworks/base/+/3f82689d2b59f1437479ccb3fb69e662a98ac2fb
  timeout reduced to 5min (from 10min) "our data shows this is a reasonable value."
* However, this affects us, our backup transport service gets destroyed and the backups fails.
* Android 13 had 600000, this is even a bit higher to make it less likely that users run into this problem.

Ref:
* seedvault-app/seedvault#564 (comment)
* seedvault-app/seedvault#583

Test: adb shell device_config list backup_and_restore
Change-Id: Iefe7d5f2ef53300e3368aa6e809b72dd0b0d1db5
erfanoabdi pushed a commit to LMODroid/platform_vendor_lmodroid that referenced this issue Oct 21, 2024
* https://android.googlesource.com/platform/frameworks/base/+/3f82689d2b59f1437479ccb3fb69e662a98ac2fb
  timeout reduced to 5min (from 10min) "our data shows this is a reasonable value."
* However, this affects us, our backup transport service gets destroyed and the backups fails.
* Android 13 had 600000, this is even a bit higher to make it less likely that users run into this problem.

Ref:
* seedvault-app/seedvault#564 (comment)
* seedvault-app/seedvault#583

Test: adb shell device_config list backup_and_restore
Change-Id: Iefe7d5f2ef53300e3368aa6e809b72dd0b0d1db5
erfanoabdi pushed a commit to LMODroid/platform_vendor_lmodroid that referenced this issue Oct 21, 2024
* https://android.googlesource.com/platform/frameworks/base/+/3f82689d2b59f1437479ccb3fb69e662a98ac2fb
  timeout reduced to 5min (from 10min) "our data shows this is a reasonable value."
* However, this affects us, our backup transport service gets destroyed and the backups fails.
* Android 13 had 600000, this is even a bit higher to make it less likely that users run into this problem.

Ref:
* seedvault-app/seedvault#564 (comment)
* seedvault-app/seedvault#583

Test: adb shell device_config list backup_and_restore
Change-Id: Iefe7d5f2ef53300e3368aa6e809b72dd0b0d1db5
ArmSM pushed a commit to ProjectSakura/vendor_sakura that referenced this issue Oct 24, 2024
* https://android.googlesource.com/platform/frameworks/base/+/3f82689d2b59f1437479ccb3fb69e662a98ac2fb
  timeout reduced to 5min (from 10min) "our data shows this is a reasonable value."
* However, this affects us, our backup transport service gets destroyed and the backups fails.
* Android 13 had 600000, this is even a bit higher to make it less likely that users run into this problem.

Ref:
* seedvault-app/seedvault#564 (comment)
* seedvault-app/seedvault#583

Test: adb shell device_config list backup_and_restore
Change-Id: Iefe7d5f2ef53300e3368aa6e809b72dd0b0d1db5
NRanjan-17 pushed a commit to DroidX-UI/vendor_droidx that referenced this issue Oct 26, 2024
* https://android.googlesource.com/platform/frameworks/base/+/3f82689d2b59f1437479ccb3fb69e662a98ac2fb
  timeout reduced to 5min (from 10min) "our data shows this is a reasonable value."
* However, this affects us, our backup transport service gets destroyed and the backups fails.
* Android 13 had 600000, this is even a bit higher to make it less likely that users run into this problem.

Ref:
* seedvault-app/seedvault#564 (comment)
* seedvault-app/seedvault#583

Test: adb shell device_config list backup_and_restore
Change-Id: Iefe7d5f2ef53300e3368aa6e809b72dd0b0d1db5
Signed-off-by: NRanjan-17 <[email protected]>
elpaablo pushed a commit to AlphaDroid-Project/vendor_lineage that referenced this issue Nov 9, 2024
* https://android.googlesource.com/platform/frameworks/base/+/3f82689d2b59f1437479ccb3fb69e662a98ac2fb
  timeout reduced to 5min (from 10min) "our data shows this is a reasonable value."
* However, this affects us, our backup transport service gets destroyed and the backups fails.
* Android 13 had 600000, this is even a bit higher to make it less likely that users run into this problem.

Ref:
* seedvault-app/seedvault#564 (comment)
* seedvault-app/seedvault#583

Test: adb shell device_config list backup_and_restore
Change-Id: Iefe7d5f2ef53300e3368aa6e809b72dd0b0d1db5
elpaablo pushed a commit to AlphaDroid-Project/vendor_lineage that referenced this issue Nov 9, 2024
* https://android.googlesource.com/platform/frameworks/base/+/3f82689d2b59f1437479ccb3fb69e662a98ac2fb
  timeout reduced to 5min (from 10min) "our data shows this is a reasonable value."
* However, this affects us, our backup transport service gets destroyed and the backups fails.
* Android 13 had 600000, this is even a bit higher to make it less likely that users run into this problem.

Ref:
* seedvault-app/seedvault#564 (comment)
* seedvault-app/seedvault#583

Test: adb shell device_config list backup_and_restore
Change-Id: Iefe7d5f2ef53300e3368aa6e809b72dd0b0d1db5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment