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