diff --git a/app/build.gradle b/app/build.gradle index 630ddb7..d2c1c46 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -18,8 +18,8 @@ android { defaultConfig { applicationId "com.aoleyun.sn" - versionCode 233 - versionName "1.6.0805" + versionCode 235 + versionName "1.6.0815" //There are no CERT files because If the mini sdk version is 23+, the AGP will ignore the V1 scheme signature. minSdkVersion 24 @@ -745,6 +745,8 @@ android { } dependencies { + + // implementation fileTree(dir: "libs", include: ["*.jar"]) compileOnly files('libs/framework.jar') compileOnly files('libs/cube_mdm.jar') @@ -770,6 +772,7 @@ dependencies { implementation 'androidx.appcompat:appcompat:1.3.1' implementation 'androidx.constraintlayout:constraintlayout:2.0.4' implementation "androidx.lifecycle:lifecycle-service:2.3.1" + implementation 'androidx.activity:activity-ktx:1.2.2' // CameraX 核心库及生命周期绑定 def camerax_version = "1.0.0" // 请根据实际情况选择稳定版本 @@ -812,6 +815,7 @@ dependencies { implementation 'com.google.code.gson:gson:2.9.0' implementation 'com.google.zxing:core:3.5.0' implementation 'com.google.mlkit:face-detection:16.1.5' + implementation 'com.google.android.material:material:1.0.5' //图片加载框架 implementation 'com.github.bumptech.glide:glide:4.13.2' diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 55611ac..514ee4c 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -45,72 +45,45 @@ android:maxSdkVersion="22" /> - + android:maxSdkVersion="23" /> - - + - + tools:ignore="ProtectedPermissions" /> - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - + - - + - @@ -129,41 +102,11 @@ - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -203,13 +148,14 @@ android:label="一键加速" android:launchMode="singleInstance" android:theme="@style/activity_styles"> - - - - + + + + + + - - + android:launchMode="singleInstance" + android:taskAffinity="com.aoleyun.sn.warning" + android:theme="@style/TransparentActivity" /> - - - @@ -332,7 +274,7 @@ - + @@ -383,27 +325,19 @@ - - - + - - + android:process=":location" /> - - + android:process=":trace" /> - - + android:required="false" /> @@ -435,21 +369,15 @@ - - - + android:value="CjFhFE1UP5G14tMBz1kWs7ca92bgHuLr" /> - - + android:value="333598267" /> - diff --git a/app/src/main/aidl/com/aoleyun/sn/SystemInfoInterface.aidl b/app/src/main/aidl/com/aoleyun/sn/SystemInfoInterface.aidl index f2d0836..a8f0c04 100644 --- a/app/src/main/aidl/com/aoleyun/sn/SystemInfoInterface.aidl +++ b/app/src/main/aidl/com/aoleyun/sn/SystemInfoInterface.aidl @@ -14,4 +14,7 @@ interface SystemInfoInterface { String getSerial(); boolean isDeviceLocked(); boolean isBrowserInput(); -} + void killApplicationProcess(String packageName); + void setDefaultLauncher(String packageName, String className); + void setDefaultSystemLauncher(); +} \ No newline at end of file diff --git a/app/src/main/java/com/aoleyun/sn/activity/InfoActivity.java b/app/src/main/java/com/aoleyun/sn/activity/InfoActivity.java new file mode 100644 index 0000000..772d547 --- /dev/null +++ b/app/src/main/java/com/aoleyun/sn/activity/InfoActivity.java @@ -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(); + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/aoleyun/sn/activity/debug/DebugActivity.java b/app/src/main/java/com/aoleyun/sn/activity/debug/DebugActivity.java index a44d506..c76356f 100644 --- a/app/src/main/java/com/aoleyun/sn/activity/debug/DebugActivity.java +++ b/app/src/main/java/com/aoleyun/sn/activity/debug/DebugActivity.java @@ -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 { 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 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 InputMethods = imeManager.getInputMethodList(); + Map 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 menuList = new ArrayList() {{ + 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 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 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 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")); + } + } + } diff --git a/app/src/main/java/com/aoleyun/sn/activity/main/MainActivity.java b/app/src/main/java/com/aoleyun/sn/activity/main/MainActivity.java index 8baa1ef..f6bb1e7 100644 --- a/app/src/main/java/com/aoleyun/sn/activity/main/MainActivity.java +++ b/app/src/main/java/com/aoleyun/sn/activity/main/MainActivity.java @@ -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 getHideIcon() throws RemoteException { // List hide = JgyUtils.getInstance().getHidePackage(); diff --git a/app/src/main/java/com/aoleyun/sn/utils/Utils.java b/app/src/main/java/com/aoleyun/sn/utils/Utils.java index 9f8e9c9..c530567 100644 --- a/app/src/main/java/com/aoleyun/sn/utils/Utils.java +++ b/app/src/main/java/com/aoleyun/sn/utils/Utils.java @@ -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()); } diff --git a/app/src/main/res/drawable/bg_dialog.xml b/app/src/main/res/drawable/bg_dialog.xml index 64427cc..3bfd5cd 100644 --- a/app/src/main/res/drawable/bg_dialog.xml +++ b/app/src/main/res/drawable/bg_dialog.xml @@ -5,5 +5,5 @@ android:width="0.8dp" android:color="#ffffff" /> - + diff --git a/app/src/main/res/drawable/dialog_background.xml b/app/src/main/res/drawable/dialog_background.xml index eaf60cf..3bfd5cd 100644 --- a/app/src/main/res/drawable/dialog_background.xml +++ b/app/src/main/res/drawable/dialog_background.xml @@ -5,5 +5,5 @@ android:width="0.8dp" android:color="#ffffff" /> - + diff --git a/app/src/main/res/drawable/update_background.xml b/app/src/main/res/drawable/update_background.xml index b904dbe..4880cea 100644 --- a/app/src/main/res/drawable/update_background.xml +++ b/app/src/main/res/drawable/update_background.xml @@ -3,11 +3,11 @@ - + + android:bottom="@dimen/dp_6" + android:left="@dimen/dp_24" + android:right="@dimen/dp_24" + android:top="@dimen/dp_6" /> \ No newline at end of file diff --git a/app/src/main/res/drawable/update_cancel_background.xml b/app/src/main/res/drawable/update_cancel_background.xml index 58247be..513010c 100644 --- a/app/src/main/res/drawable/update_cancel_background.xml +++ b/app/src/main/res/drawable/update_cancel_background.xml @@ -3,11 +3,11 @@ - + + android:bottom="@dimen/dp_6" + android:left="@dimen/dp_24" + android:right="@dimen/dp_24" + android:top="@dimen/dp_6" /> \ No newline at end of file diff --git a/app/src/main/res/layout/activity_app_update.xml b/app/src/main/res/layout-land/activity_app_update.xml similarity index 82% rename from app/src/main/res/layout/activity_app_update.xml rename to app/src/main/res/layout-land/activity_app_update.xml index 649612f..0f0c363 100644 --- a/app/src/main/res/layout/activity_app_update.xml +++ b/app/src/main/res/layout-land/activity_app_update.xml @@ -24,7 +24,7 @@ android:layout_height="match_parent"> @@ -73,8 +73,8 @@ @@ -111,10 +111,10 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" - android:layout_marginTop="8dp" + android:layout_marginTop="@dimen/dp_8" android:text="@{`V`+appInfo.version_name}" android:textColor="@color/contact_text_color" - android:textSize="16sp" /> + android:textSize="@dimen/sp_9" /> @@ -122,14 +122,14 @@ android:id="@+id/linearLayout3" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginBottom="32dp" + android:layout_marginBottom="@dimen/dp_16" app:layout_constraintBottom_toBottomOf="parent"> @@ -146,7 +146,7 @@ android:id="@+id/positive" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginStart="24dp" + android:layout_marginStart="@dimen/dp_24" android:layout_weight="1" android:background="@drawable/update_background" android:gravity="center" @@ -154,7 +154,7 @@ android:singleLine="true" android:text="更新" android:textColor="@color/white" - android:textSize="16sp" + android:textSize="@dimen/sp_9" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" diff --git a/app/src/main/res/layout-land/activity_main.xml b/app/src/main/res/layout-land/activity_main.xml index edc88c6..7c21e97 100644 --- a/app/src/main/res/layout-land/activity_main.xml +++ b/app/src/main/res/layout-land/activity_main.xml @@ -27,7 +27,6 @@ @@ -39,6 +38,7 @@ android:layout_marginStart="@dimen/dp_4" android:adjustViewBounds="true" android:scaleType="centerCrop" + android:onClick="@{click::exit}" android:src="@drawable/bt_return" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent" @@ -347,6 +347,7 @@ diff --git a/app/src/main/res/layout/update_dialog.xml b/app/src/main/res/layout-land/update_dialog.xml similarity index 97% rename from app/src/main/res/layout/update_dialog.xml rename to app/src/main/res/layout-land/update_dialog.xml index d3796f6..38b07eb 100644 --- a/app/src/main/res/layout/update_dialog.xml +++ b/app/src/main/res/layout-land/update_dialog.xml @@ -7,11 +7,11 @@ android:orientation="vertical"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout-port/activity_main.xml b/app/src/main/res/layout-port/activity_main.xml index 230ba40..3f69203 100644 --- a/app/src/main/res/layout-port/activity_main.xml +++ b/app/src/main/res/layout-port/activity_main.xml @@ -39,7 +39,6 @@ @@ -51,6 +50,7 @@ android:layout_marginStart="@dimen/dp_4" android:adjustViewBounds="true" android:scaleType="centerCrop" + android:onClick="@{click::exit}" android:src="@drawable/bt_return" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent" @@ -360,6 +360,7 @@ + + + + + + + + + + +