Compare commits
22 Commits
d8523a3f3c
...
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 |
22
.gitignore
vendored
22
.gitignore
vendored
@@ -2,4 +2,24 @@
|
||||
.idea
|
||||
.DS_Store
|
||||
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
|
||||
|
||||
@@ -43,6 +43,6 @@ dependencies {
|
||||
implementation 'com.google.android.material:material:1.3.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
|
||||
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'
|
||||
}
|
||||
@@ -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.1",
|
||||
"outputFile": "app-debug.apk"
|
||||
}
|
||||
],
|
||||
"elementType": "File"
|
||||
}
|
||||
@@ -1,7 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<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">
|
||||
<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.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/>
|
||||
<uses-permission android:name="android.permission.ANSWER_PHONE_CALLS" />
|
||||
@@ -20,6 +23,7 @@
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||
|
||||
|
||||
|
||||
<application
|
||||
android:name=".EchoLink"
|
||||
android:allowBackup="true"
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.nbee.echolink;
|
||||
|
||||
import android.app.Application;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
|
||||
public class EchoLink extends Application {
|
||||
@Override
|
||||
public void onCreate() {
|
||||
|
||||
@@ -3,7 +3,6 @@ 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;
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.nbee.echolink.async.BatteryOptimizationTask;
|
||||
import com.nbee.echolink.service.MonitorService;
|
||||
import com.nbee.echolink.service.NotificationListener;
|
||||
import com.nbee.echolink.utils.BatteryOptimizationUtil;
|
||||
import com.nbee.echolink.utils.DeviceInfoUtils;
|
||||
import com.nbee.echolink.utils.PermissionUtils;
|
||||
import com.nbee.echolink.utils.SharedPreferencesManager;
|
||||
import com.nbee.echolink.utils.ShellUtils;
|
||||
@@ -60,6 +61,8 @@ public class MainActivity extends AppCompatActivity {
|
||||
if (isFirstRun()) {
|
||||
setupInitialDataAsync(); // 异步设置初始数据
|
||||
spManager.putBoolean("isFirstRun", false); // 标记不再首次运行
|
||||
Timber.i("首次运行,设置初始数据...");
|
||||
Timber.d("android_ID: " + DeviceInfoUtils.getAndroidID(this));
|
||||
}
|
||||
|
||||
// 请求忽略电池优化设置
|
||||
|
||||
@@ -21,24 +21,24 @@ import okhttp3.RequestBody;
|
||||
import timber.log.Timber;
|
||||
|
||||
public class HeartbeatAlarmReceiver extends BroadcastReceiver {
|
||||
private Context context;
|
||||
private Context thisContext;
|
||||
private String accessToken;
|
||||
private String SN;
|
||||
|
||||
/**
|
||||
* 当接收到特定广播时,执行心跳发送逻辑的函数。
|
||||
*
|
||||
* @param context1 上下文对象,用于访问应用全局功能。
|
||||
* @param context 上下文对象,用于访问应用全局功能。
|
||||
* @param intent 携带了广播的内容。
|
||||
*/
|
||||
@Override
|
||||
public void onReceive(Context context1, Intent intent) {
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
// 初始化上下文对象,为后续操作提供context
|
||||
context = context1;
|
||||
thisContext = context;
|
||||
// 执行发送心跳信号的逻辑
|
||||
sendHeartbeatSignal();
|
||||
// 在发送心跳后,重新设置下一次心跳发送的时间
|
||||
MonitorService.scheduleHeartbeat(context);
|
||||
MonitorService.scheduleHeartbeat(thisContext);
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ public class HeartbeatAlarmReceiver extends BroadcastReceiver {
|
||||
*/
|
||||
private void sendHeartbeatSignal() {
|
||||
// 获取心跳请求的URL
|
||||
String heartBeatURL = context.getResources().getString(R.string.heart_beat_url);
|
||||
String heartBeatURL = thisContext.getResources().getString(R.string.heart_beat_url);
|
||||
OkHttpClient client = new OkHttpClient();
|
||||
Request request = buildRequest(heartBeatURL);
|
||||
|
||||
@@ -105,8 +105,9 @@ public class HeartbeatAlarmReceiver extends BroadcastReceiver {
|
||||
*/
|
||||
private <T> Request buildRequest(String apiUrl) {
|
||||
// 从资源文件中读取序列号和访问令牌
|
||||
SN = context.getResources().getString(R.string.SN);
|
||||
accessToken = context.getResources().getString(R.string.access_token);
|
||||
//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());
|
||||
|
||||
@@ -73,6 +73,17 @@ public class MonitorService extends Service {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 将来电信息发送到服务器。
|
||||
*
|
||||
* @param incomingNumber 接收到的电话号码。
|
||||
* 该方法首先检查传入的电话号码是否为"null"或null,
|
||||
* 如果是,则不执行任何操作。
|
||||
* 其次,如果电话号码与上一个来电号码相同,并且时间间隔小于70秒,
|
||||
* 也不会执行发送操作,以避免频繁发送相同信息。
|
||||
* 如果通过所有检查,将创建一个包含来电信息的CallInfo对象,
|
||||
* 并使用网络工具将其发送到服务器。
|
||||
*/
|
||||
private void sendCallInfoToServer(String incomingNumber) {
|
||||
Timber.d("sendCallInfoToServer: 处理来电信息");
|
||||
if (incomingNumber.equals("null") || incomingNumber == null) {
|
||||
@@ -91,59 +102,101 @@ public class MonitorService extends Service {
|
||||
lastCallTime = currentTimeMillis;
|
||||
String currentTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
|
||||
|
||||
// 创建CallInfo对象并设置相关信息,然后发送到服务器
|
||||
CallInfo callInfo = new CallInfo();
|
||||
callInfo.setCallTime(currentTime);
|
||||
callInfo.setPhoneNumber(incomingNumber);
|
||||
networkUtils.postRequest(callInfo);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 向服务器发送短信信息。
|
||||
*
|
||||
* @param sender 发送者的手机号码。
|
||||
* @param messageBody 短信的内容。
|
||||
* 该方法首先会检查发送者和短信内容是否为空,如果为空则不进行任何操作。
|
||||
* 接着,它会格式化当前时间,并创建一个SMSInfo对象,将发送者、短信内容和接收时间设置到这个对象中。
|
||||
* 最后,使用网络工具将这个SMSInfo对象以POST请求的方式发送到服务器。
|
||||
*/
|
||||
private void sendSmsInfoToServer(String sender, String messageBody) {
|
||||
Timber.d("sendSmsInfoToServer: 处理短信信息");
|
||||
if (checkNullString(sender, messageBody)) {
|
||||
return;
|
||||
}
|
||||
// 获取当前时间并格式化
|
||||
String currentTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
|
||||
// 创建SMSInfo对象并设置相关属性
|
||||
SMSInfo smsInfo = new SMSInfo();
|
||||
smsInfo.setSmsNumber(sender);
|
||||
smsInfo.setSmsContent(messageBody);
|
||||
smsInfo.setSmsAcceptanceTime(currentTime);
|
||||
// 使用网络工具发送POST请求
|
||||
networkUtils.postRequest(smsInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送微信消息。
|
||||
* 使用网络工具类向指定地址发送微信消息。
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
// 检查任一字符串是否等于"null"
|
||||
if (a.equals("null") || b.equals("null")) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 启动一个前台服务。该方法首先会检查系统版本,如果是在API 26及以上版本,就会创建一个通知频道。
|
||||
* 然后,构建一个通知对象,并使用该通知启动前台服务。前台服务能够在后台持续运行,即使应用被关闭或压入后台,
|
||||
* 也能保持服务的运行状态,常用于需要持续运行的服务。
|
||||
*/
|
||||
private void startForegroundService() {
|
||||
Timber.d("startForegroundService: 启动前台服务");
|
||||
// 创建通知频道(仅在API 26及以上版本中需要)
|
||||
// 检测系统版本,仅在API 26及以上版本创建通知频道
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
NotificationChannel channel = new NotificationChannel("channel_id", "Channel Name", NotificationManager.IMPORTANCE_DEFAULT);
|
||||
NotificationManager notificationManager = getSystemService(NotificationManager.class);
|
||||
notificationManager.createNotificationChannel(channel);
|
||||
}
|
||||
|
||||
// 创建通知
|
||||
// 创建通知对象。通知内容包括标题、小图标等
|
||||
Notification notification = new NotificationCompat.Builder(this, "channel_id")
|
||||
.setContentTitle(getString(R.string.notification_title))
|
||||
//.setContentText("sdads")
|
||||
.setSmallIcon(R.drawable.ic_notification) // 确保您有这个图标
|
||||
.setSmallIcon(R.drawable.ic_notification) // 设置通知的小图标
|
||||
.build();
|
||||
|
||||
// 启动前台服务
|
||||
// 使用创建的通知启动前台服务
|
||||
startForeground(1, notification);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 当其他组件请求与服务绑定时调用此方法。该服务不提供绑定接口,因此总是返回null。
|
||||
*
|
||||
* @param intent 指示服务应该执行的操作的Intent。包含请求绑定的服务的信息。
|
||||
* @return 返回null,表示该服务不支持绑定操作。
|
||||
*/
|
||||
@Nullable
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
@@ -151,20 +204,44 @@ public class MonitorService extends Service {
|
||||
return null; // 不提供绑定服务的接口
|
||||
}
|
||||
|
||||
public static void scheduleHeartbeat(Context context) {
|
||||
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
|
||||
Intent intent = new Intent(context, HeartbeatAlarmReceiver.class);
|
||||
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, 0);
|
||||
|
||||
/**
|
||||
* 调度心跳监测。此函数用于设置一个定时任务,以便周期性地触发心跳事件。
|
||||
* 心跳事件通过广播的形式由系统自动触发,用于维持应用程序在后台的活性或执行定期任务。
|
||||
*
|
||||
* @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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ 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;
|
||||
@@ -27,6 +28,7 @@ public class NotificationListener extends NotificationListenerService {
|
||||
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());
|
||||
@@ -46,39 +48,52 @@ public class NotificationListener extends NotificationListenerService {
|
||||
}
|
||||
|
||||
Bundle extras = sbn.getNotification().extras;
|
||||
String title = extras.getString(Notification.EXTRA_TITLE);
|
||||
String content = extras.getString(Notification.EXTRA_TEXT);
|
||||
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);
|
||||
String appName = handleNoticeUtils.messageHandle(packageName);
|
||||
String logMessage = String.format("packageName: %s, title: %s, content: %s, tickerText: %s", packageName, title, content, tickerText);
|
||||
|
||||
if ("微信".equals(appName) && tickerText.contains(":")) {
|
||||
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);
|
||||
String sender = parts[0].trim(); // 去除两端的空格
|
||||
String message = parts.length > 1 ? parts[1].trim() : ""; // 同样去除两端的空格
|
||||
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(appName);
|
||||
weChatMsg.setCurrentTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault()).format(new Date()));
|
||||
weChatMsg.setAppName("微信");
|
||||
weChatMsg.setCurrentTime(DATE_FORMAT.format(new Date()));
|
||||
|
||||
Timber.d("准备发送微信消息: %s", weChatMsg);
|
||||
// 异步执行网络请求
|
||||
try {
|
||||
Timber.d("准备将接受的微信通知转发: %s", weChatMsg);
|
||||
networkUtil.postRequest(weChatMsg);
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
Timber.e(e, "转发送微信通知失败");
|
||||
}
|
||||
|
||||
// 检查是否在30秒内已打印过相同内容
|
||||
if (!shouldPrintLog(logMessage)) {
|
||||
return; // 如果在30秒内已打印过,则跳过
|
||||
}
|
||||
|
||||
// Timber.d(logMessage);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onNotificationRemoved(StatusBarNotification sbn) {
|
||||
// 当通知被移除时调用
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
package com.nbee.echolink.utils;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.provider.Settings;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.util.Log;
|
||||
|
||||
public class DeviceInfoUtils {
|
||||
/**
|
||||
* 获取设备宽度(px)
|
||||
*
|
||||
*/
|
||||
public static int getDeviceWidth(Context context) {
|
||||
return context.getResources().getDisplayMetrics().widthPixels;
|
||||
@@ -20,6 +22,7 @@ public class DeviceInfoUtils {
|
||||
public static int getDeviceHeight(Context context) {
|
||||
return context.getResources().getDisplayMetrics().heightPixels;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取厂商名
|
||||
**/
|
||||
@@ -63,8 +66,6 @@ public class DeviceInfoUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* fingerprit 信息
|
||||
**/
|
||||
public static String getDeviceFubgerprint() {
|
||||
@@ -73,7 +74,6 @@ public class DeviceInfoUtils {
|
||||
|
||||
/**
|
||||
* 硬件名
|
||||
*
|
||||
**/
|
||||
public static String getDeviceHardware() {
|
||||
return android.os.Build.HARDWARE;
|
||||
@@ -81,14 +81,12 @@ public class DeviceInfoUtils {
|
||||
|
||||
/**
|
||||
* 主机
|
||||
*
|
||||
**/
|
||||
public static String getDeviceHost() {
|
||||
return android.os.Build.HOST;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* 显示ID
|
||||
**/
|
||||
public static String getDeviceDisplay() {
|
||||
@@ -97,15 +95,24 @@ public class DeviceInfoUtils {
|
||||
|
||||
/**
|
||||
* ID
|
||||
*
|
||||
**/
|
||||
public static String getDeviceId() {
|
||||
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() {
|
||||
return android.os.Build.USER;
|
||||
@@ -115,9 +122,10 @@ public class DeviceInfoUtils {
|
||||
* 获取手机 硬件序列号
|
||||
**/
|
||||
public static String getDeviceSerial() {
|
||||
return android.os.Build.SERIAL;
|
||||
return "89KX0ARVK";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取手机Android 系统SDK
|
||||
*
|
||||
@@ -143,21 +151,4 @@ public class DeviceInfoUtils {
|
||||
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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user