Android添加暗密码显示高通的nv值

在电话中输入“*#316”获取设备信息,其中以高通的NV值为例

基于google原生代码修修改Dialer

SpecialCharSequenceMgr.java handleChars()解析字符串时添加判断handleDeviceInfoEntry()

  /** This class is never instantiated. */
    /** software & hardware version display command code */
  private static final String DEVICEINFO_DISPLAY = "*#316";
  private SpecialCharSequenceMgr() {}
  public static boolean handleChars(Context context, String input, EditText textField) {
    // get rid of the separators so that the string gets parsed correctly
    String dialString = PhoneNumberUtils.stripSeparators(input);
    if (handleDeviceIdDisplay(context, dialString)
        || handleRegulatoryInfoDisplay(context, dialString)
        || handlePinEntry(context, dialString)
        || handleAdnEntry(context, dialString, textField)
        || handleDeviceInfoEntry(context, dialString)
        || handleSecretCode(context, dialString)
        ) {
      return true;
    }
  
  static boolean handleDeviceInfoEntry(Context context, String input) {
    //Secret codes are in the form *#*#<code>#*#*

    int len = input.length();
    if (len > 4 && input.equals(DEVICEINFO_DISPLAY)) {
      showDeviceInfoPanel(context);
      return true;
    }
    return false;
  }
 static TextView hwn1, hwn2;
 static void showDeviceInfoPanel(Context context) {
    Log.d(TAG, "showDeviceInfoPanel " + "mHWNStr =" + mHWNStr + "qcnStr =" + qcnStr );
    mHWNStr = SystemProperties.get("ro.vendor.sys.hw.rev","");
    qcnStr = SystemProperties.get("ro.vendor.sys.qcn.rev","");
      LinearLayout view = new LinearLayout(context);
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT);
    layoutParams.setMargins(50, 0, 20, 0);
    view.setOrientation(LinearLayout.VERTICAL);

    hwn1 = new TextView(context);
    hwn2 = new TextView(context);
    view.addView(hwn1, layoutParams);
    view.addView(hwn2, layoutParams);
    hwn1.setText(R.string.hardware_version);
    hwn2.setText(mHWNStr);
    hwn1.setTextColor(Color.BLACK);
    AlertDialog alert = new AlertDialog.Builder(context)
            .setTitle(R.string.device_version)
            .setView(view)
            .setPositiveButton(android.R.string.ok, null)
            .setCancelable(false).show();
 }

使用 QcRilHook 获取 高通的NV值
Android.mk修改如下

LOCAL_JAVA_LIBRARIES += \
	qcrilhook \
	qti-telephony-utils \
LOCAL_CERTIFICATE := platform
LOCAL_SYSTEM_EXT_MODULE := true

AndroidManifest.xml修改

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  coreApp="true"
  package="com.android.dialer"
  android:sharedUserId="android.uid.system">
  <uses-permission android:name="com.qualcomm.permission.USE_QCRIL_MSG_TUNNEL" />
  <application>
  	<uses-library android:name="com.qualcomm.qcrilhook" />
	<uses-library android:name="qti-telephony-utils" />
  </application>
</manifest>

[SpecialCharSequenceMgr.java]代码修改

  static final int NV_HARDWARE_VERSION = 6853;
  static final int NV_QCN_VERSION = 6859;
  public static QcRilHook mQcRilOemHook;
  public static boolean mQcRilHookReady = false;
  public static QcRilHookCallback mQcrilHookCb;
  
    static boolean handleDeviceInfoEntry(Context context, String input) {
    //Secret codes are in the form *#*#<code>#*#*

    int len = input.length();
    if (len > 4 && input.equals(DEVICEINFO_DISPLAY)) {
        if (mQcRilHookReady) {
            showDeviceInfoPanel(context);
        } else {
			mQcrilHookCb = new QcRilHookCallbackImpl(context);
            mQcRilOemHook = new QcRilHook(context, mQcrilHookCb);
        }
        return true;
    }
    return false;
  }
  public static class QcRilHookCallbackImpl implements QcRilHookCallback {
        private final Context context;

        public QcRilHookCallbackImpl(Context context) {
            this.context = context;
        }
        public void onQcRilHookReady() {
            Log.w(TAG, "onQcRilHookReady ");
            mHWNStr = mQcRilOemHook.getDeviceNV(NV_HARDWARE_VERSION);
            qcnStr = mQcRilOemHook.getDeviceNV(NV_QCN_VERSION);   
            if (TextUtils.isEmpty(SpecialCharSequenceMgr.mHWNStr)) {
                mHWNStr = "N/A";
            }
            if (TextUtils.isEmpty(qcnStr)) {
                SpecialCharSequenceMgr.qcnStr = "N/A";
            }
            setProp("ro.vendor.hon.sys.hw.rev",mHWNStr);
            setProp("ro.vendor.hon.sys.qcn.rev",qcnStr);
            mQcRilHookReady = true;
            Log.d(TAG, "QcRilHook Service ready, notifying registrants");
            notifyOemHookStatus(this.context);
        }
        public void onQcRilHookDisconnected() {
        }
    }

    static void notifyOemHookStatus(Context context) {
        Log.d(TAG, "notifying OemHook status ");
        if (!mQcRilHookReady) {
            mHWNStr = SystemProperties.get("ro.vendor.hon.sys.hw.rev","");
            qcnStr = SystemProperties.get("ro.vendor.hon.sys.qcn.rev","");
            if (TextUtils.isEmpty(mHWNStr)) {
                mHWNStr = "N/A";
                setProp("ro.vendor.hon.sys.hw.rev",mHWNStr);
            }
            if (TextUtils.isEmpty(qcnStr)) {
                qcnStr = "N/A";
                setProp("ro.vendor.hon.sys.qcn.rev",qcnStr);
            }
        }
        showDeviceInfoPanel(context);
    }
    public static void setProp(String key, String value) {
        Log.w(TAG, "setProp >> key = " + key + ", value = " + value);
        try {
            final Class systemPropertiesClass = Class.forName("android.os.SystemProperties");
            if (systemPropertiesClass != null) {
                final Method set = systemPropertiesClass.getMethod("set", String.class, String.class);
                if (set != null) {
                    set.invoke(systemPropertiesClass, key, value);
                }
            }
        } catch (Exception e) {
            Log.w(TAG, "SystemProperties.set failed " + e);
        }
    }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值