mirror of
https://codeberg.org/timelimit/timelimit-android.git
synced 2025-10-03 09:49:25 +02:00
Remove legacy app list sync
This commit is contained in:
parent
2867415796
commit
cb8f51efed
10 changed files with 19 additions and 100 deletions
|
@ -289,7 +289,7 @@ object ExperimentalFlags {
|
|||
// const val INSTANCE_ID_FG_APP_DETECTION = 65536L
|
||||
// private const val OBSOLETE_DISABLE_FG_APP_DETECTION_FALLBACK = 131072L
|
||||
const val STRICT_OVERLAY_CHECKING = 0x40000L
|
||||
const val DISABLE_LEGACY_APP_SENDING = 0x80000L
|
||||
// const val DISABLE_LEGACY_APP_SENDING = 0x80000L
|
||||
}
|
||||
|
||||
object ConsentFlags {
|
||||
|
|
|
@ -41,7 +41,6 @@ object CryptoAppListSync {
|
|||
database: Database,
|
||||
installed: InstalledAppsProto,
|
||||
syncUtil: SyncUtil,
|
||||
disableLegacySync: Boolean,
|
||||
serverApiLevelInfo: ServerApiLevelInfo
|
||||
) {
|
||||
val compressedDataSizeLimit =
|
||||
|
@ -166,8 +165,7 @@ object CryptoAppListSync {
|
|||
|
||||
dispatchSync(UpdateInstalledAppsAction(
|
||||
base = baseEncrypted,
|
||||
diff = diffEncrypted,
|
||||
wipe = disableLegacySync
|
||||
diff = diffEncrypted
|
||||
))
|
||||
}
|
||||
|
||||
|
@ -197,8 +195,7 @@ object CryptoAppListSync {
|
|||
|
||||
dispatchSync(UpdateInstalledAppsAction(
|
||||
base = null,
|
||||
diff = diffEncrypted,
|
||||
wipe = disableLegacySync
|
||||
diff = diffEncrypted
|
||||
))
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@ package io.timelimit.android.logic.applist
|
|||
import androidx.lifecycle.LiveData
|
||||
import io.timelimit.android.data.Database
|
||||
import io.timelimit.android.data.model.ConsentFlags
|
||||
import io.timelimit.android.data.model.ExperimentalFlags
|
||||
import io.timelimit.android.data.model.UserType
|
||||
import io.timelimit.android.integration.platform.ProtectionLevel
|
||||
import io.timelimit.android.livedata.*
|
||||
|
@ -34,7 +33,6 @@ data class DeviceState(
|
|||
val isDeviceOwner: Boolean,
|
||||
val hasSyncConsent: Boolean,
|
||||
val isLocalMode: Boolean,
|
||||
val disableLegacySync: Boolean,
|
||||
val serverApiLevel: ServerApiLevelInfo
|
||||
) {
|
||||
companion object {
|
||||
|
@ -43,7 +41,6 @@ data class DeviceState(
|
|||
val deviceRelatedData = userAndDeviceData.deviceRelatedData
|
||||
val device = deviceRelatedData.deviceEntry
|
||||
val defaultUser = if (device.defaultUser.isNotEmpty()) database.user().getUserByIdSync(device.defaultUser) else null
|
||||
val disableLegacySync = deviceRelatedData.isExperimentalFlagSetSync(ExperimentalFlags.DISABLE_LEGACY_APP_SENDING)
|
||||
val serverApiLevel = ServerApiLevelLogic.getSync(database)
|
||||
|
||||
return DeviceState(
|
||||
|
@ -54,7 +51,6 @@ data class DeviceState(
|
|||
isDeviceOwner = device.currentProtectionLevel == ProtectionLevel.DeviceOwner,
|
||||
hasSyncConsent = deviceRelatedData.consentFlags and ConsentFlags.APP_LIST_SYNC == ConsentFlags.APP_LIST_SYNC,
|
||||
isLocalMode = deviceRelatedData.isLocalMode,
|
||||
disableLegacySync = disableLegacySync,
|
||||
serverApiLevel = serverApiLevel
|
||||
)
|
||||
}
|
||||
|
@ -70,9 +66,8 @@ data class DeviceState(
|
|||
if (defaultUser.isNullOrEmpty()) liveDataFromNullableValue(null)
|
||||
else appLogic.database.user().getUserByIdLive(defaultUser)
|
||||
},
|
||||
appLogic.database.config().isExperimentalFlagsSetAsync(ExperimentalFlags.DISABLE_LEGACY_APP_SENDING),
|
||||
appLogic.serverApiLevelLogic.infoLive
|
||||
).map { (deviceEntry, hasSyncConsent, isLocalMode, deviceUser, deviceDefaultUser, disableLegacySync, serverApiLevel) ->
|
||||
).map { (deviceEntry, hasSyncConsent, isLocalMode, deviceUser, deviceDefaultUser, serverApiLevel) ->
|
||||
deviceEntry?.let { device ->
|
||||
DeviceState(
|
||||
id = device.id,
|
||||
|
@ -82,7 +77,6 @@ data class DeviceState(
|
|||
isDeviceOwner = device.currentProtectionLevel == ProtectionLevel.DeviceOwner,
|
||||
hasSyncConsent = hasSyncConsent,
|
||||
isLocalMode = isLocalMode,
|
||||
disableLegacySync = disableLegacySync,
|
||||
serverApiLevel = serverApiLevel
|
||||
)
|
||||
}
|
||||
|
|
|
@ -111,24 +111,14 @@ class SyncInstalledAppsLogic(val appLogic: AppLogic) {
|
|||
val diffPlain = AppsDifferenceUtil.calculateAppsDifference(savedPlain, installed)
|
||||
val diffPlainActions = AppsDifferenceUtil.calculateAppsDifferenceActions(diffPlain, deviceState.id)
|
||||
|
||||
if (deviceState.disableLegacySync) {
|
||||
if (diffPlainActions.isNotEmpty()) {
|
||||
Threads.database.executeAndWait {
|
||||
diffPlainActions.forEach {
|
||||
LocalDatabaseAppLogicActionDispatcher.dispatchAppLogicActionSync(
|
||||
it, appLogic.database.config().getOwnDeviceIdSync()!!, appLogic.database
|
||||
)
|
||||
}
|
||||
if (diffPlainActions.isNotEmpty()) {
|
||||
Threads.database.executeAndWait {
|
||||
diffPlainActions.forEach {
|
||||
LocalDatabaseAppLogicActionDispatcher.dispatchAppLogicActionSync(
|
||||
it, appLogic.database.config().getOwnDeviceIdSync()!!, appLogic.database
|
||||
)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
diffPlainActions.forEach { action ->
|
||||
ApplyActionUtil.applyAppLogicAction(
|
||||
action = action,
|
||||
appLogic = appLogic,
|
||||
ignoreIfDeviceIsNotConfigured = true
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if (deviceState.isConnectedMode && deviceState.serverApiLevel.hasLevelOrIsOffline(4)) {
|
||||
|
@ -137,7 +127,6 @@ class SyncInstalledAppsLogic(val appLogic: AppLogic) {
|
|||
database = appLogic.database,
|
||||
installed = installed,
|
||||
syncUtil = appLogic.syncUtil,
|
||||
disableLegacySync = deviceState.disableLegacySync,
|
||||
serverApiLevelInfo = deviceState.serverApiLevel
|
||||
)
|
||||
}
|
||||
|
|
|
@ -289,51 +289,12 @@ object ApplyServerDataStatus {
|
|||
}
|
||||
|
||||
run {
|
||||
val disableLegacySync = database.config().isExperimentalFlagsSetSync(ExperimentalFlags.DISABLE_LEGACY_APP_SENDING)
|
||||
|
||||
for (item in status.newInstalledApps) {
|
||||
DatabaseValidation.assertDeviceExists(database, item.deviceId)
|
||||
|
||||
if (
|
||||
database.cryptContainer().getCryptoMetadataSyncByDeviceId(item.deviceId, CryptContainerMetadata.TYPE_APP_LIST_BASE) == null ||
|
||||
(item.deviceId == database.config().getOwnDeviceIdSync() && !disableLegacySync)
|
||||
) {
|
||||
run {
|
||||
// apply apps
|
||||
database.app().deleteAllAppsByDeviceId(item.deviceId)
|
||||
database.app().addAppsSync(item.apps.map {
|
||||
App(
|
||||
deviceId = item.deviceId,
|
||||
packageName = it.packageName,
|
||||
title = it.title,
|
||||
isLaunchable = it.isLaunchable,
|
||||
recommendation = it.recommendation
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
run {
|
||||
// apply activities
|
||||
database.appActivity()
|
||||
.deleteAppActivitiesByDeviceIds(listOf(item.deviceId))
|
||||
database.appActivity().addAppActivitiesSync(item.activities.map {
|
||||
AppActivity(
|
||||
deviceId = item.deviceId,
|
||||
appPackageName = it.packageName,
|
||||
activityClassName = it.className,
|
||||
title = it.title
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
run {
|
||||
// apply changed version number
|
||||
database.device().updateAppsVersion(
|
||||
deviceId = item.deviceId,
|
||||
appsVersion = item.version
|
||||
)
|
||||
}
|
||||
// apply changed version number
|
||||
database.device().updateAppsVersion(
|
||||
deviceId = item.deviceId,
|
||||
appsVersion = item.version
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -471,8 +471,7 @@ data class UpdateAppActivitiesAction(
|
|||
}
|
||||
data class UpdateInstalledAppsAction (
|
||||
val base: ByteArray?,
|
||||
val diff: ByteArray?,
|
||||
val wipe: Boolean
|
||||
val diff: ByteArray?
|
||||
): AppLogicAction() {
|
||||
companion object {
|
||||
private const val TYPE_VALUE = "UPDATE_INSTALLED_APPS"
|
||||
|
@ -489,7 +488,7 @@ data class UpdateInstalledAppsAction (
|
|||
base?.let { writer.name(BASE).value(it.base64()) }
|
||||
diff?.let { writer.name(DIFF).value(it.base64()) }
|
||||
|
||||
writer.name(WIPE).value(wipe)
|
||||
writer.name(WIPE).value(true)
|
||||
|
||||
writer.endObject()
|
||||
}
|
||||
|
|
|
@ -24,10 +24,7 @@ import io.timelimit.android.data.customtypes.ImmutableBitmaskJson
|
|||
import io.timelimit.android.data.model.*
|
||||
import io.timelimit.android.extensions.MinuteOfDay
|
||||
import io.timelimit.android.extensions.parseBase64
|
||||
import io.timelimit.android.extensions.parseList
|
||||
import io.timelimit.android.integration.platform.*
|
||||
import io.timelimit.android.sync.actions.AppActivityItem
|
||||
import io.timelimit.android.sync.actions.InstalledApp
|
||||
import io.timelimit.android.util.parseJsonArray
|
||||
import io.timelimit.android.util.parseJsonStringArray
|
||||
import java.util.*
|
||||
|
@ -1057,29 +1054,21 @@ data class ServerUpdatedCategoryTask (
|
|||
|
||||
data class ServerInstalledAppsData(
|
||||
val deviceId: String,
|
||||
val version: String,
|
||||
val apps: List<InstalledApp>,
|
||||
val activities: List<AppActivityItem>
|
||||
val version: String
|
||||
) {
|
||||
companion object {
|
||||
private const val DEVICE_ID = "deviceId"
|
||||
private const val VERSION = "version"
|
||||
private const val APPS = "apps"
|
||||
private const val ACTIVITIES = "activities"
|
||||
|
||||
fun parse(reader: JsonReader): ServerInstalledAppsData {
|
||||
var deviceId: String? = null
|
||||
var version: String? = null
|
||||
var apps: List<InstalledApp>? = null
|
||||
var activities: List<AppActivityItem>? = null
|
||||
|
||||
reader.beginObject()
|
||||
while (reader.hasNext()) {
|
||||
when(reader.nextName()) {
|
||||
DEVICE_ID -> deviceId = reader.nextString()
|
||||
VERSION -> version = reader.nextString()
|
||||
APPS -> apps = InstalledApp.parseList(reader)
|
||||
ACTIVITIES -> activities = reader.parseList { AppActivityItem.parse(it) }
|
||||
else -> reader.skipValue()
|
||||
}
|
||||
}
|
||||
|
@ -1087,9 +1076,7 @@ data class ServerInstalledAppsData(
|
|||
|
||||
return ServerInstalledAppsData(
|
||||
deviceId = deviceId!!,
|
||||
version = version!!,
|
||||
apps = apps!!,
|
||||
activities = activities!!
|
||||
version = version!!
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -195,12 +195,6 @@ data class DiagnoseExperimentalFlagItem(
|
|||
enableFlags = ExperimentalFlags.STRICT_OVERLAY_CHECKING,
|
||||
disableFlags = ExperimentalFlags.STRICT_OVERLAY_CHECKING,
|
||||
enable = { true }
|
||||
),
|
||||
DiagnoseExperimentalFlagItem(
|
||||
label = R.string.diagnose_exf_dls,
|
||||
enableFlags = ExperimentalFlags.DISABLE_LEGACY_APP_SENDING,
|
||||
disableFlags = ExperimentalFlags.DISABLE_LEGACY_APP_SENDING,
|
||||
enable = { true }
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
|
@ -534,7 +534,6 @@
|
|||
<string name="diagnose_exf_esb">Overlay und Home-Button nicht zum Sperren verwenden</string>
|
||||
<string name="diagnose_exf_srn">Toasts zur Synchronisation anzeigen</string>
|
||||
<string name="diagnose_exf_soc">strengere Prüfung der Überlagerungs-Berechtigung aktivieren</string>
|
||||
<string name="diagnose_exf_dls">deaktiviere Senden der App-Liste im alten Format</string>
|
||||
|
||||
<string name="diagnose_bg_task_loop_ex">Hintergrundaufgabenschleifenfehler</string>
|
||||
|
||||
|
|
|
@ -586,7 +586,6 @@
|
|||
<string name="diagnose_exf_esb">Do not use a overlay or the home button for blocking</string>
|
||||
<string name="diagnose_exf_srn">Show sync related toasts</string>
|
||||
<string name="diagnose_exf_soc">Enable strict overlay permission check</string>
|
||||
<string name="diagnose_exf_dls">Disable sending the App List with the legacy encoding</string>
|
||||
|
||||
<string name="diagnose_bg_task_loop_ex">Background task loop exception</string>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue