version:2.1 MTK
fix:优化获取设备类型逻辑,优化获取设备版本号 update:打包更新
This commit is contained in:
182
app/build.gradle
182
app/build.gradle
@@ -41,6 +41,17 @@ android {
|
|||||||
abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86'
|
abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86'
|
||||||
// 还可以添加 'armeabi' , 'x86', 'x86_64', 'mips', 'mips64'
|
// 还可以添加 'armeabi' , 'x86', 'x86_64', 'mips', 'mips64'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
manifestPlaceholders = [
|
||||||
|
XG_ACCESS_ID : "1500026372",
|
||||||
|
XG_ACCESS_KEY: "AR7A1L5M0LPH",
|
||||||
|
]
|
||||||
|
|
||||||
|
buildConfigField "String", "ROOT_URL", '"https://led.aoleyun.cn/api/"'
|
||||||
|
buildConfigField "String", "SCREEN_BASE_URL", '"https://led.aoleyun.cn:2018/"'
|
||||||
|
buildConfigField "String", "SCREEN_URL", '"https://led.aoleyun.cn:2018/wm/is_online"'
|
||||||
|
buildConfigField "String", "WebsocketURL", '"wss://led.aoleyun.cn:2018"'
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lintOptions {
|
lintOptions {
|
||||||
@@ -56,64 +67,52 @@ android {
|
|||||||
targetCompatibility JavaVersion.VERSION_1_8
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
}
|
}
|
||||||
|
|
||||||
//多版本
|
//多渠道
|
||||||
productFlavors {
|
productFlavors {
|
||||||
//新平台正式
|
//新平台正式
|
||||||
|
newly {
|
||||||
|
flavorDimensions "default"
|
||||||
|
versionCode 20
|
||||||
|
versionName "2.9"
|
||||||
|
buildConfigField "String", "platform", '"ZhanRui"'
|
||||||
|
manifestPlaceholders = [
|
||||||
|
AMAP_KEY: "6e339305206eeb43f2b4cc1f31751f89"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
//酷比魔方
|
||||||
cube {
|
cube {
|
||||||
flavorDimensions "default"
|
flavorDimensions "default"
|
||||||
versionCode 36
|
versionCode 36
|
||||||
versionName "4.5"
|
versionName "4.5"
|
||||||
/*********************************极光推送************************************/
|
buildConfigField "String", "platform", '"ZhanRuiCube"'
|
||||||
manifestPlaceholders = [
|
manifestPlaceholders = [
|
||||||
XG_ACCESS_ID : "1500026372",
|
AMAP_KEY: "6e339305206eeb43f2b4cc1f31751f89"
|
||||||
XG_ACCESS_KEY: "AR7A1L5M0LPH",
|
|
||||||
|
|
||||||
// JPUSH_PKGNAME: "com.aoleyun.sn",
|
|
||||||
// JPUSH_APPKEY : "79c64ef41b8728ad6aa29af1", //JPush上注册的包名对应的appkey.
|
|
||||||
// JPUSH_CHANNEL: "developer-default", //暂时填写默认值即可.
|
|
||||||
// channel_value: "newly",
|
|
||||||
|
|
||||||
]
|
]
|
||||||
/*********************************极光推送end************************************/
|
|
||||||
buildConfigField "String", "ROOT_URL", '"https://led.aoleyun.cn/api/"'
|
|
||||||
buildConfigField "String", "SCREEN_BASE_URL", '"https://led.aoleyun.cn:2018/"'
|
|
||||||
buildConfigField "String", "SCREEN_URL", '"https://led.aoleyun.cn:2018/wm/is_online"'
|
|
||||||
buildConfigField "String", "WebsocketURL", '"wss://led.aoleyun.cn:2018"'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//新平台测试
|
//MTK
|
||||||
beta {
|
MTKnewly {
|
||||||
versionNameSuffix "-beta"
|
|
||||||
flavorDimensions "default"
|
flavorDimensions "default"
|
||||||
versionCode 1
|
versionCode 12
|
||||||
versionName "1.0"
|
versionName "2.1"
|
||||||
/*********************************极光推送************************************/
|
buildConfigField "String", "platform", '"MTK"'
|
||||||
manifestPlaceholders = [
|
manifestPlaceholders = [
|
||||||
XG_ACCESS_ID : "1500026372",
|
AMAP_KEY: "1af68e0a7edcaac82678b1cbb7643408"
|
||||||
XG_ACCESS_KEY: "AR7A1L5M0LPH",
|
|
||||||
// JPUSH_PKGNAME: "com.aoleyun.sn",
|
|
||||||
// JPUSH_APPKEY : "79c64ef41b8728ad6aa29af1", //JPush上注册的包名对应的appkey.
|
|
||||||
// JPUSH_CHANNEL: "developer-default", //暂时填写默认值即可.
|
|
||||||
// channel_value: "beta",
|
|
||||||
]
|
]
|
||||||
/*********************************极光推送end************************************/
|
|
||||||
buildConfigField "String", "ROOT_URL", '"https://led.aoleyun.cn/api/"'
|
|
||||||
buildConfigField "String", "SCREEN_BASE_URL", '"https://led.aoleyun.cn:2018/"'
|
|
||||||
buildConfigField "String", "SCREEN_URL", '"https://led.aoleyun.cn:2018/wm/is_online"'
|
|
||||||
buildConfigField "String", "WebsocketURL", '"wss://led.aoleyun.cn:2018"'
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
//测试版的图标
|
//测试版的图标
|
||||||
beta.res.srcDirs = ['src/beta/res']
|
// beta.res.srcDirs = ['src/beta/res']
|
||||||
// newly.res.srcDirs = ['src/beta/res']
|
// newly.res.srcDirs = ['src/beta/res']
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//签名
|
//签名
|
||||||
signingConfigs {
|
signingConfigs {
|
||||||
alldocube {
|
zhanRui {
|
||||||
storeFile file("keystore/zhanxun.keystore")
|
storeFile file("keystore/zhanxun.keystore")
|
||||||
storePassword "123456"
|
storePassword "123456"
|
||||||
keyAlias "zhanxun"
|
keyAlias "zhanxun"
|
||||||
@@ -122,7 +121,7 @@ android {
|
|||||||
v2SigningEnabled false
|
v2SigningEnabled false
|
||||||
}
|
}
|
||||||
|
|
||||||
alldocubeDebug {
|
zhanRuiUserdebug {
|
||||||
storeFile file("keystore/zhanxunUserdebug.keystore")
|
storeFile file("keystore/zhanxunUserdebug.keystore")
|
||||||
storePassword "123456"
|
storePassword "123456"
|
||||||
keyAlias "zhanxunUserdebug"
|
keyAlias "zhanxunUserdebug"
|
||||||
@@ -130,36 +129,74 @@ android {
|
|||||||
v1SigningEnabled true
|
v1SigningEnabled true
|
||||||
v2SigningEnabled false
|
v2SigningEnabled false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mtk {
|
||||||
|
storeFile file("keystore/xueshibaoos.jks")
|
||||||
|
storePassword "123456"
|
||||||
|
keyAlias "xueshibaoos"
|
||||||
|
keyPassword "123456"
|
||||||
|
v1SigningEnabled true
|
||||||
|
v2SigningEnabled true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disable release builds for now
|
// Disable release builds for now
|
||||||
// android.variantFilter { variant ->
|
android.variantFilter { variant ->
|
||||||
// if (variant.buildType.name.endsWith('zhanRuiRelease')) {
|
if (variant.buildType.name.endsWith('zhanRuiRelease')) {
|
||||||
// variant.setIgnore(variant.getFlavors().get(0).name.equals('official') || variant.getFlavors().get(0).name.equals('zhongyou'))
|
variant.setIgnore(variant.getFlavors().get(0).name.equals('official') || variant.getFlavors().get(0).name.equals('zhongyou'))
|
||||||
|
}
|
||||||
|
if (name.startsWith('newly')) {
|
||||||
|
variant.setIgnore(name.endsWith("newlyDebug")
|
||||||
|
|| name.endsWith('newlyRelease'))
|
||||||
|
}
|
||||||
|
if (name.startsWith('cube')) {
|
||||||
|
variant.setIgnore(name.endsWith("cubeDebug")
|
||||||
|
|| name.endsWith('cubeRelease'))
|
||||||
|
}
|
||||||
|
if (name.contains("MTKnewly")) {
|
||||||
|
variant.setIgnore(variant.buildType.name.endsWith("zhanRuiRelease")
|
||||||
|
|| variant.buildType.name.endsWith("zhanRuiDebug")
|
||||||
|
|| variant.buildType.name.endsWith("zhanRuiUserdebug")
|
||||||
|
|| variant.buildType.name.endsWith("zhanRuiUserdebugReleas")
|
||||||
|
|| variant.buildType.name.endsWith("alldocubeDebug")
|
||||||
|
|| variant.buildType.name.endsWith("alldocubeDebugRelease")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// // Icon recents is Go only
|
||||||
|
// if (name.contains("WithQuickstepIconRecents") && !name.contains("l3go")) {
|
||||||
|
// variant.setIgnore(true)
|
||||||
// }
|
// }
|
||||||
// if (variant.buildType.name.endsWith('zhanRuiDebug')) {
|
}
|
||||||
// variant.setIgnore(variant.getFlavors().get(0).name.equals('official') || variant.getFlavors().get(0).name.equals('zhongyou'))
|
|
||||||
// }
|
|
||||||
// if (name.contains("MTKnewly")) {
|
|
||||||
// variant.setIgnore(variant.buildType.name.endsWith("zhanRuiRelease") || variant.buildType.name.endsWith("zhanRuiDebug") || variant.buildType.name.endsWith("zhanRuiUserdebug")
|
|
||||||
// || variant.buildType.name.endsWith("zhanRuiUserdebugReleas"))
|
|
||||||
// }
|
|
||||||
// if (name.endsWith("newlyDebug") || name.endsWith("newlyRelease")) {
|
|
||||||
// variant.setIgnore(!name.contains("MTK"))
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//// // Icon recents is Go only
|
|
||||||
//// if (name.contains("WithQuickstepIconRecents") && !name.contains("l3go")) {
|
|
||||||
//// variant.setIgnore(true)
|
|
||||||
//// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
|
zhanRuiDebug.initWith(debug)
|
||||||
|
zhanRuiDebug {
|
||||||
|
debuggable true
|
||||||
|
versionNameSuffix "-debug"
|
||||||
|
signingConfig signingConfigs.zhanRui
|
||||||
|
}
|
||||||
|
|
||||||
|
zhanRuiRelease.initWith(release)
|
||||||
|
zhanRuiRelease {
|
||||||
|
signingConfig signingConfigs.zhanRui
|
||||||
|
}
|
||||||
|
|
||||||
|
//userdebug rom使用这个版本
|
||||||
|
zhanRuiUserdebug.initWith(zhanRuiDebug)
|
||||||
|
zhanRuiUserdebug {
|
||||||
|
debuggable true
|
||||||
|
versionNameSuffix "-debug"
|
||||||
|
signingConfig signingConfigs.zhanRuiUserdebug
|
||||||
|
}
|
||||||
|
|
||||||
|
zhanRuiUserdebugReleas.initWith(release)
|
||||||
|
zhanRuiUserdebugReleas {
|
||||||
|
debuggable true
|
||||||
|
signingConfig signingConfigs.zhanRuiUserdebug
|
||||||
|
}
|
||||||
|
|
||||||
debug {
|
debug {
|
||||||
buildConfigField "String", "platform", '"ZhanRui"'
|
|
||||||
manifestPlaceholders = [
|
|
||||||
AMAP_KEY: "6e339305206eeb43f2b4cc1f31751f89"
|
|
||||||
]
|
|
||||||
debuggable true
|
debuggable true
|
||||||
versionNameSuffix "-debug"
|
versionNameSuffix "-debug"
|
||||||
minifyEnabled false
|
minifyEnabled false
|
||||||
@@ -175,14 +212,10 @@ android {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
signingConfig signingConfigs.alldocube
|
signingConfig signingConfigs.mtk
|
||||||
}
|
}
|
||||||
|
|
||||||
release {
|
release {
|
||||||
buildConfigField "String", "platform", '"ZhanRui"'
|
|
||||||
manifestPlaceholders = [
|
|
||||||
AMAP_KEY: "6e339305206eeb43f2b4cc1f31751f89"
|
|
||||||
]
|
|
||||||
//混淆
|
//混淆
|
||||||
minifyEnabled false
|
minifyEnabled false
|
||||||
//前一部分代表系统默认的android程序的混淆文件,该文件已经包含了基本的混淆声明,后一个文件是自己的定义混淆文件
|
//前一部分代表系统默认的android程序的混淆文件,该文件已经包含了基本的混淆声明,后一个文件是自己的定义混淆文件
|
||||||
@@ -198,28 +231,7 @@ android {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
signingConfig signingConfigs.alldocube
|
signingConfig signingConfigs.mtk
|
||||||
}
|
|
||||||
|
|
||||||
//userdebug rom使用这个版本
|
|
||||||
alldocubeDebug.initWith(debug)
|
|
||||||
alldocubeDebug {
|
|
||||||
buildConfigField "String", "platform", '"ZhanRui"'
|
|
||||||
manifestPlaceholders = [
|
|
||||||
AMAP_KEY: "6e339305206eeb43f2b4cc1f31751f89"
|
|
||||||
]
|
|
||||||
debuggable true
|
|
||||||
versionNameSuffix "-debug"
|
|
||||||
signingConfig signingConfigs.alldocubeDebug
|
|
||||||
}
|
|
||||||
|
|
||||||
alldocubeDebugReleas.initWith(release)
|
|
||||||
alldocubeDebugReleas {
|
|
||||||
buildConfigField "String", "platform", '"ZhanRui"'
|
|
||||||
manifestPlaceholders = [
|
|
||||||
AMAP_KEY: "6e339305206eeb43f2b4cc1f31751f89"
|
|
||||||
]
|
|
||||||
signingConfig signingConfigs.alldocubeDebug
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
BIN
app/keystore/xueshibaoos.jks
Normal file
BIN
app/keystore/xueshibaoos.jks
Normal file
Binary file not shown.
@@ -145,6 +145,7 @@
|
|||||||
android:excludeFromRecents="true"
|
android:excludeFromRecents="true"
|
||||||
android:launchMode="singleTop" />
|
android:launchMode="singleTop" />
|
||||||
<activity android:name=".activity.TopActivity" />
|
<activity android:name=".activity.TopActivity" />
|
||||||
|
<activity android:name=".activity.MainActivity1" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.requestlog.RequestLogActivity"
|
android:name=".activity.requestlog.RequestLogActivity"
|
||||||
android:launchMode="singleTask" />
|
android:launchMode="singleTask" />
|
||||||
@@ -452,6 +453,7 @@
|
|||||||
<!-- android:name="CHANNEL_VALUE"-->
|
<!-- android:name="CHANNEL_VALUE"-->
|
||||||
<!-- android:value="${channel_value}" />-->
|
<!-- android:value="${channel_value}" />-->
|
||||||
|
|
||||||
|
|
||||||
<!-- 应用的其它配置 -->
|
<!-- 应用的其它配置 -->
|
||||||
<uses-library
|
<uses-library
|
||||||
android:name="org.apache.http.legacy"
|
android:name="org.apache.http.legacy"
|
||||||
|
|||||||
382
app/src/main/java/com/aoleyun/sn/activity/MainActivity1.java
Normal file
382
app/src/main/java/com/aoleyun/sn/activity/MainActivity1.java
Normal file
@@ -0,0 +1,382 @@
|
|||||||
|
package com.aoleyun.sn.activity;
|
||||||
|
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.IntentFilter;
|
||||||
|
import android.os.Message;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import com.aoleyun.sn.R;
|
||||||
|
import com.aoleyun.sn.activity.utils.WeakHandler;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
// 电池状态
|
||||||
|
import static android.os.BatteryManager.EXTRA_STATUS;
|
||||||
|
// 未知
|
||||||
|
import static android.os.BatteryManager.BATTERY_STATUS_UNKNOWN;
|
||||||
|
// 充电中
|
||||||
|
import static android.os.BatteryManager.BATTERY_STATUS_CHARGING;
|
||||||
|
// 放电中
|
||||||
|
import static android.os.BatteryManager.BATTERY_STATUS_DISCHARGING;
|
||||||
|
// 未充电
|
||||||
|
import static android.os.BatteryManager.BATTERY_STATUS_NOT_CHARGING;
|
||||||
|
// 电池满
|
||||||
|
import static android.os.BatteryManager.BATTERY_STATUS_FULL;
|
||||||
|
// 电池健康情况
|
||||||
|
import static android.os.BatteryManager.EXTRA_HEALTH;
|
||||||
|
// 未知
|
||||||
|
import static android.os.BatteryManager.BATTERY_HEALTH_UNKNOWN;
|
||||||
|
// 良好
|
||||||
|
import static android.os.BatteryManager.BATTERY_HEALTH_GOOD;
|
||||||
|
// 过热
|
||||||
|
import static android.os.BatteryManager.BATTERY_HEALTH_OVERHEAT;
|
||||||
|
// 没电
|
||||||
|
import static android.os.BatteryManager.BATTERY_HEALTH_DEAD;
|
||||||
|
// 未知错误
|
||||||
|
import static android.os.BatteryManager.BATTERY_HEALTH_UNSPECIFIED_FAILURE;
|
||||||
|
// 过电压
|
||||||
|
import static android.os.BatteryManager.BATTERY_HEALTH_OVER_VOLTAGE;
|
||||||
|
// 温度过低
|
||||||
|
import static android.os.BatteryManager.BATTERY_HEALTH_COLD;
|
||||||
|
// 充电类型
|
||||||
|
import static android.os.BatteryManager.EXTRA_PLUGGED;
|
||||||
|
// 充电器
|
||||||
|
import static android.os.BatteryManager.BATTERY_PLUGGED_AC;
|
||||||
|
// 其他
|
||||||
|
import static android.os.BatteryManager.BATTERY_PLUGGED_ANY;
|
||||||
|
// USB
|
||||||
|
import static android.os.BatteryManager.BATTERY_PLUGGED_USB;
|
||||||
|
// 无线充电
|
||||||
|
import static android.os.BatteryManager.BATTERY_PLUGGED_WIRELESS;
|
||||||
|
// 当前电量
|
||||||
|
import static android.os.BatteryManager.EXTRA_LEVEL;
|
||||||
|
// 当前电池温度
|
||||||
|
import static android.os.BatteryManager.EXTRA_TEMPERATURE;
|
||||||
|
import static android.os.BatteryManager.EXTRA_SCALE;
|
||||||
|
// 当前电池电压
|
||||||
|
import static android.os.BatteryManager.EXTRA_VOLTAGE;
|
||||||
|
// 电池技术描述
|
||||||
|
import static android.os.BatteryManager.EXTRA_TECHNOLOGY;
|
||||||
|
// 最大充电电压
|
||||||
|
import static android.os.BatteryManager.EXTRA_MAX_CHARGING_VOLTAGE;
|
||||||
|
// 最大充电电流
|
||||||
|
import static android.os.BatteryManager.EXTRA_MAX_CHARGING_CURRENT;
|
||||||
|
|
||||||
|
public class MainActivity1 extends AppCompatActivity {
|
||||||
|
|
||||||
|
private static final String TAG = MainActivity1.class.getSimpleName();
|
||||||
|
|
||||||
|
private static final int DEFAULT_CHARGING_VOLTAGE_MICRO_VOLT = 5000000;
|
||||||
|
|
||||||
|
private static final int MSG_UPDATE_UI = 0;
|
||||||
|
|
||||||
|
|
||||||
|
private String result;
|
||||||
|
|
||||||
|
private TextView tv_show;
|
||||||
|
|
||||||
|
private final MainHandler mHandler = new MainHandler(this);
|
||||||
|
private static class MainHandler extends WeakHandler<MainActivity1> {
|
||||||
|
|
||||||
|
public MainHandler(MainActivity1 owner) {
|
||||||
|
super(owner);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleMessage(Message msg) {
|
||||||
|
MainActivity1 activity = getOwner();
|
||||||
|
if (activity == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (msg.what == MSG_UPDATE_UI) {
|
||||||
|
activity.updateUI();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_main1);
|
||||||
|
startBroadCast();
|
||||||
|
|
||||||
|
initView();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initView() {
|
||||||
|
tv_show = findViewById(R.id.tv_show);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateUI() {
|
||||||
|
tv_show.setText(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
stopBroadCast();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void startBroadCast() {
|
||||||
|
IntentFilter filter = new IntentFilter();
|
||||||
|
filter.addAction(Intent.ACTION_BATTERY_CHANGED);
|
||||||
|
registerReceiver(mBroadcastReceiver, filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void stopBroadCast() {
|
||||||
|
unregisterReceiver(mBroadcastReceiver);
|
||||||
|
}
|
||||||
|
|
||||||
|
private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
if (null == intent) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String action = intent.getAction();
|
||||||
|
|
||||||
|
if (Intent.ACTION_BATTERY_CHANGED.equals(action)) {
|
||||||
|
int status = intent.getIntExtra(EXTRA_STATUS, BATTERY_STATUS_UNKNOWN);
|
||||||
|
int plugged = intent.getIntExtra(EXTRA_PLUGGED, BATTERY_PLUGGED_ANY);
|
||||||
|
int level = intent.getIntExtra(EXTRA_LEVEL, 0);
|
||||||
|
int scale = intent.getIntExtra(EXTRA_SCALE, 0);
|
||||||
|
int health = intent.getIntExtra(EXTRA_HEALTH, BATTERY_HEALTH_UNKNOWN);
|
||||||
|
|
||||||
|
int maxChargingMicroAmp = intent.getIntExtra(EXTRA_MAX_CHARGING_CURRENT, -1);
|
||||||
|
int maxChargingMicroVolt = intent.getIntExtra(EXTRA_MAX_CHARGING_VOLTAGE, -1);
|
||||||
|
int batteryVolt = intent.getIntExtra(EXTRA_VOLTAGE, -1);
|
||||||
|
int temperature = intent.getIntExtra(EXTRA_TEMPERATURE, -1);
|
||||||
|
String batteryTechnologyDescript = intent.getStringExtra(EXTRA_TECHNOLOGY);
|
||||||
|
|
||||||
|
final int maxChargingMicroWatt;
|
||||||
|
|
||||||
|
if (maxChargingMicroVolt <= 0) {
|
||||||
|
maxChargingMicroVolt = DEFAULT_CHARGING_VOLTAGE_MICRO_VOLT;
|
||||||
|
}
|
||||||
|
if (maxChargingMicroAmp > 0) {
|
||||||
|
// Calculating muW = muA * muV / (10^6 mu^2 / mu); splitting up the divisor
|
||||||
|
// to maintain precision equally on both factors.
|
||||||
|
maxChargingMicroWatt = (maxChargingMicroAmp / 1000)
|
||||||
|
* (maxChargingMicroVolt / 1000);
|
||||||
|
} else {
|
||||||
|
maxChargingMicroWatt = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
String statusStr = getStatus(status);
|
||||||
|
String healthStr = getHealth(health);
|
||||||
|
String pluggedStr = getPlugged(plugged);
|
||||||
|
String levelStr = getLevel(level);
|
||||||
|
String scaleStr = getLevel(scale);
|
||||||
|
String temperatureStr = getTemperature(temperature);
|
||||||
|
String batteryVoltStr = getBatteryVolt(batteryVolt);
|
||||||
|
String maxChargingMicroAmpStr = getMaxChargingMicroAmp(maxChargingMicroAmp);
|
||||||
|
String maxChargingMicroVoltStr = getMaxChargingMicroVolt(maxChargingMicroVolt);
|
||||||
|
|
||||||
|
int currentChargingCurrent = getCurrentChargingCurrent();
|
||||||
|
String currentChargingCurrentStr = getCurrentChargingCurrentStr(currentChargingCurrent);
|
||||||
|
int currentChargingVoltage = getCurrentChargingVoltage();
|
||||||
|
String currentChargingVoltageStr = getCurrentChargingVoltageStr(currentChargingVoltage);
|
||||||
|
|
||||||
|
|
||||||
|
result = MainActivity1.this.getString(R.string.adb_shell_help)
|
||||||
|
+ "\n" + MainActivity1.this.getString(R.string.battery_current_level) + levelStr
|
||||||
|
+ "\n" + MainActivity1.this.getString(R.string.battery_current_temperature) + temperatureStr
|
||||||
|
+ "\n" + MainActivity1.this.getString(R.string.battery_current_volt) + batteryVoltStr
|
||||||
|
+ "\n" + MainActivity1.this.getString(R.string.battery_current_charging_current) + currentChargingCurrentStr
|
||||||
|
+ "\n" + MainActivity1.this.getString(R.string.battery_current_charging_voltage) + currentChargingVoltageStr
|
||||||
|
+ "\n" + MainActivity1.this.getString(R.string.battery_status_titls) + statusStr
|
||||||
|
+ "\n" + MainActivity1.this.getString(R.string.battery_plugged_titls) + pluggedStr
|
||||||
|
+ "\n" + MainActivity1.this.getString(R.string.battery_max_charging_current) + maxChargingMicroAmpStr
|
||||||
|
+ "\n" + MainActivity1.this.getString(R.string.battery_max_charging_voltage) + maxChargingMicroVoltStr
|
||||||
|
+ "\n" + MainActivity1.this.getString(R.string.battery_health_titls) + healthStr
|
||||||
|
+ "\n" + MainActivity1.this.getString(R.string.battery_max_level) + scaleStr
|
||||||
|
+ "\n" + MainActivity1.this.getString(R.string.battery_technology_describing) + batteryTechnologyDescript
|
||||||
|
+"\n充电速度 = " + maxChargingMicroWatt;
|
||||||
|
mHandler.sendEmptyMessage(MSG_UPDATE_UI);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
private String getCurrentChargingVoltageStr(int currentChargingVoltage) {
|
||||||
|
return String.format("%.3f V", currentChargingVoltage / 1000000.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getCurrentChargingCurrentStr(int currentChargingCurrent) {
|
||||||
|
return String.format("%.3f A", currentChargingCurrent / 1000.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前充电电流 mA
|
||||||
|
*
|
||||||
|
* adb shell "cat /sys/class/power_supply/battery/BatteryAverageCurrent"
|
||||||
|
*/
|
||||||
|
private int getCurrentChargingCurrent() {
|
||||||
|
int result = 0;
|
||||||
|
BufferedReader br = null;
|
||||||
|
try {
|
||||||
|
String line;
|
||||||
|
br = new BufferedReader(new FileReader("/sys/class/power_supply/battery/BatteryAverageCurrent"));
|
||||||
|
if ((line = br.readLine()) != null) {
|
||||||
|
result = Integer.parseInt(line);
|
||||||
|
}
|
||||||
|
|
||||||
|
br.close();
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
if (br != null) {
|
||||||
|
try {
|
||||||
|
br.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前充电电压 uV
|
||||||
|
*
|
||||||
|
* adb shell "cat /sys/class/power_supply/battery/batt_vol"
|
||||||
|
*/
|
||||||
|
private int getCurrentChargingVoltage() {
|
||||||
|
int result = 0;
|
||||||
|
BufferedReader br = null;
|
||||||
|
try {
|
||||||
|
String line;
|
||||||
|
br = new BufferedReader(new FileReader("/sys/class/power_supply/battery/batt_vol"));
|
||||||
|
if ((line = br.readLine()) != null) {
|
||||||
|
result = Integer.parseInt(line);
|
||||||
|
}
|
||||||
|
|
||||||
|
br.close();
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
if (br != null) {
|
||||||
|
try {
|
||||||
|
br.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getMaxChargingMicroVolt(int maxChargingMicroVolt) {
|
||||||
|
return String.format("%.1f V", maxChargingMicroVolt / 1000000.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getMaxChargingMicroAmp(int maxChargingMicroAmp) {
|
||||||
|
return String.format("%.1f A", maxChargingMicroAmp / 1000000.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getBatteryVolt(int batteryVolt) {
|
||||||
|
return String.format("%.3f V", batteryVolt / 1000.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private String getTemperature(int temperature) {
|
||||||
|
return String.format("%.1f ℃", temperature / 10.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getLevel(int level) {
|
||||||
|
return String.format("%d %%", level);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getPlugged(int plugged) {
|
||||||
|
String result = getString(R.string.battery_plugged_any);
|
||||||
|
|
||||||
|
switch (plugged) {
|
||||||
|
case BATTERY_PLUGGED_ANY:
|
||||||
|
break;
|
||||||
|
case BATTERY_PLUGGED_AC:
|
||||||
|
result = getString(R.string.battery_plugged_ac);
|
||||||
|
break;
|
||||||
|
case BATTERY_PLUGGED_USB:
|
||||||
|
result = getString(R.string.battery_plugged_usb);
|
||||||
|
break;
|
||||||
|
case BATTERY_PLUGGED_WIRELESS:
|
||||||
|
result = getString(R.string.battery_plugged_wireless);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private String getHealth(int health) {
|
||||||
|
String result = getString(R.string.battery_health_unknow);
|
||||||
|
|
||||||
|
switch (health) {
|
||||||
|
case BATTERY_HEALTH_UNKNOWN:
|
||||||
|
break;
|
||||||
|
case BATTERY_HEALTH_GOOD:
|
||||||
|
result = getString(R.string.battery_health_good);
|
||||||
|
break;
|
||||||
|
case BATTERY_HEALTH_OVERHEAT:
|
||||||
|
result = getString(R.string.battery_health_overheat);
|
||||||
|
break;
|
||||||
|
case BATTERY_HEALTH_DEAD:
|
||||||
|
result = getString(R.string.battery_health_dead);
|
||||||
|
break;
|
||||||
|
case BATTERY_HEALTH_UNSPECIFIED_FAILURE:
|
||||||
|
result = getString(R.string.battery_health_unspecified_failure);
|
||||||
|
break;
|
||||||
|
case BATTERY_HEALTH_OVER_VOLTAGE:
|
||||||
|
result = getString(R.string.battery_health_over_voltage);
|
||||||
|
break;
|
||||||
|
case BATTERY_HEALTH_COLD:
|
||||||
|
result = getString(R.string.battery_health_cold);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private String getStatus(int status) {
|
||||||
|
String result = getString(R.string.battery_status_unknown);
|
||||||
|
|
||||||
|
switch (status) {
|
||||||
|
case BATTERY_STATUS_FULL:
|
||||||
|
result = getString(R.string.battery_status_full);
|
||||||
|
break;
|
||||||
|
case BATTERY_STATUS_NOT_CHARGING:
|
||||||
|
result = getString(R.string.battery_status_not_charging);
|
||||||
|
break;
|
||||||
|
case BATTERY_STATUS_DISCHARGING:
|
||||||
|
result = getString(R.string.battery_status_discharging);
|
||||||
|
break;
|
||||||
|
case BATTERY_STATUS_CHARGING:
|
||||||
|
result = getString(R.string.battery_status_charging);
|
||||||
|
break;
|
||||||
|
case BATTERY_STATUS_UNKNOWN:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -33,7 +33,9 @@ import com.aoleyun.sn.comm.PackageNames;
|
|||||||
import com.aoleyun.sn.network.NetInterfaceManager;
|
import com.aoleyun.sn.network.NetInterfaceManager;
|
||||||
import com.aoleyun.sn.service.LogcatService;
|
import com.aoleyun.sn.service.LogcatService;
|
||||||
import com.aoleyun.sn.utils.ApkUtils;
|
import com.aoleyun.sn.utils.ApkUtils;
|
||||||
|
import com.aoleyun.sn.utils.FlowInfo;
|
||||||
import com.aoleyun.sn.utils.ForegroundAppUtil;
|
import com.aoleyun.sn.utils.ForegroundAppUtil;
|
||||||
|
import com.aoleyun.sn.utils.GetFlowUtil;
|
||||||
import com.aoleyun.sn.utils.JGYUtils;
|
import com.aoleyun.sn.utils.JGYUtils;
|
||||||
import com.aoleyun.sn.utils.NetworkUtils;
|
import com.aoleyun.sn.utils.NetworkUtils;
|
||||||
import com.aoleyun.sn.utils.SPUtils;
|
import com.aoleyun.sn.utils.SPUtils;
|
||||||
@@ -89,15 +91,19 @@ public class SplashActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
private void initView() {
|
private void initView() {
|
||||||
if (BuildConfig.DEBUG) {
|
if (BuildConfig.DEBUG) {
|
||||||
// Log.e(TAG, "initView: " + Utils.getIMEI(this));
|
JGYUtils.getModel();
|
||||||
// Log.e(TAG, "initView: " + Utils.getIMEI(this, 0));
|
|
||||||
// Log.e(TAG, "initView: " + Utils.getIMEI(this, 1));
|
|
||||||
Log.e(TAG, "getOperators: " + NetworkUtils.getOperators(this));
|
Log.e(TAG, "getOperators: " + NetworkUtils.getOperators(this));
|
||||||
Log.e(TAG, "PublicIP: " + MMKV.defaultMMKV().decodeString(NetInterfaceManager.PublicIP, ""));
|
Log.e(TAG, "PublicIP: " + MMKV.defaultMMKV().decodeString(NetInterfaceManager.PublicIP, ""));
|
||||||
NetInterfaceManager.GetWhois();
|
NetInterfaceManager.GetWhois();
|
||||||
Log.e(TAG, "initView: " + NetworkUtils.getPhoneNumber(this));
|
Log.e(TAG, "initView: " + NetworkUtils.getPhoneNumber(this));
|
||||||
// String jsonString = ApkUtils.getRunningAppInfo(this);
|
FlowInfo flowInfo1 = GetFlowUtil.getAppFlowInfo(BuildConfig.APPLICATION_ID, this);
|
||||||
// Log.e(TAG, "initView: " + jsonString);
|
Log.e(TAG, "initView: " + GetFlowUtil.byteToMB(flowInfo1.getUpKb()));
|
||||||
|
Log.e(TAG, "initView: " + GetFlowUtil.byteToMB(flowInfo1.getDownKb()));
|
||||||
|
FlowInfo flowInfo2 = GetFlowUtil.getAppFlowInfo("com.aoleyun.appstore", this);
|
||||||
|
Log.e(TAG, "initView: " + GetFlowUtil.byteToMB(flowInfo2.getUpKb()));
|
||||||
|
Log.e(TAG, "initView: " + GetFlowUtil.byteToMB(flowInfo2.getDownKb()));
|
||||||
|
Log.e(TAG, "initView: " + Utils.getCurrentChargingCurrent());
|
||||||
|
Log.e(TAG, "initView: " + Utils.getCurrentChargingVoltage());
|
||||||
ApkUtils.showAllAPP(this);
|
ApkUtils.showAllAPP(this);
|
||||||
// JGYUtils.getInstance().cleanBackgroundMemory();
|
// JGYUtils.getInstance().cleanBackgroundMemory();
|
||||||
// NetInterfaceManager.getInstance().uploadLogFile();
|
// NetInterfaceManager.getInstance().uploadLogFile();
|
||||||
@@ -155,7 +161,8 @@ public class SplashActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
Log.i(TAG, "debugTest: " + Utils.getAndroid10MAC(this));
|
Log.i(TAG, "debugTest: " + Utils.getAndroid10MAC(this));
|
||||||
// Log.i(TAG, "debugTest: " + JPushInterface.getRegistrationID(this));
|
// Log.i(TAG, "debugTest: " + JPushInterface.getRegistrationID(this));
|
||||||
Log.i(TAG, "debugTest: " + Utils.getCustomVersion());
|
Log.e(TAG, "getCustomVersion: " + Utils.getCustomVersion());
|
||||||
|
Log.e(TAG, "getRomVersion: " + Utils.getRomVersion());
|
||||||
Log.i(TAG, "debugTest: " + BuildConfig.VERSION_NAME);
|
Log.i(TAG, "debugTest: " + BuildConfig.VERSION_NAME);
|
||||||
Log.i(TAG, "debugTest: " + Utils.getAPPVersionName(PackageNames.APPSTORE, this));
|
Log.i(TAG, "debugTest: " + Utils.getAPPVersionName(PackageNames.APPSTORE, this));
|
||||||
Log.i(TAG, "debugTest: " + Utils.getAndroid7MAC());
|
Log.i(TAG, "debugTest: " + Utils.getAndroid7MAC());
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import io.reactivex.rxjava3.schedulers.Schedulers;
|
|||||||
import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MainActivity 的 Presenter
|
* MainActivity1 的 Presenter
|
||||||
*
|
*
|
||||||
* @author jgy
|
* @author jgy
|
||||||
*/
|
*/
|
||||||
@@ -83,7 +83,7 @@ public class MainAPresenter implements MainAContact.Presenter {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void getStudesInfo(boolean refresh) {
|
public void getStudesInfo(boolean refresh) {
|
||||||
NetInterfaceManager.getInstance().getStudesInfo(false, getLifecycle(), new NetInterfaceManager.StudesInfoListener() {
|
NetInterfaceManager.getInstance().getStudesInfo(true, getLifecycle(), new NetInterfaceManager.StudesInfoListener() {
|
||||||
@Override
|
@Override
|
||||||
public void setStudentsInfo(StudentsInfo studentsInfo) {
|
public void setStudentsInfo(StudentsInfo studentsInfo) {
|
||||||
mView.setStudesInfo(studentsInfo);
|
mView.setStudesInfo(studentsInfo);
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* WeakHandler.java
|
||||||
|
*****************************************************************************
|
||||||
|
* Copyright © 2012 VLC authors and VideoLAN
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
package com.aoleyun.sn.activity.utils;
|
||||||
|
|
||||||
|
import android.os.Handler;
|
||||||
|
|
||||||
|
import java.lang.ref.WeakReference;
|
||||||
|
|
||||||
|
public abstract class WeakHandler<T> extends Handler {
|
||||||
|
private WeakReference<T> mOwner;
|
||||||
|
|
||||||
|
public WeakHandler(T owner) {
|
||||||
|
mOwner = new WeakReference<T>(owner);
|
||||||
|
}
|
||||||
|
|
||||||
|
public T getOwner() {
|
||||||
|
return mOwner.get();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,7 +6,6 @@ import com.google.gson.JsonParser;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
public class ForceDownloadData implements Serializable {
|
public class ForceDownloadData implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 2965901905485481437L;
|
private static final long serialVersionUID = 2965901905485481437L;
|
||||||
|
|
||||||
private String app_name;
|
private String app_name;
|
||||||
|
|||||||
@@ -47,4 +47,10 @@ public class CommonConfig {
|
|||||||
/*上次获取标签的时间*/
|
/*上次获取标签的时间*/
|
||||||
public final static String GET_DEVICES_TAG_LASTTIME = "Aoleyun_devices_tag_last_time";
|
public final static String GET_DEVICES_TAG_LASTTIME = "Aoleyun_devices_tag_last_time";
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 管控系统指令
|
||||||
|
*/
|
||||||
|
|
||||||
|
public final static String aole_action_usb_usb_charge = "aole_action_usb_usb_charge";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,18 +91,18 @@ package com.aoleyun.sn.jpush;
|
|||||||
// return sb.toString();
|
// return sb.toString();
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// //send msg to MainActivity
|
// //send msg to MainActivity1
|
||||||
// private void processCustomMessage(Context context, Bundle bundle) {
|
// private void processCustomMessage(Context context, Bundle bundle) {
|
||||||
// if (MainActivity.isForeground) {
|
// if (MainActivity1.isForeground) {
|
||||||
// String message = bundle.getString(JPushInterface.EXTRA_MESSAGE);
|
// String message = bundle.getString(JPushInterface.EXTRA_MESSAGE);
|
||||||
// String extras = bundle.getString(JPushInterface.EXTRA_EXTRA);
|
// String extras = bundle.getString(JPushInterface.EXTRA_EXTRA);
|
||||||
// Intent msgIntent = new Intent(MainActivity.MESSAGE_RECEIVED_ACTION);
|
// Intent msgIntent = new Intent(MainActivity1.MESSAGE_RECEIVED_ACTION);
|
||||||
// msgIntent.putExtra(MainActivity.KEY_MESSAGE, message);
|
// msgIntent.putExtra(MainActivity1.KEY_MESSAGE, message);
|
||||||
// if (!ExampleUtil.isEmpty(extras)) {
|
// if (!ExampleUtil.isEmpty(extras)) {
|
||||||
// try {
|
// try {
|
||||||
// JSONObject extraJson = new JSONObject(extras);
|
// JSONObject extraJson = new JSONObject(extras);
|
||||||
// if (extraJson.length() > 0) {
|
// if (extraJson.length() > 0) {
|
||||||
// msgIntent.putExtra(MainActivity.KEY_EXTRAS, extras);
|
// msgIntent.putExtra(MainActivity1.KEY_EXTRAS, extras);
|
||||||
// }
|
// }
|
||||||
// } catch (JSONException e) {
|
// } catch (JSONException e) {
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.aoleyun.sn.jpush.invalid;
|
package com.aoleyun.sn.jpush.invalid;
|
||||||
|
|
||||||
|
|
||||||
//public class MainActivity extends InstrumentedActivity implements OnClickListener{
|
//public class MainActivity1 extends InstrumentedActivity implements OnClickListener{
|
||||||
//
|
//
|
||||||
// private Button mInit;
|
// private Button mInit;
|
||||||
// private Button mSetting;
|
// private Button mSetting;
|
||||||
@@ -71,7 +71,7 @@ package com.aoleyun.sn.jpush.invalid;
|
|||||||
// init();
|
// init();
|
||||||
// break;
|
// break;
|
||||||
// case R.id.setting:
|
// case R.id.setting:
|
||||||
// Intent intent = new Intent(MainActivity.this, PushSetActivity.class);
|
// Intent intent = new Intent(MainActivity1.this, PushSetActivity.class);
|
||||||
// startActivity(intent);
|
// startActivity(intent);
|
||||||
// break;
|
// break;
|
||||||
// case R.id.stopPush:
|
// case R.id.stopPush:
|
||||||
|
|||||||
@@ -424,7 +424,7 @@ public class NetInterfaceManager {
|
|||||||
.observeOn(AndroidSchedulers.mainThread());
|
.observeOn(AndroidSchedulers.mainThread());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Observable<BaseResponse> getDesktopObservable() {
|
public Observable<BaseResponse<ForceDownloadData>> getDesktopObservable() {
|
||||||
return mRetrofit.create(GetDesktopApi.class)
|
return mRetrofit.create(GetDesktopApi.class)
|
||||||
.getDesktop(Utils.getSerial(mContext))
|
.getDesktop(Utils.getSerial(mContext))
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
@@ -893,24 +893,27 @@ public class NetInterfaceManager {
|
|||||||
public void getDefaultDesktop(BehaviorSubject<ActivityEvent> lifecycle, onCompleteCallback callback) {
|
public void getDefaultDesktop(BehaviorSubject<ActivityEvent> lifecycle, onCompleteCallback callback) {
|
||||||
getDesktopObservable()
|
getDesktopObservable()
|
||||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||||
.subscribe(new Observer<BaseResponse>() {
|
.subscribe(new Observer<BaseResponse<ForceDownloadData>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSubscribe(@NonNull Disposable d) {
|
public void onSubscribe(@NonNull Disposable d) {
|
||||||
Log.e("getDefaultDesktop", "onSubscribe: ");
|
Log.e("getDefaultDesktop", "onSubscribe: ");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNext(@NonNull BaseResponse baseResponse) {
|
public void onNext(@NonNull BaseResponse<ForceDownloadData> baseResponse) {
|
||||||
Log.e("getDefaultDesktop", "onNext: " + baseResponse);
|
Log.e("getDefaultDesktop", "onNext: " + baseResponse);
|
||||||
if (baseResponse.code == OK) {
|
if (baseResponse.code == OK) {
|
||||||
String jsonString = GsonUtils.toJsonString(baseResponse.data);
|
ForceDownloadData desktopInfo = baseResponse.data;
|
||||||
|
String jsonString = GsonUtils.toJsonString(desktopInfo);
|
||||||
JSONObject data = JSON.parseObject(jsonString);
|
JSONObject data = JSON.parseObject(jsonString);
|
||||||
cacheHelper.put(UrlAddress.GET_DESKTOP, jsonString);
|
cacheHelper.put(UrlAddress.GET_DESKTOP, jsonString);
|
||||||
JGYUtils.getInstance().installDesktop(data);
|
JGYUtils.getInstance().installDesktop(data);
|
||||||
|
SPUtils.put(mContext, "default_launcher", desktopInfo.getApp_package());
|
||||||
} else {
|
} else {
|
||||||
Log.e("getDefaultDesktop", "onNext: " + "删除定制桌面");
|
Log.e("getDefaultDesktop", "onNext: " + "删除定制桌面");
|
||||||
cacheHelper.put(UrlAddress.GET_DESKTOP, "");
|
cacheHelper.put(UrlAddress.GET_DESKTOP, "");
|
||||||
String whiteList = Settings.System.getString(mContext.getContentResolver(), JGYActions.ACTION_JGY_SHORTCUTLIST);
|
String whiteList = Settings.System.getString(mContext.getContentResolver(), JGYActions.ACTION_JGY_SHORTCUTLIST);
|
||||||
|
Log.e("getDefaultDesktop", "onNext: " + whiteList);
|
||||||
if (!TextUtils.isEmpty(whiteList)) {
|
if (!TextUtils.isEmpty(whiteList)) {
|
||||||
if (!whiteList.contains(ApkUtils.desktopAPP.get(0))) {
|
if (!whiteList.contains(ApkUtils.desktopAPP.get(0))) {
|
||||||
ApkUtils.UninstallAPP(mContext, ApkUtils.desktopAPP.get(0));
|
ApkUtils.UninstallAPP(mContext, ApkUtils.desktopAPP.get(0));
|
||||||
@@ -920,6 +923,9 @@ public class NetInterfaceManager {
|
|||||||
ApkUtils.UninstallAPP(mContext, ApkUtils.desktopAPP.get(1));
|
ApkUtils.UninstallAPP(mContext, ApkUtils.desktopAPP.get(1));
|
||||||
Log.e("getDefaultDesktop", "skip: " + ApkUtils.desktopAPP.get(1));
|
Log.e("getDefaultDesktop", "skip: " + ApkUtils.desktopAPP.get(1));
|
||||||
}
|
}
|
||||||
|
}else {
|
||||||
|
ApkUtils.UninstallAPP(mContext, ApkUtils.desktopAPP.get(0));
|
||||||
|
ApkUtils.UninstallAPP(mContext, ApkUtils.desktopAPP.get(1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1839,6 +1845,8 @@ public class NetInterfaceManager {
|
|||||||
set.add(JGYUtils.MTKTag);
|
set.add(JGYUtils.MTKTag);
|
||||||
} else if (platform == JGYUtils.ZhanruiPlatform) {
|
} else if (platform == JGYUtils.ZhanruiPlatform) {
|
||||||
set.add(JGYUtils.ZhanruiTag);
|
set.add(JGYUtils.ZhanruiTag);
|
||||||
|
} else if (platform == JGYUtils.CubePlatform) {
|
||||||
|
set.add(JGYUtils.CubeTag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.aoleyun.sn.network.api.get;
|
package com.aoleyun.sn.network.api.get;
|
||||||
|
|
||||||
import com.aoleyun.sn.bean.BaseResponse;
|
import com.aoleyun.sn.bean.BaseResponse;
|
||||||
|
import com.aoleyun.sn.bean.ForceDownloadData;
|
||||||
import com.aoleyun.sn.network.UrlAddress;
|
import com.aoleyun.sn.network.UrlAddress;
|
||||||
|
|
||||||
import io.reactivex.rxjava3.core.Observable;
|
import io.reactivex.rxjava3.core.Observable;
|
||||||
@@ -10,7 +11,7 @@ import retrofit2.http.Query;
|
|||||||
|
|
||||||
public interface GetDesktopApi {
|
public interface GetDesktopApi {
|
||||||
@GET(UrlAddress.GET_DESKTOP)
|
@GET(UrlAddress.GET_DESKTOP)
|
||||||
Observable<BaseResponse> getDesktop(
|
Observable<BaseResponse<ForceDownloadData>> getDesktop(
|
||||||
@Query("sn") String sn
|
@Query("sn") String sn
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ public class NewAppReceiver extends BroadcastReceiver {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Log.e(TAG, "sendAppInfo: " + state + packageName);
|
Log.e(TAG, "sendAppInfo: " + state + packageName);
|
||||||
|
JGYUtils.getInstance().checkDefaultDesktop(packageName);
|
||||||
JGYUtils.getInstance().checkForceDownload();
|
JGYUtils.getInstance().checkForceDownload();
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
if (!PackageNames.APPSTORE.equals(packageName) || !PackageNames.DEVICE_INFO.equals(packageName)) {
|
if (!PackageNames.APPSTORE.equals(packageName) || !PackageNames.DEVICE_INFO.equals(packageName)) {
|
||||||
|
|||||||
@@ -242,7 +242,7 @@ public class MainSPresenter implements MainSContact.Presenter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getDefaultDesktop() {
|
public void getDefaultDesktop() {
|
||||||
if (JGYUtils.isOfficialVersion() || JGYUtils.getInstance().getDeviceIsLocked()) {
|
if (JGYUtils.isOfficialVersion() || !JGYUtils.getInstance().getDeviceIsLocked()) {
|
||||||
mView.getDefaultDesktopFinish();
|
mView.getDefaultDesktopFinish();
|
||||||
} else {
|
} else {
|
||||||
NetInterfaceManager.getInstance()
|
NetInterfaceManager.getInstance()
|
||||||
|
|||||||
@@ -738,10 +738,10 @@ public class ApkUtils {
|
|||||||
|
|
||||||
//桌面app
|
//桌面app
|
||||||
public static List<String> desktopAPP = new ArrayList<String>() {{
|
public static List<String> desktopAPP = new ArrayList<String>() {{
|
||||||
|
this.add("com.aoleyunos.dop1");
|
||||||
|
this.add("com.aoleyunos.dop2");
|
||||||
this.add("com.uiuios.jgy1");
|
this.add("com.uiuios.jgy1");
|
||||||
this.add("com.uiuios.jgy2");
|
this.add("com.uiuios.jgy2");
|
||||||
// this.add("com.aoleyunos.dop1");
|
|
||||||
// this.add("com.aoleyunos.dop2");
|
|
||||||
this.add("com.android.uiuios");
|
this.add("com.android.uiuios");
|
||||||
}};
|
}};
|
||||||
|
|
||||||
|
|||||||
69
app/src/main/java/com/aoleyun/sn/utils/FlowInfo.java
Normal file
69
app/src/main/java/com/aoleyun/sn/utils/FlowInfo.java
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
package com.aoleyun.sn.utils;
|
||||||
|
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.JsonParser;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
public class FlowInfo implements Serializable {
|
||||||
|
private static final long serialVersionUID = 4948079364302374385L;
|
||||||
|
|
||||||
|
String packname;
|
||||||
|
Drawable icon;
|
||||||
|
String appname;
|
||||||
|
long upKb;
|
||||||
|
long downKb;
|
||||||
|
long[] stat;
|
||||||
|
|
||||||
|
public String getPackname() {
|
||||||
|
return packname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPackname(String packname) {
|
||||||
|
this.packname = packname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Drawable getIcon() {
|
||||||
|
return icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIcon(Drawable icon) {
|
||||||
|
this.icon = icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAppname() {
|
||||||
|
return appname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAppname(String appname) {
|
||||||
|
this.appname = appname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getUpKb() {
|
||||||
|
return upKb;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUpKb(long upKb) {
|
||||||
|
this.upKb = upKb;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getDownKb() {
|
||||||
|
return downKb;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDownKb(long downKb) {
|
||||||
|
this.downKb = downKb;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long[] getStat() {
|
||||||
|
return stat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStat(long[] stat) {
|
||||||
|
this.stat = stat;
|
||||||
|
}
|
||||||
|
}
|
||||||
84
app/src/main/java/com/aoleyun/sn/utils/GetFlowUtil.java
Normal file
84
app/src/main/java/com/aoleyun/sn/utils/GetFlowUtil.java
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
package com.aoleyun.sn.utils;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.pm.PackageInfo;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.net.TrafficStats;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class GetFlowUtil {
|
||||||
|
public static FlowInfo getAppFlowInfo(String pakageName, Context context) {
|
||||||
|
//获取到配置权限信息的应用程序
|
||||||
|
PackageManager pms = context.getPackageManager();
|
||||||
|
List<PackageInfo> packinfos = pms
|
||||||
|
.getInstalledPackages(PackageManager.GET_PERMISSIONS);
|
||||||
|
//存放具有Internet权限信息的应用
|
||||||
|
FlowInfo flowInfo = new FlowInfo();
|
||||||
|
for (PackageInfo packinfo : packinfos) {
|
||||||
|
String appName = packinfo.packageName;
|
||||||
|
if (!TextUtils.isEmpty(appName)) {
|
||||||
|
if (appName.equals(pakageName)) {
|
||||||
|
//用于封装具有Internet权限的应用程序信息
|
||||||
|
//封装应用信息
|
||||||
|
flowInfo.setPackname(packinfo.packageName);
|
||||||
|
flowInfo.setIcon(packinfo.applicationInfo.loadIcon(pms));
|
||||||
|
flowInfo.setAppname(packinfo.applicationInfo.loadLabel(pms).toString());
|
||||||
|
//获取到应用的uid(user id)
|
||||||
|
int uid = packinfo.applicationInfo.uid;
|
||||||
|
//TrafficStats对象通过应用的uid来获取应用的下载、上传流量信息
|
||||||
|
//发送的 上传的流量byte
|
||||||
|
flowInfo.setUpKb(TrafficStats.getUidRxBytes(uid));
|
||||||
|
//下载的流量 byte
|
||||||
|
flowInfo.setDownKb(TrafficStats.getUidTxBytes(uid));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return flowInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static long[] getStat(int uid) {
|
||||||
|
String line, line2;
|
||||||
|
long[] stats = new long[2];
|
||||||
|
try {
|
||||||
|
File fileSnd = new File("/proc/uid_stat/" + uid + "/tcp_snd");
|
||||||
|
File fileRcv = new File("/proc/uid_stat/" + uid + "/tcp_rcv");
|
||||||
|
BufferedReader br1 = new BufferedReader(new FileReader(fileSnd));
|
||||||
|
BufferedReader br2 = new BufferedReader(new FileReader(fileRcv));
|
||||||
|
while ((line = br1.readLine()) != null && (line2 = br2.readLine()) != null) {
|
||||||
|
stats[0] = Long.parseLong(line);
|
||||||
|
stats[1] = Long.parseLong(line2);
|
||||||
|
}
|
||||||
|
br1.close();
|
||||||
|
br2.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
Log.e("getStat: ", e.getMessage());
|
||||||
|
}
|
||||||
|
return stats;
|
||||||
|
}
|
||||||
|
|
||||||
|
//将字节数转化为MB
|
||||||
|
public static String byteToMB(long size) {
|
||||||
|
long kb = 1024;
|
||||||
|
long mb = kb * 1024;
|
||||||
|
long gb = mb * 1024;
|
||||||
|
if (size >= gb) {
|
||||||
|
return String.format("%.1f GB", (float) size / gb);
|
||||||
|
} else if (size >= mb) {
|
||||||
|
float f = (float) size / mb;
|
||||||
|
return String.format(f > 100 ? "%.0f MB" : "%.1f MB", f);
|
||||||
|
} else if (size > kb) {
|
||||||
|
float f = (float) size / kb;
|
||||||
|
return String.format(f > 100 ? "%.0f KB" : "%.1f KB", f);
|
||||||
|
} else {
|
||||||
|
return String.format("%d B", size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -53,7 +53,6 @@ import com.google.zxing.common.BitMatrix;
|
|||||||
import com.google.zxing.qrcode.QRCodeWriter;
|
import com.google.zxing.qrcode.QRCodeWriter;
|
||||||
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
|
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
|
||||||
import com.aoleyun.sn.BuildConfig;
|
import com.aoleyun.sn.BuildConfig;
|
||||||
import com.aoleyun.sn.base.BaseApplication;
|
|
||||||
import com.aoleyun.sn.bean.AppListInfo;
|
import com.aoleyun.sn.bean.AppListInfo;
|
||||||
import com.aoleyun.sn.bean.Appground;
|
import com.aoleyun.sn.bean.Appground;
|
||||||
import com.aoleyun.sn.bean.BaseResponse;
|
import com.aoleyun.sn.bean.BaseResponse;
|
||||||
@@ -108,16 +107,21 @@ public class JGYUtils {
|
|||||||
private Context mContext;
|
private Context mContext;
|
||||||
private ContentResolver crv;
|
private ContentResolver crv;
|
||||||
|
|
||||||
public static int MTKPlatform = 1;
|
|
||||||
public static int ZhanruiPlatform = 2;
|
|
||||||
public static int UnknowPlatform = 0;
|
public static int UnknowPlatform = 0;
|
||||||
public static String MTKTag = "MTK";
|
public static int MTKPlatform = 1;
|
||||||
public static String ZhanruiTag = "展锐cube";
|
// TODO: 2022/4/23 标签替换未完成
|
||||||
|
public static int CubePlatform = 2;
|
||||||
|
public static int ZhanruiPlatform = 3;
|
||||||
|
|
||||||
|
|
||||||
public static String Other = "其他";
|
public static String Other = "其他";
|
||||||
|
public static String MTKTag = "MTK";
|
||||||
|
// TODO: 2022/4/23 标签替换未完成
|
||||||
|
public static String CubeTag = "展锐cube";
|
||||||
|
public static String ZhanruiTag = "展锐";
|
||||||
|
|
||||||
private CacheHelper cacheHelper;
|
private CacheHelper cacheHelper;
|
||||||
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
System.loadLibrary("jgy");
|
System.loadLibrary("jgy");
|
||||||
}
|
}
|
||||||
@@ -147,6 +151,74 @@ public class JGYUtils {
|
|||||||
|
|
||||||
public static native String getAuthorization();
|
public static native String getAuthorization();
|
||||||
|
|
||||||
|
public int checkSNPlatform(String sn) {
|
||||||
|
String secondChars = sn.substring(1, 2);
|
||||||
|
if ("N".equalsIgnoreCase(secondChars)) {//MTK平台
|
||||||
|
return MTKPlatform;
|
||||||
|
} else if ("R".equalsIgnoreCase(secondChars)) {//展锐平台
|
||||||
|
return ZhanruiPlatform;
|
||||||
|
} else {
|
||||||
|
Log.e(TAG, "checkSNPlatform: " + "sn: " + sn + "没有对应平台");
|
||||||
|
return UnknowPlatform;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int checkAppPlatform() {
|
||||||
|
String platform = BuildConfig.platform;
|
||||||
|
if ("MTK".equalsIgnoreCase(platform)) {
|
||||||
|
Log.i(TAG, "checkAppPlatform: " + "MTK平台");
|
||||||
|
return MTKPlatform;
|
||||||
|
} else if ("ZhanRui".equalsIgnoreCase(platform)) {
|
||||||
|
Log.i(TAG, "checkAppPlatform: " + "展锐平台");
|
||||||
|
return ZhanruiPlatform;
|
||||||
|
} else if ("ZhanRuiCube".equalsIgnoreCase(platform)) {
|
||||||
|
Log.i(TAG, "checkAppPlatform: " + "酷比平台");
|
||||||
|
return CubePlatform;
|
||||||
|
} else {
|
||||||
|
Log.i(TAG, "checkAppPlatform: " + "没有数据");
|
||||||
|
return UnknowPlatform;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSamePlatform(String platform) {
|
||||||
|
String AppPlatform = BuildConfig.platform;
|
||||||
|
if ("ZhanRui".equals(AppPlatform)) {
|
||||||
|
return ZhanruiTag.equals(platform);
|
||||||
|
} else {
|
||||||
|
return AppPlatform.equals(platform);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface GetAppPlatformCallback {
|
||||||
|
void AppPlatform(int platform);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void getAppPlatform(GetAppPlatformCallback getAppPlatformCallback) {
|
||||||
|
String platform = BuildConfig.platform;
|
||||||
|
if ("MTK".equalsIgnoreCase(platform)) {
|
||||||
|
getAppPlatformCallback.AppPlatform(MTKPlatform);
|
||||||
|
} else if ("ZhanRui".equalsIgnoreCase(platform)) {
|
||||||
|
getAppPlatformCallback.AppPlatform(ZhanruiPlatform);
|
||||||
|
} else if ("ZhanRuiCube".equalsIgnoreCase(platform)) {
|
||||||
|
getAppPlatformCallback.AppPlatform(CubePlatform);
|
||||||
|
} else {
|
||||||
|
getAppPlatformCallback.AppPlatform(UnknowPlatform);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAppPlatform() {
|
||||||
|
String platform = BuildConfig.platform;
|
||||||
|
if ("MTK".equalsIgnoreCase(platform)) {
|
||||||
|
return MTKTag;
|
||||||
|
} else if ("ZhanRui".equalsIgnoreCase(platform)) {
|
||||||
|
return ZhanruiTag;
|
||||||
|
} else if ("ZhanRuiCube".equalsIgnoreCase(platform)) {
|
||||||
|
return CubeTag;
|
||||||
|
} else {
|
||||||
|
return Other;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isOfficialVersion() {
|
public static boolean isOfficialVersion() {
|
||||||
String channelValue = JGYUtils.getInstance().getStringMetaData();
|
String channelValue = JGYUtils.getInstance().getStringMetaData();
|
||||||
return "official".equals(channelValue);
|
return "official".equals(channelValue);
|
||||||
@@ -1591,67 +1663,6 @@ public class JGYUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int checkSNPlatform(String sn) {
|
|
||||||
String secondChars = sn.substring(1, 2);
|
|
||||||
if ("N".equalsIgnoreCase(secondChars)) {//MTK平台
|
|
||||||
return MTKPlatform;
|
|
||||||
} else if ("R".equalsIgnoreCase(secondChars)) {//展锐平台
|
|
||||||
return ZhanruiPlatform;
|
|
||||||
} else {
|
|
||||||
Log.e(TAG, "checkSNPlatform: " + "sn: " + sn + "没有对应平台");
|
|
||||||
return UnknowPlatform;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int checkAppPlatform() {
|
|
||||||
String platform = BuildConfig.platform;
|
|
||||||
if ("MTK".equalsIgnoreCase(platform)) {
|
|
||||||
Log.i(TAG, "checkAppPlatform: " + "MTK平台");
|
|
||||||
return MTKPlatform;
|
|
||||||
} else if ("ZhanRui".equalsIgnoreCase(platform)) {
|
|
||||||
Log.i(TAG, "checkAppPlatform: " + "展锐平台");
|
|
||||||
return ZhanruiPlatform;
|
|
||||||
} else {
|
|
||||||
Log.i(TAG, "checkAppPlatform: " + "没有数据");
|
|
||||||
return UnknowPlatform;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSamePlatform(String platform) {
|
|
||||||
String AppPlatform = BuildConfig.platform;
|
|
||||||
if ("ZhanRui".equals(AppPlatform)) {
|
|
||||||
return ZhanruiTag.equals(platform);
|
|
||||||
} else {
|
|
||||||
return AppPlatform.equals(platform);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface GetAppPlatformCallback {
|
|
||||||
void AppPlatform(int platform);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void getAppPlatform(GetAppPlatformCallback getAppPlatformCallback) {
|
|
||||||
String platform = BuildConfig.platform;
|
|
||||||
if ("MTK".equalsIgnoreCase(platform)) {
|
|
||||||
getAppPlatformCallback.AppPlatform(MTKPlatform);
|
|
||||||
} else if ("ZhanRui".equalsIgnoreCase(platform)) {
|
|
||||||
getAppPlatformCallback.AppPlatform(ZhanruiPlatform);
|
|
||||||
} else {
|
|
||||||
getAppPlatformCallback.AppPlatform(UnknowPlatform);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAppPlatform() {
|
|
||||||
String platform = BuildConfig.platform;
|
|
||||||
if ("MTK".equalsIgnoreCase(platform)) {
|
|
||||||
return MTKTag;
|
|
||||||
} else if ("ZhanRui".equalsIgnoreCase(platform)) {
|
|
||||||
return ZhanruiTag;
|
|
||||||
} else {
|
|
||||||
return Other;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequiresApi(api = Build.VERSION_CODES.M)
|
@RequiresApi(api = Build.VERSION_CODES.M)
|
||||||
public void cleanBackgroundMemory() {
|
public void cleanBackgroundMemory() {
|
||||||
ActivityManager manager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
|
ActivityManager manager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
|
||||||
@@ -1885,8 +1896,16 @@ public class JGYUtils {
|
|||||||
private String Launcher3 = "com.android.launcher3";
|
private String Launcher3 = "com.android.launcher3";
|
||||||
private String Launcher3Class = "com.android.launcher3.Launcher";
|
private String Launcher3Class = "com.android.launcher3.Launcher";
|
||||||
|
|
||||||
|
public void checkDefaultDesktop(String pkg) {
|
||||||
|
String desktopPkg = (String) SPUtils.get(mContext, "default_launcher", "");
|
||||||
|
if (desktopPkg.equalsIgnoreCase(pkg)) {
|
||||||
|
setDefaultDesktop(pkg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//设置默认桌面
|
//设置默认桌面
|
||||||
public void setDefaultDesktop(String pkg) {
|
public void setDefaultDesktop(String pkg) {
|
||||||
|
Log.e(TAG, "setDefaultDesktop: " + pkg);
|
||||||
if (TextUtils.isEmpty(pkg)) {
|
if (TextUtils.isEmpty(pkg)) {
|
||||||
openLauncher3();
|
openLauncher3();
|
||||||
} else {
|
} else {
|
||||||
@@ -2069,4 +2088,47 @@ public class JGYUtils {
|
|||||||
wakeUpAppstore();
|
wakeUpAppstore();
|
||||||
wakeUpNotify();
|
wakeUpNotify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getModel() {
|
||||||
|
Log.e(TAG, "MANUFACTURER=" + Build.MANUFACTURER);
|
||||||
|
Log.e(TAG, "BRAND=" + Build.BRAND);
|
||||||
|
Log.e(TAG, "MODEL=" + Build.MODEL);
|
||||||
|
Log.e(TAG, "VERSION.RELEASE=" + Build.VERSION.RELEASE);
|
||||||
|
Log.e(TAG, "VERSION.SDK_INT=" + Build.VERSION.SDK_INT);
|
||||||
|
Log.e(TAG, "DEVICE=" + Build.DEVICE);
|
||||||
|
Log.e(TAG, "HOST=" + Build.HOST);
|
||||||
|
Log.e(TAG, "ID=" + Build.ID);
|
||||||
|
Log.e(TAG, "TIME=" + Build.TIME);
|
||||||
|
Log.e(TAG, "TYPE=" + Build.TYPE);
|
||||||
|
Log.e(TAG, "PRODUCT=" + Build.PRODUCT);
|
||||||
|
Log.e(TAG, "BOARD=" + Build.BOARD);
|
||||||
|
Log.e(TAG, "DISPLAY=" + Build.DISPLAY);
|
||||||
|
Log.e(TAG, "FINGERPRINT=" + Build.FINGERPRINT);
|
||||||
|
Log.e(TAG, "HARDWARE=" + Build.HARDWARE);
|
||||||
|
Log.e(TAG, "BOOTLOADER=" + Build.BOOTLOADER);
|
||||||
|
Log.e(TAG, "TAGS=" + Build.TAGS);
|
||||||
|
Log.e(TAG, "UNKNOWN=" + Build.UNKNOWN);
|
||||||
|
Log.e(TAG, "USER=" + Build.USER);
|
||||||
|
return Build.MODEL;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String MTK_HARDWARE = "mtk";
|
||||||
|
private static String UNISOC_HARDWARE = "ums";
|
||||||
|
|
||||||
|
private static String AIHUA_BRAND = "AS";
|
||||||
|
private static String CUBE_BRAND = "ALLDOCUBE";
|
||||||
|
|
||||||
|
public static String getHardware() {
|
||||||
|
return Build.HARDWARE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isAihuaDevice() {
|
||||||
|
return getHardware().startsWith(MTK_HARDWARE) && Build.BRAND.startsWith(AIHUA_BRAND);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isCubeDevice() {
|
||||||
|
return getHardware().startsWith(UNISOC_HARDWARE) && Build.BRAND.equalsIgnoreCase(CUBE_BRAND);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,8 +115,8 @@ public class SysSettingUtils {
|
|||||||
// ToastTool.show("qch_call_forbid::"+setting_call+"----setting_phones::"+setting_phones+"----"+qch_white_list_Array+"---"+qch_call_forbid);
|
// ToastTool.show("qch_call_forbid::"+setting_call+"----setting_phones::"+setting_phones+"----"+qch_white_list_Array+"---"+qch_call_forbid);
|
||||||
Log.e(TAG, "qch_white_list_Array:" + qch_white_list_Array + "---" + qch_white_list_Array);
|
Log.e(TAG, "qch_white_list_Array:" + qch_white_list_Array + "---" + qch_white_list_Array);
|
||||||
|
|
||||||
boolean qch_sdcard_forbid_on = Settings.System.putInt(context.getContentResolver(), "qch_sdcard_forbid_on", state);
|
boolean aole_sdcard_forbid_on = Settings.System.putInt(context.getContentResolver(), "aole_sdcard_forbid_on", state);
|
||||||
Log.e(TAG, "qch_sdcard_forbid_on:" + qch_sdcard_forbid_on);
|
Log.e(TAG, "aole_sdcard_forbid_on:" + aole_sdcard_forbid_on);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "setPhoneList: " + e.getMessage());
|
Log.e(TAG, "setPhoneList: " + e.getMessage());
|
||||||
}
|
}
|
||||||
@@ -146,8 +146,8 @@ public class SysSettingUtils {
|
|||||||
}
|
}
|
||||||
//存储卡
|
//存储卡
|
||||||
int setting_memory = changeNum(jsonObject.getInteger("setting_memory"));
|
int setting_memory = changeNum(jsonObject.getInteger("setting_memory"));
|
||||||
boolean qch_sdcard_forbid_on = Settings.System.putInt(context.getContentResolver(), "qch_sdcard_forbid_on", setting_memory);
|
boolean aole_sdcard_forbid_on = Settings.System.putInt(context.getContentResolver(), "aole_sdcard_forbid_on", setting_memory);
|
||||||
Log.e(TAG, "qch_sdcard_forbid_on:" + qch_sdcard_forbid_on);
|
Log.e(TAG, "aole_sdcard_forbid_on:" + aole_sdcard_forbid_on);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "setPhoneList: " + e.getMessage());
|
Log.e(TAG, "setPhoneList: " + e.getMessage());
|
||||||
}
|
}
|
||||||
@@ -180,26 +180,36 @@ public class SysSettingUtils {
|
|||||||
//Midi模式:usb_midi
|
//Midi模式:usb_midi
|
||||||
String setting_usb = jsonObject.getString("setting_usb");
|
String setting_usb = jsonObject.getString("setting_usb");
|
||||||
if (!BuildConfig.DEBUG) {
|
if (!BuildConfig.DEBUG) {
|
||||||
SuperPower mService = (SuperPower) context.getSystemService("mdm");
|
if (JGYUtils.isCubeDevice()) {
|
||||||
boolean aole_usb_choose = Settings.System.putString(context.getContentResolver(), "aole_usb_choose", setting_usb);
|
SuperPower mService = (SuperPower) context.getSystemService("mdm");
|
||||||
Log.e("setUSBstate", "aole_usb_choose---------" + aole_usb_choose);
|
switch (setting_usb) {
|
||||||
String usbStatus = "";
|
case "usb_charge":
|
||||||
switch (setting_usb) {
|
mService.setUSBDataDisabled(true);
|
||||||
case "usb_charge":
|
break;
|
||||||
mService.setUSBDataDisabled(true);
|
case "usb_mtp":
|
||||||
usbStatus = "aole_action_usb_usb_charge";
|
mService.setUSBDataDisabled(false);
|
||||||
break;
|
break;
|
||||||
case "usb_mtp":
|
default:
|
||||||
mService.setUSBDataDisabled(false);
|
}
|
||||||
usbStatus = "aole_action_usb_usb_mtp";
|
} else {
|
||||||
break;
|
boolean aole_usb_choose = Settings.System.putString(context.getContentResolver(), "aole_usb_choose", setting_usb);
|
||||||
case "usb_midi":
|
Log.e("setUSBstate", "aole_usb_choose---------" + aole_usb_choose);
|
||||||
usbStatus = "aole_action_usb_usb_midi";
|
String usbStatus = "aole_action_usb_usb_charge";
|
||||||
break;
|
switch (setting_usb) {
|
||||||
|
case "usb_charge":
|
||||||
|
usbStatus = "aole_action_usb_usb_charge";
|
||||||
|
break;
|
||||||
|
case "usb_mtp":
|
||||||
|
usbStatus = "aole_action_usb_usb_mtp";
|
||||||
|
break;
|
||||||
|
case "usb_midi":
|
||||||
|
usbStatus = "aole_action_usb_usb_midi";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
Intent usbIntent = new Intent(usbStatus).setPackage("com.android.settings");
|
||||||
|
context.sendBroadcast(usbIntent);
|
||||||
}
|
}
|
||||||
Intent usbIntent = new Intent(usbStatus).setPackage("com.android.settings");
|
|
||||||
context.sendBroadcast(usbIntent);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -597,21 +607,21 @@ public class SysSettingUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void setCanReset(Context context, int state) {
|
private static void setCanReset(Context context, int state) {
|
||||||
boolean qch_restore_forbid_on = Settings.System.putInt(context.getContentResolver(), "qch_restore_forbid_on", 0);
|
boolean aole_restore_forbid_on = Settings.System.putInt(context.getContentResolver(), "aole_restore_forbid_on", 0);
|
||||||
Log.e(TAG, "qch_restore_forbid_on:" + qch_restore_forbid_on);
|
Log.e(TAG, "aole_restore_forbid_on:" + aole_restore_forbid_on);
|
||||||
//默认打开
|
//默认打开
|
||||||
}
|
}
|
||||||
|
|
||||||
//qch_restore_forbid_on=1,禁止恢复出厂设置
|
//aole_restore_forbid_on=1,禁止恢复出厂设置
|
||||||
//qch_restore_forbid_on=0,允许恢复出厂设置
|
//aole_restore_forbid_on=0,允许恢复出厂设置
|
||||||
private static void setCanReset(Context context, JSONObject jsonObject) {
|
private static void setCanReset(Context context, JSONObject jsonObject) {
|
||||||
int mode = jsonObject.getInteger("qch_restore");
|
int mode = jsonObject.getInteger("qch_restore");
|
||||||
if (mode == 1) {
|
if (mode == 1) {
|
||||||
boolean qch_restore_forbid_on = Settings.System.putInt(context.getContentResolver(), "qch_restore_forbid_on", 0);
|
boolean aole_restore_forbid_on = Settings.System.putInt(context.getContentResolver(), "aole_restore_forbid_on", 0);
|
||||||
Log.e(TAG, "qch_restore_forbid_on:" + qch_restore_forbid_on);
|
Log.e(TAG, "aole_restore_forbid_on:" + aole_restore_forbid_on);
|
||||||
} else {
|
} else {
|
||||||
boolean qch_restore_forbid_on = Settings.System.putInt(context.getContentResolver(), "qch_restore_forbid_on", 1);
|
boolean aole_restore_forbid_on = Settings.System.putInt(context.getContentResolver(), "aole_restore_forbid_on", 1);
|
||||||
Log.e(TAG, "qch_restore_forbid_on:" + qch_restore_forbid_on);
|
Log.e(TAG, "aole_restore_forbid_on:" + aole_restore_forbid_on);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -172,11 +172,12 @@ public class Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String getAndroid10MAC(Context context) {
|
public static String getAndroid10MAC(Context context) {
|
||||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.N_MR1) {
|
// if (Build.VERSION.SDK_INT > Build.VERSION_CODES.N_MR1) {
|
||||||
return getMacAddress(context);
|
// return getMacAddress(context);
|
||||||
} else {
|
// } else {
|
||||||
return getAndroid7MAC();
|
// return getAndroid7MAC();
|
||||||
}
|
// }
|
||||||
|
return getAllMacAddress(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -284,6 +285,95 @@ public class Utils {
|
|||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取MAC地址
|
||||||
|
*
|
||||||
|
* @param context
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String getAllMacAddress(Context context) {
|
||||||
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
|
||||||
|
return getMacDefault(context);
|
||||||
|
} else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
|
||||||
|
return getMacAddressM();
|
||||||
|
} else {
|
||||||
|
return getMacFromHardware();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Android 6.0 之前(不包括6.0)
|
||||||
|
*
|
||||||
|
* @param context
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private static String getMacDefault(Context context) {
|
||||||
|
String mac = "未获取到设备Mac地址";
|
||||||
|
if (context == null) {
|
||||||
|
return mac;
|
||||||
|
}
|
||||||
|
WifiManager wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
|
||||||
|
WifiInfo info = null;
|
||||||
|
try {
|
||||||
|
info = wifi.getConnectionInfo();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
if (info == null) {
|
||||||
|
return mac;
|
||||||
|
}
|
||||||
|
mac = info.getMacAddress();
|
||||||
|
if (!TextUtils.isEmpty(mac)) {
|
||||||
|
mac = mac.toUpperCase(Locale.ENGLISH);
|
||||||
|
}
|
||||||
|
|
||||||
|
return mac;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Android 6.0(包括) - Android 7.0(不包括)
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private static String getMacAddressM() {
|
||||||
|
String mac = "未获取到设备Mac地址";
|
||||||
|
|
||||||
|
try {
|
||||||
|
mac = new BufferedReader(new FileReader("/sys/class/net/wlan0/address")).readLine();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return mac;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 遍历循环所有的网络接口,找到接口是 wlan0
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private static String getMacFromHardware() {
|
||||||
|
try {
|
||||||
|
List<NetworkInterface> all = Collections.list(NetworkInterface.getNetworkInterfaces());
|
||||||
|
|
||||||
|
for (NetworkInterface nif : all) {
|
||||||
|
if (!nif.getName().equalsIgnoreCase("wlan0")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
byte[] macBytes = nif.getHardwareAddress();
|
||||||
|
StringBuilder res1 = new StringBuilder();
|
||||||
|
for (byte b : macBytes) {
|
||||||
|
res1.append(String.format("%02X:", b));
|
||||||
|
}
|
||||||
|
if (res1 != null) {
|
||||||
|
res1.deleteCharAt(res1.length() - 1);
|
||||||
|
}
|
||||||
|
return res1.toString();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return "未获取到设备Mac地址";
|
||||||
|
}
|
||||||
|
|
||||||
// MD5 设备地址标识
|
// MD5 设备地址标识
|
||||||
public static String getMD5(Context context) {
|
public static String getMD5(Context context) {
|
||||||
@@ -1593,17 +1683,33 @@ public class Utils {
|
|||||||
return Formatter.formatFileSize(context, availableSize);
|
return Formatter.formatFileSize(context, availableSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取自定义版本号 或者版本号
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public static String getCustomVersion() {
|
public static String getCustomVersion() {
|
||||||
if (JGYUtils.getInstance().checkAppPlatform() == JGYUtils.ZhanruiPlatform) {
|
if (JGYUtils.getInstance().checkAppPlatform() == JGYUtils.ZhanruiPlatform) {
|
||||||
return Utils.getProperty("ro.build.display.id", "获取失败");
|
return Utils.getProperty("ro.build.display.id", "获取失败");
|
||||||
|
} else if (JGYUtils.getInstance().checkAppPlatform() == JGYUtils.CubePlatform) {
|
||||||
|
return Utils.getProperty("ro.build.display.id", "获取失败");
|
||||||
|
} else if (JGYUtils.getInstance().checkAppPlatform() == JGYUtils.MTKPlatform) {
|
||||||
|
return Utils.getProperty("ro.build.display.id", "获取失败");
|
||||||
} else {
|
} else {
|
||||||
return Utils.getProperty("ro.custom.build.version", "获取失败");
|
return Utils.getProperty("ro.custom.build.version", "获取失败");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取系统版本号
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public static String getRomVersion() {
|
public static String getRomVersion() {
|
||||||
if (JGYUtils.getInstance().checkAppPlatform() == JGYUtils.ZhanruiPlatform) {
|
if (JGYUtils.getInstance().checkAppPlatform() == JGYUtils.ZhanruiPlatform) {
|
||||||
return getProperty("ro.build.id", "获取失败");
|
return getProperty("ro.build.id", "获取失败");
|
||||||
|
}else if (JGYUtils.getInstance().checkAppPlatform() == JGYUtils.CubePlatform) {
|
||||||
|
return Utils.getProperty("ro.build.id", "获取失败");
|
||||||
|
} else if (JGYUtils.getInstance().checkAppPlatform() == JGYUtils.MTKPlatform) {
|
||||||
|
return Utils.getProperty("ro.build.id", "获取失败");
|
||||||
} else {
|
} else {
|
||||||
return getProperty("ro.build.display.id", "获取失败");
|
return getProperty("ro.build.display.id", "获取失败");
|
||||||
}
|
}
|
||||||
@@ -1719,6 +1825,69 @@ public class Utils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前充电电流 mA
|
||||||
|
* <p>
|
||||||
|
* adb shell "cat /sys/class/power_supply/battery/BatteryAverageCurrent"
|
||||||
|
*/
|
||||||
|
public static int getCurrentChargingCurrent() {
|
||||||
|
int result = 0;
|
||||||
|
BufferedReader br = null;
|
||||||
|
try {
|
||||||
|
String line;
|
||||||
|
br = new BufferedReader(new FileReader("/sys/class/power_supply/battery/BatteryAverageCurrent"));
|
||||||
|
if ((line = br.readLine()) != null) {
|
||||||
|
result = Integer.parseInt(line);
|
||||||
|
}
|
||||||
|
|
||||||
|
br.close();
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
if (br != null) {
|
||||||
|
try {
|
||||||
|
br.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前充电电压 uV
|
||||||
|
* <p>
|
||||||
|
* adb shell "cat /sys/class/power_supply/battery/batt_vol"
|
||||||
|
*/
|
||||||
|
public static int getCurrentChargingVoltage() {
|
||||||
|
int result = 0;
|
||||||
|
BufferedReader br = null;
|
||||||
|
try {
|
||||||
|
String line;
|
||||||
|
br = new BufferedReader(new FileReader("/sys/class/power_supply/battery/batt_vol"));
|
||||||
|
if ((line = br.readLine()) != null) {
|
||||||
|
result = Integer.parseInt(line);
|
||||||
|
}
|
||||||
|
|
||||||
|
br.close();
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
if (br != null) {
|
||||||
|
try {
|
||||||
|
br.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
17
app/src/main/res/layout/activity_main1.xml
Normal file
17
app/src/main/res/layout/activity_main1.xml
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||||
|
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||||
|
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||||
|
android:paddingTop="@dimen/activity_vertical_margin"
|
||||||
|
android:orientation="vertical"
|
||||||
|
tools:context="com.aoleyun.sn.activity.MainActivity1">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_show"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
</LinearLayout>
|
||||||
@@ -4,6 +4,9 @@
|
|||||||
<!-- Your custom size defind by references, can be writted in anywhere, any module, any values/*.xml, for example: -->
|
<!-- Your custom size defind by references, can be writted in anywhere, any module, any values/*.xml, for example: -->
|
||||||
<dimen name="common_margin">@dimen/dp_15</dimen>
|
<dimen name="common_margin">@dimen/dp_15</dimen>
|
||||||
|
|
||||||
|
<dimen name="activity_horizontal_margin">16dp</dimen>
|
||||||
|
<dimen name="activity_vertical_margin">16dp</dimen>
|
||||||
|
|
||||||
<!-- dp and sp values, must be defind in this file! -->
|
<!-- dp and sp values, must be defind in this file! -->
|
||||||
<!-- view size,you can add if there is no one -->
|
<!-- view size,you can add if there is no one -->
|
||||||
<dimen name="dp_m_60">-60dp</dimen>
|
<dimen name="dp_m_60">-60dp</dimen>
|
||||||
|
|||||||
@@ -76,4 +76,41 @@ www.jiaoguanyi.com\n
|
|||||||
<item>http://shouji.360tpcdn.com/170917/af50b75c9980cd6cba079052f4aa4e63/com.jingdong.app.mall_52563.apk</item>
|
<item>http://shouji.360tpcdn.com/170917/af50b75c9980cd6cba079052f4aa4e63/com.jingdong.app.mall_52563.apk</item>
|
||||||
<item>http://shouji.360tpcdn.com/170919/1a4d1a0ca1255ae315c36394dd2b0865/com.mt.mtxx.mtxx_6860.apk</item>
|
<item>http://shouji.360tpcdn.com/170919/1a4d1a0ca1255ae315c36394dd2b0865/com.mt.mtxx.mtxx_6860.apk</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<string name="battery_status_titls">电池状态: </string>
|
||||||
|
<string name="battery_status_unknown">未知</string>
|
||||||
|
<string name="battery_status_charging">充电中</string>
|
||||||
|
<string name="battery_status_discharging">放电中</string>
|
||||||
|
<string name="battery_status_not_charging">未充电</string>
|
||||||
|
<string name="battery_status_full">电池满</string>
|
||||||
|
|
||||||
|
<string name="battery_health_titls">电池健康情况: </string>
|
||||||
|
<string name="battery_health_unknow">未知</string>
|
||||||
|
<string name="battery_health_good">良好</string>
|
||||||
|
<string name="battery_health_overheat">过热</string>
|
||||||
|
<string name="battery_health_dead">没电</string>
|
||||||
|
<string name="battery_health_unspecified_failure">未知错误</string>
|
||||||
|
<string name="battery_health_over_voltage">过电压</string>
|
||||||
|
<string name="battery_health_cold">温度过低</string>
|
||||||
|
|
||||||
|
<string name="battery_plugged_titls">充电类型: </string>
|
||||||
|
<string name="battery_plugged_ac">充电器</string>
|
||||||
|
<string name="battery_plugged_usb">USB</string>
|
||||||
|
<string name="battery_plugged_any">其他</string>
|
||||||
|
<string name="battery_plugged_wireless">无线充电</string>
|
||||||
|
|
||||||
|
<string name="battery_current_level">当前电量: </string>
|
||||||
|
<string name="battery_max_level">电量最大值: </string>
|
||||||
|
<string name="battery_current_temperature">当前电池温度: </string>
|
||||||
|
<string name="battery_current_volt">当前电池电压: </string>
|
||||||
|
<string name="battery_technology_describing">电池技术描述: </string>
|
||||||
|
|
||||||
|
<string name="battery_current_charging_current">当前充电电流: </string>
|
||||||
|
<string name="battery_max_charging_current">最大充电电流: </string>
|
||||||
|
|
||||||
|
<string name="battery_current_charging_voltage">当前充电电压: </string>
|
||||||
|
<string name="battery_max_charging_voltage">最大充电电压: </string>
|
||||||
|
<string name="adb_shell_help">发送命令: adb shell dumpsys battery \n</string>
|
||||||
</resources>
|
</resources>
|
||||||
Reference in New Issue
Block a user