From 738492db594f1c74b9ba3a298c8d6139b6043a44 Mon Sep 17 00:00:00 2001 From: alperozturk96 Date: Thu, 5 Nov 2026 14:40:40 +0300 Subject: [PATCH 1/2] unify capabilities operations Signed-off-by: alperozturk96 --- .../client/database/dao/CapabilityDao.kt | 6 +- .../database/entity/CapabilityEntity.kt | 220 +++++++---- .../datamodel/FileDataStorageManager.java | 370 +----------------- .../com/owncloud/android/db/ProviderMeta.java | 4 - .../providers/FileContentProvider.java | 20 +- 5 files changed, 168 insertions(+), 452 deletions(-) diff --git a/app/src/main/java/com/nextcloud/client/database/dao/CapabilityDao.kt b/app/src/main/java/com/nextcloud/client/database/dao/CapabilityDao.kt index 51ea739b2fe3..f297dccdf007 100644 --- a/app/src/main/java/com/nextcloud/client/database/dao/CapabilityDao.kt +++ b/app/src/main/java/com/nextcloud/client/database/dao/CapabilityDao.kt @@ -9,11 +9,15 @@ package com.nextcloud.client.database.dao import androidx.room.Dao import androidx.room.Query +import androidx.room.Upsert import com.nextcloud.client.database.entity.CapabilityEntity @Dao interface CapabilityDao { @Query("SELECT * FROM capabilities WHERE account = :accountName LIMIT 1") - suspend fun getByAccountName(accountName: String): CapabilityEntity? + fun getByAccountName(accountName: String): CapabilityEntity? + + @Upsert + fun upsert(entity: CapabilityEntity): Long } diff --git a/app/src/main/java/com/nextcloud/client/database/entity/CapabilityEntity.kt b/app/src/main/java/com/nextcloud/client/database/entity/CapabilityEntity.kt index a8b7035168f6..e44368c1b7ff 100644 --- a/app/src/main/java/com/nextcloud/client/database/entity/CapabilityEntity.kt +++ b/app/src/main/java/com/nextcloud/client/database/entity/CapabilityEntity.kt @@ -1,6 +1,7 @@ /* * Nextcloud - Android Client * + * SPDX-FileCopyrightText: 2026 Alper Ozturk * SPDX-FileCopyrightText: 2022 Álvaro Brey * SPDX-FileCopyrightText: 2022 Nextcloud GmbH * SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only @@ -169,80 +170,159 @@ fun CapabilityEntity?.toOCCapability(): OCCapability { val id = this.id ?: return capability fun intToBoolean(value: Int?): CapabilityBooleanType = - value?.let { CapabilityBooleanType.fromValue(it) } ?: CapabilityBooleanType.UNKNOWN + value?.let { CapabilityBooleanType.fromValue(it) } ?: CapabilityBooleanType.FALSE capability.id = id.toLong() - capability.accountName = this.accountName - capability.versionMayor = this.versionMajor ?: 0 - capability.versionMinor = this.versionMinor ?: 0 - capability.versionMicro = this.versionMicro ?: 0 - capability.versionString = this.versionString - capability.versionEdition = this.versionEditor - capability.extendedSupport = intToBoolean(this.extendedSupport) - capability.corePollInterval = this.corePollinterval ?: 0 - capability.filesSharingApiEnabled = intToBoolean(this.sharingApiEnabled) - capability.filesSharingPublicEnabled = intToBoolean(this.sharingPublicEnabled) - capability.filesSharingPublicPasswordEnforced = intToBoolean(this.sharingPublicPasswordEnforced) - capability.filesSharingPublicAskForOptionalPassword = intToBoolean(this.sharingPublicAskForOptionalPassword) - capability.filesSharingPublicExpireDateEnabled = intToBoolean(this.sharingPublicExpireDateEnabled) - capability.filesSharingPublicExpireDateDays = this.sharingPublicExpireDateDays ?: 0 - capability.filesSharingPublicExpireDateEnforced = intToBoolean(this.sharingPublicExpireDateEnforced) - capability.filesSharingPublicSendMail = intToBoolean(this.sharingPublicSendMail) - capability.filesSharingPublicUpload = intToBoolean(this.sharingPublicUpload) - capability.filesSharingUserSendMail = intToBoolean(this.sharingUserSendMail) - capability.filesSharingResharing = intToBoolean(this.sharingResharing) - capability.filesSharingFederationOutgoing = intToBoolean(this.sharingFederationOutgoing) - capability.filesSharingFederationIncoming = intToBoolean(this.sharingFederationIncoming) - capability.filesBigFileChunking = intToBoolean(this.filesBigfilechunking) - capability.filesUndelete = intToBoolean(this.filesUndelete) - capability.filesVersioning = intToBoolean(this.filesVersioning) - capability.externalLinks = intToBoolean(this.externalLinks) - capability.serverName = this.serverName - capability.serverColor = this.serverColor - capability.serverTextColor = this.serverTextColor - capability.serverElementColor = this.serverElementColor - capability.serverSlogan = this.serverSlogan - capability.serverLogo = this.serverLogo - capability.serverBackground = this.serverBackgroundUrl - capability.endToEndEncryption = intToBoolean(this.endToEndEncryption) - capability.endToEndEncryptionKeysExist = intToBoolean(this.endToEndEncryptionKeysExist) - capability.endToEndEncryptionApiVersion = this.endToEndEncryptionApiVersion?.let { + capability.accountName = accountName + capability.versionMayor = versionMajor ?: 0 + capability.versionMinor = versionMinor ?: 0 + capability.versionMicro = versionMicro ?: 0 + capability.versionString = versionString + capability.versionEdition = versionEditor + capability.extendedSupport = intToBoolean(extendedSupport) + capability.corePollInterval = corePollinterval ?: 0 + capability.filesSharingApiEnabled = intToBoolean(sharingApiEnabled) + capability.filesSharingPublicEnabled = intToBoolean(sharingPublicEnabled) + capability.filesSharingPublicPasswordEnforced = intToBoolean(sharingPublicPasswordEnforced) + capability.filesSharingPublicAskForOptionalPassword = intToBoolean(sharingPublicAskForOptionalPassword) + capability.filesSharingPublicExpireDateEnabled = intToBoolean(sharingPublicExpireDateEnabled) + capability.filesSharingPublicExpireDateDays = sharingPublicExpireDateDays ?: 0 + capability.filesSharingPublicExpireDateEnforced = intToBoolean(sharingPublicExpireDateEnforced) + capability.filesSharingPublicSendMail = intToBoolean(sharingPublicSendMail) + capability.filesSharingPublicUpload = intToBoolean(sharingPublicUpload) + capability.filesSharingUserSendMail = intToBoolean(sharingUserSendMail) + capability.filesSharingResharing = intToBoolean(sharingResharing) + capability.filesSharingFederationOutgoing = intToBoolean(sharingFederationOutgoing) + capability.filesSharingFederationIncoming = intToBoolean(sharingFederationIncoming) + capability.filesBigFileChunking = intToBoolean(filesBigfilechunking) + capability.filesUndelete = intToBoolean(filesUndelete) + capability.filesVersioning = intToBoolean(filesVersioning) + capability.externalLinks = intToBoolean(externalLinks) + capability.serverName = serverName + capability.serverColor = serverColor + capability.serverTextColor = serverTextColor + capability.serverElementColor = serverElementColor + capability.serverSlogan = serverSlogan + capability.serverLogo = serverLogo + capability.serverBackground = serverBackgroundUrl + capability.endToEndEncryption = intToBoolean(endToEndEncryption) + capability.endToEndEncryptionKeysExist = intToBoolean(endToEndEncryptionKeysExist) + capability.endToEndEncryptionApiVersion = endToEndEncryptionApiVersion?.let { E2EVersion.fromValue(it) } ?: E2EVersion.UNKNOWN - capability.serverBackgroundDefault = intToBoolean(this.serverBackgroundDefault) - capability.serverBackgroundPlain = intToBoolean(this.serverBackgroundPlain) - capability.activity = intToBoolean(this.activity) - capability.richDocuments = intToBoolean(this.richdocument) - capability.richDocumentsDirectEditing = intToBoolean(this.richdocumentDirectEditing) - capability.richDocumentsTemplatesAvailable = intToBoolean(this.richdocumentTemplates) - capability.richDocumentsMimeTypeList = this.richdocumentMimetypeList?.split(",") ?: emptyList() - capability.richDocumentsOptionalMimeTypeList = this.richdocumentOptionalMimetypeList?.split(",") ?: emptyList() - capability.richDocumentsProductName = this.richdocumentProductName - capability.directEditingEtag = this.directEditingEtag - capability.etag = this.etag - capability.userStatus = intToBoolean(this.userStatus) - capability.userStatusSupportsEmoji = intToBoolean(this.userStatusSupportsEmoji) - capability.userStatusSupportsBusy = intToBoolean(this.userStatusSupportsBusy) - capability.filesLockingVersion = this.filesLockingVersion - capability.assistant = intToBoolean(this.assistant) - capability.groupfolders = intToBoolean(this.groupfolders) - capability.dropAccount = intToBoolean(this.dropAccount) - capability.securityGuard = intToBoolean(this.securityGuard) - capability.governance = intToBoolean(this.governance) - capability.forbiddenFilenameCharactersJson = this.forbiddenFileNameCharacters - capability.forbiddenFilenamesJson = this.forbiddenFileNames - capability.forbiddenFilenameExtensionJson = this.forbiddenFileNameExtensions - capability.forbiddenFilenameBaseNamesJson = this.forbiddenFilenameBaseNames - capability.isWCFEnabled = intToBoolean(this.isWCFEnabled) - capability.filesDownloadLimit = intToBoolean(this.filesDownloadLimit) - capability.filesDownloadLimitDefault = this.filesDownloadLimitDefault ?: 0 - capability.recommendations = intToBoolean(this.recommendation) - capability.notesFolderPath = this.notesFolderPath - capability.defaultPermissions = this.defaultPermissions ?: 0 - capability.hasValidSubscription = intToBoolean(this.hasValidSubscription) - capability.clientIntegrationJson = this.clientIntegrationJson - capability.modRewriteWorking = intToBoolean(this.modRewriteWorking) - capability.chunkedUploadMaxSize = this.chunkedUploadMaxSize ?: OCCapability.CHUNKED_UPLOAD_MAX_SIZE_UNKNOWN + capability.serverBackgroundDefault = intToBoolean(serverBackgroundDefault) + capability.serverBackgroundPlain = intToBoolean(serverBackgroundPlain) + capability.activity = intToBoolean(activity) + capability.richDocuments = intToBoolean(richdocument) + capability.richDocumentsDirectEditing = intToBoolean(richdocumentDirectEditing) + capability.richDocumentsTemplatesAvailable = intToBoolean(richdocumentTemplates) + capability.richDocumentsMimeTypeList = richdocumentMimetypeList.orEmpty().split(MIME_TYPE_SEPARATOR) + capability.richDocumentsOptionalMimeTypeList = + richdocumentOptionalMimetypeList.orEmpty().split(MIME_TYPE_SEPARATOR) + capability.richDocumentsProductName = richdocumentProductName + capability.directEditingEtag = directEditingEtag + capability.etag = etag + capability.userStatus = intToBoolean(userStatus) + capability.userStatusSupportsEmoji = intToBoolean(userStatusSupportsEmoji) + capability.userStatusSupportsBusy = intToBoolean(userStatusSupportsBusy) + capability.filesLockingVersion = filesLockingVersion + capability.assistant = intToBoolean(assistant) + capability.groupfolders = intToBoolean(groupfolders) + capability.dropAccount = intToBoolean(dropAccount) + capability.securityGuard = intToBoolean(securityGuard) + capability.governance = intToBoolean(governance) + capability.forbiddenFilenameCharactersJson = forbiddenFileNameCharacters + capability.forbiddenFilenamesJson = forbiddenFileNames + capability.forbiddenFilenameExtensionJson = forbiddenFileNameExtensions + capability.forbiddenFilenameBaseNamesJson = forbiddenFilenameBaseNames + capability.isWCFEnabled = intToBoolean(isWCFEnabled) + capability.filesDownloadLimit = intToBoolean(filesDownloadLimit) + capability.filesDownloadLimitDefault = filesDownloadLimitDefault ?: 0 + capability.recommendations = intToBoolean(recommendation) + capability.notesFolderPath = notesFolderPath + capability.defaultPermissions = defaultPermissions ?: 0 + capability.hasValidSubscription = intToBoolean(hasValidSubscription) + capability.clientIntegrationJson = clientIntegrationJson + capability.modRewriteWorking = intToBoolean(modRewriteWorking) + capability.chunkedUploadMaxSize = chunkedUploadMaxSize ?: 0L + capability.sharingJson = sharingJson return capability } + +@Suppress("LongMethod") +fun OCCapability.toEntity(accountName: String, id: Int?): CapabilityEntity = CapabilityEntity( + id = id, + assistant = assistant.value, + accountName = accountName, + versionMajor = versionMayor, + versionMinor = versionMinor, + versionMicro = versionMicro, + versionString = versionString, + versionEditor = versionEdition, + extendedSupport = extendedSupport.value, + corePollinterval = corePollInterval, + sharingApiEnabled = filesSharingApiEnabled.value, + sharingPublicEnabled = filesSharingPublicEnabled.value, + sharingPublicPasswordEnforced = filesSharingPublicPasswordEnforced.value, + sharingPublicExpireDateEnabled = filesSharingPublicExpireDateEnabled.value, + sharingPublicExpireDateDays = filesSharingPublicExpireDateDays, + sharingPublicExpireDateEnforced = filesSharingPublicExpireDateEnforced.value, + sharingPublicSendMail = filesSharingPublicSendMail.value, + sharingPublicUpload = filesSharingPublicUpload.value, + sharingUserSendMail = filesSharingUserSendMail.value, + sharingResharing = filesSharingResharing.value, + sharingFederationOutgoing = filesSharingFederationOutgoing.value, + sharingFederationIncoming = filesSharingFederationIncoming.value, + filesBigfilechunking = filesBigFileChunking.value, + filesUndelete = filesUndelete.value, + filesVersioning = filesVersioning.value, + externalLinks = externalLinks.value, + serverName = serverName, + serverColor = serverColor, + serverTextColor = serverTextColor, + serverElementColor = serverElementColor, + serverSlogan = serverSlogan, + serverLogo = serverLogo, + serverBackgroundUrl = serverBackground, + endToEndEncryption = endToEndEncryption.value, + endToEndEncryptionKeysExist = endToEndEncryptionKeysExist.value, + endToEndEncryptionApiVersion = endToEndEncryptionApiVersion.value, + activity = activity.value, + serverBackgroundDefault = serverBackgroundDefault.value, + serverBackgroundPlain = serverBackgroundPlain.value, + richdocument = richDocuments.value, + richdocumentMimetypeList = richDocumentsMimeTypeList?.joinToString(MIME_TYPE_SEPARATOR), + richdocumentDirectEditing = richDocumentsDirectEditing.value, + richdocumentTemplates = richDocumentsTemplatesAvailable.value, + richdocumentOptionalMimetypeList = richDocumentsOptionalMimeTypeList?.joinToString(MIME_TYPE_SEPARATOR), + sharingPublicAskForOptionalPassword = filesSharingPublicAskForOptionalPassword.value, + richdocumentProductName = richDocumentsProductName, + directEditingEtag = directEditingEtag, + userStatus = userStatus.value, + userStatusSupportsEmoji = userStatusSupportsEmoji.value, + etag = etag, + filesLockingVersion = filesLockingVersion, + groupfolders = groupfolders.value, + dropAccount = dropAccount.value, + securityGuard = securityGuard.value, + governance = governance.value, + forbiddenFileNameCharacters = forbiddenFilenameCharactersJson, + forbiddenFileNames = forbiddenFilenamesJson, + forbiddenFileNameExtensions = forbiddenFilenameExtensionJson, + forbiddenFilenameBaseNames = forbiddenFilenameBaseNamesJson, + filesDownloadLimit = filesDownloadLimit.value, + filesDownloadLimitDefault = filesDownloadLimitDefault, + recommendation = recommendations.value, + notesFolderPath = notesFolderPath, + defaultPermissions = defaultPermissions, + userStatusSupportsBusy = userStatusSupportsBusy.value, + isWCFEnabled = isWCFEnabled.value, + hasValidSubscription = hasValidSubscription.value, + clientIntegrationJson = clientIntegrationJson, + modRewriteWorking = modRewriteWorking.value, + chunkedUploadMaxSize = chunkedUploadMaxSize, + sharingJson = sharingJson +) + +private const val MIME_TYPE_SEPARATOR = "," diff --git a/app/src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.java b/app/src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.java index ae793c845797..8e81d128f466 100644 --- a/app/src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.java +++ b/app/src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.java @@ -36,6 +36,8 @@ import com.nextcloud.client.database.dao.OfflineOperationDao; import com.nextcloud.client.database.dao.RecommendedFileDao; import com.nextcloud.client.database.dao.ShareDao; +import com.nextcloud.client.database.entity.CapabilityEntity; +import com.nextcloud.client.database.entity.CapabilityEntityKt; import com.nextcloud.client.database.entity.FileEntity; import com.nextcloud.client.database.entity.OfflineOperationEntity; import com.nextcloud.client.jobs.offlineOperations.repository.OfflineOperationsRepository; @@ -64,7 +66,6 @@ import com.owncloud.android.lib.resources.shares.OCShare; import com.owncloud.android.lib.resources.shares.ShareType; import com.owncloud.android.lib.resources.shares.ShareeUser; -import com.owncloud.android.lib.resources.status.CapabilityBooleanType; import com.owncloud.android.lib.resources.status.E2EVersion; import com.owncloud.android.lib.resources.status.OCCapability; import com.owncloud.android.lib.resources.tags.Tag; @@ -2128,212 +2129,17 @@ public void saveConflict(OCFile ocFile, String etagInConflict) { } public void saveCapabilities(OCCapability capability) { - // Prepare capabilities data - ContentValues contentValues = createContentValues(user.getAccountName(), capability); + final String accountName = user.getAccountName(); + final CapabilityEntity existing = capabilityDao.getByAccountName(accountName); + final Integer existingId = existing != null ? existing.getId() : null; + final long rowId = capabilityDao.upsert(CapabilityEntityKt.toEntity(capability, accountName, existingId)); - if (capabilityExists(user.getAccountName())) { - if (getContentResolver() != null) { - getContentResolver().update(ProviderTableMeta.CONTENT_URI_CAPABILITIES, contentValues, - ProviderTableMeta.CAPABILITIES_ACCOUNT_NAME + "=?", - new String[]{user.getAccountName()}); - } else { - try { - getContentProviderClient().update(ProviderTableMeta.CONTENT_URI_CAPABILITIES, - contentValues, ProviderTableMeta.CAPABILITIES_ACCOUNT_NAME + "=?", - new String[]{user.getAccountName()}); - } catch (RemoteException e) { - Log_OC.e(TAG, FAILED_TO_INSERT_MSG + e.getMessage(), e); - } - } - } else { - Uri result_uri = null; - if (getContentResolver() != null) { - result_uri = getContentResolver().insert( - ProviderTableMeta.CONTENT_URI_CAPABILITIES, contentValues); - } else { - try { - result_uri = getContentProviderClient().insert( - ProviderTableMeta.CONTENT_URI_CAPABILITIES, contentValues); - } catch (RemoteException e) { - Log_OC.e(TAG, FAILED_TO_INSERT_MSG + e.getMessage(), e); - } - } - if (result_uri != null) { - long new_id = Long.parseLong(result_uri.getPathSegments() - .get(1)); - capability.setId(new_id); - capability.setAccountName(user.getAccountName()); - } - } - } - - @NonNull - private ContentValues createContentValues(String accountName, OCCapability capability) { - ContentValues contentValues = new ContentValues(); - contentValues.put(ProviderTableMeta.CAPABILITIES_ACCOUNT_NAME, - accountName); - contentValues.put(ProviderTableMeta.CAPABILITIES_VERSION_MAYOR, - capability.getVersionMayor()); - contentValues.put(ProviderTableMeta.CAPABILITIES_VERSION_MINOR, - capability.getVersionMinor()); - contentValues.put(ProviderTableMeta.CAPABILITIES_VERSION_MICRO, - capability.getVersionMicro()); - contentValues.put(ProviderTableMeta.CAPABILITIES_VERSION_STRING, - capability.getVersionString()); - contentValues.put(ProviderTableMeta.CAPABILITIES_VERSION_EDITION, - capability.getVersionEdition()); - contentValues.put(ProviderTableMeta.CAPABILITIES_EXTENDED_SUPPORT, - capability.getExtendedSupport().getValue()); - contentValues.put(ProviderTableMeta.CAPABILITIES_CORE_POLLINTERVAL, - capability.getCorePollInterval()); - contentValues.put(ProviderTableMeta.CAPABILITIES_SHARING_API_ENABLED, - capability.getFilesSharingApiEnabled().getValue()); - contentValues.put(ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_ENABLED, - capability.getFilesSharingPublicEnabled().getValue()); - contentValues.put(ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_PASSWORD_ENFORCED, - capability.getFilesSharingPublicPasswordEnforced().getValue()); - contentValues.put(ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_ASK_FOR_OPTIONAL_PASSWORD, - capability.getFilesSharingPublicAskForOptionalPassword().getValue()); - contentValues.put(ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_EXPIRE_DATE_ENABLED, - capability.getFilesSharingPublicExpireDateEnabled().getValue()); - contentValues.put(ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_EXPIRE_DATE_DAYS, - capability.getFilesSharingPublicExpireDateDays()); - contentValues.put(ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_EXPIRE_DATE_ENFORCED, - capability.getFilesSharingPublicExpireDateEnforced().getValue()); - contentValues.put(ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_SEND_MAIL, - capability.getFilesSharingPublicSendMail().getValue()); - contentValues.put(ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_UPLOAD, - capability.getFilesSharingPublicUpload().getValue()); - contentValues.put(ProviderTableMeta.CAPABILITIES_SHARING_USER_SEND_MAIL, - capability.getFilesSharingUserSendMail().getValue()); - contentValues.put(ProviderTableMeta.CAPABILITIES_SHARING_RESHARING, - capability.getFilesSharingResharing().getValue()); - contentValues.put(ProviderTableMeta.CAPABILITIES_SHARING_FEDERATION_OUTGOING, - capability.getFilesSharingFederationOutgoing().getValue()); - contentValues.put(ProviderTableMeta.CAPABILITIES_SHARING_FEDERATION_INCOMING, - capability.getFilesSharingFederationIncoming().getValue()); - contentValues.put(ProviderTableMeta.CAPABILITIES_FILES_BIGFILECHUNKING, - capability.getFilesBigFileChunking().getValue()); - contentValues.put(ProviderTableMeta.CAPABILITIES_FILES_UNDELETE, - capability.getFilesUndelete().getValue()); - contentValues.put(ProviderTableMeta.CAPABILITIES_FILES_VERSIONING, - capability.getFilesVersioning().getValue()); - contentValues.put(ProviderTableMeta.CAPABILITIES_EXTERNAL_LINKS, - capability.getExternalLinks().getValue()); - contentValues.put(ProviderTableMeta.CAPABILITIES_SERVER_NAME, - capability.getServerName()); - contentValues.put(ProviderTableMeta.CAPABILITIES_SERVER_COLOR, - capability.getServerColor()); - contentValues.put(ProviderTableMeta.CAPABILITIES_SERVER_TEXT_COLOR, - capability.getServerTextColor()); - contentValues.put(ProviderTableMeta.CAPABILITIES_SERVER_ELEMENT_COLOR, - capability.getServerElementColor()); - contentValues.put(ProviderTableMeta.CAPABILITIES_SERVER_BACKGROUND_URL, - capability.getServerBackground()); - contentValues.put(ProviderTableMeta.CAPABILITIES_SERVER_SLOGAN, - capability.getServerSlogan()); - contentValues.put(ProviderTableMeta.CAPABILITIES_SERVER_LOGO, - capability.getServerLogo()); - contentValues.put(ProviderTableMeta.CAPABILITIES_END_TO_END_ENCRYPTION, - capability.getEndToEndEncryption().getValue()); - contentValues.put(ProviderTableMeta.CAPABILITIES_END_TO_END_ENCRYPTION_KEYS_EXIST, - capability.getEndToEndEncryptionKeysExist().getValue()); - contentValues.put(ProviderTableMeta.CAPABILITIES_END_TO_END_ENCRYPTION_API_VERSION, - capability.getEndToEndEncryptionApiVersion().getValue()); - contentValues.put(ProviderTableMeta.CAPABILITIES_SERVER_BACKGROUND_DEFAULT, - capability.getServerBackgroundDefault().getValue()); - contentValues.put(ProviderTableMeta.CAPABILITIES_SERVER_BACKGROUND_PLAIN, - capability.getServerBackgroundPlain().getValue()); - contentValues.put(ProviderTableMeta.CAPABILITIES_ACTIVITY, - capability.getActivity().getValue()); - contentValues.put(ProviderTableMeta.CAPABILITIES_RICHDOCUMENT, - capability.getRichDocuments().getValue()); - contentValues.put(ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_MIMETYPE_LIST, - TextUtils.join(",", capability.getRichDocumentsMimeTypeList())); - contentValues.put(ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_OPTIONAL_MIMETYPE_LIST, - TextUtils.join(",", capability.getRichDocumentsOptionalMimeTypeList())); - contentValues.put(ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_DIRECT_EDITING, - capability.getRichDocumentsDirectEditing().getValue()); - contentValues.put(ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_TEMPLATES, - capability.getRichDocumentsTemplatesAvailable().getValue()); - contentValues.put(ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_PRODUCT_NAME, - capability.getRichDocumentsProductName()); - contentValues.put(ProviderTableMeta.CAPABILITIES_DIRECT_EDITING_ETAG, - capability.getDirectEditingEtag()); - contentValues.put(ProviderTableMeta.CAPABILITIES_ETAG, capability.getEtag()); - contentValues.put(ProviderTableMeta.CAPABILITIES_USER_STATUS, capability.getUserStatus().getValue()); - contentValues.put(ProviderTableMeta.CAPABILITIES_USER_STATUS_SUPPORTS_EMOJI, - capability.getUserStatusSupportsEmoji().getValue()); - contentValues.put(ProviderTableMeta.CAPABILITIES_USER_STATUS_SUPPORTS_BUSY, - capability.getUserStatusSupportsBusy().getValue()); - contentValues.put(ProviderTableMeta.CAPABILITIES_FILES_LOCKING_VERSION, - capability.getFilesLockingVersion()); - contentValues.put(ProviderTableMeta.CAPABILITIES_ASSISTANT, capability.getAssistant().getValue()); - contentValues.put(ProviderTableMeta.CAPABILITIES_GROUPFOLDERS, capability.getGroupfolders().getValue()); - contentValues.put(ProviderTableMeta.CAPABILITIES_DROP_ACCOUNT, capability.getDropAccount().getValue()); - contentValues.put(ProviderTableMeta.CAPABILITIES_SECURITY_GUARD, capability.getSecurityGuard().getValue()); - contentValues.put(ProviderTableMeta.CAPABILITIES_GOVERNANCE, capability.getGovernance().getValue()); - - contentValues.put(ProviderTableMeta.CAPABILITIES_FORBIDDEN_FILENAME_CHARACTERS, capability.getForbiddenFilenameCharactersJson()); - contentValues.put(ProviderTableMeta.CAPABILITIES_FORBIDDEN_FILENAMES, capability.getForbiddenFilenamesJson()); - contentValues.put(ProviderTableMeta.CAPABILITIES_FORBIDDEN_FORBIDDEN_FILENAME_EXTENSIONS, capability.getForbiddenFilenameExtensionJson()); - contentValues.put(ProviderTableMeta.CAPABILITIES_FORBIDDEN_FORBIDDEN_FILENAME_BASE_NAMES, capability.getForbiddenFilenameBaseNamesJson()); - contentValues.put(ProviderTableMeta.CAPABILITIES_WINDOWS_COMPATIBLE_FILENAMES, capability.isWCFEnabled().getValue()); - contentValues.put(ProviderTableMeta.CAPABILITIES_FILES_DOWNLOAD_LIMIT, capability.getFilesDownloadLimit().getValue()); - contentValues.put(ProviderTableMeta.CAPABILITIES_FILES_DOWNLOAD_LIMIT_DEFAULT, capability.getFilesDownloadLimitDefault()); - - contentValues.put(ProviderTableMeta.CAPABILITIES_RECOMMENDATION, capability.getRecommendations().getValue()); - - contentValues.put(ProviderTableMeta.CAPABILITIES_NOTES_FOLDER_PATH, capability.getNotesFolderPath()); - - contentValues.put(ProviderTableMeta.CAPABILITIES_DEFAULT_PERMISSIONS, capability.getDefaultPermissions()); - - contentValues.put(ProviderTableMeta.CAPABILITIES_HAS_VALID_SUBSCRIPTION, capability.getHasValidSubscription().getValue()); - - contentValues.put(ProviderTableMeta.CAPABILITIES_CLIENT_INTEGRATION_JSON, capability.getClientIntegrationJson()); - - contentValues.put(ProviderTableMeta.CAPABILITIES_MOD_REWRITE_WORKING, capability.getModRewriteWorking().getValue()); - - contentValues.put(ProviderTableMeta.CAPABILITIES_CHUNKED_UPLOAD_MAX_SIZE, capability.getChunkedUploadMaxSize()); - - contentValues.put(ProviderTableMeta.CAPABILITIES_SHARING_JSON, capability.getSharingJson()); - - return contentValues; - } - - private boolean capabilityExists(String accountName) { - Cursor cursor = getCapabilityCursorForAccount(accountName); - boolean exists = false; - - if (cursor != null) { - exists = cursor.moveToFirst(); - cursor.close(); - } - - return exists; - } - - private Cursor getCapabilityCursorForAccount(String accountName) { - Cursor cursor = null; - if (getContentResolver() != null) { - cursor = getContentResolver() - .query(ProviderTableMeta.CONTENT_URI_CAPABILITIES, - null, - ProviderTableMeta.CAPABILITIES_ACCOUNT_NAME + "=? ", - new String[]{accountName}, null); - } else { - try { - cursor = getContentProviderClient().query( - ProviderTableMeta.CONTENT_URI_CAPABILITIES, - null, - ProviderTableMeta.CAPABILITIES_ACCOUNT_NAME + "=? ", - new String[]{accountName}, null); - } catch (RemoteException e) { - Log_OC.e(TAG, "Couldn't determine capability existence, assuming non existance: " + e.getMessage(), e); - } + if (existingId != null) { + return; } - return cursor; + capability.setId(rowId); + capability.setAccountName(accountName); } public String getE2EEVersion(@NonNull User user) { @@ -2353,159 +2159,11 @@ public OCCapability getCapability(User user) { @NonNull public OCCapability getCapability(String accountName) { - OCCapability capability; - Cursor cursor = getCapabilityCursorForAccount(accountName); - - if (cursor.moveToFirst()) { - capability = createCapabilityInstance(cursor); - } else { - capability = new OCCapability(); // return default with all UNKNOWN - } - cursor.close(); - - return capability; + return CapabilityEntityKt.toOCCapability(capabilityDao.getByAccountName(accountName)); } public boolean capabilityExistsForAccount(String accountName) { - Cursor cursor = getCapabilityCursorForAccount(accountName); - - boolean exists = cursor.moveToFirst(); - cursor.close(); - - return exists; - } - - private OCCapability createCapabilityInstance(Cursor cursor) { - OCCapability capability = null; - if (cursor != null) { - capability = new OCCapability(); - capability.setId(getLong(cursor, ProviderTableMeta._ID)); - capability.setAccountName(getString(cursor, ProviderTableMeta.CAPABILITIES_ACCOUNT_NAME)); - capability.setVersionMayor(getInt(cursor, ProviderTableMeta.CAPABILITIES_VERSION_MAYOR)); - capability.setVersionMinor(getInt(cursor, ProviderTableMeta.CAPABILITIES_VERSION_MINOR)); - capability.setVersionMicro(getInt(cursor, ProviderTableMeta.CAPABILITIES_VERSION_MICRO)); - capability.setVersionString(getString(cursor, ProviderTableMeta.CAPABILITIES_VERSION_STRING)); - capability.setVersionEdition(getString(cursor, ProviderTableMeta.CAPABILITIES_VERSION_EDITION)); - capability.setExtendedSupport(getBoolean(cursor, ProviderTableMeta.CAPABILITIES_EXTENDED_SUPPORT)); - capability.setCorePollInterval(getInt(cursor, ProviderTableMeta.CAPABILITIES_CORE_POLLINTERVAL)); - capability.setFilesSharingApiEnabled(getBoolean(cursor, - ProviderTableMeta.CAPABILITIES_SHARING_API_ENABLED)); - capability.setFilesSharingPublicEnabled(getBoolean(cursor, - ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_ENABLED)); - capability.setFilesSharingPublicPasswordEnforced( - getBoolean(cursor, ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_PASSWORD_ENFORCED)); - capability.setFilesSharingPublicAskForOptionalPassword( - getBoolean(cursor, ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_ASK_FOR_OPTIONAL_PASSWORD)); - capability.setFilesSharingPublicExpireDateEnabled( - getBoolean(cursor, ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_EXPIRE_DATE_ENABLED)); - capability.setFilesSharingPublicExpireDateDays( - getInt(cursor, ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_EXPIRE_DATE_DAYS)); - capability.setFilesSharingPublicExpireDateEnforced( - getBoolean(cursor, ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_EXPIRE_DATE_ENFORCED)); - capability.setFilesSharingPublicSendMail( - getBoolean(cursor, ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_SEND_MAIL)); - capability.setFilesSharingPublicUpload(getBoolean(cursor, - ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_UPLOAD)); - capability.setFilesSharingUserSendMail(getBoolean(cursor, - ProviderTableMeta.CAPABILITIES_SHARING_USER_SEND_MAIL)); - capability.setFilesSharingResharing(getBoolean(cursor, - ProviderTableMeta.CAPABILITIES_SHARING_RESHARING)); - capability.setFilesSharingFederationOutgoing( - getBoolean(cursor, ProviderTableMeta.CAPABILITIES_SHARING_FEDERATION_OUTGOING)); - capability.setFilesSharingFederationIncoming( - getBoolean(cursor, ProviderTableMeta.CAPABILITIES_SHARING_FEDERATION_INCOMING)); - capability.setFilesBigFileChunking(getBoolean(cursor, - ProviderTableMeta.CAPABILITIES_FILES_BIGFILECHUNKING)); - capability.setFilesUndelete(getBoolean(cursor, ProviderTableMeta.CAPABILITIES_FILES_UNDELETE)); - capability.setFilesVersioning(getBoolean(cursor, ProviderTableMeta.CAPABILITIES_FILES_VERSIONING)); - capability.setExternalLinks(getBoolean(cursor, ProviderTableMeta.CAPABILITIES_EXTERNAL_LINKS)); - capability.setServerName(getString(cursor, ProviderTableMeta.CAPABILITIES_SERVER_NAME)); - capability.setServerColor(getString(cursor, ProviderTableMeta.CAPABILITIES_SERVER_COLOR)); - capability.setServerTextColor(getString(cursor, ProviderTableMeta.CAPABILITIES_SERVER_TEXT_COLOR)); - capability.setServerElementColor(getString(cursor, ProviderTableMeta.CAPABILITIES_SERVER_ELEMENT_COLOR)); - capability.setServerBackground(getString(cursor, ProviderTableMeta.CAPABILITIES_SERVER_BACKGROUND_URL)); - capability.setServerSlogan(getString(cursor, ProviderTableMeta.CAPABILITIES_SERVER_SLOGAN)); - capability.setServerLogo(getString(cursor, ProviderTableMeta.CAPABILITIES_SERVER_LOGO)); - capability.setEndToEndEncryption(getBoolean(cursor, ProviderTableMeta.CAPABILITIES_END_TO_END_ENCRYPTION)); - capability.setEndToEndEncryptionKeysExist( - getBoolean(cursor, - ProviderTableMeta.CAPABILITIES_END_TO_END_ENCRYPTION_KEYS_EXIST) - ); - - String e2eVersionString = getString(cursor, ProviderTableMeta.CAPABILITIES_END_TO_END_ENCRYPTION_API_VERSION); - E2EVersion e2EVersion; - if (e2eVersionString == null) { - e2EVersion = E2EVersion.UNKNOWN; - } else { - e2EVersion = E2EVersion.fromValue(e2eVersionString); - } - capability.setEndToEndEncryptionApiVersion(e2EVersion); - - capability.setServerBackgroundDefault( - getBoolean(cursor, ProviderTableMeta.CAPABILITIES_SERVER_BACKGROUND_DEFAULT)); - capability.setServerBackgroundPlain(getBoolean(cursor, - ProviderTableMeta.CAPABILITIES_SERVER_BACKGROUND_PLAIN)); - capability.setActivity(getBoolean(cursor, ProviderTableMeta.CAPABILITIES_ACTIVITY)); - capability.setRichDocuments(getBoolean(cursor, ProviderTableMeta.CAPABILITIES_RICHDOCUMENT)); - capability.setRichDocumentsDirectEditing( - getBoolean(cursor, ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_DIRECT_EDITING)); - capability.setRichDocumentsTemplatesAvailable( - getBoolean(cursor, ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_TEMPLATES)); - String mimetypes = getString(cursor, ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_MIMETYPE_LIST); - if (mimetypes == null) { - mimetypes = ""; - } - capability.setRichDocumentsMimeTypeList(Arrays.asList(mimetypes.split(","))); - - String optionalMimetypes = getString(cursor, - ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_OPTIONAL_MIMETYPE_LIST); - if (optionalMimetypes == null) { - optionalMimetypes = ""; - } - capability.setRichDocumentsOptionalMimeTypeList(Arrays.asList(optionalMimetypes.split(","))); - capability.setRichDocumentsProductName(getString(cursor, - ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_PRODUCT_NAME)); - capability.setDirectEditingEtag(getString(cursor, ProviderTableMeta.CAPABILITIES_DIRECT_EDITING_ETAG)); - capability.setEtag(getString(cursor, ProviderTableMeta.CAPABILITIES_ETAG)); - capability.setUserStatus(getBoolean(cursor, ProviderTableMeta.CAPABILITIES_USER_STATUS)); - capability.setUserStatusSupportsEmoji( - getBoolean(cursor, ProviderTableMeta.CAPABILITIES_USER_STATUS_SUPPORTS_EMOJI)); - capability.setUserStatusSupportsBusy( - getBoolean(cursor, ProviderTableMeta.CAPABILITIES_USER_STATUS_SUPPORTS_BUSY)); - capability.setFilesLockingVersion( - getString(cursor, ProviderTableMeta.CAPABILITIES_FILES_LOCKING_VERSION)); - capability.setAssistant(getBoolean(cursor, ProviderTableMeta.CAPABILITIES_ASSISTANT)); - capability.setGroupfolders(getBoolean(cursor, ProviderTableMeta.CAPABILITIES_GROUPFOLDERS)); - capability.setDropAccount(getBoolean(cursor, ProviderTableMeta.CAPABILITIES_DROP_ACCOUNT)); - capability.setSecurityGuard(getBoolean(cursor, ProviderTableMeta.CAPABILITIES_SECURITY_GUARD)); - capability.setGovernance(getBoolean(cursor, ProviderTableMeta.CAPABILITIES_GOVERNANCE)); - - capability.setForbiddenFilenameCharactersJson(getString(cursor, ProviderTableMeta.CAPABILITIES_FORBIDDEN_FILENAME_CHARACTERS)); - capability.setForbiddenFilenamesJson(getString(cursor, ProviderTableMeta.CAPABILITIES_FORBIDDEN_FILENAMES)); - capability.setForbiddenFilenameExtensionJson(getString(cursor, ProviderTableMeta.CAPABILITIES_FORBIDDEN_FORBIDDEN_FILENAME_EXTENSIONS)); - capability.setForbiddenFilenameBaseNamesJson(getString(cursor, ProviderTableMeta.CAPABILITIES_FORBIDDEN_FORBIDDEN_FILENAME_BASE_NAMES)); - capability.setWCFEnabled(getBoolean(cursor, ProviderTableMeta.CAPABILITIES_WINDOWS_COMPATIBLE_FILENAMES)); - capability.setFilesDownloadLimit(getBoolean(cursor, ProviderTableMeta.CAPABILITIES_FILES_DOWNLOAD_LIMIT)); - capability.setFilesDownloadLimitDefault(getInt(cursor, ProviderTableMeta.CAPABILITIES_FILES_DOWNLOAD_LIMIT_DEFAULT)); - - capability.setRecommendations(getBoolean(cursor, ProviderTableMeta.CAPABILITIES_RECOMMENDATION)); - - capability.setNotesFolderPath(getString(cursor, ProviderTableMeta.CAPABILITIES_NOTES_FOLDER_PATH)); - - capability.setDefaultPermissions(getInt(cursor, ProviderTableMeta.CAPABILITIES_DEFAULT_PERMISSIONS)); - capability.setHasValidSubscription(getBoolean(cursor, ProviderTableMeta.CAPABILITIES_HAS_VALID_SUBSCRIPTION)); - - capability.setClientIntegrationJson(getString(cursor, ProviderTableMeta.CAPABILITIES_CLIENT_INTEGRATION_JSON)); - - capability.setModRewriteWorking(getBoolean(cursor, ProviderTableMeta.CAPABILITIES_MOD_REWRITE_WORKING)); - - capability.setChunkedUploadMaxSize( - getLong(cursor, ProviderTableMeta.CAPABILITIES_CHUNKED_UPLOAD_MAX_SIZE)); - - capability.setSharingJson(getString(cursor, ProviderTableMeta.CAPABILITIES_SHARING_JSON)); - } - - return capability; + return capabilityDao.getByAccountName(accountName) != null; } public void deleteVirtuals(VirtualFolderType type) { @@ -2744,10 +2402,6 @@ private long getLong(Cursor cursor, String columnName) { return cursor.getLong(cursor.getColumnIndexOrThrow(columnName)); } - private CapabilityBooleanType getBoolean(Cursor cursor, String columnName) { - return CapabilityBooleanType.fromValue(cursor.getInt(cursor.getColumnIndexOrThrow(columnName))); - } - public ContentResolver getContentResolver() { return this.contentResolver; } diff --git a/app/src/main/java/com/owncloud/android/db/ProviderMeta.java b/app/src/main/java/com/owncloud/android/db/ProviderMeta.java index 3886a51210d6..28eab9cdaeb9 100644 --- a/app/src/main/java/com/owncloud/android/db/ProviderMeta.java +++ b/app/src/main/java/com/owncloud/android/db/ProviderMeta.java @@ -69,8 +69,6 @@ static public class ProviderTableMeta implements BaseColumns { + MainApp.getAuthority() + "/dir"); public static final Uri CONTENT_URI_SHARE = Uri.parse(CONTENT_PREFIX + MainApp.getAuthority() + "/shares"); - public static final Uri CONTENT_URI_CAPABILITIES = Uri.parse(CONTENT_PREFIX - + MainApp.getAuthority() + "/capabilities"); public static final Uri CONTENT_URI_UPLOADS = Uri.parse(CONTENT_PREFIX + MainApp.getAuthority() + "/uploads"); public static final Uri CONTENT_URI_SYNCED_FOLDERS = Uri.parse(CONTENT_PREFIX @@ -274,8 +272,6 @@ static public class ProviderTableMeta implements BaseColumns { public static final String CAPABILITIES_RICHDOCUMENT_DIRECT_EDITING = "richdocument_direct_editing"; public static final String CAPABILITIES_RICHDOCUMENT_TEMPLATES = "richdocument_direct_templates"; public static final String CAPABILITIES_RICHDOCUMENT_PRODUCT_NAME = "richdocument_product_name"; - public static final String CAPABILITIES_DEFAULT_SORT_ORDER = CAPABILITIES_ACCOUNT_NAME - + " collate nocase asc"; public static final String CAPABILITIES_DIRECT_EDITING_ETAG = "direct_editing_etag"; public static final String CAPABILITIES_ETAG = "etag"; public static final String CAPABILITIES_USER_STATUS = "user_status"; diff --git a/app/src/main/java/com/owncloud/android/providers/FileContentProvider.java b/app/src/main/java/com/owncloud/android/providers/FileContentProvider.java index fb87de46c992..bef3e6a72abe 100644 --- a/app/src/main/java/com/owncloud/android/providers/FileContentProvider.java +++ b/app/src/main/java/com/owncloud/android/providers/FileContentProvider.java @@ -62,7 +62,6 @@ public class FileContentProvider extends ContentProvider { private static final int DIRECTORY = 2; private static final int ROOT_DIRECTORY = 3; private static final int SHARES = 4; - private static final int CAPABILITIES = 5; private static final int UPLOADS = 6; private static final int SYNCED_FOLDERS = 7; private static final int EXTERNAL_LINKS = 8; @@ -137,7 +136,6 @@ private int delete(SupportSQLiteDatabase db, Uri uri, String where, String... wh case DIRECTORY -> deleteDirectory(db, uri, where, whereArgs); case ROOT_DIRECTORY -> db.delete(ProviderTableMeta.FILE_TABLE_NAME, where, whereArgs); case SHARES -> db.delete(ProviderTableMeta.OCSHARES_TABLE_NAME, where, whereArgs); - case CAPABILITIES -> db.delete(ProviderTableMeta.CAPABILITIES_TABLE_NAME, where, whereArgs); case UPLOADS -> db.delete(ProviderTableMeta.UPLOADS_TABLE_NAME, where, whereArgs); case SYNCED_FOLDERS -> db.delete(ProviderTableMeta.SYNCED_FOLDERS_TABLE_NAME, where, whereArgs); case EXTERNAL_LINKS -> db.delete(ProviderTableMeta.EXTERNAL_LINKS_TABLE_NAME, where, whereArgs); @@ -266,16 +264,6 @@ private Uri insert(SupportSQLiteDatabase db, Uri uri, ContentValues values) { return insertedShareUri; - case CAPABILITIES: - Uri insertedCapUri; - long idCapabilities = db.insert(ProviderTableMeta.CAPABILITIES_TABLE_NAME, SQLiteDatabase.CONFLICT_REPLACE, values); - if (idCapabilities > 0) { - insertedCapUri = ContentUris.withAppendedId(ProviderTableMeta.CONTENT_URI_CAPABILITIES, idCapabilities); - } else { - throw new SQLException(ERROR + uri); - } - return insertedCapUri; - case UPLOADS: Uri insertedUploadUri; long uploadId = db.insert(ProviderTableMeta.UPLOADS_TABLE_NAME, SQLiteDatabase.CONFLICT_REPLACE, values); @@ -418,8 +406,6 @@ public boolean onCreate() { mUriMatcher.addURI(authority, "dir/#", DIRECTORY); mUriMatcher.addURI(authority, "shares/", SHARES); mUriMatcher.addURI(authority, "shares/#", SHARES); - mUriMatcher.addURI(authority, "capabilities/", CAPABILITIES); - mUriMatcher.addURI(authority, "capabilities/#", CAPABILITIES); mUriMatcher.addURI(authority, "uploads/", UPLOADS); mUriMatcher.addURI(authority, "uploads/#", UPLOADS); mUriMatcher.addURI(authority, "synced_folders", SYNCED_FOLDERS); @@ -475,7 +461,6 @@ private Cursor query(SupportSQLiteDatabase db, yield ProviderTableMeta.FILE_TABLE_NAME; } case SHARES -> ProviderTableMeta.OCSHARES_TABLE_NAME; - case CAPABILITIES -> ProviderTableMeta.CAPABILITIES_TABLE_NAME; case UPLOADS -> ProviderTableMeta.UPLOADS_TABLE_NAME; case SYNCED_FOLDERS -> ProviderTableMeta.SYNCED_FOLDERS_TABLE_NAME; case EXTERNAL_LINKS -> ProviderTableMeta.EXTERNAL_LINKS_TABLE_NAME; @@ -500,7 +485,6 @@ private Cursor query(SupportSQLiteDatabase db, if (TextUtils.isEmpty(sortOrder)) { order = switch (uriMatch) { case SHARES -> ProviderTableMeta.OCSHARES_DEFAULT_SORT_ORDER; - case CAPABILITIES -> ProviderTableMeta.CAPABILITIES_DEFAULT_SORT_ORDER; case UPLOADS -> ProviderTableMeta.UPLOADS_DEFAULT_SORT_ORDER; case SYNCED_FOLDERS -> ProviderTableMeta.SYNCED_FOLDER_LOCAL_PATH; case EXTERNAL_LINKS -> ProviderTableMeta.EXTERNAL_LINKS_NAME; @@ -587,8 +571,6 @@ private int update(SupportSQLiteDatabase db, Uri uri, ContentValues values, Stri case DIRECTORY -> 0; case SHARES -> db.update(ProviderTableMeta.OCSHARES_TABLE_NAME, SQLiteDatabase.CONFLICT_REPLACE, values, selection, selectionArgs); - case CAPABILITIES -> - db.update(ProviderTableMeta.CAPABILITIES_TABLE_NAME, SQLiteDatabase.CONFLICT_REPLACE, values, selection, selectionArgs); case UPLOADS -> db.update(ProviderTableMeta.UPLOADS_TABLE_NAME, SQLiteDatabase.CONFLICT_REPLACE, values, selection, selectionArgs); case SYNCED_FOLDERS -> @@ -647,7 +629,7 @@ public ContentProviderResult[] applyBatch(@NonNull ArrayList { + case SHARES, UPLOADS, SYNCED_FOLDERS, EXTERNAL_LINKS, VIRTUAL, FILESYSTEM -> { String callingPackage = mContext.getPackageManager().getNameForUid(Binder.getCallingUid()); yield callingPackage == null || !callingPackage.equals(mContext.getPackageName()); } From 04a70451dc91aa3d5ddf9b2383ef6e55d77e570c Mon Sep 17 00:00:00 2001 From: alperozturk96 Date: Thu, 5 Nov 2026 15:15:13 +0300 Subject: [PATCH 2/2] unify capabilities operations Signed-off-by: alperozturk96 --- .../nextcloud/client/database/entity/CapabilityEntity.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/nextcloud/client/database/entity/CapabilityEntity.kt b/app/src/main/java/com/nextcloud/client/database/entity/CapabilityEntity.kt index e44368c1b7ff..a11f847bbbb9 100644 --- a/app/src/main/java/com/nextcloud/client/database/entity/CapabilityEntity.kt +++ b/app/src/main/java/com/nextcloud/client/database/entity/CapabilityEntity.kt @@ -15,6 +15,7 @@ import com.owncloud.android.db.ProviderMeta.ProviderTableMeta import com.owncloud.android.lib.resources.status.CapabilityBooleanType import com.owncloud.android.lib.resources.status.E2EVersion import com.owncloud.android.lib.resources.status.OCCapability +import java.util.regex.Pattern @Entity(tableName = ProviderTableMeta.CAPABILITIES_TABLE_NAME) data class CapabilityEntity( @@ -216,9 +217,10 @@ fun CapabilityEntity?.toOCCapability(): OCCapability { capability.richDocuments = intToBoolean(richdocument) capability.richDocumentsDirectEditing = intToBoolean(richdocumentDirectEditing) capability.richDocumentsTemplatesAvailable = intToBoolean(richdocumentTemplates) - capability.richDocumentsMimeTypeList = richdocumentMimetypeList.orEmpty().split(MIME_TYPE_SEPARATOR) + capability.richDocumentsMimeTypeList = + MIME_TYPE_SEPARATOR_PATTERN.split(richdocumentMimetypeList.orEmpty()).toList() capability.richDocumentsOptionalMimeTypeList = - richdocumentOptionalMimetypeList.orEmpty().split(MIME_TYPE_SEPARATOR) + MIME_TYPE_SEPARATOR_PATTERN.split(richdocumentOptionalMimetypeList.orEmpty()).toList() capability.richDocumentsProductName = richdocumentProductName capability.directEditingEtag = directEditingEtag capability.etag = etag @@ -326,3 +328,4 @@ fun OCCapability.toEntity(accountName: String, id: Int?): CapabilityEntity = Cap ) private const val MIME_TYPE_SEPARATOR = "," +private val MIME_TYPE_SEPARATOR_PATTERN: Pattern = Pattern.compile(MIME_TYPE_SEPARATOR)