Java Code Examples for timber.log.Timber#v()

The following examples show how to use timber.log.Timber#v() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MediaStoreUtil.java    From APlayer with GNU General Public License v3.0 6 votes vote down vote up
public static List<Song> getSongs(@Nullable String selection, String[] selectionValues,
    final String sortOrder) {
  if (!hasStoragePermissions()) {
    return new ArrayList<>();
  }

  List<Song> songs = new ArrayList<>();

  try (Cursor cursor = makeSongCursor(selection, selectionValues, sortOrder)) {
    if (cursor != null && cursor.getCount() > 0) {
      while (cursor.moveToNext()) {
        songs.add(getSongInfo(cursor));
      }
    }
  } catch (Exception ignore) {
    Timber.v(ignore);
  }
  return songs;
}
 
Example 2
Source File: AddGattServerServiceTransaction.java    From bitgatt with Mozilla Public License 2.0 6 votes vote down vote up
@Override
public void onServerServiceAdded(int status, BluetoothGattService service) {
    TransactionResult.Builder builder = new TransactionResult.Builder().transactionName(getName());
    builder.responseStatus(GattDisconnectReason.getReasonForCode(status).ordinal());
    if (status == BluetoothGatt.GATT_SUCCESS) {
        getGattServer().setState(GattState.ADD_SERVICE_SUCCESS);
        Timber.v("Gatt service was added to the gatt server successfully");
        builder.gattState(getGattServer().getGattState())
                .serviceUuid(service.getUuid())
                .resultStatus(TransactionResult.TransactionResultStatus.SUCCESS);
        callCallbackWithTransactionResultAndRelease(callback, builder.build());
        getGattServer().setState(GattState.IDLE);
    } else {
        getGattServer().setState(GattState.ADD_SERVICE_FAILURE);
        Timber.e("The gatt service could not be added: %s", service.getUuid());
        builder.gattState(getGattServer().getGattState())
                .serviceUuid(service.getUuid())
                .resultStatus(TransactionResult.TransactionResultStatus.FAILURE);
        callCallbackWithTransactionResultAndRelease(callback, builder.build());
        getGattServer().setState(GattState.IDLE);
    }
}
 
Example 3
Source File: GattReadWriteTests.java    From bitgatt with Mozilla Public License 2.0 6 votes vote down vote up
@Test
public void provideBluetoothStatusToReadGattDescriptorTransaction() {
    BluetoothGatt gatt = mock(BluetoothGatt.class);
    BluetoothGattDescriptor descriptor = mock(BluetoothGattDescriptor.class);
    when(descriptor.getUuid()).thenReturn(characteristicUuid);
    ReadGattDescriptorTransaction readTx = new ReadGattDescriptorTransaction(conn, GattState.READ_DESCRIPTOR_SUCCESS, descriptor);
    readTx.callback = result -> {
        try {
            // should force the index out of bounds if code doesn't work
            Timber.v(result.getResponseCodeString());
            Assert.assertTrue("We can just skate here, all good", true);
        } catch(ArrayIndexOutOfBoundsException ex) {
            Assert.fail("This must be converted to a normal ordinal");
        }
    };
    readTx.onDescriptorRead(gatt, new GattUtils().copyDescriptor(descriptor), 133);
}
 
Example 4
Source File: PeripheralScanner.java    From bitgatt with Mozilla Public License 2.0 6 votes vote down vote up
/**
 * This will stop any future periodical scans that are happening, but will not affect any scans
 * that are already in progress, high-priority or otherwise.
 */

synchronized void cancelPeriodicalScan(@Nullable Context context) {
    if (context == null) {
        Timber.v("Can't cancel the scan with a null context");
        return;
    }
    // set scan multipliers back to default
    scanBackoffMultiplier = DEFAULT_SCAN_BACKOFF_MULTIPLIER;
    periodicalScanEnabled.set(false);
    mHandler.removeCallbacks(scanTimeoutRunnable);
    mHandler.removeCallbacks(periodicRunnable);
    // if we are presently actively scanning we will let that scan run it's course and then
    // let it call onScanStatusChanged, otherwise we will fire it from here so the caller knows
    if (!isScanning()) {
        listener.onScanStatusChanged(isScanning());
    }
}
 
