List of usage examples for android.util Log DEBUG
int DEBUG
To view the source code for android.util Log DEBUG.
Click Source Link
From source file:com.android.car.trust.CarBleTrustAgent.java
private void maybeStartBleUnlockService() { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "Trying to open a Ble GATT server"); }/*from w w w .j a va 2s. com*/ BluetoothManager btManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE); BluetoothGattServer mGattServer = btManager.openGattServer(this, new BluetoothGattServerCallback() { @Override public void onConnectionStateChange(BluetoothDevice device, int status, int newState) { super.onConnectionStateChange(device, status, newState); } }); // The BLE stack is started up before the trust agent service, however Gatt capabilities // might not be ready just yet. Keep trying until a GattServer can open up before proceeding // to start the rest of the BLE services. if (mGattServer == null) { Log.e(TAG, "Gatt not available, will try again...in " + BLE_RETRY_MS + "ms"); Handler handler = new Handler(); handler.postDelayed(new Runnable() { @Override public void run() { maybeStartBleUnlockService(); } }, BLE_RETRY_MS); } else { mGattServer.close(); if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "GATT available, starting up UnlockService"); } mCarUnlockService.start(); } }
From source file:jp.yojio.triplog.Common.DataApi.gdata.AndroidGDataClient.java
private InputStream createAndExecuteMethod(HttpRequestCreator creator, String uriString, String authToken) throws HttpException, IOException { HttpResponse response = null;/* w w w . ja v a 2 s . c o m*/ int status = 500; int redirectsLeft = MAX_REDIRECTS; URI uri; try { uri = new URI(uriString); } catch (URISyntaxException use) { Log.w(TAG, "Unable to parse " + uriString + " as URI.", use); throw new IOException("Unable to parse " + uriString + " as URI: " + use.getMessage()); } // we follow redirects ourselves, since we want to follow redirects even on // POSTs, which // the HTTP library does not do. following redirects ourselves also allows // us to log // the redirects using our own logging. while (redirectsLeft > 0) { HttpUriRequest request = creator.createRequest(uri); request.addHeader("Accept-Encoding", "gzip"); // only add the auth token if not null (to allow for GData feeds that do // not require // authentication.) if (!TextUtils.isEmpty(authToken)) { request.addHeader("Authorization", "GoogleLogin auth=" + authToken); } if (LOCAL_LOGV) { for (Header h : request.getAllHeaders()) { Log.v(TAG, h.getName() + ": " + h.getValue()); } Log.d(TAG, "Executing " + request.getRequestLine().toString()); } response = null; try { response = httpClient.execute(request); } catch (IOException ioe) { Log.w(TAG, "Unable to execute HTTP request." + ioe); throw ioe; } StatusLine statusLine = response.getStatusLine(); if (statusLine == null) { Log.w(TAG, "StatusLine is null."); throw new NullPointerException("StatusLine is null -- should not happen."); } if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, response.getStatusLine().toString()); for (Header h : response.getAllHeaders()) { Log.d(TAG, h.getName() + ": " + h.getValue()); } } status = statusLine.getStatusCode(); HttpEntity entity = response.getEntity(); if ((status >= 200) && (status < 300) && entity != null) { return getUngzippedContent(entity); } // TODO: handle 301, 307? // TODO: let the http client handle the redirects, if we can be sure we'll // never get a // redirect on POST. if (status == 302) { // consume the content, so the connection can be closed. entity.consumeContent(); Header location = response.getFirstHeader("Location"); if (location == null) { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "Redirect requested but no Location " + "specified."); } break; } if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "Following redirect to " + location.getValue()); } try { uri = new URI(location.getValue()); } catch (URISyntaxException use) { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "Unable to parse " + location.getValue() + " as URI.", use); throw new IOException("Unable to parse " + location.getValue() + " as URI."); } break; } --redirectsLeft; } else { break; } } if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "Received " + status + " status code."); } String errorMessage = null; HttpEntity entity = response.getEntity(); try { if (response != null && entity != null) { InputStream in = entity.getContent(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); byte[] buf = new byte[8192]; int bytesRead = -1; while ((bytesRead = in.read(buf)) != -1) { baos.write(buf, 0, bytesRead); } // TODO: use appropriate encoding, picked up from Content-Type. errorMessage = new String(baos.toByteArray()); if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, errorMessage); } } } finally { if (entity != null) { entity.consumeContent(); } } String exceptionMessage = "Received " + status + " status code"; if (errorMessage != null) { exceptionMessage += (": " + errorMessage); } throw new HttpException(exceptionMessage, status, null /* InputStream */); }
From source file:com.dirkgassen.wator.ui.view.RangeSlider.java
/** * Returns the position of the center of the thumb that correlates to the current {@link #value}. * * @param paddingLeft left padding of this slider * @param paddingRight right padding of this slider * @return position of the center of the thumb *///from w ww .j a v a 2s . com private float positionFromValue(int paddingLeft, int paddingRight) { if (valueSet != null) { // Calculate for a value set: find the index of the value. We are finding the index of the first entry // which is larger than or equal to the value. The value _should_ always be an entry of the index, though. for (int no = 0; no < valueSet.length; no++) { if (value <= valueSet[no]) { if (Log.isLoggable("Wa-Tor", Log.DEBUG)) { Log.d("Wa-Tor", "Found current value " + value + " @ position " + no); } return (getWidth() - paddingLeft - paddingRight - thumbSize) * ((float) no) / (valueSet.length - 1) + paddingLeft + thumbSize / 2; } } return paddingLeft + thumbSize / 2; } // Calculate for a linear range return (getWidth() - paddingLeft - paddingRight - thumbSize) * ((float) value - minValue) / (maxValue - minValue) + paddingLeft + thumbSize / 2; }
From source file:im.ene.ribbon.BottomNavigationView.java
@Override protected void onRestoreInstanceState(final Parcelable state) { log(TAG, INFO, "onRestoreInstanceState"); SavedState savedState = (SavedState) state; super.onRestoreInstanceState(savedState.getSuperState()); defaultSelectedIndex = savedState.selectedIndex; log(TAG, Log.DEBUG, "defaultSelectedIndex: %d", defaultSelectedIndex); if (badgeProvider != null && savedState.badgeBundle != null) { badgeProvider.restore(savedState.badgeBundle); }/*from w ww . ja va 2 s. co m*/ }
From source file:com.infine.android.devoxx.service.RestService.java
/** * Charge les fichiers de donnees statiques * /*from www . j a v a 2 s. c o m*/ * @throws HandlerException */ private void loadStaticFiles() throws HandlerException { final long startLocal = System.currentTimeMillis(); // final boolean localParse = localVersion < latestVersion; // if (localParse || localVersion == VERSION_NONE) { // Load static local data // chargement des blocks mLocalExecutor.execute(R.raw.schedule, new JsonScheduleHandler(mApplicationContext, PREFS_SCHEDULE_VERSION, 0)); // chargement des sessions mLocalExecutor.execute(R.raw.session, new JsonSessionHandler(mApplicationContext, PREFS_SESSION_VERSION, 0)); // Room loading mLocalExecutor.execute(R.raw.room, new JsonRoomHandler()); // Speaker loading mLocalExecutor.execute(R.raw.speaker, new JsonSpeakerHandler(mApplicationContext, PREFS_SPEAKER_VERSION, 0)); // Save local parsed version // if (localVersion > VERSION_NONE) { // prefs.edit().putInt(Prefs.LOCAL_VERSION, latestVersion).commit(); // } // } if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "local sync took " + (System.currentTimeMillis() - startLocal) + "ms"); } }
From source file:com.radicaldynamic.groupinform.activities.AccountDeviceList.java
public static ArrayList<AccountDevice> loadDeviceList() { if (Collect.Log.DEBUG) Log.d(Collect.LOGTAG, t + "loading device cache"); ArrayList<AccountDevice> devices = new ArrayList<AccountDevice>(); if (!new File(Collect.getInstance().getCacheDir(), FileUtilsExtended.DEVICE_CACHE_FILE).exists()) { if (Collect.Log.WARN) Log.w(Collect.LOGTAG, t + "device cache file cannot be read: aborting loadDeviceList()"); return devices; }//from w ww. j ava 2s . com try { FileInputStream fis = new FileInputStream( new File(Collect.getInstance().getCacheDir(), FileUtilsExtended.DEVICE_CACHE_FILE)); InputStreamReader reader = new InputStreamReader(fis); BufferedReader buffer = new BufferedReader(reader, 8192); StringBuilder sb = new StringBuilder(); String cur; while ((cur = buffer.readLine()) != null) { sb.append(cur + "\n"); } buffer.close(); reader.close(); fis.close(); try { // int assignedSeats = 0; JSONArray jsonDevices = (JSONArray) new JSONTokener(sb.toString()).nextValue(); for (int i = 0; i < jsonDevices.length(); i++) { JSONObject jsonDevice = jsonDevices.getJSONObject(i); AccountDevice device = new AccountDevice(jsonDevice.getString("id"), jsonDevice.getString("rev"), jsonDevice.getString("alias"), jsonDevice.getString("email"), jsonDevice.getString("status")); // Optional information that will only be present if the user is also an account owner device.setLastCheckin(jsonDevice.optString("lastCheckin")); device.setPin(jsonDevice.optString("pin")); device.setRole(jsonDevice.optString("role")); // Update the lookup hash Collect.getInstance().getInformOnlineState().getAccountDevices().put(device.getId(), device); // Show a device so long as it hasn't been marked as removed if (!device.getStatus().equals("removed")) { devices.add(device); // assignedSeats++; } } // // Record the number of seats in this account that are assigned & allocated (not necessarily "active") // Collect.getInstance().getInformOnlineState().setAccountAssignedSeats(assignedSeats); } catch (JSONException e) { // Parse error (malformed result) if (Collect.Log.ERROR) Log.e(Collect.LOGTAG, t + "failed to parse JSON " + sb.toString()); e.printStackTrace(); } } catch (Exception e) { if (Collect.Log.ERROR) Log.e(Collect.LOGTAG, t + "unable to read device cache: " + e.toString()); e.printStackTrace(); } return devices; }
From source file:com.example.android.jumpingjack.MainActivity.java
/** * Resets the FLAG_KEEP_SCREEN_ON flag so activity can go into background. */// www. ja v a2s . c o m private void resetFlag() { mHandler.post(new Runnable() { @Override public void run() { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "Resetting FLAG_KEEP_SCREEN_ON flag to allow going to background"); } getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); finish(); } }); }
From source file:com.android.contacts.DynamicShortcuts.java
@VisibleForTesting void updatePinned() { final List<ShortcutInfo> updates = new ArrayList<>(); final List<String> removedIds = new ArrayList<>(); final List<String> enable = new ArrayList<>(); for (ShortcutInfo shortcut : mShortcutManager.getPinnedShortcuts()) { final PersistableBundle extras = shortcut.getExtras(); if (extras == null || extras.getInt(EXTRA_SHORTCUT_TYPE, SHORTCUT_TYPE_UNKNOWN) != SHORTCUT_TYPE_CONTACT_URI) { continue; }/* w w w . ja va 2 s .c om*/ // The contact ID may have changed but that's OK because it is just an optimization final long contactId = extras.getLong(Contacts._ID); final ShortcutInfo update = createShortcutForUri(Contacts.getLookupUri(contactId, shortcut.getId())); if (update != null) { updates.add(update); if (!shortcut.isEnabled()) { // Handle the case that a contact is disabled because it doesn't exist but // later is created (for instance by a sync) enable.add(update.getId()); } } else if (shortcut.isEnabled()) { removedIds.add(shortcut.getId()); } } if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "updating " + updates); Log.d(TAG, "enabling " + enable); Log.d(TAG, "disabling " + removedIds); } mShortcutManager.updateShortcuts(updates); mShortcutManager.enableShortcuts(enable); mShortcutManager.disableShortcuts(removedIds, mContext.getString(R.string.dynamic_shortcut_contact_removed_message)); }
From source file:carbon.internal.PercentLayoutHelper.java
/** * Iterates over children and restores their original dimensions that were changed for * percentage values. Calling this method only makes sense if you previously called * {@link PercentLayoutHelper#adjustChildren(int, int)}. *//* w w w .j a va2s .c o m*/ public void restoreOriginalParams() { for (int i = 0, N = mHost.getChildCount(); i < N; i++) { View view = mHost.getChildAt(i); ViewGroup.LayoutParams params = view.getLayoutParams(); if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "should restore " + view + " " + params); } if (params instanceof PercentLayoutParams) { PercentLayoutInfo info = ((PercentLayoutParams) params).getPercentLayoutInfo(); if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "using " + info); } if (info != null) { if (params instanceof ViewGroup.MarginLayoutParams) { info.restoreMarginLayoutParams((ViewGroup.MarginLayoutParams) params); } else { info.restoreLayoutParams(params); } } } } }