INNER CODE UNIT · Kotlin

syncAllIfChanged

1812z/HyperIsland · android/app/src/main/kotlin/io/github/hyperisland/XposedPrefsSyncApp.kt:163

    private fun syncAllIfChanged(service: XposedService, src: SharedPreferences) {
        val source = src.all.filterKeys(::shouldSyncKey)
        val digest = configDigest(source)
        val meta = service.getRemotePreferences(REMOTE_PREFS_META)
        if (meta.getInt(META_FORMAT_VERSION, 0) == SYNC_FORMAT_VERSION &&
            meta.getString(META_CONFIG_DIGEST, null) == digest
        ) {
            Log.d(TAG, "config unchanged, skipped full sync (${source.size} keys)")
            return
        }

        val grouped = source.entries.groupBy({ remotePrefsNameForKey(it.key) }, { it })
        var changedGroups = 0
        for (prefsName in allRemotePrefsNames()) {
            val entries = grouped[prefsName].orEmpty()
            if (syncGroupDiff(service, prefsName, entries)) changedGroups++
        }
        updateRemoteDigest(service, digest)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…