Example 5
Source File: SafeAsyncTask.java    From Pioneer with Apache License 2.0 6 votes vote down vote up
@Override
protected final void onPostExecute(Tasks.ResultOrException<Result> e) {
    super.onPostExecute(e);
    if (stopped) {
        return;
    }
    if (isCancelled()) {
        onCancelled();
        return;
    }
    resultOrException = e;
    onStopped();
    if (e.exception != null) {
        Timber.v("onException [%s] - [%s]", this, e.exception);
        onException(e.exception);
    } else {
        Timber.v("onSuccess [%s] - [%s]", this, e.result);
        onSuccess(e.result);
    }
}
 
Example 6
Source File: IoUtils.java    From Pioneer with Apache License 2.0 6 votes vote down vote up
@NonNull
public static File createTempFile(Context context, String suffix, boolean isPublic) throws IOException {
    File directory;
    if (isPublic) {
        directory = null;
    } else {
        directory = fromCacheDir(context, DataConstants.Temp.TMP_DIRECTORY_NAME);
        if (directory != null && !ensureDirsExist(directory)) {
            Timber.w("Could not create tmp directory in cacheDir");
            directory = null;
        }
    }
    File tmp = File.createTempFile(DataConstants.Temp.TMP_FILE_PREFIX, suffix, directory);
    Timber.v("Create tmp file: %s", tmp);
    if (isPublic) {
        setOtherWritable(tmp);
    }
    return tmp;
}
 
Example 7
Source File: AlwaysConnectedScanner.java    From bitgatt with Mozilla Public License 2.0 6 votes vote down vote up
private void stopScanningUntilDisconnectionEvent(Context context) {
    if (isAlwaysConnectedScannerEnabled()) {
        PeripheralScanner peripheralScanner = FitbitGatt.getInstance().getPeripheralScanner();
        if (peripheralScanner != null) {
            if (FitbitGatt.atLeastSDK(Build.VERSION_CODES.O_MR1)) {
                peripheralScanner.cancelPendingIntentBasedBackgroundScan();
            } else {
                peripheralScanner.cancelPeriodicalScan(context);
            }
            peripheralScanner.cancelHighPriorityScan(context);
            peripheralScanner.cancelScan(context);
            Timber.v("Stopped all of the scanning");
        } else {
            Timber.w("The scanner isn't set up yet, did you call FitbitGatt#start(...)?");
        }
    } else {
        Timber.w("The scanner was disabled so we will not continue");
    }
}
 
Example 8
Source File: AccountAuthenticatorService.java    From Pioneer with Apache License 2.0 5 votes vote down vote up
@Override
public IBinder onBind(Intent intent) {
    Timber.uprootAll();
    Timber.plant(new Timber.DebugTree());
    Timber.v("onBind: %s", intent);
    return intent.getAction().equals(ACTION_AUTHENTICATOR_INTENT) ? getAuthenticator()
            .getIBinder() : null;
}
 
Example 9
Source File: SafeAsyncTask.java    From Pioneer with Apache License 2.0 5 votes vote down vote up
@Override
protected final void onCancelled() {
    super.onCancelled();
    if (stopped) {
        return;
    }
    Timber.v("onCancel [%s]", this);
    resultOrException = null;
    onStopped();
    onCancel();
}
 
Example 10
Source File: GattClientCallback.java    From bitgatt with Mozilla Public License 2.0 5 votes vote down vote up
@Override
public void onReadRemoteRssi(BluetoothGatt gatt, int rssi, int status) {
    super.onReadRemoteRssi(gatt, rssi, status);
    Timber.v("[%s] onReadRemoteRssi: Gatt Response Status %s", getDeviceMacFromGatt(gatt), GattStatus.getStatusForCode(status));
    Timber.d("[%s][Threading] Originally called on thread : %s", getDeviceMacFromGatt(gatt), Thread.currentThread().getName());
    ArrayList<GattClientListener> copy = new ArrayList<>(listeners.size());
    copy.addAll(listeners);
    handler.post(() -> {
        for (GattClientListener listener : copy) {
            if (listener.getDevice() != null && listener.getDevice().equals(gatt.getDevice())) {
                listener.onReadRemoteRssi(gatt, rssi, status);
            }
        }
    });
}
 
