Skip to content

hook 原生方法疑问 #28

Description

@529523346

在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是有值的

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions