| | |
| | | |
| | | import androidx.annotation.Nullable; |
| | | |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.util.concurrent.atomic.AtomicBoolean; |
| | | |
| | | /** |
| | |
| | | |
| | | @Override |
| | | public void SendCmd(int cmd, String value) throws RemoteException { |
| | | Log.d(TAG, "Process " + Process.myPid() + " Thread " + Thread.currentThread().getId() + " RecvMsgFromMainProc cmd = " + String.format(" %04X ", cmd) + " length " + value.length() + " value " + value.trim()); |
| | | MainProcMsgEntry(cmd, value.trim()); |
| | | if (cmd == 0x8100) { |
| | | try { |
| | | byte [] file = value.getBytes("ISO-8859-1"); |
| | | Log.d(TAG, byte2hex(file)); |
| | | MainProcBinMsgEntry(cmd, file, file.length); |
| | | } catch (UnsupportedEncodingException e) { |
| | | Log.d(TAG, "UnsupportedEncodingException"); |
| | | } |
| | | } else { |
| | | Log.d(TAG, "Process " + Process.myPid() + " Thread " + Thread.currentThread().getId() + " RecvMsgFromMainProc cmd = " + String.format(" %04X ", cmd) + " length " + value.length() + " value " + value.trim()); |
| | | MainProcMsgEntry(cmd, value.trim()); |
| | | } |
| | | } |
| | | }; |
| | | @Nullable |
| | |
| | | if (!mIsServiceDestroyed.get()){ |
| | | onMessageArrived(cmd, value); |
| | | } |
| | | |
| | | |
| | | |
| | | Log.d(TAG, "SendMsgToMainProc cmd = " + String.format("%04X", cmd) + " json = " + value); |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | private String byte2hex(byte [] buffer){ |
| | | StringBuilder h = new StringBuilder(); |
| | | |
| | | Log.d(TAG, "byte buffer length = " + buffer.length); |
| | | |
| | | for(int i = 0; i < buffer.length; i++){ |
| | | String temp = Integer.toHexString(buffer[i] & 0xFF); |
| | | if(temp.length() == 1){ |
| | | temp = "0" + temp; |
| | | } |
| | | h.append(temp); |
| | | h.append(" "); |
| | | } |
| | | |
| | | return h.toString(); |
| | | } |
| | | |
| | | // Used to load the 'native-lib' library on application startup. |
| | | static { |
| | | System.loadLibrary("native-lib"); |
| | |
| | | |
| | | public native void startNative(); |
| | | public native void MainProcMsgEntry(int cmd, String value); |
| | | public native void MainProcBinMsgEntry(int cmd, byte []data, int length); |
| | | } |