Skip to content

Commit

Permalink
Merge pull request #26 from judemanutd/features/oem-updates
Browse files Browse the repository at this point in the history
OEM Updates
  • Loading branch information
judemanutd authored Dec 22, 2019
2 parents 9fae996 + 99b8030 commit ba7359a
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 10 deletions.
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
```

Expand All @@ -42,7 +42,7 @@ dependencies {
<dependency>
<groupId>com.github.judemanutd</groupId>
<artifactId>autostarter</artifactId>
<version>1.0.5</version>
<version>1.0.6</version>
<type>pom</type>
</dependency>
```
Expand Down Expand Up @@ -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)
8 changes: 4 additions & 4 deletions autostarter/build.gradle
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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'
Expand All @@ -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"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {

Expand All @@ -96,6 +104,8 @@ class AutoStartPermissionHelper private constructor() {

BRAND_NOKIA -> return autoStartNokia(context)

BRAND_SAMSUNG -> return autoStartSamsung(context)

else -> {
return false
}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -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"
Expand Down

0 comments on commit ba7359a

Please sign in to comment.