Set EUID to 1000 to fix notification and get modules list for Flyme (#2549)
Add more logs for LSPNotificationManager
Seteuid to 1000
This reverts commit 0a26993039.
This commit is contained in:
parent
495686b532
commit
d972bf4bd6
|
|
@ -7,6 +7,8 @@ import android.os.IBinder;
|
|||
import android.os.Looper;
|
||||
import android.os.Parcel;
|
||||
import android.os.ServiceManager;
|
||||
import android.system.ErrnoException;
|
||||
import android.system.Os;
|
||||
import android.util.Log;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
|
@ -69,7 +71,15 @@ public class BridgeService {
|
|||
};
|
||||
|
||||
// For service
|
||||
// This MUST run in main thread
|
||||
private static synchronized void sendToBridge(IBinder binder, boolean isRestart) {
|
||||
assert Looper.myLooper() == Looper.getMainLooper();
|
||||
try {
|
||||
Os.seteuid(0);
|
||||
} catch (ErrnoException e) {
|
||||
Log.e(TAG, "seteuid 0", e);
|
||||
}
|
||||
try {
|
||||
do {
|
||||
bridgeService = ServiceManager.getService(SERVICE_NAME);
|
||||
if (bridgeService != null && bridgeService.pingBinder()) {
|
||||
|
|
@ -135,6 +145,13 @@ public class BridgeService {
|
|||
if (listener != null) {
|
||||
listener.onResponseFromBridgeService(res);
|
||||
}
|
||||
} finally {
|
||||
try {
|
||||
Os.seteuid(1000);
|
||||
} catch (ErrnoException e) {
|
||||
Log.e(TAG, "seteuid 1000", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void send(LSPosedService service, Listener listener) {
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ public class LSPNotificationManager {
|
|||
private static final IBinder.DeathRecipient recipient = new IBinder.DeathRecipient() {
|
||||
@Override
|
||||
public void binderDied() {
|
||||
Log.w(TAG, "nm is dead");
|
||||
Log.w(TAG, "notificationManager is dead");
|
||||
binder.unlinkToDeath(this, 0);
|
||||
binder = null;
|
||||
notificationManager = null;
|
||||
|
|
@ -96,11 +96,16 @@ public class LSPNotificationManager {
|
|||
|
||||
private static boolean hasNotificationChannelForSystem(
|
||||
INotificationManager nm, String channelId) throws RemoteException {
|
||||
NotificationChannel channel;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
return nm.getNotificationChannelForPackage("android", 1000, channelId, null, false) != null;
|
||||
channel = nm.getNotificationChannelForPackage("android", 1000, channelId, null, false);
|
||||
} else {
|
||||
return nm.getNotificationChannelForPackage("android", 1000, channelId, false) != null;
|
||||
channel = nm.getNotificationChannelForPackage("android", 1000, channelId, false);
|
||||
}
|
||||
if(channel != null) {
|
||||
Log.d(TAG, "hasNotificationChannelForSystem: " + channel);
|
||||
}
|
||||
return channel != null;
|
||||
}
|
||||
|
||||
private static void createNotificationChannel(INotificationManager nm) throws RemoteException {
|
||||
|
|
@ -112,6 +117,7 @@ public class LSPNotificationManager {
|
|||
NotificationManager.IMPORTANCE_HIGH);
|
||||
updated.setShowBadge(false);
|
||||
if (hasNotificationChannelForSystem(nm, UPDATED_CHANNEL_ID)) {
|
||||
Log.d(TAG, "update notification channel: " + UPDATED_CHANNEL_ID);
|
||||
nm.updateNotificationChannelForPackage("android", 1000, updated);
|
||||
} else {
|
||||
list.add(updated);
|
||||
|
|
@ -122,6 +128,7 @@ public class LSPNotificationManager {
|
|||
NotificationManager.IMPORTANCE_MIN);
|
||||
status.setShowBadge(false);
|
||||
if (hasNotificationChannelForSystem(nm, STATUS_CHANNEL_ID)) {
|
||||
Log.d(TAG, "update notification channel: " + STATUS_CHANNEL_ID);
|
||||
nm.updateNotificationChannelForPackage("android", 1000, status);
|
||||
} else {
|
||||
list.add(status);
|
||||
|
|
@ -132,11 +139,13 @@ public class LSPNotificationManager {
|
|||
NotificationManager.IMPORTANCE_HIGH);
|
||||
scope.setShowBadge(false);
|
||||
if (hasNotificationChannelForSystem(nm, SCOPE_CHANNEL_ID)) {
|
||||
Log.d(TAG, "update notification channel: " + SCOPE_CHANNEL_ID);
|
||||
nm.updateNotificationChannelForPackage("android", 1000, scope);
|
||||
} else {
|
||||
list.add(scope);
|
||||
}
|
||||
|
||||
Log.d(TAG, "create notification channels for android: " + list);
|
||||
nm.createNotificationChannelsForPackage("android", 1000, new ParceledListSlice<>(list));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue