From d3d178d245ff4ba856de082d0be0e2cd8c4ce804 Mon Sep 17 00:00:00 2001 From: Alessandro Ferro <49845537+xfarrow@users.noreply.github.com> Date: Mon, 10 Oct 2022 11:33:41 +0200 Subject: [PATCH] Update ringing option --- .../java/com/xfarrow/locatemydevice/SmsHandler.java | 11 +++++++++++ 1 file changed, 11 insertions(+) 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 051b114..1775b4c 100644 --- a/src/app/src/main/java/com/xfarrow/locatemydevice/SmsHandler.java +++ b/src/app/src/main/java/com/xfarrow/locatemydevice/SmsHandler.java @@ -339,6 +339,17 @@ public class SmsHandler { // ring else if(providedOption.equals(Utils.RING_OPTION)){ + // In this way the smartphone will ring only if the overlay on screen permission + // has been granted. This is not something inherently related to ringing, + // rather on the Activity used to show the button "Stop". We could make the phone ring + // without the overlay permission, but there would be no way to stop it except for + // powering it off or closing it from the recent applications (impossible if the phone + // is lost and locked). + if(!android.provider.Settings.canDrawOverlays(context)) { + Utils.sendSms(smsManager, "Unable to ring. Overlay permission not granted.", + sender); + return; + } Intent ringerActivityIntent = new Intent(context, RingerActivity.class); ringerActivityIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(ringerActivityIntent);