Skip to content

Commit

Permalink
Added new method entry to know if the lib can handle the autostart
Browse files Browse the repository at this point in the history
  • Loading branch information
CedricAle committed Oct 24, 2019
1 parent c7932ed commit c542a6d
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ class AutoStartPermissionHelper private constructor() {
private val PACKAGE_NOKIA_MAIN = "com.evenwell.powersaving.g3"
private val PACKAGE_NOKIA_COMPONENT = "com.evenwell.powersaving.g3.exception.PowerSaverExceptionActivity"

private val PACKAGES_TO_CHECK_FOR_PERMISSION = listOf(PACKAGE_ASUS_MAIN, PACKAGE_XIAOMI_MAIN, PACKAGE_LETV_MAIN, PACKAGE_HONOR_MAIN, PACKAGE_OPPO_MAIN, PACKAGE_OPPO_FALLBACK, PACKAGE_VIVO_MAIN, PACKAGE_VIVO_FALLBACK, PACKAGE_NOKIA_MAIN, PACKAGE_HUAWEI_MAIN)

fun getAutoStartPermission(context: Context) {

val build_info = Build.BRAND.toLowerCase()
Expand All @@ -97,6 +99,19 @@ class AutoStartPermissionHelper private constructor() {

}

fun isAutoStartPermissionAvailable(context: Context): Boolean {

val packages: List<ApplicationInfo>
val pm = context.packageManager
packages = pm.getInstalledApplications(0)
for (packageInfo in packages) {
if (PACKAGES_TO_CHECK_FOR_PERMISSION.contains(packageInfo.packageName)) {
return true
}
}
return false
}

private fun autoStartXiaomi(context: Context) {
if (isPackageExists(context, PACKAGE_XIAOMI_MAIN)) {
try {
Expand Down

0 comments on commit c542a6d

Please sign in to comment.