version:2.1 MTK
fix:优化获取设备类型逻辑,优化获取设备版本号 update:打包更新
This commit is contained in:
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.service.LogcatService;
|
||||
import com.aoleyun.sn.utils.ApkUtils;
|
||||
import com.aoleyun.sn.utils.FlowInfo;
|
||||
import com.aoleyun.sn.utils.ForegroundAppUtil;
|
||||
import com.aoleyun.sn.utils.GetFlowUtil;
|
||||
import com.aoleyun.sn.utils.JGYUtils;
|
||||
import com.aoleyun.sn.utils.NetworkUtils;
|
||||
import com.aoleyun.sn.utils.SPUtils;
|
||||
@@ -89,15 +91,19 @@ public class SplashActivity extends AppCompatActivity {
|
||||
|
||||
private void initView() {
|
||||
if (BuildConfig.DEBUG) {
|
||||
// Log.e(TAG, "initView: " + Utils.getIMEI(this));
|
||||
// Log.e(TAG, "initView: " + Utils.getIMEI(this, 0));
|
||||
// Log.e(TAG, "initView: " + Utils.getIMEI(this, 1));
|
||||
JGYUtils.getModel();
|
||||
Log.e(TAG, "getOperators: " + NetworkUtils.getOperators(this));
|
||||
Log.e(TAG, "PublicIP: " + MMKV.defaultMMKV().decodeString(NetInterfaceManager.PublicIP, ""));
|
||||
NetInterfaceManager.GetWhois();
|
||||
Log.e(TAG, "initView: " + NetworkUtils.getPhoneNumber(this));
|
||||
// String jsonString = ApkUtils.getRunningAppInfo(this);
|
||||
// Log.e(TAG, "initView: " + jsonString);
|
||||
FlowInfo flowInfo1 = GetFlowUtil.getAppFlowInfo(BuildConfig.APPLICATION_ID, this);
|
||||
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);
|
||||
// JGYUtils.getInstance().cleanBackgroundMemory();
|
||||
// NetInterfaceManager.getInstance().uploadLogFile();
|
||||
@@ -155,7 +161,8 @@ public class SplashActivity extends AppCompatActivity {
|
||||
|
||||
Log.i(TAG, "debugTest: " + Utils.getAndroid10MAC(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: " + Utils.getAPPVersionName(PackageNames.APPSTORE, this));
|
||||
Log.i(TAG, "debugTest: " + Utils.getAndroid7MAC());
|
||||
|
||||
@@ -28,7 +28,7 @@ import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||
import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
||||
|
||||
/**
|
||||
* MainActivity 的 Presenter
|
||||
* MainActivity1 的 Presenter
|
||||
*
|
||||
* @author jgy
|
||||
*/
|
||||
@@ -83,7 +83,7 @@ public class MainAPresenter implements MainAContact.Presenter {
|
||||
*/
|
||||
@Override
|
||||
public void getStudesInfo(boolean refresh) {
|
||||
NetInterfaceManager.getInstance().getStudesInfo(false, getLifecycle(), new NetInterfaceManager.StudesInfoListener() {
|
||||
NetInterfaceManager.getInstance().getStudesInfo(true, getLifecycle(), new NetInterfaceManager.StudesInfoListener() {
|
||||
@Override
|
||||
public void setStudentsInfo(StudentsInfo 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;
|
||||
|
||||
public class ForceDownloadData implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 2965901905485481437L;
|
||||
|
||||
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 aole_action_usb_usb_charge = "aole_action_usb_usb_charge";
|
||||
}
|
||||
|
||||
@@ -91,18 +91,18 @@ package com.aoleyun.sn.jpush;
|
||||
// return sb.toString();
|
||||
// }
|
||||
//
|
||||
// //send msg to MainActivity
|
||||
// //send msg to MainActivity1
|
||||
// private void processCustomMessage(Context context, Bundle bundle) {
|
||||
// if (MainActivity.isForeground) {
|
||||
// if (MainActivity1.isForeground) {
|
||||
// String message = bundle.getString(JPushInterface.EXTRA_MESSAGE);
|
||||
// String extras = bundle.getString(JPushInterface.EXTRA_EXTRA);
|
||||
// Intent msgIntent = new Intent(MainActivity.MESSAGE_RECEIVED_ACTION);
|
||||
// msgIntent.putExtra(MainActivity.KEY_MESSAGE, message);
|
||||
// Intent msgIntent = new Intent(MainActivity1.MESSAGE_RECEIVED_ACTION);
|
||||
// msgIntent.putExtra(MainActivity1.KEY_MESSAGE, message);
|
||||
// if (!ExampleUtil.isEmpty(extras)) {
|
||||
// try {
|
||||
// JSONObject extraJson = new JSONObject(extras);
|
||||
// if (extraJson.length() > 0) {
|
||||
// msgIntent.putExtra(MainActivity.KEY_EXTRAS, extras);
|
||||
// msgIntent.putExtra(MainActivity1.KEY_EXTRAS, extras);
|
||||
// }
|
||||
// } catch (JSONException e) {
|
||||
//
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
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 mSetting;
|
||||
@@ -71,7 +71,7 @@ package com.aoleyun.sn.jpush.invalid;
|
||||
// init();
|
||||
// break;
|
||||
// case R.id.setting:
|
||||
// Intent intent = new Intent(MainActivity.this, PushSetActivity.class);
|
||||
// Intent intent = new Intent(MainActivity1.this, PushSetActivity.class);
|
||||
// startActivity(intent);
|
||||
// break;
|
||||
// case R.id.stopPush:
|
||||
|
||||
@@ -424,7 +424,7 @@ public class NetInterfaceManager {
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
public Observable<BaseResponse> getDesktopObservable() {
|
||||
public Observable<BaseResponse<ForceDownloadData>> getDesktopObservable() {
|
||||
return mRetrofit.create(GetDesktopApi.class)
|
||||
.getDesktop(Utils.getSerial(mContext))
|
||||
.subscribeOn(Schedulers.io())
|
||||
@@ -893,24 +893,27 @@ public class NetInterfaceManager {
|
||||
public void getDefaultDesktop(BehaviorSubject<ActivityEvent> lifecycle, onCompleteCallback callback) {
|
||||
getDesktopObservable()
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
.subscribe(new Observer<BaseResponse<ForceDownloadData>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getDefaultDesktop", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse baseResponse) {
|
||||
public void onNext(@NonNull BaseResponse<ForceDownloadData> baseResponse) {
|
||||
Log.e("getDefaultDesktop", "onNext: " + baseResponse);
|
||||
if (baseResponse.code == OK) {
|
||||
String jsonString = GsonUtils.toJsonString(baseResponse.data);
|
||||
ForceDownloadData desktopInfo = baseResponse.data;
|
||||
String jsonString = GsonUtils.toJsonString(desktopInfo);
|
||||
JSONObject data = JSON.parseObject(jsonString);
|
||||
cacheHelper.put(UrlAddress.GET_DESKTOP, jsonString);
|
||||
JGYUtils.getInstance().installDesktop(data);
|
||||
SPUtils.put(mContext, "default_launcher", desktopInfo.getApp_package());
|
||||
} else {
|
||||
Log.e("getDefaultDesktop", "onNext: " + "删除定制桌面");
|
||||
cacheHelper.put(UrlAddress.GET_DESKTOP, "");
|
||||
String whiteList = Settings.System.getString(mContext.getContentResolver(), JGYActions.ACTION_JGY_SHORTCUTLIST);
|
||||
Log.e("getDefaultDesktop", "onNext: " + whiteList);
|
||||
if (!TextUtils.isEmpty(whiteList)) {
|
||||
if (!whiteList.contains(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));
|
||||
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);
|
||||
} else if (platform == JGYUtils.ZhanruiPlatform) {
|
||||
set.add(JGYUtils.ZhanruiTag);
|
||||
} else if (platform == JGYUtils.CubePlatform) {
|
||||
set.add(JGYUtils.CubeTag);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.aoleyun.sn.network.api.get;
|
||||
|
||||
import com.aoleyun.sn.bean.BaseResponse;
|
||||
import com.aoleyun.sn.bean.ForceDownloadData;
|
||||
import com.aoleyun.sn.network.UrlAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
@@ -10,7 +11,7 @@ import retrofit2.http.Query;
|
||||
|
||||
public interface GetDesktopApi {
|
||||
@GET(UrlAddress.GET_DESKTOP)
|
||||
Observable<BaseResponse> getDesktop(
|
||||
Observable<BaseResponse<ForceDownloadData>> getDesktop(
|
||||
@Query("sn") String sn
|
||||
);
|
||||
}
|
||||
|
||||
@@ -63,6 +63,7 @@ public class NewAppReceiver extends BroadcastReceiver {
|
||||
break;
|
||||
}
|
||||
Log.e(TAG, "sendAppInfo: " + state + packageName);
|
||||
JGYUtils.getInstance().checkDefaultDesktop(packageName);
|
||||
JGYUtils.getInstance().checkForceDownload();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
if (!PackageNames.APPSTORE.equals(packageName) || !PackageNames.DEVICE_INFO.equals(packageName)) {
|
||||
|
||||
@@ -242,7 +242,7 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
|
||||
@Override
|
||||
public void getDefaultDesktop() {
|
||||
if (JGYUtils.isOfficialVersion() || JGYUtils.getInstance().getDeviceIsLocked()) {
|
||||
if (JGYUtils.isOfficialVersion() || !JGYUtils.getInstance().getDeviceIsLocked()) {
|
||||
mView.getDefaultDesktopFinish();
|
||||
} else {
|
||||
NetInterfaceManager.getInstance()
|
||||
|
||||
@@ -738,10 +738,10 @@ public class ApkUtils {
|
||||
|
||||
//桌面app
|
||||
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.jgy2");
|
||||
// this.add("com.aoleyunos.dop1");
|
||||
// this.add("com.aoleyunos.dop2");
|
||||
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.decoder.ErrorCorrectionLevel;
|
||||
import com.aoleyun.sn.BuildConfig;
|
||||
import com.aoleyun.sn.base.BaseApplication;
|
||||
import com.aoleyun.sn.bean.AppListInfo;
|
||||
import com.aoleyun.sn.bean.Appground;
|
||||
import com.aoleyun.sn.bean.BaseResponse;
|
||||
@@ -108,16 +107,21 @@ public class JGYUtils {
|
||||
private Context mContext;
|
||||
private ContentResolver crv;
|
||||
|
||||
public static int MTKPlatform = 1;
|
||||
public static int ZhanruiPlatform = 2;
|
||||
public static int UnknowPlatform = 0;
|
||||
public static String MTKTag = "MTK";
|
||||
public static String ZhanruiTag = "展锐cube";
|
||||
public static int MTKPlatform = 1;
|
||||
// TODO: 2022/4/23 标签替换未完成
|
||||
public static int CubePlatform = 2;
|
||||
public static int ZhanruiPlatform = 3;
|
||||
|
||||
|
||||
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;
|
||||
|
||||
|
||||
static {
|
||||
System.loadLibrary("jgy");
|
||||
}
|
||||
@@ -147,6 +151,74 @@ public class JGYUtils {
|
||||
|
||||
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() {
|
||||
String channelValue = JGYUtils.getInstance().getStringMetaData();
|
||||
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)
|
||||
public void cleanBackgroundMemory() {
|
||||
ActivityManager manager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
@@ -1885,8 +1896,16 @@ public class JGYUtils {
|
||||
private String Launcher3 = "com.android.launcher3";
|
||||
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) {
|
||||
Log.e(TAG, "setDefaultDesktop: " + pkg);
|
||||
if (TextUtils.isEmpty(pkg)) {
|
||||
openLauncher3();
|
||||
} else {
|
||||
@@ -2069,4 +2088,47 @@ public class JGYUtils {
|
||||
wakeUpAppstore();
|
||||
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);
|
||||
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);
|
||||
Log.e(TAG, "qch_sdcard_forbid_on:" + qch_sdcard_forbid_on);
|
||||
boolean aole_sdcard_forbid_on = Settings.System.putInt(context.getContentResolver(), "aole_sdcard_forbid_on", state);
|
||||
Log.e(TAG, "aole_sdcard_forbid_on:" + aole_sdcard_forbid_on);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "setPhoneList: " + e.getMessage());
|
||||
}
|
||||
@@ -146,8 +146,8 @@ public class SysSettingUtils {
|
||||
}
|
||||
//存储卡
|
||||
int setting_memory = changeNum(jsonObject.getInteger("setting_memory"));
|
||||
boolean qch_sdcard_forbid_on = Settings.System.putInt(context.getContentResolver(), "qch_sdcard_forbid_on", setting_memory);
|
||||
Log.e(TAG, "qch_sdcard_forbid_on:" + qch_sdcard_forbid_on);
|
||||
boolean aole_sdcard_forbid_on = Settings.System.putInt(context.getContentResolver(), "aole_sdcard_forbid_on", setting_memory);
|
||||
Log.e(TAG, "aole_sdcard_forbid_on:" + aole_sdcard_forbid_on);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "setPhoneList: " + e.getMessage());
|
||||
}
|
||||
@@ -180,26 +180,36 @@ public class SysSettingUtils {
|
||||
//Midi模式:usb_midi
|
||||
String setting_usb = jsonObject.getString("setting_usb");
|
||||
if (!BuildConfig.DEBUG) {
|
||||
SuperPower mService = (SuperPower) context.getSystemService("mdm");
|
||||
boolean aole_usb_choose = Settings.System.putString(context.getContentResolver(), "aole_usb_choose", setting_usb);
|
||||
Log.e("setUSBstate", "aole_usb_choose---------" + aole_usb_choose);
|
||||
String usbStatus = "";
|
||||
switch (setting_usb) {
|
||||
case "usb_charge":
|
||||
mService.setUSBDataDisabled(true);
|
||||
usbStatus = "aole_action_usb_usb_charge";
|
||||
break;
|
||||
case "usb_mtp":
|
||||
mService.setUSBDataDisabled(false);
|
||||
usbStatus = "aole_action_usb_usb_mtp";
|
||||
break;
|
||||
case "usb_midi":
|
||||
usbStatus = "aole_action_usb_usb_midi";
|
||||
break;
|
||||
|
||||
if (JGYUtils.isCubeDevice()) {
|
||||
SuperPower mService = (SuperPower) context.getSystemService("mdm");
|
||||
switch (setting_usb) {
|
||||
case "usb_charge":
|
||||
mService.setUSBDataDisabled(true);
|
||||
break;
|
||||
case "usb_mtp":
|
||||
mService.setUSBDataDisabled(false);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
} else {
|
||||
boolean aole_usb_choose = Settings.System.putString(context.getContentResolver(), "aole_usb_choose", setting_usb);
|
||||
Log.e("setUSBstate", "aole_usb_choose---------" + aole_usb_choose);
|
||||
String usbStatus = "aole_action_usb_usb_charge";
|
||||
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) {
|
||||
boolean qch_restore_forbid_on = Settings.System.putInt(context.getContentResolver(), "qch_restore_forbid_on", 0);
|
||||
Log.e(TAG, "qch_restore_forbid_on:" + qch_restore_forbid_on);
|
||||
boolean aole_restore_forbid_on = Settings.System.putInt(context.getContentResolver(), "aole_restore_forbid_on", 0);
|
||||
Log.e(TAG, "aole_restore_forbid_on:" + aole_restore_forbid_on);
|
||||
//默认打开
|
||||
}
|
||||
|
||||
//qch_restore_forbid_on=1,禁止恢复出厂设置
|
||||
//qch_restore_forbid_on=0,允许恢复出厂设置
|
||||
//aole_restore_forbid_on=1,禁止恢复出厂设置
|
||||
//aole_restore_forbid_on=0,允许恢复出厂设置
|
||||
private static void setCanReset(Context context, JSONObject jsonObject) {
|
||||
int mode = jsonObject.getInteger("qch_restore");
|
||||
if (mode == 1) {
|
||||
boolean qch_restore_forbid_on = Settings.System.putInt(context.getContentResolver(), "qch_restore_forbid_on", 0);
|
||||
Log.e(TAG, "qch_restore_forbid_on:" + qch_restore_forbid_on);
|
||||
boolean aole_restore_forbid_on = Settings.System.putInt(context.getContentResolver(), "aole_restore_forbid_on", 0);
|
||||
Log.e(TAG, "aole_restore_forbid_on:" + aole_restore_forbid_on);
|
||||
} else {
|
||||
boolean qch_restore_forbid_on = Settings.System.putInt(context.getContentResolver(), "qch_restore_forbid_on", 1);
|
||||
Log.e(TAG, "qch_restore_forbid_on:" + qch_restore_forbid_on);
|
||||
boolean aole_restore_forbid_on = Settings.System.putInt(context.getContentResolver(), "aole_restore_forbid_on", 1);
|
||||
Log.e(TAG, "aole_restore_forbid_on:" + aole_restore_forbid_on);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -172,11 +172,12 @@ public class Utils {
|
||||
}
|
||||
|
||||
public static String getAndroid10MAC(Context context) {
|
||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.N_MR1) {
|
||||
return getMacAddress(context);
|
||||
} else {
|
||||
return getAndroid7MAC();
|
||||
}
|
||||
// if (Build.VERSION.SDK_INT > Build.VERSION_CODES.N_MR1) {
|
||||
// return getMacAddress(context);
|
||||
// } else {
|
||||
// return getAndroid7MAC();
|
||||
// }
|
||||
return getAllMacAddress(context);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -284,6 +285,95 @@ public class Utils {
|
||||
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 设备地址标识
|
||||
public static String getMD5(Context context) {
|
||||
@@ -1593,17 +1683,33 @@ public class Utils {
|
||||
return Formatter.formatFileSize(context, availableSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取自定义版本号 或者版本号
|
||||
* @return
|
||||
*/
|
||||
public static String getCustomVersion() {
|
||||
if (JGYUtils.getInstance().checkAppPlatform() == JGYUtils.ZhanruiPlatform) {
|
||||
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 {
|
||||
return Utils.getProperty("ro.custom.build.version", "获取失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取系统版本号
|
||||
* @return
|
||||
*/
|
||||
public static String getRomVersion() {
|
||||
if (JGYUtils.getInstance().checkAppPlatform() == JGYUtils.ZhanruiPlatform) {
|
||||
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 {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user