1、Android apk 调用Hidl处理
app添加对应的hidl jar包
2、MainActivity 添加如下代码
package com.example.test2;import androidx.appcompat.app.AppCompatActivity;
import vendor.hardware.test.V1_0.ITest;
import vendor.hardware.test.V1_0.ITestCmdCallback;
import android.os.Bundle;
import android.os.RemoteException;import java.util.ArrayList;public class MainActivity extends AppCompatActivity {ITestCmdCallback mCallback;ITest mTest;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);}@Overrideprotected void onResume() {super.onResume();try {mTest = ITest.getService(false);android.util.Log.i("zmao","getService success!");} catch(Exception e) {android.util.Log.i("zmao","exception" + e);}}
}
3、编译报错
Android studio 报错android.hidl.base.V1_0.IBase无法找到,一共导入如下jar包后编译pass
4、安装调试
安装后测试,发生selinux权限问题
adb root
adb remount
adb shell setenforce 0
APK调用Hidl成功