feat(debug): 扩展 DebugActivity 系统控制功能

新增进程管理、默认桌面设置、通知渠道、快捷方式及多种系统配置接口
This commit is contained in:
2026-08-28 17:09:25 +08:00
parent 314c053e56
commit b381678756
25 changed files with 2776 additions and 521 deletions

View File

@@ -0,0 +1,57 @@
package com.aoleyun.sn.activity;
import android.os.Build;
import android.view.View;
import androidx.databinding.DataBindingUtil;
import com.aoleyun.sn.R;
import com.aoleyun.sn.base.BaseDataBindingActivity;
import com.aoleyun.sn.databinding.ActivityInfoBinding;
import com.aoleyun.sn.utils.Utils;
public class InfoActivity extends BaseDataBindingActivity {
private ActivityInfoBinding mBinding;
@Override
public boolean setNightMode() {
return true;
}
@Override
public boolean setfitWindow() {
return true;
}
@Override
protected void initDataBinding() {
mBinding = DataBindingUtil.setContentView(this, R.layout.activity_info);
mBinding.setClick(new BtnClick());
}
@Override
protected void initView() {
// ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
// Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
// v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
// return insets;
// });
mBinding.tvModel.setText(Build.MODEL);
mBinding.tvSerial.setText(Utils.getSerial(this));
}
@Override
protected void initData() {
}
public class BtnClick {
public void exit(View view) {
finish();
}
}
}

View File

@@ -1,20 +1,67 @@
package com.aoleyun.sn.activity.debug;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.StatusBarManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.provider.Settings;
import android.util.Log;
import android.view.View;
import android.widget.CompoundButton;
import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodManager;
import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationManagerCompat;
import androidx.core.content.pm.ShortcutInfoCompat;
import androidx.core.content.pm.ShortcutManagerCompat;
import androidx.core.graphics.drawable.IconCompat;
import com.aoleyun.sn.BuildConfig;
import com.aoleyun.sn.R;
import com.aoleyun.sn.base.mvvm.BaseMvvmActivity;
import com.aoleyun.sn.databinding.ActivityDebugBinding;
import com.aoleyun.sn.manager.AllwinnerCubeMdmManager;
import com.aoleyun.sn.receiver.ShortcutReceiver;
import com.aoleyun.sn.utils.ApkUtils;
import com.aoleyun.sn.utils.JgyUtils;
import com.aoleyun.sn.utils.SysSettingUtils;
import com.hjq.toast.Toaster;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
public class DebugActivity extends BaseMvvmActivity<DebugViewModel, ActivityDebugBinding> {
private static final String TAG = "DebugActivity";
private JgyUtils jgyUtils;
public static final String NIGHT_DISPLAY_ENABLED = "NIGHT_DISPLAY_ENABLED";
public static final String NIGHT_DISPLAY_DISABLED = "NIGHT_DISPLAY_DISABLED";
public static final String READ_MODEL_ENABLED = "READ_MODEL_ENABLED";
public static final String READ_MODEL_DISABLED = "READ_MODEL_DISABLED";
StatusBarManager mStatusBarManager;
private static final String CHANNEL_ID = "CHANNEL_ID";
private static final String CHANNEL_NAME = "应用中心";
private static final String CHANNEL_DESCRIPTION = "应用中心通知";
private NotificationManagerCompat notificationManager;
private int NotificationID = 7897;
@Override
public boolean setNightMode() {
return true;
}
@Override
public boolean setfitWindow() {
return true;
}
@Override
protected int getLayoutId() {
@@ -31,110 +78,687 @@ public class DebugActivity extends BaseMvvmActivity<DebugViewModel, ActivityDebu
@Override
protected void initView() {
jgyUtils = JgyUtils.getInstance();
initListener();
mStatusBarManager = (StatusBarManager) getApplicationContext().getSystemService(Context.STATUS_BAR_SERVICE);
notificationManager = NotificationManagerCompat.from(this);
createNotificationChannel();
}
@Override
protected void initData() {
boolean canReset = SysSettingUtils.getCanReset(DebugActivity.this);
Log.e(TAG, "initData: canReset = " + canReset);
mViewDataBinding.swRestore.setChecked(canReset);
boolean usbStatus = SysSettingUtils.isDisableUsbStatus(DebugActivity.this);
Log.e(TAG, "initData: usbStatus = " + usbStatus);
mViewDataBinding.swUsbDebug.setChecked(usbStatus);
int tf = SysSettingUtils.getTF(DebugActivity.this);
Log.e(TAG, "initData: tf = " + tf);
mViewDataBinding.swTf.setChecked(tf == 0);
boolean developer = jgyUtils.getDeveloperOptions();
Log.e(TAG, "initData: developer = " + developer);
mViewDataBinding.swDeveloper.setChecked(developer);
int bluetooth = SysSettingUtils.getBluetooth(DebugActivity.this);
Log.e(TAG, "initData: bluetooth = " + bluetooth);
mViewDataBinding.swBluetooth.setChecked(bluetooth == 0);
int camera = SysSettingUtils.getCamera(DebugActivity.this);
Log.e(TAG, "initData: camera = " + camera);
mViewDataBinding.swCamera.setChecked(camera == 0);
int appinstall = SysSettingUtils.getAdminApp(DebugActivity.this);
Log.e(TAG, "initData: appinstall = " + appinstall);
mViewDataBinding.swAppinstall.setChecked(appinstall == 0);
}
private void initListener() {
mViewDataBinding.swRestore.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
// isChecked=true 允许恢复出厂 -> state=0; false 禁止 -> state=1
SysSettingUtils.setCanReset(DebugActivity.this, isChecked ? 0 : 1);
Toaster.show("恢复出厂设置已" + (isChecked ? "开启" : "关闭"));
}
});
mViewDataBinding.swUsbDebug.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
// isChecked=true 开启 -> state=1(MTP); false 仅充电 -> state=0
SysSettingUtils.setUsbStatus(DebugActivity.this, isChecked ? 1 : 0);
Toaster.show("USB调试已" + (isChecked ? "开启" : "关闭"));
}
});
mViewDataBinding.swTf.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
// isChecked=true 开启 -> state=0; false 关闭 -> state=1
SysSettingUtils.setTF(DebugActivity.this, isChecked ? 0 : 1);
Toaster.show("存储卡已" + (isChecked ? "开启" : "关闭"));
}
});
mViewDataBinding.swDeveloper.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
jgyUtils.setDeveloperOptions(isChecked ? 1 : 0);
Toaster.show("开发者选项已" + (isChecked ? "开启" : "关闭"));
}
});
mViewDataBinding.swBluetooth.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
// isChecked=true 开启 -> state=0; false 关闭 -> state=1
SysSettingUtils.setBluetooth(DebugActivity.this, isChecked ? 0 : 1);
Toaster.show("蓝牙已" + (isChecked ? "开启" : "关闭"));
}
});
mViewDataBinding.swCamera.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
// isChecked=true 开启 -> state=0; false 关闭 -> state=1
SysSettingUtils.setCamera(DebugActivity.this, isChecked ? 0 : 1);
Toaster.show("摄像头已" + (isChecked ? "开启" : "关闭"));
}
});
mViewDataBinding.swAppinstall.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
// isChecked=true 允许安装 -> state=0; false 禁止 -> state=1
SysSettingUtils.setAdminApp(DebugActivity.this, isChecked ? 0 : 1);
Toaster.show("允许安装应用已" + (isChecked ? "开启" : "关闭"));
}
});
private void gotoLauncher() {
Intent i = new Intent(Intent.ACTION_MAIN);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); //android123提示如果是服务里调用,必须加入new task标识
i.addCategory(Intent.CATEGORY_HOME);
startActivity(i);
}
public class BtnClick {
public void refresh(View view) {
initData();
private String getInputMethodId(String pkg) {
InputMethodManager imeManager = (InputMethodManager) getApplicationContext().getSystemService(INPUT_METHOD_SERVICE);
List<InputMethodInfo> InputMethods = imeManager.getInputMethodList();
Map<String, String> inputMap = new HashMap<>();
for (InputMethodInfo inputMethodInfo : InputMethods) {
inputMap.put(inputMethodInfo.getPackageName(), inputMethodInfo.getId());
}
String id = inputMap.get(pkg);
Log.e(TAG, "getInputMethodId: " + id);
return id;
}
public static void addShortCutCompact(Context context) {
if (ShortcutManagerCompat.isRequestPinShortcutSupported(context)) {
Intent shortcutInfoIntent = new Intent(context, DebugActivity.class);
shortcutInfoIntent.setAction(Intent.ACTION_VIEW); //action必须设置,不然报错
ShortcutInfoCompat info = new ShortcutInfoCompat.Builder(context, "id")
.setIcon(IconCompat.createWithResource(context, R.mipmap.ic_launcher))
.setShortLabel("name")
.setIntent(shortcutInfoIntent)
.build();
//当添加快捷方式的确认弹框弹出来时,将被回调,自定义Receiver
PendingIntent shortcutCallbackIntent = PendingIntent.getBroadcast(context, 0, new Intent(context, ShortcutReceiver.class), PendingIntent.FLAG_UPDATE_CURRENT);
ShortcutManagerCompat.requestPinShortcut(context, info,
shortcutCallbackIntent.getIntentSender());
}
}
private void createNotificationChannel() {
// Create the NotificationChannel, but only on API 26+ because
// the NotificationChannel class is new and not in the support library
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel channel = new NotificationChannel(CHANNEL_ID, CHANNEL_NAME, NotificationManager.IMPORTANCE_DEFAULT);
channel.setDescription(CHANNEL_DESCRIPTION);
channel.setSound(null, null);
// Register the channel with the system; you can't change the importance
// or other notification behaviors after this
NotificationManager notificationManager = getSystemService(NotificationManager.class);
if (notificationManager != null) {
notificationManager.createNotificationChannel(channel);
}
}
}
private void sendSimpleNotification() {
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, CHANNEL_ID)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle("应用中心正在运行")
// .setContentText("测试内容")
// .setAutoCancel(false)
.setShowWhen(false)
// .setOngoing(true)
.setOnlyAlertOnce(true)
.setPriority(NotificationCompat.PRIORITY_MIN);
// notificationId is a unique int for each notification that you must define
notificationManager.notify(NotificationID, builder.build());
}
public void setDeveloperOptions(int state) {
Settings.System.putInt(getContentResolver(), "aole_Developeroptions", state);
Log.e(TAG, "setDeveloperOptions: " + state);
Settings.System.putInt(getContentResolver(), "aole_Developeroptions", state);
int old_dev_enabled = Settings.Global.getInt(getContentResolver(), Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0);
Log.e(TAG, "setDeveloperOptions: old_dev_enabled = " + old_dev_enabled);
int new_state = (state == 1 ? 0 : 1);
if (old_dev_enabled != new_state) {
Settings.Global.putInt(getContentResolver(), Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, new_state);
Settings.Global.putInt(getContentResolver(), Settings.Global.ADB_ENABLED, new_state);
}
if (state == 1) {
// Intent intent = new Intent();
// intent.setAction("qch_developeroptions_close");
// intent.setPackage(JGYActions.ANDROID_SETTINGS_PACKAGE_NAME);
// sendBroadcast(intent);
Log.e(TAG, "setDeveloperOptions: " + "关闭开发者模式");
} else {
Log.e(TAG, "setDeveloperOptions: " + "打开开发者模式");
}
}
public class BtnClick {
public void openSettings(View view) {
startActivity(new Intent(Settings.ACTION_SETTINGS));
// startActivity(new Intent(Settings.ACTION_SECURITY_SETTINGS));
}
public void setUsbSettings(View view) {
Settings.System.putString(getContentResolver(), "app_view_click_disabled",
"com.android.gallery3d:12345,78901;com.android.settings:9876543,12346");
}
public void getUsbSettings(View view) {
String app_view_click_disabled = Settings.System.getString(getContentResolver(), "app_view_click_disabled");
Toaster.show(app_view_click_disabled);
}
public void setUsbCharge(View view) {
Log.e(TAG, "bt_usb_charge: " + view.getId());
Intent usbIntent = new Intent("aole_action_usb_usb_charge");
usbIntent.setPackage("com.android.settings");
sendBroadcast(usbIntent);
if (JgyUtils.isAllWinnerDevice()) {
AllwinnerCubeMdmManager.getInstance().setUsbStatus(0);
}
}
public void setUsbMtp(View view) {
Log.e(TAG, "bt_usb_charge: " + view.getId());
Intent usbIntent = new Intent("aole_action_usb_usb_mtp");
usbIntent.setPackage("com.android.settings");
sendBroadcast(usbIntent);
if (JgyUtils.isAllWinnerDevice()) {
AllwinnerCubeMdmManager.getInstance().setUsbStatus(1);
}
}
public void setUsbMidi(View view) {
Log.e(TAG, "bt_usb_charge: " + view.getId());
Intent usbIntent = new Intent("aole_action_usb_usb_midi");
usbIntent.setPackage("com.android.settings");
sendBroadcast(usbIntent);
if (JgyUtils.isAllWinnerDevice()) {
AllwinnerCubeMdmManager.getInstance().setUsbStatus(2);
}
}
public void getAllowAppInstallStatus(View view) {
int aole_sdcard_forbid_on = Settings.System.getInt(getContentResolver(), "aole_app_allow_install", 0);
mViewDataBinding.btnAllowInstallApp.setText("状态:" + aole_sdcard_forbid_on);
}
public void setAllowAppInstallOn(View view) {
Settings.System.putInt(getContentResolver(), "aole_app_allow_install", 0);
}
public void setAllowAppInstallOff(View view) {
Settings.System.putInt(getContentResolver(), "aole_app_allow_install", 1);
}
public void getAllowInstallList(View view) {
String aole_app_forbid = Settings.System.getString(getContentResolver(), "aole_app_forbid");
mViewDataBinding.btnAllowInstallList.setText("列表:" + aole_app_forbid);
Toaster.show(aole_app_forbid);
Log.e(TAG, "getAllowInstallList: aole_app_forbid = " + aole_app_forbid);
}
public void setAllowAppInstallStatus(View view) {
Settings.System.putString(getContentResolver(), "aole_app_forbid", BuildConfig.APPLICATION_ID);
}
public void cleanAllowAppInstallStatus(View view) {
Settings.System.putString(getContentResolver(), "aole_app_forbid", "");
}
public void getForceInstallList(View view) {
String aole_force_app = Settings.System.getString(getContentResolver(), "aole_force_app");
mViewDataBinding.btnForceInstallList.setText("列表:" + aole_force_app);
Toaster.show(aole_force_app);
Log.e(TAG, "getForceInstallList: aole_force_app = " + aole_force_app);
}
public void setForceAppInstallStatus(View view) {
Settings.System.putString(getContentResolver(), "aole_force_app", BuildConfig.APPLICATION_ID);
}
public void cleanForceAppInstallStatus(View view) {
Settings.System.putString(getContentResolver(), "aole_force_app", "");
}
public void getAutoRunAppList(View view) {
String aole_app_power_on = Settings.System.getString(getContentResolver(), "aole_app_power_on");
mViewDataBinding.btnAutoRunList.setText("列表:" + aole_app_power_on);
Toaster.show(aole_app_power_on);
Log.e(TAG, "getAutoRunAppList: aole_app_power_on = " + aole_app_power_on);
}
public void setAutoRunAppList(View view) {
Settings.System.putString(getContentResolver(), "aole_app_power_on", BuildConfig.APPLICATION_ID);
}
public void cleanAutoRunAppList(View view) {
Settings.System.putString(getContentResolver(), "aole_app_power_on", "");
}
public void goLauncher(View view) {
gotoLauncher();
}
public void setDefaultLauncher3(View view) {
Intent intent = new Intent("setDefaultLauncher");
intent.putExtra("package", "com.android.launcher3");
intent.putExtra("className", "com.android.launcher3.Launcher");
intent.setPackage("com.android.settings");
sendBroadcast(intent);
if (JgyUtils.isAllWinnerDevice()) {
AllwinnerCubeMdmManager.getInstance().setDefaultLauncher("com.android.launcher3");
}
}
public void setDefaultDop2(View view) {
Intent intent = new Intent("setDefaultLauncher");
intent.putExtra("package", "com.aoleyunos.dop2");
intent.putExtra("className", "com.aoleyunos.dop2.activity.main.MainActivity");
intent.setPackage("com.android.settings");
sendBroadcast(intent);
if (JgyUtils.isAllWinnerDevice()) {
AllwinnerCubeMdmManager.getInstance().setDefaultLauncher("com.aoleyunos.dop2");
}
}
public void setDefaultUiuiOs(View view) {
Intent intent = new Intent("setDefaultLauncher");
intent.putExtra("package", "com.android.uiuios");
intent.putExtra("className", "com.android.uiuios.Launcher");
intent.setPackage("com.android.settings");
sendBroadcast(intent);
if (JgyUtils.isAllWinnerDevice()) {
AllwinnerCubeMdmManager.getInstance().setDefaultLauncher("com.android.uiuios");
}
}
public void setDefaultAoleyun(View view) {
Intent intent = new Intent("setDefaultLauncher");
intent.putExtra("package", "com.aoleyun.os");
intent.putExtra("className", "com.aoleyun.os.Launcher");
intent.setPackage("com.android.settings");
sendBroadcast(intent);
if (JgyUtils.isAllWinnerDevice()) {
AllwinnerCubeMdmManager.getInstance().setDefaultLauncher("com.aoleyun.os");
}
}
public void openDocumentsui(View view) {
ApkUtils.openPackage(DebugActivity.this, "com.android.documentsui");
}
public void getSdStatus(View view) {
int aole_sdcard_forbid_on = Settings.System.getInt(getContentResolver(), "aole_sdcard_forbid_on", 0);
mViewDataBinding.btSdStatu.setText("状态:" + aole_sdcard_forbid_on);
}
public void setSdOn(View view) {
Settings.System.putInt(getContentResolver(), "aole_sdcard_forbid_on", 0);
if (JgyUtils.isAllWinnerDevice()) {
AllwinnerCubeMdmManager.getInstance().setSDEnable(true);
}
}
public void setSdOff(View view) {
Settings.System.putInt(getContentResolver(), "aole_sdcard_forbid_on", 1);
if (JgyUtils.isAllWinnerDevice()) {
AllwinnerCubeMdmManager.getInstance().setSDEnable(false);
}
}
public void getDeveloperStatu(View view) {
int aole_Developeroptions = Settings.System.getInt(getContentResolver(), "aole_Developeroptions", 0);
Log.e(TAG, "onClick: aole_Developeroptions = " + aole_Developeroptions);
mViewDataBinding.btDeveloperStatu.setText("状态:" + aole_Developeroptions);
}
public void setDeveloperOn(View view) {
setDeveloperOptions(0);
if (JgyUtils.isAllWinnerDevice()) {
AllwinnerCubeMdmManager.getInstance().setDeveloperEnable(true);
}
}
public void btDeveloperOff(View view) {
setDeveloperOptions(1);
if (JgyUtils.isAllWinnerDevice()) {
AllwinnerCubeMdmManager.getInstance().setDeveloperEnable(false);
}
}
public void getAutoRotationStatus(View view) {
int aole_auto_rotation = Settings.System.getInt(getContentResolver(), "aole_auto_rotation", 0);
Log.e(TAG, "getAutoRotationStatus: aole_auto_rotation = " + aole_auto_rotation);
mViewDataBinding.btRotationStatu.setText("状态:" + aole_auto_rotation);
}
public void setAutoRotationOn(View view) {
Settings.System.putInt(getContentResolver(), "aole_auto_rotation", 0);
}
public void setAutoRotationOff(View view) {
Settings.System.putInt(getContentResolver(), "aole_auto_rotation", 1);
}
public void getBatterySaverStatus(View view) {
int aole_setting_battery_saver = Settings.System.getInt(getContentResolver(), "aole_setting_battery_saver", 0);
Log.e(TAG, "getBatterySaverStatus: aole_setting_battery_saver = " + aole_setting_battery_saver);
mViewDataBinding.btBatteryStatu.setText("状态:" + aole_setting_battery_saver);
}
public void setBatterySaverOn(View view) {
Settings.System.putInt(getContentResolver(), "aole_setting_battery_saver", 0);
}
public void setBatterySaverOff(View view) {
Settings.System.putInt(getContentResolver(), "aole_setting_battery_saver", 1);
}
public void getNavigationStatus(View view) {
Intent intent = new Intent(Settings.ACTION_SECURITY_SETTINGS);
startActivity(intent);
}
public void setNavigationOn(View view) {
Intent navIntent = new Intent("aole_show_NavigationBar");
// Intent navIntent = new Intent("aole_show_NavigationBar").setPackage("com.android.systemui");
sendBroadcast(navIntent);
if (JgyUtils.isAllWinnerDevice()) {
AllwinnerCubeMdmManager.getInstance().setNavigationStatus(true);
}
}
public void setNavigationOff(View view) {
Intent navIntent = new Intent("aole_hide_NavigationBar");
// Intent navIntent = new Intent("aole_hide_NavigationBar").setPackage("com.android.systemui");
sendBroadcast(navIntent);
if (JgyUtils.isAllWinnerDevice()) {
AllwinnerCubeMdmManager.getInstance().setNavigationStatus(false);
}
}
public void showStatusbar(View view) {
// mStatusBarManager.disable(StatusBarManager.DISABLE_RECENT | StatusBarManager.DISABLE_HOME);
// mStatusBarManager.disable(StatusBarManager.DISABLE_BACK | StatusBarManager.DISABLE_RECENT | StatusBarManager.DISABLE_HOME);
mStatusBarManager.disable(StatusBarManager.DISABLE_NONE);//显示隐藏的虚拟按键
}
public void hideStatusbarBack(View view) {
mStatusBarManager.disable(StatusBarManager.DISABLE_BACK);//隐藏返回键
}
public void hideStatusbarHome(View view) {
mStatusBarManager.disable(StatusBarManager.DISABLE_HOME);//隐藏home键
}
public void hideStatusbarRecent(View view) {
mStatusBarManager.disable(StatusBarManager.DISABLE_RECENT);//隐藏recent键
}
public void setPowerKeyLongPressEnable(View view) {
if (JgyUtils.isAllWinnerDevice()) {
AllwinnerCubeMdmManager.getInstance().setPowerKeyLongPressEnable(true);
}
}
public void setPowerKeyLongPressDisable(View view) {
if (JgyUtils.isAllWinnerDevice()) {
AllwinnerCubeMdmManager.getInstance().setPowerKeyLongPressEnable(false);
}
}
public void setStatusOn(View view) {
Intent navIntent = new Intent("aole_show_statusBar");
// Intent navIntent = new Intent("aole_show_statusBar").setPackage("com.android.systemui");
sendBroadcast(navIntent);
if (JgyUtils.isAllWinnerDevice()) {
AllwinnerCubeMdmManager.getInstance().setStatusBarEnable(true);
}
}
public void hideStatusOff(View view) {
Intent navIntent = new Intent("aole_hide_statusBar");
// Intent navIntent = new Intent("aole_hide_statusBar").setPackage("com.android.systemui");
sendBroadcast(navIntent);
if (JgyUtils.isAllWinnerDevice()) {
AllwinnerCubeMdmManager.getInstance().setStatusBarEnable(false);
}
}
public void setCollapseOn(View view) {
// StatusBarManager mStatusBarManager = (StatusBarManager) getApplicationContext().getSystemService(Context.STATUS_BAR_SERVICE);
// mStatusBarManager.disable(StatusBarManager.DISABLE_EXPAND);
// mStatusBarManager.disable(StatusBarManager.DISABLE2_NOTIFICATION_SHADE);
Settings.Global.putInt(getContentResolver(), "PULLDOWN_MENU_ENABLED", 1);
}
public void setCollapseOff(View view) {
Settings.Global.putInt(getContentResolver(), "PULLDOWN_MENU_ENABLED", 0);
// StatusBarManager mStatusBarManager = (StatusBarManager) getApplicationContext().getSystemService(Context.STATUS_BAR_SERVICE);
// mStatusBarManager.disable(StatusBarManager.DISABLE_NONE);
// mStatusBarManager.disable(StatusBarManager.DISABLE2_NONE);
}
public void getHotspotStatus(View view) {
int aole_hotspot_forbid_on = Settings.System.getInt(getContentResolver(), "aole_hotspot_forbid_on", 0);
mViewDataBinding.btHotspotStatu.setText("状态:" + aole_hotspot_forbid_on);
}
public void setHotspotOn(View view) {
Settings.System.putInt(getContentResolver(), "aole_hotspot_forbid_on", 0);
if (JgyUtils.isAllWinnerDevice()) {
AllwinnerCubeMdmManager.getInstance().setWifiHotSpotStatus(0);
}
}
public void setHotspotOff(View view) {
Settings.System.putInt(getContentResolver(), "aole_hotspot_forbid_on", 1);
Intent intent = new Intent("aole_hotspot_close");
intent.setPackage("com.android.settings");
sendStickyBroadcast(intent);
if (JgyUtils.isAllWinnerDevice()) {
AllwinnerCubeMdmManager.getInstance().setWifiHotSpotStatus(1);
}
}
public void getBluetoothStatus(View view) {
int aole_bht_forbid_on = Settings.System.getInt(getContentResolver(), "aole_bht_forbid_on", 0);
mViewDataBinding.btBhtStatu.setText("状态:" + aole_bht_forbid_on);
}
public void setBhtOn(View view) {
Settings.System.putInt(getContentResolver(), "aole_bht_forbid_on", 0);
if (JgyUtils.isAllWinnerDevice()) {
AllwinnerCubeMdmManager.getInstance().setBluetoothEnable(true);
}
}
public void setBhtOff(View view) {
Settings.System.putInt(getContentResolver(), "aole_bht_forbid_on", 1);
if (JgyUtils.isAllWinnerDevice()) {
AllwinnerCubeMdmManager.getInstance().setBluetoothEnable(false);
}
}
public void setBtOn(View view) {
Settings.System.putInt(getContentResolver(), "aole_bt_forbid_on", 0);
}
public void setBtOff(View view) {
Settings.System.putInt(getContentResolver(), "aole_bt_forbid_on", 1);
}
public void setBhtvideoOn(View view) {
Settings.System.putInt(getContentResolver(), "aole_bhtvideo_forbid_on", 0);
}
public void setBhtvideoOff(View view) {
Settings.System.putInt(getContentResolver(), "aole_bhtvideo_forbid_on", 1);
}
public void getResetStatus(View view) {
int aole_restore_forbid_on = Settings.System.getInt(getContentResolver(), "aole_restore_forbid_on", 0);
mViewDataBinding.btResetStatu.setText("状态:" + aole_restore_forbid_on);
}
public void setResetOn(View view) {
Settings.System.putInt(getContentResolver(), "aole_restore_forbid_on", 0);
if (JgyUtils.isAllWinnerDevice()) {
AllwinnerCubeMdmManager.getInstance().setResetFactoryEnable(true);
}
}
public void setResetOff(View view) {
Settings.System.putInt(getContentResolver(), "aole_restore_forbid_on", 1);
if (JgyUtils.isAllWinnerDevice()) {
AllwinnerCubeMdmManager.getInstance().setResetFactoryEnable(false);
}
}
public void getMenuList(View view) {
String aole_restore_forbid_on = Settings.System.getString(getContentResolver(), "aole_settings_disallow");
mViewDataBinding.btMenuStatu.setText("列表:" + aole_restore_forbid_on);
Toaster.show(aole_restore_forbid_on);
}
private List<String> menuList = new ArrayList<String>() {{
this.add("wlan");
this.add("connected_devices");
this.add("apps");
this.add("notifications");
this.add("display");
this.add("sound");
this.add("storage");
this.add("battery");
this.add("wallpaper");
this.add("location");
this.add("system");
this.add("about");
}};
public void setMenuList(View view) {
Settings.System.putString(getContentResolver(), "aole_settings_disallow", String.join(",", menuList));
}
public void cleanMenuList(View view) {
Settings.System.putString(getContentResolver(), "aole_settings_disallow", "");
}
public void listInputMeth(View view) {
InputMethodManager imeManager = (InputMethodManager) getApplicationContext().getSystemService(INPUT_METHOD_SERVICE);
List<InputMethodInfo> InputMethods = imeManager.getEnabledInputMethodList();
Log.e(TAG, "onClick: " + InputMethods);
}
public void setInputBaidu(View view) {
Log.e(TAG, "init: " + getInputMethodId("com.baidu.input"));
Intent intent = new Intent("setDefaultInputMethod");
intent.putExtra("package", getInputMethodId("com.baidu.input"));
intent.setPackage("com.android.settings");
sendBroadcast(intent);
if (JgyUtils.isAllWinnerDevice()) {
AllwinnerCubeMdmManager.getInstance().setDefaultInputMethod(new ComponentName("com.baidu.input", "com.baidu.input.ImeService").toString());
}
}
public void setInputSogou(View view) {
Log.e(TAG, "init: " + getInputMethodId("com.sohu.inputmethod.sogou"));
Intent intent = new Intent("setDefaultInputMethod");
intent.putExtra("package", getInputMethodId("com.sohu.inputmethod.sogou"));
intent.setPackage("com.android.settings");
sendBroadcast(intent);
if (JgyUtils.isAllWinnerDevice()) {
AllwinnerCubeMdmManager.getInstance().setDefaultInputMethod(new ComponentName("com.sohu.inputmethod.sogou", "com.sohu.inputmethod.sogou.SogouIME").toString());
}
}
public void setInputGoogle(View view) {
Log.e(TAG, "init: " + getInputMethodId("com.google.android.inputmethod.pinyin"));
Intent intent = new Intent("setDefaultInputMethod");
intent.putExtra("package", getInputMethodId("com.google.android.inputmethod.pinyin"));
intent.setPackage("com.android.settings");
sendBroadcast(intent);
if (JgyUtils.isAllWinnerDevice()) {
AllwinnerCubeMdmManager.getInstance().setDefaultInputMethod(new ComponentName("com.google.android.inputmethod.pinyin", "com.google.android.inputmethod.pinyin.PinyinIME").toString());
}
}
public void setInputWetype(View view) {
Log.e(TAG, "init: " + getInputMethodId("com.tencent.wetype"));
Intent intent = new Intent("setDefaultInputMethod");
intent.putExtra("package", getInputMethodId("com.tencent.wetype"));
intent.setPackage("com.android.settings");
sendBroadcast(intent);
if (JgyUtils.isAllWinnerDevice()) {
AllwinnerCubeMdmManager.getInstance().setDefaultInputMethod(new ComponentName("com.tencent.wetype", "com.tencent.wetype.plugin.hld.WxHldService").toString());
}
}
public void openUrl(View view) {
Intent intent = new Intent();
intent.setAction("android.intent.action.VIEW");
Uri content_url = Uri.parse("https://www.baidu.com/");
intent.setData(content_url);
startActivity(intent);
}
public void setBrowserOn(View view) {
Intent intent = new Intent("setDefaultBrowser");
intent.putExtra("package", ("com.quark.browser"));
intent.setPackage("com.android.settings");
sendBroadcast(intent);
if (JgyUtils.isAllWinnerDevice()) {
AllwinnerCubeMdmManager.getInstance().setDefaultBrowser("com.quark.browser");
}
}
public void setBrowserOff(View view) {
Intent intent = new Intent("setDefaultBrowser");
intent.putExtra("package", ("com.android.chrome"));
intent.setPackage("com.android.settings");
sendBroadcast(intent);
if (JgyUtils.isAllWinnerDevice()) {
AllwinnerCubeMdmManager.getInstance().setDefaultBrowser("com.android.chrome");
}
}
public void getAppStatus(View view) {
Log.e("aole_network_disallow", "onClick: " + Settings.System.getString(getContentResolver(), "aole_network_disallow"));
}
public void setAppOn(View view) {
Settings.System.putString(getContentResolver(), "aole_network_disallow", "com.quark.browser");
List<String> appBlackNet = new ArrayList<>();
appBlackNet.add("com.quark.browser");
if (JgyUtils.isAllWinnerDevice()) {
AllwinnerCubeMdmManager.getInstance().setBlackNetApp(appBlackNet);
}
}
public void setAppOnDuo(View view) {
Settings.System.putString(getContentResolver(), "aole_network_disallow", "com.quark.browser");
List<String> appBlackNet = new ArrayList<>();
appBlackNet.add("com.quark.browser");
appBlackNet.add("com.tencent.mtt");
if (JgyUtils.isAllWinnerDevice()) {
AllwinnerCubeMdmManager.getInstance().setBlackNetApp(appBlackNet);
}
}
public void setAppOff(View view) {
Settings.System.putString(getContentResolver(), "aole_network_disallow", "");
if (JgyUtils.isAllWinnerDevice()) {
AllwinnerCubeMdmManager.getInstance().setBlackNetApp(new ArrayList<>());
}
}
public void setNightOn(View view) {
sendBroadcast(new Intent(NIGHT_DISPLAY_ENABLED));
}
public void setNightOff(View view) {
sendBroadcast(new Intent(NIGHT_DISPLAY_DISABLED));
}
public void setReadOn(View view) {
sendBroadcast(new Intent(READ_MODEL_ENABLED));
}
public void setReadOff(View view) {
sendBroadcast(new Intent(READ_MODEL_DISABLED));
}
public void addshortcut(View view) {
// addShortcut(DebugActivity.this, new Intent(
// DebugActivity.this, MainActivity.class), "TTUtilsTest", false,
// ((BitmapDrawable) getResources().getDrawable(R.drawable.ic_launcher)).getBitmap());
addShortCutCompact(DebugActivity.this);
}
public void addNoti(View view) {
sendSimpleNotification();
}
public void addNotiRand(View view) {
NotificationCompat.Builder builder = new NotificationCompat.Builder(DebugActivity.this, CHANNEL_ID)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle("应用中心正在运行")
// .setContentText("测试内容")
// .setAutoCancel(false)
.setShowWhen(false)
// .setOngoing(true)
.setOnlyAlertOnce(true)
.setPriority(NotificationCompat.PRIORITY_MIN);
// notificationId is a unique int for each notification that you must define
notificationManager.notify(new Random().nextInt(10000), builder.build());
}
public void notiOff(View view) {
Intent statusIntent = new Intent("aole_hide_appinfo");
sendBroadcast(statusIntent);
}
public void notiOn(View view) {
Intent statusIntent = new Intent("aole_show_appinfo");
sendBroadcast(statusIntent);
}
public void setNotiBlackList(View view) {
Settings.System.putString(getContentResolver(), "aole_app_info", BuildConfig.APPLICATION_ID);
Log.e("bt_noti_black", "onClick: " + Settings.System.getString(getContentResolver(), "aole_app_info"));
}
}
}

View File

@@ -23,6 +23,7 @@ import androidx.lifecycle.Observer;
import com.aoleyun.sn.BuildConfig;
import com.aoleyun.sn.R;
import com.aoleyun.sn.activity.InfoActivity;
import com.aoleyun.sn.activity.debug.DebugActivity;
import com.aoleyun.sn.activity.update.UpdateActivity;
import com.aoleyun.sn.base.mvvm.BaseMvvmActivity;
@@ -81,9 +82,15 @@ public class MainActivity extends BaseMvvmActivity<MainViewModel, ActivityMainBi
public void openOta(View view) {
JgyUtils.getInstance().openRomOta();
}
public void toDeviceInfo(View view) {
if ("DX11".equals(Build.MODEL)) {
startActivity(new Intent(MainActivity.this, InfoActivity.class));
}
}
}
final static int COUNTS = 3;// 点击次数
final static int COUNTS = 8;// 点击次数
final static long DURATION = 1000;// 规定有效时间
long[] mHits = new long[COUNTS];

View File

@@ -0,0 +1,17 @@
package com.aoleyun.sn.receiver;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
public class ShortcutReceiver extends BroadcastReceiver {
private static final String TAG = "ShortcutReceiver";
@Override
public void onReceive(Context context, Intent intent) {
Log.e(TAG, "onReceive: " + intent);
}
}

View File

@@ -10,6 +10,7 @@ import android.util.Log;
import com.aoleyun.sn.SystemInfoInterface;
import com.aoleyun.sn.comm.CommonConfig;
import com.aoleyun.sn.comm.JGYActions;
import com.aoleyun.sn.utils.JgyUtils;
import com.aoleyun.sn.utils.Utils;
import com.tencent.mmkv.MMKV;
@@ -60,6 +61,21 @@ public class RemoteService extends Service {
return state == 0;
}
@Override
public void killApplicationProcess(String packageName) throws RemoteException {
JgyUtils.getInstance().killPackage(packageName);
}
@Override
public void setDefaultLauncher(String packageName, String className) throws RemoteException {
}
@Override
public void setDefaultSystemLauncher() throws RemoteException {
}
// @Override
// public List<String> getHideIcon() throws RemoteException {
// List<String> hide = JgyUtils.getInstance().getHidePackage();

View File

@@ -1570,7 +1570,15 @@ public class Utils {
public static int getBattery(Context context) {
try {
BatteryManager batteryManager = (BatteryManager) context.getSystemService(Context.BATTERY_SERVICE);
return batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY);
if (batteryManager == null) {
return 0;
}
int capacity = batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY);
// -1 表示设备无法获取电量(无电池或底层未上报),归一到 0 避免下游误判
if (capacity < 0 || capacity > 100) {
return 0;
}
return capacity;
} catch (Exception e) {
Log.e("getBattery", "getBattery" + e.getMessage());
}