1.1.0 优化推送,修改主页
This commit is contained in:
@@ -16,8 +16,8 @@ android {
|
||||
applicationId "com.uiuipad.find"
|
||||
minSdkVersion 24
|
||||
targetSdkVersion 29
|
||||
versionCode 10
|
||||
versionName "1.0.9"
|
||||
versionCode 11
|
||||
versionName "1.1.0"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
|
||||
@@ -16,5 +16,7 @@ public class MainAContact {
|
||||
public interface MainView extends BaseView {
|
||||
void setQrCode(Bitmap bitmap);
|
||||
void setSnInfo(SnInfo snInfo);
|
||||
void setSnInfoNoBind();
|
||||
void setSnInfoNotFound();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,11 +73,14 @@ public class MainAPresenter implements MainAContact.Presenter {
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<SnInfo> snInfoBaseResponse) {
|
||||
Log.e("getSnInfo", "onNext: " + snInfoBaseResponse);
|
||||
if (snInfoBaseResponse.code == 200) {
|
||||
int code = snInfoBaseResponse.code;
|
||||
if (code == 200) {
|
||||
SnInfo snInfo = snInfoBaseResponse.data;
|
||||
mView.setSnInfo(snInfo);
|
||||
}else {
|
||||
mView.setSnInfo(null);
|
||||
} else if (code == 402) {
|
||||
mView.setSnInfoNotFound();
|
||||
} else if (code == 403) {
|
||||
mView.setSnInfoNoBind();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ import android.os.IBinder;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
@@ -62,6 +61,15 @@ public class MainActivity extends BaseActivity implements MainAContact.MainView,
|
||||
ConstraintLayout cl_ota;
|
||||
@BindView(R.id.cl_app)
|
||||
ConstraintLayout cl_app;
|
||||
@BindView(R.id.iv_activation)
|
||||
ImageView iv_activation;
|
||||
@BindView(R.id.tv_bindtime)
|
||||
TextView tv_bindtime;
|
||||
@BindView(R.id.iv_ota)
|
||||
ImageView iv_ota;
|
||||
@BindView(R.id.iv_app)
|
||||
ImageView iv_app;
|
||||
|
||||
|
||||
private MainAPresenter mPresenter;
|
||||
|
||||
@@ -112,7 +120,8 @@ public class MainActivity extends BaseActivity implements MainAContact.MainView,
|
||||
tv_serial.setText(Utils.getSerial());
|
||||
tv_system_version.setText(Utils.getCustomVersion());
|
||||
|
||||
RxView.clicks(cl_app)
|
||||
|
||||
RxView.clicks(iv_app)
|
||||
.throttleFirst(60, TimeUnit.SECONDS) //两秒钟之内只取一个点击事件,防抖操作
|
||||
.subscribe(new Consumer<Object>() {
|
||||
/**
|
||||
@@ -138,7 +147,7 @@ public class MainActivity extends BaseActivity implements MainAContact.MainView,
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
cl_ota.setOnClickListener(new View.OnClickListener() {
|
||||
iv_ota.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
ApkUtils.openPackage(MainActivity.this, "com.yhk.qeota", "com.yhk.qeota.activity.ScrollingActivity");
|
||||
@@ -187,16 +196,32 @@ public class MainActivity extends BaseActivity implements MainAContact.MainView,
|
||||
public void setSnInfo(SnInfo snInfo) {
|
||||
if (snInfo == null) {
|
||||
tv_phone.setText("未绑定");
|
||||
iv_activation.setImageDrawable(getDrawable(R.drawable.icon_inactivated));
|
||||
} else {
|
||||
String phone = snInfo.getMobile();
|
||||
if (StringUtils.isEmpty(phone)) {
|
||||
tv_phone.setText("未绑定");
|
||||
tv_bind_time.setText(getString(R.string.login_bind));
|
||||
iv_activation.setImageDrawable(getDrawable(R.drawable.icon_inactivated));
|
||||
} else {
|
||||
tv_phone.setText(phone);
|
||||
iv_activation.setImageDrawable(getDrawable(R.drawable.icon_activated));
|
||||
long bindTime = snInfo.getBind_time();
|
||||
tv_bind_time.setText(String.format(getString(R.string.binding_time), TimeUtils.transferSecondToDate(bindTime)));
|
||||
tv_bindtime.setText(String.format(getString(R.string.activation_time), TimeUtils.transferSecondToDate(bindTime)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSnInfoNoBind() {
|
||||
tv_phone.setText("未绑定");
|
||||
iv_activation.setImageDrawable(getDrawable(R.drawable.icon_activated));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSnInfoNotFound() {
|
||||
tv_phone.setText("未激活");
|
||||
iv_activation.setImageDrawable(getDrawable(R.drawable.icon_inactivated));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -268,16 +268,16 @@ public class NetInterfaceManager {
|
||||
}
|
||||
|
||||
public Observable<BaseResponse> getUpdateSnInfoControl() {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("wifi_name", Utils.getWifiSsid(mContext));
|
||||
params.put("wifi_signal", Utils.getWifiRssi(mContext));
|
||||
params.put("battery", String.valueOf(Utils.getBattery(mContext)));
|
||||
params.put("bluetooth", Utils.getBluetoothList());
|
||||
params.put("memory", Formatter.formatFileSize(mContext, Utils.getUsedMemory(mContext)));
|
||||
params.put("storage", Utils.getDataTotalSize(mContext));
|
||||
params.put("memory_use", Formatter.formatFileSize(mContext, Utils.getUsedMemory(mContext)));
|
||||
params.put("storage_use", Utils.getUsedSize(mContext));
|
||||
params.put("sn", Utils.getSerial());
|
||||
Map<String, RequestBody> params = new HashMap<>();
|
||||
params.put("wifi_name", NetInterfaceManager.convertToRequestBody(Utils.getWifiSsid(mContext)));
|
||||
params.put("wifi_signal", NetInterfaceManager.convertToRequestBody(Utils.getWifiRssi(mContext)));
|
||||
params.put("battery", NetInterfaceManager.convertToRequestBody(Utils.getBattery(mContext)));
|
||||
params.put("bluetooth", NetInterfaceManager.convertToRequestBody(Utils.getBluetoothList()));
|
||||
params.put("memory", NetInterfaceManager.convertToRequestBody(Utils.getUsedMemoryString(mContext)));
|
||||
params.put("storage", NetInterfaceManager.convertToRequestBody(Utils.getDataTotalSize(mContext)));
|
||||
params.put("memory_use", NetInterfaceManager.convertToRequestBody(Utils.getUsedMemoryString(mContext)));
|
||||
params.put("storage_use", NetInterfaceManager.convertToRequestBody(Utils.getUsedSize(mContext)));
|
||||
params.put("sn", NetInterfaceManager.convertToRequestBody(Utils.getSerial()));
|
||||
return mRetrofit.create(UpdateSnInfoApi.class)
|
||||
.updateSnInfo(params)
|
||||
.subscribeOn(Schedulers.io())
|
||||
@@ -396,40 +396,43 @@ public class NetInterfaceManager {
|
||||
int old = Settings.Global.getInt(mCrv, "is_control", 0);
|
||||
if (is_control != old) {
|
||||
try {
|
||||
new CacheUtils().clearApplicationUserData(mContext, "com.uiuipad.os");
|
||||
new CacheUtils().clearApplicationUserData(mContext, "com.android.launcher3");
|
||||
// new CacheUtils().clearApplicationUserData(mContext, "com.uiuipad.os");
|
||||
// new CacheUtils().clearApplicationUserData(mContext, "com.android.launcher3");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e(TAG, "clearCache: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
Settings.Global.putInt(mCrv, "is_control", is_control);
|
||||
int is_loss = snSetting.getIs_loss();
|
||||
String loss_str = snSetting.getLoss_str();
|
||||
mMMKV.encode(CommonConfig.LOST_STATUS_KEY, is_loss);
|
||||
mMMKV.encode(CommonConfig.FIND_STRING_KEY, loss_str);
|
||||
int is_lockscreen = snSetting.getIs_lockscreen();
|
||||
mMMKV.encode(ManagerService.LOCK_STATE, is_lockscreen);
|
||||
String lockscreen_pwd = snSetting.getLockscreen_pwd();
|
||||
Settings.Global.putString(mCrv, ManagerService.LOCK_SCREEN_PASSWORD, lockscreen_pwd);
|
||||
int is_timecontrol = snSetting.getIs_timecontrol();
|
||||
String timecontrol_start = snSetting.getTimecontrol_start();
|
||||
String timecontrol_end = snSetting.getTimecontrol_end();
|
||||
if (is_timecontrol == 0) {
|
||||
TimeUtils.setEmpty(mContext);
|
||||
TimeUtils.ContralTime c = TimeUtils.getDefaltContralTime(mContext);
|
||||
if (null != c) {
|
||||
Log.e("getTimeControl", c.toString());
|
||||
if (is_control == 1) {
|
||||
int is_loss = snSetting.getIs_loss();
|
||||
String loss_str = snSetting.getLoss_str();
|
||||
mMMKV.encode(CommonConfig.LOST_STATUS_KEY, is_loss);
|
||||
mMMKV.encode(CommonConfig.FIND_STRING_KEY, loss_str);
|
||||
int is_lockscreen = snSetting.getIs_lockscreen();
|
||||
mMMKV.encode(ManagerService.LOCK_STATE, is_lockscreen);
|
||||
String lockscreen_pwd = snSetting.getLockscreen_pwd();
|
||||
Settings.Global.putString(mCrv, ManagerService.LOCK_SCREEN_PASSWORD, lockscreen_pwd);
|
||||
int is_timecontrol = snSetting.getIs_timecontrol();
|
||||
String timecontrol_start = snSetting.getTimecontrol_start();
|
||||
String timecontrol_end = snSetting.getTimecontrol_end();
|
||||
if (is_timecontrol == 0) {
|
||||
TimeUtils.setEmpty(mContext);
|
||||
TimeUtils.ContralTime c = TimeUtils.getDefaltContralTime(mContext);
|
||||
if (null != c) {
|
||||
Log.e("getTimeControl", c.toString());
|
||||
}
|
||||
} else {
|
||||
TimeUtils.ContralTime c = TimeUtils.String2ContralTime(mContext, timecontrol_start + "-" + timecontrol_end);
|
||||
if (null != c) {
|
||||
Log.e("getTimeControl", "OK:" + c.toString());
|
||||
}
|
||||
}
|
||||
ControlUtils.setSystemControl(mContext, snSetting);
|
||||
ControlUtils.setRoleHolderAsUser(mContext, "com.uiuipad.os");
|
||||
} else {
|
||||
TimeUtils.ContralTime c = TimeUtils.String2ContralTime(mContext, timecontrol_start + "-" + timecontrol_end);
|
||||
if (null != c) {
|
||||
Log.e("getTimeControl", "OK:" + c.toString());
|
||||
}
|
||||
ControlUtils.disableSystemControl(mContext);
|
||||
}
|
||||
|
||||
ControlUtils.setSystemControl(mContext, snSetting);
|
||||
|
||||
} else {
|
||||
TimeUtils.setEmpty(mContext);
|
||||
TimeUtils.ContralTime c = TimeUtils.getDefaltContralTime(mContext);
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.uiuipad.find.network.UrlAddress;
|
||||
import java.util.Map;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import okhttp3.RequestBody;
|
||||
import retrofit2.http.Multipart;
|
||||
import retrofit2.http.POST;
|
||||
import retrofit2.http.PartMap;
|
||||
@@ -14,7 +15,7 @@ public interface UpdateSnInfoApi {
|
||||
@Multipart
|
||||
@POST(UrlAddress.UPDATE_SN_INFO)
|
||||
Observable<BaseResponse> updateSnInfo(
|
||||
@PartMap Map<String, String> params
|
||||
@PartMap Map<String, RequestBody> params
|
||||
// @Field("wifi_name") String wifi_name,
|
||||
// @Field("wifi_signal") String wifi_signal,
|
||||
// @Field("battery") String battery,
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.uiuipad.find.manager.MapManager;
|
||||
import com.uiuipad.find.network.NetInterfaceManager;
|
||||
import com.uiuipad.find.network.RetryCallback;
|
||||
import com.uiuipad.find.service.ManagerService;
|
||||
import com.uiuipad.find.service.main.MainService;
|
||||
import com.uiuipad.find.util.ApkUtils;
|
||||
import com.uiuipad.find.util.CmdUtil;
|
||||
import com.uiuipad.find.util.ControlUtils;
|
||||
@@ -118,12 +119,19 @@ public class PushManager {
|
||||
private static final String APP_UNINSTALL = "26";
|
||||
/*清除应用缓存*/
|
||||
private static final String CLEAR_APP_CACHE = "27";
|
||||
/*时间管控*/
|
||||
private static final String TIME_MANAGEMENT = "28";
|
||||
/*应用管控开关*/
|
||||
private static final String SYSTEM_CONTROL = "29";
|
||||
/*摄像头拍照*/
|
||||
private static final String FRONT_CAMERA = "30";
|
||||
/*设备解绑*/
|
||||
private static final String UNBIND_DEVICES = "31";
|
||||
/*强制停用应用*/
|
||||
private static final String FORCE_STOP_APP = "32";
|
||||
/*恢复出厂*/
|
||||
private static final String RESTORE_FACTORY = "33";
|
||||
|
||||
|
||||
private PushManager(Context context) {
|
||||
if (context == null) {
|
||||
@@ -201,8 +209,9 @@ public class PushManager {
|
||||
case ACTIONBAR_CONTROL:
|
||||
case NAVIGATIONBAR_CONTROL:
|
||||
case TF_CONTROL:
|
||||
case TIME_MANAGEMENT:
|
||||
case SYSTEM_CONTROL:
|
||||
NetInterfaceManager.getInstance().getSnSetting();
|
||||
setControl(mContext, title, extras);
|
||||
break;
|
||||
case FOCUS_MODE:
|
||||
break;
|
||||
@@ -218,11 +227,78 @@ public class PushManager {
|
||||
break;
|
||||
case CLEAR_APP_CACHE:
|
||||
|
||||
break;
|
||||
case FRONT_CAMERA:
|
||||
break;
|
||||
case UNBIND_DEVICES:
|
||||
ToastUtil.debugShow("收到管控:解除绑定");
|
||||
mMMKV.clearAll();
|
||||
ControlUtils.disableSystemControl(mContext);
|
||||
break;
|
||||
case RESTORE_FACTORY:
|
||||
ToastUtil.debugShow("收到管控:恢复出厂");
|
||||
ControlUtils.doMasterClear(mContext);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
private void setControl(Context context, String type, String extras) {
|
||||
JsonObject jsonObject = GsonUtils.getJsonObject(extras);
|
||||
switch (type) {
|
||||
case APPSTORE_INSTALL:
|
||||
|
||||
case USB_CONTROL:
|
||||
if (jsonObject.get("is_usb") != null) {
|
||||
int is_usb = jsonObject.get("is_usb").getAsInt();
|
||||
ControlUtils.setUsbState(mContext, is_usb);
|
||||
}
|
||||
break;
|
||||
case BLUETOOTH_CONTROL:
|
||||
if (jsonObject.get("is_bluetooth_file") != null) {
|
||||
int is_bluetooth_file = jsonObject.get("is_bluetooth_file").getAsInt();
|
||||
ControlUtils.setBluetooth(mContext, is_bluetooth_file);
|
||||
}
|
||||
break;
|
||||
case DEVELOPER_MODE:
|
||||
if (jsonObject.get("is_developer") != null) {
|
||||
int is_developer = jsonObject.get("is_developer").getAsInt();
|
||||
ControlUtils.setDeveloperOptions(mContext, is_developer);
|
||||
}
|
||||
break;
|
||||
case DEVICE_RESET:
|
||||
if (jsonObject.get("is_restore") != null) {
|
||||
int is_restore = jsonObject.get("is_restore").getAsInt();
|
||||
ControlUtils.setCanReset(mContext, is_restore);
|
||||
}
|
||||
break;
|
||||
case ACTIONBAR_CONTROL:
|
||||
if (jsonObject.get("is_topbar") != null) {
|
||||
int is_topbar = jsonObject.get("is_topbar").getAsInt();
|
||||
ControlUtils.setActionBar(mContext, is_topbar);
|
||||
}
|
||||
break;
|
||||
case NAVIGATIONBAR_CONTROL:
|
||||
if (jsonObject.get("is_bottombar") != null) {
|
||||
int is_bottombar = jsonObject.get("is_bottombar").getAsInt();
|
||||
ControlUtils.setNavigationBar(mContext, is_bottombar);
|
||||
}
|
||||
break;
|
||||
case TF_CONTROL:
|
||||
if (jsonObject.get("is_memory_card") != null) {
|
||||
int is_memory_card = jsonObject.get("is_memory_card").getAsInt();
|
||||
ControlUtils.setTF(mContext, is_memory_card);
|
||||
}
|
||||
break;
|
||||
case TIME_MANAGEMENT:
|
||||
case SYSTEM_CONTROL:
|
||||
mContext.sendBroadcast(new Intent(MainService.OS_REFRESH_ACTION));
|
||||
break;
|
||||
default:
|
||||
}
|
||||
NetInterfaceManager.getInstance().getSnSetting();
|
||||
}
|
||||
|
||||
private void globalUpdate(Context context, String extras) {
|
||||
Gson gson = new Gson();
|
||||
Type type = new TypeToken<AppInfo>() {
|
||||
@@ -353,6 +429,7 @@ public class PushManager {
|
||||
String msg = baseResponse.msg;
|
||||
if (code == 200) {
|
||||
ToastUtil.show("绑定成功");
|
||||
mContext.sendBroadcast(new Intent(MainService.REFRESH_ACTION));
|
||||
} else if (code == 301) {
|
||||
ToastUtil.show(msg);
|
||||
}
|
||||
|
||||
@@ -36,7 +36,6 @@ import com.uiuipad.find.bean.jxw.JxwResponse;
|
||||
import com.uiuipad.find.comm.CommonConfig;
|
||||
import com.uiuipad.find.gson.GsonUtils;
|
||||
import com.uiuipad.find.network.NetInterfaceManager;
|
||||
import com.uiuipad.find.push.PushManager;
|
||||
import com.uiuipad.find.util.ApkUtils;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -82,7 +81,7 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
|
||||
@Override
|
||||
public void onConnected(NetworkUtils.NetworkType networkType) {
|
||||
|
||||
mPresenter.updateSnInfo();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -149,7 +148,38 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
}
|
||||
|
||||
private void registerReceivers() {
|
||||
registerRefreshReceiver();
|
||||
}
|
||||
|
||||
private void unregisterReceivers() {
|
||||
if (mRefreshReceiver != null) {
|
||||
unregisterReceiver(mRefreshReceiver);
|
||||
}
|
||||
}
|
||||
|
||||
public static final String REFRESH_ACTION = "uiui.find.main.action.refresh";
|
||||
public static final String OS_REFRESH_ACTION = "uiui.find.os.action.refresh";
|
||||
private RefreshReceiver mRefreshReceiver;
|
||||
|
||||
private void registerRefreshReceiver() {
|
||||
if (null == mRefreshReceiver) {
|
||||
mRefreshReceiver = new RefreshReceiver();
|
||||
}
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
|
||||
filter.addAction(REFRESH_ACTION);
|
||||
registerReceiver(mRefreshReceiver, filter);
|
||||
}
|
||||
|
||||
class RefreshReceiver extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
Log.e("RefreshReceiver", "onReceive: " + action);
|
||||
if (REFRESH_ACTION.equals(action)) {
|
||||
mPresenter.updateSnInfo();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static final String CHANNEL_ID = "CHANNEL_ID";
|
||||
@@ -204,6 +234,7 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
lifecycleSubject.onNext(ActivityEvent.DESTROY);
|
||||
NetworkUtils.unregisterNetworkStatusChangedListener(this);
|
||||
mPresenter.detachView();
|
||||
unregisterReceivers();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,10 +3,13 @@ package com.uiuipad.find.util;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.StatusBarManager;
|
||||
import android.app.role.RoleManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.PowerManager;
|
||||
import android.os.Process;
|
||||
import android.os.UserHandle;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
|
||||
@@ -20,6 +23,8 @@ import com.uiuipad.find.comm.CommonConfig;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* @author TT
|
||||
@@ -169,19 +174,19 @@ public class ControlUtils {
|
||||
|
||||
public static void disableSystemControl(Context context) {
|
||||
setUsbState(context, 0);
|
||||
setBluetooth(context, 0);
|
||||
setBluetooth(context, 1);
|
||||
setDeveloperOptions(context, 0);
|
||||
setCanReset(context, 0);
|
||||
setActionBar(context, 0);
|
||||
setCanReset(context, 1);
|
||||
setActionBar(context, 1);
|
||||
// setNavigationBar(context, 0);
|
||||
setStatusBar(context);
|
||||
setTF(context, 0);
|
||||
setTF(context, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* usb连接模式管控
|
||||
*/
|
||||
private static void setUsbState(Context context, int status) {
|
||||
public static void setUsbState(Context context, int status) {
|
||||
Log.e(TAG, "setUsbState: " + status);
|
||||
String usbStatus;
|
||||
switch (status) {
|
||||
@@ -198,7 +203,7 @@ public class ControlUtils {
|
||||
context.sendBroadcast(usbIntent);
|
||||
}
|
||||
|
||||
private static void setBluetooth(Context context, int status) {
|
||||
public static void setBluetooth(Context context, int status) {
|
||||
int code = status == 1 ? 0 : 1;
|
||||
boolean aole_bht_forbid_on = Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_BHT_FORBID_ON, code);
|
||||
}
|
||||
@@ -229,7 +234,7 @@ public class ControlUtils {
|
||||
}
|
||||
}
|
||||
|
||||
private static void setCanReset(Context context, int status) {
|
||||
public static void setCanReset(Context context, int status) {
|
||||
if (status == 1) {
|
||||
Settings.Global.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_RESTORE_FORBID_ON, 0);
|
||||
} else {
|
||||
@@ -242,7 +247,7 @@ public class ControlUtils {
|
||||
* @param context
|
||||
* @param status 系统导航条显示开关
|
||||
*/
|
||||
private static void setNavigationBar(Context context, int status) {
|
||||
public static void setNavigationBar(Context context, int status) {
|
||||
// boolean aole_hide_NavigationBar = Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_HIDE_NAVIGATION_BAR, status);
|
||||
// Log.e("SystemSetting", "aole_hide_NavigationBar:" + aole_hide_NavigationBar);
|
||||
// String navigationStatus = "";
|
||||
@@ -284,7 +289,7 @@ public class ControlUtils {
|
||||
* @param context
|
||||
* @param status 状态栏显示开关
|
||||
*/
|
||||
private static void setActionBar(Context context, int status) {
|
||||
public static void setActionBar(Context context, int status) {
|
||||
Log.e(TAG, "setActionBar: " + status);
|
||||
Settings.Global.putInt(context.getContentResolver(), "pulldown_menu_enabled", status);
|
||||
// int oldNum = Settings.System.getInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_HIDE_STATUS_BAR, 0);
|
||||
@@ -306,8 +311,57 @@ public class ControlUtils {
|
||||
// }
|
||||
}
|
||||
|
||||
private static void setTF(Context context, int state) {
|
||||
public static void setTF(Context context, int state) {
|
||||
Log.e(TAG, "setTF: " + state);
|
||||
Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_SDCARD_FORBID_ON, state == 1 ? 0 : 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 重置,恢复出厂设置
|
||||
*/
|
||||
public static void doMasterClear(Context context) {
|
||||
if (BuildConfig.DEBUG) {
|
||||
ToastUtil.show("收到重置设备推送消息");
|
||||
return;
|
||||
}
|
||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.N_MR1) {
|
||||
Intent intent = new Intent("android.intent.action.FACTORY_RESET");
|
||||
intent.setPackage("android");
|
||||
intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
|
||||
intent.putExtra("android.intent.extra.REASON", "MasterClearConfirm");
|
||||
intent.putExtra("android.intent.extra.WIPE_EXTERNAL_STORAGE", false);
|
||||
intent.putExtra("com.android.internal.intent.extra.WIPE_ESIMS", false);
|
||||
context.sendBroadcast(intent);
|
||||
} else {
|
||||
Intent intent = new Intent("android.intent.action.MASTER_CLEAR");
|
||||
// intent.setPackage("com.android.settings");
|
||||
context.sendBroadcast(intent);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setRoleHolderAsUser(Context context, String packageName) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
String roleName = "android.app.role.HOME";
|
||||
boolean add = true;
|
||||
int flags = 0;
|
||||
UserHandle user = Process.myUserHandle();
|
||||
Log.i("settingssssssstemf", (add ? "Adding" : "Removing") + " package as role holder, role: "
|
||||
+ roleName + ", package: " + packageName);
|
||||
RoleManager roleManager = context.getSystemService(RoleManager.class);
|
||||
Executor executor = context.getMainExecutor();
|
||||
Consumer<Boolean> callback = successful -> {
|
||||
if (successful) {
|
||||
Log.d("settingssssssstemf", "Package " + (add ? "added" : "removed")
|
||||
+ " as role holder, role: " + roleName + ", package: " + packageName);
|
||||
} else {
|
||||
Log.d("settingssssssstemf", "Failed to " + (add ? "add" : "remove")
|
||||
+ " package as role holder, role: " + roleName + ", package: "
|
||||
+ packageName);
|
||||
}
|
||||
};
|
||||
roleManager.addRoleHolderAsUser(roleName, packageName, flags, user, executor, callback);
|
||||
Log.i("settingssssssstemf", "addRoleHolderAsUser done");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,4 +133,11 @@ public class FileSizeUtil {
|
||||
}
|
||||
return fileSizeLong;
|
||||
}
|
||||
|
||||
public static String FormetFileSize(long fileS) {
|
||||
DecimalFormat df = new DecimalFormat("#.00");
|
||||
double fileSizeLong;
|
||||
fileSizeLong = Double.parseDouble(df.format((double) fileS / 1073741824));
|
||||
return String.valueOf(fileSizeLong);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ public class Utils {
|
||||
WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
|
||||
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
|
||||
if (wifiInfo != null) {
|
||||
return wifiInfo.getSSID();
|
||||
return wifiInfo.getSSID().replaceAll("\"", "");
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
@@ -71,7 +71,7 @@ public class Utils {
|
||||
public static String getWifiRssi(Context context) {
|
||||
WifiManager wifiManager = (WifiManager) context.getSystemService(WIFI_SERVICE);
|
||||
WifiInfo info = wifiManager.getConnectionInfo();
|
||||
return String.valueOf(info.getRssi());
|
||||
return info.getRssi() + "dBm";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,6 +126,16 @@ public class Utils {
|
||||
return freeMem;
|
||||
}
|
||||
|
||||
public static String getUsedMemoryString(Context context) {
|
||||
ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
|
||||
activityManager.getMemoryInfo(memoryInfo);
|
||||
long freeMem = memoryInfo.totalMem - memoryInfo.availMem;
|
||||
// Log.e("getHardware", "getFreeMemory: " + freeMem);
|
||||
// return freeMem;
|
||||
return FileSizeUtil.FormetFileSize(freeMem);
|
||||
}
|
||||
|
||||
/**
|
||||
* 描述:获取可用内存.
|
||||
*
|
||||
@@ -198,7 +208,8 @@ public class Utils {
|
||||
long availableSize = sf.getAvailableBytes();
|
||||
long blockSize = sf.getBlockSize();
|
||||
long totalBlocks = sf.getBlockCount();
|
||||
return Formatter.formatFileSize(context, blockSize * totalBlocks - availableSize);
|
||||
// return Formatter.formatFileSize(context, blockSize * totalBlocks - availableSize);
|
||||
return FileSizeUtil.FormetFileSize(blockSize * totalBlocks - availableSize);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -209,7 +220,8 @@ public class Utils {
|
||||
StatFs sf = new StatFs(context.getCacheDir().getAbsolutePath());
|
||||
long blockSize = sf.getBlockSize();
|
||||
long totalBlocks = sf.getBlockCount();
|
||||
return Formatter.formatFileSize(context, blockSize * totalBlocks);
|
||||
// return Formatter.formatFileSize(context, blockSize * totalBlocks);
|
||||
return FileSizeUtil.FormetFileSize(blockSize * totalBlocks);
|
||||
}
|
||||
|
||||
|
||||
|
||||
BIN
app/src/main/res/drawable-hdpi/icon_activated.png
Normal file
BIN
app/src/main/res/drawable-hdpi/icon_activated.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.1 KiB |
BIN
app/src/main/res/drawable-hdpi/icon_inactivated.png
Normal file
BIN
app/src/main/res/drawable-hdpi/icon_inactivated.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.5 KiB |
BIN
app/src/main/res/drawable-hdpi/icon_update.png
Normal file
BIN
app/src/main/res/drawable-hdpi/icon_update.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 712 B |
BIN
app/src/main/res/drawable-hdpi/icon_upgrade.png
Normal file
BIN
app/src/main/res/drawable-hdpi/icon_upgrade.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 712 B |
@@ -111,6 +111,31 @@
|
||||
app:layout_constraintTop_toBottomOf="@+id/tv_name" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_activation"
|
||||
android:layout_width="@dimen/dp_66"
|
||||
android:layout_height="@dimen/dp_20"
|
||||
android:layout_marginTop="@dimen/dp_16"
|
||||
android:layout_marginEnd="@dimen/dp_20"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/icon_inactivated"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_bindtime"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/dp_20"
|
||||
android:layout_marginBottom="@dimen/dp_16"
|
||||
android:maxLines="1"
|
||||
android:textColor="@color/text_gray"
|
||||
android:textSize="@dimen/sp_8"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
tools:text="绑定时间" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
@@ -211,12 +236,22 @@
|
||||
android:id="@+id/tv_system_version"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/dp_8"
|
||||
android:text="@string/unknown"
|
||||
android:textColor="@color/text_gray"
|
||||
android:textSize="@dimen/sp_9"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/cl_ota"
|
||||
app:layout_constraintStart_toEndOf="@+id/tv_system_version2"
|
||||
app:layout_constraintEnd_toStartOf="@+id/iv_ota"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_ota"
|
||||
android:layout_width="@dimen/dp_24"
|
||||
android:layout_height="@dimen/dp_24"
|
||||
android:layout_marginEnd="@dimen/dp_16"
|
||||
android:src="@drawable/icon_upgrade"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
@@ -225,6 +260,7 @@
|
||||
android:layout_height="@dimen/dp_20"
|
||||
android:layout_marginEnd="@dimen/dp_16"
|
||||
android:background="@drawable/bt_default_normnl"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
@@ -279,12 +315,22 @@
|
||||
android:id="@+id/tv_version"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/dp_8"
|
||||
android:text="@string/unknown"
|
||||
android:textColor="@color/text_gray"
|
||||
android:textSize="@dimen/sp_9"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/cl_app"
|
||||
app:layout_constraintStart_toEndOf="@+id/tv_app_version2"
|
||||
app:layout_constraintEnd_toStartOf="@+id/iv_app"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_app"
|
||||
android:layout_width="@dimen/dp_24"
|
||||
android:layout_height="@dimen/dp_24"
|
||||
android:layout_marginEnd="@dimen/dp_16"
|
||||
android:src="@drawable/icon_upgrade"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
@@ -293,6 +339,7 @@
|
||||
android:layout_height="@dimen/dp_20"
|
||||
android:layout_marginEnd="@dimen/dp_16"
|
||||
android:background="@drawable/bt_default_normnl"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
@@ -111,6 +111,31 @@
|
||||
app:layout_constraintTop_toBottomOf="@+id/tv_name" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_activation"
|
||||
android:layout_width="@dimen/dp_66"
|
||||
android:layout_height="@dimen/dp_20"
|
||||
android:layout_marginTop="@dimen/dp_16"
|
||||
android:layout_marginEnd="@dimen/dp_20"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/icon_inactivated"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_bindtime"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/dp_20"
|
||||
android:layout_marginBottom="@dimen/dp_16"
|
||||
android:maxLines="1"
|
||||
android:textColor="@color/text_gray"
|
||||
android:textSize="@dimen/sp_8"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
tools:text="绑定时间" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
@@ -211,12 +236,22 @@
|
||||
android:id="@+id/tv_system_version"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/dp_8"
|
||||
android:text="@string/unknown"
|
||||
android:textColor="@color/text_gray"
|
||||
android:textSize="@dimen/sp_9"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/cl_ota"
|
||||
app:layout_constraintStart_toEndOf="@+id/tv_system_version2"
|
||||
app:layout_constraintEnd_toStartOf="@+id/iv_ota"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_ota"
|
||||
android:layout_width="@dimen/dp_24"
|
||||
android:layout_height="@dimen/dp_24"
|
||||
android:layout_marginEnd="@dimen/dp_16"
|
||||
android:src="@drawable/icon_upgrade"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
@@ -225,6 +260,7 @@
|
||||
android:layout_height="@dimen/dp_20"
|
||||
android:layout_marginEnd="@dimen/dp_16"
|
||||
android:background="@drawable/bt_default_normnl"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
@@ -279,12 +315,22 @@
|
||||
android:id="@+id/tv_version"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/dp_8"
|
||||
android:text="@string/unknown"
|
||||
android:textColor="@color/text_gray"
|
||||
android:textSize="@dimen/sp_9"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/cl_app"
|
||||
app:layout_constraintStart_toEndOf="@+id/tv_app_version2"
|
||||
app:layout_constraintEnd_toStartOf="@+id/iv_app"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_app"
|
||||
android:layout_width="@dimen/dp_24"
|
||||
android:layout_height="@dimen/dp_24"
|
||||
android:layout_marginEnd="@dimen/dp_16"
|
||||
android:src="@drawable/icon_upgrade"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
@@ -293,6 +339,7 @@
|
||||
android:layout_height="@dimen/dp_20"
|
||||
android:layout_marginEnd="@dimen/dp_16"
|
||||
android:background="@drawable/bt_default_normnl"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<!-- <color name="colorAccent">#03DAC5</color>-->
|
||||
|
||||
<color name="default_blue">#0480FF</color>
|
||||
<color name="text_gray">#9a9a9a</color>
|
||||
<color name="text_gray">#a0a0a0</color>
|
||||
<color name="toast_color">#CD000000</color>
|
||||
|
||||
<color name="check_default_color">#4880ff</color>
|
||||
|
||||
@@ -6,5 +6,6 @@
|
||||
|
||||
<string name="binding_time">绑定时间:%s</string>
|
||||
<string name="login_bind">请登录后扫码绑定\n管控平板</string>
|
||||
<string name="activation_time">激活时间:%s</string>
|
||||
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user