-
Notifications
You must be signed in to change notification settings - Fork 939
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Task/Issue URL: https://app.asana.com/0/0/1206314482566716/f ### Description This PR contains the removal of the Google backup service implementation to persist ATB ### Steps to test this PR - [x] Go to develop - [x] Add a file under the Android directory called `test_d2d.sh` - [x] Copy and paste in this new file the code from https://app.asana.com/0/0/1206310480197408/f - [x] Install from develop - [x] Run `./test_cloud_backup.sh com.duckduckgo.mobile.android.debug` to perform a backup - [x] Check in File Explorer, you have `com.duckduckgo.app.statistics.backup` file with the `atb` key in it - [x] Install from this branch - [x] Refresh File Explorer - [x] Check `com.duckduckgo.app.statistics.backup` has been cleared ### No UI changes
- Loading branch information
Showing
20 changed files
with
104 additions
and
526 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
app/src/main/java/com/duckduckgo/app/reinstalls/BackupServiceDataStore.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright (c) 2024 DuckDuckGo | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.duckduckgo.app.reinstalls | ||
|
||
import android.content.Context | ||
import android.content.SharedPreferences | ||
import com.duckduckgo.di.scopes.AppScope | ||
import com.squareup.anvil.annotations.ContributesBinding | ||
import javax.inject.Inject | ||
|
||
interface BackupServiceDataStore { | ||
fun clearBackupPreferences() | ||
} | ||
|
||
@ContributesBinding(AppScope::class) | ||
class BackupServiceSharedPreferences @Inject constructor( | ||
private val context: Context, | ||
) : BackupServiceDataStore { | ||
|
||
private val backupServicePreferences: SharedPreferences by lazy { context.getSharedPreferences(FILENAME_BACKUP_SERVICE, Context.MODE_PRIVATE) } | ||
private val backupPixelPreferences: SharedPreferences by lazy { context.getSharedPreferences(FILENAME_BACKUP_PIXEL, Context.MODE_PRIVATE) } | ||
|
||
override fun clearBackupPreferences() { | ||
if (backupServicePreferences.contains(KEY_ATB)) { | ||
backupServicePreferences.edit().clear().apply() | ||
} | ||
if (backupPixelPreferences.contains(KEY_PIXEL_SENT)) { | ||
backupPixelPreferences.edit().clear().apply() | ||
} | ||
} | ||
|
||
companion object { | ||
private const val FILENAME_BACKUP_SERVICE = "com.duckduckgo.app.statistics.backup" | ||
private const val KEY_ATB = "com.duckduckgo.app.statistics.backup.atb" | ||
private const val FILENAME_BACKUP_PIXEL = "com.duckduckgo.app.statistics.backup.pixel" | ||
private const val KEY_PIXEL_SENT = "com.duckduckgo.app.statistics.backup.pixel.sent" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
app/src/test/java/com/duckduckgo/app/reinstalls/ReinstallAtbListenerTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright (c) 2024 DuckDuckGo | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.duckduckgo.app.reinstalls | ||
|
||
import com.duckduckgo.common.test.CoroutineTestRule | ||
import kotlinx.coroutines.test.runTest | ||
import org.junit.Before | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.mockito.kotlin.mock | ||
import org.mockito.kotlin.verify | ||
|
||
class ReinstallAtbListenerTest { | ||
|
||
private lateinit var testee: ReinstallAtbListener | ||
|
||
private val mockBackupDataStore: BackupServiceDataStore = mock() | ||
|
||
@get:Rule | ||
val coroutineTestRule: CoroutineTestRule = CoroutineTestRule() | ||
|
||
@Before | ||
fun before() { | ||
testee = ReinstallAtbListener(mockBackupDataStore) | ||
} | ||
|
||
@Test | ||
fun whenBeforeAtbInitIsCalledThenClearBackupServiceSharedPreferences() = runTest { | ||
testee.beforeAtbInit() | ||
|
||
verify(mockBackupDataStore).clearBackupPreferences() | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
28 changes: 0 additions & 28 deletions
28
...gent/backup-agent-api/src/main/java/com/duckduckgo/backup.agent/api/BackupAgentManager.kt
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
34 changes: 0 additions & 34 deletions
34
...p-agent-impl/src/main/java/com/duckduckgo/app/backup/agent/impl/BackupAgentManagerImpl.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.