working module

This commit is contained in:
2026-11-27 01:11:19 +05:00
parent b1eb40870f
commit fa1434e88d
21 changed files with 219 additions and 119 deletions
+53
View File
@@ -0,0 +1,53 @@
{
"permissions": {
"allow": [
"Bash(cat)",
"Read(//tmp/**)",
"Bash(./gradlew assembleDebug)",
"Bash(apt-get update *)",
"Bash(apt-get install *)",
"Bash(./gradlew clean *)",
"Bash(export ANDROID_SDK_ROOT=/opt/android-sdk)",
"Bash(yes)",
"Bash(/opt/android-sdk/cmdline-tools/bin/sdkmanager --sdk_root=/opt/android-sdk --licenses)",
"Bash(mkdir *)",
"Bash(rm *)",
"Bash(export ANDROID_SDK_ROOT=/opt/android-sdk-linux)",
"Bash(rm -rf android-35)",
"Bash(mv android-35-2 *)",
"Bash(./gradlew --offline assembleDebug)",
"Bash(rm -rf android-34-* android-35-*)",
"Read(//home/shihaam/git/sargit/**)",
"Bash(git rm *)",
"Bash(git add *)",
"Bash(git config *)",
"Bash(gradle build *)",
"Bash(gradle compileDebugKotlin)",
"Bash(gradle dependencies *)",
"WebFetch(domain:github.com)",
"Bash(gradle assemble *)",
"Bash(gradle tasks *)",
"Bash(gradle -p app tasks)",
"Bash(gradle :app:build --stacktrace)",
"Bash(gradle projects *)",
"Bash(gradle settings *)",
"Bash(gradle --debug projects)",
"Bash(gradle -S projects)",
"Bash(kotlinc *)",
"Bash(gradle *)",
"Bash(chmod +x ./gradlew)",
"Bash(./gradlew --version)",
"Bash(./gradlew build *)",
"Bash(export ANDROID_HOME=/opt/android-sdk)",
"Bash(export ANDROID_HOME=/opt/android-sdk-linux)",
"Bash(mkdir -p /opt/android-sdk-linux/licenses)",
"Bash(xargs cat)",
"Bash(git commit *)",
"Bash(git restore *)",
"Bash(python3 *)",
"Bash(aapt2 dump *)",
"Bash(aapt dump *)",
"Bash(./gradlew assembleDebug --info)"
]
}
}
+1
View File
@@ -14,3 +14,4 @@
.cxx
local.properties
/.idea/
/ref/
+66
View File
@@ -0,0 +1,66 @@
# Unstack
libxposed (API 102) module that disables the stacked dual-SIM status bar icon introduced in Android 16 QPR1, bringing back separate per-SIM signal icons.
| | Status bar |
|---|---|
| **Stock** | ![Stock stacked icon](screenshots/stock.jpg) |
| **Unstack, data on SIM 1** | ![Data on SIM 1](screenshots/sim1_data.jpg) |
| **Unstack, data on SIM 2** | ![Data on SIM 2](screenshots/sim2_data.jpg) |
The stock stacked icon squeezes both SIMs into one glyph with a single `5G` label next to it, so the status bar no longer tells you which SIM is carrying mobile data. With Unstack, each SIM gets its own signal icon again and the network type label sits next to the SIM that's using data.
## What it changes
Since Android 16 QPR1, when two SIMs are active SystemUI merges their signal bars into one stacked icon. Whether that happens is decided by a `Flow<Boolean>` named `isStackable` on the mobile icons interactor. Reconstructed from the decompiled `SystemUI.apk` (crDroid, Android 17), it looks roughly like this:
```kotlin
// MobileIconsInteractorImpl
val isStackable: Flow<Boolean> =
icons.flatMapLatest { icons ->
if (icons.isEmpty()) flowOf(false)
else combine(icons.map { it.signalLevelIcon }) { levels ->
/* true when both SIMs' cellular icons can be merged */
}
}
// MobileIconsViewModel
val isStackable: StateFlow<Boolean> =
combine(iconsAreAllVisible, interactor.isStackable) { visible, stackable ->
visible && stackable
}.stateIn(scope, SharingStarted.WhileSubscribed(), false)
```
The view model only shows the stacked icon when the interactor says the icons are stackable. Unstack hooks the interactor's `isStackable()` getter and makes it always return a flow of `false`:
```kotlin
val falseFlow = MutableStateFlow(false) // created via SystemUI's own classloader
module.hook(MobileIconsInteractorImpl::isStackable).intercept { falseFlow }
module.hook(MobileIconsInteractorKairosAdapter::isStackable).intercept { falseFlow }
```
So `visible && stackable` is always `false`, and SystemUI falls back to drawing one signal icon per SIM.
### Why this hook point
- **The getter, not the field.** The backing field is `final` and is built once in the constructor. The view model reads it through the `MobileIconsInteractor.isStackable()` interface method, so hooking the getter catches every consumer, with no need to touch the constructor or rewrite final fields.
- **The flow is created in SystemUI's classloader.** The `Flow` type has to be SystemUI's own `kotlinx.coroutines` class. A flow built from the module's classes would be a different type and would fail when SystemUI collects it.
- **Two implementations are hooked.** SystemUI has a second, Kairos-based mobile icons pipeline behind a flag. Its `Flow`-facing entry point is `MobileIconsInteractorKairosAdapter.isStackable()`. Hooking both covers whichever pipeline is active. A class that doesn't exist on a given build is logged and skipped.
## Build
Requires `io.github.libxposed:api:102.0.0` in `mavenLocal()` (run `./gradlew publishToMavenLocal` in the [libxposed/api](https://github.com/libxposed/api) repo).
```bash
./gradlew assembleDebug
adb install -r app/build/outputs/apk/debug/app-debug.apk
```
Vector discovers the module through `app/src/main/resources/META-INF/xposed/` (`java_init.list`, `module.prop`, `scope.list`).
## Usage
1. Enable **Unstack** in Vector. The scope is preset to System UI.
2. Restart SystemUI: `adb shell su -c 'pkill -f com.android.systemui'`
3. Check that the hooks attached: `adb logcat -s Unstack`
+11 -15
View File
@@ -4,20 +4,14 @@ plugins {
android {
namespace = "sh.sar.unstacksim"
compileSdk {
version = release(36) {
minorApiLevel = 1
}
}
compileSdk = 34
defaultConfig {
applicationId = "sh.sar.unstacksim"
minSdk = 36
targetSdk = 36
minSdk = 26
targetSdk = 34
versionCode = 1
versionName = "1.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
@@ -29,17 +23,19 @@ android {
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
}
dependencies {
implementation(libs.androidx.appcompat)
implementation(libs.androidx.core.ktx)
implementation(libs.material)
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.espresso.core)
androidTestImplementation(libs.androidx.junit)
compileOnly(libs.libxposed.api)
}
+12 -18
View File
@@ -1,21 +1,15 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Keep all Xposed module classes and entry points
-keep class sh.sar.unstacksim.** { *; }
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Keep reflection targets
-keepclasseswithmembernames class * {
native <methods>;
}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# Keep hook callbacks
-keep interface io.github.libxposed.api.XposedModuleInterface$* { *; }
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
# Kotlin metadata
-keepattributes *Annotation*
-keepattributes SourceFile,LineNumberTable
-keepattributes InnerClasses
@@ -1,24 +0,0 @@
package sh.sar.unstacksim
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.Assert.*
/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("sh.sar.unstacksim", appContext.packageName)
}
}
+5 -9
View File
@@ -1,15 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:allowBackup="false"
android:description="@string/xposed_description"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Unstacksim" />
android:supportsRtl="true" />
</manifest>
</manifest>
@@ -0,0 +1,19 @@
package sh.sar.unstacksim
import io.github.libxposed.api.XposedModule
import io.github.libxposed.api.XposedModuleInterface.PackageLoadedParam
import android.util.Log
class EntryPoint : XposedModule() {
companion object {
private const val TAG = "Unstack"
private const val SYSTEM_UI_PACKAGE = "com.android.systemui"
}
override fun onPackageLoaded(param: PackageLoadedParam) {
if (param.packageName == SYSTEM_UI_PACKAGE) {
Log.d(TAG, "SystemUI package loaded, installing hooks")
HookManager.init(this, param.defaultClassLoader)
}
}
}
@@ -0,0 +1,29 @@
package sh.sar.unstacksim
import android.util.Log
import io.github.libxposed.api.XposedModule
object HookManager {
private const val TAG = "Unstack"
private const val PKG = "com.android.systemui.statusbar.pipeline.mobile.domain.interactor"
private val TARGETS = listOf(
"$PKG.MobileIconsInteractorImpl",
"$PKG.MobileIconsInteractorKairosAdapter",
)
fun init(module: XposedModule, classLoader: ClassLoader) {
val falseFlow = classLoader.loadClass("kotlinx.coroutines.flow.StateFlowKt")
.getDeclaredMethod("MutableStateFlow", Any::class.java)
.invoke(null, false)!!
for (name in TARGETS) {
try {
val method = classLoader.loadClass(name).getDeclaredMethod("isStackable")
module.hook(method).intercept { falseFlow }
Log.i(TAG, "Hooked $name.isStackable")
} catch (e: ReflectiveOperationException) {
Log.w(TAG, "Skipping $name: $e")
}
}
}
}
+5 -11
View File
@@ -1,16 +1,10 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.Unstacksim" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Minimal night theme for Xposed module (no UI) -->
<style name="Theme.Unstacksim" parent="android:Theme.Material">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_200</item>
<item name="colorPrimaryVariant">@color/purple_700</item>
<item name="colorOnPrimary">@color/black</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/teal_200</item>
<item name="colorSecondaryVariant">@color/teal_200</item>
<item name="colorOnSecondary">@color/black</item>
<item name="android:colorPrimary">@color/purple_200</item>
<item name="android:colorPrimaryDark">@color/purple_700</item>
<!-- Status bar color. -->
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
<item name="android:statusBarColor">@color/purple_700</item>
</style>
</resources>
+4 -2
View File
@@ -1,3 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">unstacksim</string>
</resources>
<string name="app_name">Unstack</string>
<string name="xposed_description">Disables stacked dual-SIM status bar icons</string>
</resources>
+5 -11
View File
@@ -1,16 +1,10 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.Unstacksim" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Minimal theme for Xposed module (no UI) -->
<style name="Theme.Unstacksim" parent="android:Theme.Light">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_500</item>
<item name="colorPrimaryVariant">@color/purple_700</item>
<item name="colorOnPrimary">@color/white</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/teal_200</item>
<item name="colorSecondaryVariant">@color/teal_700</item>
<item name="colorOnSecondary">@color/black</item>
<item name="android:colorPrimary">@color/purple_500</item>
<item name="android:colorPrimaryDark">@color/purple_700</item>
<!-- Status bar color. -->
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
<item name="android:statusBarColor">@color/purple_700</item>
</style>
</resources>
@@ -0,0 +1 @@
sh.sar.unstacksim.EntryPoint
@@ -0,0 +1,3 @@
minApiVersion=102
targetApiVersion=102
staticScope=true
@@ -0,0 +1 @@
com.android.systemui
@@ -1,17 +0,0 @@
package sh.sar.unstacksim
import org.junit.Test
import org.junit.Assert.*
/**
* Example local unit test, which will execute on the development machine (host).
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
class ExampleUnitTest {
@Test
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}
}
+2 -12
View File
@@ -1,19 +1,9 @@
[versions]
agp = "9.2.1"
coreKtx = "1.19.1"
junit = "4.13.2"
junitVersion = "1.3.0"
espressoCore = "3.7.0"
appcompat = "1.6.1"
material = "1.10.0"
libxposed = "102.0.0"
[libraries]
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
junit = { group = "junit", name = "junit", version.ref = "junit" }
androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
material = { group = "com.google.android.material", name = "material", version.ref = "material" }
libxposed-api = { group = "io.github.libxposed", name = "api", version.ref = "libxposed" }
[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }
Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

+2
View File
@@ -14,11 +14,13 @@ pluginManagement {
plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version "1.0.0"
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
mavenLocal()
}
}