mirror of
https://codeberg.org/timelimit/timelimit-android.git
synced 2025-10-03 17:59:51 +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
|
// const val INSTANCE_ID_FG_APP_DETECTION = 65536L
|
||||||
// private const val OBSOLETE_DISABLE_FG_APP_DETECTION_FALLBACK = 131072L
|
// private const val OBSOLETE_DISABLE_FG_APP_DETECTION_FALLBACK = 131072L
|
||||||
const val STRICT_OVERLAY_CHECKING = 0x40000L
|
const val STRICT_OVERLAY_CHECKING = 0x40000L
|
||||||
const val DISABLE_LEGACY_APP_SENDING = 0x80000L
|
// const val DISABLE_LEGACY_APP_SENDING = 0x80000L
|
||||||
}
|
}
|
||||||
|
|
||||||
object ConsentFlags {
|
object ConsentFlags {
|
||||||
|
|
|
@ -41,7 +41,6 @@ object CryptoAppListSync {
|
||||||
database: Database,
|
database: Database,
|
||||||
installed: InstalledAppsProto,
|
installed: InstalledAppsProto,
|
||||||
syncUtil: SyncUtil,
|
syncUtil: SyncUtil,
|
||||||
disableLegacySync: Boolean,
|
|
||||||
serverApiLevelInfo: ServerApiLevelInfo
|
serverApiLevelInfo: ServerApiLevelInfo
|
||||||
) {
|
) {
|
||||||
val compressedDataSizeLimit =
|
val compressedDataSizeLimit =
|
||||||
|
@ -166,8 +165,7 @@ object CryptoAppListSync {
|
||||||
|
|
||||||
dispatchSync(UpdateInstalledAppsAction(
|
dispatchSync(UpdateInstalledAppsAction(
|
||||||
base = baseEncrypted,
|
base = baseEncrypted,
|
||||||
diff = diffEncrypted,
|
diff = diffEncrypted
|
||||||
wipe = disableLegacySync
|
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,8 +195,7 @@ object CryptoAppListSync {
|
||||||
|
|
||||||
dispatchSync(UpdateInstalledAppsAction(
|
dispatchSync(UpdateInstalledAppsAction(
|
||||||
base = null,
|
base = null,
|
||||||
diff = diffEncrypted,
|
diff = diffEncrypted
|
||||||
wipe = disableLegacySync
|
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,6 @@ package io.timelimit.android.logic.applist
|
||||||
import androidx.lifecycle.LiveData
|
import androidx.lifecycle.LiveData
|
||||||
import io.timelimit.android.data.Database
|
import io.timelimit.android.data.Database
|
||||||
import io.timelimit.android.data.model.ConsentFlags
|
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.data.model.UserType
|
||||||
import io.timelimit.android.integration.platform.ProtectionLevel
|
import io.timelimit.android.integration.platform.ProtectionLevel
|
||||||
import io.timelimit.android.livedata.*
|
import io.timelimit.android.livedata.*
|
||||||
|
@ -34,7 +33,6 @@ data class DeviceState(
|
||||||
val isDeviceOwner: Boolean,
|
val isDeviceOwner: Boolean,
|
||||||
val hasSyncConsent: Boolean,
|
val hasSyncConsent: Boolean,
|
||||||
val isLocalMode: Boolean,
|
val isLocalMode: Boolean,
|
||||||
val disableLegacySync: Boolean,
|
|
||||||
val serverApiLevel: ServerApiLevelInfo
|
val serverApiLevel: ServerApiLevelInfo
|
||||||
) {
|
) {
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -43,7 +41,6 @@ data class DeviceState(
|
||||||
val deviceRelatedData = userAndDeviceData.deviceRelatedData
|
val deviceRelatedData = userAndDeviceData.deviceRelatedData
|
||||||
val device = deviceRelatedData.deviceEntry
|
val device = deviceRelatedData.deviceEntry
|
||||||
val defaultUser = if (device.defaultUser.isNotEmpty()) database.user().getUserByIdSync(device.defaultUser) else null
|
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)
|
val serverApiLevel = ServerApiLevelLogic.getSync(database)
|
||||||
|
|
||||||
return DeviceState(
|
return DeviceState(
|
||||||
|
@ -54,7 +51,6 @@ data class DeviceState(
|
||||||
isDeviceOwner = device.currentProtectionLevel == ProtectionLevel.DeviceOwner,
|
isDeviceOwner = device.currentProtectionLevel == ProtectionLevel.DeviceOwner,
|
||||||
hasSyncConsent = deviceRelatedData.consentFlags and ConsentFlags.APP_LIST_SYNC == ConsentFlags.APP_LIST_SYNC,
|
hasSyncConsent = deviceRelatedData.consentFlags and ConsentFlags.APP_LIST_SYNC == ConsentFlags.APP_LIST_SYNC,
|
||||||
isLocalMode = deviceRelatedData.isLocalMode,
|
isLocalMode = deviceRelatedData.isLocalMode,
|
||||||
disableLegacySync = disableLegacySync,
|
|
||||||
serverApiLevel = serverApiLevel
|
serverApiLevel = serverApiLevel
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -70,9 +66,8 @@ data class DeviceState(
|
||||||
if (defaultUser.isNullOrEmpty()) liveDataFromNullableValue(null)
|
if (defaultUser.isNullOrEmpty()) liveDataFromNullableValue(null)
|
||||||
else appLogic.database.user().getUserByIdLive(defaultUser)
|
else appLogic.database.user().getUserByIdLive(defaultUser)
|
||||||
},
|
},
|
||||||
appLogic.database.config().isExperimentalFlagsSetAsync(ExperimentalFlags.DISABLE_LEGACY_APP_SENDING),
|
|
||||||
appLogic.serverApiLevelLogic.infoLive
|
appLogic.serverApiLevelLogic.infoLive
|
||||||
).map { (deviceEntry, hasSyncConsent, isLocalMode, deviceUser, deviceDefaultUser, disableLegacySync, serverApiLevel) ->
|
).map { (deviceEntry, hasSyncConsent, isLocalMode, deviceUser, deviceDefaultUser, serverApiLevel) ->
|
||||||
deviceEntry?.let { device ->
|
deviceEntry?.let { device ->
|
||||||
DeviceState(
|
DeviceState(
|
||||||
id = device.id,
|
id = device.id,
|
||||||
|
@ -82,7 +77,6 @@ data class DeviceState(
|
||||||
isDeviceOwner = device.currentProtectionLevel == ProtectionLevel.DeviceOwner,
|
isDeviceOwner = device.currentProtectionLevel == ProtectionLevel.DeviceOwner,
|
||||||
hasSyncConsent = hasSyncConsent,
|
hasSyncConsent = hasSyncConsent,
|
||||||
isLocalMode = isLocalMode,
|
isLocalMode = isLocalMode,
|
||||||
disableLegacySync = disableLegacySync,
|
|
||||||
serverApiLevel = serverApiLevel
|
serverApiLevel = serverApiLevel
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,7 +111,6 @@ class SyncInstalledAppsLogic(val appLogic: AppLogic) {
|
||||||
val diffPlain = AppsDifferenceUtil.calculateAppsDifference(savedPlain, installed)
|
val diffPlain = AppsDifferenceUtil.calculateAppsDifference(savedPlain, installed)
|
||||||
val diffPlainActions = AppsDifferenceUtil.calculateAppsDifferenceActions(diffPlain, deviceState.id)
|
val diffPlainActions = AppsDifferenceUtil.calculateAppsDifferenceActions(diffPlain, deviceState.id)
|
||||||
|
|
||||||
if (deviceState.disableLegacySync) {
|
|
||||||
if (diffPlainActions.isNotEmpty()) {
|
if (diffPlainActions.isNotEmpty()) {
|
||||||
Threads.database.executeAndWait {
|
Threads.database.executeAndWait {
|
||||||
diffPlainActions.forEach {
|
diffPlainActions.forEach {
|
||||||
|
@ -121,15 +120,6 @@ class SyncInstalledAppsLogic(val appLogic: AppLogic) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
diffPlainActions.forEach { action ->
|
|
||||||
ApplyActionUtil.applyAppLogicAction(
|
|
||||||
action = action,
|
|
||||||
appLogic = appLogic,
|
|
||||||
ignoreIfDeviceIsNotConfigured = true
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (deviceState.isConnectedMode && deviceState.serverApiLevel.hasLevelOrIsOffline(4)) {
|
if (deviceState.isConnectedMode && deviceState.serverApiLevel.hasLevelOrIsOffline(4)) {
|
||||||
CryptoAppListSync.sync(
|
CryptoAppListSync.sync(
|
||||||
|
@ -137,7 +127,6 @@ class SyncInstalledAppsLogic(val appLogic: AppLogic) {
|
||||||
database = appLogic.database,
|
database = appLogic.database,
|
||||||
installed = installed,
|
installed = installed,
|
||||||
syncUtil = appLogic.syncUtil,
|
syncUtil = appLogic.syncUtil,
|
||||||
disableLegacySync = deviceState.disableLegacySync,
|
|
||||||
serverApiLevelInfo = deviceState.serverApiLevel
|
serverApiLevelInfo = deviceState.serverApiLevel
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -289,45 +289,7 @@ object ApplyServerDataStatus {
|
||||||
}
|
}
|
||||||
|
|
||||||
run {
|
run {
|
||||||
val disableLegacySync = database.config().isExperimentalFlagsSetSync(ExperimentalFlags.DISABLE_LEGACY_APP_SENDING)
|
|
||||||
|
|
||||||
for (item in status.newInstalledApps) {
|
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
|
// apply changed version number
|
||||||
database.device().updateAppsVersion(
|
database.device().updateAppsVersion(
|
||||||
deviceId = item.deviceId,
|
deviceId = item.deviceId,
|
||||||
|
@ -335,7 +297,6 @@ object ApplyServerDataStatus {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
run {
|
run {
|
||||||
// apply removed categories
|
// apply removed categories
|
||||||
|
|
|
@ -471,8 +471,7 @@ data class UpdateAppActivitiesAction(
|
||||||
}
|
}
|
||||||
data class UpdateInstalledAppsAction (
|
data class UpdateInstalledAppsAction (
|
||||||
val base: ByteArray?,
|
val base: ByteArray?,
|
||||||
val diff: ByteArray?,
|
val diff: ByteArray?
|
||||||
val wipe: Boolean
|
|
||||||
): AppLogicAction() {
|
): AppLogicAction() {
|
||||||
companion object {
|
companion object {
|
||||||
private const val TYPE_VALUE = "UPDATE_INSTALLED_APPS"
|
private const val TYPE_VALUE = "UPDATE_INSTALLED_APPS"
|
||||||
|
@ -489,7 +488,7 @@ data class UpdateInstalledAppsAction (
|
||||||
base?.let { writer.name(BASE).value(it.base64()) }
|
base?.let { writer.name(BASE).value(it.base64()) }
|
||||||
diff?.let { writer.name(DIFF).value(it.base64()) }
|
diff?.let { writer.name(DIFF).value(it.base64()) }
|
||||||
|
|
||||||
writer.name(WIPE).value(wipe)
|
writer.name(WIPE).value(true)
|
||||||
|
|
||||||
writer.endObject()
|
writer.endObject()
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,10 +24,7 @@ import io.timelimit.android.data.customtypes.ImmutableBitmaskJson
|
||||||
import io.timelimit.android.data.model.*
|
import io.timelimit.android.data.model.*
|
||||||
import io.timelimit.android.extensions.MinuteOfDay
|
import io.timelimit.android.extensions.MinuteOfDay
|
||||||
import io.timelimit.android.extensions.parseBase64
|
import io.timelimit.android.extensions.parseBase64
|
||||||
import io.timelimit.android.extensions.parseList
|
|
||||||
import io.timelimit.android.integration.platform.*
|
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.parseJsonArray
|
||||||
import io.timelimit.android.util.parseJsonStringArray
|
import io.timelimit.android.util.parseJsonStringArray
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
@ -1057,29 +1054,21 @@ data class ServerUpdatedCategoryTask (
|
||||||
|
|
||||||
data class ServerInstalledAppsData(
|
data class ServerInstalledAppsData(
|
||||||
val deviceId: String,
|
val deviceId: String,
|
||||||
val version: String,
|
val version: String
|
||||||
val apps: List<InstalledApp>,
|
|
||||||
val activities: List<AppActivityItem>
|
|
||||||
) {
|
) {
|
||||||
companion object {
|
companion object {
|
||||||
private const val DEVICE_ID = "deviceId"
|
private const val DEVICE_ID = "deviceId"
|
||||||
private const val VERSION = "version"
|
private const val VERSION = "version"
|
||||||
private const val APPS = "apps"
|
|
||||||
private const val ACTIVITIES = "activities"
|
|
||||||
|
|
||||||
fun parse(reader: JsonReader): ServerInstalledAppsData {
|
fun parse(reader: JsonReader): ServerInstalledAppsData {
|
||||||
var deviceId: String? = null
|
var deviceId: String? = null
|
||||||
var version: String? = null
|
var version: String? = null
|
||||||
var apps: List<InstalledApp>? = null
|
|
||||||
var activities: List<AppActivityItem>? = null
|
|
||||||
|
|
||||||
reader.beginObject()
|
reader.beginObject()
|
||||||
while (reader.hasNext()) {
|
while (reader.hasNext()) {
|
||||||
when(reader.nextName()) {
|
when(reader.nextName()) {
|
||||||
DEVICE_ID -> deviceId = reader.nextString()
|
DEVICE_ID -> deviceId = reader.nextString()
|
||||||
VERSION -> version = reader.nextString()
|
VERSION -> version = reader.nextString()
|
||||||
APPS -> apps = InstalledApp.parseList(reader)
|
|
||||||
ACTIVITIES -> activities = reader.parseList { AppActivityItem.parse(it) }
|
|
||||||
else -> reader.skipValue()
|
else -> reader.skipValue()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1087,9 +1076,7 @@ data class ServerInstalledAppsData(
|
||||||
|
|
||||||
return ServerInstalledAppsData(
|
return ServerInstalledAppsData(
|
||||||
deviceId = deviceId!!,
|
deviceId = deviceId!!,
|
||||||
version = version!!,
|
version = version!!
|
||||||
apps = apps!!,
|
|
||||||
activities = activities!!
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -195,12 +195,6 @@ data class DiagnoseExperimentalFlagItem(
|
||||||
enableFlags = ExperimentalFlags.STRICT_OVERLAY_CHECKING,
|
enableFlags = ExperimentalFlags.STRICT_OVERLAY_CHECKING,
|
||||||
disableFlags = ExperimentalFlags.STRICT_OVERLAY_CHECKING,
|
disableFlags = ExperimentalFlags.STRICT_OVERLAY_CHECKING,
|
||||||
enable = { true }
|
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_esb">Overlay und Home-Button nicht zum Sperren verwenden</string>
|
||||||
<string name="diagnose_exf_srn">Toasts zur Synchronisation anzeigen</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_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>
|
<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_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_srn">Show sync related toasts</string>
|
||||||
<string name="diagnose_exf_soc">Enable strict overlay permission check</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>
|
<string name="diagnose_bg_task_loop_ex">Background task loop exception</string>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue