SmartisanOS 的 smartisanos.api 包下 API 大都不需要特殊权限即可调用,其中包含一些危险 API,任何应用都可以直接调用。

锤子,你的安全意识真的不太高啊.

获取顶部activity

    public static ComponentName getTopActivitySmartisan(Context context) {
        ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
        try {
            Class clazz = Class.forName("smartisanos.api.ActivityManagerSmt");
            Object obj = clazz.getMethod("getInstance").invoke(null);
            Method method = clazz.getMethod("getTopActivity", ActivityManager.class);
            return (ComponentName) method.invoke(obj, activityManager);
        } catch (Exception e) {
            return null;
        }
    } 

移除多任务卡片

    public static boolean removeTaskByPackageNameSmartisan(String packageName) {
        try {
            Class clazz = Class.forName("smartisanos.api.ActivityManagerSmt");
            Object obj = clazz.getMethod("getInstance").invoke(null);
            Method method = clazz.getMethod("removeTaskByPackageName", String.class);
            method.invoke(obj, packageName);
            return true;
        } catch (Exception e) {
            Log.e(Activity2.class.getName(), e.toString());
            return false;
        }
    }

设置 CPU 加速

    public static boolean setCpuBoost(int ms) {
        try {
            Class clazz = Class.forName("smartisanos.api.PerformanceSmt");
            Object obj = clazz.newInstance();
            Method method = clazz.getMethod("setCpuBoost", int.class);
            method.invoke(obj, ms);
            return true;
        } catch (Exception e) {
            return false;
        }
    }

    public static boolean releaseCpuBoost() {
        try {
            Class clazz = Class.forName("smartisanos.api.PerformanceSmt");
            Object obj = clazz.newInstance();
            Method method = clazz.getMethod("releaseCpuBoost");
            method.invoke(obj);
            return true;
        } catch (Exception e) {
            return false;
        }
    }