/** Finalise communicate with socket server. */ public void endClient() { Xlog.v(TAG, "enter endClient"); mSendThread.interrupt(); Xlog.v(TAG, "Queue remaining:" + mCommandQueue.size()); closeClient(); mCallBack = null; }
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case MENU_ID_UPGRADE: if (Util.isLowBattery(getApplicationContext())) { showDialog(DIALOG_LOW_BATTERY); } else { showDialog(DIALOG_INSTALLWARNING); } return true; case android.R.id.home: Xlog.v(TAG, "Navigation key,finish activity"); if (!mDownloadInfo.getIfNeedRefreshMenu()) { if (mDownloadInfo.getActivityID() < 0) { mGoToMainEntry = true; SdPkgInstallActivity.this.startActivity(new Intent(this, MainEntry.class)); } } SdPkgInstallActivity.this.finish(); break; case MENU_ID_REFRESH: mGoToMainEntry = true; requeryPackages(); break; default: break; } return super.onOptionsItemSelected(item); }
// add for gemini private static void wakeUpServiceGemini(Context context, int simId) { Xlog.v(MmsApp.TXN_TAG, "wakeUpServiceGemini: start transaction service ... simId=" + simId); Intent it = new Intent(context, TransactionService.class); it.putExtra(Phone.GEMINI_SIM_ID_KEY, simId); context.startService(it); }
public static final int v(String tag, String msg, Throwable tr) { int result; if (SR_XLOG_ENABLED) { result = Xlog.v(tag, msg, tr); } else { result = Log.v(tag, msg, tr); } return result; }
/** * Send command to socket server. * * @param command Command need to send */ public void sendCommand(String command) { Xlog.v(TAG, "enter sendCommand"); String sendComm = "$" + command + "*" + calcCS(command); Xlog.v(TAG, "Send command: " + sendComm); if (!mSendThread.isAlive()) { Xlog.v(TAG, "sendThread is not alive"); mSendThread.start(); } if (command.equals(sendComm) || mCommandQueue.contains(sendComm)) { Xlog.v(TAG, "send command return because of hasn't handle the same"); return; } try { mCommandQueue.put(sendComm); } catch (InterruptedException ie) { Xlog.w(TAG, "send command interrupted:" + ie.getMessage()); } }
public void onClick(View v) { if (v.equals(mChecked)) { long value = mChecked.isChecked() == true ? 0xFFFFFFFFL : 0; mBtTest = new BtTest(); mBtTest.setFWDump(value); // SystemProperties.set(KEY_DEBUG_FEATURE, Long.toString(value)); Toast.makeText(this, "The change will be valid after you restart phone", Toast.LENGTH_LONG) .show(); Xlog.v(TAG, "DebugFeature isChecked--" + mChecked.isChecked()); } }
@Override protected void onStop() { Xlog.i(TAG, "onStop"); if (!mGoToMainEntry && !mDownloadInfo.getIfNeedRefresh() && mDownloadInfo.getActivityID() < 0 && (MainEntry.getInstance() == null || !MainEntry.getInstance().isStarted())) { Xlog.v(TAG, "background, show new version notification"); mNotifyManager.showNewVersionNotification(); } super.onStop(); }
private String getUsbMode() { String result = null; StringBuilder strBuilder = new StringBuilder(); strBuilder.append("cat "); strBuilder.append(mPortFile); Xlog.v(TAG, "get current dramc cmd: " + strBuilder.toString()); try { if (ShellExe.RESULT_SUCCESS == ShellExe.execCommand(strBuilder.toString(), true)) { result = ShellExe.getOutput(); } } catch (IOException e) { Xlog.w(TAG, "get current dramc IOException: " + e.getMessage()); } return result; }
/** Start client socket and connect with server. */ private void openClient() { Xlog.v(TAG, "enter startClient"); if (null != mClientSocket && mClientSocket.isConnected()) { Xlog.d(TAG, "localSocket has started, return"); return; } try { mClientSocket = new Socket("127.0.0.1", SERVER_PORT); mClientSocket.setSoTimeout(SOCKET_TIME_OUT_TIME); mDataOutput = new DataOutputStream(mClientSocket.getOutputStream()); mDataInput = new DataInputStream(mClientSocket.getInputStream()); } catch (UnknownHostException e) { Xlog.w(TAG, e.getMessage()); } catch (IOException e) { Xlog.w(TAG, e.getMessage()); } }
private boolean isUsbConnected() { String result = null; boolean isConnected = false; StringBuilder strBuilder = new StringBuilder(); strBuilder.append("cat "); strBuilder.append(USB_CONNECT_STATE); Xlog.v(TAG, "isUsbConnected cmd: " + strBuilder.toString()); try { if (ShellExe.RESULT_SUCCESS == ShellExe.execCommand(strBuilder.toString(), true)) { result = ShellExe.getOutput(); if (result.equals(USB_CONFIGURED) || result.equals(USB_CONNECT)) { isConnected = true; } } } catch (IOException e) { Xlog.w(TAG, "get current dramc IOException: " + e.getMessage()); } return isConnected; }
private void sendNotifyRespInd(int status) throws MmsException, IOException { // Create the M-NotifyResp.ind Xlog.v(MmsApp.TXN_TAG, "NotificationTransaction: sendNotifyRespInd()"); NotifyRespInd notifyRespInd = new NotifyRespInd( PduHeaders.CURRENT_MMS_VERSION, mNotificationInd.getTransactionId(), status); // MTK_OP01_PROTECT_START String optr = SystemProperties.get("ro.operator.optr"); if (optr.equals("OP01")) { // X-Mms-Report-Allowed Optional SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext); boolean reportAllowed = true; if (FeatureOption.MTK_GEMINI_SUPPORT) { reportAllowed = prefs.getBoolean( Integer.toString(mSimId) + "_" + MessagingPreferenceActivity.MMS_ENABLE_TO_SEND_DELIVERY_REPORT, true); } else { reportAllowed = prefs.getBoolean(MessagingPreferenceActivity.MMS_ENABLE_TO_SEND_DELIVERY_REPORT, true); } Xlog.d(MmsApp.TXN_TAG, "reportAllowed: " + reportAllowed); try { notifyRespInd.setReportAllowed(reportAllowed ? PduHeaders.VALUE_YES : PduHeaders.VALUE_NO); } catch (InvalidHeaderValueException ihve) { // do nothing here Xlog.e(MmsApp.TXN_TAG, "notifyRespInd.setReportAllowed Failed !!"); } } // MTK_OP01_PROTECT_END // Pack M-NotifyResp.ind and send it if (MmsConfig.getNotifyWapMMSC()) { sendPdu(new PduComposer(mContext, notifyRespInd).make(), mContentLocation); } else { sendPdu(new PduComposer(mContext, notifyRespInd).make()); } }
@Override protected void onResume() { super.onResume(); String current = getUsbMode(); Xlog.v(TAG, "Current: " + current); if (null == current) { Toast.makeText(this, R.string.uart_usb_switch_geterror, Toast.LENGTH_SHORT).show(); finish(); return; } Boolean mode = null; if (current.contains(MODE_USB)) { mode = true; } else if (current.contains(MODE_UART)) { mode = false; } updateStatus(mode); mRgMode.setOnCheckedChangeListener(mCheckListener); }
/** Stop client socket and disconnect with server. */ private void closeClient() { Xlog.v(TAG, "enter closeClient"); try { if (null != mDataInput) { mDataInput.close(); } if (null != mDataOutput) { mDataOutput.close(); } if (null != mClientSocket) { mClientSocket.close(); } } catch (IOException e) { Xlog.w(TAG, "closeClient IOException: " + e.getMessage()); } finally { mClientSocket = null; mDataInput = null; mDataOutput = null; } }
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { Xlog.v( TAG, "onActivityResult: requestCode=" + requestCode + ", resultCode=" + resultCode + ", data=" + data); if (resultCode != RESULT_OK && resultCode != RESULT_CANCELED) { return; } switch (requestCode) { case REQUEST_CODE_EDIT_SLIDE: synchronized (this) { mDirty = true; } setResult(RESULT_OK, mResultIntent); if ((data != null) && data.getBooleanExtra("done", false)) { finish(); return; } try { initSlideList(); } catch (MmsException e) { Log.e(TAG, "Failed to initialize the slide-list.", e); finish(); return; } break; } }
private void setUsbMode(String value) { Xlog.v(TAG, "setUsbMode(), value: " + value); SystemProperties.set(KEY_USB_PORT, value); }
/** * Constructor, initial parameters and start thread to send/receive. * * @param callBack Callback when message received */ public ClientSocket(CWTest callBack) { Xlog.v(TAG, "ClientSocket constructor"); this.mCallBack = callBack; mCommandQueue = new LinkedBlockingQueue<String>(); mDataBuffer = new byte[BUFFER_SIZE]; mSendThread = new Thread( new Runnable() { public void run() { while (true) { try { mCommand = mCommandQueue.take(); Xlog.v(TAG, "Queue take command:" + mCommand); } catch (InterruptedException ie) { Xlog.w(TAG, "Take command interrupted:" + ie.getMessage()); return; } openClient(); if (null != mDataOutput && null != mDataInput) { try { // in = new // DataInputStream(localSocket.getInputStream()); mDataOutput.writeBytes(mCommand); mDataOutput.write('\r'); mDataOutput.write('\n'); mDataOutput.flush(); String result = null; int line = 0; int count = -1; while ((count = mDataInput.read(mDataBuffer)) != -1) { line++; result = new String(mDataBuffer, 0, count); Xlog.v(TAG, "line: " + line + " sentence: " + result); if (result.contains("PMTK817")) { mResponse = result; Xlog.v(TAG, "Get response from MNL"); break; } if (line > LINE_OUT_SIZE) { mResponse = "TIMEOUT"; break; } } } catch (IOException e) { Xlog.w(TAG, "sendCommand IOException: " + e.getMessage()); mResponse = "ERROR"; } } else { Xlog.d(TAG, "out is null"); mResponse = "ERROR"; } if (null != ClientSocket.this.mCallBack) { ClientSocket.this.mCallBack.onResponse(mResponse); } mCommand = null; closeClient(); } } }); mSendThread.start(); }
@Override public void onClick(DialogInterface dialog, int which) { Xlog.v(TAG, "Dialog_OTA,OK, finishInstallProcess"); finishInstallProcess(); }
@Override public void onCancel(DialogInterface dialog) { Xlog.v(TAG, "Dialog canceled, finishInstallProcess"); finishInstallProcess(); }
/*proxy interface done*/ private void log(String info) { if (null != info) { Xlog.v(TAG, info); } }
@Override public void onDismiss(DialogInterface dialog) { Xlog.v(TAG, "Dialog onDismiss"); mCurrentDialog = -1; }