开发中经常会遇到,三方检测apk的监测数据和实际的监测数据不符合的情况,今天来看看 主频 和 屏幕尺寸如何修改,如果有需求改ram rom的可参考这篇
Mr.Alright---安卓如何修改3rd App(某兔兔、某大师、CPU-Z)等检测信息
屏幕尺寸的修改
这个东西理论上不能修改的,因为这是实际的尺寸,GMS过认证的时候会实际用尺子去测试,所以不能乱改,params->physical_width = 57; params->physical_height = 124;
真的要改的话就只能修改textview了,虽然可能会影响一定性能,但是客户是上帝啊!
平时我们设置textview的内容一般用的都是setText()的方法,安兔兔原来也是这么用的,可能是安兔兔发现,厂商随意的修改手机信息,所以现在改成了append的方式来设置内容了
alps\frameworks\base\core\java\android\widget\TextView.java
private boolean mNeedFakePhysicalSize;
private CharSequence[] mRealPhysicalSize;
private CharSequence mFakePhysicalSize;
private CharSequence getPhysicalSize(CharSequence oriPhysicalSize) {
mNeedFakePhysicalSize = mContext.getResources().getBoolean(com.android.internal.R.bool.need_fake_physical_size);
mRealPhysicalSize = mContext.getResources().getStringArray(com.android.internal.R.array.real_physical_size);
mFakePhysicalSize = mContext.getResources().getString(com.android.internal.R.string.fake_physical_size);
if (!mNeedFakePhysicalSize || oriPhysicalSize == null
|| (!mContext.getPackageName().contains("com.antutu")
&& !mContext.getPackageName().contains("com.cpuid.cpu_z")
&& !mContext.getPackageName().contains("com.ludashi"))) {
return oriPhysicalSize;
}
try {
for (CharSequence reallPhysicalSize : mRealPhysicalSize) {
if (oriPhysicalSize.toString().contains(reallPhysicalSize)) {
oriPhysicalSize = oriPhysicalSize.toString().replace(reallPhysicalSize, mFakePhysicalSize);
break;
}
}
} catch (Exception e) {
Log.i("getPhysicalSize", "Failed to obtain fake physical size");
}
return oriPhysicalSize;
}
// 针对安兔兔
public void append(CharSequence text, int start, int end) {
if (!(mText instanceof Editable)) {
setText(mText, BufferType.EDITABLE);
}
((Editable) mText).append(text, start, end);
//add +++++++++++++++++++++start
if(text != null){
mText = getPhysicalSize(mText);
}
//add ++++++++++++++++++++ end
if (mAutoLinkMask != 0) {
boolean linksWereAdded = Linkify.addLinks(mSpannable, mAutoLinkMask);
// Do not change the movement method for text that support text selection as it
// would prevent an arbitrary cursor displacement.
if (linksWereAdded && mLinksClickable && !textCanBeSelected()) {
setMovementMethod(LinkMovementMethod.getInstance());
}
}
}
// 其他的
@android.view.RemotableViewMethod
public final void setText(CharSequence text) {
//add ++++++++++++++++++ start
if(text != null){
text = getPhysicalSize(text);
}
//add +++++++++++++++++++ end
setText(text, mBufferType);
}
// 相应资源
<java-symbol type="bool" name="need_fake_physical_size" />
<java-symbol type="array" name="real_physical_size" />
<java-symbol type="string" name="fake_physical_size"/>
<bool name="need_fake_physical_size">true</bool>
<string name="fake_physical_size">5.50</string>
<string-array name="real_physical_size">
<item>5.41</item>
<item>5.37</item>
<item>5,41</item>
<item>5,37</item>
</string-array>
主频的修改
首先确定下你的项目使用的是那个版本的kernel,可以在alps\device\xxx\xxx_project\projectinfo.txt中查看
在项目对应的alps/device/xxx/xxx_project/ProjectConfig.mk中打开宏
FAKE_CPU_MAX_FREQ = yes
之后在alps/kernel-4.14/arch/arm/configs/xxx_debug_defconfig 和 alps/kernel-4.14/arch/arm/configs/xxx_defconfig中添加对应的宏
CONFIG_FAKE_CPU_MAX_FREQ=y
在 alps/kernel-4.9-lc/drivers/cpufreq/Kconfig 中添加
config FAKE_CPU_MAX_FREQ
bool "FAKE CPU MAX FREQ"
alps/kernel-4.9-lc/drivers/cpufreq/cpufreq.c 中修改
// A: for fake cpu max freq {
#ifdef CONFIG_FAKE_CPU_MAX_FREQ
#define show_one(file_name, object) \
static ssize_t show_##file_name \
(struct cpufreq_policy *policy, char *buf) \
{ \
if ((policy->object == policy->cpuinfo.max_freq \
&& policy->cpuinfo.max_freq == 1248000) \
|| (policy->object == policy->max \
&& policy->max == 1248000) \
|| (policy->object == policy->cur \
&& policy->cur == 1248000)) \
{ \
return sprintf(buf, "%u\n", 1300000); \
} \
return sprintf(buf, "%u\n", policy->object); \
}
#else /* FAKE_CPU_MAX_FREQ */
// A: }
#define show_one(file_name, object) \
static ssize_t show_##file_name \
(struct cpufreq_policy *policy, char *buf) \
{ \
return sprintf(buf, "%u\n", policy->object); \
}
// A: for fake cpu max freq {
#endif /* FAKE_CPU_MAX_FREQ */
// A: }
OK啦 !