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

Update method on Android so that it perform factory reset before and after writing firmware files #524 #525

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1990,9 +1990,7 @@ class BDBleApiImpl private constructor(context: Context, features: Set<PolarBleS
}

doFactoryReset(identifier, true)
.andThen(Completable.timer(30, TimeUnit.SECONDS))
.andThen(waitDeviceSessionToOpen(identifier, factoryResetMaxWaitTimeSeconds, waitForDeviceDownSeconds = 10L))
.andThen(Completable.timer(5, TimeUnit.SECONDS))
.andThen(
Flowable.fromIterable(firmwareFiles)
.concatMap { firmwareFile ->
Expand All @@ -2013,18 +2011,22 @@ class BDBleApiImpl private constructor(context: Context, features: Set<PolarBleS
.concatMap { status ->
if (status is FirmwareUpdateStatus.FinalizingFwUpdate) {
BleLogger.d(TAG, "Starting finalization of firmware update")
Completable.timer(rebootTriggeredWaitTimeSeconds, TimeUnit.SECONDS)
.andThen(
waitDeviceSessionToOpen(identifier, factoryResetMaxWaitTimeSeconds, if (isDeviceSensor) 0L else 120L)
.andThen(
Completable.fromCallable {
BleLogger.d(TAG, "Restoring backup to device after version ${firmwareUpdateResponse.version}")
sendInitializationAndStartSyncNotifications(client)
backupManager.restoreBackup(backup).subscribe()
}
)
)
.andThen(Flowable.just(FirmwareUpdateStatus.FinalizingFwUpdate()))
BleLogger.d(TAG, "Waiting for device session to open after reboot")
waitDeviceSessionToOpen(identifier, factoryResetMaxWaitTimeSeconds, waitForDeviceDownSeconds = 10L)
.andThen(Completable.defer {
BleLogger.d(TAG, "Performing factory reset while preserving pairing information")
return@defer doFactoryReset(identifier, true)
})
.andThen(Completable.defer {
BleLogger.d(TAG, "Waiting for device session to open after factory reset")
return@defer waitDeviceSessionToOpen(identifier, factoryResetMaxWaitTimeSeconds, waitForDeviceDownSeconds = 10L)
})
.andThen(Completable.defer {
BleLogger.d(TAG, "Restoring backup to device after version ${firmwareUpdateResponse.version}")
sendInitializationAndStartSyncNotifications(client)
return@defer backupManager.restoreBackup(backup)
})
.andThen(Flowable.just(status))
} else {
Flowable.just(status)
}
Expand Down