Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ subprojects {
val flags =
listOf(
"-DVERSION_CODE=${versionCodeProvider.get()}",
"-DVERSION_NAME='\"${versionNameProvider.get()}\"'",
"-DVERSION_NAME=${versionNameProvider.get()}",
)

val args =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,16 @@ object ManagerService : ILSPManagerService.Stub() {
IBinder.DeathRecipient {
private val connection =
object : android.app.IServiceConnection.Stub() {
// Android 8.1 ~ 16
override fun connected(name: ComponentName?, service: IBinder?, dead: Boolean) {}

// Android 17+ (new signature with IBinderSession)
override fun connected(
name: ComponentName?,
service: IBinder?,
session: android.app.IBinderSession?,
dead: Boolean
) {}
}

init {
Expand Down
35 changes: 35 additions & 0 deletions hiddenapi/stubs/src/main/java/android/app/IBinderSession.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package android.app;

import android.os.IBinder;
import android.os.IInterface;

/**
* Stub of {@code android.app.IBinderSession} introduced in Android 17 (API 36+).
*
* <p>This interface is used as a parameter of the new
* {@link IServiceConnection#connected} overload added in Android 17. On older
* Android versions this class does not exist at runtime, but because the stub
* is only referenced from the new {@code connected} overload (which is never
* invoked on older versions), the absence of the runtime class is not a
* problem — the method is never dispatched there.
*/
public interface IBinderSession extends IInterface {

String DESCRIPTOR = "android.app.IBinderSession";

void binderTransactionCompleted(long transactionId);

long binderTransactionStarting(String name);

abstract class Stub extends android.os.Binder implements IBinderSession {

public static IBinderSession asInterface(IBinder obj) {
throw new UnsupportedOperationException();
}

@Override
public IBinder asBinder() {
throw new UnsupportedOperationException();
}
}
}
14 changes: 14 additions & 0 deletions hiddenapi/stubs/src/main/java/android/app/IServiceConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,22 @@
import android.os.IInterface;

public interface IServiceConnection extends IInterface {

/**
* Old signature, used on Android 8.1 ~ 16. Removed from the framework
* interface in Android 17, but kept here so that code compiling against
* this stub can still override it (the method is simply never invoked on
* Android 17+).
*/
void connected(ComponentName name, IBinder service, boolean dead);

/**
* New signature introduced in Android 17 (API 36+). On older Android
* versions this overload does not exist at runtime and is never invoked,
* so overriding it is harmless there.
*/
void connected(ComponentName name, IBinder service, IBinderSession session, boolean dead);

abstract class Stub extends Binder implements IServiceConnection {

public static IServiceConnection asInterface(IBinder obj) {
Expand Down
9 changes: 8 additions & 1 deletion native/include/common/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,14 @@ inline constexpr auto kLinkerPath = "/linker";
/// The version code of the library, populated by the build system.
const int kVersionCode = VERSION_CODE;

// Stringize the VERSION_NAME token so the build system can pass it as a bare
// token (e.g. -DVERSION_NAME=2.0) without quoting, which is fragile across
// Windows / Unix toolchains. Macros are not namespace members, so these must
// live at file scope.
#define VECTOR_STRINGIZE(x) #x
#define VECTOR_STRINGIZE_TOKEN(x) VECTOR_STRINGIZE(x)

/// The version name of the library, populated by the build system.
const char *const kVersionName = VERSION_NAME;
const char *const kVersionName = VECTOR_STRINGIZE_TOKEN(VERSION_NAME);

} // namespace vector::native
4 changes: 2 additions & 2 deletions zygisk/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ android {

val flags =
listOf(
"-DINJECTED_PACKAGE_NAME='\"${injectedPackageName}\"'",
"-DINJECTED_PACKAGE_NAME=${injectedPackageName}",
"-DINJECTED_PACKAGE_UID=${injectedPackageUid}",
"-DMANAGER_PACKAGE_NAME='\"${defaultManagerPackageName}\"'",
"-DMANAGER_PACKAGE_NAME=${defaultManagerPackageName}",
)

externalNativeBuild {
Expand Down
12 changes: 8 additions & 4 deletions zygisk/src/main/cpp/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,14 @@ constexpr int SHARED_RELRO_UID = 1037;
// Android uses this to separate users. UID = AppID + UserID * 10000.
constexpr int PER_USER_RANGE = 100000;

// Defined via CMake generated marcos
// Defined via CMake generated marcos.
// Package names are passed as bare tokens (no quotes) because quoting is
// fragile across Windows / Unix toolchains; stringize them here instead.
#define VECTOR_STR(x) #x
#define VECTOR_STR_TOKEN(x) VECTOR_STR(x)
constexpr uid_t kHostPackageUid = INJECTED_PACKAGE_UID;
const char *const kHostPackageName = INJECTED_PACKAGE_NAME;
const char *const kManagerPackageName = MANAGER_PACKAGE_NAME;
const char *const kHostPackageName = VECTOR_STR_TOKEN(INJECTED_PACKAGE_NAME);
const char *const kManagerPackageName = VECTOR_STR_TOKEN(MANAGER_PACKAGE_NAME);
constexpr uid_t GID_INET = 3003; // Android's Internet group ID.

enum RuntimeFlags : uint32_t {
Expand Down Expand Up @@ -260,7 +264,7 @@ void VectorModule::preAppSpecialize(zygisk::AppSpecializeArgs *args) {
jint inet_gid = GID_INET;
env_->SetIntArrayRegion(new_gids, original_gids_count, 1, &inet_gid);

args->nice_name = env_->NewStringUTF(INJECTED_PACKAGE_NAME);
args->nice_name = env_->NewStringUTF(kHostPackageName);
args->gids = new_gids;
}
}
Expand Down