Skip to content

Fix manager crash (AbstractMethodError) on HyperOS3(Android 17) due to IServiceConnection signature change#784

Open
Leaf-lsgtky wants to merge 2 commits into
JingMatrix:masterfrom
Leaf-lsgtky:fix/android17-iserviceconnection
Open

Fix manager crash (AbstractMethodError) on HyperOS3(Android 17) due to IServiceConnection signature change#784
Leaf-lsgtky wants to merge 2 commits into
JingMatrix:masterfrom
Leaf-lsgtky:fix/android17-iserviceconnection

Conversation

@Leaf-lsgtky

Copy link
Copy Markdown

Problem

On Android 17 (API 36), opening the manager triggers an AbstractMethodError that kills the parasitic manager process, followed by a DeadObjectException in system_server (dispatching a broadcast to the dead process), which causes a framework restart (SYSTEM_RESTART) every time the manager is launched.

The debug crash log shows:
java.lang.AbstractMethodError: abstract method "void android.app.IServiceConnection.connected(android.content.ComponentName, android.os.IBinder, android.app.IBinderSession, boolean)" on receiver org.matrix.vector.daemon.ipc.ManagerServiceManagerGuardconnection$1

Root cause

Android 17 replaced the old IServiceConnection.connected(ComponentName, IBinder, boolean) overload with a new 4-argument signature that adds an IBinderSession parameter, and removed the old overload entirely from the framework interface.

Vector's IServiceConnection stub and the ManagerService connection implementation only declared/overrode the old 3-argument signature. When system_server dispatched the new 4-argument connected() to the parasitic manager process, the Stub lacked the new abstract method → AbstractMethodError → process death → DeadObjectException → framework restart.

Fix

Commit 1 — Android 17 compatibility (core fix)

  • Add IBinderSession stub (android.app.IBinderSession extends IInterface) with binderTransactionCompleted(long) and binderTransactionStarting(String):long, matching the Android 17 framework interface.
  • Declare both connected() overloads in the IServiceConnection stub so it compiles against Android 8.1–17. The old overload is simply never invoked on Android 17+.
  • Override the new 4-argument connected() in ManagerService's connection Stub (no-op, same as the existing 3-argument override).

Commit 2 — Windows build fix (prerequisite for local testing)

Passing string macros wrapped in single quotes (-DVERSION_NAME='"2.0"') breaks on Windows because single quotes are not shell quoting characters there. The compiler receives -DVERSION_NAME='2.0' (a multi-character constant) and fails. Fixed by passing bare tokens and stringizing them at the C++ side via a STRINGIZE macro, which is robust across Windows and Unix toolchains.

Testing

  • Device: Xiaomi (HyperOS 3, Android 17 / API 36)
  • Reproduced the crash with the unpatched debug build (manager launch → AbstractMethodError → framework restart).
  • Applied the fix, rebuilt the debug zip, flashed via KSU and rebooted.
  • Manager opens successfully without crash; framework remains stable.
  • Verified no regression on framework startup (VectorDaemon / VectorSystemServer logs normal).

The change is backward-compatible: on Android 8.1–16 the new overload exists only in the stub (never invoked at runtime), and the old overload is preserved unchanged.

Android 17 (API 36) replaced the old 3-argument
IServiceConnection.connected(ComponentName, IBinder, boolean) with a
new 4-argument overload that adds an IBinderSession parameter, and
removed the old overload entirely from the framework interface.

Vector's IServiceConnection stub and the ManagerService connection
implementation only declared/overrode the old 3-argument signature.
When system_server dispatched the new 4-argument connected() to the
parasitic manager process on Android 17, the Stub lacked the new
abstract method and threw AbstractMethodError, killing the manager
process. system_server then hit DeadObjectException while dispatching
a broadcast to the dead process, triggering a framework restart
(SYSTEM_RESTART) every time the manager was opened.

Fix:
- Add an IBinderSession stub (android.app.IBinderSession extends
  IInterface) with binderTransactionCompleted(long) and
  binderTransactionStarting(String):long, matching the Android 17
  framework interface.
- Declare both connected() overloads in the IServiceConnection stub so
  it compiles against Android 8.1~17 (the old overload is simply never
  invoked on Android 17+).
- Override the new 4-argument connected() in ManagerService's
  connection Stub (no-op, same as the existing 3-argument override).
The build system passed string macros to the C/C++ compiler wrapped in
single quotes, e.g.  -DVERSION_NAME='2.0'  and
-DINJECTED_PACKAGE_NAME='com.android.shell'. On Linux/macOS the shell
strips the single quotes and the compiler sees a quoted string literal,
but on Windows single quotes are not shell quoting characters, so the
compiler receives -DVERSION_NAME='2.0' (a multi-character constant) or
-DINJECTED_PACKAGE_NAME='com.android.shell', causing compilation
failures:
  - narrowing conversion from 'int' to 'const char*'
  - expected unqualified-id / multi-character constant

Fix by passing the values as bare tokens
(-DVERSION_NAME=2.0, -DINJECTED_PACKAGE_NAME=com.android.shell) and
stringizing them at the C++ side via a STRINGIZE macro, which is robust
across Windows and Unix toolchains. Also move the stringize helper
macros out of a namespace (macros are not namespace members and cannot
be invoked with a qualified name).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant