Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ public class ExternalCommandReceiver extends BroadcastReceiver {
private static final String START_NEW_LOGGER = "start new logger";
private static final String STOP_LOGGER = "stop logger";
private static final String START_UPLOAD = "start upload";
private static final String GET_TRACK_ID = "get track id";

public static final String BROADCAST_TRACK_ID = BuildConfig.APPLICATION_ID + ".broadcast.track_id";
public static final String EXTRA_TRACK_ID = "trackId";

@Override
public void onReceive(@NonNull Context context, @Nullable Intent intent) {
Expand All @@ -48,6 +52,7 @@ public void onReceive(@NonNull Context context, @Nullable Intent intent) {
case START_NEW_LOGGER -> startNewLoggerService(context, overwrite);
case STOP_LOGGER -> stopLogger(context);
case START_UPLOAD -> uploadData(context);
case GET_TRACK_ID -> sendTrackId(context);
}
}
}
Expand Down Expand Up @@ -94,4 +99,15 @@ private void uploadData(@NonNull Context context) {
ContextCompat.startForegroundService(context, intent);
}
}

/**
* Send current track id via broadcast
* @param context Context
*/
private void sendTrackId(@NonNull Context context) {
int trackId = DbAccess.getTrackId(context);
Intent intent = new Intent(BROADCAST_TRACK_ID);
intent.putExtra(EXTRA_TRACK_ID, trackId);
context.sendBroadcast(intent);
}
}