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 5cecf2a commit e9f582e
Show file tree
Hide file tree
Showing 22 changed files with 1,341 additions and 1 deletion.
65 changes: 64 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.map.SetLocationParams;

Expand All @@ -20,6 +22,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.profile.ExportProfileParams;

Expand All @@ -46,6 +49,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 @@ -867,6 +871,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 @@ -882,6 +902,18 @@ 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();

boolean setMapMargins(in MapMarginsParams params);
Expand Down Expand Up @@ -938,4 +970,35 @@ interface IOsmAndAidlInterface {
long registerForLogcatMessages(in ALogcatListenerParams params, IOsmAndAidlCallback callback);

boolean setZoomLimits(in ZoomLimitsParams params);
}

/**
* 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/ALocationType.aidl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package net.osmand.aidlapi.map;

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

import android.os.Parcel;
import android.os.Parcelable;

public enum ALocationType implements Parcelable {
CURRENT(0),
PROJECTION(1),
ROUTE_END(2),
;

final int value;

ALocationType(int value) {
this.value = value;
}

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

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

public int getValue() {
return value;
}

@Override
public int describeContents() {
return 0;
}

@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(name());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package net.osmand.aidlapi.navigation;

parcelable NavigationStatus;
Loading

0 comments on commit e9f582e

Please sign in to comment.