NotificationCompatCompatV21.java 文件源码

java
阅读 32 收藏 0 点赞 0 评论 0

项目:TPlayer 作者:
private boolean resolveRemoteViews(Context appContext, String packageName, Notification notification) {
    if (notification == null) {
        return false;
    }
    String sourcePath = null;
    PackageInfo packageInfo = getPackageInfo(packageName);
    ApplicationInfo host = getHostContext().getApplicationInfo();
    if (packageInfo != null) {
        sourcePath = packageInfo.applicationInfo.sourceDir;
    }
    if (TextUtils.isEmpty(sourcePath)) {
        sourcePath = getPackageResourcePath(packageName).getAbsolutePath();
    }

    //Fix RemoteViews
    getNotificationFixer().fixNotificationRemoteViews(appContext, notification);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        getNotificationFixer().fixIcon(notification.getSmallIcon(), appContext, packageInfo != null);
        getNotificationFixer().fixIcon(notification.getLargeIcon(), appContext, packageInfo != null);
    } else {
        getNotificationFixer().fixIconImage(appContext.getResources(), notification.contentView, false, notification);
    }
    notification.icon = host.icon;

    ApplicationInfo proxyApplicationInfo = new ApplicationInfo(host);

    proxyApplicationInfo.packageName = packageName;
    proxyApplicationInfo.publicSourceDir = sourcePath;
    proxyApplicationInfo.sourceDir = sourcePath;

    fixApplicationInfo(notification.tickerView, proxyApplicationInfo);
    fixApplicationInfo(notification.contentView, proxyApplicationInfo);
    fixApplicationInfo(notification.bigContentView, proxyApplicationInfo);
    fixApplicationInfo(notification.headsUpContentView, proxyApplicationInfo);
    Bundle bundle = Reflect.on(notification).get("extras");
    if (bundle != null) {
        bundle.putParcelable(EXTRA_BUILDER_APPLICATION_INFO, proxyApplicationInfo);
    }
    return true;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号