This repository has been archived by the owner on Apr 12, 2023. It is now read-only.
Move WorkManager initialization to Application#onCreate #283
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue 番号 / Issue ID
目的 / Purpose
#136 (comment) より。
Android版の接触確認API(Google Play Services)は、システムが接触確認アプリを停止してバックグランド処理が実行されない場合に備えて「Force-stop Handling」を備えている。
Google Play Servicesは、Force-stop Handlingで6時間に1回の頻度でアプリのプロセスを再度起動して、WorkManagerのJobを復帰する。
ところが、一部の端末(some popular devices)では、Force-stopされたかを判定する処理でSecurityExceptionが発生するため、Force-stop Handlingが完了せず、Jobの復帰が行われない可能性がある。
androidx/androidx@9b77063#diff-7794a8af74a01c5c6d2ee10558482274048bd3aa011aaca99459c2c5049fd7dd
問題に対応するためWorkManagerにWorkerを登録する一連の処理を、現在の
App.xaml.cs
からAndroidのApplication#onCreate
に移動することで、Force-stop HandlingでApplicationプロセスが起動されたタイミングでWorkerを再セットするように変更する。破壊的変更をもたらしますか / Does this introduce a breaking change?
Pull Request の種類 / Pull Request type
検証方法 / How to test
コードの入手 / Get the code
コードの検証 / Test the code
確認事項 / What to check
Debug
でビルドする(Exposure Notificationアプリとしてシステムに登録する必要があるため)timestamp
.txt が作成されていることを確認する(MainApplicationが起動する度に、起動時刻のファイルが作成される)adb shell dumpsys jobscheduler
で、Job SchedulerにCOCOAのJob(Worker)が登録されていることを確認する( jobscheduler-202107152120.txt )adb shell am force-stop [COCOAのパッケージ名]
で、COCOAを停止するadb shell dumpsys jobscheduler
で、Job SchedulerにCOCOAのJob(Worker)が消えていることを確認する( jobscheduler-202107152121-forcestopped.txt )timestamp
.txt が作成されていることを確認する(Force-stop handlingでCOCOAのアプリケーションプロセスが再起動されたことを確認する)( Screen Shot 2021-07-16 at 10.06.20.png )adb shell dumpsys jobscheduler
で、Job SchedulerにCOCOAのJob(Worker)が(ふたたび)登録されていることを確認する( jobscheduler-202107161006-forcestophandling.txt )
iOS側のコードレビュー注意
ExposureNotificationの初期化処理を
App
からAndroidおよびiOSのコードに移動させたため、iOS側にも影響がある。アプリ起動時に
ExposureNotification.ios.cs
のPlatformScheduleFetch
が呼ばれることは確認しているが、念のためチェックが必要と考えます。チェックしました。
起動時に
PlatformScheduleFetch
が呼ばれていることと、約4時間ごとにバックグラウンド処理が実行されることを確認しています(ios_log-init_work_application_oncreate.txt )。
その他 / Other information
特になし。