簡體   English   中英

如何以編程方式啟用自動啟動和浮動 window 權限

[英]How to programmatically enable auto start and floating window permissions

  1. 如何以編程方式啟用自動啟動權限?
  2. 如何找到需要做自動啟動碼的手機?
  3. 如何檢查自動啟動權限是啟用還是禁用?

我只能找到有關具有canDrawOverlay()權限的顯示彈出權限的信息。

如果未啟用,我想為設備啟用自動啟動


我已經為小米找到了解決方案,榮譽和讓。

if(Build.BRAND.equalsIgnoreCase("xiaomi") ){

                Intent intent = new Intent();
                intent.setComponent(new ComponentName("com.miui.securitycenter", "com.miui.permcenter.autostart.AutoStartManagementActivity"));
                startActivity(intent);


            }else if(Build.BRAND.equalsIgnoreCase("Letv")){

                Intent intent = new Intent();
                intent.setComponent(new ComponentName("com.letv.android.letvsafe", "com.letv.android.letvsafe.AutobootManageActivity"));
                startActivity(intent);

            }
            else if(Build.BRAND.equalsIgnoreCase("Honor")){

                Intent intent = new Intent();
                intent.setComponent(new ComponentName("com.huawei.systemmanager", "com.huawei.systemmanager.optimize.process.ProtectActivity"));
                startActivity(intent);

            }

請檢查以下解決方案以啟用OPPOVIVO設備的floating windowautostart permission

無法確定是否啟用了自動啟動選項 您可以在Security permissions => Autostart => Enable Autostart下手動檢查。

在 Oppo 設備上:

  private void initOPPO() {
    try {

        Intent i = new Intent(Intent.ACTION_MAIN);
        i.setComponent(new ComponentName("com.oppo.safe", "com.oppo.safe.permission.floatwindow.FloatWindowListActivity"));
        startActivity(i);
    } catch (Exception e) {
        e.printStackTrace();
        try {

            Intent intent = new Intent("action.coloros.safecenter.FloatWindowListActivity");
            intent.setComponent(new ComponentName("com.coloros.safecenter", "com.coloros.safecenter.permission.floatwindow.FloatWindowListActivity"));
            startActivity(intent);
        } catch (Exception ee) {

            ee.printStackTrace();
            try{

                Intent i = new Intent("com.coloros.safecenter");
                i.setComponent(new ComponentName("com.coloros.safecenter", "com.coloros.safecenter.sysfloatwindow.FloatWindowListActivity"));
                startActivity(i);
            }catch (Exception e1){

                e1.printStackTrace();
            }
        }

    }
}

VIVO的自動啟動權限

 private static void autoLaunchVivo(Context context) {
    try {
        Intent intent = new Intent();
        intent.setComponent(new ComponentName("com.iqoo.secure",
                "com.iqoo.secure.ui.phoneoptimize.AddWhiteListActivity"));
        context.startActivity(intent);
    } catch (Exception e) {
        try {
            Intent intent = new Intent();
            intent.setComponent(new ComponentName("com.vivo.permissionmanager",
                    "com.vivo.permissionmanager.activity.BgStartUpManagerActivity"));
            context.startActivity(intent);
        } catch (Exception ex) {
            try {
                Intent intent = new Intent();
                intent.setClassName("com.iqoo.secure",
                        "com.iqoo.secure.ui.phoneoptimize.BgStartUpManager");
                context.startActivity(intent);
            } catch (Exception exx) {
                ex.printStackTrace();
            }
        }
    }
}

OPPO 自動啟動

 if (Build.MANUFACTURER.equalsIgnoreCase("oppo")) {
        try {
            Intent intent = new Intent();
            intent.setClassName("com.coloros.safecenter",
                    "com.coloros.safecenter.permission.startup.StartupAppListActivity");
            startActivity(intent);
        } catch (Exception e) {
            try {
                Intent intent = new Intent();
                intent.setClassName("com.oppo.safe",
                        "com.oppo.safe.permission.startup.StartupAppListActivity");
                startActivity(intent);

            } catch (Exception ex) {
                try {
                    Intent intent = new Intent();
                    intent.setClassName("com.coloros.safecenter",
                            "com.coloros.safecenter.startupapp.StartupAppListActivity");
                    startActivity(intent);
                } catch (Exception exx) {

                }
            }
        }
}

如果小米操作系統需要,自動啟動功能將在您從 Playstore 下載應用程序時自動啟用,因為亞馬遜、谷歌 IO 等應用程序也不允許自動啟動,在這種情況下,您必須轉到安全權限 -> 自動啟動 ->然后從那里啟用自動啟動。您不能通過代碼使應用程序自動啟動,您所能做的就是顯示一個對話框以啟用自動啟動並將用戶帶到自動啟動活動,但這不是一個好的選擇,因為您無法檢查自動啟動是否啟用與否。

這是由小米在 MIUI8 中完成的,以節省電池電量。

參考

可以參考文章MIUI8

使用這個助手類

 public class AutoStartHelper {

/***
 * Xiaomi
 */
private final String BRAND_XIAOMI = "xiaomi";
private String PACKAGE_XIAOMI_MAIN = "com.miui.securitycenter";
private String PACKAGE_XIAOMI_COMPONENT = "com.miui.permcenter.autostart.AutoStartManagementActivity";

/***
 * Letv
 */
private final String BRAND_LETV = "letv";
private String PACKAGE_LETV_MAIN = "com.letv.android.letvsafe";
private String PACKAGE_LETV_COMPONENT = "com.letv.android.letvsafe.AutobootManageActivity";

/***
 * ASUS ROG
 */
private final String BRAND_ASUS = "asus";
private String PACKAGE_ASUS_MAIN = "com.asus.mobilemanager";
private String PACKAGE_ASUS_COMPONENT = "com.asus.mobilemanager.powersaver.PowerSaverSettings";

/***
 * Honor
 */
private final String BRAND_HONOR = "honor";
private String PACKAGE_HONOR_MAIN = "com.huawei.systemmanager";
private String PACKAGE_HONOR_COMPONENT = "com.huawei.systemmanager.optimize.process.ProtectActivity";

/**
 * Oppo
 */
private final String BRAND_OPPO = "oppo";
private String PACKAGE_OPPO_MAIN = "com.coloros.safecenter";
private String PACKAGE_OPPO_FALLBACK = "com.oppo.safe";
private String PACKAGE_OPPO_COMPONENT = "com.coloros.safecenter.permission.startup.StartupAppListActivity";
private String PACKAGE_OPPO_COMPONENT_FALLBACK = "com.oppo.safe.permission.startup.StartupAppListActivity";
private String PACKAGE_OPPO_COMPONENT_FALLBACK_A = "com.coloros.safecenter.startupapp.StartupAppListActivity";

/**
 * Vivo
 */

private final String BRAND_VIVO = "vivo";
private String PACKAGE_VIVO_MAIN = "com.iqoo.secure";
private String PACKAGE_VIVO_FALLBACK = "com.vivo.perm;issionmanager";
private String PACKAGE_VIVO_COMPONENT = "com.iqoo.secure.ui.phoneoptimize.AddWhiteListActivity";
private String PACKAGE_VIVO_COMPONENT_FALLBACK = "com.vivo.permissionmanager.activity.BgStartUpManagerActivity";
private String PACKAGE_VIVO_COMPONENT_FALLBACK_A = "com.iqoo.secure.ui.phoneoptimize.BgStartUpManager";

/**
 * Nokia
 */

private final String BRAND_NOKIA = "nokia";
private String PACKAGE_NOKIA_MAIN = "com.evenwell.powersaving.g3";
private String PACKAGE_NOKIA_COMPONENT = "com.evenwell.powersaving.g3.exception.PowerSaverExceptionActivity";


private AutoStartHelper() {
}

public static AutoStartHelper getInstance() {
    return new AutoStartHelper();
}


public void getAutoStartPermission(Context context) {

    String build_info = Build.BRAND.toLowerCase();
    switch (build_info) {
        case BRAND_ASUS:
            autoStartAsus(context);
            break;
        case BRAND_XIAOMI:
            autoStartXiaomi(context);
            break;
        case BRAND_LETV:
            autoStartLetv(context);
            break;
        case BRAND_HONOR:
            autoStartHonor(context);
            break;
        case BRAND_OPPO:
            autoStartOppo(context);
            break;
        case BRAND_VIVO:
            autoStartVivo(context);
            break;
        case BRAND_NOKIA:
            autoStartNokia(context);
            break;

    }

}

private void autoStartAsus(final Context context) {
    if (isPackageExists(context, PACKAGE_ASUS_MAIN)) {

        showAlert(context, (dialog, which) -> {
            try {
            PrefUtil.writeBoolean(context, PrefUtil.PREF_KEY_APP_AUTO_START, true);
                startIntent(context, PACKAGE_ASUS_MAIN, PACKAGE_ASUS_COMPONENT);
            } catch (Exception e) {
                e.printStackTrace();
            }
            dialog.dismiss();
        });

    }


}

private void showAlert(Context context, DialogInterface.OnClickListener onClickListener) {

    new AlertDialog.Builder(context).setTitle("Allow AutoStart")
            .setMessage("Please enable auto start in settings.")
            .setPositiveButton("Allow", onClickListener).show().setCancelable(false);
}

private void autoStartXiaomi(final Context context) {
    if (isPackageExists(context, PACKAGE_XIAOMI_MAIN)) {
        showAlert(context, (dialog, which) -> {
            try {
                PrefUtil.writeBoolean(context, PrefUtil.PREF_KEY_APP_AUTO_START, true);
                startIntent(context, PACKAGE_XIAOMI_MAIN, PACKAGE_XIAOMI_COMPONENT);
            } catch (Exception e) {
                e.printStackTrace();
            }
        });


    }
}

private void autoStartLetv(final Context context) {
    if (isPackageExists(context, PACKAGE_LETV_MAIN)) {
        showAlert(context, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {

                try {
                    PrefUtil.writeBoolean(context, PrefUtil.PREF_KEY_APP_AUTO_START, true);
                    startIntent(context, PACKAGE_LETV_MAIN, PACKAGE_LETV_COMPONENT);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });


    }
}


private void autoStartHonor(final Context context) {
    if (isPackageExists(context, PACKAGE_HONOR_MAIN)) {
        showAlert(context, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {

                try {
                    PrefUtil.writeBoolean(context, PrefUtil.PREF_KEY_APP_AUTO_START, true);
                    startIntent(context, PACKAGE_HONOR_MAIN, PACKAGE_HONOR_COMPONENT);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });


    }
}

private void autoStartOppo(final Context context) {
    if (isPackageExists(context, PACKAGE_OPPO_MAIN) || isPackageExists(context, PACKAGE_OPPO_FALLBACK)) {
        showAlert(context, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {

                try {
                    PrefUtil.writeBoolean(context, PrefUtil.PREF_KEY_APP_AUTO_START, true);
                    startIntent(context, PACKAGE_OPPO_MAIN, PACKAGE_OPPO_COMPONENT);
                } catch (Exception e) {
                    e.printStackTrace();
                    try {
                        PrefUtil.writeBoolean(context, PrefUtil.PREF_KEY_APP_AUTO_START, true);
                        startIntent(context, PACKAGE_OPPO_FALLBACK, PACKAGE_OPPO_COMPONENT_FALLBACK);
                    } catch (Exception ex) {
                        ex.printStackTrace();
                        try {
                            PrefUtil.writeBoolean(context, PrefUtil.PREF_KEY_APP_AUTO_START, true);
                            startIntent(context, PACKAGE_OPPO_MAIN, PACKAGE_OPPO_COMPONENT_FALLBACK_A);
                        } catch (Exception exx) {
                            exx.printStackTrace();
                        }

                    }

                }
            }
        });


    }
}

private void autoStartVivo(final Context context) {
    if (isPackageExists(context, PACKAGE_VIVO_MAIN) || isPackageExists(context, PACKAGE_VIVO_FALLBACK)) {
        showAlert(context, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {

                try {
                    PrefUtil.writeBoolean(context, PrefUtil.PREF_KEY_APP_AUTO_START, true);
                    startIntent(context, PACKAGE_VIVO_MAIN, PACKAGE_VIVO_COMPONENT);
                } catch (Exception e) {
                    e.printStackTrace();
                    try {
                        PrefUtil.writeBoolean(context, PrefUtil.PREF_KEY_APP_AUTO_START, true);
                        startIntent(context, PACKAGE_VIVO_FALLBACK, PACKAGE_VIVO_COMPONENT_FALLBACK);
                    } catch (Exception ex) {
                        ex.printStackTrace();
                        try {
                            PrefUtil.writeBoolean(context, PrefUtil.PREF_KEY_APP_AUTO_START, true);
                            startIntent(context, PACKAGE_VIVO_MAIN, PACKAGE_VIVO_COMPONENT_FALLBACK_A);
                        } catch (Exception exx) {
                            exx.printStackTrace();
                        }

                    }

                }

            }
        });
    }
}

private void autoStartNokia(final Context context) {
    if (isPackageExists(context, PACKAGE_NOKIA_MAIN)) {
        showAlert(context, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {

                try {
                    PrefUtil.writeBoolean(context, PrefUtil.PREF_KEY_APP_AUTO_START, true);
                    startIntent(context, PACKAGE_NOKIA_MAIN, PACKAGE_NOKIA_COMPONENT);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }
}


private void startIntent(Context context, String packageName, String componentName) throws Exception {
    try {
        Intent intent = new Intent();
        intent.setComponent(new ComponentName(packageName, componentName));
        context.startActivity(intent);
    } catch (Exception var5) {
        var5.printStackTrace();
        throw var5;
    }
}

private Boolean isPackageExists(Context context, String targetPackage) {
    List<ApplicationInfo> packages;
    PackageManager pm = context.getPackageManager();
    packages = pm.getInstalledApplications(0);
    for (ApplicationInfo packageInfo :
            packages) {
        if (packageInfo.packageName.equals(targetPackage)) {
            return true;
        }
    }

    return false;
 }
}

在你的活動中

 AutoStartHelper.getInstance().getAutoStartPermission(this);

無法跟蹤我們是否啟用了自動啟動。

正如其他人所說,無法確定是否啟用了自動啟動選項,但我們可以使用意圖將用戶重定向到自動啟動設置。 然后由用戶決定是否允許。

我們可以使用ACTION_APPLICATION_DETAILS_SETTINGSACTION_MANAGE_APPLICATIONS_SETTINGS標志直接重定向到自動啟動設置屏幕。

我已經在小米OPPO手機上對此進行了測試,我相信此代碼也適用於其他自定義 UI 設備,如 Vivo 等。

單擊一個彈出對話框,上面寫着請從應用程序設置屏幕檢查並啟用自動啟動選項。 將下面的代碼放在單擊“確定”按鈕上。

  try
    {
        //Open the specific App Info page:
        Intent intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
        intent.setData(Uri.parse("package:" + context.getPackageName()));
        context.startActivity(intent);
    }
    catch ( ActivityNotFoundException e )
    {
        //Open the generic Apps page:
        Intent intent = new Intent(android.provider.Settings.ACTION_MANAGE_APPLICATIONS_SETTINGS);
        context.startActivity(intent);
    }

我找到了一種方法來檢查是否在 MIUI 10 和 11 中以編程方式啟用了自動啟動權限。

https://github.com/XomaDev/autostart

https://github.com/XomaDev/autostart

在 MIUI 10 和 11 上,我發現了一個管理 MI 自動啟動權限的公共類。

private Object isAutoStartEnabled(Activity activity, String packageName) throws Exception {
        Class<?> clazz;
        try {
            clazz = Class.forName(CLAZZ);
        } catch (ClassNotFoundException ignored) {
            // we don't know if its enabled, class
            // is not found
            return false;
        }
        Method method = getMethod(clazz);
        if (method == null) {
            return false;
        }
        method.setAccessible(true);

        // the target object is null, because the
        // method is static
        Object result = method.invoke(null, activity, packageName);
        if (!(result instanceof Integer))
            throw new Exception();
        return (int) result == ENABLED;
    }

這是手機更改應用程序權限的類。

該類允許檢查權限是否通過靜態定義的方法啟用,而更改自動啟動權限要求它是系統應用程序。

調用該方法時,它會相應地返回 0 和 1,其中 0 表示“自動啟動啟用狀態”。

在 MIUI 10 和 11 上做了一些測試,效果很好。 12日,仍然是手機管理權限的類,但令人驚訝的是,通過反射看到所有方法都隱藏了。

kotlin中的更新版本

/**
 * To request AutoStart permission based on [Brand].
 */
@Singleton
class AutoStartPermissionManager @Inject constructor(
    @ApplicationContext private val _context: Context
) {

    /**
     * Request AutoStart permission based on [Brand] type.
     * Note-> No permission required for [Brand.OTHER].
     */
    fun requestAutoStartPermission() {
        when (Build.BRAND.uppercase().toEnum(Brand::name, Brand.OTHER)) {
            Brand.XIAOMI, Brand.REDMI -> xiaomiAutoStart()
            Brand.NOKIA -> nokiaAutoStart()
            Brand.LETV -> letvAutoStart()
            Brand.ASUS -> asusAutoStart()
            Brand.HONOR -> honorAutoStart()
            Brand.OPPO -> oppoAutoStart()
            Brand.VIVO -> vivoAutoStart()
            Brand.OTHER -> {}
        }
    }

    /**
     * Request AutoStart permission for [Brand.XIAOMI] and [Brand.REDMI].
     */
    private fun xiaomiAutoStart() {
        if (isPackageExists(XIAOMI_MAIN)) {
            try {
                startAutoStartActivity(_context, XIAOMI_MAIN, XIAOMI_COMPONENT)

            } catch (e: BAExceptions.ActivityNotFound) {
                Logger.error(e, message = e.msg)
            }
        }
    }

    @Throws(BAExceptions::class)
    private fun startAutoStartActivity(context: Context, packageName: String, componentName: String) {
        val intentAutoStartPage = Intent().apply {
            component = ComponentName(packageName, componentName)
            flags = Intent.FLAG_ACTIVITY_NEW_TASK
        }
        try {
            context.startActivity(intentAutoStartPage)
        } catch (e: Exception) {
            throw BAExceptions.ActivityNotFound
        }
    }

    /**
     * Request AutoStart permission for [Brand.NOKIA].
     */
    private fun nokiaAutoStart() {
        if (isPackageExists(NOKIA_MAIN)) {
            try {
                startAutoStartActivity(_context, NOKIA_MAIN, NOKIA_COMPONENT)

            } catch (e: BAExceptions.ActivityNotFound) {
                Logger.error(e, message = e.msg)
            }
        }
    }

    /**
     * Request AutoStart permission for [Brand.LETV].
     */
    private fun letvAutoStart() {
        if (isPackageExists(LETV_MAIN)) {
            try {
                startAutoStartActivity(_context, LETV_MAIN, LETV_COMPONENT)

            } catch (e: BAExceptions.ActivityNotFound) {
                Logger.error(e, message = e.msg)
            }
        }
    }

    /**
     * Request AutoStart permission for [Brand.ASUS].
     */
    private fun asusAutoStart() {
        if (isPackageExists(ASUS_MAIN)) {
            try {
                startAutoStartActivity(_context, ASUS_MAIN, ASUS_COMPONENT)

            } catch (e: BAExceptions.ActivityNotFound) {
                Logger.error(e, message = e.msg)
            }
        }
    }

    /**
     * Request AutoStart permission for [Brand.HONOR].
     */
    private fun honorAutoStart() {
        if (isPackageExists(HONOR_MAIN)) {
            try {
                startAutoStartActivity(_context, HONOR_MAIN, HONOR_COMPONENT)

            } catch (e: BAExceptions.ActivityNotFound) {
                Logger.error(e, message = e.msg)
            }
        }
    }

    /**
     * Request AutoStart permission for [Brand.OPPO].
     */
    private fun oppoAutoStart() {
        if (isPackageExists(OPPO_MAIN) || isPackageExists(OPPO_FALLBACK)) {
            try {
                startAutoStartActivity(_context, OPPO_MAIN, OPPO_COMPONENT)

            } catch (e: BAExceptions.ActivityNotFound) {
                Logger.error(e, message = e.msg)

                try {
                    startAutoStartActivity(_context, OPPO_FALLBACK, OPPO_COMPONENT_FALLBACK)

                } catch (ex: BAExceptions.ActivityNotFound) {
                    Logger.error(ex, message = ex.msg)

                    try {
                        startAutoStartActivity(_context, OPPO_MAIN, OPPO_COMPONENT_FALLBACK_A)

                    } catch (exx: BAExceptions.ActivityNotFound) {
                        Logger.error(exx, message = exx.msg)
                    }
                }
            }
        }
    }

    /**
     * Request AutoStart permission for [Brand.VIVO].
     */
    private fun vivoAutoStart() {
        if (isPackageExists(VIVO_MAIN) || isPackageExists(VIVO_FALLBACK)) {
            try {
                startAutoStartActivity(_context, VIVO_MAIN, VIVO_COMPONENT)

            } catch (e: BAExceptions.ActivityNotFound) {
                Logger.error(e, message = e.msg)

                try {
                    startAutoStartActivity(_context, VIVO_FALLBACK, VIVO_COMPONENT_FALLBACK)

                } catch (ex: BAExceptions.ActivityNotFound) {
                    Logger.error(ex, message = ex.msg)

                    try {
                        startAutoStartActivity(_context, VIVO_MAIN, VIVO_COMPONENT_FALLBACK_A)

                    } catch (exx: BAExceptions.ActivityNotFound) {
                        Logger.error(exx, message = exx.msg)
                    }
                }
            }
        }
    }

    /**
     * Return true if requested package exist false otherwise.
     */
    private fun isPackageExists(targetPackage: String): Boolean {
        val packages = _context.packageManager.getInstalledApplications(0)
        for (packageInfo in packages) {
            if (packageInfo.packageName.equals(targetPackage)) return true
        }

        return false
    }

    /**
     * Type of brands for which we can request AutoStart permission.
     * Note-> No permission required for [Brand.OTHER].
     */
    private enum class Brand {
        REDMI,
        XIAOMI,
        NOKIA,
        LETV,
        ASUS,
        HONOR,
        OPPO,
        VIVO,
        OTHER
    }

    /**
     * All [Brand] packages using this we can request AutoStart permission.
     */
    private companion object BrandPackage {

        // Xiaomi
        private val XIAOMI_MAIN = "com.miui.securitycenter"
        private val XIAOMI_COMPONENT = "com.miui.permcenter.autostart.AutoStartManagementActivity"

        // Nokia
        private val NOKIA_MAIN = "com.evenwell.powersaving.g3"
        private val NOKIA_COMPONENT = "com.evenwell.powersaving.g3.exception.PowerSaverExceptionActivity"

        // Letv
        private val LETV_MAIN = "com.letv.android.letvsafe"
        private val LETV_COMPONENT = "com.letv.android.letvsafe.AutobootManageActivity"

        // ASUS ROG
        private val ASUS_MAIN = "com.asus.mobilemanager"
        private val ASUS_COMPONENT = "com.asus.mobilemanager.powersaver.PowerSaverSettings"

        // Honor
        private val HONOR_MAIN = "com.huawei.systemmanager"
        private val HONOR_COMPONENT = "com.huawei.systemmanager.optimize.process.ProtectActivity"

        // Oppo
        private val OPPO_MAIN = "com.coloros.safecenter"
        private val OPPO_FALLBACK = "com.oppo.safe"
        private val OPPO_COMPONENT = "com.coloros.safecenter.permission.startup.StartupAppListActivity"
        private val OPPO_COMPONENT_FALLBACK = "com.oppo.safe.permission.startup.StartupAppListActivity"
        private val OPPO_COMPONENT_FALLBACK_A = "com.coloros.safecenter.startupapp.StartupAppListActivity"

        // Vivo
        private val VIVO_MAIN = "com.iqoo.secure"
        private val VIVO_FALLBACK = "com.vivo.permissionmanager"
        private val VIVO_COMPONENT = "com.iqoo.secure.ui.phoneoptimize.AddWhiteListActivity"
        private val VIVO_COMPONENT_FALLBACK = "com.vivo.permissionmanager.activity.BgStartUpManagerActivity"
        private val VIVO_COMPONENT_FALLBACK_A = "com.iqoo.secure.ui.phoneoptimize.BgStartUpManager"
    }
}

輔助擴展 function

inline fun <reified T : Enum<T>> String.toEnum(value: (T) -> String, def: T): T {
    return enumValues<T>().firstOrNull { value(it) == this } ?: def
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM