JAVA 是客户端端,C++ 是服务端
Java 端代码:
import android.view.InputChannel;
import android.os.Binder;
import android.os.IBinder;
import android.os.Parcel;
import android.os.ServiceManager;
import android.os.SystemProperties;
public boolean sendData(int cmd, Parcel data) throws Exception {
IBinder binder = null;
final int MAX_WAIT = 9; //最多获取service 10次
int index = 0;
//SystemProperties.set("ctl.start", "tsp_auto_service");
do {
Log.i("---LHC---", "get service : chinatsp.autoaction");
binder = ServiceManager.getService("chinatsp.autoaction");
if (null == binder){
try {
Thread.sleep(100);
} catch (Exception e) {
e.printStackTrace();
}
}
}while ((null == binder) && ((index++) < MAX_WAIT));
if (