Logging fixed: enable or disable LogCat logging from your DfuService class
This commit is contained in:
parent
3f00657408
commit
750ea15bf4
|
@ -668,9 +668,4 @@ import no.nordicsemi.android.dfu.internal.exception.UploadAbortedException;
|
||||||
if (DfuBaseService.DEBUG)
|
if (DfuBaseService.DEBUG)
|
||||||
Log.i(TAG, message);
|
Log.i(TAG, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void logd(final String message) {
|
|
||||||
if (DfuBaseService.DEBUG)
|
|
||||||
Log.d(TAG, message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,7 @@ import no.nordicsemi.android.error.GattError;
|
||||||
public abstract class DfuBaseService extends IntentService implements DfuProgressInfo.ProgressListener {
|
public abstract class DfuBaseService extends IntentService implements DfuProgressInfo.ProgressListener {
|
||||||
private static final String TAG = "DfuBaseService";
|
private static final String TAG = "DfuBaseService";
|
||||||
|
|
||||||
/* package */ static final boolean DEBUG = true; // TODO change me to false!
|
/* package */ static boolean DEBUG = false;
|
||||||
|
|
||||||
public static final int NOTIFICATION_ID = 283; // a random number
|
public static final int NOTIFICATION_ID = 283; // a random number
|
||||||
|
|
||||||
|
@ -642,7 +642,7 @@ public abstract class DfuBaseService extends IntentService implements DfuProgres
|
||||||
* NOTE: We are doing this to avoid the hack with calling the hidden gatt.refresh() method, at least for bonded devices.
|
* NOTE: We are doing this to avoid the hack with calling the hidden gatt.refresh() method, at least for bonded devices.
|
||||||
*/
|
*/
|
||||||
if (gatt.getDevice().getBondState() == BluetoothDevice.BOND_BONDED) {
|
if (gatt.getDevice().getBondState() == BluetoothDevice.BOND_BONDED) {
|
||||||
logd("Waiting 1600 ms for a possible Service Changed indication...");
|
logi("Waiting 1600 ms for a possible Service Changed indication...");
|
||||||
waitFor(1600);
|
waitFor(1600);
|
||||||
// After 1.6s the services are already discovered so the following gatt.discoverServices() finishes almost immediately.
|
// After 1.6s the services are already discovered so the following gatt.discoverServices() finishes almost immediately.
|
||||||
|
|
||||||
|
@ -746,6 +746,7 @@ public abstract class DfuBaseService extends IntentService implements DfuProgres
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
|
|
||||||
|
DEBUG = isDebug();
|
||||||
initialize();
|
initialize();
|
||||||
|
|
||||||
final LocalBroadcastManager manager = LocalBroadcastManager.getInstance(this);
|
final LocalBroadcastManager manager = LocalBroadcastManager.getInstance(this);
|
||||||
|
@ -1414,6 +1415,23 @@ public abstract class DfuBaseService extends IntentService implements DfuProgres
|
||||||
*/
|
*/
|
||||||
protected abstract Class<? extends Activity> getNotificationTarget();
|
protected abstract Class<? extends Activity> getNotificationTarget();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Using this method you may enable detail debug LogCat logs from DFU.
|
||||||
|
* <p>Recommended use:</p>
|
||||||
|
* <pre>
|
||||||
|
* @Override
|
||||||
|
* protected boolean isDebug() {
|
||||||
|
* return BuildConfig.DEBUG;
|
||||||
|
* }
|
||||||
|
* </pre>
|
||||||
|
* @return true to enable LogCat output, false (default) if not
|
||||||
|
*/
|
||||||
|
protected boolean isDebug() {
|
||||||
|
// Override this method and return true if you need more logs in LogCat
|
||||||
|
// Note: BuildConfig.DEBUG always returns false in library projects, so please use your app package BuildConfig
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private void sendProgressBroadcast(final DfuProgressInfo info) {
|
private void sendProgressBroadcast(final DfuProgressInfo info) {
|
||||||
final Intent broadcast = new Intent(BROADCAST_PROGRESS);
|
final Intent broadcast = new Intent(BROADCAST_PROGRESS);
|
||||||
broadcast.putExtra(EXTRA_DATA, info.getProgress());
|
broadcast.putExtra(EXTRA_DATA, info.getProgress());
|
||||||
|
@ -1493,9 +1511,4 @@ public abstract class DfuBaseService extends IntentService implements DfuProgres
|
||||||
if (DfuBaseService.DEBUG)
|
if (DfuBaseService.DEBUG)
|
||||||
Log.i(TAG, message);
|
Log.i(TAG, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void logd(final String message) {
|
|
||||||
if (DfuBaseService.DEBUG)
|
|
||||||
Log.d(TAG, message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue