From 907c1b0f49049d9a7ec2694b96d8ef3d37d66589 Mon Sep 17 00:00:00 2001 From: Babu Madhikarmi Date: Wed, 19 Aug 2020 18:17:36 +0200 Subject: [PATCH 1/2] Added support for Oppo Rx17 Neo and Pro. These devices have none of the packages lists as the Auto Start switch is within the app info screen. Sadly I can't make it highlight the "Auto Start" switch row but we can take the user there at least. Device info: Oppo Rx17 Neo (CPH1893) Rx17 Pro (CPH1877), Color OS 5.2 (Android 8.1). Should also work on versions above but only checked on Neo, CPH1893EX_11_A.16. Firmware links: https://oppo-uk.custhelp.com/app/software_update_detail/p_name/RX17%20Neo https://oppo-uk.custhelp.com/app/software_update_detail/p_name/RX17%20Pro --- .../autostarter/AutoStartPermissionHelper.kt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/autostarter/src/main/java/com/judemanutd/autostarter/AutoStartPermissionHelper.kt b/autostarter/src/main/java/com/judemanutd/autostarter/AutoStartPermissionHelper.kt index 6d2ea13..43a3fee 100644 --- a/autostarter/src/main/java/com/judemanutd/autostarter/AutoStartPermissionHelper.kt +++ b/autostarter/src/main/java/com/judemanutd/autostarter/AutoStartPermissionHelper.kt @@ -4,7 +4,9 @@ import android.content.ComponentName import android.content.Context import android.content.Intent import android.content.pm.ApplicationInfo +import android.net.Uri import android.os.Build +import android.provider.Settings import java.util.* class AutoStartPermissionHelper private constructor() { @@ -56,6 +58,9 @@ class AutoStartPermissionHelper private constructor() { private val PACKAGE_OPPO_COMPONENT = "com.coloros.safecenter.permission.startup.StartupAppListActivity" private val PACKAGE_OPPO_COMPONENT_FALLBACK = "com.oppo.safe.permission.startup.StartupAppListActivity" private val PACKAGE_OPPO_COMPONENT_FALLBACK_A = "com.coloros.safecenter.startupapp.StartupAppListActivity" + private val OPPO_AUTOSTART_IN_APP_INFO_SUPPORTED_DEVICES = arrayOf( + "CPH1893", "CPH1877" //Rx17 Neo, Rx17 Pro + ) /** * Vivo @@ -94,7 +99,6 @@ class AutoStartPermissionHelper private constructor() { PACKAGE_OPPO_FALLBACK, PACKAGE_VIVO_MAIN, PACKAGE_VIVO_FALLBACK, PACKAGE_NOKIA_MAIN, PACKAGE_HUAWEI_MAIN, PACKAGE_SAMSUNG_MAIN, PACKAGE_ONE_PLUS_MAIN) fun getAutoStartPermission(context: Context): Boolean { - when (Build.BRAND.toLowerCase(Locale.getDefault())) { BRAND_ASUS -> return autoStartAsus(context) @@ -240,6 +244,13 @@ class AutoStartPermissionHelper private constructor() { } } } + } else if (OPPO_AUTOSTART_IN_APP_INFO_SUPPORTED_DEVICES.contains(Build.DEVICE) + || OPPO_AUTOSTART_IN_APP_INFO_SUPPORTED_DEVICES.contains(Build.PRODUCT)) { + val i = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS) + i.addCategory(Intent.CATEGORY_DEFAULT) + i.data = Uri.parse("package:${context.packageName}") + context.startActivity(i) + return true } else { return false } From 120e41b527894882747757b6feb32f59c0e992ea Mon Sep 17 00:00:00 2001 From: Babu Madhikarmi Date: Fri, 21 Aug 2020 17:37:26 +0200 Subject: [PATCH 2/2] Color OS 5.2+ now requires oppo.permission.OPPO_COMPONENT_SAFE to launch StartupAppListActivity. However Allow auto start switch is available in app info section. Therefore we fallback to this. Received confirmation allow auto start exists in ColorOS 6.0.1 so can treat as a forward trend and no longer gate by device. Tested on ColorOS 5.2 Rx17 (neo CPH1893, pro CPH1877) and Color OS 6.0.1 (A1k CPH1923) https://github.com/judemanutd/AutoStarter/issues/14#issuecomment-678341935 --- .../autostarter/AutoStartPermissionHelper.kt | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/autostarter/src/main/java/com/judemanutd/autostarter/AutoStartPermissionHelper.kt b/autostarter/src/main/java/com/judemanutd/autostarter/AutoStartPermissionHelper.kt index 43a3fee..a5b1304 100644 --- a/autostarter/src/main/java/com/judemanutd/autostarter/AutoStartPermissionHelper.kt +++ b/autostarter/src/main/java/com/judemanutd/autostarter/AutoStartPermissionHelper.kt @@ -58,9 +58,6 @@ class AutoStartPermissionHelper private constructor() { private val PACKAGE_OPPO_COMPONENT = "com.coloros.safecenter.permission.startup.StartupAppListActivity" private val PACKAGE_OPPO_COMPONENT_FALLBACK = "com.oppo.safe.permission.startup.StartupAppListActivity" private val PACKAGE_OPPO_COMPONENT_FALLBACK_A = "com.coloros.safecenter.startupapp.StartupAppListActivity" - private val OPPO_AUTOSTART_IN_APP_INFO_SUPPORTED_DEVICES = arrayOf( - "CPH1893", "CPH1877" //Rx17 Neo, Rx17 Pro - ) /** * Vivo @@ -240,22 +237,27 @@ class AutoStartPermissionHelper private constructor() { startIntent(context, PACKAGE_OPPO_MAIN, PACKAGE_OPPO_COMPONENT_FALLBACK_A) } catch (exx: Exception) { exx.printStackTrace() - return false + return launchOppoAppInfo(context) } } } - } else if (OPPO_AUTOSTART_IN_APP_INFO_SUPPORTED_DEVICES.contains(Build.DEVICE) - || OPPO_AUTOSTART_IN_APP_INFO_SUPPORTED_DEVICES.contains(Build.PRODUCT)) { + } else { + return launchOppoAppInfo(context) + } + return true + } + + private fun launchOppoAppInfo(context: Context): Boolean { + return try { val i = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS) i.addCategory(Intent.CATEGORY_DEFAULT) i.data = Uri.parse("package:${context.packageName}") context.startActivity(i) - return true - } else { - return false + true + } catch (exx: Exception) { + exx.printStackTrace() + false } - - return true } private fun autoStartVivo(context: Context): Boolean {