From c5e24df58f31ea4d466f27e094ac6d686545b164 Mon Sep 17 00:00:00 2001
From: thewh1teagle <61390950+thewh1teagle@users.noreply.github.com>
Date: Fri, 22 Nov 2024 20:26:37 +0200
Subject: [PATCH 1/3] unrelated .idea changes
---
.idea/locatemydevice.iml | 9 +
.idea/misc.xml | 6 +
.idea/modules.xml | 8 +
.idea/other.xml | 329 +++++++++++++++++++++++++
.idea/vcs.xml | 6 +
src/.idea/compiler.xml | 2 +-
src/.idea/deploymentTargetSelector.xml | 10 +
src/.idea/gradle.xml | 5 +-
src/.idea/migrations.xml | 10 +
src/.idea/misc.xml | 2 +-
src/.idea/other.xml | 329 +++++++++++++++++++++++++
11 files changed, 711 insertions(+), 5 deletions(-)
create mode 100644 .idea/locatemydevice.iml
create mode 100644 .idea/misc.xml
create mode 100644 .idea/modules.xml
create mode 100644 .idea/other.xml
create mode 100644 .idea/vcs.xml
create mode 100644 src/.idea/deploymentTargetSelector.xml
create mode 100644 src/.idea/migrations.xml
create mode 100644 src/.idea/other.xml
diff --git a/.idea/locatemydevice.iml b/.idea/locatemydevice.iml
new file mode 100644
index 0000000..d6ebd48
--- /dev/null
+++ b/.idea/locatemydevice.iml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..ee820d2
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..11d9ca5
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/other.xml b/.idea/other.xml
new file mode 100644
index 0000000..104e542
--- /dev/null
+++ b/.idea/other.xml
@@ -0,0 +1,329 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/.idea/compiler.xml b/src/.idea/compiler.xml
index fb7f4a8..b589d56 100644
--- a/src/.idea/compiler.xml
+++ b/src/.idea/compiler.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/src/.idea/deploymentTargetSelector.xml b/src/.idea/deploymentTargetSelector.xml
new file mode 100644
index 0000000..b268ef3
--- /dev/null
+++ b/src/.idea/deploymentTargetSelector.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/.idea/gradle.xml b/src/.idea/gradle.xml
index 7b46144..0897082 100644
--- a/src/.idea/gradle.xml
+++ b/src/.idea/gradle.xml
@@ -4,16 +4,15 @@
-
-
-
+
+
diff --git a/src/.idea/migrations.xml b/src/.idea/migrations.xml
new file mode 100644
index 0000000..f8051a6
--- /dev/null
+++ b/src/.idea/migrations.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/.idea/misc.xml b/src/.idea/misc.xml
index bd1fffc..c54f89c 100644
--- a/src/.idea/misc.xml
+++ b/src/.idea/misc.xml
@@ -11,7 +11,7 @@
-
+
diff --git a/src/.idea/other.xml b/src/.idea/other.xml
new file mode 100644
index 0000000..104e542
--- /dev/null
+++ b/src/.idea/other.xml
@@ -0,0 +1,329 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
From 034fb8f55571ad7a331494f6022ab1bbcfab8a1f Mon Sep 17 00:00:00 2001
From: thewh1teagle <61390950+thewh1teagle@users.noreply.github.com>
Date: Fri, 22 Nov 2024 20:27:22 +0200
Subject: [PATCH 2/3] unrelated
---
.idea/workspace.xml | 50 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
create mode 100644 .idea/workspace.xml
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 0000000..03c1278
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,50 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1732297498520
+
+
+ 1732297498520
+
+
+
+
\ No newline at end of file
From 38eed12e513d946d22a0b0862126f5605e53de26 Mon Sep 17 00:00:00 2001
From: thewh1teagle <61390950+thewh1teagle@users.noreply.github.com>
Date: Fri, 22 Nov 2024 20:42:22 +0200
Subject: [PATCH 3/3] feat: add option to turn on/off gps
---
README.md | 2 ++
.../xfarrow/locatemydevice/SmsHandler.java | 30 +++++++++++++++----
.../com/xfarrow/locatemydevice/Utils.java | 22 ++++++++++++++
3 files changed, 48 insertions(+), 6 deletions(-)
diff --git a/README.md b/README.md
index 01cb7f3..e884d8a 100644
--- a/README.md
+++ b/README.md
@@ -34,6 +34,8 @@ callme | You will receive a call from the lost smartphone | Calls, Overlay |
wifi | Will return Wi-Fi infos | Location |
wifi-on | Will enable Wi-Fi (Only API < 29) | None |
wifi-off | Will disable Wi-Fi (Only API < 29) | None |
+gps-on | Will enable GPS. | WRITE_SECURE_SETTINGS
+gps-off | Will disable GPS. | WRITE_SECURE_SETTINGS
ring | Will make the smartphone ring | Overlay |
### Auto enabling location (only 1.1-beta)
diff --git a/src/app/src/main/java/com/xfarrow/locatemydevice/SmsHandler.java b/src/app/src/main/java/com/xfarrow/locatemydevice/SmsHandler.java
index ad5500f..973a894 100644
--- a/src/app/src/main/java/com/xfarrow/locatemydevice/SmsHandler.java
+++ b/src/app/src/main/java/com/xfarrow/locatemydevice/SmsHandler.java
@@ -87,7 +87,7 @@ public void handleSms(String message, String sender, Context context) {
LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
// location not enabled and unable to turn it on
- if(!locationManager.isLocationEnabled() && !Utils.toggleLocationOn(context)){
+ if(!locationManager.isLocationEnabled() && !Utils.setLocation(context, true)){
String response = "Location is not enabled. Unable to serve request.";
Utils.sendSms(smsManager, response, sender);
return;
@@ -153,7 +153,7 @@ else if(providedOption.equals(Utils.CELLULAR_INFO_OPTION)) {
// getAllCellInfo() requires Location services to work
LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
boolean isLocationOn;
- isLocationOn = locationManager.isLocationEnabled() || Utils.toggleLocationOn(context);
+ isLocationOn = locationManager.isLocationEnabled() || Utils.setLocation(context, true);
List availableTowersInRange = telephony.getAllCellInfo();
responseSms.append("Towers in range: ");
@@ -271,7 +271,7 @@ else if(providedOption.equals(Utils.WIFI_OPTION)){
LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
- if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1 && !locationManager.isLocationEnabled() && !Utils.toggleLocationOn(context)) {
+ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1 && !locationManager.isLocationEnabled() && !Utils.setLocation(context, true)) {
responseSms.append("Location is off. Unable to execute command.");
Utils.sendSms(smsManager, responseSms.toString(), sender);
return;
@@ -310,8 +310,7 @@ else if(providedOption.equals(Utils.WIFI_OPTION)){
}
// wifi-on OR wifi-off
- else if(providedOption.contains(Utils.WIFI_OPTION) && (providedOption.contains(Utils.ON_SUBOPTION)
- || providedOption.contains(Utils.OFF_SUBOPTION))){
+ else if(providedOption.contains(Utils.WIFI_OPTION) && (providedOption.contains(Utils.ON_SUBOPTION) || providedOption.contains(Utils.OFF_SUBOPTION))){
StringBuilder responseSms = new StringBuilder();
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q){
@@ -326,6 +325,21 @@ else if(providedOption.contains(Utils.WIFI_OPTION) && (providedOption.contains(U
Utils.sendSms(smsManager, responseSms.toString(), sender);
}
+ // gps-on OR gps-off
+ else if(providedOption.contains(Utils.GPS_OPTION) && (providedOption.contains(Utils.ON_SUBOPTION) || providedOption.contains(Utils.OFF_SUBOPTION))){
+
+ boolean state = providedOption.contains(Utils.ON_SUBOPTION);
+ LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
+ // location not enabled and unable to turn it on
+ if(!Utils.setLocation(context, state)){
+ String response = state ? "Failed to enable GPS." : "Failed to disable GPS.";
+ Utils.sendSms(smsManager, response, sender);
+ return;
+ }
+ String response = state ? "GPS enabled." : "GPS disabled.";
+ Utils.sendSms(smsManager, response, sender);
+ }
+
// lock
else if(providedOption.equals(Utils.LOCK_OPTION)){
StringBuilder responseSms = new StringBuilder();
@@ -380,7 +394,7 @@ else if(providedOption.equals(Utils.RING_OPTION)){
Utils.sendSms(smsManager, "Ringing", sender);
}
- else{
+ else {
StringBuilder responseSms = new StringBuilder("This option is not valid. Available options:\n\n");
responseSms.append(Utils.LOCATE_OPTION + ": Will return the most accurate set of coordinates possible " +
@@ -404,6 +418,10 @@ else if(providedOption.equals(Utils.RING_OPTION)){
responseSms.append(Utils.WIFI_OPTION + Utils.OFF_SUBOPTION + ": Will disable Wi-Fi (Only API < 29).\n\n");
+ responseSms.append(Utils.GPS_OPTION + Utils.ON_SUBOPTION + ": Will enable GPS.\n\n");
+
+ responseSms.append(Utils.GPS_OPTION + Utils.OFF_SUBOPTION + ": Will disable GPS.\n\n");
+
responseSms.append(Utils.RING_OPTION + ": Will make the smartphone ring.\n\n");
Utils.sendSms(smsManager, responseSms.toString(), sender);
diff --git a/src/app/src/main/java/com/xfarrow/locatemydevice/Utils.java b/src/app/src/main/java/com/xfarrow/locatemydevice/Utils.java
index 4692010..c980f5a 100644
--- a/src/app/src/main/java/com/xfarrow/locatemydevice/Utils.java
+++ b/src/app/src/main/java/com/xfarrow/locatemydevice/Utils.java
@@ -27,6 +27,7 @@ public class Utils {
public static final String BATTERY_OPTION = "battery";
public static final String CALL_ME_OPTION = "callme";
public static final String WIFI_OPTION = "wifi";
+ public static final String GPS_OPTION = "gps";
public static final String LOCK_OPTION = "lock";
public static final String SHOW_MESSAGE_OPTION = "show";
public static final String RING_OPTION = "ring";
@@ -89,6 +90,27 @@ public static boolean toggleLocationOn(Context context){
}
+ // forcefully toggle location services on (secure setting - needs permission to be granted via adb)
+ @SuppressLint("ObsoleteSdkInt")
+ public static boolean setLocation(Context context, boolean state){
+
+ if (Build.VERSION.SDK_INT < 19) {
+ return false;
+ }
+
+ if(ActivityCompat.checkSelfPermission(context, Manifest.permission.WRITE_SECURE_SETTINGS) != PackageManager.PERMISSION_GRANTED){
+ return false;
+ }
+
+ int locationMode = state
+ ? android.provider.Settings.Secure.LOCATION_MODE_HIGH_ACCURACY // On
+ : android.provider.Settings.Secure.LOCATION_MODE_OFF;
+
+ return android.provider.Settings.Secure.putInt(context.getContentResolver(),
+ android.provider.Settings.Secure.LOCATION_MODE,
+ locationMode);
+ }
+
// forcefully toggle location services off (secure setting - needs permission to be granted via adb)
@SuppressLint("ObsoleteSdkInt")
public static boolean toggleLocationOff(Context context){