Skip to content

Commit

Permalink
added one plus experimental support
Browse files Browse the repository at this point in the history
resolves #34
  • Loading branch information
Jude Fernandes committed Feb 2, 2020
1 parent 7dd6dae commit a880a13
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 8 deletions.
5 changes: 3 additions & 2 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.7'
implementation 'com.github.judemanutd:autostarter:1.0.8'
}
```

Expand All @@ -42,7 +42,7 @@ dependencies {
<dependency>
<groupId>com.github.judemanutd</groupId>
<artifactId>autostarter</artifactId>
<version>1.0.7</version>
<version>1.0.8</version>
<type>pom</type>
</dependency>
```
Expand Down Expand Up @@ -75,6 +75,7 @@ In order to check if your phone is supported by the library you can call the fol
7. Huawei
8. Samsung
9. Asus
10. One Plus [ Untested ]

I will be adding support for other manufacturers as and when possible. I am also open to PR's and contributions from others.

Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ android {

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
testImplementation 'junit:junit:4.12'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:appcompat-v7:28.0.0'
Expand Down
8 changes: 4 additions & 4 deletions autostarter/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ext {
siteUrl = 'https://github.com/judemanutd/AutoStarter'
gitUrl = 'https://github.com/judemanutd/AutoStarter.git'

libraryVersion = '1.0.7'
libraryVersion = '1.0.8'

developerId = 'judemanutd'
developerName = 'Jude Fernandes'
Expand All @@ -31,8 +31,8 @@ android {
defaultConfig {
minSdkVersion 14
targetSdkVersion 29
versionCode 7
versionName "1.0.7"
versionCode 8
versionName "1.0.8"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

Expand All @@ -50,7 +50,7 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

testImplementation 'junit:junit:4.12'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,15 @@ class AutoStartPermissionHelper private constructor() {
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)
/***
* One plus
*/
private val BRAND_ONE_PLUS = "oneplus"
private val PACKAGE_ONE_PLUS_MAIN = "com.oneplus.security"
private val PACKAGE_ONE_PLUS_COMPONENT = "com.oneplus.security.chainlaunch.view.ChainLaunchAppListActivity"

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, PACKAGE_ONE_PLUS_MAIN)

fun getAutoStartPermission(context: Context): Boolean {

Expand All @@ -107,6 +115,8 @@ class AutoStartPermissionHelper private constructor() {

BRAND_SAMSUNG -> return autoStartSamsung(context)

BRAND_ONE_PLUS -> return autoStartOnePlus(context)

else -> {
return false
}
Expand Down Expand Up @@ -292,6 +302,21 @@ class AutoStartPermissionHelper private constructor() {
return true
}

private fun autoStartOnePlus(context: Context): Boolean {
if (isPackageExists(context, PACKAGE_ONE_PLUS_MAIN)) {
try {
startIntent(context, PACKAGE_ONE_PLUS_MAIN, PACKAGE_ONE_PLUS_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

0 comments on commit a880a13

Please sign in to comment.