Skip to content

Commit

Permalink
Bugfix: PublicAPI StartRecording recorded no data.
Browse files Browse the repository at this point in the history
Problem was that the TrackRecordingService was not started as a ForegroundService anymore.

Fixes #1904.
  • Loading branch information
dennisguse committed Dec 5, 2024
1 parent 7c8fae6 commit b65230b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,7 @@ public class PublicApiTest {

private final Context context = ApplicationProvider.getApplicationContext();

@Test
public void StartTest() {
PreferencesUtils.setBoolean(R.string.publicapi_enabled_key, true);

context.startActivity(IntentUtils.newIntent(context, StartRecording.class));
}

//NOTE: this doesn't check if the TrackRecordingService was started in foreground.
@Test
public void StartStopTest() throws InterruptedException {
PreferencesUtils.setBoolean(R.string.publicapi_enabled_key, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,15 @@ public abstract class AbstractAPIActivity extends AppCompatActivity {
protected void onCreate(@Nullable Bundle savedInstanceState) {
SplashScreen splashScreen = SplashScreen.installSplashScreen(this);
super.onCreate(savedInstanceState);
splashScreen.setKeepOnScreenCondition(() -> true );
splashScreen.setKeepOnScreenCondition(() -> true);

if (PreferencesUtils.isPublicAPIenabled()) {
Log.i(TAG, "Received and trying to execute requested action.");
TrackRecordingServiceConnection.execute(this, serviceConnectedCallback);
if (requiresForeground()) {
TrackRecordingServiceConnection.executeForeground(this, serviceConnectedCallback);
} else {
TrackRecordingServiceConnection.execute(this, serviceConnectedCallback);
}
} else {
Toast.makeText(this, getString(R.string.settings_public_api_disabled_toast), Toast.LENGTH_LONG).show();
Log.w(TAG, "Public API is disabled; ignoring request.");
Expand All @@ -48,4 +52,8 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
protected abstract void execute(TrackRecordingService service);

protected abstract boolean isPostExecuteStopService();

protected boolean requiresForeground() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,9 @@ private void startDashboardAPI(@NonNull Track.Id trackId, @NonNull Bundle bundle
protected boolean isPostExecuteStopService() {
return false;
}

@Override
protected boolean requiresForeground() {
return true;
}
}

0 comments on commit b65230b

Please sign in to comment.