Skip to content

Commit 16e8e82

Browse files
authored
Merge pull request #4776 from owncloud/feature/add_provider_settings_qa_variant
[QA] Add content provider to handle settings in QA variant
2 parents 5a5e307 + 8393d30 commit 16e8e82

4 files changed

Lines changed: 119 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ ownCloud admins and users.
5050
* Enhancement - Remove a space member: [#4725](https://github.com/owncloud/android/issues/4725)
5151
* Enhancement - Workflow to build APK: [#4751](https://github.com/owncloud/android/pull/4751)
5252
* Enhancement - Workflow to check Conventional Commits: [#4759](https://github.com/owncloud/android/pull/4759)
53+
* Enhancement - QA Content Provider: [#4776](https://github.com/owncloud/android/pull/4776)
5354

5455
## Details
5556

@@ -139,6 +140,13 @@ ownCloud admins and users.
139140

140141
https://github.com/owncloud/android/pull/4759
141142

143+
* Enhancement - QA Content Provider: [#4776](https://github.com/owncloud/android/pull/4776)
144+
145+
A new content provider has been added to the QA variant in order to work with
146+
the sharing preferences with testing purposes.
147+
148+
https://github.com/owncloud/android/pull/4776
149+
142150
# Changelog for ownCloud Android Client [4.7.0] (2025-11-17)
143151

144152
The following sections list the changes in ownCloud Android Client 4.7.0 relevant to

changelog/unreleased/4776

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Enhancement: QA Content Provider
2+
3+
A new content provider has been added to the QA variant in order to work with the sharing preferences with testing purposes.
4+
5+
https://github.com/owncloud/android/pull/4776
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<!--
2+
~ Copyright (C) 2026 The Android Open Source Project
3+
~
4+
~ Licensed under the Apache License, Version 2.0 (the "License");
5+
~ you may not use this file except in compliance with the License.
6+
~ You may obtain a copy of the License at
7+
~
8+
~ http://www.apache.org/licenses/LICENSE-2.0
9+
~
10+
~ Unless required by applicable law or agreed to in writing, software
11+
~ distributed under the License is distributed on an "AS IS" BASIS,
12+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
~ See the License for the specific language governing permissions and
14+
~ limitations under the License.
15+
-->
16+
17+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
18+
19+
<application>
20+
<provider
21+
android:name="com.owncloud.android.test.TestPreferencesProvider"
22+
android:authorities="com.owncloud.android.test.preferences"
23+
android:exported="true" />
24+
</application>
25+
26+
</manifest>
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/**
2+
* ownCloud Android client application
3+
*
4+
* @author Jesus Recio Rincon
5+
*
6+
* Copyright (C) 2026 ownCloud GmbH.
7+
*
8+
* This program is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU General Public License version 2,
10+
* as published by the Free Software Foundation.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
21+
package com.owncloud.android.test
22+
23+
import android.content.ContentProvider
24+
import android.content.ContentValues
25+
import android.content.Context
26+
import android.database.Cursor
27+
import android.net.Uri
28+
import android.os.Bundle
29+
import androidx.core.content.edit
30+
31+
/**
32+
*
33+
* A ContentProvider used only in the QA flavor to allow
34+
* external test tools (E2E tests for automation) to modify
35+
* SharedPreferences at runtime.
36+
*
37+
* This provider is NOT intended for production usage.
38+
*/
39+
class TestPreferencesProvider : ContentProvider() {
40+
41+
override fun onCreate(): Boolean = true
42+
43+
override fun call(
44+
method: String,
45+
arg: String?,
46+
extras: Bundle?
47+
): Bundle {
48+
49+
val prefs = context?.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE)
50+
if (method == SET_BOOLEAN) {
51+
prefs?.edit {
52+
arg?.let { setting ->
53+
extras?.let { extra ->
54+
putBoolean(setting, extra.getBoolean("value"))
55+
}
56+
}
57+
}
58+
}
59+
return Bundle()
60+
}
61+
62+
override fun query(
63+
uri: Uri, projection: Array<out String>?,
64+
selection: String?, selectionArgs: Array<out String>?,
65+
sortOrder: String?
66+
): Cursor? = null
67+
68+
override fun insert(uri: Uri, values: ContentValues?): Uri? = null
69+
70+
override fun delete(uri: Uri, selection: String?, selectionArgs: Array<out String>?): Int = 0
71+
72+
override fun update(uri: Uri, values: ContentValues?, selection: String?, selectionArgs: Array<out String>?): Int = 0
73+
74+
override fun getType(uri: Uri): String? = null
75+
76+
companion object {
77+
private const val SET_BOOLEAN = "set_boolean"
78+
private const val PREFS_NAME = "com.owncloud.android_preferences"
79+
}
80+
}

0 commit comments

Comments
 (0)