Skip to content

Commit

Permalink
Encrypt databases
Browse files Browse the repository at this point in the history
  • Loading branch information
S1210 committed May 31, 2023
1 parent a87bc56 commit 6f6bc74
Show file tree
Hide file tree
Showing 61 changed files with 280 additions and 211 deletions.
18 changes: 11 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ android {
buildConfigField 'Boolean', 'BLUR_DETECTION_ENABLED', "false"
buildConfigField 'Boolean', 'USE_AWS_S3', "false"
buildConfigField 'Boolean', 'ORG_LINK', "false"
buildConfigField 'String', 'CRYPTO_KEY', "\"THE_BEST_APP_IN_THE_WORLD\""


javaCompileOptions {
annotationProcessorOptions {
arguments = ["room.schemaLocation": "$projectDir/schemas".toString()]
kapt {
arguments {
arg("room.schemaLocation", "$projectDir/schemas")
}
}
}
Expand Down Expand Up @@ -228,9 +228,13 @@ dependencies {
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:1.1.5")

//Database
implementation 'androidx.room:room-runtime:2.4.0-beta01'
implementation 'androidx.room:room-ktx:2.4.0-beta01'
kapt "androidx.room:room-compiler:2.4.0-beta01"
implementation 'androidx.room:room-runtime:2.4.0'
implementation 'androidx.room:room-ktx:2.4.0'
kapt "androidx.room:room-compiler:2.4.0"

// Sqlcipher
implementation "net.zetetic:android-database-sqlcipher:4.4.2"
implementation "androidx.sqlite:sqlite:2.1.0"

devImplementation 'com.amitshekhar.android:debug-db:1.0.6'

Expand Down
4 changes: 4 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,7 @@
# The SDK has several references of Apache HTTP client
-dontwarn com.amazonaws.http.**
-dontwarn com.amazonaws.metrics.**

# SQLCipher
-keep,includedescriptorclasses class net.sqlcipher.** { *; }
-keep,includedescriptorclasses interface net.sqlcipher.** { *; }
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import kotlinx.coroutines.withContext
import org.greenstand.android.TreeTracker.R
import org.greenstand.android.TreeTracker.analytics.Analytics
import org.greenstand.android.TreeTracker.background.TreeSyncWorker
import org.greenstand.android.TreeTracker.database.TreeTrackerDAO
import org.greenstand.android.TreeTracker.database.app.dao.TreeTrackerDAO
import org.greenstand.android.TreeTracker.models.FeatureFlags
import org.greenstand.android.TreeTracker.models.location.LocationDataCapturer
import org.greenstand.android.TreeTracker.models.messages.MessagesRepo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package org.greenstand.android.TreeTracker.dashboard

import org.greenstand.android.TreeTracker.database.TreeTrackerDAO
import org.greenstand.android.TreeTracker.database.app.dao.TreeTrackerDAO
import org.greenstand.android.TreeTracker.preferences.PrefKey
import org.greenstand.android.TreeTracker.preferences.PrefKeys
import org.greenstand.android.TreeTracker.preferences.Preferences
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* Copyright 2023 Treetracker
*
* 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 org.greenstand.android.TreeTracker.database.app

import androidx.room.AutoMigration
import androidx.room.Database
import androidx.room.RoomDatabase
import androidx.room.TypeConverters
import org.greenstand.android.TreeTracker.database.app.dao.TreeTrackerDAO
import org.greenstand.android.TreeTracker.database.app.entity.DeviceConfigEntity
import org.greenstand.android.TreeTracker.database.app.entity.LocationEntity
import org.greenstand.android.TreeTracker.database.app.entity.OrganizationEntity
import org.greenstand.android.TreeTracker.database.app.entity.SessionEntity
import org.greenstand.android.TreeTracker.database.app.entity.TreeEntity
import org.greenstand.android.TreeTracker.database.app.entity.UserEntity
import org.greenstand.android.TreeTracker.database.app.legacy.entity.LocationDataEntity
import org.greenstand.android.TreeTracker.database.app.legacy.entity.PlanterCheckInEntity
import org.greenstand.android.TreeTracker.database.app.legacy.entity.PlanterInfoEntity
import org.greenstand.android.TreeTracker.database.app.legacy.entity.TreeAttributeEntity
import org.greenstand.android.TreeTracker.database.app.legacy.entity.TreeCaptureEntity

@Database(
version = 9,
exportSchema = true,
entities = [
PlanterCheckInEntity::class,
PlanterInfoEntity::class,
TreeAttributeEntity::class,
TreeCaptureEntity::class,
LocationDataEntity::class,
SessionEntity::class,
UserEntity::class,
LocationEntity::class,
TreeEntity::class,
DeviceConfigEntity::class,
OrganizationEntity::class,
],
autoMigrations = [
// 8 -> 9 for v2.2
AutoMigration(from = 8, to = 9)
],
)
@TypeConverters(Converters::class)
abstract class AppDatabase : RoomDatabase() {

abstract fun treeTrackerDao(): TreeTrackerDAO

companion object {

const val DB_NAME = "treetracker.v2.db"
const val DB_NAME_ENCRYPT = "treetracker.v2-encrypt.db"

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.greenstand.android.TreeTracker.database
package org.greenstand.android.TreeTracker.database.app

import androidx.room.TypeConverter
import com.google.gson.Gson
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.greenstand.android.TreeTracker.database
package org.greenstand.android.TreeTracker.database.app

import androidx.room.migration.Migration
import androidx.sqlite.db.SupportSQLiteDatabase
import org.greenstand.android.TreeTracker.database.legacy.entity.PlanterInfoEntity
import org.greenstand.android.TreeTracker.database.app.legacy.entity.PlanterInfoEntity

val MIGRATION_6_7 = object : Migration(6, 7) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.greenstand.android.TreeTracker.database
package org.greenstand.android.TreeTracker.database.app.dao

import androidx.room.Dao
import androidx.room.Delete
Expand All @@ -23,17 +23,17 @@ import androidx.room.Query
import androidx.room.Transaction
import androidx.room.Update
import kotlinx.coroutines.flow.Flow
import org.greenstand.android.TreeTracker.database.entity.DeviceConfigEntity
import org.greenstand.android.TreeTracker.database.entity.LocationEntity
import org.greenstand.android.TreeTracker.database.entity.OrganizationEntity
import org.greenstand.android.TreeTracker.database.entity.SessionEntity
import org.greenstand.android.TreeTracker.database.entity.TreeEntity
import org.greenstand.android.TreeTracker.database.entity.UserEntity
import org.greenstand.android.TreeTracker.database.legacy.entity.PlanterCheckInEntity
import org.greenstand.android.TreeTracker.database.legacy.entity.PlanterInfoEntity
import org.greenstand.android.TreeTracker.database.legacy.entity.TreeAttributeEntity
import org.greenstand.android.TreeTracker.database.legacy.entity.TreeCaptureEntity
import org.greenstand.android.TreeTracker.database.legacy.views.TreeMapMarkerDbView
import org.greenstand.android.TreeTracker.database.app.entity.DeviceConfigEntity
import org.greenstand.android.TreeTracker.database.app.entity.LocationEntity
import org.greenstand.android.TreeTracker.database.app.entity.OrganizationEntity
import org.greenstand.android.TreeTracker.database.app.entity.SessionEntity
import org.greenstand.android.TreeTracker.database.app.entity.TreeEntity
import org.greenstand.android.TreeTracker.database.app.entity.UserEntity
import org.greenstand.android.TreeTracker.database.app.legacy.entity.PlanterCheckInEntity
import org.greenstand.android.TreeTracker.database.app.legacy.entity.PlanterInfoEntity
import org.greenstand.android.TreeTracker.database.app.legacy.entity.TreeAttributeEntity
import org.greenstand.android.TreeTracker.database.app.legacy.entity.TreeCaptureEntity
import org.greenstand.android.TreeTracker.database.app.legacy.views.TreeMapMarkerDbView

@Dao
interface TreeTrackerDAO {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.greenstand.android.TreeTracker.database.entity
package org.greenstand.android.TreeTracker.database.app.entity

import androidx.room.ColumnInfo
import androidx.room.Entity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.greenstand.android.TreeTracker.database.entity
package org.greenstand.android.TreeTracker.database.app.entity

import androidx.room.ColumnInfo
import androidx.room.Entity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.greenstand.android.TreeTracker.database.entity
package org.greenstand.android.TreeTracker.database.app.entity

import androidx.room.ColumnInfo
import androidx.room.Entity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.greenstand.android.TreeTracker.database.entity
package org.greenstand.android.TreeTracker.database.app.entity

import androidx.room.ColumnInfo
import androidx.room.Entity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.greenstand.android.TreeTracker.database.entity
package org.greenstand.android.TreeTracker.database.app.entity

import androidx.room.ColumnInfo
import androidx.room.Entity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.greenstand.android.TreeTracker.database.entity
package org.greenstand.android.TreeTracker.database.app.entity

import androidx.room.ColumnInfo
import androidx.room.Entity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.greenstand.android.TreeTracker.database.legacy.entity
package org.greenstand.android.TreeTracker.database.app.legacy.entity

import androidx.room.ColumnInfo
import androidx.room.Entity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.greenstand.android.TreeTracker.database.legacy.entity
package org.greenstand.android.TreeTracker.database.app.legacy.entity

import androidx.room.ColumnInfo
import androidx.room.Entity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.greenstand.android.TreeTracker.database.legacy.entity
package org.greenstand.android.TreeTracker.database.app.legacy.entity

import androidx.room.ColumnInfo
import androidx.room.Entity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.greenstand.android.TreeTracker.database.legacy.entity
package org.greenstand.android.TreeTracker.database.app.legacy.entity

import androidx.room.ColumnInfo
import androidx.room.Entity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.greenstand.android.TreeTracker.database.legacy.entity
package org.greenstand.android.TreeTracker.database.app.legacy.entity

import androidx.room.ColumnInfo
import androidx.room.Entity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.greenstand.android.TreeTracker.database.legacy.views
package org.greenstand.android.TreeTracker.database.app.legacy.views

class TreeMapMarkerDbView(
val latitude: Double,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.greenstand.android.TreeTracker.database.legacy.views
package org.greenstand.android.TreeTracker.database.app.legacy.views

// @DatabaseView("""
// SELECT
Expand Down
Loading

0 comments on commit 6f6bc74

Please sign in to comment.