Open 529523346 opened 1 month ago
在hook textview的settext方法时发现有时候获取到的原text为null,不知道是啥原因,望大佬指点 @Proxy() @TargetClass(value = "android.widget.TextView", scope = Scope.ALL) @TargetMethod(methodName = "setText") public void aroundSetText(CharSequence text) { Logger.e("TextViewSetTextAspect:CharSequence=>TextView被hook=>" + "原字符串为:" + text); // 获取原始参数 String stringKey = text == null ? null : ResourceMapper.getNameForValue(text.toString()); // 修改参数 if (stringKey != null && !stringKey.equals("")) { String configValues = CacheUtil.INSTANCE.getAppConfig().getLanguage_package().get(stringKey); if (configValues != null && configValues.length() > 0) { Logger.e("TextViewSetTextAspect:CharSequence=>修改前的字符串=>" + text + ",Key=>" + stringKey + ",匹配到的字符串=>" + configValues); text = configValues; } else { Logger.e("TextViewSetTextAspect:CharSequence=>未匹配到value:" + "原字符串为=>" + text + ",Key为=>" + stringKey); } } else { Logger.e("TextViewSetTextAspect:CharSequence=>未匹配到key:" + "原字符串为=>" + text + ",Key为=>" + stringKey); } Origin.callVoid(); } 发现原字符串有还时候输出为空串,但是实际textview是有值的
@Proxy() @TargetClass(value = "android.widget.TextView", scope = Scope.ALL) @TargetMethod(methodName = "setText") public void aroundSetText(CharSequence text) { Logger.e("TextViewSetTextAspect:CharSequence=>TextView被hook=>" + "原字符串为:" + text); // 获取原始参数 String stringKey = text == null ? null : ResourceMapper.getNameForValue(text.toString()); // 修改参数 if (stringKey != null && !stringKey.equals("")) { String configValues = CacheUtil.INSTANCE.getAppConfig().getLanguage_package().get(stringKey); if (configValues != null && configValues.length() > 0) { Logger.e("TextViewSetTextAspect:CharSequence=>修改前的字符串=>" + text + ",Key=>" + stringKey + ",匹配到的字符串=>" + configValues); text = configValues; } else { Logger.e("TextViewSetTextAspect:CharSequence=>未匹配到value:" + "原字符串为=>" + text + ",Key为=>" + stringKey); } } else { Logger.e("TextViewSetTextAspect:CharSequence=>未匹配到key:" + "原字符串为=>" + text + ",Key为=>" + stringKey); } Origin.callVoid(); }
在hook textview的settext方法时发现有时候获取到的原text为null,不知道是啥原因,望大佬指点
@Proxy() @TargetClass(value = "android.widget.TextView", scope = Scope.ALL) @TargetMethod(methodName = "setText") public void aroundSetText(CharSequence text) { Logger.e("TextViewSetTextAspect:CharSequence=>TextView被hook=>" + "原字符串为:" + text); // 获取原始参数 String stringKey = text == null ? null : ResourceMapper.getNameForValue(text.toString()); // 修改参数 if (stringKey != null && !stringKey.equals("")) { String configValues = CacheUtil.INSTANCE.getAppConfig().getLanguage_package().get(stringKey); if (configValues != null && configValues.length() > 0) { Logger.e("TextViewSetTextAspect:CharSequence=>修改前的字符串=>" + text + ",Key=>" + stringKey + ",匹配到的字符串=>" + configValues); text = configValues; } else { Logger.e("TextViewSetTextAspect:CharSequence=>未匹配到value:" + "原字符串为=>" + text + ",Key为=>" + stringKey); } } else { Logger.e("TextViewSetTextAspect:CharSequence=>未匹配到key:" + "原字符串为=>" + text + ",Key为=>" + stringKey); } Origin.callVoid(); }
发现原字符串有还时候输出为空串,但是实际textview是有值的