Do not hardcode service names

This commit is contained in:
vvb2060 2022-12-03 01:08:54 +08:00 committed by LoveSy
parent 6b01a1a3ac
commit 4669e3677a
4 changed files with 8 additions and 6 deletions

View File

@ -26,6 +26,7 @@ import android.app.IActivityManager;
import android.app.IApplicationThread;
import android.app.IServiceConnection;
import android.app.ProfilerInfo;
import android.content.Context;
import android.content.IContentProvider;
import android.content.IIntentReceiver;
import android.content.Intent;
@ -58,8 +59,8 @@ public class ActivityManagerService {
};
public static IActivityManager getActivityManager() {
if (binder == null && am == null) {
binder = ServiceManager.getService("activity");
if (binder == null || am == null) {
binder = ServiceManager.getService(Context.ACTIVITY_SERVICE);
if (binder == null) return null;
try {
binder.linkToDeath(deathRecipient, 0);

View File

@ -92,7 +92,7 @@ public class PackageService {
};
private static IPackageManager getPackageManager() {
if (binder == null && pm == null) {
if (binder == null || pm == null) {
binder = ServiceManager.getService("package");
if (binder == null) return null;
try {

View File

@ -21,6 +21,7 @@ package org.lsposed.lspd.service;
import static org.lsposed.lspd.service.ServiceManager.TAG;
import android.content.Context;
import android.content.pm.UserInfo;
import android.os.Build;
import android.os.IBinder;
@ -53,8 +54,8 @@ public class UserService {
}
public static IUserManager getUserManager() {
if (binder == null && um == null) {
binder = ServiceManager.getService("user");
if (binder == null || um == null) {
binder = ServiceManager.getService(Context.USER_SERVICE);
if (binder == null) return null;
try {
binder.linkToDeath(recipient, 0);

View File

@ -17,7 +17,7 @@ public interface IUserManager extends IInterface {
List<UserInfo> getUsers(boolean excludePartial, boolean excludeDying, boolean excludePreCreated)
throws RemoteException;
UserInfo getUserInfo(int userHandle);
UserInfo getUserInfo(int userHandle) throws RemoteException;
UserInfo getProfileParent(int userId) throws RemoteException;