mirror of
https://github.com/areteruhiro/LIME-beta-hiro.git
synced 2025-02-10 23:41:38 +09:00
コードの変更
This commit is contained in:
parent
8c990f106d
commit
bc8a91e853
@ -9,8 +9,8 @@ android {
|
|||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdk 28
|
minSdk 28
|
||||||
targetSdk 35
|
targetSdk 35
|
||||||
versionCode 116151
|
versionCode 116154
|
||||||
versionName "1.16.15a"
|
versionName "1.16.15c"
|
||||||
multiDexEnabled false
|
multiDexEnabled false
|
||||||
proguardFiles += 'proguard-rules.pro'
|
proguardFiles += 'proguard-rules.pro'
|
||||||
buildConfigField 'String', 'HOOK_TARGET_VERSION', '"141910383"'
|
buildConfigField 'String', 'HOOK_TARGET_VERSION', '"141910383"'
|
||||||
|
@ -3,6 +3,7 @@ package io.github.hiro.lime.hooks;
|
|||||||
import android.app.AndroidAppHelper;
|
import android.app.AndroidAppHelper;
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.media.MediaPlayer;
|
||||||
import android.media.RingtoneManager;
|
import android.media.RingtoneManager;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
@ -24,7 +25,7 @@ import io.github.hiro.lime.LimeOptions;
|
|||||||
public class RingTone implements IHook {
|
public class RingTone implements IHook {
|
||||||
private android.media.Ringtone ringtone = null;
|
private android.media.Ringtone ringtone = null;
|
||||||
private boolean isPlaying = false;
|
private boolean isPlaying = false;
|
||||||
|
MediaPlayer mediaPlayer = null;
|
||||||
@Override
|
@Override
|
||||||
public void hook(LimeOptions limeOptions, XC_LoadPackage.LoadPackageParam loadPackageParam) throws Throwable {
|
public void hook(LimeOptions limeOptions, XC_LoadPackage.LoadPackageParam loadPackageParam) throws Throwable {
|
||||||
if (!limeOptions.callTone.checked) return;
|
if (!limeOptions.callTone.checked) return;
|
||||||
@ -49,11 +50,9 @@ public class RingTone implements IHook {
|
|||||||
Context moduleContext = AndroidAppHelper.currentApplication().createPackageContext(
|
Context moduleContext = AndroidAppHelper.currentApplication().createPackageContext(
|
||||||
"io.github.hiro.lime", Context.CONTEXT_IGNORE_SECURITY);
|
"io.github.hiro.lime", Context.CONTEXT_IGNORE_SECURITY);
|
||||||
|
|
||||||
|
|
||||||
String resourceName = "ringtone";
|
String resourceName = "ringtone";
|
||||||
int resourceId = moduleContext.getResources().getIdentifier(resourceName, "raw", "io.github.hiro.lime");
|
int resourceId = moduleContext.getResources().getIdentifier(resourceName, "raw", "io.github.hiro.lime");
|
||||||
|
|
||||||
|
|
||||||
File ringtoneDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), "LimeBackup");
|
File ringtoneDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), "LimeBackup");
|
||||||
if (!ringtoneDir.exists()) {
|
if (!ringtoneDir.exists()) {
|
||||||
ringtoneDir.mkdirs();
|
ringtoneDir.mkdirs();
|
||||||
@ -75,24 +74,44 @@ public class RingTone implements IHook {
|
|||||||
|
|
||||||
if (paramValue.contains("type:NOTIFIED_RECEIVED_CALL,") && !isPlaying) {
|
if (paramValue.contains("type:NOTIFIED_RECEIVED_CALL,") && !isPlaying) {
|
||||||
if (context != null) {
|
if (context != null) {
|
||||||
if (ringtone != null && ringtone.isPlaying()) {
|
// MediaPlayerが初期化されているか確認
|
||||||
//Log.d("Xposed", "Ringtone is already playing. Skipping playback.");
|
if (mediaPlayer != null) {
|
||||||
return; // 再生中の場合は何もしない
|
// MediaPlayerが再生中か確認
|
||||||
|
if (mediaPlayer.isPlaying()) {
|
||||||
|
return; // 再生中の場合は何もしない
|
||||||
|
} else {
|
||||||
|
mediaPlayer.release(); // 再生中でない場合は解放
|
||||||
|
mediaPlayer = null; // MediaPlayerのインスタンスをnullに設定
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Uri ringtoneUri = Uri.fromFile(destFile); // コピーしたファイルのURIを取得
|
Uri ringtoneUri = Uri.fromFile(destFile); // コピーしたファイルのURIを取得
|
||||||
ringtone = RingtoneManager.getRingtone(context, ringtoneUri);
|
mediaPlayer = MediaPlayer.create(context, ringtoneUri);
|
||||||
ringtone.play();
|
mediaPlayer.setLooping(true); // 繰り返し再生を設定
|
||||||
isPlaying = true;
|
|
||||||
|
if (mediaPlayer != null) {
|
||||||
|
mediaPlayer.start();
|
||||||
|
isPlaying = true;
|
||||||
|
|
||||||
|
// 再生が終了したときのリスナーを設定
|
||||||
|
mediaPlayer.setOnCompletionListener(mp -> {
|
||||||
|
mp.seekTo(0); // 最初に戻る
|
||||||
|
mp.start(); // 再生を開始
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (paramValue.contains("RESULT=REJECTED,") || paramValue.contains("RESULT=REJECTED,")) {
|
if (paramValue.contains("RESULT=REJECTED,")) {
|
||||||
if (ringtone != null && ringtone.isPlaying()) {
|
if (mediaPlayer != null) {
|
||||||
ringtone.stop();
|
if (mediaPlayer.isPlaying()) {
|
||||||
|
mediaPlayer.stop();
|
||||||
|
}
|
||||||
|
mediaPlayer.release(); // MediaPlayerを解放
|
||||||
|
mediaPlayer = null; // MediaPlayerのインスタンスをnullに設定
|
||||||
isPlaying = false;
|
isPlaying = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -107,34 +126,34 @@ public class RingTone implements IHook {
|
|||||||
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
|
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
|
||||||
|
|
||||||
if (method.getName().equals("setServerConfig")) {
|
if (method.getName().equals("setServerConfig")) {
|
||||||
if (ringtone != null && ringtone.isPlaying()) {
|
if (mediaPlayer != null && mediaPlayer.isPlaying()) {
|
||||||
ringtone.stop();
|
mediaPlayer.stop();
|
||||||
isPlaying = false;
|
mediaPlayer.release(); // MediaPlayerを解放
|
||||||
|
mediaPlayer = null; // MediaPlayerのインスタンスをnullに設定
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (method.getName().equals("stop")) {
|
if (method.getName().equals("stop")) {
|
||||||
if (ringtone != null && ringtone.isPlaying()) {
|
if (mediaPlayer != null && mediaPlayer.isPlaying()) {
|
||||||
ringtone.stop();
|
mediaPlayer.stop();
|
||||||
isPlaying = false;
|
mediaPlayer.release(); // MediaPlayerを解放
|
||||||
|
mediaPlayer = null; // MediaPlayerのインスタンスをnullに設定
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (method.getName().equals("processToneEvent")) {
|
if (method.getName().equals("processToneEvent")) {
|
||||||
Object arg0 = param.args[0];
|
Object arg0 = param.args[0];
|
||||||
if (limeOptions.DialTone.checked) {
|
if (limeOptions.DialTone.checked) {
|
||||||
//Log.d("Xposed", "MuteTone is enabled. Suppressing tone event.");
|
Log.d("Xposed", "MuteTone is enabled. Suppressing tone event.");
|
||||||
param.setResult(null);
|
param.setResult(null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg0.toString().contains("START")) {
|
if (arg0.toString().contains("START")) {
|
||||||
if (appContext != null) {
|
if (appContext != null) {
|
||||||
// ringtone が初期化されており、再生中の場合はスキップ
|
// MediaPlayerが初期化されており、再生中の場合はスキップ
|
||||||
if (ringtone != null && ringtone.isPlaying()) {
|
if (mediaPlayer != null && mediaPlayer.isPlaying()) {
|
||||||
//Log.d("Xposed", "Ringtone is already playing. Skipping playback.");
|
Log.d("Xposed", "MediaPlayer is already playing. Skipping playback.");
|
||||||
return; // 再生中の場合は何もしない
|
return; // 再生中の場合は何もしない
|
||||||
}
|
}
|
||||||
Context moduleContext = AndroidAppHelper.currentApplication().createPackageContext(
|
Context moduleContext = AndroidAppHelper.currentApplication().createPackageContext(
|
||||||
@ -143,7 +162,6 @@ public class RingTone implements IHook {
|
|||||||
String resourceName = "dial_tone";
|
String resourceName = "dial_tone";
|
||||||
int resourceId = moduleContext.getResources().getIdentifier(resourceName, "raw", "io.github.hiro.lime");
|
int resourceId = moduleContext.getResources().getIdentifier(resourceName, "raw", "io.github.hiro.lime");
|
||||||
|
|
||||||
|
|
||||||
File ringtoneDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), "LimeBackup");
|
File ringtoneDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), "LimeBackup");
|
||||||
if (!ringtoneDir.exists()) {
|
if (!ringtoneDir.exists()) {
|
||||||
ringtoneDir.mkdirs(); // ディレクトリが存在しない場合は作成
|
ringtoneDir.mkdirs(); // ディレクトリが存在しない場合は作成
|
||||||
@ -165,40 +183,40 @@ public class RingTone implements IHook {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Uri ringtoneUri = Uri.fromFile(destFile); // コピーしたファイルのURIを取得
|
Uri ringtoneUri = Uri.fromFile(destFile); // コピーしたファイルのURIを取得
|
||||||
ringtone = RingtoneManager.getRingtone(appContext, ringtoneUri);
|
mediaPlayer = MediaPlayer.create(appContext, ringtoneUri);
|
||||||
|
mediaPlayer.setLooping(true); // 繰り返し再生を設定
|
||||||
|
|
||||||
if (ringtone != null) {
|
if (mediaPlayer != null) {
|
||||||
|
Log.d("Xposed", "Playing media.");
|
||||||
//Log.d("Xposed", "Playing ringtone.");
|
mediaPlayer.start();
|
||||||
ringtone.play();
|
|
||||||
isPlaying = true;
|
|
||||||
} else {
|
} else {
|
||||||
//Log.d("Xposed", "Ringtone is null. Cannot play ringtone.");
|
Log.d("Xposed", "MediaPlayer is null. Cannot play media.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//Log.d("Xposed", "appContext is null. Cannot play ringtone.");
|
Log.d("Xposed", "appContext is null. Cannot play media.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
//Log.d("Xposed", "Argument is not 'START'. Actual value: " + arg0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
Log.d("Xposed", "Argument is not 'START'. Actual value: " + arg0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (limeOptions.MuteTone.checked) {
|
if (limeOptions.MuteTone.checked) {
|
||||||
if (method.getName().equals("setTonePlayer")) {
|
if (method.getName().equals("setTonePlayer")) {
|
||||||
param.setResult(null);
|
param.setResult(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (method.getName().equals("ACTIVATED") && param.args != null && param.args.length > 0) {
|
if (method.getName().equals("ACTIVATED") && param.args != null && param.args.length > 0) {
|
||||||
Object arg0 = param.args[0];
|
Object arg0 = param.args[0];
|
||||||
if ("ACTIVATED".equals(arg0)) {
|
if ("ACTIVATED".equals(arg0)) {
|
||||||
if (ringtone != null && ringtone.isPlaying()) {
|
if (mediaPlayer != null && mediaPlayer.isPlaying()) {
|
||||||
ringtone.stop();
|
mediaPlayer.stop();
|
||||||
isPlaying = false;
|
mediaPlayer.release(); // MediaPlayerを解放
|
||||||
|
mediaPlayer = null; // MediaPlayerのインスタンスをnullに設定
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user