Skip to content

Commit

Permalink
get_route api function
Browse files Browse the repository at this point in the history
aidl method stub to get location

aidl output parameter as parcelable

APosition constructor params order fixed

Order of AIDL methods rearranged; Added getCurrentRouteSegmentIndex() & getRouteCreationTime();

get rid of duplicate class LatLonParcelable, use ALatLon instead; added getRoute() aidl api method; added getRoutePoints()  aidl method

getApplicationMode() aidl method added

Refactored due to osmandapp#9304 (comment) && osmandapp#9304 (comment)
  • Loading branch information
ATMI authored and ntruchsess committed Apr 9, 2024
1 parent bb2c72e commit 6b0ffe6
Show file tree
Hide file tree
Showing 24 changed files with 1,458 additions and 3 deletions.
64 changes: 63 additions & 1 deletion OsmAnd-api/src/net/osmand/aidlapi/IOsmAndAidlInterface.aidl
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package net.osmand.aidlapi;

import net.osmand.aidlapi.map.ALatLon;
import net.osmand.aidlapi.map.ALocation;
import net.osmand.aidlapi.map.ALocationType;
import net.osmand.aidlapi.map.SetMapLocationParams;

import net.osmand.aidlapi.favorite.group.AFavoriteGroup;
Expand All @@ -19,6 +21,7 @@ import net.osmand.aidlapi.mapmarker.RemoveMapMarkerParams;
import net.osmand.aidlapi.mapmarker.UpdateMapMarkerParams;

import net.osmand.aidlapi.calculateroute.CalculateRouteParams;
import net.osmand.aidlapi.calculateroute.CalculatedRoute;

import net.osmand.aidlapi.gpx.ImportGpxParams;
import net.osmand.aidlapi.gpx.ShowGpxParams;
Expand All @@ -43,6 +46,7 @@ import net.osmand.aidlapi.maplayer.UpdateMapLayerParams;

import net.osmand.aidlapi.navigation.NavigateParams;
import net.osmand.aidlapi.navigation.NavigateGpxParams;
import net.osmand.aidlapi.navigation.NavigationStatus;

