Do not hardcode service names
This commit is contained in:
parent
6b01a1a3ac
commit
4669e3677a
|
|
@ -26,6 +26,7 @@ import android.app.IActivityManager;
|
||||||
import android.app.IApplicationThread;
|
import android.app.IApplicationThread;
|
||||||
import android.app.IServiceConnection;
|
import android.app.IServiceConnection;
|
||||||
import android.app.ProfilerInfo;
|
import android.app.ProfilerInfo;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.IContentProvider;
|
import android.content.IContentProvider;
|
||||||
import android.content.IIntentReceiver;
|
import android.content.IIntentReceiver;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
|
@ -58,8 +59,8 @@ public class ActivityManagerService {
|
||||||
};
|
};
|
||||||
|
|
||||||
public static IActivityManager getActivityManager() {
|
public static IActivityManager getActivityManager() {
|
||||||
if (binder == null && am == null) {
|
if (binder == null || am == null) {
|
||||||
binder = ServiceManager.getService("activity");
|
binder = ServiceManager.getService(Context.ACTIVITY_SERVICE);
|
||||||
if (binder == null) return null;
|
if (binder == null) return null;
|
||||||
try {
|
try {
|
||||||
binder.linkToDeath(deathRecipient, 0);
|
binder.linkToDeath(deathRecipient, 0);
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ public class PackageService {
|
||||||
};
|
};
|
||||||
|
|
||||||
private static IPackageManager getPackageManager() {
|
private static IPackageManager getPackageManager() {
|
||||||
if (binder == null && pm == null) {
|
if (binder == null || pm == null) {
|
||||||
binder = ServiceManager.getService("package");
|
binder = ServiceManager.getService("package");
|
||||||
if (binder == null) return null;
|
if (binder == null) return null;
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ package org.lsposed.lspd.service;
|
||||||
|
|
||||||
import static org.lsposed.lspd.service.ServiceManager.TAG;
|
import static org.lsposed.lspd.service.ServiceManager.TAG;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.content.pm.UserInfo;
|
import android.content.pm.UserInfo;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
|
|
@ -53,8 +54,8 @@ public class UserService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IUserManager getUserManager() {
|
public static IUserManager getUserManager() {
|
||||||
if (binder == null && um == null) {
|
if (binder == null || um == null) {
|
||||||
binder = ServiceManager.getService("user");
|
binder = ServiceManager.getService(Context.USER_SERVICE);
|
||||||
if (binder == null) return null;
|
if (binder == null) return null;
|
||||||
try {
|
try {
|
||||||
binder.linkToDeath(recipient, 0);
|
binder.linkToDeath(recipient, 0);
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ public interface IUserManager extends IInterface {
|
||||||
List<UserInfo> getUsers(boolean excludePartial, boolean excludeDying, boolean excludePreCreated)
|
List<UserInfo> getUsers(boolean excludePartial, boolean excludeDying, boolean excludePreCreated)
|
||||||
throws RemoteException;
|
throws RemoteException;
|
||||||
|
|
||||||
UserInfo getUserInfo(int userHandle);
|
UserInfo getUserInfo(int userHandle) throws RemoteException;
|
||||||
|
|
||||||
UserInfo getProfileParent(int userId) throws RemoteException;
|
UserInfo getProfileParent(int userId) throws RemoteException;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue