Compare commits

..

No commits in common. "d7cc7beb58d52255f75d5f81bac8a404f16867c4" and "bce11daee79a7264351f585c9c0737d55dd30129" have entirely different histories.

48 changed files with 174 additions and 597 deletions

112
.gitignore vendored
View File

@ -1,5 +1,113 @@
*.iml
.gradle
.idea
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties
app/debug/app-debug.apk
# Built application files
*.apk
*.ap_
*.aab
# Files for the Dalvik VM
*.dex
# Java class files
*.class
# Generated files
bin/
gen/
out/
release/
# Gradle files
.gradle/
build/
# Local configuration file (sdk path, etc)
local.properties
# Proguard folder generated by Eclipse
proguard/
# Log Files
*.log
# Android Studio Navigation editor temp files
.navigation/
# Android Studio captures folder
captures/
# IntelliJ
*.iml
.idea/
.idea_modules/
# Keystore files
*.jks
*.keystore
# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild
# Google Services (e.g. APIs or Firebase)
google-services.json
# Freeline
freeline.py
freeline/
freeline_project_description.json
# fastlane
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
fastlane/readme.md
# Version control
vcs.xml
# lint
lint/intermediates/
lint/generated/
lint/outputs/
lint/tmp/
lint/reports/
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr
# CMake
cmake-build-debug/
# Local config
.idea/workspace.xml
.idea/tasks.xml
.idea/gradle.xml
.idea/assetWizardSettings.xml
.idea/dictionaries
.idea/libraries
.idea/caches
# Android Patch
gen-external-apklibs

View File

@ -35,8 +35,6 @@ dependencies {
compileOnly 'org.projectlombok:lombok:1.18.28'
// https://mvnrepository.com/artifact/com.google.code.gson/gson
implementation 'com.google.code.gson:gson:2.10'
// https://mvnrepository.com/artifact/com.jakewharton.timber/timber
implementation 'com.jakewharton.timber:timber:5.0.1'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

View File

@ -1,46 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<group android:scaleX="0.063738704"
android:scaleY="0.063738704"
android:translateX="21.063614"
android:translateY="21.365784">
<path
android:pathData="M323.2,259.9C323.2,259.9 439.6,348.2 616.7,183C773.9,36.3 902.3,267.8 903.2,378.7C904.3,522.3 745.9,637.2 822.8,731.5C899.7,825.9 670.4,981.6 546.8,846.8C393.1,679.1 351.4,815.4 263.8,815.4C200.9,815.4 71.8,659.1 159,542.9C232.4,445 192.3,412.6 173,378.7C145,329.8 211.4,197 323.2,259.9Z"
android:fillColor="#f0fffd"
android:fillType="nonZero"
android:strokeColor="#00000000"/>
<path
android:pathData="M842.5,199.6C842.5,201.8 842.4,203.9 842.2,206.1C840.5,225.2 831.4,243 816.8,255.5C802.2,268 783.2,274.3 764,273C744.8,271.8 726.9,263 714.1,248.7C701.2,234.4 694.5,215.6 695.4,196.4C696.2,177.1 704.6,159 718.6,145.9C732.7,132.7 751.3,125.6 770.5,126C789.8,126.5 808.1,134.4 821.5,148.2C835,161.9 842.5,180.4 842.5,199.6L842.5,199.6Z"
android:fillColor="#8ad1c8"
android:fillType="nonZero"
android:strokeColor="#00000000"/>
<path
android:pathData="M778.2,205.3C773.4,209 766.8,216.3 768.8,232.7C766.6,239 758.7,251.2 758.7,257C758.7,262.8 749.2,263.8 748.1,262.3C747,260.7 746.5,240.6 740.7,236.9C734.9,233.2 736,216.4 736,216.4C736,216.4 738.1,210 731.2,205.8C724.4,201.6 719.6,191.6 725.7,185.8C731.8,179.9 715.4,176.3 713.3,172C712.4,170.2 709,166.2 705.3,162.2C713.2,148.9 725.1,138.3 739.3,132.1C744.7,137.7 749.4,144.9 748.1,152.5C748.3,156.2 764.3,162 756.5,169.9C748.6,177.8 738,188.9 756.5,192.6C775,196.3 782.9,201.6 778.2,205.3Z"
android:fillColor="#0d6e61"
android:fillType="nonZero"
android:strokeColor="#00000000"/>
<path
android:pathData="M820.3,147C816.4,155.3 806.5,162 800.9,162C794.5,155.1 780.8,164.6 779.5,153.6C778.8,147.1 786.2,137.1 792.4,129.8C802.9,133.4 812.4,139.2 820.3,147Z"
android:fillColor="#0d6e61"
android:fillType="nonZero"
android:strokeColor="#00000000"/>
<path
android:pathData="M842.2,206.1C840.6,224.3 832.3,241.3 818.9,253.7C816.4,251.3 814.4,248.6 815.1,246.4C816.7,241.7 823.1,231.6 822,225.3C821,219.4 826.5,201.5 842.2,206.1Z"
android:fillColor="#0d6e61"
android:fillType="nonZero"
android:strokeColor="#00000000"/>
<path
android:pathData="M722.4,571.8C720,586.3 716.1,600.6 710.8,614.3C675.7,704.1 581.7,760.3 482.8,744.1C428.1,735.2 379.3,704.9 347,660C314.7,615.1 301.5,559.1 310.4,504.5C310.9,501.8 311.4,499 312,496.2C334.3,387 439.1,314.1 550.1,332.2C583.2,337.5 614.5,350.9 641.4,371C650.2,377.5 658.5,384.8 666.1,392.8C688.8,416.1 705.8,444.5 715.5,475.6C725.3,506.7 727.7,539.6 722.4,571.8L722.4,571.8Z"
android:fillColor="#3da193"
android:fillType="nonZero"
android:strokeColor="#00000000"/>
<path
android:pathData="M710.8,614.3C671,639.9 624.1,663.5 572.3,683.1C519.6,703 467.9,716.5 420.5,723.5C309,740.2 221.5,721.6 201.8,669.4C183.3,620.7 228.8,554.7 312,496.2C311.4,499 310.9,501.8 310.4,504.5C308.8,514.7 307.9,524.9 307.7,535.2C259.8,572.2 234.9,608.5 244.7,634.5C254.3,659.8 294.9,670.5 352.6,667.5C409.1,664.5 481.9,648.2 558.2,619.4C624.2,594.4 682,564.1 725.1,533.6C782.7,492.8 814,451.8 803.2,423.2C792.1,393.8 739.2,384 666.1,392.8C658.5,384.8 650.2,377.6 641.4,371C743.6,359.1 822.4,378.5 841,427.6C860.9,480.1 806.6,552.7 710.8,614.3Z"
android:fillColor="#0d6e61"
android:fillType="nonZero"
android:strokeColor="#00000000"/>
</group>
</vector>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.1 KiB

View File

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#3F9C8F</color>
</resources>

View File

@ -19,14 +19,12 @@
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application
android:name=".EchoLink"
android:allowBackup="true"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.EchoLink"
tools:targetApi="29">

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

View File

@ -1,17 +0,0 @@
package com.nbee.echolink;
import android.app.Application;
import timber.log.Timber;
public class EchoLink extends Application {
@Override
public void onCreate() {
super.onCreate();
// 植入 Timber
Timber.plant(new FileLoggingTree(this));
// 打印日志文件的路径
Timber.d("Log file path: " + this.getFilesDir() + "/logs/echoLink.log");
}
}

View File

@ -1,59 +0,0 @@
package com.nbee.echolink;
import android.content.Context;
import android.util.Log;
import timber.log.Timber;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
public class FileLoggingTree extends Timber.DebugTree {
private final File logFile;
public FileLoggingTree(Context context) {
File logDirectory = new File(context.getFilesDir(), "logs");
if (!logDirectory.exists()) {
logDirectory.mkdirs();
}
this.logFile = new File(logDirectory, "echoLink.log");
}
@Override
protected void log(int priority, String tag, String message, Throwable t) {
super.log(priority, tag, message, t);
try (FileWriter fileWriter = new FileWriter(logFile, true)) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
String timestamp = dateFormat.format(new Date());
String logMessage = timestamp + " [" + priorityToString(priority) + "] " + tag + ": " + message + "\n";
fileWriter.append(logMessage);
if (t != null) {
fileWriter.append(Log.getStackTraceString(t)).append("\n");
}
} catch (IOException e) {
Log.e("FileLoggingTree", "Error writing log to file", e);
}
}
private String priorityToString(int priority) {
switch (priority) {
case Log.ERROR:
return "ERROR";
case Log.WARN:
return "WARN";
case Log.INFO:
return "INFO";
case Log.DEBUG:
return "DEBUG";
case Log.VERBOSE:
return "VERBOSE";
default:
return "UNKNOWN";
}
}
}

