PhoneChecker

This commit is contained in:
Milos Kozak 2020-01-15 19:56:57 +01:00
parent 8c02daf39d
commit 1e3c979b51
3 changed files with 39 additions and 0 deletions

View file

@ -308,6 +308,9 @@ dependencies {
implementation "com.squareup.retrofit2:adapter-rxjava2:2.6.2"
implementation "com.squareup.retrofit2:converter-gson:2.6.2"
// Phone checker
implementation 'com.scottyab:rootbeer-lib:0.0.7'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0-alpha03'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test:rules:1.3.0-alpha03'

View file

@ -0,0 +1,35 @@
package info.nightscout.androidaps.plugins.constraints.phoneChecker
import android.os.Build
import com.scottyab.rootbeer.RootBeer
import info.nightscout.androidaps.MainApp
import info.nightscout.androidaps.R
import info.nightscout.androidaps.interfaces.ConstraintsInterface
import info.nightscout.androidaps.interfaces.PluginBase
import info.nightscout.androidaps.interfaces.PluginDescription
import info.nightscout.androidaps.interfaces.PluginType
object PhoneCheckerPlugin : PluginBase(PluginDescription()
.mainType(PluginType.CONSTRAINTS)
.neverVisible(true)
.alwaysEnabled(true)
.showInList(false)
.pluginName(R.string.phonechecker)
), ConstraintsInterface {
var phoneRooted: Boolean = false
var devMode: Boolean = false
val phoneModel: String = Build.MODEL
val manufacturer: String = Build.MANUFACTURER
private fun isDevModeEnabled(): Boolean {
return android.provider.Settings.Secure.getInt(MainApp.instance().contentResolver,
android.provider.Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) != 0;
}
override fun onStart() {
super.onStart()
phoneRooted = RootBeer(MainApp.instance()).isRootedWithoutBusyBoxCheck()
devMode = isDevModeEnabled()
}
}

View file

@ -1690,5 +1690,6 @@
<string name="ebstopsloop">Use of Extended bolus feature will stop closed loop mode for the time of running extended bolus. Do you really want it?</string>
<string name="closed_loop_disabled_with_eb">Closed loop disabled because of running Extended bolus</string>
<string name="extended_bolus_short">EB</string>
<string name="phonechecker">\"PhoneChecker\"</string>
</resources>