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