View File

@ -1,79 +1,28 @@
package com.nbee.echolink;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
import com.nbee.echolink.broadcast.PhoneCallReceiver;
import com.nbee.echolink.broadcast.SMSReceiver;
import com.nbee.echolink.service.MonitorService;
import com.nbee.echolink.utils.PermissionUtils;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
public class MainActivity extends AppCompatActivity {
private final String TAG = "MainActivity";
private PermissionUtils permissionUtils;
private TextView logTextView; // 将类型从 View 更改为 TextView
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
logTextView = findViewById(R.id.logTextView);
updateLog("初始化日志...");
permissionUtils = new PermissionUtils(this);
permissionUtils.checkPermissions();
// 启动MonitorService服务
Intent serviceIntent = new Intent(this, MonitorService.class);
startService(serviceIntent);
}
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
permissionUtils.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
@Override
protected void onResume() {
super.onResume();
String logContent = readLogFile();
updateLog(logContent);
}
private void updateLog(String newLog) {
logTextView.setText(newLog);
}
private String readLogFile() {
try {
File logFile = new File(getFilesDir(), "logs/echoLink.log"); // 日志文件的路径
if (!logFile.exists()) {
return "日志文件不存在";
}
StringBuilder logContent = new StringBuilder();
try (BufferedReader reader = new BufferedReader(new FileReader(logFile))) {
String line;
while ((line = reader.readLine()) != null) {
logContent.append(line).append("\n");
}
}
return logContent.toString();
} catch (IOException e) {
e.printStackTrace();
return "读取日志文件时出错";
}
}
}

View File

@ -20,34 +20,29 @@ import com.nbee.echolink.utils.NetworkUtil;
import java.text.SimpleDateFormat;
import java.util.Date;
import timber.log.Timber;
public class MonitorService extends Service {
private NetworkUtil networkUtil;
private static final String TAG = "MonitorService";
private String lastPhoneNumber = null;
private long lastCallTime = 0;
private int count;
@Override
public void onCreate() {
super.onCreate();
Timber.d("MonitorService onCreate");
startForegroundService();
networkUtil = new NetworkUtil(this);
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Timber.d("MonitorService onStartCommand");
if (intent != null) {
if (intent.hasExtra("incomingNumber")) {
String incomingNumber = intent.getStringExtra("incomingNumber");
Timber.d("获取到来电信息,号码: "+ incomingNumber);
Log.i(TAG, "获取到来电信息,号码: "+ incomingNumber);
sendCallInfoToServer(incomingNumber);
} else if (intent.hasExtra("sender") && intent.hasExtra("messageBody")) {
String sender = intent.getStringExtra("sender");
String messageBody = intent.getStringExtra("messageBody");
Timber.d("获取到短信信息,号码: "+ sender);
Log.i(TAG, "获取到短信信息,号码: "+ sender);
sendSmsInfoToServer(sender, messageBody);
}
}
@ -55,7 +50,6 @@ public class MonitorService extends Service {
}
private void sendCallInfoToServer(String incomingNumber) {
Timber.d("sendCallInfoToServer: 处理来电信息");
if (incomingNumber.equals("null") || incomingNumber == null) {
return;
}
@ -63,7 +57,7 @@ public class MonitorService extends Service {
long currentTimeMillis = System.currentTimeMillis();
if (incomingNumber.equals(lastPhoneNumber) && (currentTimeMillis - lastCallTime) < 70000) {
// 如果电话号码与上次相同且在70秒之内则不执行请求
Timber.d("sendCallInfoToServer: 电话号码与上次相同且在70秒之内不执行请求.");
Log.i(TAG, "sendCallInfoToServer: 电话号码与上次相同且在70秒之内不执行请求.");
return;
}
@ -79,7 +73,6 @@ public class MonitorService extends Service {
}
private void sendSmsInfoToServer(String sender,String messageBody){
Timber.d("sendSmsInfoToServer: 处理短信信息");
if (checkNullString(sender,messageBody)){
return;
}
@ -102,7 +95,6 @@ public class MonitorService extends Service {
}
private void startForegroundService() {
Timber.d("startForegroundService: 启动前台服务");
// 创建通知频道仅在API 26及以上版本中需要
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel channel = new NotificationChannel("channel_id", "Channel Name", NotificationManager.IMPORTANCE_DEFAULT);
@ -112,7 +104,8 @@ public class MonitorService extends Service {
// 创建通知
Notification notification = new NotificationCompat.Builder(this, "channel_id")
.setContentTitle(getString(R.string.notification_title))
.setContentTitle("服务运行中")
.setContentText("EchoLink正在运行")
.setSmallIcon(R.drawable.ic_notification) // 确保您有这个图标
.build();
@ -123,7 +116,6 @@ public class MonitorService extends Service {
@Nullable
@Override
public IBinder onBind(Intent intent) {
Timber.d("MonitorService onBind");
return null; // 不提供绑定服务的接口
}
}

View File

@ -1,50 +0,0 @@
package com.nbee.echolink.utils;
import static android.content.Context.POWER_SERVICE;
import static androidx.core.content.ContextCompat.getSystemService;
import static androidx.core.content.ContextCompat.startActivity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.PowerManager;
import android.provider.Settings;
import timber.log.Timber;
public class BatteryOptimizationUtil {
/**
*
*/
public static boolean isAppIgnoringBatteryOptimizations(Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
PowerManager pm = (PowerManager) context.getSystemService(POWER_SERVICE);
if (pm != null) {
return pm.isIgnoringBatteryOptimizations(context.getPackageName());
}
}
return true; // 在低于Android 6.0的设备上默认为true
}
/**
*
*/
public static void requestIgnoreBatteryOptimization(Context context) {
Timber.d("请求电池优化白名单");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
String packageName = context.getPackageName();
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
if (pm != null && !pm.isIgnoringBatteryOptimizations(packageName)) {
Intent intent = new Intent();
intent.setAction(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
intent.setData(Uri.parse("package:" + packageName));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // 添加FLAG_ACTIVITY_NEW_TASK标志
context.startActivity(intent);
}
}
}
}

View File

@ -1,162 +0,0 @@
package com.nbee.echolink.utils;
import java.util.Locale;
import android.content.Context;
import android.telephony.TelephonyManager;
import android.util.Log;
public class DeviceInfoUtils {
/**
* px
*
*/
public static int getDeviceWidth(Context context) {
return context.getResources().getDisplayMetrics().widthPixels;
}
/**
* px
*/
public static int getDeviceHeight(Context context) {
return context.getResources().getDisplayMetrics().heightPixels;
}
/**
* android.permission.READ_Phone_STATE
* Android 10
*/
// public static String getIMEI(Context context) {
// TelephonyManager tm = (TelephonyManager) context
// .getSystemService(Context.TELEPHONY_SERVICE);
// String deviceId = tm.getDeviceId();
// if (deviceId == null) {
// return "UnKnown";
// } else {
// return deviceId;
// }
// }
/**
*
* **/
public static String getDeviceManufacturer() {
return android.os.Build.MANUFACTURER;
}
/**
*
* **/
public static String getDeviceProduct() {
return android.os.Build.PRODUCT;
}
/**
*
*/
public static String getDeviceBrand() {
return android.os.Build.BRAND;
}
/**
*
*/
public static String getDeviceModel() {
return android.os.Build.MODEL;
}
/**
*
*/
public static String getDeviceBoard() {
return android.os.Build.BOARD;
}
/**
*
* **/
public static String getDeviceDevice() {
return android.os.Build.DEVICE;
}
/**
*
*
* fingerprit
* **/
public static String getDeviceFubgerprint() {
return android.os.Build.FINGERPRINT;
}
/**
*
*
* **/
public static String getDeviceHardware() {
return android.os.Build.HARDWARE;
}
/**
*
*
* **/
public static String getDeviceHost() {
return android.os.Build.HOST;
}
/**
*
* ID
* **/
public static String getDeviceDisplay() {
return android.os.Build.DISPLAY;
}
/**
* ID
*
* **/
public static String getDeviceId() {
return android.os.Build.ID;
}
/**
*
*
* **/
public static String getDeviceUser() {
return android.os.Build.USER;
}
/**
*
* **/
public static String getDeviceSerial() {
return android.os.Build.SERIAL;
}
/**
* Android SDK
*
* @return
*/
public static int getDeviceSDK() {
return android.os.Build.VERSION.SDK_INT;
}
/**
* Android
*
* @return
*/
public static String getDeviceAndroidVersion() {
return android.os.Build.VERSION.RELEASE;
}
/**
*
*/
public static String getDeviceDefaultLanguage() {
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();
}
}

View File

@ -16,7 +16,6 @@ import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import timber.log.Timber;
public class NetworkUtil {
private final String TAG = "NetworkUtil";
@ -46,17 +45,14 @@ public class NetworkUtil {
OkHttpClient client = new OkHttpClient();
// ... 构建请求 ...
Request request = buildRequest(dataObject,apiUrl);
Timber.d("Sending request to " + apiUrl + " (Retry count: " + retryCount + ")");
client.newCall(request).enqueue(new okhttp3.Callback() {
@Override
public void onFailure(okhttp3.Call call, IOException e) {
Timber.d("Request to " + apiUrl + " failed on attempt " + retryCount+ e);
if (retryCount < MAX_RETRIES) {
handler.postDelayed(() -> postRequestWithRetry(dataObject, retryCount + 1,apiUrl), RETRY_DELAY_MS);
} else {
Log.e(TAG, "onFailure: Failed after " + MAX_RETRIES + " attempts", e);
Timber.e("onFailure: Failed after " + MAX_RETRIES + " attempts" + e);
// 超出重试次数,处理失败情况
}
}
@ -64,14 +60,14 @@ public class NetworkUtil {
public void onResponse(okhttp3.Call call, okhttp3.Response response) throws IOException {
if (!response.isSuccessful()) {
// 在这里处理响应错误
Timber.d("Request to " + apiUrl + " returned error: " + response.code() + ", " + response.message());
Log.d("onResponse", 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 " + apiUrl + ": " + apiResponse.getCode() + " - " + apiResponse.getMsg());
Log.i(TAG, "onResponse ResponseCode: " + apiResponse.getCode() + "ResponseMessage" + apiResponse.getMsg());
}
}
});
@ -81,7 +77,7 @@ public class NetworkUtil {
Gson gson = new Gson();
// 将对象转换为JSON字符串
String json = gson.toJson(dataObject);
Timber.d("Building request to " + apiUrl + " with data: " + json);
// 创建请求体
MediaType JSON = MediaType.get("application/json; charset=utf-8");
RequestBody body = RequestBody.create(json, JSON);

View File

@ -1,90 +0,0 @@
package com.nbee.echolink.utils;
import android.Manifest;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.pm.PackageManager;
import android.widget.Toast;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import java.util.Arrays;
import timber.log.Timber;
public class PermissionUtils {
private static final int PERMISSION_REQUEST_CODE = 1;
private Activity activity;
public PermissionUtils(Activity activity) {
this.activity = activity;
}
public void checkPermissions() {
String[] permissions = {
Manifest.permission.READ_PHONE_STATE,
Manifest.permission.SEND_SMS,
Manifest.permission.READ_CALL_LOG,
Manifest.permission.READ_CONTACTS,
Manifest.permission.RECEIVE_SMS
};
if (!hasPermissions(permissions)) {
Timber.d("请求以下权限:" + Arrays.toString(permissions));
ActivityCompat.requestPermissions(activity, permissions, PERMISSION_REQUEST_CODE);
}
}
private boolean hasPermissions(String... permissions) {
for (String permission : permissions) {
if (ContextCompat.checkSelfPermission(activity, permission) != PackageManager.PERMISSION_GRANTED) {
Timber.d("缺少权限:" + permission);
return false;
}
}
return true;
}
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
if (requestCode == PERMISSION_REQUEST_CODE) {
StringBuilder deniedPermissions = new StringBuilder();
for (int i = 0; i < grantResults.length; i++) {
if (grantResults[i] != PackageManager.PERMISSION_GRANTED) {
if (deniedPermissions.length() > 0) deniedPermissions.append(", ");
deniedPermissions.append(permissions[i]);
}
}
if (deniedPermissions.length() > 0) {
// 显示对话框
Timber.d("权限被拒绝:" + deniedPermissions.toString());
showAlert("以下权限被拒绝:\n" + deniedPermissions.toString());
} else {
// 所有请求的权限都被授予
// 在这里处理所有权限被授予的情况
Timber.d("已获取所有权限:" + Arrays.toString(permissions));
showToast("已授予运行所需的权限");
}
}
}
private void showAlert(String message) {
new AlertDialog.Builder(activity)
.setMessage(message)
.setPositiveButton("确认", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
})
.create()
.show();
}
private void showToast(String message) {
Toast.makeText(activity, message, Toast.LENGTH_SHORT).show();
}
}

View File

@ -0,0 +1,30 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
<aapt:attr name="android:fillColor">
<gradient
android:endX="85.84757"
android:endY="92.4963"
android:startX="42.9492"
android:startY="49.59793"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
android:strokeWidth="1"
android:strokeColor="#00000000" />
</vector>

View File

@ -1,3 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"

View File

@ -1,46 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<group android:scaleX="0.063738704"
android:scaleY="0.063738704"
android:translateX="21.063614"
android:translateY="21.365784">
<path
android:pathData="M323.2,259.9C323.2,259.9 439.6,348.2 616.7,183C773.9,36.3 902.3,267.8 903.2,378.7C904.3,522.3 745.9,637.2 822.8,731.5C899.7,825.9 670.4,981.6 546.8,846.8C393.1,679.1 351.4,815.4 263.8,815.4C200.9,815.4 71.8,659.1 159,542.9C232.4,445 192.3,412.6 173,378.7C145,329.8 211.4,197 323.2,259.9Z"
android:fillColor="#f0fffd"
android:fillType="nonZero"
android:strokeColor="#00000000"/>
<path
android:pathData="M842.5,199.6C842.5,201.8 842.4,203.9 842.2,206.1C840.5,225.2 831.4,243 816.8,255.5C802.2,268 783.2,274.3 764,273C744.8,271.8 726.9,263 714.1,248.7C701.2,234.4 694.5,215.6 695.4,196.4C696.2,177.1 704.6,159 718.6,145.9C732.7,132.7 751.3,125.6 770.5,126C789.8,126.5 808.1,134.4 821.5,148.2C835,161.9 842.5,180.4 842.5,199.6L842.5,199.6Z"
android:fillColor="#8ad1c8"
android:fillType="nonZero"
android:strokeColor="#00000000"/>
<path
android:pathData="M778.2,205.3C773.4,209 766.8,216.3 768.8,232.7C766.6,239 758.7,251.2 758.7,257C758.7,262.8 749.2,263.8 748.1,262.3C747,260.7 746.5,240.6 740.7,236.9C734.9,233.2 736,216.4 736,216.4C736,216.4 738.1,210 731.2,205.8C724.4,201.6 719.6,191.6 725.7,185.8C731.8,179.9 715.4,176.3 713.3,172C712.4,170.2 709,166.2 705.3,162.2C713.2,148.9 725.1,138.3 739.3,132.1C744.7,137.7 749.4,144.9 748.1,152.5C748.3,156.2 764.3,162 756.5,169.9C748.6,177.8 738,188.9 756.5,192.6C775,196.3 782.9,201.6 778.2,205.3Z"
android:fillColor="#0d6e61"
android:fillType="nonZero"
android:strokeColor="#00000000"/>
<path
android:pathData="M820.3,147C816.4,155.3 806.5,162 800.9,162C794.5,155.1 780.8,164.6 779.5,153.6C778.8,147.1 786.2,137.1 792.4,129.8C802.9,133.4 812.4,139.2 820.3,147Z"
android:fillColor="#0d6e61"
android:fillType="nonZero"
android:strokeColor="#00000000"/>
<path
android:pathData="M842.2,206.1C840.6,224.3 832.3,241.3 818.9,253.7C816.4,251.3 814.4,248.6 815.1,246.4C816.7,241.7 823.1,231.6 822,225.3C821,219.4 826.5,201.5 842.2,206.1Z"
android:fillColor="#0d6e61"
android:fillType="nonZero"
android:strokeColor="#00000000"/>
<path
android:pathData="M722.4,571.8C720,586.3 716.1,600.6 710.8,614.3C675.7,704.1 581.7,760.3 482.8,744.1C428.1,735.2 379.3,704.9 347,660C314.7,615.1 301.5,559.1 310.4,504.5C310.9,501.8 311.4,499 312,496.2C334.3,387 439.1,314.1 550.1,332.2C583.2,337.5 614.5,350.9 641.4,371C650.2,377.5 658.5,384.8 666.1,392.8C688.8,416.1 705.8,444.5 715.5,475.6C725.3,506.7 727.7,539.6 722.4,571.8L722.4,571.8Z"
android:fillColor="#3da193"
android:fillType="nonZero"
android:strokeColor="#00000000"/>
<path
android:pathData="M710.8,614.3C671,639.9 624.1,663.5 572.3,683.1C519.6,703 467.9,716.5 420.5,723.5C309,740.2 221.5,721.6 201.8,669.4C183.3,620.7 228.8,554.7 312,496.2C311.4,499 310.9,501.8 310.4,504.5C308.8,514.7 307.9,524.9 307.7,535.2C259.8,572.2 234.9,608.5 244.7,634.5C254.3,659.8 294.9,670.5 352.6,667.5C409.1,664.5 481.9,648.2 558.2,619.4C624.2,594.4 682,564.1 725.1,533.6C782.7,492.8 814,451.8 803.2,423.2C792.1,393.8 739.2,384 666.1,392.8C658.5,384.8 650.2,377.6 641.4,371C743.6,359.1 822.4,378.5 841,427.6C860.9,480.1 806.6,552.7 710.8,614.3Z"
android:fillColor="#0d6e61"
android:fillType="nonZero"
android:strokeColor="#00000000"/>
</group>
</vector>

View File

@ -5,32 +5,14 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<!-- 用于显示日志标题的 TextView -->
<TextView
android:id="@+id/logTitleTextView"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="日志"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<!-- ScrollView 包含一个 TextView 用于显示日志内容 -->
<ScrollView
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintTop_toBottomOf="@id/logTitleTextView"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">
<TextView
android:id="@+id/logTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</ScrollView>
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 982 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

View File

@ -10,7 +10,7 @@
<item name="colorSecondaryVariant">@color/teal_200</item>
<item name="colorOnSecondary">@color/black</item>
<!-- Status bar color. -->
<item name="android:statusBarColor">@color/grey</item>
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
</style>
</resources>

View File

@ -7,5 +7,4 @@
<color name="teal_700">#FF018786</color>
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>
<color name="grey">#808080</color>
</resources>

View File

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#3F9C8F</color>
</resources>

View File

@ -3,7 +3,4 @@
<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="access_token">gKGCDSgWV82XbU0H</string>
<string name="notification_title">监控服务运行中</string>
<string name="notification_text">EchoLink正在运行</string>
</resources>

View File

@ -2,7 +2,7 @@
<!-- Base application theme. -->
<style name="Theme.EchoLink" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/teal_700</item>
<item name="colorPrimary">@color/purple_500</item>
<item name="colorPrimaryVariant">@color/purple_700</item>
<item name="colorOnPrimary">@color/white</item>
<!-- Secondary brand color. -->
@ -10,7 +10,7 @@
<item name="colorSecondaryVariant">@color/teal_700</item>
<item name="colorOnSecondary">@color/black</item>
<!-- Status bar color. -->
<item name="android:statusBarColor">@color/grey</item>
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
</style>
</resources>