forked from upstream-mirrors/OpenTracks
Moved myTrackLib into MyTracks: compiles, but recording service is not started correctly.
This commit is contained in:
@@ -55,11 +55,7 @@ public class SensorStateActivity extends AbstractActivity {
|
||||
// Check if service is available and recording
|
||||
boolean isRecording = false;
|
||||
if (trackRecordingService != null) {
|
||||
try {
|
||||
isRecording = trackRecordingService.isRecording();
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Unable to determine if the track recording service is recording.", e);
|
||||
}
|
||||
isRecording = trackRecordingService.isRecording();
|
||||
}
|
||||
|
||||
if (!isRecording) {
|
||||
@@ -151,20 +147,13 @@ public class SensorStateActivity extends AbstractActivity {
|
||||
if (trackRecordingService == null) {
|
||||
Log.d(TAG, "Cannot get the track recording service.");
|
||||
} else {
|
||||
try {
|
||||
sensorState = Sensor.SensorState.valueOf(trackRecordingService.getSensorState());
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Cannote read sensor state.", e);
|
||||
sensorState = Sensor.SensorState.NONE;
|
||||
}
|
||||
sensorState = Sensor.SensorState.valueOf(trackRecordingService.getSensorState());
|
||||
|
||||
try {
|
||||
byte[] buff = trackRecordingService.getSensorData();
|
||||
if (buff != null) {
|
||||
sensorDataSet = Sensor.SensorDataSet.parseFrom(buff);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Cannot read sensor data set.", e);
|
||||
} catch (InvalidProtocolBufferException e) {
|
||||
Log.e(TAG, "Cannot read sensor data set.", e);
|
||||
}
|
||||
|
||||
@@ -146,11 +146,6 @@ public class TrackController {
|
||||
*/
|
||||
private long getTotalTime() {
|
||||
ITrackRecordingService trackRecordingService = trackRecordingServiceConnection.getServiceIfBound();
|
||||
try {
|
||||
return trackRecordingService != null ? trackRecordingService.getTotalTime() : 0L;
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "exception", e);
|
||||
return 0L;
|
||||
}
|
||||
return trackRecordingService != null ? trackRecordingService.getTotalTime() : 0L;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,30 +115,19 @@ public class TrackListActivity extends AbstractTrackActivity implements FileType
|
||||
}
|
||||
if (startNewRecording) {
|
||||
startGps = false;
|
||||
try {
|
||||
long trackId = service.startNewTrack();
|
||||
startNewRecording = false;
|
||||
Intent intent = IntentUtils.newIntent(TrackListActivity.this, TrackDetailActivity.class)
|
||||
.putExtra(TrackDetailActivity.EXTRA_TRACK_ID, trackId);
|
||||
startActivity(intent);
|
||||
Toast.makeText(
|
||||
TrackListActivity.this, R.string.track_list_record_success, Toast.LENGTH_SHORT)
|
||||
.show();
|
||||
} catch (RemoteException e) {
|
||||
Toast.makeText(
|
||||
TrackListActivity.this, R.string.track_list_record_error, Toast.LENGTH_LONG).show();
|
||||
Log.e(TAG, "Unable to start a new recording.", e);
|
||||
}
|
||||
|
||||
long trackId = service.startNewTrack();
|
||||
startNewRecording = false;
|
||||
Intent intent = IntentUtils.newIntent(TrackListActivity.this, TrackDetailActivity.class)
|
||||
.putExtra(TrackDetailActivity.EXTRA_TRACK_ID, trackId);
|
||||
startActivity(intent);
|
||||
Toast.makeText(
|
||||
TrackListActivity.this, R.string.track_list_record_success, Toast.LENGTH_SHORT)
|
||||
.show();
|
||||
}
|
||||
if (startGps) {
|
||||
try {
|
||||
service.startGps();
|
||||
startGps = false;
|
||||
} catch (RemoteException e) {
|
||||
Toast.makeText(TrackListActivity.this, R.string.gps_starting_error, Toast.LENGTH_LONG)
|
||||
.show();
|
||||
Log.e(TAG, "Unable to start gps");
|
||||
}
|
||||
service.startGps();
|
||||
startGps = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -477,11 +466,7 @@ public class TrackListActivity extends AbstractTrackActivity implements FileType
|
||||
} else {
|
||||
ITrackRecordingService trackRecordingService = trackRecordingServiceConnection.getServiceIfBound();
|
||||
if (trackRecordingService != null) {
|
||||
try {
|
||||
trackRecordingService.stopGps();
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Unable to stop gps.", e);
|
||||
}
|
||||
trackRecordingService.stopGps();
|
||||
}
|
||||
trackRecordingServiceConnection.unbindAndStop();
|
||||
}
|
||||
|
||||
+9
-13
@@ -60,7 +60,7 @@ public class ControlRecordingService extends IntentService implements ServiceCon
|
||||
|
||||
@Override
|
||||
public void onServiceConnected(ComponentName name, IBinder service) {
|
||||
trackRecordingService = ITrackRecordingService.Stub.asInterface(service);
|
||||
trackRecordingService = (ITrackRecordingService)service;
|
||||
notifyConnected();
|
||||
}
|
||||
|
||||
@@ -109,18 +109,14 @@ public class ControlRecordingService extends IntentService implements ServiceCon
|
||||
void onHandleIntent(Intent intent, ITrackRecordingService service) {
|
||||
String action = intent.getAction();
|
||||
if (action != null) {
|
||||
try {
|
||||
if (action.equals(getString(R.string.track_action_start))) {
|
||||
service.startNewTrack();
|
||||
} else if (action.equals(getString(R.string.track_action_end))) {
|
||||
service.endCurrentTrack();
|
||||
} else if (action.equals(getString(R.string.track_action_pause))) {
|
||||
service.pauseCurrentTrack();
|
||||
} else if (action.equals(getString(R.string.track_action_resume))) {
|
||||
service.resumeCurrentTrack();
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.d(TAG, "ControlRecordingService onHandleIntent RemoteException", e);
|
||||
if (action.equals(getString(R.string.track_action_start))) {
|
||||
service.startNewTrack();
|
||||
} else if (action.equals(getString(R.string.track_action_end))) {
|
||||
service.endCurrentTrack();
|
||||
} else if (action.equals(getString(R.string.track_action_pause))) {
|
||||
service.pauseCurrentTrack();
|
||||
} else if (action.equals(getString(R.string.track_action_resume))) {
|
||||
service.resumeCurrentTrack();
|
||||
}
|
||||
}
|
||||
unbindService(this);
|
||||
|
||||
+5
-3
@@ -15,13 +15,15 @@
|
||||
*/
|
||||
package com.google.android.apps.mytracks.services;
|
||||
|
||||
import android.location.Location;
|
||||
|
||||
import com.google.android.apps.mytracks.content.WaypointCreationRequest;
|
||||
|
||||
/**
|
||||
* MyTracks service.
|
||||
* This service is the process that actually records and manages tracks.
|
||||
*/
|
||||
interface ITrackRecordingService {
|
||||
public interface ITrackRecordingService {
|
||||
|
||||
/**
|
||||
* Starts gps.
|
||||
@@ -81,7 +83,7 @@ interface ITrackRecordingService {
|
||||
* @param request the details of the waypoint to be inserted
|
||||
* @return the ID of the inserted waypoint
|
||||
*/
|
||||
long insertWaypoint(in WaypointCreationRequest request);
|
||||
long insertWaypoint(WaypointCreationRequest request);
|
||||
|
||||
/**
|
||||
* Inserts a track point in the current recording track.
|
||||
@@ -91,7 +93,7 @@ interface ITrackRecordingService {
|
||||
*
|
||||
* @param location the track point to be inserted
|
||||
*/
|
||||
void insertTrackPoint(in Location location);
|
||||
void insertTrackPoint(Location location);
|
||||
|
||||
/**
|
||||
* Gets the current sensor data. Returns null if there is no data.
|
||||
+1087
-1118
File diff suppressed because it is too large
Load Diff
+2
-2
@@ -56,7 +56,7 @@ public class TrackRecordingServiceConnection {
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Failed to bind a death recipient.", e);
|
||||
}
|
||||
setTrackRecordingService(ITrackRecordingService.Stub.asInterface(service));
|
||||
setTrackRecordingService((ITrackRecordingService)service);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -119,7 +119,7 @@ public class TrackRecordingServiceConnection {
|
||||
* Gets the track recording service if bound. Returns null otherwise
|
||||
*/
|
||||
public ITrackRecordingService getServiceIfBound() {
|
||||
if (trackRecordingService != null && !trackRecordingService.asBinder().isBinderAlive()) {
|
||||
if (trackRecordingService != null) {
|
||||
setTrackRecordingService(null);
|
||||
return null;
|
||||
}
|
||||
|
||||
+6
-16
@@ -71,13 +71,9 @@ public class TrackRecordingServiceConnectionUtils {
|
||||
* @param trackRecordingServiceConnection the track recording service
|
||||
*/
|
||||
public static void resumeTrack(TrackRecordingServiceConnection trackRecordingServiceConnection) {
|
||||
try {
|
||||
ITrackRecordingService service = trackRecordingServiceConnection.getServiceIfBound();
|
||||
if (service != null) {
|
||||
service.resumeCurrentTrack();
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Unable to resume track.", e);
|
||||
ITrackRecordingService service = trackRecordingServiceConnection.getServiceIfBound();
|
||||
if (service != null) {
|
||||
service.resumeCurrentTrack();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,13 +84,9 @@ public class TrackRecordingServiceConnectionUtils {
|
||||
* connection
|
||||
*/
|
||||
public static void pauseTrack(TrackRecordingServiceConnection trackRecordingServiceConnection) {
|
||||
try {
|
||||
ITrackRecordingService service = trackRecordingServiceConnection.getServiceIfBound();
|
||||
if (service != null) {
|
||||
service.pauseCurrentTrack();
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Unable to resume track.", e);
|
||||
ITrackRecordingService service = trackRecordingServiceConnection.getServiceIfBound();
|
||||
if (service != null) {
|
||||
service.pauseCurrentTrack();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,8 +173,6 @@ public class TrackRecordingServiceConnectionUtils {
|
||||
Toast.makeText(context, R.string.marker_add_success, Toast.LENGTH_SHORT).show();
|
||||
return markerId;
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Unable to add marker", e);
|
||||
} catch (IllegalStateException e) {
|
||||
Log.e(TAG, "Unable to add marker.", e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user