List of usage examples for android.util Log INFO
int INFO
To view the source code for android.util Log INFO.
Click Source Link
From source file:com.xorcode.andtweet.TwitterUser.java
private static boolean isUsernameValid(String username) { boolean ok = false; if (username != null && (username.length() > 0)) { ok = Pattern.matches("[a-zA-Z_0-9\\.\\-\\(\\)]+", username); if (!ok && MyLog.isLoggable(TAG, Log.INFO)) { Log.i(TAG, "The Username is not valid: \"" + username + "\""); }/*from w w w.j av a 2 s . co m*/ } return ok; }
From source file:com.cbsb.ftpserv.ProxyConnector.java
/** * Connects an outgoing socket to the proxy and authenticates, creating an account * if necessary./*from w w w . j a va 2 s .com*/ */ private Socket newAuthedSocket(String hostname, int port) { if (hostname == null) { myLog.i("newAuthedSocket can't connect to null host"); return null; } JSONObject json = new JSONObject(); //String secret = retrieveSecret(); Socket socket; OutputStream out = null; InputStream in = null; try { myLog.d("Opening proxy connection to " + hostname + ":" + port); socket = new Socket(); socket.connect(new InetSocketAddress(hostname, port), CONNECT_TIMEOUT); json.put("android_id", Util.getAndroidId()); json.put("swiftp_version", Util.getVersion()); json.put("action", "login"); out = socket.getOutputStream(); in = socket.getInputStream(); int numBytes; out.write(json.toString().getBytes(ENCODING)); myLog.l(Log.DEBUG, "Sent login request"); // Read and parse the server's response byte[] bytes = new byte[IN_BUF_SIZE]; // Here we assume that the server's response will all be contained in // a single read, which may be unsafe for large responses numBytes = in.read(bytes); if (numBytes == -1) { myLog.l(Log.INFO, "Proxy socket closed while waiting for auth response"); return null; } else if (numBytes == 0) { myLog.l(Log.INFO, "Short network read waiting for auth, quitting"); return null; } json = new JSONObject(new String(bytes, 0, numBytes, ENCODING)); if (checkAndPrintJsonError(json)) { return null; } myLog.d("newAuthedSocket successful"); return socket; } catch (Exception e) { myLog.i("Exception during proxy connection or authentication: " + e); return null; } }
From source file:com.google.android.car.kitchensink.radio.RadioTestFragment.java
private void addHandlers() { mOpenRadio.setOnClickListener(new View.OnClickListener() { @Override/* w w w .j ava2 s. c o m*/ public void onClick(View v) { handleRadioStart(); updateStates(); } }); mCloseRadio.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { handleRadioEnd(); mToggleMuteRadio.setChecked(true); updateStates(); } }); mToggleMuteRadio.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (DBG) { Log.i(TAG, "Toggle mute radio"); } mRadioTuner.setMute(!mRadioTuner.getMute()); updateStates(); } }); mGetRadioFocus.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (DBG) { Log.i(TAG, "Get radio focus"); } try { mCarAudioManager.requestAudioFocus(mRadioFocusListener, mRadioAudioAttrib, AudioManager.AUDIOFOCUS_GAIN, 0); } catch (CarNotConnectedException e) { //ignore for now } mHasRadioFocus = true; updateStates(); } }); mReleaseRadioFocus.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (DBG) { Log.i(TAG, "Release radio focus"); } mCarAudioManager.abandonAudioFocus(mRadioFocusListener, mRadioAudioAttrib); mHasRadioFocus = false; updateStates(); } }); mGetFocus.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (DBG) { Log.i(TAG, "Get secondary focus"); } mAudioManager.requestAudioFocus(mSecondaryFocusListener, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN); mHasSecondaryFocus = true; updateStates(); } }); mReleaseFocus.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (DBG) { Log.i(TAG, "Release secondary focus"); } mAudioManager.abandonAudioFocus(mSecondaryFocusListener); mHasSecondaryFocus = false; updateStates(); } }); mRadioNext.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (DBG) { Log.i(TAG, "Next radio station"); } if (mRadioTuner != null) { mRadioTuner.scan(RadioTuner.DIRECTION_UP, true); } updateStates(); } }); mRadioPrev.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (DBG) { Log.i(TAG, "Previous radio station"); } if (mRadioTuner != null) { mRadioTuner.scan(RadioTuner.DIRECTION_DOWN, true); } updateStates(); } }); mRadioScanCancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (DBG) { Log.i(TAG, "Cancel radio scan"); } if (mRadioTuner != null) { mRadioTuner.cancel(); } updateStates(); } }); mRadioTuneToStation.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (DBG) { Log.i(TAG, "Tuning to station"); } String station = mStationFrequency.getText().toString().trim(); if (mRadioTuner != null && !(station.equals(""))) { mRadioTuner.tune(Integer.parseInt(station), 0); } resetMessages(); updateMessages(); updateStates(); } }); mRadioStepUp.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (DBG) { Log.i(TAG, "Step up"); } if (mRadioTuner != null) { mRadioTuner.step(RadioTuner.DIRECTION_UP, false); } resetMessages(); updateMessages(); updateStates(); } }); mRadioStepDown.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (DBG) { Log.i(TAG, "Step down"); } if (mRadioTuner != null) { mRadioTuner.step(RadioTuner.DIRECTION_DOWN, false); } resetMessages(); updateMessages(); updateStates(); } }); mRadioGetProgramInfo.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (DBG) { Log.i(TAG, "getProgramInformation"); } if (mRadioTuner != null) { RadioManager.ProgramInfo[] programInfos = new RadioManager.ProgramInfo[1]; mRadioTuner.getProgramInformation(programInfos); addLog(Log.INFO, "mRadioTuner.getProgramInformation() =>" + programInfos[0]); } } }); mRadioBand.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (DBG) { Log.i(TAG, "Changing radio band"); } if (mRadioTuner != null) { mRadioTuner.setConfiguration(mRadioBand.isChecked() ? mFmConfig : mAmConfig); } resetMessages(); updateMessages(); updateStates(); } }); }
From source file:org.swiftp.server.ProxyConnector.java
/** * Connects an outgoing socket to the proxy and authenticates, creating an account if * necessary./*from ww w . j av a2 s .c om*/ */ private Socket newAuthedSocket(String hostname, int port) { if (hostname == null) { myLog.i("newAuthedSocket can't connect to null host"); return null; } JSONObject json = new JSONObject(); // String secret = retrieveSecret(); Socket socket; OutputStream out = null; InputStream in = null; try { myLog.d("Opening proxy connection to " + hostname + ":" + port); socket = new Socket(); socket.connect(new InetSocketAddress(hostname, port), CONNECT_TIMEOUT); json.put("android_id", Util.getAndroidId()); json.put("swiftp_version", Util.getVersion()); json.put("action", "login"); out = socket.getOutputStream(); in = socket.getInputStream(); int numBytes; out.write(json.toString().getBytes(ENCODING)); myLog.l(Log.DEBUG, "Sent login request"); // Read and parse the server's response byte[] bytes = new byte[IN_BUF_SIZE]; // Here we assume that the server's response will all be contained in // a single read, which may be unsafe for large responses numBytes = in.read(bytes); if (numBytes == -1) { myLog.l(Log.INFO, "Proxy socket closed while waiting for auth response"); return null; } else if (numBytes == 0) { myLog.l(Log.INFO, "Short network read waiting for auth, quitting"); return null; } json = new JSONObject(new String(bytes, 0, numBytes, ENCODING)); if (checkAndPrintJsonError(json)) { return null; } myLog.d("newAuthedSocket successful"); return socket; } catch (Exception e) { myLog.i("Exception during proxy connection or authentication: " + e); return null; } }
From source file:layout.FragmentBoardItemList.java
public void getThreadList(int offset) { loadingMoreThreads = true;/* ww w . j av a 2 s .co m*/ showProgressBar(); String strOffset = ""; if (offset == 0) { currentOffset = 0; boardItems.clear(); } else { strOffset = "&offset=" + offset; } setUpThreadProgess(); final String repliesForCatalog = settings.getString("pref_repliesperthread", "5"); Ion.with(getContext()) .load("http://bienvenidoainternet.org/cgi/api/list?dir=" + currentBoard.getBoardDir() + "&replies=" + repliesForCatalog + strOffset) .setLogging("getThreadList", Log.INFO).noCache().asString() .setCallback(new FutureCallback<String>() { @Override public void onCompleted(Exception e, String result) { hideProgressBar(); if (e != null) { e.printStackTrace(); displayError(e.getMessage()); } else { try { JSONObject json = new JSONObject(result); JSONArray threads = json.getJSONArray("threads"); for (int i = 0; i < threads.length(); i++) { JSONObject thread = threads.getJSONObject(i); BoardItem item = new BoardItem(); item.setEmail(thread.getString("email")); item.setFile(thread.getString("file")); item.setFilesize(thread.getInt("file_size")); item.setId(thread.getInt("id")); item.setName(thread.getString("name")); item.setSubject(thread.getString("subject")); item.setThumb(thread.getString("thumb")); item.setThumbHeight(thread.getInt("thumb_height")); item.setThumbWidth(thread.getInt("thumb_width")); item.setTimeStamp(thread.getLong("timestamp")); item.setTotalFiles(thread.getInt("total_files")); item.setTotalReplies(thread.getInt("total_replies")); item.setTripcode(thread.getString("tripcode")); item.setTimeStampFormatted(thread.getString("timestamp_formatted")); item.setLockStatus(thread.getInt("locked")); if (item.getTimeStampFormatted().contains("ID")) { item.setPosterId( item.getTimeStampFormatted().split(" ")[1].replace("ID :", "")); } item.setParentBoard(currentBoard); item.setParentId(0); item.setIdColor(addReplyID(item.getPosterId())); if (currentBoard.getBoardType() == 1) { item.setBbsId(1); } item.setMessage(thread.getString("message")); boardItems.add(item); if (!repliesForCatalog.equals("0")) { JSONArray replies = thread.getJSONArray("replies"); for (int r = 0; r < replies.length(); r++) { JSONObject jReply = replies.getJSONObject(r); BoardItem reply = new BoardItem(); reply.setDeletedCode(jReply.getInt("IS_DELETED")); if (currentBoard.getBoardType() == 1) { reply.setBbsId(item.getTotalReplies() - (Integer.valueOf(repliesForCatalog) - r) + 2); } if (reply.getDeletedCode() == 0) { reply.setEmail(jReply.getString("email")); reply.setFile(jReply.getString("file")); reply.setFilesize(jReply.getInt("file_size")); reply.setId(jReply.getInt("id")); reply.setParentId(item.getId()); reply.setLockStatus(item.isLocked ? 1 : 0); reply.setName(jReply.getString("name")); reply.setSubject(jReply.getString("subject")); reply.setThumb(jReply.getString("thumb")); reply.setThumbHeight(jReply.getInt("thumb_height")); reply.setThumbWidth(jReply.getInt("thumb_width")); reply.setTimeStamp(jReply.getLong("timestamp")); reply.setTripcode(jReply.getString("tripcode")); reply.setParentBoard(currentBoard); reply.setTimeStampFormatted( jReply.getString("timestamp_formatted")); reply.isReply = true; if (reply.getTimeStampFormatted().contains("ID")) { reply.setPosterId(reply.getTimeStampFormatted().split(" ")[1] .replace("ID:", "")); } reply.setIdColor(addReplyID(reply.getPosterId())); // reply.setTotalReplies(item.getTotalReplies()); reply.setMessage(jReply.getString("message")); } else { reply.setTimeStamp(jReply.getLong("timestamp")); reply.setId(jReply.getInt("id")); reply.isReply = true; reply.setLockStatus(item.isLocked ? 1 : 0); } boardItems.add(reply); } } } } catch (JSONException e1) { e1.printStackTrace(); displayError(e1.getMessage()); } } listViewAdapter.notifyDataSetChanged(); listViewAdapter.updateBoardItems(boardItems); mListener.onThreadList(); loadingMoreThreads = false; if (boardItems.isEmpty()) { mListener.updateToolbar(currentBoard, currentThread); } } }); }
From source file:com.cbsb.ftpserv.ProxyConnector.java
private JSONObject sendCmdSocketRequest(JSONObject json) { try {/*w w w . j a v a2 s . c o m*/ boolean queued; synchronized (this) { if (responseWaiter == null) { responseWaiter = Thread.currentThread(); queued = false; myLog.d("sendCmdSocketRequest proceeding without queue"); } else if (!responseWaiter.isAlive()) { // This code should never run. It is meant to recover from a situation // where there is a thread that sent a proxy request but died before // starting the subsequent request. If this is the case, the correct // behavior is to run the next queued thread in the queue, or if the // queue is empty, to perform our own request. myLog.l(Log.INFO, "Won't wait on dead responseWaiter"); if (queuedRequestThreads.size() == 0) { responseWaiter = Thread.currentThread(); queued = false; } else { queuedRequestThreads.add(Thread.currentThread()); queuedRequestThreads.remove().interrupt(); // start queued thread queued = true; } } else { myLog.d("sendCmdSocketRequest queueing thread"); queuedRequestThreads.add(Thread.currentThread()); queued = true; } } // If a different thread has sent a request and is waiting for a response, // then the current thread will be in a queue waiting for an interrupt if (queued) { // The current thread must wait until we are popped off the waiting queue // and receive an interrupt() boolean interrupted = false; try { myLog.d("Queued cmd session request thread sleeping..."); Thread.sleep(QUEUE_WAIT_MS); } catch (InterruptedException e) { myLog.l(Log.DEBUG, "Proxy request popped and ready"); interrupted = true; } if (!interrupted) { myLog.l(Log.INFO, "Timed out waiting on proxy queue"); return null; } } // We have been popped from the wait queue if necessary, and now it's time // to send the request. try { responseWaiter = Thread.currentThread(); byte[] outboundData = Util.jsonToByteArray(json); try { out.write(outboundData); } catch (IOException e) { myLog.l(Log.INFO, "IOException sending proxy request"); return null; } // Wait RESPONSE_WAIT_MS for a response from the proxy boolean interrupted = false; try { // Wait for the main ProxyConnector thread to interrupt us, meaning // that a response has been received. myLog.d("Cmd session request sleeping until response"); Thread.sleep(RESPONSE_WAIT_MS); } catch (InterruptedException e) { myLog.d("Cmd session response received"); interrupted = true; } if (!interrupted) { myLog.l(Log.INFO, "Proxy request timed out"); return null; } // At this point, the main ProxyConnector thread will have stored // our response in "JSONObject response". myLog.d("Cmd session response was: " + response); return response; } finally { // Make sure that when this request finishes, the next thread on the // queue gets started. synchronized (this) { if (queuedRequestThreads.size() != 0) { queuedRequestThreads.remove().interrupt(); } } } } catch (JSONException e) { myLog.l(Log.INFO, "JSONException in sendRequest: " + e); return null; } }
From source file:com.example.lenovo.networktools.widget.ftp.swiftp.ProxyConnector.java
@SuppressWarnings("unused") private JSONObject sendCmdSocketRequest(JSONObject json) { try {//ww w . j av a 2s.c o m boolean queued; synchronized (this) { if (responseWaiter == null) { responseWaiter = Thread.currentThread(); queued = false; myLog.d("sendCmdSocketRequest proceeding without queue"); } else if (!responseWaiter.isAlive()) { // This code should never run. It is meant to recover from a situation // where there is a thread that sent a proxy request but died before // starting the subsequent request. If this is the case, the correct // behavior is to run the next queued thread in the queue, or if the // queue is empty, to perform our own request. myLog.l(Log.INFO, "Won't wait on dead responseWaiter"); if (queuedRequestThreads.size() == 0) { responseWaiter = Thread.currentThread(); queued = false; } else { queuedRequestThreads.add(Thread.currentThread()); queuedRequestThreads.remove().interrupt(); // start queued thread queued = true; } } else { myLog.d("sendCmdSocketRequest queueing thread"); queuedRequestThreads.add(Thread.currentThread()); queued = true; } } // If a different thread has sent a request and is waiting for a response, // then the current thread will be in a queue waiting for an interrupt if (queued) { // The current thread must wait until we are popped off the waiting queue // and receive an interrupt() boolean interrupted = false; try { myLog.d("Queued cmd session request thread sleeping..."); Thread.sleep(QUEUE_WAIT_MS); } catch (InterruptedException e) { myLog.l(Log.DEBUG, "Proxy request popped and ready"); interrupted = true; } if (!interrupted) { myLog.l(Log.INFO, "Timed out waiting on proxy queue"); return null; } } // We have been popped from the wait queue if necessary, and now it's time // to send the request. try { responseWaiter = Thread.currentThread(); byte[] outboundData = Util.jsonToByteArray(json); try { out.write(outboundData); } catch (IOException e) { myLog.l(Log.INFO, "IOException sending proxy request"); return null; } // Wait RESPONSE_WAIT_MS for a response from the proxy boolean interrupted = false; try { // Wait for the main ProxyConnector thread to interrupt us, meaning // that a response has been received. myLog.d("Cmd session request sleeping until response"); Thread.sleep(RESPONSE_WAIT_MS); } catch (InterruptedException e) { myLog.d("Cmd session response received"); interrupted = true; } if (!interrupted) { myLog.l(Log.INFO, "Proxy request timed out"); return null; } // At this point, the main ProxyConnector thread will have stored // our response in "JSONObject response". myLog.d("Cmd session response was: " + response); return response; } finally { // Make sure that when this request finishes, the next thread on the // queue gets started. synchronized (this) { if (queuedRequestThreads.size() != 0) { queuedRequestThreads.remove().interrupt(); } } } } catch (JSONException e) { myLog.l(Log.INFO, "JSONException in sendRequest: " + e); return null; } }
From source file:com.ntsync.android.sync.client.NetworkUtilities.java
private static String createUsername(Context context, String email) throws ServerException, NetworkErrorException, UnsupportedEncodingException { final HttpPost post = new HttpPost(CREATEUSERNAME_URI); if (Log.isLoggable(TAG, Log.INFO)) { Log.i(TAG, "createUsername with URI: " + post.getURI()); }/* www . j a v a2 s .c o m*/ List<BasicNameValuePair> values = new ArrayList<BasicNameValuePair>(); values.add(new BasicNameValuePair("email", email)); HttpEntity postEntity = new UrlEncodedFormEntity(values, SyncDataHelper.DEFAULT_CHARSET_NAME); post.setHeader(postEntity.getContentEncoding()); post.setEntity(postEntity); String username = null; byte[] content; try { final HttpResponse resp = getHttpClient(context).execute(post, createHttpContext(null, null)); content = getResponse(resp); } catch (IOException ex) { throw new NetworkErrorException(ex); } if (content != null && content.length > 0) { username = new String(content, SyncDataHelper.DEFAULT_CHARSET_NAME); } return username; }
From source file:org.swiftp.server.ProxyConnector.java
@SuppressWarnings("unused") private JSONObject sendCmdSocketRequest(JSONObject json) { try {/*from ww w. jav a2s . c om*/ boolean queued; synchronized (this) { if (responseWaiter == null) { responseWaiter = Thread.currentThread(); queued = false; myLog.d("sendCmdSocketRequest proceeding without queue"); } else if (!responseWaiter.isAlive()) { // This code should never run. It is meant to recover from a situation // where there is a thread that sent a proxy request but died before // starting the subsequent request. If this is the case, the correct // behavior is to run the next queued thread in the queue, or if the // queue is empty, to perform our own request. myLog.l(Log.INFO, "Won't wait on dead responseWaiter"); if (queuedRequestThreads.size() == 0) { responseWaiter = Thread.currentThread(); queued = false; } else { queuedRequestThreads.add(Thread.currentThread()); queuedRequestThreads.remove().interrupt(); // start queued thread queued = true; } } else { myLog.d("sendCmdSocketRequest queueing thread"); queuedRequestThreads.add(Thread.currentThread()); queued = true; } } // If a different thread has sent a request and is waiting for a response, // then the current thread will be in a queue waiting for an interrupt if (queued) { // The current thread must wait until we are popped off the waiting queue // and receive an interrupt() boolean interrupted = false; try { myLog.d("Queued cmd session request thread sleeping..."); Thread.sleep(QUEUE_WAIT_MS); } catch (InterruptedException e) { myLog.l(Log.DEBUG, "Proxy request popped and ready"); interrupted = true; } if (!interrupted) { myLog.l(Log.INFO, "Timed out waiting on proxy queue"); return null; } } // We have been popped from the wait queue if necessary, and now it's time // to send the request. try { responseWaiter = Thread.currentThread(); byte[] outboundData = Util.jsonToByteArray(json); try { out.write(outboundData); } catch (IOException e) { myLog.l(Log.INFO, "IOException sending proxy request"); return null; } // Wait RESPONSE_WAIT_MS for a response from the proxy boolean interrupted = false; try { // Wait for the main ProxyConnector thread to interrupt us, meaning // that a response has been received. myLog.d("Cmd session request sleeping until response"); Thread.sleep(RESPONSE_WAIT_MS); } catch (InterruptedException e) { myLog.d("Cmd session response received"); interrupted = true; } if (!interrupted) { myLog.l(Log.INFO, "Proxy request timed out"); return null; } // At this point, the main ProxyConnector thread will have stored // our response in "JSONObject response". myLog.d("Cmd session response was: " + response); return response; } finally { // Make sure that when this request finishes, the next thread on the // queue gets started. synchronized (this) { if (queuedRequestThreads.size() != 0) { queuedRequestThreads.remove().interrupt(); } } } } catch (JSONException e) { myLog.l(Log.INFO, "JSONException in sendRequest: " + e); return null; } }
From source file:com.ntsync.android.sync.client.NetworkUtilities.java
/** * Perform 2-way sync with the server-side contacts. We send a request that * includes all the locally-dirty contacts so that the server can process * those changes, and we receive (and return) a list of contacts that were * updated on the server-side that need to be updated locally. * //from ww w.ja v a 2 s. c o m * @param account * The account being synced * @param authtoken * The authtoken stored in the AccountManager for this account * @param serverSyncState * A token returned from the server on the last sync * @param dirtyContacts * A list of the contacts to send to the server * @param newIdMap * Map of RawId to ServerId * @param explizitPhotoSave * @return A list of contacts that we need to update locally. Null if * processing of server-results failed. * @throws ParserConfigurationException * @throws TransformerException * @throws AuthenticatorException * @throws OperationCanceledException * when Authentication was canceled from user * @throws SAXException * @throws ServerException * @throws NetworkErrorException * @throws HeaderParseException * @throws HeaderCreateException */ public static SyncResponse syncContacts(Account account, String authtoken, SyncAnchor serverSyncState, List<RawContact> dirtyContacts, List<ContactGroup> dirtyGroups, SecretKey key, AccountManager accountManager, Context context, SyncResult syncResult, String pwdSaltHexStr, Map<Long, String> newIdMap, Restrictions restr, boolean explizitPhotoSave) throws AuthenticationException, OperationCanceledException, AuthenticatorException, ServerException, NetworkErrorException, HeaderParseException, HeaderCreateException { String clientId = getClientId(accountManager, account); SyncPrepErrorStatistic prepError = new SyncPrepErrorStatistic(); byte[] totBuffer = RequestGenerator.prepareServerRequest(serverSyncState, dirtyContacts, dirtyGroups, key, SystemHelper.getPkgVersion(context), clientId, pwdSaltHexStr, newIdMap, prepError, restr, explizitPhotoSave); syncResult.stats.numSkippedEntries += prepError.getIgnoredRows(); String currAuthtoken = authtoken; SyncResponse syncResponse = null; boolean retry; int retrycount = 0; do { retry = false; HttpEntity entity = new ByteArrayEntity(totBuffer); // Send the updated friends data to the server final HttpPost post = new HttpPost(SYNC_URI); post.setHeader("Content-Encoding", "application/octect-stream"); post.setEntity(entity); HttpEntity respEntity = null; try { final HttpResponse resp = getHttpClient(context).execute(post, createHttpContext(account.name, currAuthtoken)); respEntity = resp.getEntity(); if (resp.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { final byte[] response = EntityUtils.toByteArray(respEntity); syncResponse = processServerResponse(account, key, accountManager, clientId, response, syncResult); if (Log.isLoggable(TAG, Log.INFO)) { Log.i(TAG, "Response-Length: " + response.length); } } else { if (resp.getStatusLine().getStatusCode() == HttpStatus.SC_UNAUTHORIZED) { currAuthtoken = retryAuthentification(retrycount, accountManager, currAuthtoken, account.name, resp); retry = true; } else { throw new ServerException( "Server error in sending dirty contacts: " + resp.getStatusLine()); } } } catch (IOException ex) { throw new NetworkErrorException(ex); } finally { consumeContent(respEntity); } retrycount++; } while (retry); return syncResponse; }