找到frameworks\base\core\java\android\widget\TextView.java该类
查看源代码可以找到
public final void setText(CharSequence text)这个方法加个判断语句
public final void setText(CharSequence text) {
if(KstTextView.isModifyTextForThirdPartApp(mContext)){
text = KstTextView.setText(mContext, text, getId(), this);
//意思就是判断是不是需要的包名 然后对包名内的符合需求的字符串进行修改
}
setText(text, mBufferType);
}
写另一个类
frameworks\base\core\java\android\widget\KstTextView.java
public static boolean isModifyTextForThirdPartApp(Context context){
if(context.getPackageName().equals(FILTER_KEY_ANTUTU)||
context.getPackageName().equals(FILTER_KEY_CPUX)|| //可以加别的第三方apk包名
context.getPackageName().equals(FILTER_KEY_ASSISTANTFORANDROID)){
return true;
}
return false;
}
public static final CharSequence setText(Context context,CharSequence text, int id, View view) {
if(text != null){
if(text.toString().contains("5.1")&&!text.toString().contains("G")){
text = text.toString().replace("5.1", "7.0");
}
}