Remove USER_ID from ServiceManager, and replace it by a constant in FakeContext. This is the same as android.os.Process.ROOT_UID, but this constant has been introduced in API 29. PR #3757 <https://github.com/Genymobile/scrcpy/pull/3757>
42 lines
1.1 KiB
Java
42 lines
1.1 KiB
Java
package com.genymobile.scrcpy;
|
|
|
|
import android.annotation.TargetApi;
|
|
import android.content.AttributionSource;
|
|
import android.content.ContextWrapper;
|
|
import android.os.Build;
|
|
import android.os.Process;
|
|
|
|
public final class FakeContext extends ContextWrapper {
|
|
|
|
public static final String PACKAGE_NAME = "com.android.shell";
|
|
public static final int ROOT_UID = 0; // Like android.os.Process.ROOT_UID, but before API 29
|
|
|
|
private static final FakeContext INSTANCE = new FakeContext();
|
|
|
|
public static FakeContext get() {
|
|
return INSTANCE;
|
|
}
|
|
|
|
private FakeContext() {
|
|
super(null);
|
|
}
|
|
|
|
@Override
|
|
public String getPackageName() {
|
|
return PACKAGE_NAME;
|
|
}
|
|
|
|
@Override
|
|
public String getOpPackageName() {
|
|
return PACKAGE_NAME;
|
|
}
|
|
|
|
@TargetApi(Build.VERSION_CODES.S)
|
|
@Override
|
|
public AttributionSource getAttributionSource() {
|
|
AttributionSource.Builder builder = new AttributionSource.Builder(Process.SHELL_UID);
|
|
builder.setPackageName(PACKAGE_NAME);
|
|
return builder.build();
|
|
}
|
|
}
|