Android 8 app 使用QcRilHook 分析
如果需要在app中使用 QcRilHook 获取 高通的NV值 你需要如下操作
- Android.mk
LOCAL_JAVA_LIBRARIES := qcrilhook
2 AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.qualcomm.qti.phonefeature"
android:sharedUserId="android.uid.phone" >
<permission
android:name="com.qualcomm.permission.USE_PHONE_SERVICE"
android:protectionLevel="signatureOrSystem" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="com.qualcomm.permission.USE_QCRIL_MSG_TUNNEL"/>
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.CAPTURE_AUDIO_OUTPUT" />
<application
android:name=".AppGlobals"
android:process="com.android.phone"
android:supportsRtl="true" >
<uses-library android:name="com.qualcomm.qcrilhook" />
<service android:name=".FeatureService"
android:singleUser="true"/>
<activity
android:name=".PrimarySubSetting"
android:configChanges="orientation|screenSize|keyboardHidden"
android:icon="@drawable/ic_settings_sim_display"
android:label="@string/multi_sim_settings_title" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="com.qualcomm.qti.phonefeature.LTE_CONFIGURE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
- java class 使用
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneFactory;
import com.qualcomm.qcrilhook.QcRilHook;
import com.qualcomm.qcrilhook.QcRilHookCallback;
public class AppGlobals extends Application {
public static final String TAG = "phone_features";
ServiceStateMonitor mServiceMonitor;
CardStateMonitor mCardMonitor;
Phone[] mPhones;
QcRilHook mQcRilHook;
private boolean mQcRilHookLoaded = false;
private RegistrantList mProxyLoadedRegistrants = new RegistrantList();
private QcRilHookCallback mQcRilHookCallback = new QcRilHookCallback() {
@Override
public void onQcRilHookReady() {
mQcRilHookLoaded = true;
synchronized (mProxyLoadedRegistrants) {
mProxyLoadedRegistrants.notifyRegistrants();
}
}
@Override
public void onQcRilHookDisconnected() {
mQcRilHookLoaded = false;
}
};
}
@Override
public void onCreate() {
super.onCreate();
if (UserHandle.myUserId() == 0) {
mPhones = PhoneFactory.getPhones();
mServiceMonitor = new ServiceStateMonitor();
mCardMonitor = new CardStateMonitor(this);
mQcRilHook = new QcRilHook(this, mQcRilHookCallback);
}
}
public void registerQcRilHookLoaded(Handler handler, int what, Object obj) {
Registrant r = new Registrant(handler, what, obj);
synchronized (mProxyLoadedRegistrants) {
mProxyLoadedRegistrants.add(r);
if (mQcRilHookLoaded) {
r.notifyRegistrant();
}
}
}
public void unregisterQcRilHookLoaded(Handler handler) {
synchronized (mProxyLoadedRegistrants) {
mProxyLoadedRegistrants.remove(handler);
}
}
public boolean isQcRilHookLoaded() {
return mQcRilHookLoaded;
}
}
- 操作细节
private void getModemInfoString(int type){
int token;
int requestId = mQcRILHook.QCRIL_EVT_HOOK_GET_MODEM_INFO_STRING;
Message msg = Message.obtain(null, MSG_GET_MODEM_INFO_STRING_RESP, token, 0);
OemHookCallback oemHookCb = new TomOemHookCallback(msg);
mQcRILHook.sendQcRilHookMsgAsync(requestId, request, oemHookCb, 0);
}
if(mQcRILHook.getBindQcrilMsgTunnelServiceState()){
Log.d(LOG_TAG,"BindQcrilMsgTunnelService again ok");
getModemInfoString();
}
总结
这里要说一下manifest里的一个属性 android:process=“com.android.phone” 具体如下:
如果需要将某些组件(如Service,Activity等)运行在单独的进程中,就需要用到android:process属性了。我们可以给android的组件设置android:process属性来使其运行在指定的进程中。
|