-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 031c17b
Showing
54 changed files
with
1,422 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto |
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,16 @@ | ||
*.iml | ||
.gradle | ||
.idea | ||
/local.properties | ||
/.idea/caches | ||
/.idea/libraries | ||
/.idea/modules.xml | ||
/.idea/workspace.xml | ||
/.idea/navEditor.xml | ||
/.idea/assetWizardSettings.xml | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild | ||
.cxx | ||
local.properties |
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,62 @@ | ||
# SMS2WhatsApp | ||
|
||
## Notes | ||
|
||
This project was generated by Copilot for personal use only. The author is not responsible for any risks or issues that may arise from using this application. | ||
|
||
## Purpose | ||
|
||
**SMS2WhatsApp** is an Android application designed to personally use on backup phone to monitor incoming SMS messages and automatically forward them to a specified WhatsApp contact. This app is ideal for users who want to ensure they never miss important messages by having them forwarded to their preferred messaging platform. | ||
|
||
## Features | ||
|
||
- **Automatic SMS Monitoring**: Continuously monitors incoming SMS messages. | ||
- **WhatsApp Forwarding**: Automatically forwards the content of SMS messages to a specified WhatsApp contact. | ||
- **User-Friendly Interface**: Simple and intuitive interface for easy setup and use. | ||
|
||
## Screenshots | ||
|
||
![screenshot](screenshot/MainScreen.png) | ||
|
||
![screenshot](screenshot/Accessibility1.png) | ||
|
||
![screenshot](screenshot/Accessibility2.png) | ||
|
||
![screenshot](screenshot/DeviceAdminApp.png) | ||
|
||
![screenshot](screenshot/SMSPermission.png) | ||
|
||
![screenshot](screenshot/TestMsg.png) | ||
|
||
## Permissions Required | ||
|
||
To ensure optimal functionality, this app requires the following permissions: | ||
- **SMS**: To receive and read messages. | ||
- **Accessibility Services**: To enhance user experience and provide additional features. | ||
- **Device Admin**: For advanced security and management capabilities. | ||
|
||
Additionally, please disable any screen lock security methods to allow seamless access. | ||
|
||
## Installation | ||
|
||
1. Clone the repository: | ||
```bash | ||
git clone https://github.com/Iceloof/SMS2WhatsApp.git | ||
``` | ||
2. Open the project in Android Studio. | ||
3. Build and run the app on your Android device. | ||
|
||
## Usage | ||
|
||
1. Open the app and grant the necessary permissions. | ||
2. Configure the WhatsApp contact to which SMS messages should be forwarded. | ||
3. Enable the SMS monitoring service. | ||
|
||
## Contributing | ||
|
||
Contributions are welcome! Please fork the repository and submit a pull request with your changes. | ||
|
||
## License | ||
|
||
This project is licensed under the MIT License - see the LICENSE file for details. | ||
|
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,2 @@ | ||
/build | ||
/release |
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,72 @@ | ||
plugins { | ||
alias(libs.plugins.android.application) | ||
alias(libs.plugins.kotlin.android) | ||
} | ||
|
||
android { | ||
namespace = "com.iceloof.sms2whatsapp" | ||
compileSdk = 34 | ||
|
||
defaultConfig { | ||
applicationId = "com.iceloof.sms2whatsapp" | ||
minSdk = 30 | ||
targetSdk = 34 | ||
versionCode = 1 | ||
versionName = "1.0" | ||
|
||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
vectorDrawables { | ||
useSupportLibrary = true | ||
} | ||
setProperty("archivesBaseName", "SMS2WhatsApp_" + versionName) | ||
} | ||
|
||
buildTypes { | ||
release { | ||
isMinifyEnabled = false | ||
proguardFiles( | ||
getDefaultProguardFile("proguard-android-optimize.txt"), | ||
"proguard-rules.pro" | ||
) | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
} | ||
kotlinOptions { | ||
jvmTarget = "1.8" | ||
} | ||
buildFeatures { | ||
compose = true | ||
} | ||
composeOptions { | ||
kotlinCompilerExtensionVersion = "1.5.1" | ||
} | ||
packaging { | ||
resources { | ||
excludes += "/META-INF/{AL2.0,LGPL2.1}" | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
|
||
implementation(libs.androidx.core.ktx) | ||
implementation(libs.androidx.lifecycle.runtime.ktx) | ||
implementation(libs.androidx.activity.compose) | ||
implementation(platform(libs.androidx.compose.bom)) | ||
implementation(libs.androidx.ui) | ||
implementation(libs.androidx.ui.graphics) | ||
implementation(libs.androidx.ui.tooling.preview) | ||
implementation(libs.androidx.material3) | ||
implementation(libs.androidx.appcompat) | ||
implementation(libs.androidx.constraintlayout) | ||
testImplementation(libs.junit) | ||
androidTestImplementation(libs.androidx.junit) | ||
androidTestImplementation(libs.androidx.espresso.core) | ||
androidTestImplementation(platform(libs.androidx.compose.bom)) | ||
androidTestImplementation(libs.androidx.ui.test.junit4) | ||
debugImplementation(libs.androidx.ui.tooling) | ||
debugImplementation(libs.androidx.ui.test.manifest) | ||
} |
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,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
24 changes: 24 additions & 0 deletions
24
app/src/androidTest/java/com/iceloof/sms2whatsapp/ExampleInstrumentedTest.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,24 @@ | ||
package com.iceloof.sms2whatsapp | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
|
||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
import org.junit.Assert.* | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* See [testing documentation](http://d.android.com/tools/testing). | ||
*/ | ||
@RunWith(AndroidJUnit4::class) | ||
class ExampleInstrumentedTest { | ||
@Test | ||
fun useAppContext() { | ||
// Context of the app under test. | ||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext | ||
assertEquals("com.iceloof.sms2whatsapp", appContext.packageName) | ||
} | ||
} |
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,68 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools"> | ||
|
||
<uses-permission android:name="android.permission.RECEIVE_SMS"/> | ||
<uses-permission android:name="android.permission.INTERNET"/> | ||
<uses-permission android:name="android.permission.READ_SMS"/> | ||
<uses-permission android:name="android.permission.WAKE_LOCK"/> | ||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/> | ||
<uses-permission android:name="android.permission.BIND_DEVICE_ADMIN" | ||
tools:ignore="ProtectedPermissions" /> | ||
<uses-permission android:name="android.permission.BIND_ACCESSIBILITY_SERVICE" | ||
tools:ignore="ProtectedPermissions" /> | ||
|
||
<uses-feature android:name="android.hardware.telephony" android:required="false"/> | ||
<application | ||
android:allowBackup="true" | ||
android:dataExtractionRules="@xml/data_extraction_rules" | ||
android:fullBackupContent="@xml/backup_rules" | ||
android:icon="@drawable/icon" | ||
android:label="@string/app_name" | ||
android:roundIcon="@drawable/icon" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme" | ||
tools:targetApi="31"> | ||
<activity | ||
android:name=".MainActivity" | ||
android:exported="true" | ||
android:theme="@style/AppTheme"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
<service | ||
android:name=".AccessibilityService" | ||
android:exported="true" | ||
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE"> | ||
<intent-filter> | ||
<action android:name="android.accessibilityservice.AccessibilityService"/> | ||
</intent-filter> | ||
<meta-data | ||
android:name="android.accessibilityservice" | ||
android:resource="@xml/accessibility_service_config"/> | ||
</service> | ||
<receiver | ||
android:name=".SmsReceiver" | ||
android:exported="true" | ||
android:permission="android.permission.BROADCAST_SMS"> | ||
<intent-filter> | ||
<action android:name="android.provider.Telephony.SMS_RECEIVED"/> | ||
</intent-filter> | ||
</receiver> | ||
<receiver | ||
android:name=".MyDeviceAdminReceiver" | ||
android:exported="true" | ||
android:permission="android.permission.BIND_DEVICE_ADMIN"> | ||
<meta-data | ||
android:name="android.app.device_admin" | ||
android:resource="@xml/device_admin_receiver" /> | ||
<intent-filter> | ||
<action android:name="android.app.action.DEVICE_ADMIN_ENABLED" /> | ||
</intent-filter> | ||
</receiver> | ||
</application> | ||
|
||
</manifest> |
63 changes: 63 additions & 0 deletions
63
app/src/main/java/com/iceloof/sms2whatsapp/AccessibilityService.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,63 @@ | ||
package com.iceloof.sms2whatsapp | ||
import android.accessibilityservice.AccessibilityService | ||
import android.accessibilityservice.AccessibilityServiceInfo | ||
import android.app.admin.DevicePolicyManager | ||
import android.content.ComponentName | ||
import android.content.Context | ||
import android.view.accessibility.AccessibilityEvent | ||
import android.view.accessibility.AccessibilityNodeInfo | ||
|
||
class AccessibilityService : AccessibilityService() { | ||
|
||
override fun onAccessibilityEvent(event: AccessibilityEvent?) { | ||
if (event?.eventType == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED && event.packageName == "com.whatsapp") { | ||
val rootNode = rootInActiveWindow ?: return | ||
val sendButtonNode = findNodeByContentDescription(rootNode, "Send") | ||
Thread.sleep(500) | ||
if (sendButtonNode != null) { | ||
sendButtonNode.performAction(AccessibilityNodeInfo.ACTION_CLICK) | ||
Thread.sleep(500) | ||
performGlobalAction(GLOBAL_ACTION_BACK) | ||
Thread.sleep(500) | ||
performGlobalAction(GLOBAL_ACTION_HOME) | ||
lockScreen() | ||
} | ||
} | ||
} | ||
|
||
override fun onInterrupt() { | ||
// Handle service interruption | ||
} | ||
|
||
override fun onServiceConnected() { | ||
val info = AccessibilityServiceInfo().apply { | ||
eventTypes = AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED | ||
feedbackType = AccessibilityServiceInfo.FEEDBACK_GENERIC | ||
notificationTimeout = 100 | ||
packageNames = arrayOf("com.whatsapp") | ||
} | ||
serviceInfo = info | ||
} | ||
|
||
private fun lockScreen() { | ||
val devicePolicyManager = getSystemService(Context.DEVICE_POLICY_SERVICE) as DevicePolicyManager | ||
val componentName = ComponentName(this, MyDeviceAdminReceiver::class.java) | ||
if (devicePolicyManager.isAdminActive(componentName)) { | ||
devicePolicyManager.lockNow() | ||
} | ||
} | ||
|
||
private fun findNodeByContentDescription(root: AccessibilityNodeInfo, description: String): AccessibilityNodeInfo? { | ||
for (i in 0 until root.childCount) { | ||
val child = root.getChild(i) ?: continue | ||
if (child.contentDescription?.toString() == description) { | ||
return child | ||
} | ||
val result = findNodeByContentDescription(child, description) | ||
if (result != null) { | ||
return result | ||
} | ||
} | ||
return null | ||
} | ||
} |
Oops, something went wrong.