shwenzhang / AndResGuard

proguard resource for Android by wechat team
Apache License 2.0
8.53k stars 1.53k forks source link

获取屏幕尺寸错误:Resources.getSystem().getDisplayMetrics().widthPixels #442

Open DysaniazzZ opened 3 years ago

DysaniazzZ commented 3 years ago

设备名称: OnePlus 8 Pro

Android 版本: 11

版本号: Hydrogen Os 11.0.2.2.IN11

问题描述: 测试发现使用 AndResGuard 在部分高版本手机上会出现 Resources.getSystem().getDisplayMetrics().widthPixels 拿到的屏幕宽高出现错误。上面这个机型在横屏时的实际宽高为:3047 x 1380,然而资源混淆后拿到的宽高变成了:1440 x 2987。

获取屏幕宽高的方法:

DisplayMetrics displayMetrics = Resources.getSystem().getDisplayMetrics();
int width = displayMetrics.widthPixels;
int height = displayMetrics.heightPixels;

assembleDebug 版本获取的数据(正确):

Screen Shot 2020-12-04 at 15 01 49

resguardDebug 版本获取的数据(错误):

Screen Shot 2020-12-04 at 14 59 46
simpleton commented 3 years ago

是只在OnePlus 8 Pro复现么?