From e7dbb61369c4bf27bbedc64e36073b15df1cf99a Mon Sep 17 00:00:00 2001 From: areteruhiro Date: Mon, 3 Feb 2025 22:16:25 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=B3=E3=83=BC=E3=83=89=E3=81=AE=E3=83=AA?= =?UTF-8?q?=E3=83=90=E3=83=BC=E3=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/github/hiro/lime/hooks/RingTone.java | 38 +++---------------- 1 file changed, 6 insertions(+), 32 deletions(-) diff --git a/app/src/main/java/io/github/hiro/lime/hooks/RingTone.java b/app/src/main/java/io/github/hiro/lime/hooks/RingTone.java index 211cc15..f5dd2b0 100644 --- a/app/src/main/java/io/github/hiro/lime/hooks/RingTone.java +++ b/app/src/main/java/io/github/hiro/lime/hooks/RingTone.java @@ -1,4 +1,3 @@ - package io.github.hiro.lime.hooks; import android.app.AndroidAppHelper; @@ -52,32 +51,10 @@ public class RingTone implements IHook { Context moduleContext = AndroidAppHelper.currentApplication().createPackageContext( "io.github.hiro.lime", Context.CONTEXT_IGNORE_SECURITY); - String resourceNameA = "dial_tone"; - int resourceIdA = moduleContext.getResources().getIdentifier(resourceNameA, "raw", "io.github.hiro.lime"); - - File ringtoneDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), "LimeBackup"); - if (!ringtoneDir.exists()) { - ringtoneDir.mkdirs(); - } - File destFileA = new File(ringtoneDir, resourceNameA + ".wav"); - - if (!destFileA.exists()) { - try (InputStream in = moduleContext.getResources().openRawResource(resourceIdA); - OutputStream out = new FileOutputStream(destFileA)) { - byte[] buffer = new byte[1024]; - int length; - while ((length = in.read(buffer)) > 0) { - out.write(buffer, 0, length); - } - } catch (IOException e) { - e.printStackTrace(); - } - } - - String resourceName = "ringtone"; int resourceId = moduleContext.getResources().getIdentifier(resourceName, "raw", "io.github.hiro.lime"); + File ringtoneDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), "LimeBackup"); if (!ringtoneDir.exists()) { ringtoneDir.mkdirs(); } @@ -96,9 +73,6 @@ public class RingTone implements IHook { } } - - - if (paramValue.contains("type:NOTIFIED_RECEIVED_CALL,") && !isPlaying) { if (context != null) { if (mediaPlayer != null) { @@ -185,11 +159,11 @@ public class RingTone implements IHook { if (!ringtoneDir.exists()) { ringtoneDir.mkdirs(); } - File destFileA = new File(ringtoneDir, resourceNameA + ".wav"); + File destFile = new File(ringtoneDir, resourceNameA + ".wav"); - if (!destFileA.exists()) { + if (!destFile.exists()) { try (InputStream in = moduleContext.getResources().openRawResource(resourceIdA); - OutputStream out = new FileOutputStream(destFileA)) { + OutputStream out = new FileOutputStream(destFile)) { byte[] buffer = new byte[1024]; int length; while ((length = in.read(buffer)) > 0) { @@ -200,7 +174,7 @@ public class RingTone implements IHook { } } - Uri ringtoneUri = Uri.fromFile(destFileA); + Uri ringtoneUri = Uri.fromFile(destFile); mediaPlayer = MediaPlayer.create(appContext, ringtoneUri); mediaPlayer.setLooping(true); @@ -242,4 +216,4 @@ public class RingTone implements IHook { } }); } -} +} \ No newline at end of file