1.4.0318 修复升级后设置默认桌面,对接小程序管控,增加专注模式,接管系统打开app
This commit is contained in:
@@ -12,6 +12,7 @@ import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.aoleyun.sn.BuildConfig;
|
||||
import com.aoleyun.sn.bean.SnSetting;
|
||||
import com.aoleyun.sn.comm.CommonConfig;
|
||||
import com.aoleyun.sn.comm.JGYActions;
|
||||
import com.aoleyun.sn.gson.GsonUtils;
|
||||
@@ -71,7 +72,11 @@ public class SysSettingUtils {
|
||||
Log.e("setDisableSetting", "Close all settings: ");
|
||||
setPhoneList(context, 1);
|
||||
setUSBstate(context, 1);
|
||||
setBluetooth(context, 1);
|
||||
if (JGYUtils.getInstance().getAppPlatform().equals(JGYUtils.YXPD1TAG)) {
|
||||
setBluetooth(context, 1);
|
||||
} else {
|
||||
setBluetooth(context, 0);
|
||||
}
|
||||
setHotspot(context, 1);
|
||||
setBar(context, 1);
|
||||
setCamera(context, 1);
|
||||
@@ -246,7 +251,6 @@ public class SysSettingUtils {
|
||||
context.sendBroadcast(usbIntent);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void setBluetooth(Context context, int state) {
|
||||
@@ -654,7 +658,7 @@ public class SysSettingUtils {
|
||||
}
|
||||
|
||||
private static void setCanReset(Context context, int state) {
|
||||
boolean aole_restore_forbid_on = Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_RESTORE_FORBID_ON, 0);
|
||||
boolean aole_restore_forbid_on = Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_RESTORE_FORBID_ON, state);
|
||||
Log.e(TAG, "aole_restore_forbid_on: " + aole_restore_forbid_on);
|
||||
//默认打开
|
||||
}
|
||||
@@ -822,10 +826,10 @@ public class SysSettingUtils {
|
||||
JsonElement appInstall = jsonObject.get("is_app_install");
|
||||
if (appInstall != null) {
|
||||
int is_app_install = appInstall.getAsInt();
|
||||
Log.e(TAG, "setAdminApp: is_admin_app = " + is_app_install);
|
||||
Settings.System.putInt(context.getContentResolver(), "aole_app_allow_install", changeNum(is_app_install));
|
||||
Log.e(TAG, "setAdminApp: is_app_install = " + is_app_install);
|
||||
Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_APP_ALLOW_INSTALL, is_app_install);
|
||||
} else {
|
||||
Settings.System.putInt(context.getContentResolver(), "aole_app_allow_install", 1);
|
||||
Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_APP_ALLOW_INSTALL, 0);
|
||||
}
|
||||
|
||||
JsonElement adminApp = jsonObject.get("is_admin_app");
|
||||
@@ -847,7 +851,147 @@ public class SysSettingUtils {
|
||||
|
||||
private static void setAdminApp(Context context, int state) {
|
||||
Log.e(TAG, "setAdminApp: state = " + state);
|
||||
Settings.Global.putInt(context.getContentResolver(), "is_admin_app", state);
|
||||
Settings.System.putInt(context.getContentResolver(), "aole_app_allow_install", changeNum(state));
|
||||
Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_APP_ALLOW_INSTALL, changeNum(state));
|
||||
Settings.Global.putInt(context.getContentResolver(), "is_admin_app", changeNum(state));
|
||||
}
|
||||
|
||||
|
||||
public static void setSnSetting(Context context, SnSetting snSetting) {
|
||||
if (snSetting != null) {
|
||||
int is_timecontrol = snSetting.getIs_timecontrol();
|
||||
if (is_timecontrol == 0) {
|
||||
TimeUtils.setEmpty(context);
|
||||
TimeUtils.ContralTime c = TimeUtils.getDefaltContralTime(context);
|
||||
if (null != c) {
|
||||
Log.e("getTimeControl", c.toString());
|
||||
}
|
||||
} else {
|
||||
String start_time = snSetting.getTimecontrol_start();
|
||||
String end_time = snSetting.getTimecontrol_end();
|
||||
TimeUtils.ContralTime c = TimeUtils.String2ContralTime(context, start_time + "-" + end_time);
|
||||
if (null != c) {
|
||||
Log.e("getTimeControl", "OK:" + c.toString());
|
||||
}
|
||||
}
|
||||
int is_storeinstall = snSetting.getIs_storeinstall();
|
||||
Settings.Global.putInt(context.getContentResolver(), CommonConfig.AOLEYUN_APPSTORE_INSTALL, is_storeinstall);
|
||||
int is_usb = snSetting.getIs_usb();
|
||||
setUsb(context, changeNum(is_usb));
|
||||
int is_bluetooth_file = snSetting.getIs_bluetooth_file();
|
||||
setBluetooth(context, changeNum(is_bluetooth_file));
|
||||
int is_developer = snSetting.getIs_developer();
|
||||
JGYUtils.getInstance().setDeveloperOptions(changeNum(is_developer));
|
||||
int is_restore = snSetting.getIs_restore();
|
||||
setCanReset(context, changeNum(is_restore));
|
||||
int is_topbar = snSetting.getIs_topbar();
|
||||
setActionBar(context, changeNum(is_topbar));
|
||||
int is_bottombar = snSetting.getIs_bottombar();
|
||||
setNavigationBar(context, changeNum(is_bottombar));
|
||||
int is_memory_card = snSetting.getIs_memory_card();
|
||||
setTF(context, changeNum(is_memory_card));
|
||||
|
||||
} else {
|
||||
TimeUtils.setEmpty(context);
|
||||
TimeUtils.ContralTime c = TimeUtils.getDefaltContralTime(context);
|
||||
if (null != c) {
|
||||
Log.e("getTimeControl", c.toString());
|
||||
}
|
||||
Settings.Global.putInt(context.getContentResolver(), CommonConfig.AOLEYUN_APPSTORE_INSTALL, 1);
|
||||
setUsb(context, 0);
|
||||
setBluetooth(context, 0);
|
||||
JGYUtils.getInstance().setDeveloperOptions(1);
|
||||
setCanReset(context, 0);
|
||||
setActionBar(context, 0);
|
||||
setNavigationBar(context, 0);
|
||||
setTF(context, 0);
|
||||
}
|
||||
}
|
||||
|
||||
private static void setActionBar(Context context, int status) {
|
||||
//状态栏显示开关
|
||||
int oldNum = Settings.System.getInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_HIDE_STATUS_BAR, 0);
|
||||
if (oldNum != status) {
|
||||
//写入到系统不涉及任何管控,因为之前调用会频繁隐藏显示
|
||||
boolean aole_hide_statusBar = Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_HIDE_STATUS_BAR, status);
|
||||
Log.e(TAG, "aole_hide_statusBar: " + aole_hide_statusBar);
|
||||
String statusbarStatus = "";
|
||||
switch (status) {
|
||||
case 0:
|
||||
statusbarStatus = CommonConfig.AOLE_ACTION_SHOW_STATUS_BAR;
|
||||
break;
|
||||
case 1:
|
||||
statusbarStatus = CommonConfig.AOLE_ACTION_HIDE_STATUS_BAR;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
Intent statusIntent = new Intent(statusbarStatus);
|
||||
// Intent statusIntent = new Intent(statusbarStatus).setPackage("com.android.systemui");
|
||||
context.sendBroadcast(statusIntent);
|
||||
}
|
||||
}
|
||||
|
||||
private 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(TAG, "aole_hide_NavigationBar---------" + aole_hide_NavigationBar);
|
||||
|
||||
String navigationStatus = "";
|
||||
switch (status) {
|
||||
case 0:
|
||||
navigationStatus = CommonConfig.AOLE_ACTION_SHOW_NAVIGATION_BAR;
|
||||
break;
|
||||
case 1:
|
||||
navigationStatus = CommonConfig.AOLE_ACTION_HIDE_NAVIGATION_BAR;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
Intent navIntent = new Intent(navigationStatus);
|
||||
// Intent navIntent = new Intent(navigationStatus).setPackage("com.android.systemui");
|
||||
context.sendBroadcast(navIntent);
|
||||
}
|
||||
|
||||
private static void setUsb(Context context, int status) {
|
||||
//USB数据功能管控
|
||||
//仅充电:usb_charge
|
||||
//MTP模式:usb_mtp
|
||||
//Midi模式:usb_midi
|
||||
if (JGYUtils.isCubeDevice()) {
|
||||
SuperPower mService = (SuperPower) context.getSystemService("mdm");
|
||||
switch (status) {
|
||||
case 0:
|
||||
mService.setUsbDataDisabled(true);
|
||||
break;
|
||||
case 1:
|
||||
mService.setUsbDataDisabled(false);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
} else {
|
||||
String usbStatus;
|
||||
switch (status) {
|
||||
default:
|
||||
case 0:
|
||||
usbStatus = CommonConfig.AOLE_ACTION_USB_USB_CHARGE;
|
||||
JGYUtils.getInstance().setMtpEnable(false);
|
||||
break;
|
||||
case 1:
|
||||
usbStatus = CommonConfig.AOLE_ACTION_USB_USB_MTP;
|
||||
JGYUtils.getInstance().setMtpEnable(true);
|
||||
break;
|
||||
case 2:
|
||||
usbStatus = CommonConfig.AOLE_ACTION_USB_USB_MIDI;
|
||||
JGYUtils.getInstance().setMtpEnable(false);
|
||||
break;
|
||||
}
|
||||
Intent usbIntent = new Intent(usbStatus);
|
||||
if (JGYUtils.getInstance().checkAppPlatform() == JGYUtils.TeclastP20sPlatform
|
||||
|| JGYUtils.getInstance().checkAppPlatform() == JGYUtils.AH6016Platform
|
||||
) {
|
||||
usbIntent.setPackage("com.android.settings");
|
||||
}
|
||||
context.sendBroadcast(usbIntent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user