43 lines
1.6 KiB
Plaintext
43 lines
1.6 KiB
Plaintext
import { common } from '@kit.AbilityKit'
|
|
import { MmkvTransferManager } from '../backupTransferManagers/MmkvTransferManager'
|
|
import { SpTransferManager } from '../backupTransferManagers/SpTransferManager'
|
|
|
|
export interface ISettingDataTransferProps {
|
|
context: common.Context,
|
|
mMmkvTransferManager: MmkvTransferManager,
|
|
mSpTransferManager: SpTransferManager,
|
|
}
|
|
|
|
export class SettingDataTransfer {
|
|
private TAG = 'SettingDataTransfer'
|
|
private mMmkvTransferManager: MmkvTransferManager
|
|
private mSpTransferManager: SpTransferManager
|
|
private context: common.Context
|
|
|
|
constructor(props: ISettingDataTransferProps) {
|
|
this.context = props.context
|
|
this.mMmkvTransferManager = props.mMmkvTransferManager
|
|
this.mSpTransferManager = props.mSpTransferManager
|
|
}
|
|
|
|
execute() {
|
|
const mmkv_public_default = this.mMmkvTransferManager.getSourceMmkv(this.context, 'public_default')
|
|
const fileradar_auto_upload_only_wifi_USERID = mmkv_public_default?.decodeBool('fileradar_auto_upload_only_wifi_USERID', false)
|
|
|
|
const sp_auto_upload_switch = this.mSpTransferManager.getDataFromSourceSp(this.context, 'auto_upload_switch.xml')
|
|
// write local preferences
|
|
const spMap = new Map<string, boolean>()
|
|
|
|
for (const key of sp_auto_upload_switch.keys()) {
|
|
const userId = key
|
|
const auto_upload_switch: boolean = sp_auto_upload_switch.get(userId) as boolean
|
|
spMap.set(`${userId}/docSync`, !!auto_upload_switch)
|
|
spMap.set(`${userId}/uploadOnlyWlan`, fileradar_auto_upload_only_wifi_USERID)
|
|
}
|
|
|
|
this.mSpTransferManager.insertDataToTargetSp(this.context, 'setting', spMap)
|
|
|
|
mmkv_public_default?.close()
|
|
}
|
|
}
|