-
Notifications
You must be signed in to change notification settings - Fork 17
fix: block coloros 15 fixSmallIcon method #78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Closed
Owner
|
它竟然加到系统框架里了吗 |
Contributor
Author
|
是的 他直接调用Notification.setSmallIcon覆盖图标了 |
Owner
|
你可否看看这个方法有没有别的可能性 hook SystemUI 绕过,因为 hook 系统框架的代价有点高 |
Contributor
Author
这不太行吧 他这个方法直接覆盖掉原本的SmallIcon private void fixSmallIcon(Notification notification, String pkg, String opPkg, boolean isExp) {
Bundle notifExtras;
if (notification == null || TextUtils.isEmpty(pkg)) {
Slog.d(TAG, "fixSmallIcon: notification or pkg is null");
return;
}
if (isExp || (notifExtras = notification.extras) == null) {
return;
}
ApplicationInfo appInfo = (ApplicationInfo) notifExtras.getParcelable("android.appInfo", ApplicationInfo.class);
if (appInfo == null) {
Slog.d(TAG, "fixSmallIcon: appInfo is null");
return;
}
if (NotificationInfoUtil.isAndroidPackage(pkg, appInfo) || NotificationInfoUtil.isSystemOrPlatformSignedApp(appInfo) || NotificationInfoUtil.isCommercialNotification(notification, opPkg) || isOplusAppUseSmallIcon(notification, pkg)) {
return;
}
int appIconRes = appInfo.icon;
if (appIconRes == 0) {
Slog.d(TAG, "fixSmallIcon: Failed to get the app icon, no icon in appInfo");
return;
}
Icon appIcon = Icon.createWithResource(pkg, appIconRes);
if (appIcon == null) {
return;
}
notifExtras.putBoolean(OPLUS_SMALLICON_USE_APP_ICON, true);
notification.setSmallIcon(appIcon);
} |
Owner
|
这个方法在哪里调用的 |
Contributor
Author
Android Services中通知管理服务(NotificationManagerService)的enqueueNotificationInternal方法内 |
Contributor
Author
// Fix the notification as best we can.
try {
fixNotification(notification, pkg, tag, id, userId, notificationUid,
policy, stripUijFlag);
+ if (this.mNMSWrapper.getNMSExt() != null)
+ this.mNMSWrapper.getNMSExt().fixNotificationForOplus(notification, pkg, opPkg); // 此方法修改通知图标
} catch (Exception e) {
if (notification.isForegroundService()) {
throw new SecurityException("Invalid FGS notification", e);
}
Slog.e(TAG, "Cannot fix notification", e);
return false;
} |
Contributor
Author
|
ColorOS的行为比较的破坏原生逻辑 暂时不知道有什么别的办法 |
Owner
|
有够过分的,hook 系统框架有行为变更重启手机的需求,代价比较高,我看看后面有没有什么解决方案,明天等我上班后再研究 |
fankes
approved these changes
May 29, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
ColorOS 15.0.1 通过系统框架fixSmallIcon方法替换通知图标为应用彩色图标, 通过Hook系统框架拦截此方法阻止 ColorOS 15.0.1 替换通知图标