feat(aoleyuntest): 增加系统设置测试功能

- 替换 ToastUtil 为 Toaster
- 新增应用白名单、强制安装、开机自启等测试项
- 新增自动旋转、省电模式、设置菜单等开关测试
- 补充热点、蓝牙、恢复出厂状态查询
This commit is contained in:
2026-08-14 16:27:37 +08:00
parent b6ab76793f
commit cb5011ac56
5 changed files with 404 additions and 107 deletions

View File

@@ -25,6 +25,7 @@ import androidx.core.content.pm.ShortcutInfoCompat;
import androidx.core.content.pm.ShortcutManagerCompat;
import androidx.core.graphics.drawable.IconCompat;
import com.hjq.toast.Toaster;
import com.ttstd.ttutils.BuildConfig;
import com.ttstd.ttutils.R;
import com.ttstd.ttutils.activity.main.MainActivity;
@@ -34,7 +35,6 @@ import com.ttstd.ttutils.manager.AllwinnerCubeMdmManager;
import com.ttstd.ttutils.receiver.ShortcutReceiver;
import com.ttstd.ttutils.utils.java.ApkUtils;
import com.ttstd.ttutils.utils.java.JgyUtils;
import com.ttstd.ttutils.utils.java.ToastUtil;
import java.util.ArrayList;
import java.util.HashMap;
@@ -196,7 +196,7 @@ public class AoleyunTestActivity extends BaseMvvmActivity<AoleyunTestViewModel,
private void lazyExit() {
if (System.currentTimeMillis() - mPreClickTime > 5000) {
ToastUtil.show("再按一次,退出");
Toaster.show("再按一次,退出");
mPreClickTime = System.currentTimeMillis();
} else {
finish();
@@ -258,7 +258,7 @@ public class AoleyunTestActivity extends BaseMvvmActivity<AoleyunTestViewModel,
public void getUsbSettings(View view) {
String app_view_click_disabled = Settings.System.getString(getContentResolver(), "app_view_click_disabled");
ToastUtil.show(app_view_click_disabled);
Toaster.show(app_view_click_disabled);
}
public void setUsbCharge(View view) {
@@ -305,6 +305,64 @@ public class AoleyunTestActivity extends BaseMvvmActivity<AoleyunTestViewModel,
}
}
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();
}
@@ -396,6 +454,34 @@ public class AoleyunTestActivity extends BaseMvvmActivity<AoleyunTestViewModel,
}
}
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);
@@ -481,6 +567,11 @@ public class AoleyunTestActivity extends BaseMvvmActivity<AoleyunTestViewModel,
// 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()) {
@@ -498,6 +589,11 @@ public class AoleyunTestActivity extends BaseMvvmActivity<AoleyunTestViewModel,
}
}
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()) {
@@ -528,6 +624,11 @@ public class AoleyunTestActivity extends BaseMvvmActivity<AoleyunTestViewModel,
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()) {
@@ -542,6 +643,36 @@ public class AoleyunTestActivity extends BaseMvvmActivity<AoleyunTestViewModel,
}
}
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();

View File

@@ -18,8 +18,6 @@ import android.provider.Settings;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import com.jiaoguanyi.appstore.IGetLicenseInterface;
@@ -31,7 +29,6 @@ import com.ttstd.ttutils.R;
import com.ttstd.ttutils.utils.java.CmdUtil;
import com.ttstd.ttutils.utils.java.JgyUtils;
import com.ttstd.ttutils.utils.java.TTUtils;
import com.ttstd.ttutils.utils.java.ToastUtil;
import com.ttstd.ttutils.utils.jni.NDKTools;
import com.uiui.sn.IGetInfoInterface;

View File

@@ -15,7 +15,6 @@ import com.ttstd.ttutils.BuildConfig
import com.ttstd.ttutils.manager.AllwinnerCubeMdmManager
import com.ttstd.ttutils.utils.java.JgyUtils
import com.ttstd.ttutils.utils.java.TTUtils
import com.ttstd.ttutils.utils.java.ToastUtil
class KotlinApplication : Application() {

View File

@@ -1,100 +0,0 @@
package com.ttstd.ttutils.utils.java;
import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import android.widget.Toast;
import com.ttstd.ttutils.BuildConfig;
/**
* Created by tongtong on 2017/3/2.
*/
public class ToastUtil {
private static Handler mainHandler = new Handler(Looper.getMainLooper());
private static Toast toast;
private static Context mContext;
@SuppressLint("ShowToast")
public static void init(Context context) {
mContext = context;
toast = Toast.makeText(mContext, "", Toast.LENGTH_SHORT);
debugToast = Toast.makeText(mContext, "", Toast.LENGTH_SHORT);
}
private static long time1 = 0L;
private static long time2 = 0L;
public static void show(final String msg) {
mainHandler.post(new Runnable() {
@Override
public void run() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
time2 = System.currentTimeMillis();
if ((time2 - time1) > 3499) {
showToast(mContext, msg, Toast.LENGTH_LONG);
Log.e("fht", "LENGTH_LONG");
time1 = time2;
}
} else {
if (toast != null) {
toast.setText(msg);
toast.show();
}
}
}
});
}
private static Toast mToast = null;
//android 8.0以后限制
//https://www.jianshu.com/p/d9813ad03d59
//https://www.jianshu.com/p/050ce052b873
public static void showToast(Context context, String text, int duration) {
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.P) {
Toast.makeText(context, text, duration).show();
} else {
if (mToast == null) {
mToast = Toast.makeText(context, text, duration);
} else {
mToast.setText(text);
mToast.setDuration(duration);
}
mToast.show();
}
}
// public static void showInCenter(String msg) {
// mainHandler.post(() -> {
// if (toast != null) {
// toast.setGravity(Gravity.CENTER, 0, 0);
// toast.setText(msg);
// toast.show();
// }
// });
// }
static Handler debugHandler = new Handler(Looper.getMainLooper());
static Toast debugToast;
public static void debugShow(final String msg) {
mainHandler.post(new Runnable() {
@Override
public void run() {
if (BuildConfig.DEBUG) {
if (toast != null) {
toast.setText(msg);
toast.show();
}
}
}
});
}
}

View File

@@ -86,6 +86,158 @@
android:text="midi" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:visibility="visible">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="1"
android:text="应用白名单安装开关" />
<Button
android:id="@+id/btn_allow_install_app"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="@{click::getAllowAppInstallStatus}"
android:text="状态:" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="1"
android:onClick="@{click::setAllowAppInstallOn}"
android:singleLine="true"
android:text="on" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="@{click::setAllowAppInstallOff}"
android:text="off" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:visibility="visible">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="1"
android:text="应用安装白名单列表" />
<Button
android:id="@+id/btn_allow_install_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="@{click::getAllowInstallList}"
android:text="列表:" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="1"
android:onClick="@{click::setAllowAppInstallStatus}"
android:singleLine="true"
android:text="写入当前包名" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="@{click::cleanAllowAppInstallStatus}"
android:text="清空" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:visibility="visible">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="1"
android:text="强制安装应用" />
<Button
android:id="@+id/btn_force_install_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="@{click::getForceInstallList}"
android:text="列表:" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="1"
android:onClick="@{click::setForceAppInstallStatus}"
android:singleLine="true"
android:text="写入当前包名" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="@{click::cleanForceAppInstallStatus}"
android:text="清空" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:visibility="visible">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="1"
android:text="开机自启应用" />
<Button
android:id="@+id/btn_auto_run_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="@{click::getAutoRunAppList}"
android:text="列表:" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="1"
android:onClick="@{click::setAutoRunAppList}"
android:singleLine="true"
android:text="写入当前包名" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="@{click::cleanAutoRunAppList}"
android:text="清空" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -228,6 +380,80 @@
android:text="off" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:visibility="visible">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="自动旋转" />
<Button
android:id="@+id/bt_rotation_statu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="@{click::getAutoRotationStatus}"
android:text="状态:" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="1"
android:onClick="@{click::setAutoRotationOn}"
android:singleLine="true"
android:text="on" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="@{click::setAutoRotationOff}"
android:text="off" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:visibility="visible">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="省电模式开关" />
<Button
android:id="@+id/bt_battery_statu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="@{click::getBatterySaverStatus}"
android:text="状态:" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="1"
android:onClick="@{click::setBatterySaverOn}"
android:singleLine="true"
android:text="on" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="@{click::setBatterySaverOff}"
android:text="off" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -437,6 +663,7 @@
android:id="@+id/bt_hotspot_statu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="@{click::getHotspotStatus}"
android:layout_weight="1"
android:text="状态:" />
@@ -475,6 +702,7 @@
android:id="@+id/bt_bht_statu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="@{click::getBluetoothStatus}"
android:layout_weight="1"
android:text="状态:" />
@@ -555,6 +783,7 @@
android:id="@+id/bt_reset_statu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="@{click::getResetStatus}"
android:layout_weight="1"
android:text="状态:" />
@@ -577,6 +806,46 @@
android:text="off" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="1"
android:singleLine="true"
android:text="设置菜单开关" />
<Button
android:id="@+id/bt_menu_statu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="@{click::getMenuList}"
android:layout_weight="1"
android:text="状态:" />
<Button
android:id="@+id/bt_menu_on"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="1"
android:onClick="@{click::setMenuList}"
android:singleLine="true"
android:text="on" />
<Button
android:id="@+id/bt_menu_off"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="@{click::cleanMenuList}"
android:text="off" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -865,4 +1134,5 @@
</LinearLayout>
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>