import net.osmand.aidlapi.note.TakePhotoNoteParams;
import net.osmand.aidlapi.note.StartVideoRecordingParams;
Expand Down Expand Up @@ -848,6 +852,22 @@ interface IOsmAndAidlInterface {

boolean getQuickActionsInfo(out List<QuickActionInfoParams> quickActions);

/**
* Method to get position of various objects
*
* @params positionType (int) - type of position to get
*/
boolean getPosition(in int positionType, out APosition position);

/**
* Method to get index of the current route segment
*/
int getCurrentRouteSegmentIndex();

boolean executeQuickAction(in QuickActionParams params);

boolean getQuickActionsInfo(out List<QuickActionInfoParams> quickActions);

/**
* Toggle Lock/Unlock screen.
*/
Expand All @@ -863,5 +883,47 @@ interface IOsmAndAidlInterface {
*/
long registerForKeyEvents(in AKeyEventsParams params, IOsmAndAidlCallback callback);

/**
* Method to get position of various objects
*
* @params locationType (ALocationType) - type of position to get (CURRENT - last fixed, PROJECTION - last projection, ROUTE_END end of the route)
*/
boolean getPosition(in int positionType, out APosition position);

/**
* Method to get index of the current route segment
*/
int getCurrentRouteSegmentIndex();

AppInfoParams getAppInfo();
}
/**
* Method to get creation time of current route
*
*/
long getRouteCreationTime();

/**
* Method to get current route points
*
*/
boolean getRoutePoints(out List<ALatLon> route);
boolean getLocation(in ALocationType locationType, out ALocation location);

/**
* Method to get application mode
*
*/
String getApplicationMode();

/**
* Method to get current navigation status
*
*/
boolean getNavigationStatus(out NavigationStatus status);

/**
* Method to get calculated route
*
*/
boolean getCalculatedRoute(out CalculatedRoute route);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package net.osmand.aidlapi.calculateroute;

parcelable CalculatedRoute;
133 changes: 133 additions & 0 deletions OsmAnd-api/src/net/osmand/aidlapi/calculateroute/CalculatedRoute.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
package net.osmand.aidlapi.calculateroute;

import android.os.Bundle;
import android.os.Parcel;

import net.osmand.aidlapi.AidlParams;
import net.osmand.aidlapi.map.ALatLon;

import java.util.ArrayList;

public class CalculatedRoute extends AidlParams {

private boolean isRouteCalculated;

private String appMode;

private ArrayList<ALatLon> routePoints;
private int routeDistance;

private float routingTime;
private long creationTime;

private float calculationTime;

public CalculatedRoute() {

}

public CalculatedRoute(boolean isRouteCalculated, String appMode, ArrayList<ALatLon> routePoints, int routeDistance, float routingTime, long creationTime, float calculationTime) {
this.isRouteCalculated = isRouteCalculated;
this.appMode = appMode;
this.routePoints = routePoints;
this.routeDistance = routeDistance;
this.routingTime = routingTime;
this.creationTime = creationTime;
this.calculationTime = calculationTime;
}

protected CalculatedRoute(Parcel in) {
readFromParcel(in);
}

public static final Creator<CalculatedRoute> CREATOR = new Creator<CalculatedRoute>() {
@Override
public CalculatedRoute createFromParcel(Parcel in) {
return new CalculatedRoute(in);
}

@Override
public CalculatedRoute[] newArray(int size) {
return new CalculatedRoute[size];
}
};

public boolean isRouteCalculated() {
return isRouteCalculated;
}

public String getAppMode() {
return appMode;
}

public ArrayList<ALatLon> getRoutePoints() {
return routePoints;
}

public int getRouteDistance() {
return routeDistance;
}

public float getRoutingTime() {
return routingTime;
}

public long getCreationTime() {
return creationTime;
}

public float getCalculationTime() {
return calculationTime;
}

public void setRouteCalculated(boolean routeCalculated) {
isRouteCalculated = routeCalculated;
}

public void setAppMode(String appMode) {
this.appMode = appMode;
}

public void setRoutePoints(ArrayList<ALatLon> routePoints) {
this.routePoints = routePoints;
}

public void setRouteDistance(int routeDistance) {
this.routeDistance = routeDistance;
}

public void setRoutingTime(float routingTime) {
this.routingTime = routingTime;
}

public void setCreationTime(long creationTime) {
this.creationTime = creationTime;
}

public void setCalculationTime(float calculationTime) {
this.calculationTime = calculationTime;
}

@Override
protected void readFromBundle(Bundle bundle) {
bundle.setClassLoader(ALatLon.class.getClassLoader());
isRouteCalculated = bundle.getBoolean("isRouteCalculated");
appMode = bundle.getString("appMode");
routePoints = bundle.getParcelableArrayList("routePoints");
routeDistance = bundle.getInt("routeDistance");
routingTime = bundle.getFloat("routingTime");
creationTime = bundle.getLong("creationTime");
calculationTime = bundle.getFloat("calculationTime");
}

@Override
protected void writeToBundle(Bundle bundle) {
bundle.putBoolean("isRouteCalculated", isRouteCalculated);
bundle.putString("appMode", appMode);
bundle.putParcelableArrayList("routePoints", routePoints);
bundle.putInt("routeDistance", routeDistance);
bundle.putFloat("routingTime", routingTime);
bundle.putLong("creationTime", creationTime);
bundle.putFloat("calculationTime", calculationTime);
}
}
3 changes: 3 additions & 0 deletions OsmAnd-api/src/net/osmand/aidlapi/map/ALocation.aidl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package net.osmand.aidlapi.map;

parcelable ALocation;
139 changes: 139 additions & 0 deletions OsmAnd-api/src/net/osmand/aidlapi/map/ALocation.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
package net.osmand.aidlapi.map;

import android.os.Bundle;
import android.os.Parcel;

import net.osmand.aidlapi.AidlParams;

public class ALocation extends AidlParams {

public double getLatitude() {
return latitude;
}

public void setLatitude(double latitude) {
this.latitude = latitude;
}

public double getLongitude() {
return longitude;
}

public void setLongitude(double longitude) {
this.longitude = longitude;
}

public double getAltitude() {
return altitude;
}

public void setAltitude(double altitude) {
this.altitude = altitude;
}

public double getSpeed() {
return speed;
}

public void setSpeed(double speed) {
this.speed = speed;
}

public double getBearing() {
return bearing;
}

public void setBearing(double bearing) {
this.bearing = bearing;
}

private double latitude;
private double longitude;
private double altitude;
private double speed;
private double bearing;

public ALocation(double latitude, double longitude, double altitude, double speed, double bearing) {
this.latitude = latitude;
this.longitude = longitude;
this.altitude = altitude;
this.speed = speed;
this.bearing = bearing;
}

public ALocation(Parcel in) {
readFromParcel(in);
}

public static final Creator<ALocation> CREATOR = new
Creator<ALocation>() {
public ALocation createFromParcel(Parcel in) {
return new ALocation(in);
}

public ALocation[] newArray(int size) {
return new ALocation[size];
}
};

public ALocation() {
}

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
int temp;
temp = (int)Math.floor(latitude * 10000);
result = prime * result + temp;
temp = (int)Math.floor(longitude * 10000);
result = prime * result + temp;
temp = (int)Math.floor(altitude * 10000);
result = prime * result + temp;
temp = (int)Math.floor(speed * 10000);
result = prime * result + temp;
temp = (int)Math.floor(bearing * 10000);
result = prime * result + temp;
return result;
}

@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;

ALocation other = (ALocation) obj;
return Math.abs(latitude - other.latitude) < 0.00001
&& Math.abs(longitude - other.longitude) < 0.00001
&& Math.abs(altitude - other.altitude) < 1
&& Math.abs(speed - other.speed) < 1;
}

@Override
public String toString() {
return "Lat " + ((float)latitude) + " Lon " + ((float)longitude) + " Alt " + ((float)altitude);
}


@Override
protected void readFromBundle(Bundle bundle) {
latitude = bundle.getDouble("latitude", latitude);
longitude = bundle.getDouble("longitude", longitude);
altitude = bundle.getDouble("altitude", altitude);
speed = bundle.getDouble("speed", speed);
bearing = bundle.getDouble("bearing", bearing);
}

@Override
protected void writeToBundle(Bundle bundle) {
bundle.putDouble("latitude", latitude);
bundle.putDouble("longitude", longitude);
bundle.putDouble("altitude", altitude);
bundle.putDouble("speed", speed);
bundle.putDouble("bearing", bearing);
}
}
3 changes: 3 additions & 0 deletions OsmAnd-api/src/net/osmand/aidlapi/map/ALocationType.aidl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package net.osmand.aidlapi.map;

parcelable ALocationType;
Loading

0 comments on commit 6b0ffe6

Please sign in to comment.