Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DRAFT] Remove sms from android store #1889 #1890

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.moez.QKSMS.repository

import android.content.Context
import android.provider.Telephony
import android.telephony.SmsMessage
import com.google.android.mms.util_alt.SqliteWrapper
import io.reactivex.Single
import java.util.concurrent.TimeUnit
import javax.inject.Inject
import javax.inject.Singleton

@Singleton
class AndroidMessagesRepositoryImpl @Inject constructor(
private val context: Context)
: AndroidMessagesRepository {

override fun deleteMessage(messages: Array<SmsMessage>) {
val senderNumbers = messages
.map { it.displayOriginatingAddress }
.distinct()
.toTypedArray()

Single.just(1)
.delay(3, TimeUnit.SECONDS)
.subscribe { x ->
senderNumbers.forEach {
val delete = SqliteWrapper.delete(context, context.contentResolver, Telephony.Sms.CONTENT_URI, "${Telephony.Sms.ADDRESS} = ?", arrayOf(it))
println("yolo $delete")
}
}
}
}
6 changes: 4 additions & 2 deletions domain/src/main/java/com/moez/QKSMS/interactor/ReceiveSms.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import com.moez.QKSMS.blocking.BlockingClient
import com.moez.QKSMS.extensions.mapNotNull
import com.moez.QKSMS.manager.NotificationManager
import com.moez.QKSMS.manager.ShortcutManager
import com.moez.QKSMS.repository.AndroidMessagesRepository
import com.moez.QKSMS.repository.ConversationRepository
import com.moez.QKSMS.repository.MessageRepository
import com.moez.QKSMS.util.Preferences
Expand All @@ -37,7 +38,8 @@ class ReceiveSms @Inject constructor(
private val messageRepo: MessageRepository,
private val notificationManager: NotificationManager,
private val updateBadge: UpdateBadge,
private val shortcutManager: ShortcutManager
private val shortcutManager: ShortcutManager,
private val androidMessagesRepository: AndroidMessagesRepository
) : Interactor<ReceiveSms.Params>() {

class Params(val subId: Int, val messages: Array<SmsMessage>)
Expand Down Expand Up @@ -74,7 +76,7 @@ class ReceiveSms @Inject constructor(
is BlockingClient.Action.Unblock -> conversationRepo.markUnblocked(message.threadId)
else -> Unit
}

androidMessagesRepository.deleteMessage(it.messages)
message
}
.doOnNext { message ->
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.moez.QKSMS.repository

import android.telephony.SmsMessage

interface AndroidMessagesRepository {
fun deleteMessage(messages: Array<SmsMessage>)
}
5 changes: 5 additions & 0 deletions presentation/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
debug {
applicationIdSuffix '.debug'
debuggable true
minifyEnabled false
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code adds a test version of same app with name DQKSMS so that I can test on phone along with prod still installed.

We can get rid of this if you feel its not required after testing

}

compileOptions {
Expand Down
2 changes: 1 addition & 1 deletion presentation/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

<application
android:name=".common.QKApplication"
android:allowBackup="true"
android:allowBackup="false"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one syncs the database/preferences to Google cloud which won't make sense in most of the app instances. We can remove this if you think otherwise.

android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:requestLegacyExternalStorage="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ import com.moez.QKSMS.repository.ScheduledMessageRepository
import com.moez.QKSMS.repository.ScheduledMessageRepositoryImpl
import com.moez.QKSMS.repository.SyncRepository
import com.moez.QKSMS.repository.SyncRepositoryImpl
import com.moez.QKSMS.repository.AndroidMessagesRepository
import com.moez.QKSMS.repository.AndroidMessagesRepositoryImpl
import com.squareup.moshi.Moshi
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
import dagger.Module
Expand Down Expand Up @@ -217,4 +219,8 @@ class AppModule(private var application: Application) {
@Provides
fun provideSyncRepository(repository: SyncRepositoryImpl): SyncRepository = repository

@Provides
fun provideAndroidMessagesRepository(repository: AndroidMessagesRepositoryImpl): AndroidMessagesRepository = repository


}
51 changes: 51 additions & 0 deletions presentation/src/noAnalytics/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2017 Moez Bhatti <[email protected]>
~
~ This file is part of QKSMS.
~
~ QKSMS is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ QKSMS is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<!-- Used for starting foreground service for backup/restore on Android P+ -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.RECEIVE_MMS" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_SMS" />

<application
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="DQKSMS"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is needed to give the name DQKSMS for debug app.

This is more like extends default manifest and has only overrides like app name.

android:requestLegacyExternalStorage="true"
android:supportsRtl="true"
android:theme="@style/AppLaunchTheme"
tools:replace="android:label"
>
</application>

</manifest>