Skip to content
This repository has been archived by the owner on Dec 13, 2023. It is now read-only.

Fix getApplicationInfo on non-primary user #247

Merged
merged 1 commit into from
Oct 12, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import android.content.pm.ApplicationInfo;
import android.content.pm.IPackageManager;
import android.os.Build;
import android.os.Process;
import android.os.ServiceManager;
import android.util.JsonReader;
import android.util.Log;
Expand Down Expand Up @@ -70,9 +71,9 @@ public class LSPAppComponentFactoryStub extends AppComponentFactory {
var ipm = IPackageManager.Stub.asInterface(ServiceManager.getService("package"));
ApplicationInfo manager;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
manager = (ApplicationInfo) HiddenApiBypass.invoke(IPackageManager.class, ipm, "getApplicationInfo", Constants.MANAGER_PACKAGE_NAME, 0L, 0);
manager = (ApplicationInfo) HiddenApiBypass.invoke(IPackageManager.class, ipm, "getApplicationInfo", Constants.MANAGER_PACKAGE_NAME, 0L, Process.myPid() / 100000);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Process.myUid()

} else {
manager = ipm.getApplicationInfo(Constants.MANAGER_PACKAGE_NAME, 0, 0);
manager = ipm.getApplicationInfo(Constants.MANAGER_PACKAGE_NAME, 0, Process.myUid() / 100000);
}
try (var zip = new ZipFile(new File(manager.sourceDir));
var is = zip.getInputStream(zip.getEntry(Constants.LOADER_DEX_ASSET_PATH));
Expand Down