diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 5b9ceedb8f6a..51651b97ce8b 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -63,6 +63,21 @@
+
+
+
+
+
+
+
diff --git a/app/src/main/java/me/phh/treble/app/Nubia.kt b/app/src/main/java/me/phh/treble/app/Nubia.kt
index d056c25616db..a4ba635d973c 100644
--- a/app/src/main/java/me/phh/treble/app/Nubia.kt
+++ b/app/src/main/java/me/phh/treble/app/Nubia.kt
@@ -87,6 +87,23 @@ object Nubia : EntryStartup {
val b = sp.getBoolean(key, false)
SystemProperties.set("nubia.perf.ufs", if(b) "1" else "0")
}
+ NubiaSettings.shoulderBtn -> {
+ val i = if(sp.getBoolean(key, false)) "1" else "0"
+ if (NubiaSettings.is6Series()){
+ // Right
+ writeToFileNofail("/sys/devices/platform/soc/a88000.i2c/i2c-3/3-0010/mode", i)
+ // Left
+ writeToFileNofail("/sys/devices/platform/soc/998000.i2c/i2c-1/1-0010/mode", i)
+ } else if (NubiaSettings.is5GLite()){
+ // both right and left
+ writeToFileNofail("/sys/devices/platform/soc/880000.i2c/i2c-0/0-0010/mode", i)
+ } else if (NubiaSettings.is5G5S()){
+ // Right
+ writeToFileNofail("/sys/devices/platform/soc/988000.i2c/i2c-1/1-0010/mode", i)
+ // Left
+ writeToFileNofail("/sys/devices/platform/soc/990000.i2c/i2c-2/2-0010/mode", i)
+ }
+ }
}
}
@@ -99,6 +116,7 @@ object Nubia : EntryStartup {
//Refresh parameters on boot
spListener.onSharedPreferenceChanged(sp, NubiaSettings.dt2w)
spListener.onSharedPreferenceChanged(sp, NubiaSettings.tsGameMode)
+ spListener.onSharedPreferenceChanged(sp, NubiaSettings.shoulderBtn)
spListener.onSharedPreferenceChanged(sp, NubiaSettings.bypassCharger)
spListener.onSharedPreferenceChanged(sp, NubiaSettings.highTouchScreenSampleRate)
@@ -125,6 +143,14 @@ object Nubia : EntryStartup {
ctxt,
NubiaGameModeTilesService::class.java
), PackageManager.COMPONENT_ENABLED_STATE_ENABLED, 0)
+ if (NubiaSettings.is5G5S() || NubiaSettings.is6Series() || NubiaSettings.is5GLite()) {
+ // Enable shoulder triggers quick setting tile
+ ctxt.packageManager.setComponentEnabledSetting(
+ ComponentName(
+ ctxt,
+ NubiaShoulderBtnTilesService::class.java
+ ), PackageManager.COMPONENT_ENABLED_STATE_ENABLED, 0)
+ }
}
}
diff --git a/app/src/main/java/me/phh/treble/app/NubiaSettings.kt b/app/src/main/java/me/phh/treble/app/NubiaSettings.kt
index be4d503e72b8..c38090975000 100644
--- a/app/src/main/java/me/phh/treble/app/NubiaSettings.kt
+++ b/app/src/main/java/me/phh/treble/app/NubiaSettings.kt
@@ -15,9 +15,12 @@ object NubiaSettings : Settings {
val boostGpu = "nubia_boost_gpu"
val boostCache = "nubia_boost_cache"
val boostUfs = "nubia_boost_ufs"
+ val shoulderBtn = "nubia_shoulder_btn"
override fun enabled() = Tools.vendorFp.toLowerCase().startsWith("nubia/")
fun is6Series() = Tools.vendorFp.toLowerCase().startsWith("nubia/nx669")
+ fun is5GLite() = Tools.vendorFp.toLowerCase().startsWith("nubia/nx651")
+ fun is5G5S() = Tools.vendorFp.toLowerCase().startsWith("nubia/nx659")
}
diff --git a/app/src/main/java/me/phh/treble/app/NubiaTilesService.kt b/app/src/main/java/me/phh/treble/app/NubiaTilesService.kt
index c0f2b5e2365d..0924abecafa7 100644
--- a/app/src/main/java/me/phh/treble/app/NubiaTilesService.kt
+++ b/app/src/main/java/me/phh/treble/app/NubiaTilesService.kt
@@ -123,4 +123,50 @@ class NubiaFanControlTilesService: TileService() {
override fun onTileRemoved() {
super.onTileRemoved()
}
-}
\ No newline at end of file
+}
+
+
+class NubiaShoulderBtnTilesService: TileService() {
+ private lateinit var sp: SharedPreferences
+
+ override fun onCreate() {
+ this.sp = PreferenceManager.getDefaultSharedPreferences(this)
+ }
+
+ // Called when the user adds your tile.
+ override fun onTileAdded() {
+ super.onTileAdded()
+ }
+ // Called when your app can update your tile.
+ override fun onStartListening() {
+ super.onStartListening()
+ val shouldBtnEnabled: Boolean = sp.getBoolean(NubiaSettings.shoulderBtn, false)
+ qsTile.contentDescription = if (shouldBtnEnabled) "On" else "Off"
+ qsTile.state = if (shouldBtnEnabled) Tile.STATE_ACTIVE else Tile.STATE_INACTIVE
+ qsTile.updateTile()
+
+ }
+
+ // Called when your app can no longer update your tile.
+ override fun onStopListening() {
+ super.onStopListening()
+ }
+
+ // Called when the user taps on your tile in an active or inactive state.
+ override fun onClick() {
+ super.onClick()
+ val shouldBtnEnabled: Boolean = sp.getBoolean(NubiaSettings.shoulderBtn, false)
+ with (sp.edit()) {
+ putBoolean(NubiaSettings.shoulderBtn, !shouldBtnEnabled)
+ apply()
+ }
+ qsTile.state = if (shouldBtnEnabled) Tile.STATE_INACTIVE else Tile.STATE_ACTIVE
+ qsTile.contentDescription = if (shouldBtnEnabled) "Off" else "On"
+ qsTile.updateTile()
+ }
+ // Called when the user removes your tile.
+ override fun onTileRemoved() {
+ super.onTileRemoved()
+ }
+
+}
diff --git a/app/src/main/res/xml/pref_nubia.xml b/app/src/main/res/xml/pref_nubia.xml
index 75502a5b5575..c25102599983 100644
--- a/app/src/main/res/xml/pref_nubia.xml
+++ b/app/src/main/res/xml/pref_nubia.xml
@@ -32,6 +32,13 @@
android:key="nubia_touchscreen_game_mode"
android:title="Enable game mode"
app:summaryOn="Auto stop fan is disabled" />
+