diff --git a/README.md b/README.md index 6a5e772..aa8fa59 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ Add this to your module's `build.gradle` file: ```groovy dependencies { // ... other dependencies - implementation 'com.github.judemanutd:autostarter:1.0.5' + implementation 'com.github.judemanutd:autostarter:1.0.6' } ``` @@ -42,7 +42,7 @@ dependencies { com.github.judemanutd autostarter - 1.0.5 + 1.0.6 pom ``` @@ -72,6 +72,16 @@ In order to check if your phone is supported by the library you can call the fol 4. Honor [ Untested ] 5. Oppo [ Untested ] 6. Vivo [ Untested ] - 7. Huawei [ Untested ] + 7. Huawei I will be adding support for other manufacturers as and when possible. I am also open to PR's and contributions from others. + +## Related Info + +Since this depends entirely on the OEM and not on android itself, the underlying component that this library makes use of is continuously changing. +Do check out these repositories for further information on this issue + +- [dont-kill-my-app](https://github.com/urbandroid-team/dont-kill-my-app) +- [backgroundable-android](https://github.com/dirkam/backgroundable-android) +- [AppKillerManager](https://github.com/thelittlefireman/AppKillerManager) +- [CRomAppWhitelist](https://github.com/WanghongLin/CRomAppWhitelist) \ No newline at end of file diff --git a/autostarter/build.gradle b/autostarter/build.gradle index d4a5b37..b00e33a 100644 --- a/autostarter/build.gradle +++ b/autostarter/build.gradle @@ -1,6 +1,6 @@ apply plugin: 'com.android.library' -apply plugin: 'kotlin-android-extensions' apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' ext { bintrayRepo = 'maven' @@ -15,7 +15,7 @@ ext { siteUrl = 'https://github.com/judemanutd/AutoStarter' gitUrl = 'https://github.com/judemanutd/AutoStarter.git' - libraryVersion = '1.0.5' + libraryVersion = '1.0.6' developerId = 'judemanutd' developerName = 'Jude Fernandes' @@ -31,8 +31,8 @@ android { defaultConfig { minSdkVersion 14 targetSdkVersion 29 - versionCode 5 - versionName "1.0.5" + versionCode 6 + versionName "1.0.6" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" diff --git a/autostarter/src/main/java/com/judemanutd/autostarter/AutoStartPermissionHelper.kt b/autostarter/src/main/java/com/judemanutd/autostarter/AutoStartPermissionHelper.kt index eaf2846..0bb2039 100644 --- a/autostarter/src/main/java/com/judemanutd/autostarter/AutoStartPermissionHelper.kt +++ b/autostarter/src/main/java/com/judemanutd/autostarter/AutoStartPermissionHelper.kt @@ -44,6 +44,7 @@ class AutoStartPermissionHelper private constructor() { private val BRAND_HUAWEI = "huawei" private val PACKAGE_HUAWEI_MAIN = "com.huawei.systemmanager" private val PACKAGE_HUAWEI_COMPONENT = "com.huawei.systemmanager.optimize.process.ProtectActivity" + private val PACKAGE_HUAWEI_COMPONENT_FALLBACK = "com.huawei.systemmanager.startupmgr.ui.StartupNormalAppListActivity" /** * Oppo @@ -74,7 +75,14 @@ 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) + /*** + * Samsung + */ + private val BRAND_SAMSUNG = "samsung" + private val PACKAGE_SAMSUNG_MAIN = "com.samsung.android.lool" + private val PACKAGE_SAMSUNG_COMPONENT = "com.samsung.android.sm.ui.battery.BatteryActivity" + + 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, PACKAGE_SAMSUNG_MAIN) fun getAutoStartPermission(context: Context): Boolean { @@ -96,6 +104,8 @@ class AutoStartPermissionHelper private constructor() { BRAND_NOKIA -> return autoStartNokia(context) + BRAND_SAMSUNG -> return autoStartSamsung(context) + else -> { return false } @@ -182,6 +192,12 @@ class AutoStartPermissionHelper private constructor() { startIntent(context, PACKAGE_HUAWEI_MAIN, PACKAGE_HUAWEI_COMPONENT) } catch (e: Exception) { e.printStackTrace() + try { + startIntent(context, PACKAGE_HUAWEI_MAIN, PACKAGE_HUAWEI_COMPONENT_FALLBACK) + } catch (ex: Exception) { + ex.printStackTrace() + return false + } return false } } else { @@ -260,6 +276,21 @@ class AutoStartPermissionHelper private constructor() { return true } + private fun autoStartSamsung(context: Context): Boolean { + if (isPackageExists(context, PACKAGE_SAMSUNG_MAIN)) { + try { + startIntent(context, PACKAGE_SAMSUNG_MAIN, PACKAGE_SAMSUNG_COMPONENT) + } catch (e: Exception) { + e.printStackTrace() + return false + } + } else { + return false + } + + return true + } + @Throws(Exception::class) private fun startIntent(context: Context, packageName: String, componentName: String) { try { diff --git a/build.gradle b/build.gradle index 6b613bb..11e53d4 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.3.50' + ext.kotlin_version = '1.3.61' repositories { google() @@ -10,7 +10,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:3.5.2' + classpath 'com.android.tools.build:gradle:3.5.3' classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4' classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"