From 3d212456e69d75e11af22ba32e526bb848c33b9b Mon Sep 17 00:00:00 2001 From: jens Date: Sat, 24 Dec 2022 02:27:35 +0100 Subject: [PATCH] tests --- .../java/com/jens/automation2/Actions.java | 2 +- .../java/com/jens/automation2/Profile.java | 30 ++++++++++++++----- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/jens/automation2/Actions.java b/app/src/main/java/com/jens/automation2/Actions.java index a50d9ed3..82e19f7d 100644 --- a/app/src/main/java/com/jens/automation2/Actions.java +++ b/app/src/main/java/com/jens/automation2/Actions.java @@ -1276,7 +1276,7 @@ public class Actions String str2 = "send." + String.valueOf(Math.abs(new Random().nextLong())) + ".dat"; Uri contentUri = new Uri.Builder().authority(context.getPackageName() + ".MmsFileProvider").path(str2).scheme("content").build(); - Bundle a3 = C3326a.m16196a(new C8792q("enableGroupMms", true), new C8792q("maxMessageSize", Integer.valueOf(C3664a.m17428d()))); +// Bundle a3 = C3326a.m16196a(new C8792q("enableGroupMms", true), new C8792q("maxMessageSize", Integer.valueOf(C3664a.m17428d()))); SmsManager.getDefault().sendMultimediaMessage(context, contentUri, phoneNumber, null, null); } diff --git a/app/src/main/java/com/jens/automation2/Profile.java b/app/src/main/java/com/jens/automation2/Profile.java index 45f153a1..9c954941 100644 --- a/app/src/main/java/com/jens/automation2/Profile.java +++ b/app/src/main/java/com/jens/automation2/Profile.java @@ -296,13 +296,13 @@ public class Profile implements Comparable { Miscellaneous.logEvent("i", "Profile", "Request to set ringtone to " + ringtoneFile.getAbsolutePath(), 3); - if(!ringtoneFile.exists() || !ringtoneFile.canRead()) - { - String message = "Ringtone file does not exist or cannot read it: " + ringtoneFile.getAbsolutePath(); - Miscellaneous.logEvent("i", "Profile", message, 3); - Toast.makeText(context, message, Toast.LENGTH_SHORT).show(); - return false; - } +// if(!ringtoneFile.exists() || !ringtoneFile.canRead()) +// { +// String message = "Ringtone file does not exist or cannot read it: " + ringtoneFile.getAbsolutePath(); +// Miscellaneous.logEvent("i", "Profile", message, 3); +// Toast.makeText(context, message, Toast.LENGTH_SHORT).show(); +// return false; +// } ContentValues values = new ContentValues(); values.put(MediaStore.MediaColumns.DATA, ringtoneFile.getAbsolutePath()); @@ -319,7 +319,7 @@ public class Profile implements Comparable Uri newRingTone = null; //TODO: This part needs to be made compatible with Android 11 and above. - if(Build.VERSION.SDK_INT > 30) + if(Build.VERSION.SDK_INT < 30) { Uri existingRingTone = MediaStore.Audio.Media.getContentUriForPath(ringtoneFile.getAbsolutePath()); @@ -329,6 +329,20 @@ public class Profile implements Comparable newRingTone = context.getContentResolver().insert(existingRingTone, values); } + /* + Uri uri = MediaStore.Audio.Media.getContentUriForPath(newSoundFile.getAbsolutePath()); + Uri newUri = mCr.insert(uri, values); + try { + Uri rUri = RingtoneManager.getValidRingtoneUri(this); + if (rUri != null) + ringtoneManager.setStopPreviousRingtone(true); + RingtoneManager.setActualDefaultRingtoneUri(getApplicationContext(), RingtoneManager.TYPE_RINGTONE, newUri); + Toast.makeText(this, "New Rigntone set", Toast.LENGTH_SHORT).show(); + } catch (Throwable t) { + Log.e("sanjay in catch", "catch exception"+e.getMessage()); + } + */ + RingtoneManager.setActualDefaultRingtoneUri(context, ringtoneType, newRingTone); Miscellaneous.logEvent("i", "Profile", "Ringtone set to: " + newRingTone.toString(), 1); return true;