Example 11
Source File: PeripheralScanner.java    From bitgatt with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * This will cancel any current scans and will not stop the periodic ones.
 */
synchronized void cancelScan(@Nullable Context context) {
    if (context == null) {
        Timber.v("Can't cancel the scan with a null context");
        return;
    }
    Timber.d("StopScanning requested ");
    stopScan(context);
    mHandler.removeCallbacks(scanTimeoutRunnable);
    mHandler.removeCallbacks(periodicRunnable);
}
 
Example 12
Source File: FitbitGatt.java    From bitgatt with Mozilla Public License 2.0 5 votes vote down vote up
@VisibleForTesting
void doDecrementAndInvalidateClosedConnections() {
    if (this.appContext == null) {
        Timber.w("[%s] Bitgatt must not be started, please start bitgatt client.", Build.DEVICE);
        return;
    }
    addConnectedDevices(this.appContext);
    for (FitbitBluetoothDevice fitbitBluetoothDevice : getConnectionMap().keySet()) {
        GattConnection conn = getConnectionMap().get(fitbitBluetoothDevice);
        if (conn != null) {
            // we only want to try to prune disconnected peripherals, there may be some
            // peripherals that are connected that we want to get rid of, but the caller
            // will need to disconnect them first, eventually we will clean up the
            // connection
            if (!conn.isConnected()) {
                long currentTtl = conn.getDisconnectedTTL();
                if (currentTtl <= 0) {
                    conn.close();
                    GattConnection connection = getConnectionMap().remove(fitbitBluetoothDevice);
                    if (connection != null) {
                        notifyListenersOfConnectionDisconnected(connection);
                        Timber.v("Connection for %s is disconnected and pruned", connection.getDevice());
                    }
                } else {
                    conn.setDisconnectedTTL(currentTtl - CLEANUP_INTERVAL);
                }
            }
        }
    }
    decrementAndInvalidateClosedConnections();
}
 
Example 13
Source File: AnalyticsModule.java    From android with Apache License 2.0 4 votes vote down vote up
@Override
public void trackViewedScreen(String screen) {
    Timber.v("Viewing %s", screen);
}
 
Example 14
Source File: GattTransaction.java    From bitgatt with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public void onDescriptorWrite(BluetoothGatt gatt, BluetoothGattDescriptorCopy descriptor, int status) {
    Timber.v("[%s] onDescriptorWrite not handled in tx: %s", utils.debugSafeGetBtDeviceName(gatt), getName());
}
 
Example 15
Source File: LrcView.java    From APlayer with GNU General Public License v3.0 4 votes vote down vote up
public void log(Object o) {
  Timber.v("%s", o);
}
 
Example 16
Source File: GattTransaction.java    From bitgatt with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristicCopy characteristic) {
    if (FitbitGatt.getInstance().isSlowLoggingEnabled()) {
        Timber.v("[%s] onCharacteristicChanged not handled in tx: %s", utils.debugSafeGetBtDeviceName(gatt), getName());
    }
}
 
Example 17
Source File: SignInActivityViewModel.java    From Anago with Apache License 2.0 4 votes vote down vote up
public void onTextChanged(CharSequence s, int start, int before, int count) {
    Timber.v("text changed");
    buttonEnabled.set(!TextUtils.isEmpty(name.get()) && !TextUtils.isEmpty(password.get()));
}
 
Example 18
Source File: GattPlugin.java    From bitgatt with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public void onPendingIntentScanStopped() {
    Timber.v("Pending intent scan stopped");
}
 
Example 19
Source File: GattPlugin.java    From bitgatt with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public void onScanStopped() {
    Timber.v("Scan was stopped");
}
 
Example 20
Source File: GattServerConnection.java    From bitgatt with Mozilla Public License 2.0 2 votes vote down vote up
/**
 * To set or change an intra-transaction delay... this value is initialized to zero, setting
 * it to any non-zero value will cause it to be posted to the connection handler
 * @param txDelay The delay in milliseconds to wait before queueing the next transaction
 */
void setIntraTransactionDelay(long txDelay) {
    long oldValue = intraTransactionDelay.getAndSet(txDelay);
    Timber.v("[%s] Changing intra-transaction delay from %dms, to %dms", Build.MODEL, oldValue, intraTransactionDelay.get());
}