Skip to content
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

解析APK图标时得到一个XML。附带一个临时解决方案 #65

Open
LEORChn opened this issue Jul 11, 2021 · 1 comment
Open

Comments

@LEORChn
Copy link

LEORChn commented Jul 11, 2021

测试APK:知乎 v5.8.1

下载APK:https://github.com/LEORChn/ContentDelivery/releases/download/temp/zhihu_5.8.1.apk
(如果没有特殊需要,在一段时间后会清除。)

浏览器:Chrome 43

new AppInfoParser(file).parse().then(function(e){
  console.log(e.icon);
  // 预期表现:data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAYAAADimH...
  // 实际表现:data:image/png;base64,AwAIAMgAAAABABwAZAAAAAMAAAAAAAAAAAEAACgAAA...
});

临时解决方案 in dist/app-info-parser.js

code with lines tag

// is it png?
if((apkInfo.icon || '').contains(';base64,iVBORw0K')){
  // yes it is png
  resolve(apkInfo);
}else{
  // no it is not png but maybe xml
  var xml = new BinaryXmlParser(iconBuffer).parse();
  if(xml.nodeName == 'bitmap'){
    // xml.attributes[0].typedValue.value = 'resourceId:0x7f0d0002'
    var iconRef = xml.attributes[0].typedValue.value.split(':')[1].toUpperCase().replace('0X', '@');
    _this2.getEntry(resourceMap[iconRef][0]).then(function (iconBuffer) {
      apkInfo.icon = getBase64FromBuffer(iconBuffer);
      resolve(apkInfo);
    });
  }else{
    // exception... but when? i dont know.
    resolve(apkInfo);
  }
}
@chenquincy
Copy link
Owner

@LEORChn 抱歉,在封闭开发中,暂时没有精力解决问题。看起来像是 apk 的图标路径解析,等有时间会修复~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants