Skip to content

Commit

Permalink
Merge pull request #51 from Prometheus3k/oppo-rx17-neo-cph1893
Browse files Browse the repository at this point in the history
Added support for Oppo Color OS 5.2 (Android 8.1) + Color OS 6 (Android 9) [Rx17 Neo - CPH1893 / Rx17 Pro - CPH1877]
  • Loading branch information
judemanutd authored May 22, 2021
2 parents c229561 + 3d9e8e7 commit 218649f
Showing 1 changed file with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,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() {
Expand Down Expand Up @@ -98,7 +100,7 @@ class AutoStartPermissionHelper private constructor() {

fun getAutoStartPermission(context: Context): Boolean {

when (Build.BRAND.toLowerCase(Locale.ENGLISH)) {
when (Build.BRAND.toLowerCase(Locale.getDefault())) {

BRAND_ASUS -> return autoStartAsus(context)

Expand Down Expand Up @@ -239,17 +241,29 @@ 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 {
return false
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)
true
} catch (exx: Exception) {
exx.printStackTrace()
false
}
}

private fun autoStartVivo(context: Context): Boolean {
if (isPackageExists(context, PACKAGE_VIVO_MAIN) || isPackageExists(context, PACKAGE_VIVO_FALLBACK)) {
try {
Expand Down

0 comments on commit 218649f

Please sign in to comment.