Skip to content

Commit

Permalink
Dashboard API: check if parameters are present before forwarding them.
Browse files Browse the repository at this point in the history
Part of #2030.
  • Loading branch information
dennisguse committed Dec 18, 2024
1 parent fd9646b commit 3e63bfe
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ public class CreateMarkerActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

Track.Id trackId = new Track.Id(getIntent().getLongExtra(EXTRA_TRACK_ID, 0L));
Location location = getIntent().getParcelableExtra(EXTRA_LOCATION);
Track.Id trackId = new Track.Id(getIntent().getLongExtra(EXTRA_TRACK_ID, -1L));
Location location = getIntent().getParcelableExtra(EXTRA_LOCATION, Location.class);
if (!getIntent().hasExtra(EXTRA_TRACK_ID) || location == null) {
throw new IllegalStateException("Parameter 'track_id' and/or 'location' missing or invalid.");
}

TrackRecordingServiceConnection.execute(this, (service, self) -> {
Intent intent = IntentUtils
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,15 @@
package de.dennisguse.opentracks.publicapi;

import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.util.Log;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;
import androidx.viewpager.widget.ViewPager;

import java.util.ArrayList;
import java.util.List;

import de.dennisguse.opentracks.AbstractActivity;
import de.dennisguse.opentracks.R;
import de.dennisguse.opentracks.data.ContentProviderUtils;
import de.dennisguse.opentracks.data.models.Marker;
import de.dennisguse.opentracks.databinding.MarkerDetailActivityBinding;
import de.dennisguse.opentracks.ui.markers.DeleteMarkerDialogFragment.DeleteMarkerCaller;
import de.dennisguse.opentracks.ui.markers.MarkerDetailActivity;
import de.dennisguse.opentracks.ui.markers.MarkerDetailFragment;
import de.dennisguse.opentracks.util.IntentUtils;

/**
Expand All @@ -44,10 +29,11 @@ public class ShowMarkerActivity extends AppCompatActivity {
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);

Marker.Id markerId = new Marker.Id(getIntent().getLongExtra(EXTRA_MARKER_ID, 0));
if (markerId.id() == 0) {
throw new IllegalStateException("No valid markerId provided");
if (!getIntent().hasExtra(EXTRA_MARKER_ID)) {
throw new IllegalStateException("Parameter 'markerId' missing");
}

Marker.Id markerId = new Marker.Id(getIntent().getLongExtra(EXTRA_MARKER_ID, -1));
Intent intent = IntentUtils.newIntent(this, MarkerDetailActivity.class)
.putExtra(MarkerDetailActivity.EXTRA_MARKER_ID, markerId);
startActivity(intent);
Expand Down

0 comments on commit 3e63bfe

Please sign in to comment.