From 1200264e4ea48ae4143dfc197e06bf1eafecf5d9 Mon Sep 17 00:00:00 2001
From: pppscn <35696959@qq.com>
Date: Wed, 23 Feb 2022 23:42:19 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=EF=BC=9A=E4=BF=9D=E6=B4=BB?=
=?UTF-8?q?=E6=8E=AA=E6=96=BD-=E6=92=AD=E6=94=BE=E6=97=A0=E5=A3=B0?=
=?UTF-8?q?=E9=9F=B3=E4=B9=90=E8=AE=A9=E5=90=8E=E5=8F=B0=E4=B8=80=E7=9B=B4?=
=?UTF-8?q?=E8=BF=90=E8=A1=8C=EF=BC=88=E5=8F=AF=E8=83=BD=E6=AF=94=E8=BE=83?=
=?UTF-8?q?=E8=80=97=E7=94=B5=EF=BC=8C=E6=8C=89=E9=9C=80=E5=90=AF=E7=94=A8?=
=?UTF-8?q?=EF=BC=89?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/src/main/AndroidManifest.xml | 5 +
.../idormy/sms/forwarder/MainActivity.java | 11 ++
.../idormy/sms/forwarder/MyApplication.java | 6 ++
.../idormy/sms/forwarder/SettingActivity.java | 71 ++++++++++++-
.../receiver/RebootBroadcastReceiver.java | 7 ++
.../sms/forwarder/service/MusicService.java | 95 ++++++++++++++++++
.../idormy/sms/forwarder/utils/Define.java | 1 +
.../sms/forwarder/utils/SettingUtil.java | 8 ++
app/src/main/res/layout/activity_setting.xml | 61 ++++++++++-
app/src/main/res/raw/silence.mp3 | Bin 0 -> 191007 bytes
app/src/main/res/values-en/strings.xml | 2 +
app/src/main/res/values/strings.xml | 4 +-
12 files changed, 265 insertions(+), 6 deletions(-)
create mode 100644 app/src/main/java/com/idormy/sms/forwarder/service/MusicService.java
create mode 100644 app/src/main/res/raw/silence.mp3
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 1c85667a..1e7ce2bf 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -156,6 +156,11 @@
+
{
+ SettingUtil.switchPlaySilenceMusic(isChecked);
+
+ if (isChecked) {
+ startService(new Intent(context, MusicService.class));
+ } else {
+ stopService(new Intent(context, MusicService.class));
+ }
+ Log.d(TAG, "onCheckedChanged:" + isChecked);
+ });
+ }
+
//接口请求失败重试时间间隔
private void editRetryDelayTime(final EditText et_retry_times, final EditText et_delay_time) {
et_retry_times.setText(String.valueOf(SettingUtil.getRetryTimes()));
@@ -945,4 +968,48 @@ public class SettingActivity extends AppCompatActivity {
return super.onMenuOpened(featureId, menu);
}
+ /**
+ * 获取当前手机品牌
+ *
+ * @return 手机品牌
+ */
+ public static String getAutoStartTips() {
+ String brand = Build.BRAND.toLowerCase();
+ String tips;
+
+ switch (brand) {
+ case "huawei":
+ tips = "华为手机:应用启动管理 -> 关闭应用开关 -> 打开允许自启动";
+ break;
+ case "honor":
+ tips = "荣耀手机:应用启动管理 -> 关闭应用开关 -> 打开允许自启动";
+ break;
+ case "xiaomi":
+ tips = "小米手机:授权管理 -> 自启动管理 -> 允许应用自启动";
+ break;
+ case "oppo":
+ tips = "OPPO手机:权限隐私 -> 自启动管理 -> 允许应用自启动";
+ break;
+ case "vivo":
+ tips = "vivo手机:权限管理 -> 自启动 -> 允许应用自启动";
+ break;
+ case "meizu":
+ tips = "魅族手机:权限管理 -> 后台管理 -> 点击应用 -> 允许后台运行";
+ break;
+ case "samsung":
+ tips = "三星手机:自动运行应用程序 -> 打开应用开关 -> 电池管理 -> 未监视的应用程序 -> 添加应用";
+ break;
+ case "letv":
+ tips = "乐视手机:自启动管理 -> 允许应用自启动";
+ break;
+ case "smartisan":
+ tips = "锤子手机:权限管理 -> 自启动权限管理 -> 点击应用 -> 允许被系统启动";
+ break;
+ default:
+ tips = "未知手机品牌:需要自主查看设置操作";
+ break;
+ }
+
+ return tips;
+ }
}
diff --git a/app/src/main/java/com/idormy/sms/forwarder/receiver/RebootBroadcastReceiver.java b/app/src/main/java/com/idormy/sms/forwarder/receiver/RebootBroadcastReceiver.java
index 88acd49e..508ce591 100644
--- a/app/src/main/java/com/idormy/sms/forwarder/receiver/RebootBroadcastReceiver.java
+++ b/app/src/main/java/com/idormy/sms/forwarder/receiver/RebootBroadcastReceiver.java
@@ -8,7 +8,9 @@ import android.util.Log;
import com.idormy.sms.forwarder.service.BatteryService;
import com.idormy.sms.forwarder.service.FrontService;
+import com.idormy.sms.forwarder.service.MusicService;
import com.idormy.sms.forwarder.utils.InitUtil;
+import com.idormy.sms.forwarder.utils.SettingUtil;
public class RebootBroadcastReceiver extends BroadcastReceiver {
@@ -31,6 +33,11 @@ public class RebootBroadcastReceiver extends BroadcastReceiver {
//电池状态监听
Intent batteryServiceIntent = new Intent(context, BatteryService.class);
context.startService(batteryServiceIntent);
+
+ //后台播放无声音乐
+ if (SettingUtil.getPlaySilenceMusic()) {
+ context.startService(new Intent(context, MusicService.class));
+ }
}
}
diff --git a/app/src/main/java/com/idormy/sms/forwarder/service/MusicService.java b/app/src/main/java/com/idormy/sms/forwarder/service/MusicService.java
new file mode 100644
index 00000000..1a88abf8
--- /dev/null
+++ b/app/src/main/java/com/idormy/sms/forwarder/service/MusicService.java
@@ -0,0 +1,95 @@
+package com.idormy.sms.forwarder.service;
+
+import android.app.Service;
+import android.content.Intent;
+import android.media.AudioManager;
+import android.media.MediaPlayer;
+import android.os.IBinder;
+import android.util.Log;
+
+import com.idormy.sms.forwarder.R;
+
+public class MusicService extends Service {
+
+ private final String TAG = "MusicService";
+
+ private MediaPlayer mMediaPlayer;
+
+ private AudioManager mAudioManager;
+
+ private final AudioManager.OnAudioFocusChangeListener mAudioFocusChange = new
+ AudioManager.OnAudioFocusChangeListener() {
+ @Override
+ public void onAudioFocusChange(int focusChange) {
+ switch (focusChange) {
+ case AudioManager.AUDIOFOCUS_GAIN:
+ Log.e(TAG, "AUDIOFOCUS_GAIN");
+ try {
+ startPlayMusic();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ break;
+ case AudioManager.AUDIOFOCUS_LOSS:
+ Log.e(TAG, "AUDIOFOCUS_LOSS");
+ mAudioManager.abandonAudioFocus(mAudioFocusChange);
+ break;
+ case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT:
+ Log.e(TAG, "AUDIOFOCUS_LOSS_TRANSIENT");
+ break;
+ case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK:
+ Log.e(TAG, "AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK");
+ break;
+ }
+ }
+ };
+
+ public MusicService() {
+
+ }
+
+ @Override
+ public IBinder onBind(Intent intent) {
+ // TODO: Return the communication channel to the service.
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ @Override
+ public int onStartCommand(Intent intent, int flags, int startId) {
+ //音标处理
+ mAudioManager = (AudioManager) getSystemService(AUDIO_SERVICE);
+ if (mAudioManager != null)
+ mAudioManager.requestAudioFocus(mAudioFocusChange, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN);
+
+ mMediaPlayer = MediaPlayer.create(getApplicationContext(), R.raw.silence);
+ mMediaPlayer.setLooping(true);
+
+ startPlayMusic();
+
+ return START_STICKY;
+ }
+
+
+ private void startPlayMusic() {
+ if (mMediaPlayer != null && !mMediaPlayer.isPlaying()) {
+ Log.e(TAG, "启动后台播放音乐");
+ mMediaPlayer.start();
+ }
+ }
+
+ private void stopPlayMusic() {
+ if (mMediaPlayer != null) {
+ Log.e(TAG, "关闭后台播放音乐");
+ mMediaPlayer.stop();
+ }
+ }
+
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ stopPlayMusic();
+ Log.e(TAG, TAG + "---->onDestroy,停止服务");
+ }
+
+}
+
diff --git a/app/src/main/java/com/idormy/sms/forwarder/utils/Define.java b/app/src/main/java/com/idormy/sms/forwarder/utils/Define.java
index 0fbbd9d8..b1d8095c 100644
--- a/app/src/main/java/com/idormy/sms/forwarder/utils/Define.java
+++ b/app/src/main/java/com/idormy/sms/forwarder/utils/Define.java
@@ -11,6 +11,7 @@ public class Define {
public static final String SP_MSG_KEY_STRING_ENABLE_APP_NOTIFY = "tsms_msg_key_switch_enable_app_notify";
public static final String SP_MSG_KEY_STRING_CANCEL_APP_NOTIFY = "tsms_msg_key_switch_cancel_app_notify";
public static final String SP_MSG_KEY_STRING_ENABLE_EXCLUDE_FROM_RECENTS = "tsms_msg_key_switch_enable_exclude_from_recents";
+ public static final String SP_MSG_KEY_STRING_ENABLE_PLAY_SILENCE_MUSIC = "tsms_msg_key_switch_enable_play_silence_music";
public static final String SP_MSG_KEY_STRING_ADD_EXTRA_DEVICE_MARK = "tsms_msg_key_string_add_extra_device_mark";
public static final String SP_MSG_KEY_STRING_ADD_EXTRA_SIM1 = "tsms_msg_key_string_add_extra_sim1";
public static final String SP_MSG_KEY_STRING_ADD_EXTRA_SIM2 = "tsms_msg_key_string_add_extra_sim2";
diff --git a/app/src/main/java/com/idormy/sms/forwarder/utils/SettingUtil.java b/app/src/main/java/com/idormy/sms/forwarder/utils/SettingUtil.java
index 28055786..cc62b03a 100644
--- a/app/src/main/java/com/idormy/sms/forwarder/utils/SettingUtil.java
+++ b/app/src/main/java/com/idormy/sms/forwarder/utils/SettingUtil.java
@@ -93,6 +93,14 @@ public class SettingUtil {
return sp_setting.getBoolean(Define.SP_MSG_KEY_STRING_ENABLE_EXCLUDE_FROM_RECENTS, false);
}
+ public static void switchPlaySilenceMusic(Boolean enable) {
+ sp_setting.edit().putBoolean(Define.SP_MSG_KEY_STRING_ENABLE_PLAY_SILENCE_MUSIC, enable).apply();
+ }
+
+ public static boolean getPlaySilenceMusic() {
+ return sp_setting.getBoolean(Define.SP_MSG_KEY_STRING_ENABLE_PLAY_SILENCE_MUSIC, false);
+ }
+
public static void switchSmsTemplate(Boolean switchSmsTemplate) {
sp_setting.edit().putBoolean(Define.SP_MSG_KEY_SWITCH_SMS_TEMPLATE, switchSmsTemplate).apply();
}
diff --git a/app/src/main/res/layout/activity_setting.xml b/app/src/main/res/layout/activity_setting.xml
index 9e9db791..e03816d1 100644
--- a/app/src/main/res/layout/activity_setting.xml
+++ b/app/src/main/res/layout/activity_setting.xml
@@ -544,12 +544,26 @@
android:orientation="horizontal"
android:padding="15dp">
-
+ android:orientation="vertical">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
*EXVqjSp;#(Hk>U>bzQIDUe}A;-#@p1-X1^xxUQF9KY#o3;obYYyZh(&NB_S+
zJ^p_9^z#h#{8+~SIH57d%EyFOvW!v*jWJd}CbW`eluBrfvGOsYl`NxFLSu}Tj|r`0
z8Kn{$W2}5kXeG-imCzVt2X3j0Tf6G2GZk%bOI=l5DcWp3F!n-AR!n?j}y`fpg=+}kRB(b6F`B4U?4qCNGE^-
z3Bf>moRCfc1rmaR^f)1%016}o1L<)>Isp_&2nN#QgmeNZkPr-{#|h~K=K?xV*X7PY
z_qtHm00k0)f%G^bod60X1Ow@DLOKByNC*bf00k0)f%G^bod60X1Ow@DLOKByNC*bf2X3j0Tf6G2GZk%bOI=l
z5DcWp3F!n-AR!n?j}y`fpg=+}kRB(b6F`B4U?4qCNGE^-3Bf>itOIpj4qgFWsLNOh
z!2;Xk&QL2X3j0Tf6G2GZk%bOI=l5DcWp3F!n-AR!n?j}y`fpg=+}
zkRB(b6F`B4U?4qCNGE^-3Bf>moRCfc1rmaR^f)1%016}o1L<)>Isp_&2nN#Qgmi*)
z0Uf9djc1^K{}1-@WBm+u84F&5gkT^&PDm$!0tvxDdYq6>00k0)f%G^bod60X1Ow@D
zLOKByNC*bfUyaKvVm$4Fp1-8eXp@d+8zH%^7X9xz;+EjI#3rH&p`eDAME4D`Wfmn7Q6%r!9aSPkWK&v
z5`uyBI3b+?3M2#r>2X3j0Tf6G2GZk%bOI=l5DcWp3F!n-AR!n?j}y`fpg=+}kRB(b
z6F`B4U?4qCNGE^-3Bf>moRCfc1rmaR^f)1%016}o1KF_-)O9&{1$3bzub
z3Bdw=moRCfc
z1rmaR^f)1%016}o1L<)>Isp_&2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44dbd 100644
--- a/app/src/main/res/values-en/strings.xml
+++ b/app/src/main/res/values-en/strings.xml
@@ -434,4 +434,6 @@
被永久拒绝授权,请前往系统设置手动授予权限!
获取必需的权限失败,APP功能可能受限!
\n 首次使用请按照1234步骤顺序设置,数字点亮表示该步骤已设置(4点亮表示有成功日志)!\n\n 根据以往用户反馈,90%的新用户最终排查结果都是手机权限设置问题,5%的用户是APP保活问题,其他问题排查参考Wiki中的常见问题(APP右上角使用帮助入口)\n\n 强烈建议:手动排查一下系统设置:自启动、电源策略、APP的权限,把所有权限打开(始终允许,不要“使用中允许”,MIUI系统就全部变绿),特别是一些国产定制系统加入隐私保护、验证码保护等(例如:MIUI 系统的 空白通行证)\n\n 请选择是否立即“前往系统设置”检查,或“稍后自行处理”?
+ Play silent music in the background
+ Play silent music to keep running in the background, which may consume more power, enable it on demand
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 6fb0f29f..9619b676 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -327,7 +327,7 @@
电池监控
【注意】需要手动创建APP转发规则,包名:88888888
保活措施
- 建议开启每一项授权或设置,不要禁用通知栏,避免APP被杀
+ 建议开启前三项授权或设置,不要禁用通知栏,避免APP被杀
个性设置
如果自动获取失败,请手动填写备注 或 清空后再次自动获取
次
@@ -433,4 +433,6 @@
被永久拒绝授权,请前往系统设置手动授予权限!
获取必需的权限失败,APP功能可能受限!
\n 首次使用请按照1234步骤顺序设置,数字点亮表示该步骤已设置(4点亮表示有成功日志)!\n\n 根据以往用户反馈,90%的新用户最终排查结果都是手机权限设置问题,5%的用户是APP保活问题,其他问题排查参考Wiki中的常见问题(APP右上角使用帮助入口)\n\n 强烈建议:手动排查一下系统设置:自启动、电源策略、APP的权限,把所有权限打开(始终允许,不要“使用中允许”,MIUI系统就全部变绿),特别是一些国产定制系统加入隐私保护、验证码保护等(例如:MIUI 系统的 空白通行证)\n\n 请选择是否立即“前往系统设置”检查,或“稍后自行处理”?
+ 后台播放无声音乐
+ 播放无声音乐让后台一直运行,可能比较耗电,按需启用