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.cbsb.ftpserv.ProxyConnector.java
public void run() { myLog.i("In ProxyConnector.run()"); setProxyState(State.CONNECTING); try {// ww w .j av a2 s. c om String candidateProxies[] = getProxyList(); for (String candidateHostname : candidateProxies) { hostname = candidateHostname; commandSocket = newAuthedSocket(hostname, Defaults.REMOTE_PROXY_PORT); if (commandSocket == null) { continue; } commandSocket.setSoTimeout(0); // 0 == forever //commandSocket.setKeepAlive(true); // Now that we have authenticated, we want to start the command session so we can // be notified of pending control sessions. JSONObject request = makeJsonRequest("start_command_session"); response = sendRequest(commandSocket, request); if (response == null) { myLog.i("Couldn't create proxy command session"); continue; // try next server } if (!response.has("prefix")) { myLog.l(Log.INFO, "start_command_session didn't receive a prefix in response"); continue; // try next server } prefix = response.getString("prefix"); response = null; // Indicate that response is free for other use myLog.l(Log.INFO, "Got prefix of: " + prefix); break; // breaking with commandSocket != null indicates success } if (commandSocket == null) { myLog.l(Log.INFO, "No proxies accepted connection, failing."); setProxyState(State.UNREACHABLE); return; } setProxyState(State.CONNECTED); preferServer(hostname); inputStream = commandSocket.getInputStream(); out = commandSocket.getOutputStream(); int numBytes; byte[] bytes = new byte[IN_BUF_SIZE]; //spawnQuotaRequester().start(); while (true) { myLog.d("to proxy read()"); numBytes = inputStream.read(bytes); incrementProxyUsage(numBytes); myLog.d("from proxy read()"); JSONObject incomingJson = null; if (numBytes > 0) { String responseString = new String(bytes, ENCODING); incomingJson = new JSONObject(responseString); if (incomingJson.has("action")) { // If the incoming JSON object has an "action" field, then it is a // request, and not a response incomingCommand(incomingJson); } else { // If the incoming JSON object does not have an "action" field, then // it is a response to a request we sent earlier. // If there's an object waiting for a response, then that object // will be referenced by responseWaiter. if (responseWaiter != null) { if (response != null) { myLog.l(Log.INFO, "Overwriting existing cmd session response"); } response = incomingJson; responseWaiter.interrupt(); } else { myLog.l(Log.INFO, "Response received but no responseWaiter"); } } } else if (numBytes == 0) { myLog.d("Command socket read 0 bytes, looping"); } else { // numBytes < 0 myLog.l(Log.DEBUG, "Command socket end of stream, exiting"); if (proxyState != State.DISCONNECTED) { // Set state to FAILED unless this was an intentional // socket closure. setProxyState(State.FAILED); } break; } } myLog.l(Log.INFO, "ProxyConnector thread quitting cleanly"); } catch (IOException e) { myLog.l(Log.INFO, "IOException in command session: " + e); setProxyState(State.FAILED); } catch (JSONException e) { myLog.l(Log.INFO, "Commmand socket JSONException: " + e); setProxyState(State.FAILED); } catch (Exception e) { myLog.l(Log.INFO, "Other exception in ProxyConnector: " + e); setProxyState(State.FAILED); } finally { Globals.setProxyConnector(null); hostname = null; myLog.d("ProxyConnector.run() returning"); persistProxyUsage(); } }
From source file:org.swiftp.server.ProxyConnector.java
@Override public void run() { myLog.i("In ProxyConnector.run()"); setProxyState(State.CONNECTING); try {// ww w. j a v a2 s . c om String candidateProxies[] = getProxyList(); for (String candidateHostname : candidateProxies) { hostname = candidateHostname; commandSocket = newAuthedSocket(hostname, Defaults.REMOTE_PROXY_PORT); if (commandSocket == null) { continue; } commandSocket.setSoTimeout(0); // 0 == forever // commandSocket.setKeepAlive(true); // Now that we have authenticated, we want to start the command session so // we can // be notified of pending control sessions. JSONObject request = makeJsonRequest("start_command_session"); response = sendRequest(commandSocket, request); if (response == null) { myLog.i("Couldn't create proxy command session"); continue; // try next server } if (!response.has("prefix")) { myLog.l(Log.INFO, "start_command_session didn't receive a prefix in response"); continue; // try next server } prefix = response.getString("prefix"); response = null; // Indicate that response is free for other use myLog.l(Log.INFO, "Got prefix of: " + prefix); break; // breaking with commandSocket != null indicates success } if (commandSocket == null) { myLog.l(Log.INFO, "No proxies accepted connection, failing."); setProxyState(State.UNREACHABLE); return; } setProxyState(State.CONNECTED); preferServer(hostname); inputStream = commandSocket.getInputStream(); out = commandSocket.getOutputStream(); int numBytes; byte[] bytes = new byte[IN_BUF_SIZE]; // spawnQuotaRequester().start(); while (true) { myLog.d("to proxy read()"); numBytes = inputStream.read(bytes); incrementProxyUsage(numBytes); myLog.d("from proxy read()"); JSONObject incomingJson = null; if (numBytes > 0) { String responseString = new String(bytes, ENCODING); incomingJson = new JSONObject(responseString); if (incomingJson.has("action")) { // If the incoming JSON object has an "action" field, then it is a // request, and not a response incomingCommand(incomingJson); } else { // If the incoming JSON object does not have an "action" field, // then // it is a response to a request we sent earlier. // If there's an object waiting for a response, then that object // will be referenced by responseWaiter. if (responseWaiter != null) { if (response != null) { myLog.l(Log.INFO, "Overwriting existing cmd session response"); } response = incomingJson; responseWaiter.interrupt(); } else { myLog.l(Log.INFO, "Response received but no responseWaiter"); } } } else if (numBytes == 0) { myLog.d("Command socket read 0 bytes, looping"); } else { // numBytes < 0 myLog.l(Log.DEBUG, "Command socket end of stream, exiting"); if (proxyState != State.DISCONNECTED) { // Set state to FAILED unless this was an intentional // socket closure. setProxyState(State.FAILED); } break; } } myLog.l(Log.INFO, "ProxyConnector thread quitting cleanly"); } catch (IOException e) { myLog.l(Log.INFO, "IOException in command session: " + e); setProxyState(State.FAILED); } catch (JSONException e) { myLog.l(Log.INFO, "Commmand socket JSONException: " + e); setProxyState(State.FAILED); } catch (Exception e) { myLog.l(Log.INFO, "Other exception in ProxyConnector: " + e); setProxyState(State.FAILED); } finally { Globals.setProxyConnector(null); hostname = null; myLog.d("ProxyConnector.run() returning"); persistProxyUsage(); } }
From source file:com.google.android.gcm.demo.logic.GcmServerSideSender.java
/** * Send a downstream message via HTTP plain text. * * @param destination the registration id of the recipient app. * @param message the message to be sent * @throws IOException/* w w w .j av a 2 s . c om*/ */ public void sendHttpPlaintextDownstreamMessage(String destination, Message message) throws IOException { StringBuilder request = new StringBuilder(); request.append(PARAM_TO).append('=').append(destination); addOptParameter(request, PARAM_DELAY_WHILE_IDLE, message.isDelayWhileIdle()); addOptParameter(request, PARAM_DRY_RUN, message.isDryRun()); addOptParameter(request, PARAM_COLLAPSE_KEY, message.getCollapseKey()); addOptParameter(request, PARAM_RESTRICTED_PACKAGE_NAME, message.getRestrictedPackageName()); addOptParameter(request, PARAM_TIME_TO_LIVE, message.getTimeToLive()); for (Map.Entry<String, String> entry : message.getData().entrySet()) { if (entry.getKey() != null && entry.getValue() != null) { String prefixedKey = PARAM_PLAINTEXT_PAYLOAD_PREFIX + entry.getKey(); addOptParameter(request, prefixedKey, URLEncoder.encode(entry.getValue(), UTF8)); } } HttpRequest httpRequest = new HttpRequest(); httpRequest.setHeader(HEADER_CONTENT_TYPE, CONTENT_TYPE_FORM_ENCODED); httpRequest.setHeader(HEADER_AUTHORIZATION, "key=" + key); httpRequest.doPost(GCM_SEND_ENDPOINT, request.toString()); if (httpRequest.getResponseCode() != 200) { throw new IOException("Invalid request." + "\nStatus: " + httpRequest.getResponseCode() + "\nResponse: " + httpRequest.getResponseBody()); } String[] lines = httpRequest.getResponseBody().split("\n"); if (lines.length == 0 || lines[0].equals("")) { throw new IOException("Received empty response from GCM service."); } String[] firstLineValues = lines[0].split("="); if (firstLineValues.length != 2) { throw new IOException("Invalid response from GCM: " + httpRequest.getResponseBody()); } switch (firstLineValues[0]) { case RESPONSE_PLAINTEXT_MESSAGE_ID: logger.log(Log.INFO, "Message sent.\nid: " + firstLineValues[1]); // check for canonical registration id if (lines.length > 1) { // If the response includes a 2nd line we expect it to be the CANONICAL REG ID String[] secondLineValues = lines[1].split("="); if (secondLineValues.length == 2 && secondLineValues[0].equals(RESPONSE_PLAINTEXT_CANONICAL_REG_ID)) { logger.log(Log.INFO, "Message sent: canonical registration id = " + secondLineValues[1]); } else { logger.log(Log.ERROR, "Invalid response from GCM." + "\nResponse: " + httpRequest.getResponseBody()); } } break; case RESPONSE_PLAINTEXT_ERROR: logger.log(Log.ERROR, "Message failed.\nError: " + firstLineValues[1]); break; default: logger.log(Log.ERROR, "Invalid response from GCM." + "\nResponse: " + httpRequest.getResponseBody()); break; } }
From source file:com.radicaldynamic.groupinform.activities.AccountDeviceList.java
static public void fetchDeviceList(boolean fetchAnyway) { if (Collect.getInstance().getIoService().isSignedIn() || fetchAnyway) { if (Collect.Log.INFO) Log.i(Collect.LOGTAG, t + "fetching list of devices"); } else {//from ww w . j av a 2 s.c o m if (Collect.Log.INFO) Log.i(Collect.LOGTAG, t + "not signed in, skipping device list fetch"); return; } // Try to ping the service to see if it is "up" String deviceListUrl = Collect.getInstance().getInformOnlineState().getServerUrl() + "/device/list"; String getResult = HttpUtils.getUrlData(deviceListUrl); JSONObject jsonDeviceList; try { jsonDeviceList = (JSONObject) new JSONTokener(getResult).nextValue(); String result = jsonDeviceList.optString(InformOnlineState.RESULT, InformOnlineState.ERROR); if (result.equals(InformOnlineState.OK)) { // Write out list of jsonDevices for later retrieval by loadDevicesList() and InformOnlineService.loadDevicesHash() JSONArray jsonDevices = jsonDeviceList.getJSONArray("devices"); // // Record the number of seats that this account is licenced for // Collect // .getInstance() // .getInformOnlineState() // .setAccountLicencedSeats(jsonDeviceList.getInt("licencedSeats")); // // Record the plan type for this account (this is a weird place to do it in but it makes sense to piggyback) // Collect // .getInstance() // .getInformOnlineState() // .setAccountPlan(jsonDeviceList.getString("planType")); try { // Write out a device list cache file FileOutputStream fos = new FileOutputStream( new File(Collect.getInstance().getCacheDir(), FileUtilsExtended.DEVICE_CACHE_FILE)); fos.write(jsonDevices.toString().getBytes()); fos.close(); } catch (Exception e) { if (Collect.Log.ERROR) Log.e(Collect.LOGTAG, t + "unable to write device cache: " + e.toString()); e.printStackTrace(); } } else { // There was a problem... handle it! } } catch (NullPointerException e) { // Communication error if (Collect.Log.ERROR) Log.e(Collect.LOGTAG, t + "no getResult to parse. Communication error with node.js server?"); e.printStackTrace(); } catch (JSONException e) { // Parse error (malformed result) if (Collect.Log.ERROR) Log.e(Collect.LOGTAG, t + "failed to parse getResult " + getResult); e.printStackTrace(); } }
From source file:com.royclarkson.springagram.PhotoAddFragment.java
private File createImageFile() throws IOException { // Create an image file name String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); String imageFileName = "JPEG_" + timeStamp + "_"; File storageDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM); File image = File.createTempFile(imageFileName, ".jpg", storageDir); this.photoPath = image.getAbsolutePath(); if (Log.isLoggable(TAG, Log.INFO)) { Log.i(TAG, "PhotoPath: " + this.photoPath); }/* w w w . j av a2s. c o m*/ return image; }
From source file:com.radicaldynamic.groupinform.services.InformOnlineService.java
public boolean goOffline() { if (checkout()) { if (Collect.Log.INFO) Log.i(Collect.LOGTAG, t + "went offline at users request"); Collect.getInstance().getInformOnlineState().setOfflineModeEnabled(true); return true; } else {//from w ww.j a v a 2s .co m if (Collect.Log.WARN) Log.w(Collect.LOGTAG, t + "unable to go offline at users request"); return false; } }
From source file:com.google.android.marvin.mytalkback.TtsDiscoveryProxyActivity.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { final TtsEngineInfo engine = getEngineForRequestCode(requestCode); if (engine == null) { return;/*w ww. j a v a2s .c o m*/ } LogUtils.log(this, Log.INFO, "Discovered TTS engine: %s", engine.name); handleCheckTtsDataResult(engine, data); mResultsReceived++; // If we've received results from all engines, we're done! if (mResultsReceived >= mExpectedResults) { finishAndNotify(); } }
From source file:de.escoand.readdaily.MainActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); // restart after theme changed if (resultCode == SettingsActivity.CODE_THEME_CHANGED) { LogHandler.log(Log.INFO, "theme changed, restarting"); finish();// w w w . jav a2 s .c o m startActivity(new Intent(this, this.getClass())); } // restart after download else if (resultCode == StoreActivity.CODE_CONTENT_LOADED) { LogHandler.log(Log.INFO, "content loaded, restarting"); finish(); startActivity(new Intent(this, this.getClass())); } }
From source file:com.kth.common.utils.etc.LogUtil.java
/** * INFO ?.//from www . j av a2 s . co m * * @param clazz ?? Class. * @param msg . */ public static void i(final Class<?> clazz, final String msg) { if (LogUtil.isInfoEnabled()) { Log.println(Log.INFO, TAG, LogUtil.getClassLineNumber(clazz) + " - " + msg); // ?? ? ?. if (LogUtil.isFileLogEnabled()) { write(Log.INFO, LogUtil.getClassLineNumber(clazz), msg); } } }
From source file:org.ametro.app.ApplicationEx.java
public void onCreate() { if (Log.isLoggable(Constants.LOG_TAG_MAIN, Log.INFO)) { Log.i(Constants.LOG_TAG_MAIN, "aMetro application started"); }// w w w . j av a 2 s. c o m mInstance = this; mConnectionManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); FileUtil.touchDirectory(Constants.ROOT_PATH); FileUtil.touchDirectory(Constants.LOCAL_CATALOG_PATH); FileUtil.touchDirectory(Constants.IMPORT_CATALOG_PATH); FileUtil.touchDirectory(Constants.TEMP_CATALOG_PATH); FileUtil.touchDirectory(Constants.ICONS_PATH); FileUtil.touchFile(Constants.NO_MEDIA_FILE); extractEULA(this); super.onCreate(); }