private void submit(LogPackByte pack) { Logger.i("gqw, logContent = " + pack.client.multiLogPack.logList.get(0).content); try { // socket.connect(socketAddr); socket = new Socket(SERVER_IP, SERVER_PORT); LogPackByte.printLogList(pack); byte[] sendBytes = pack.client.encode(); // System.out.printf("begin bytes2HexStr\r\n"); // System.out.printf(ByteConvert.bytes2HexStr(sendBytes) + "\r\n"); // System.out.printf("end bytes2HexStr\r\n"); OutputStream out = socket.getOutputStream(); out.write(sendBytes); out.flush(); // byte[] reponse = new byte[32]; // InputStream in = socket.getInputStream(); // in.read(reponse, 0, reponse.length); // Logger.i("gqw-u, log reponse = " + new String(reponse)); // in.close(); out.close(); socket.close(); } catch (IOException e) { e.printStackTrace(); } }
/** * @Description 设置上传log时的条数限制,即有多少条log后打包上传到后台(默认值为1,每次log后立即上传) * * @param count * @date 2013-5-10 */ public void setLogLimit(int count) { if (count > 0 && count < 100) { logCountLimit = count; } else { Logger.e("gqw, " + count + " is out of range"); } }
private Context getContext() { if (context == null) { try { context = SkyContext.context.createPackageContext( "com.skyworth.tvos.userservice", Activity.CONTEXT_IGNORE_SECURITY); } catch (NameNotFoundException e) { } if (context == null) { Logger.i("gqw, context is null..."); context = SkyContext.context; } } return context; }