Compare commits
73 Commits
ac624c70b2
...
system
| Author | SHA1 | Date | |
|---|---|---|---|
| 4e8f666802 | |||
| 884aefc366 | |||
| 2c84258ae2 | |||
| 7297b8f1c4 | |||
| 48be0900e1 | |||
| 620235c089 | |||
| b3752e4716 | |||
| ffc88920db | |||
| 492cafb51a | |||
| bfc5e4905a | |||
| e55cba4b63 | |||
| 59eae71d70 | |||
| 4463c24107 | |||
| c416971d67 | |||
| 21dc14ba5f | |||
| b4b02d0b1c | |||
| 443b41fde6 | |||
| 09908fcdc7 | |||
| 10b7fc57c1 | |||
| 55b181cba7 | |||
| f0a49ef542 | |||
| a398e59655 | |||
| d8523a3f3c | |||
| 7681db0596 | |||
| d500f8ee41 | |||
| 81af975717 | |||
| db097f7dd9 | |||
| 2314852b1c | |||
| 308ceedbe5 | |||
| 90e705b043 | |||
| a451f4ffc2 | |||
| ebd667f391 | |||
| a5b306a4a2 | |||
| acf592153e | |||
| 976bb6316b | |||
| e39170ef45 | |||
| 9ed7c9bcbb | |||
| f17489bdbb | |||
| 3e284d528e | |||
| 172a26896d | |||
| acdd23567e | |||
| e5d8b244d1 | |||
| b64cb19e17 | |||
| a5e081a0a1 | |||
| 5fd4acf9fb | |||
| 1ecf3998ad | |||
| d52b837175 | |||
| 82d21d98be | |||
| cc4ef4939c | |||
| e59de5764e | |||
| edef32dc07 | |||
| a79a381b00 | |||
| cf08d5b5a5 | |||
| 8bfdaf761c | |||
| 33fa742d2e | |||
| e1241a01c3 | |||
| f46467e83d | |||
| cc0afc2338 | |||
| cbf7f3eeea | |||
| 935ded253b | |||
| f95229b421 | |||
| fef6a08ea6 | |||
| 67900cd09a | |||
| 1e71f67c59 | |||
| 003238da4c | |||
| 1938470b43 | |||
| 1220777e5a | |||
| f288d8c6f2 | |||
| e16a598617 | |||
| 38e391ff46 | |||
| 79a246cbd6 | |||
| 935bd0edc3 | |||
| 4009796ac2 |
22
.gitignore
vendored
22
.gitignore
vendored
@@ -2,4 +2,24 @@
|
|||||||
.idea
|
.idea
|
||||||
.DS_Store
|
.DS_Store
|
||||||
local.properties
|
local.properties
|
||||||
app/debug/app-debug.apk
|
# Built application files
|
||||||
|
*.apk
|
||||||
|
*.ap_
|
||||||
|
|
||||||
|
# Generated files
|
||||||
|
bin/
|
||||||
|
gen/
|
||||||
|
out/
|
||||||
|
|
||||||
|
# Gradle files
|
||||||
|
build/
|
||||||
|
|
||||||
|
# Keystore files
|
||||||
|
*.jks
|
||||||
|
*.keystore
|
||||||
|
|
||||||
|
app/release
|
||||||
|
app/release/*
|
||||||
|
app/debug
|
||||||
|
app/debug/*
|
||||||
|
app/debug/output-metadata.json
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ android {
|
|||||||
minSdk 26
|
minSdk 26
|
||||||
targetSdk 31
|
targetSdk 31
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "1.0"
|
versionName "1.0.1"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
@@ -43,6 +43,6 @@ dependencies {
|
|||||||
implementation 'com.google.android.material:material:1.3.0'
|
implementation 'com.google.android.material:material:1.3.0'
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
|
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
|
||||||
testImplementation 'junit:junit:4.13.2'
|
testImplementation 'junit:junit:4.13.2'
|
||||||
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
|
androidTestImplementation 'androidx.test.ext:junit:1.1.4'
|
||||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
|
||||||
}
|
}
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
{
|
|
||||||
"version": 3,
|
|
||||||
"artifactType": {
|
|
||||||
"type": "APK",
|
|
||||||
"kind": "Directory"
|
|
||||||
},
|
|
||||||
"applicationId": "com.nbee.echolink",
|
|
||||||
"variantName": "debug",
|
|
||||||
"elements": [
|
|
||||||
{
|
|
||||||
"type": "SINGLE",
|
|
||||||
"filters": [],
|
|
||||||
"attributes": [],
|
|
||||||
"versionCode": 1,
|
|
||||||
"versionName": "1.0",
|
|
||||||
"outputFile": "app-debug.apk"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"elementType": "File"
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
package="com.nbee.echolink"
|
||||||
|
android:sharedUserId="android.uid.system"
|
||||||
xmlns:tools="http://schemas.android.com/tools">
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
||||||
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||||
<uses-permission android:name="android.permission.ACTION_NOTIFICATION_LISTENER_SETTINGS" />
|
<uses-permission android:name="android.permission.ACTION_NOTIFICATION_LISTENER_SETTINGS" />
|
||||||
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/>
|
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/>
|
||||||
<uses-permission android:name="android.permission.ANSWER_PHONE_CALLS" />
|
<uses-permission android:name="android.permission.ANSWER_PHONE_CALLS" />
|
||||||
@@ -20,6 +23,7 @@
|
|||||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:name=".EchoLink"
|
android:name=".EchoLink"
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
@@ -49,6 +53,10 @@
|
|||||||
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
|
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</receiver>
|
</receiver>
|
||||||
|
<receiver android:name=".broadcast.HeartbeatAlarmReceiver"
|
||||||
|
android:enabled="true"
|
||||||
|
android:exported="true">
|
||||||
|
</receiver>
|
||||||
<receiver android:name=".broadcast.PhoneCallReceiver"
|
<receiver android:name=".broadcast.PhoneCallReceiver"
|
||||||
android:enabled="true"
|
android:enabled="true"
|
||||||
android:exported="true">
|
android:exported="true">
|
||||||
@@ -63,6 +71,14 @@
|
|||||||
<action android:name="android.intent.action.BOOT_COMPLETED"/>
|
<action android:name="android.intent.action.BOOT_COMPLETED"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</receiver>
|
</receiver>
|
||||||
<service android:name=".service.MonitorService" />
|
<service android:name=".service.MonitorService"/>
|
||||||
|
<service android:name=".service.NotificationListener"
|
||||||
|
android:label="NotificationListener"
|
||||||
|
android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE"
|
||||||
|
android:exported="true">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.service.notification.NotificationListenerService" />
|
||||||
|
</intent-filter>
|
||||||
|
</service>
|
||||||
</application>
|
</application>
|
||||||
</manifest>
|
</manifest>
|
||||||
@@ -1,20 +1,10 @@
|
|||||||
package com.nbee.echolink;
|
package com.nbee.echolink;
|
||||||
|
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.content.Context;
|
|
||||||
|
|
||||||
import androidx.work.ExistingPeriodicWorkPolicy;
|
|
||||||
import androidx.work.PeriodicWorkRequest;
|
|
||||||
import androidx.work.WorkManager;
|
|
||||||
|
|
||||||
import com.nbee.echolink.utils.HeartbeatWorker;
|
|
||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
import timber.log.Timber;
|
import timber.log.Timber;
|
||||||
|
|
||||||
|
|
||||||
public class EchoLink extends Application {
|
public class EchoLink extends Application {
|
||||||
private static final int EXECUTION_INTERVAL = 15; // 示例:15分钟
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
@@ -24,17 +14,6 @@ public class EchoLink extends Application {
|
|||||||
// 打印日志文件的路径
|
// 打印日志文件的路径
|
||||||
Timber.d("Log file path: " + this.getFilesDir() + "/logs/echoLink.log");
|
Timber.d("Log file path: " + this.getFilesDir() + "/logs/echoLink.log");
|
||||||
// 安排定时任务
|
// 安排定时任务
|
||||||
doScheduledTask(this);
|
// doScheduledTask(this);
|
||||||
}
|
|
||||||
private void doScheduledTask(Context context){
|
|
||||||
Timber.d("start do scheduled task");
|
|
||||||
PeriodicWorkRequest heartbeatWorkRequest =
|
|
||||||
new PeriodicWorkRequest.Builder(HeartbeatWorker.class, EXECUTION_INTERVAL, TimeUnit.MINUTES)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
// 安排周期性工作
|
|
||||||
WorkManager.getInstance(context).enqueueUniquePeriodicWork("HeartbeatWork",
|
|
||||||
ExistingPeriodicWorkPolicy.KEEP,
|
|
||||||
heartbeatWorkRequest);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package com.nbee.echolink;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import timber.log.Timber;
|
import timber.log.Timber;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|||||||
@@ -1,102 +1,250 @@
|
|||||||
package com.nbee.echolink;
|
package com.nbee.echolink;
|
||||||
|
|
||||||
import static java.lang.Thread.*;
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.work.ExistingPeriodicWorkPolicy;
|
|
||||||
import androidx.work.PeriodicWorkRequest;
|
|
||||||
import androidx.work.WorkManager;
|
|
||||||
|
|
||||||
|
import com.nbee.echolink.async.BatteryOptimizationTask;
|
||||||
import com.nbee.echolink.service.MonitorService;
|
import com.nbee.echolink.service.MonitorService;
|
||||||
|
import com.nbee.echolink.service.NotificationListener;
|
||||||
import com.nbee.echolink.utils.BatteryOptimizationUtil;
|
import com.nbee.echolink.utils.BatteryOptimizationUtil;
|
||||||
import com.nbee.echolink.utils.HeartbeatWorker;
|
import com.nbee.echolink.utils.DeviceInfoUtils;
|
||||||
import com.nbee.echolink.utils.PermissionUtils;
|
import com.nbee.echolink.utils.PermissionUtils;
|
||||||
|
import com.nbee.echolink.utils.SharedPreferencesManager;
|
||||||
import com.nbee.echolink.utils.ShellUtils;
|
import com.nbee.echolink.utils.ShellUtils;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.io.PrintWriter;
|
||||||
|
|
||||||
import timber.log.Timber;
|
import timber.log.Timber;
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
private final String TAG = "MainActivity";
|
private final String TAG = "MainActivity";
|
||||||
private PermissionUtils permissionUtils;
|
private PermissionUtils permissionUtils;
|
||||||
|
private SharedPreferencesManager spManager;
|
||||||
private TextView logTextView; // 将类型从 View 更改为 TextView
|
private TextView logTextView; // 将类型从 View 更改为 TextView
|
||||||
private ShellUtils shellUtils;
|
|
||||||
private boolean isRoot;
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当活动被创建时调用。
|
||||||
|
* 主要负责初始化界面、检查权限、设置初始数据、启动服务等操作。
|
||||||
|
*
|
||||||
|
* @param savedInstanceState 如果活动之前被销毁,这参数包含之前的状态。如果活动没被销毁之前,这参数是null。
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
// 设置对应的布局文件
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
|
|
||||||
isRoot = shellUtils.checkRootPermission();
|
// 初始化“清除日志”按钮
|
||||||
if (!isRoot){
|
Button clearAllLogs = findViewById(R.id.clearLogsButton);
|
||||||
Timber.d("未获取root权限: "+ isRoot);
|
|
||||||
}
|
// 初始化日志文本视图并显示初始化信息
|
||||||
logTextView = findViewById(R.id.logTextView);
|
logTextView = findViewById(R.id.logTextView);
|
||||||
updateLog("初始化日志...");
|
updateLog("初始化日志...");
|
||||||
|
|
||||||
requestIgnoreBattery();
|
// 初始化SharedPreferences管理器
|
||||||
|
spManager = new SharedPreferencesManager(this);
|
||||||
|
|
||||||
|
// 检查是否是首次运行,是则进行初始数据设置
|
||||||
|
if (isFirstRun()) {
|
||||||
|
setupInitialDataAsync(); // 异步设置初始数据
|
||||||
|
spManager.putBoolean("isFirstRun", false); // 标记不再首次运行
|
||||||
|
Timber.i("首次运行,设置初始数据...");
|
||||||
|
Timber.d("android_ID: " + DeviceInfoUtils.getAndroidID(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 请求忽略电池优化设置
|
||||||
|
requestIgnoreBatteryAsync();
|
||||||
|
|
||||||
|
// 初始化权限工具类
|
||||||
permissionUtils = new PermissionUtils(this);
|
permissionUtils = new PermissionUtils(this);
|
||||||
permissionUtils.checkPermissions();
|
permissionUtils.checkPermissions();
|
||||||
// 启动MonitorService服务
|
|
||||||
|
|
||||||
|
// 检查通知权限是否开启
|
||||||
|
if (permissionUtils.isNotificationServiceEnabled(this)) {
|
||||||
|
// 权限已开启,可以执行相关操作
|
||||||
|
} else {
|
||||||
|
// 权限未开启,引导用户去设置页面开启
|
||||||
|
Intent intent = new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS");
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 启动MonitorService服务
|
||||||
Intent serviceIntent = new Intent(this, MonitorService.class);
|
Intent serviceIntent = new Intent(this, MonitorService.class);
|
||||||
startService(serviceIntent);
|
startService(serviceIntent);
|
||||||
|
|
||||||
|
// 启动通知监听服务
|
||||||
|
Intent serviceIntent1 = new Intent(this, NotificationListener.class);
|
||||||
|
startService(serviceIntent1);
|
||||||
|
|
||||||
|
// 设置点击“清除日志”按钮的监听器
|
||||||
|
clearAllLogs.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
clearLogs(); // 调用清空日志的方法
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理权限请求的结果。
|
||||||
|
* 当用户对应用的权限请求做出响应时,系统会调用此方法。
|
||||||
|
*
|
||||||
|
* @param requestCode 请求码,用于标识哪个权限请求被响应。
|
||||||
|
* @param permissions 请求的权限数组。
|
||||||
|
* @param grantResults 请求结果的整型数组,每个元素对应一个权限的请求结果。
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
|
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
|
||||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||||
|
// 向PermissionUtils传递权限请求的结果,进行进一步处理。
|
||||||
permissionUtils.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
permissionUtils.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
String logContent = readLogFile();
|
readLogFileAsync();
|
||||||
updateLog(logContent);
|
|
||||||
}
|
}
|
||||||
private void requestIgnoreBattery(){
|
|
||||||
Context context = getApplicationContext();
|
/**
|
||||||
PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
|
* 检查应用是否是首次运行。
|
||||||
boolean hasIgnored = powerManager.isIgnoringBatteryOptimizations(context.getPackageName());
|
* <p>此方法通过读取SharedPreferences中的“isFirstRun”键值对来判断。如果该键不存在或者值为true,表示是首次运行。</p>
|
||||||
if(!hasIgnored){
|
*
|
||||||
BatteryOptimizationUtil.requestIgnoreBatteryOptimization(context);
|
* @return boolean 如果是首次运行返回true,否则返回false。
|
||||||
Timber.d("不在在优化电池白名单内");
|
*/
|
||||||
|
private boolean isFirstRun() {
|
||||||
|
// 从SharedPreferences中获取“isFirstRun”键对应的值,如果不存在则默认返回true
|
||||||
|
return spManager.getBoolean("isFirstRun", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 异步设置初始数据,主要用于配置通知监控的包名。
|
||||||
|
* 该方法会开启一个新的线程,在其中进行SharedPreferences的配置,
|
||||||
|
* 包括设置特定包名及其对应的应用名称。
|
||||||
|
* 完成后,可根据需要在该线程中执行其他操作,如发送广播或更新UI等,
|
||||||
|
* 但若涉及UI操作,需确保在主线程中进行。
|
||||||
|
*/
|
||||||
|
private void setupInitialDataAsync() {
|
||||||
|
new Thread(() -> {
|
||||||
|
// 设置SharedPreferences中的包名和应用名示例
|
||||||
|
spManager.putString("com.tencent.mm", "微信");
|
||||||
|
// 日志输出,表示SharedPreferences设置成功
|
||||||
|
Timber.d("写入SharedPreferences成功。");
|
||||||
|
// 在这里可以执行其他操作,如需要更新UI,请确保在主线程中进行
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 异步读取日志文件的函数。
|
||||||
|
* 该函数内部使用了AsyncTask来在后台读取日志文件,并且在读取完成后更新日志显示。
|
||||||
|
* 无参数。
|
||||||
|
* 无返回值。
|
||||||
|
*/
|
||||||
|
private void readLogFileAsync() {
|
||||||
|
new AsyncTask<Void, Void, String>() {
|
||||||
|
@Override
|
||||||
|
protected String doInBackground(Void... voids) {
|
||||||
|
// 在后台执行任务,读取日志文件内容
|
||||||
|
return readLogFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(String logContent) {
|
||||||
|
// 在UI线程上执行,将读取到的日志内容更新到UI
|
||||||
|
updateLog(logContent);
|
||||||
|
}
|
||||||
|
}.execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 异步请求忽略电池优化的函数。
|
||||||
|
* 这个函数不会接收任何参数,也不会返回任何结果。
|
||||||
|
* 它主要通过创建并执行一个名为BatteryOptimizationTask的异步任务,
|
||||||
|
* 来请求系统忽略应用的电池优化设置。
|
||||||
|
*/
|
||||||
|
private void requestIgnoreBatteryAsync() {
|
||||||
|
// 创建并执行BatteryOptimizationTask异步任务
|
||||||
|
new BatteryOptimizationTask(this).execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新日志文本视图的内容。
|
||||||
|
*
|
||||||
|
* @param newLog 新的日志内容。
|
||||||
|
* 调用此方法会将日志文本视图的内容更新为传入的新日志内容。
|
||||||
|
*/
|
||||||
|
private void updateLog(String newLog) {
|
||||||
|
logTextView.setText(newLog); // 更新日志文本视图的内容为新的日志字符串
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清除日志文件的内容。
|
||||||
|
* 该方法首先检查是否存在名为"echoLink.log"的日志文件。
|
||||||
|
* 如果存在,则重写该文件以清空其内容,并更新日志状态。
|
||||||
|
* 如果文件不存在,则直接更新日志状态表示无需清空。
|
||||||
|
* 该方法不接受任何参数且无返回值。
|
||||||
|
*/
|
||||||
|
private void clearLogs() {
|
||||||
|
File logFile = new File(getFilesDir(), "logs/echoLink.log");
|
||||||
|
if (logFile.exists()) {
|
||||||
|
try {
|
||||||
|
// 使用空字符串重写文件来清空内容
|
||||||
|
PrintWriter writer = new PrintWriter(logFile);
|
||||||
|
writer.print("");
|
||||||
|
writer.close();
|
||||||
|
updateLog("日志已清空。"); // 更新日志状态,提示日志已清空
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
updateLog("清空日志文件时出错。"); // 更新日志状态,提示清空日志文件时出现错误
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return;
|
updateLog("日志文件不存在,无需清空。"); // 更新日志状态,表示无需清空日志文件
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateLog(String newLog) {
|
/**
|
||||||
logTextView.setText(newLog);
|
* 读取日志文件的内容。
|
||||||
}
|
* <p>此方法不接受任何参数,它会尝试读取名为"echoLink.log"的日志文件。</p>
|
||||||
|
* <p>返回值为日志文件的字符串内容,如果文件不存在,则返回"日志文件不存在";
|
||||||
|
* 如果在读取过程中发生IO异常,则返回"读取日志文件时出错"。</p>
|
||||||
|
*
|
||||||
|
* @return 返回日志文件的内容,或者错误信息。
|
||||||
|
*/
|
||||||
private String readLogFile() {
|
private String readLogFile() {
|
||||||
try {
|
try {
|
||||||
File logFile = new File(getFilesDir(), "logs/echoLink.log"); // 日志文件的路径
|
// 创建日志文件的路径
|
||||||
|
File logFile = new File(getFilesDir(), "logs/echoLink.log");
|
||||||
if (!logFile.exists()) {
|
if (!logFile.exists()) {
|
||||||
return "日志文件不存在";
|
return "日志文件不存在";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 用于存储日志文件内容的StringBuilder
|
||||||
StringBuilder logContent = new StringBuilder();
|
StringBuilder logContent = new StringBuilder();
|
||||||
try (BufferedReader reader = new BufferedReader(new FileReader(logFile))) {
|
try (BufferedReader reader = new BufferedReader(new FileReader(logFile))) {
|
||||||
String line;
|
String line;
|
||||||
|
// 逐行读取日志文件,并将其添加到logContent中
|
||||||
while ((line = reader.readLine()) != null) {
|
while ((line = reader.readLine()) != null) {
|
||||||
logContent.append(line).append("\n");
|
logContent.append(line).append("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 将logContent转换为字符串并返回
|
||||||
return logContent.toString();
|
return logContent.toString();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package com.nbee.echolink.async;
|
||||||
|
|
||||||
|
import static android.content.Context.POWER_SERVICE;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.AsyncTask;
|
||||||
|
import android.os.PowerManager;
|
||||||
|
|
||||||
|
import com.nbee.echolink.utils.BatteryOptimizationUtil;
|
||||||
|
|
||||||
|
import timber.log.Timber;
|
||||||
|
|
||||||
|
public class BatteryOptimizationTask extends AsyncTask<Void, Void, Void> {
|
||||||
|
private Context context;
|
||||||
|
|
||||||
|
public BatteryOptimizationTask(Context context) {
|
||||||
|
this.context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Void doInBackground(Void... voids) {
|
||||||
|
PowerManager powerManager = (PowerManager) context.getSystemService(POWER_SERVICE);
|
||||||
|
boolean hasIgnored = powerManager.isIgnoringBatteryOptimizations(context.getPackageName());
|
||||||
|
if (!hasIgnored) {
|
||||||
|
BatteryOptimizationUtil.requestIgnoreBatteryOptimization(context);
|
||||||
|
Timber.d("请求忽略电池优化");
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,10 +7,17 @@ import android.content.Intent;
|
|||||||
import com.nbee.echolink.service.MonitorService;
|
import com.nbee.echolink.service.MonitorService;
|
||||||
|
|
||||||
public class BootCompletedReceiver extends BroadcastReceiver {
|
public class BootCompletedReceiver extends BroadcastReceiver {
|
||||||
|
/**
|
||||||
|
* 当接收到开机启动完成的广播时启动监控服务。
|
||||||
|
*
|
||||||
|
* @param context 上下文对象,提供了调用环境的信息。
|
||||||
|
* @param intent 携带了广播的内容。
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
// 检查接收到的广播是否为系统启动完成的广播
|
||||||
if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
|
if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
|
||||||
// 启动您的服务或活动
|
// 如果是系统启动完成的广播,则启动监控服务
|
||||||
Intent serviceIntent = new Intent(context, MonitorService.class);
|
Intent serviceIntent = new Intent(context, MonitorService.class);
|
||||||
context.startService(serviceIntent);
|
context.startService(serviceIntent);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,132 @@
|
|||||||
|
package com.nbee.echolink.broadcast;
|
||||||
|
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.JsonSyntaxException;
|
||||||
|
import com.nbee.echolink.R;
|
||||||
|
import com.nbee.echolink.model.DeviceInfo;
|
||||||
|
import com.nbee.echolink.response.ApiResponse;
|
||||||
|
import com.nbee.echolink.service.MonitorService;
|
||||||
|
import com.nbee.echolink.utils.DeviceInfoUtils;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import okhttp3.MediaType;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
import okhttp3.Request;
|
||||||
|
import okhttp3.RequestBody;
|
||||||
|
import timber.log.Timber;
|
||||||
|
|
||||||
|
public class HeartbeatAlarmReceiver extends BroadcastReceiver {
|
||||||
|
private Context thisContext;
|
||||||
|
private String accessToken;
|
||||||
|
private String SN;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当接收到特定广播时,执行心跳发送逻辑的函数。
|
||||||
|
*
|
||||||
|
* @param context 上下文对象,用于访问应用全局功能。
|
||||||
|
* @param intent 携带了广播的内容。
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
// 初始化上下文对象,为后续操作提供context
|
||||||
|
thisContext = context;
|
||||||
|
// 执行发送心跳信号的逻辑
|
||||||
|
sendHeartbeatSignal();
|
||||||
|
// 在发送心跳后,重新设置下一次心跳发送的时间
|
||||||
|
MonitorService.scheduleHeartbeat(thisContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送心跳信号的函数。
|
||||||
|
* 该函数不会返回任何值,用于向服务器发送一个心跳请求,以保持客户端的活动状态。
|
||||||
|
* 该请求为异步请求,请求失败或成功都会在回调函数中进行处理。
|
||||||
|
*/
|
||||||
|
private void sendHeartbeatSignal() {
|
||||||
|
// 获取心跳请求的URL
|
||||||
|
String heartBeatURL = thisContext.getResources().getString(R.string.heart_beat_url);
|
||||||
|
OkHttpClient client = new OkHttpClient();
|
||||||
|
Request request = buildRequest(heartBeatURL);
|
||||||
|
|
||||||
|
// 发送异步请求
|
||||||
|
client.newCall(request).enqueue(new okhttp3.Callback() {
|
||||||
|
@Override
|
||||||
|
public void onFailure(okhttp3.Call call, IOException e) {
|
||||||
|
// 请求失败时的处理逻辑
|
||||||
|
Timber.e(e, "请求 " + heartBeatURL + "失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResponse(okhttp3.Call call, okhttp3.Response response) {
|
||||||
|
try {
|
||||||
|
if (!response.isSuccessful()) {
|
||||||
|
// 处理响应错误的情况
|
||||||
|
Timber.d("Request to " + heartBeatURL + " returned error: " + response.code() + ", " + response.message());
|
||||||
|
} else {
|
||||||
|
// 处理成功响应的逻辑
|
||||||
|
String responseBody = response.body().string(); // 获取响应体内容
|
||||||
|
Gson gson = new Gson();
|
||||||
|
ApiResponse apiResponse = gson.fromJson(responseBody, ApiResponse.class);
|
||||||
|
if (apiResponse == null) {
|
||||||
|
// 处理api响应为空的情况
|
||||||
|
Timber.d("apiResponse is null.");
|
||||||
|
}
|
||||||
|
if (!apiResponse.getCode().equals("0")) {
|
||||||
|
// 处理响应状态码错误的情况
|
||||||
|
Timber.d("请求返回状态码错误,返回内容: " + apiResponse);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
// 处理响应处理过程中的IO异常
|
||||||
|
Timber.e(e, "IOException during handling response");
|
||||||
|
} catch (JsonSyntaxException e) {
|
||||||
|
// 处理响应解析过程中的JSON格式异常
|
||||||
|
Timber.e(e, "JsonSyntaxException during parsing response");
|
||||||
|
} finally {
|
||||||
|
// 确保响应体被关闭,避免资源泄露
|
||||||
|
response.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建一个网络请求。
|
||||||
|
*
|
||||||
|
* @param apiUrl 请求的API地址。
|
||||||
|
* @param <T> 请求返回的类型。
|
||||||
|
* @return 返回构建好的Request对象。
|
||||||
|
*/
|
||||||
|
private <T> Request buildRequest(String apiUrl) {
|
||||||
|
// 从资源文件中读取序列号和访问令牌
|
||||||
|
//SN = thisContext.getResources().getString(R.string.SN);
|
||||||
|
SN = DeviceInfoUtils.getAndroidID(thisContext);
|
||||||
|
accessToken = thisContext.getResources().getString(R.string.access_token);
|
||||||
|
// 创建设备信息对象并设置设备相关属性
|
||||||
|
DeviceInfo deviceInfo = new DeviceInfo();
|
||||||
|
deviceInfo.setDeviceBrand(DeviceInfoUtils.getDeviceBrand());
|
||||||
|
deviceInfo.setDeviceModel(DeviceInfoUtils.getDeviceModel());
|
||||||
|
deviceInfo.setAndroidVersion("Android " + DeviceInfoUtils.getDeviceAndroidVersion());
|
||||||
|
deviceInfo.setSn(SN);
|
||||||
|
// 使用Gson将设备信息对象转换为JSON字符串
|
||||||
|
Gson gson = new Gson();
|
||||||
|
String json = gson.toJson(deviceInfo);
|
||||||
|
// 创建请求体,使用JSON格式
|
||||||
|
MediaType JSON = MediaType.get("application/json; charset=utf-8");
|
||||||
|
RequestBody body = RequestBody.create(json, JSON);
|
||||||
|
// 构建请求对象,并设置请求头,包括accessToken和Content-Type
|
||||||
|
Request request = new Request.Builder()
|
||||||
|
.url(apiUrl)
|
||||||
|
.addHeader("accessToken", accessToken)
|
||||||
|
.addHeader("Content-Type", "application/json")
|
||||||
|
.post(body)
|
||||||
|
.build();
|
||||||
|
return request;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,14 +4,16 @@ public class DeviceInfo {
|
|||||||
private String deviceBrand;
|
private String deviceBrand;
|
||||||
private String deviceModel;
|
private String deviceModel;
|
||||||
private String androidVersion;
|
private String androidVersion;
|
||||||
|
private String sn;
|
||||||
|
|
||||||
public DeviceInfo() {
|
public DeviceInfo() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public DeviceInfo(String deviceBrand, String deviceModel, String androidVersion) {
|
public DeviceInfo(String deviceBrand, String deviceModel, String androidVersion,String sn) {
|
||||||
this.deviceBrand = deviceBrand;
|
this.deviceBrand = deviceBrand;
|
||||||
this.deviceModel = deviceModel;
|
this.deviceModel = deviceModel;
|
||||||
this.androidVersion = androidVersion;
|
this.androidVersion = androidVersion;
|
||||||
|
this.sn = sn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDeviceBrand() {
|
public String getDeviceBrand() {
|
||||||
@@ -38,12 +40,21 @@ public class DeviceInfo {
|
|||||||
this.androidVersion = androidVersion;
|
this.androidVersion = androidVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getSn() {
|
||||||
|
return sn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSn(String sn) {
|
||||||
|
this.sn = sn;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "DeviceInfo{" +
|
return "DeviceInfo{" +
|
||||||
"deviceBrand='" + deviceBrand + '\'' +
|
"deviceBrand='" + deviceBrand + '\'' +
|
||||||
", deviceModel='" + deviceModel + '\'' +
|
", deviceModel='" + deviceModel + '\'' +
|
||||||
", androidVersion='" + androidVersion + '\'' +
|
", androidVersion='" + androidVersion + '\'' +
|
||||||
|
", SN='" + sn + '\'' +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
82
app/src/main/java/com/nbee/echolink/model/WeChatMsg.java
Normal file
82
app/src/main/java/com/nbee/echolink/model/WeChatMsg.java
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
package com.nbee.echolink.model;
|
||||||
|
|
||||||
|
public class WeChatMsg {
|
||||||
|
private String packageName;
|
||||||
|
private String appName;
|
||||||
|
private String title;
|
||||||
|
private String sender;
|
||||||
|
private String message;
|
||||||
|
private String currentTime;
|
||||||
|
|
||||||
|
public String getCurrentTime() {
|
||||||
|
return currentTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCurrentTime(String currentTime) {
|
||||||
|
this.currentTime = currentTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPackageName() {
|
||||||
|
return packageName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPackageName(String packageName) {
|
||||||
|
this.packageName = packageName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAppName() {
|
||||||
|
return appName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAppName(String appName) {
|
||||||
|
this.appName = appName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSender() {
|
||||||
|
return sender;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSender(String sender) {
|
||||||
|
this.sender = sender;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessage(String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WeChatMsg() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public WeChatMsg(String packageName, String appName, String title, String sender, String message,String currentTime) {
|
||||||
|
this.packageName = packageName;
|
||||||
|
this.appName = appName;
|
||||||
|
this.title = title;
|
||||||
|
this.sender = sender;
|
||||||
|
this.message = message;
|
||||||
|
this.currentTime = currentTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "WeChatMsg{" +
|
||||||
|
"packageName='" + packageName + '\'' +
|
||||||
|
", appName='" + appName + '\'' +
|
||||||
|
", title='" + title + '\'' +
|
||||||
|
", sender='" + sender + '\'' +
|
||||||
|
", message='" + message + '\'' +
|
||||||
|
", currentTime='" + currentTime + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,21 +1,25 @@
|
|||||||
package com.nbee.echolink.service;
|
package com.nbee.echolink.service;
|
||||||
|
|
||||||
|
import android.app.AlarmManager;
|
||||||
import android.app.Notification;
|
import android.app.Notification;
|
||||||
import android.app.NotificationChannel;
|
import android.app.NotificationChannel;
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
|
import android.app.PendingIntent;
|
||||||
import android.app.Service;
|
import android.app.Service;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.core.app.NotificationCompat;
|
import androidx.core.app.NotificationCompat;
|
||||||
|
|
||||||
import com.nbee.echolink.R;
|
import com.nbee.echolink.R;
|
||||||
|
import com.nbee.echolink.broadcast.HeartbeatAlarmReceiver;
|
||||||
import com.nbee.echolink.model.CallInfo;
|
import com.nbee.echolink.model.CallInfo;
|
||||||
import com.nbee.echolink.model.SMSInfo;
|
import com.nbee.echolink.model.SMSInfo;
|
||||||
import com.nbee.echolink.utils.NetworkUtil;
|
import com.nbee.echolink.model.WeChatMsg;
|
||||||
|
import com.nbee.echolink.utils.NetworkUtils;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@@ -23,37 +27,63 @@ import java.util.Date;
|
|||||||
import timber.log.Timber;
|
import timber.log.Timber;
|
||||||
|
|
||||||
public class MonitorService extends Service {
|
public class MonitorService extends Service {
|
||||||
private NetworkUtil networkUtil;
|
private NetworkUtils networkUtils;
|
||||||
private static final String TAG = "MonitorService";
|
private static final String TAG = "MonitorService";
|
||||||
private String lastPhoneNumber = null;
|
private String lastPhoneNumber = null;
|
||||||
private long lastCallTime = 0;
|
private long lastCallTime = 0;
|
||||||
private int count;
|
private static final long HEARTBEAT_INTERVAL_MINUTES = 10; // 10分钟
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 服务创建时调用的函数。
|
||||||
|
* 该函数在服务创建时被系统自动调用,用于初始化服务的相关操作。
|
||||||
|
* 无参数和返回值。
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate(); // 调用父类的onCreate方法进行初始化
|
||||||
Timber.d("MonitorService onCreate");
|
Timber.d("监控服务 onCreate"); // 记录日志,表示监控服务创建
|
||||||
startForegroundService();
|
startForegroundService(); // 启动前台服务,保证服务不会被系统轻易杀死
|
||||||
networkUtil = new NetworkUtil(this);
|
networkUtils = new NetworkUtils(this); // 初始化网络工具类
|
||||||
|
scheduleHeartbeat(this); // 启动心跳定时任务,用于保持服务的活跃状态或与服务器保持连接
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 服务启动时的命令处理。
|
||||||
|
*
|
||||||
|
* @param intent 携带启动服务的意图,可能包含来电或短信的信息。
|
||||||
|
* @param flags 启动标志,提供额外数据。
|
||||||
|
* @param startId 一个唯一的整数,标识此启动请求。
|
||||||
|
* @return 返回START_STICKY,如果系统在服务终止后杀死,则重新创建服务并调用onStartCommand(),但不重新传递最后的意图。
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||||
Timber.d("MonitorService onStartCommand");
|
if (intent != null) { // 检查传入的Intent是否非空
|
||||||
if (intent != null) {
|
if (intent.hasExtra("incomingNumber")) { // 检查Intent是否包含来电号码
|
||||||
if (intent.hasExtra("incomingNumber")) {
|
|
||||||
String incomingNumber = intent.getStringExtra("incomingNumber");
|
String incomingNumber = intent.getStringExtra("incomingNumber");
|
||||||
Timber.d("获取到来电信息,号码: "+ incomingNumber);
|
Timber.d("获取到来电信息,号码: " + incomingNumber);
|
||||||
sendCallInfoToServer(incomingNumber);
|
sendCallInfoToServer(incomingNumber); // 将来电信息发送到服务器
|
||||||
} else if (intent.hasExtra("sender") && intent.hasExtra("messageBody")) {
|
} else if (intent.hasExtra("sender") && intent.hasExtra("messageBody")) { // 检查Intent是否包含短信信息
|
||||||
String sender = intent.getStringExtra("sender");
|
String sender = intent.getStringExtra("sender");
|
||||||
String messageBody = intent.getStringExtra("messageBody");
|
String messageBody = intent.getStringExtra("messageBody");
|
||||||
Timber.d("获取到短信信息,号码: "+ sender);
|
Timber.d("获取到短信信息,号码: " + sender);
|
||||||
sendSmsInfoToServer(sender, messageBody);
|
sendSmsInfoToServer(sender, messageBody); // 将短信信息发送到服务器
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return START_STICKY;
|
return START_STICKY; // 返回服务启动策略
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将来电信息发送到服务器。
|
||||||
|
*
|
||||||
|
* @param incomingNumber 接收到的电话号码。
|
||||||
|
* 该方法首先检查传入的电话号码是否为"null"或null,
|
||||||
|
* 如果是,则不执行任何操作。
|
||||||
|
* 其次,如果电话号码与上一个来电号码相同,并且时间间隔小于70秒,
|
||||||
|
* 也不会执行发送操作,以避免频繁发送相同信息。
|
||||||
|
* 如果通过所有检查,将创建一个包含来电信息的CallInfo对象,
|
||||||
|
* 并使用网络工具将其发送到服务器。
|
||||||
|
*/
|
||||||
private void sendCallInfoToServer(String incomingNumber) {
|
private void sendCallInfoToServer(String incomingNumber) {
|
||||||
Timber.d("sendCallInfoToServer: 处理来电信息");
|
Timber.d("sendCallInfoToServer: 处理来电信息");
|
||||||
if (incomingNumber.equals("null") || incomingNumber == null) {
|
if (incomingNumber.equals("null") || incomingNumber == null) {
|
||||||
@@ -72,58 +102,146 @@ public class MonitorService extends Service {
|
|||||||
lastCallTime = currentTimeMillis;
|
lastCallTime = currentTimeMillis;
|
||||||
String currentTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
|
String currentTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
|
||||||
|
|
||||||
|
// 创建CallInfo对象并设置相关信息,然后发送到服务器
|
||||||
CallInfo callInfo = new CallInfo();
|
CallInfo callInfo = new CallInfo();
|
||||||
callInfo.setCallTime(currentTime);
|
callInfo.setCallTime(currentTime);
|
||||||
callInfo.setPhoneNumber(incomingNumber);
|
callInfo.setPhoneNumber(incomingNumber);
|
||||||
networkUtil.postRequest(callInfo);
|
networkUtils.postRequest(callInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendSmsInfoToServer(String sender,String messageBody){
|
|
||||||
|
/**
|
||||||
|
* 向服务器发送短信信息。
|
||||||
|
*
|
||||||
|
* @param sender 发送者的手机号码。
|
||||||
|
* @param messageBody 短信的内容。
|
||||||
|
* 该方法首先会检查发送者和短信内容是否为空,如果为空则不进行任何操作。
|
||||||
|
* 接着,它会格式化当前时间,并创建一个SMSInfo对象,将发送者、短信内容和接收时间设置到这个对象中。
|
||||||
|
* 最后,使用网络工具将这个SMSInfo对象以POST请求的方式发送到服务器。
|
||||||
|
*/
|
||||||
|
private void sendSmsInfoToServer(String sender, String messageBody) {
|
||||||
Timber.d("sendSmsInfoToServer: 处理短信信息");
|
Timber.d("sendSmsInfoToServer: 处理短信信息");
|
||||||
if (checkNullString(sender,messageBody)){
|
if (checkNullString(sender, messageBody)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// 获取当前时间并格式化
|
||||||
String currentTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
|
String currentTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
|
||||||
|
// 创建SMSInfo对象并设置相关属性
|
||||||
SMSInfo smsInfo = new SMSInfo();
|
SMSInfo smsInfo = new SMSInfo();
|
||||||
smsInfo.setSmsNumber(sender);
|
smsInfo.setSmsNumber(sender);
|
||||||
smsInfo.setSmsContent(messageBody);
|
smsInfo.setSmsContent(messageBody);
|
||||||
smsInfo.setSmsAcceptanceTime(currentTime);
|
smsInfo.setSmsAcceptanceTime(currentTime);
|
||||||
networkUtil.postRequest(smsInfo);
|
// 使用网络工具发送POST请求
|
||||||
|
networkUtils.postRequest(smsInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkNullString(String a, String b){
|
/**
|
||||||
if (a == null || b == null){
|
* 发送微信消息。
|
||||||
|
* 使用网络工具类向指定地址发送微信消息。
|
||||||
|
*
|
||||||
|
* @param weChatMsg 微信消息对象,包含消息的全部必要信息。
|
||||||
|
*/
|
||||||
|
public void sendWeChatMsg(WeChatMsg weChatMsg) {
|
||||||
|
networkUtils.postRequest(weChatMsg);
|
||||||
|
// 使用网络工具类发送POST请求,将微信消息发送出去。
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查两个字符串是否为null或"null"。
|
||||||
|
*
|
||||||
|
* @param a 第一个字符串
|
||||||
|
* @param b 第二个字符串
|
||||||
|
* @return 如果任一字符串为null或者"null",返回true;否则返回false。
|
||||||
|
*/
|
||||||
|
private boolean checkNullString(String a, String b) {
|
||||||
|
// 检查任一字符串是否为null
|
||||||
|
if (a == null || b == null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (a.equals("null") || b.equals("null")){
|
// 检查任一字符串是否等于"null"
|
||||||
|
if (a.equals("null") || b.equals("null")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 启动一个前台服务。该方法首先会检查系统版本,如果是在API 26及以上版本,就会创建一个通知频道。
|
||||||
|
* 然后,构建一个通知对象,并使用该通知启动前台服务。前台服务能够在后台持续运行,即使应用被关闭或压入后台,
|
||||||
|
* 也能保持服务的运行状态,常用于需要持续运行的服务。
|
||||||
|
*/
|
||||||
private void startForegroundService() {
|
private void startForegroundService() {
|
||||||
Timber.d("startForegroundService: 启动前台服务");
|
Timber.d("startForegroundService: 启动前台服务");
|
||||||
// 创建通知频道(仅在API 26及以上版本中需要)
|
// 检测系统版本,仅在API 26及以上版本创建通知频道
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
NotificationChannel channel = new NotificationChannel("channel_id", "Channel Name", NotificationManager.IMPORTANCE_DEFAULT);
|
NotificationChannel channel = new NotificationChannel("channel_id", "Channel Name", NotificationManager.IMPORTANCE_DEFAULT);
|
||||||
NotificationManager notificationManager = getSystemService(NotificationManager.class);
|
NotificationManager notificationManager = getSystemService(NotificationManager.class);
|
||||||
notificationManager.createNotificationChannel(channel);
|
notificationManager.createNotificationChannel(channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建通知
|
// 创建通知对象。通知内容包括标题、小图标等
|
||||||
Notification notification = new NotificationCompat.Builder(this, "channel_id")
|
Notification notification = new NotificationCompat.Builder(this, "channel_id")
|
||||||
.setContentTitle(getString(R.string.notification_title))
|
.setContentTitle(getString(R.string.notification_title))
|
||||||
.setSmallIcon(R.drawable.ic_notification) // 确保您有这个图标
|
//.setContentText("sdads")
|
||||||
|
.setSmallIcon(R.drawable.ic_notification) // 设置通知的小图标
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
// 启动前台服务
|
// 使用创建的通知启动前台服务
|
||||||
startForeground(1, notification);
|
startForeground(1, notification);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当其他组件请求与服务绑定时调用此方法。该服务不提供绑定接口,因此总是返回null。
|
||||||
|
*
|
||||||
|
* @param intent 指示服务应该执行的操作的Intent。包含请求绑定的服务的信息。
|
||||||
|
* @return 返回null,表示该服务不支持绑定操作。
|
||||||
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public IBinder onBind(Intent intent) {
|
public IBinder onBind(Intent intent) {
|
||||||
Timber.d("MonitorService onBind");
|
Timber.d("MonitorService onBind");
|
||||||
return null; // 不提供绑定服务的接口
|
return null; // 不提供绑定服务的接口
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调度心跳监测。此函数用于设置一个定时任务,以便周期性地触发心跳事件。
|
||||||
|
* 心跳事件通过广播的形式由系统自动触发,用于维持应用程序在后台的活性或执行定期任务。
|
||||||
|
*
|
||||||
|
* @param context 应用程序的上下文环境,用于访问系统的各种服务。
|
||||||
|
*/
|
||||||
|
public static void scheduleHeartbeat(Context context) {
|
||||||
|
// 获取系统的闹钟服务
|
||||||
|
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
|
||||||
|
// 创建一个意图,指定当闹钟触发时要执行的广播接收器
|
||||||
|
Intent intent = new Intent(context, HeartbeatAlarmReceiver.class);
|
||||||
|
|
||||||
|
// 根据Android版本选择合适的标志位创建一个唯一的PendingIntent
|
||||||
|
PendingIntent pendingIntent = null;
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||||
|
// Android 12及以上版本需要指定FLAG_IMMUTABLE或FLAG_MUTABLE
|
||||||
|
pendingIntent = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_IMMUTABLE);
|
||||||
|
} else {
|
||||||
|
// 早期版本不需要指定这些标志
|
||||||
|
pendingIntent = PendingIntent.getBroadcast(context, 0, intent, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 计算心跳事件的触发间隔,单位为毫秒
|
||||||
|
long intervalMillis = HEARTBEAT_INTERVAL_MINUTES * 60 * 1000; // 10分钟的毫秒数
|
||||||
|
|
||||||
|
// 根据Android版本选择合适的闹钟设置方法,以确保闹钟在设备休眠时也能触发
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
|
// 对于6.0及以上版本,使用setExactAndAllowWhileIdle方法,可以在设备闲置时精确安排闹钟
|
||||||
|
alarmManager.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + intervalMillis, pendingIntent);
|
||||||
|
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||||
|
// 对于4.4到6.0版本,使用setExact方法,可以精确安排闹钟
|
||||||
|
alarmManager.setExact(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + intervalMillis, pendingIntent);
|
||||||
|
} else {
|
||||||
|
// 对于更早的版本,使用set方法,可以安排一个带宽醒目的闹钟
|
||||||
|
alarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + intervalMillis, pendingIntent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,122 @@
|
|||||||
|
package com.nbee.echolink.service;
|
||||||
|
|
||||||
|
import android.app.Notification;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
|
import android.service.notification.NotificationListenerService;
|
||||||
|
import android.service.notification.StatusBarNotification;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.nbee.echolink.model.WeChatMsg;
|
||||||
|
import com.nbee.echolink.utils.HandleNoticeUtils;
|
||||||
|
import com.nbee.echolink.utils.NetworkUtils;
|
||||||
|
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import timber.log.Timber;
|
||||||
|
|
||||||
|
|
||||||
|
public class NotificationListener extends NotificationListenerService {
|
||||||
|
private static final String TAG = "NotificationListener";
|
||||||
|
private static final List<String> notAllowList = Arrays.asList("com.github.kr328.clash","com.google.android.dialer",
|
||||||
|
"com.google.android.apps.messaging");
|
||||||
|
private HandleNoticeUtils handleNoticeUtils;
|
||||||
|
private static final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
|
||||||
|
private NetworkUtils networkUtil;
|
||||||
|
private final HashMap<String, Long> recentLogs = new HashMap<>();
|
||||||
|
private final Handler logCleanerHandler = new Handler(Looper.getMainLooper());
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate() {
|
||||||
|
super.onCreate();
|
||||||
|
handleNoticeUtils = new HandleNoticeUtils(this);
|
||||||
|
networkUtil = new NetworkUtils(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNotificationPosted(StatusBarNotification sbn) {
|
||||||
|
String packageName = sbn.getPackageName();
|
||||||
|
if (notAllowList.contains(packageName)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Bundle extras = sbn.getNotification().extras;
|
||||||
|
String title = getNotificationText(extras, Notification.EXTRA_TITLE);
|
||||||
|
String content = getNotificationText(extras, Notification.EXTRA_TEXT);
|
||||||
|
String tickerText = sbn.getNotification().tickerText != null ? sbn.getNotification().tickerText.toString() : "";
|
||||||
|
String logMessage = String.format("packageName: %s, title: %s, content: %s, tickerText: %s", packageName, title, content, tickerText);
|
||||||
|
|
||||||
|
if (!shouldPrintLog(logMessage)) {
|
||||||
|
return; // 如果在30秒内已打印过,则跳过
|
||||||
|
}
|
||||||
|
|
||||||
|
String appName = handleNoticeUtils.messageHandle(packageName);
|
||||||
|
if ("微信".equals(appName)) {
|
||||||
|
handleWeChatNotification(packageName, title, tickerText);
|
||||||
|
}
|
||||||
|
|
||||||
|
Timber.d(logMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getNotificationText(Bundle extras, String key) {
|
||||||
|
CharSequence charSequence = extras.getCharSequence(key);
|
||||||
|
return charSequence != null ? charSequence.toString() : "";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleWeChatNotification(String packageName, String title, String tickerText) {
|
||||||
|
if (tickerText.contains(":")) {
|
||||||
|
String[] parts = tickerText.split(":", 2);
|
||||||
|
if (parts.length < 2) return; // 安全检查,确保不会因数组越界而崩溃
|
||||||
|
|
||||||
|
String sender = parts[0].trim();
|
||||||
|
String message = parts[1].trim();
|
||||||
|
WeChatMsg weChatMsg = new WeChatMsg();
|
||||||
|
weChatMsg.setPackageName(packageName);
|
||||||
|
weChatMsg.setSender(sender);
|
||||||
|
weChatMsg.setMessage(message);
|
||||||
|
weChatMsg.setTitle(title);
|
||||||
|
weChatMsg.setAppName("微信");
|
||||||
|
weChatMsg.setCurrentTime(DATE_FORMAT.format(new Date()));
|
||||||
|
|
||||||
|
try {
|
||||||
|
Timber.d("准备将接受的微信通知转发: %s", weChatMsg);
|
||||||
|
networkUtil.postRequest(weChatMsg);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Timber.e(e, "转发送微信通知失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNotificationRemoved(StatusBarNotification sbn) {
|
||||||
|
// 当通知被移除时调用
|
||||||
|
Log.d(TAG, "通知被移除: " + sbn.getPackageName());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查是否应打印日志
|
||||||
|
*/
|
||||||
|
private boolean shouldPrintLog(String logMessage) {
|
||||||
|
Long lastPrintTime = recentLogs.get(logMessage);
|
||||||
|
long currentTime = System.currentTimeMillis();
|
||||||
|
|
||||||
|
if (lastPrintTime == null || (currentTime - lastPrintTime) > 30000) {
|
||||||
|
// 更新日志的打印时间
|
||||||
|
recentLogs.put(logMessage, currentTime);
|
||||||
|
|
||||||
|
// 安排一分钟后清理这个日志条目
|
||||||
|
logCleanerHandler.postDelayed(() -> recentLogs.remove(logMessage), 60000);
|
||||||
|
|
||||||
|
return true; // 如果没有打印过或距离上次打印超过30秒,则应打印
|
||||||
|
}
|
||||||
|
|
||||||
|
return false; // 如果在30秒内已打印过,则不打印
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,14 +1,16 @@
|
|||||||
package com.nbee.echolink.utils;
|
package com.nbee.echolink.utils;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.provider.Settings;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
public class DeviceInfoUtils {
|
public class DeviceInfoUtils {
|
||||||
/**
|
/**
|
||||||
* 获取设备宽度(px)
|
* 获取设备宽度(px)
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public static int getDeviceWidth(Context context) {
|
public static int getDeviceWidth(Context context) {
|
||||||
return context.getResources().getDisplayMetrics().widthPixels;
|
return context.getResources().getDisplayMetrics().widthPixels;
|
||||||
@@ -20,6 +22,7 @@ public class DeviceInfoUtils {
|
|||||||
public static int getDeviceHeight(Context context) {
|
public static int getDeviceHeight(Context context) {
|
||||||
return context.getResources().getDisplayMetrics().heightPixels;
|
return context.getResources().getDisplayMetrics().heightPixels;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取厂商名
|
* 获取厂商名
|
||||||
**/
|
**/
|
||||||
@@ -63,8 +66,6 @@ public class DeviceInfoUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
*
|
|
||||||
* fingerprit 信息
|
* fingerprit 信息
|
||||||
**/
|
**/
|
||||||
public static String getDeviceFubgerprint() {
|
public static String getDeviceFubgerprint() {
|
||||||
@@ -73,7 +74,6 @@ public class DeviceInfoUtils {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 硬件名
|
* 硬件名
|
||||||
*
|
|
||||||
**/
|
**/
|
||||||
public static String getDeviceHardware() {
|
public static String getDeviceHardware() {
|
||||||
return android.os.Build.HARDWARE;
|
return android.os.Build.HARDWARE;
|
||||||
@@ -81,14 +81,12 @@ public class DeviceInfoUtils {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 主机
|
* 主机
|
||||||
*
|
|
||||||
**/
|
**/
|
||||||
public static String getDeviceHost() {
|
public static String getDeviceHost() {
|
||||||
return android.os.Build.HOST;
|
return android.os.Build.HOST;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* 显示ID
|
* 显示ID
|
||||||
**/
|
**/
|
||||||
public static String getDeviceDisplay() {
|
public static String getDeviceDisplay() {
|
||||||
@@ -97,15 +95,24 @@ public class DeviceInfoUtils {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* ID
|
* ID
|
||||||
*
|
|
||||||
**/
|
**/
|
||||||
public static String getDeviceId() {
|
public static String getDeviceId() {
|
||||||
return android.os.Build.ID;
|
return android.os.Build.ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取手机用户名
|
* 获取设备的Android ID。
|
||||||
*
|
*
|
||||||
|
* @param context 上下文对象,用于访问应用特定的资源和类。
|
||||||
|
* @return 设备唯一的Android ID,是一个64位的十进制字符串。
|
||||||
|
*/
|
||||||
|
public static String getAndroidID(Context context) {
|
||||||
|
// 通过Settings.Secure.getString获取设备的Android ID
|
||||||
|
return Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取手机用户名
|
||||||
**/
|
**/
|
||||||
public static String getDeviceUser() {
|
public static String getDeviceUser() {
|
||||||
return android.os.Build.USER;
|
return android.os.Build.USER;
|
||||||
@@ -115,9 +122,10 @@ public class DeviceInfoUtils {
|
|||||||
* 获取手机 硬件序列号
|
* 获取手机 硬件序列号
|
||||||
**/
|
**/
|
||||||
public static String getDeviceSerial() {
|
public static String getDeviceSerial() {
|
||||||
return android.os.Build.SERIAL;
|
return "89KX0ARVK";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取手机Android 系统SDK
|
* 获取手机Android 系统SDK
|
||||||
*
|
*
|
||||||
@@ -143,21 +151,4 @@ public class DeviceInfoUtils {
|
|||||||
return Locale.getDefault().getLanguage();
|
return Locale.getDefault().getLanguage();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取当前系统上的语言列表(Locale列表)
|
|
||||||
*/
|
|
||||||
public static String getDeviceSupportLanguage() {
|
|
||||||
Log.e("wangjie", "Local:" + Locale.GERMAN);
|
|
||||||
Log.e("wangjie", "Local:" + Locale.ENGLISH);
|
|
||||||
Log.e("wangjie", "Local:" + Locale.US);
|
|
||||||
Log.e("wangjie", "Local:" + Locale.CHINESE);
|
|
||||||
Log.e("wangjie", "Local:" + Locale.TAIWAN);
|
|
||||||
Log.e("wangjie", "Local:" + Locale.FRANCE);
|
|
||||||
Log.e("wangjie", "Local:" + Locale.FRENCH);
|
|
||||||
Log.e("wangjie", "Local:" + Locale.GERMANY);
|
|
||||||
Log.e("wangjie", "Local:" + Locale.ITALIAN);
|
|
||||||
Log.e("wangjie", "Local:" + Locale.JAPAN);
|
|
||||||
Log.e("wangjie", "Local:" + Locale.JAPANESE);
|
|
||||||
return Locale.getAvailableLocales().toString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package com.nbee.echolink.utils;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
public class HandleNoticeUtils {
|
||||||
|
private SharedPreferencesManager spManager;
|
||||||
|
private Context context;
|
||||||
|
|
||||||
|
public HandleNoticeUtils(Context context) {
|
||||||
|
this.context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String messageHandle(String packageName){
|
||||||
|
String appName = null;
|
||||||
|
spManager = new SharedPreferencesManager(context);
|
||||||
|
String value = spManager.getString(packageName,"defaultValue");
|
||||||
|
if (value.equals("defaultValue")){
|
||||||
|
return appName;
|
||||||
|
}
|
||||||
|
appName = value;
|
||||||
|
return appName;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,92 +0,0 @@
|
|||||||
package com.nbee.echolink.utils;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.work.Worker;
|
|
||||||
import androidx.work.WorkerParameters;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Handler;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.nbee.echolink.R;
|
|
||||||
import com.nbee.echolink.model.DeviceInfo;
|
|
||||||
import com.nbee.echolink.response.ApiResponse;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import okhttp3.MediaType;
|
|
||||||
import okhttp3.OkHttpClient;
|
|
||||||
import okhttp3.Request;
|
|
||||||
import okhttp3.RequestBody;
|
|
||||||
import timber.log.Timber;
|
|
||||||
|
|
||||||
public class HeartbeatWorker extends Worker {
|
|
||||||
private final Context context;
|
|
||||||
private String accessToken;
|
|
||||||
|
|
||||||
|
|
||||||
public HeartbeatWorker(@NonNull Context context, @NonNull WorkerParameters workerParams) {
|
|
||||||
super(context, workerParams);
|
|
||||||
this.context = context; // 保存上下文引用
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public Result doWork() {
|
|
||||||
Context context = getApplicationContext();
|
|
||||||
// 在这里实现您的心跳发送逻辑
|
|
||||||
sendHeartbeatSignal();
|
|
||||||
return Result.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void sendHeartbeatSignal() {
|
|
||||||
String heartBeatURL = context.getResources().getString(R.string.heart_beat_url); // 获取URL
|
|
||||||
OkHttpClient client = new OkHttpClient();
|
|
||||||
Request request = buildRequest(heartBeatURL);
|
|
||||||
client.newCall(request).enqueue(new okhttp3.Callback() {
|
|
||||||
@Override
|
|
||||||
public void onFailure(okhttp3.Call call, IOException e) {
|
|
||||||
Timber.d("Request to " + heartBeatURL);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void onResponse(okhttp3.Call call, okhttp3.Response response) throws IOException {
|
|
||||||
if (!response.isSuccessful()) {
|
|
||||||
// 在这里处理响应错误
|
|
||||||
Timber.d("Request to " + heartBeatURL + " returned error: " + response.code() + ", " + response.message());
|
|
||||||
throw new IOException("Unexpected code " + response);
|
|
||||||
}
|
|
||||||
// ... 处理响应 ...
|
|
||||||
Gson gson1 = new Gson();
|
|
||||||
ApiResponse apiResponse = gson1.fromJson(response.body().string(), ApiResponse.class);
|
|
||||||
if (apiResponse.getCode().equals(0)){
|
|
||||||
Timber.d("Received response from " + heartBeatURL + ": " + apiResponse.getCode() + " - " + apiResponse.getMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private <T>Request buildRequest(String apiUrl){
|
|
||||||
accessToken = context.getResources().getString(R.string.access_token);
|
|
||||||
DeviceInfo deviceInfo = new DeviceInfo();
|
|
||||||
deviceInfo.setDeviceBrand(DeviceInfoUtils.getDeviceBrand());
|
|
||||||
deviceInfo.setDeviceModel(DeviceInfoUtils.getDeviceModel());
|
|
||||||
deviceInfo.setAndroidVersion(DeviceInfoUtils.getDeviceAndroidVersion());
|
|
||||||
Gson gson = new Gson();
|
|
||||||
// 将对象转换为JSON字符串
|
|
||||||
String json = gson.toJson(deviceInfo);
|
|
||||||
Timber.d("Building request to " + apiUrl + " with data: " + json);
|
|
||||||
// 创建请求体
|
|
||||||
MediaType JSON = MediaType.get("application/json; charset=utf-8");
|
|
||||||
RequestBody body = RequestBody.create(json, JSON);
|
|
||||||
|
|
||||||
// 构建请求,并设置请求头
|
|
||||||
Request request = new Request.Builder()
|
|
||||||
.url(apiUrl)
|
|
||||||
.addHeader("accessToken", accessToken) // 使用加载的accessToken
|
|
||||||
.addHeader("Content-Type", "application/json")
|
|
||||||
.post(body)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
return request;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
package com.nbee.echolink.utils;
|
package com.nbee.echolink.utils;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.nbee.echolink.R;
|
import com.nbee.echolink.R;
|
||||||
import com.nbee.echolink.model.CallInfo;
|
import com.nbee.echolink.model.CallInfo;
|
||||||
import com.nbee.echolink.model.SMSInfo;
|
import com.nbee.echolink.model.SMSInfo;
|
||||||
|
import com.nbee.echolink.model.WeChatMsg;
|
||||||
import com.nbee.echolink.response.ApiResponse;
|
import com.nbee.echolink.response.ApiResponse;
|
||||||
|
|
||||||
|
|
||||||
@@ -18,32 +18,38 @@ import okhttp3.Request;
|
|||||||
import okhttp3.RequestBody;
|
import okhttp3.RequestBody;
|
||||||
import timber.log.Timber;
|
import timber.log.Timber;
|
||||||
|
|
||||||
public class NetworkUtil {
|
public class NetworkUtils {
|
||||||
private final String TAG = "NetworkUtil";
|
private final String TAG = "NetworkUtils";
|
||||||
private String callApiUrl;
|
private final String callApiUrl;
|
||||||
private String smsApiUrl;
|
private final String smsApiUrl;
|
||||||
private String accessToken;
|
private final String wechatApiUrl;
|
||||||
private Handler handler = new Handler();
|
private final String accessToken;
|
||||||
|
private final Handler handler = new Handler();
|
||||||
private static final int MAX_RETRIES = 3;
|
private static final int MAX_RETRIES = 3;
|
||||||
private static final long RETRY_DELAY_MS = 2000; // 重试延迟,例如2秒
|
private static final long RETRY_DELAY_MS = 2000; // 重试延迟,例如2秒
|
||||||
|
// OkHttpClient的单例
|
||||||
|
private static final OkHttpClient client = new OkHttpClient();
|
||||||
|
|
||||||
// API URL
|
// API URL
|
||||||
public NetworkUtil(Context context) {
|
public NetworkUtils(Context context) {
|
||||||
callApiUrl = context.getResources().getString(R.string.call_api_url);
|
callApiUrl = context.getResources().getString(R.string.call_api_url);
|
||||||
smsApiUrl = context.getResources().getString(R.string.message_api_url);
|
smsApiUrl = context.getResources().getString(R.string.message_api_url);
|
||||||
|
wechatApiUrl= context.getResources().getString(R.string.send_wechat_msg_api_url);
|
||||||
accessToken = context.getResources().getString(R.string.access_token);
|
accessToken = context.getResources().getString(R.string.access_token);
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T> void postRequest(T dataObject) {
|
public <T> void postRequest(T dataObject) {
|
||||||
|
// 使用单例的OkHttpClient
|
||||||
if (dataObject instanceof CallInfo) {
|
if (dataObject instanceof CallInfo) {
|
||||||
postRequestWithRetry(dataObject, 0,callApiUrl);
|
postRequestWithRetry(dataObject, 0, callApiUrl);
|
||||||
} else if (dataObject instanceof SMSInfo) {
|
} else if (dataObject instanceof SMSInfo) {
|
||||||
postRequestWithRetry(dataObject, 0,smsApiUrl);
|
postRequestWithRetry(dataObject, 0, smsApiUrl);
|
||||||
|
} else if (dataObject instanceof WeChatMsg){
|
||||||
|
postRequestWithRetry(dataObject,0,wechatApiUrl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T> void postRequestWithRetry(T dataObject, int retryCount,String apiUrl) {
|
private <T> void postRequestWithRetry(T dataObject, int retryCount,String apiUrl) {
|
||||||
OkHttpClient client = new OkHttpClient();
|
|
||||||
// ... 构建请求 ...
|
// ... 构建请求 ...
|
||||||
Request request = buildRequest(dataObject,apiUrl);
|
Request request = buildRequest(dataObject,apiUrl);
|
||||||
Timber.d("Sending request to " + apiUrl + " (Retry count: " + retryCount + ")");
|
Timber.d("Sending request to " + apiUrl + " (Retry count: " + retryCount + ")");
|
||||||
@@ -55,7 +61,6 @@ public class NetworkUtil {
|
|||||||
if (retryCount < MAX_RETRIES) {
|
if (retryCount < MAX_RETRIES) {
|
||||||
handler.postDelayed(() -> postRequestWithRetry(dataObject, retryCount + 1,apiUrl), RETRY_DELAY_MS);
|
handler.postDelayed(() -> postRequestWithRetry(dataObject, retryCount + 1,apiUrl), RETRY_DELAY_MS);
|
||||||
} else {
|
} else {
|
||||||
Log.e(TAG, "onFailure: Failed after " + MAX_RETRIES + " attempts", e);
|
|
||||||
Timber.e("onFailure: Failed after " + MAX_RETRIES + " attempts" + e);
|
Timber.e("onFailure: Failed after " + MAX_RETRIES + " attempts" + e);
|
||||||
// 超出重试次数,处理失败情况
|
// 超出重试次数,处理失败情况
|
||||||
}
|
}
|
||||||
@@ -70,6 +75,7 @@ public class NetworkUtil {
|
|||||||
// ... 处理响应 ...
|
// ... 处理响应 ...
|
||||||
Gson gson1 = new Gson();
|
Gson gson1 = new Gson();
|
||||||
ApiResponse apiResponse = gson1.fromJson(response.body().string(), ApiResponse.class);
|
ApiResponse apiResponse = gson1.fromJson(response.body().string(), ApiResponse.class);
|
||||||
|
Timber.d("ApiResponse" + apiResponse);
|
||||||
if (apiResponse.getCode().equals(0)){
|
if (apiResponse.getCode().equals(0)){
|
||||||
Timber.d("Received response from " + apiUrl + ": " + apiResponse.getCode() + " - " + apiResponse.getMsg());
|
Timber.d("Received response from " + apiUrl + ": " + apiResponse.getCode() + " - " + apiResponse.getMsg());
|
||||||
}
|
}
|
||||||
@@ -3,8 +3,10 @@ package com.nbee.echolink.utils;
|
|||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.DialogInterface;
|
import android.content.ComponentName;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
|
import android.provider.Settings;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.core.app.ActivityCompat;
|
import androidx.core.app.ActivityCompat;
|
||||||
@@ -17,7 +19,7 @@ import timber.log.Timber;
|
|||||||
|
|
||||||
public class PermissionUtils {
|
public class PermissionUtils {
|
||||||
private static final int PERMISSION_REQUEST_CODE = 1;
|
private static final int PERMISSION_REQUEST_CODE = 1;
|
||||||
private Activity activity;
|
private final Activity activity;
|
||||||
|
|
||||||
public PermissionUtils(Activity activity) {
|
public PermissionUtils(Activity activity) {
|
||||||
this.activity = activity;
|
this.activity = activity;
|
||||||
@@ -30,11 +32,10 @@ public class PermissionUtils {
|
|||||||
Manifest.permission.READ_CALL_LOG,
|
Manifest.permission.READ_CALL_LOG,
|
||||||
Manifest.permission.READ_CONTACTS,
|
Manifest.permission.READ_CONTACTS,
|
||||||
Manifest.permission.RECEIVE_SMS
|
Manifest.permission.RECEIVE_SMS
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!hasPermissions(permissions)) {
|
if (!hasPermissions(permissions)) {
|
||||||
Timber.d("请求以下权限:" + Arrays.toString(permissions));
|
Timber.d("请求以下权限: %s", Arrays.toString(permissions));
|
||||||
ActivityCompat.requestPermissions(activity, permissions, PERMISSION_REQUEST_CODE);
|
ActivityCompat.requestPermissions(activity, permissions, PERMISSION_REQUEST_CODE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -42,7 +43,7 @@ public class PermissionUtils {
|
|||||||
private boolean hasPermissions(String... permissions) {
|
private boolean hasPermissions(String... permissions) {
|
||||||
for (String permission : permissions) {
|
for (String permission : permissions) {
|
||||||
if (ContextCompat.checkSelfPermission(activity, permission) != PackageManager.PERMISSION_GRANTED) {
|
if (ContextCompat.checkSelfPermission(activity, permission) != PackageManager.PERMISSION_GRANTED) {
|
||||||
Timber.d("缺少权限:" + permission);
|
Timber.d("缺少权限: %s", permission);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -62,14 +63,8 @@ public class PermissionUtils {
|
|||||||
|
|
||||||
if (deniedPermissions.length() > 0) {
|
if (deniedPermissions.length() > 0) {
|
||||||
// 显示对话框
|
// 显示对话框
|
||||||
Timber.d("权限被拒绝:" + deniedPermissions.toString());
|
Timber.d("权限被拒绝:%s", deniedPermissions);
|
||||||
showAlert("以下权限被拒绝:\n" + deniedPermissions.toString());
|
showAlert("以下权限被拒绝:\n" + deniedPermissions);
|
||||||
} else {
|
|
||||||
// 所有请求的权限都被授予
|
|
||||||
// 在这里处理所有权限被授予的情况
|
|
||||||
Timber.d("已获取所有权限:" + Arrays.toString(permissions));
|
|
||||||
showToast("已授予运行所需的权限");
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -77,15 +72,27 @@ public class PermissionUtils {
|
|||||||
private void showAlert(String message) {
|
private void showAlert(String message) {
|
||||||
new AlertDialog.Builder(activity)
|
new AlertDialog.Builder(activity)
|
||||||
.setMessage(message)
|
.setMessage(message)
|
||||||
.setPositiveButton("确认", new DialogInterface.OnClickListener() {
|
.setPositiveButton("确认", (dialog, which) -> dialog.dismiss())
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
dialog.dismiss();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.create()
|
.create()
|
||||||
.show();
|
.show();
|
||||||
}
|
}
|
||||||
private void showToast(String message) {
|
private void showToast(String message) {
|
||||||
Toast.makeText(activity, message, Toast.LENGTH_SHORT).show();
|
Toast.makeText(activity, message, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isNotificationServiceEnabled(Context context) {
|
||||||
|
String packageName = context.getPackageName();
|
||||||
|
String flat = Settings.Secure.getString(context.getContentResolver(), "enabled_notification_listeners");
|
||||||
|
if (flat != null && !flat.isEmpty()) {
|
||||||
|
final String[] activeListeners = flat.split(":");
|
||||||
|
for (String activeListener : activeListeners) {
|
||||||
|
ComponentName cn = ComponentName.unflattenFromString(activeListener);
|
||||||
|
if (cn != null && cn.getPackageName().equals(packageName)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,58 @@
|
|||||||
|
package com.nbee.echolink.utils;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
|
||||||
|
public class SharedPreferencesManager {
|
||||||
|
|
||||||
|
private static final String PREFS_NAME = "MyAppPrefs";
|
||||||
|
private SharedPreferences sharedPreferences;
|
||||||
|
|
||||||
|
public SharedPreferencesManager(Context context) {
|
||||||
|
this.sharedPreferences = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void putString(String key, String value) {
|
||||||
|
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||||
|
editor.putString(key, value);
|
||||||
|
editor.apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getString(String key,String defaultValue) {
|
||||||
|
return sharedPreferences.getString(key,defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void putBoolean(String key, boolean value) {
|
||||||
|
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||||
|
editor.putBoolean(key, value);
|
||||||
|
editor.apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getBoolean(String key, boolean defaultValue) {
|
||||||
|
return sharedPreferences.getBoolean(key, defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void putInt(String key, int value) {
|
||||||
|
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||||
|
editor.putInt(key, value);
|
||||||
|
editor.apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getInt(String key, int defaultValue) {
|
||||||
|
return sharedPreferences.getInt(key, defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 添加更多的方法来处理其他类型,如 putLong, getLong, putFloat, getFloat 等。
|
||||||
|
|
||||||
|
public void remove(String key) {
|
||||||
|
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||||
|
editor.remove(key);
|
||||||
|
editor.apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearAll() {
|
||||||
|
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||||
|
editor.clear();
|
||||||
|
editor.apply();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".MainActivity">
|
tools:context=".MainActivity">
|
||||||
|
|
||||||
<!-- 用于显示日志标题的 TextView -->
|
<!-- 用于显示日志标题的 TextView -->
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/logTitleTextView"
|
android:id="@+id/logTitleTextView"
|
||||||
@@ -19,10 +20,11 @@
|
|||||||
|
|
||||||
<!-- ScrollView 包含一个 TextView 用于显示日志内容 -->
|
<!-- ScrollView 包含一个 TextView 用于显示日志内容 -->
|
||||||
<ScrollView
|
<ScrollView
|
||||||
|
android:id="@+id/logScrollView"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
app:layout_constraintTop_toBottomOf="@id/logTitleTextView"
|
app:layout_constraintTop_toBottomOf="@id/logTitleTextView"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toTopOf="@+id/clearLogsButton"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent">
|
app:layout_constraintEnd_toEndOf="parent">
|
||||||
|
|
||||||
@@ -32,5 +34,13 @@
|
|||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content" />
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
|
<!-- 新增加的按钮用于清空所有日志 -->
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
<Button
|
||||||
|
android:id="@+id/clearLogsButton"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="清空所有日志"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent" />
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
<string name="call_api_url">https://api.kimgo.cn/api/call</string>
|
<string name="call_api_url">https://api.kimgo.cn/api/call</string>
|
||||||
<string name="message_api_url">https://api.kimgo.cn/api/sms</string>
|
<string name="message_api_url">https://api.kimgo.cn/api/sms</string>
|
||||||
<string name="heart_beat_url">https://api.kimgo.cn/heartbeat</string>
|
<string name="heart_beat_url">https://api.kimgo.cn/heartbeat</string>
|
||||||
|
<string name="send_wechat_msg_api_url">https://api.kimgo.cn/api/wechat</string>
|
||||||
|
<string name="SN">XCCS3IK75OCM</string>
|
||||||
<string name="access_token">gKGCDSgWV82XbU0H</string>
|
<string name="access_token">gKGCDSgWV82XbU0H</string>
|
||||||
<string name="notification_title">监控服务运行中</string>
|
<string name="notification_title">监控服务运行中</string>
|
||||||
<string name="notification_text">EchoLink正在运行</string>
|
<string name="notification_text">EchoLink正在运行</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user