Add ability to add and remove avoid roads via aidl
This commit is contained in:
parent
c20c0aa6e7
commit
625ff2face
10 changed files with 167 additions and 17 deletions
|
@ -92,7 +92,9 @@ import net.osmand.aidlapi.copyfile.CopyFileParams;
|
|||
|
||||
import net.osmand.aidlapi.navigation.ANavigationUpdateParams;
|
||||
import net.osmand.aidlapi.navigation.ANavigationVoiceRouterMessageParams;
|
||||
import net.osmand.aidlapi.navigation.ABlockedRoadParams;
|
||||
import net.osmand.aidlapi.navigation.ABlockedRoad;
|
||||
import net.osmand.aidlapi.navigation.AddBlockedRoadParams;
|
||||
import net.osmand.aidlapi.navigation.RemoveBlockedRoadParams;
|
||||
|
||||
import net.osmand.aidlapi.contextmenu.ContextMenuButtonsParams;
|
||||
import net.osmand.aidlapi.contextmenu.UpdateContextMenuButtonsParams;
|
||||
|
@ -894,5 +896,9 @@ interface IOsmAndAidlInterface {
|
|||
|
||||
boolean getProfiles(out List<AProfile> profiles);
|
||||
|
||||
boolean getBlockedRoads(out List<ABlockedRoadParams> blockedRoads);
|
||||
boolean getBlockedRoads(out List<ABlockedRoad> blockedRoads);
|
||||
|
||||
boolean addRoadBlock(in AddBlockedRoadParams params);
|
||||
|
||||
boolean removeRoadBlock(in RemoveBlockedRoadParams params);
|
||||
}
|
|
@ -1,3 +1,3 @@
|
|||
package net.osmand.aidlapi.navigation;
|
||||
|
||||
parcelable ABlockedRoadParams;
|
||||
parcelable ABlockedRoad;
|
|
@ -5,7 +5,7 @@ import android.os.Parcel;
|
|||
|
||||
import net.osmand.aidlapi.AidlParams;
|
||||
|
||||
public class ABlockedRoadParams extends AidlParams {
|
||||
public class ABlockedRoad extends AidlParams {
|
||||
|
||||
private long roadId;
|
||||
private double latitude;
|
||||
|
@ -14,7 +14,7 @@ public class ABlockedRoadParams extends AidlParams {
|
|||
private String name;
|
||||
private String appModeKey;
|
||||
|
||||
public ABlockedRoadParams(long roadId, double latitude, double longitude, double direction, String name, String appModeKey) {
|
||||
public ABlockedRoad(long roadId, double latitude, double longitude, double direction, String name, String appModeKey) {
|
||||
this.roadId = roadId;
|
||||
this.latitude = latitude;
|
||||
this.longitude = longitude;
|
||||
|
@ -23,19 +23,19 @@ public class ABlockedRoadParams extends AidlParams {
|
|||
this.appModeKey = appModeKey;
|
||||
}
|
||||
|
||||
protected ABlockedRoadParams(Parcel in) {
|
||||
protected ABlockedRoad(Parcel in) {
|
||||
readFromParcel(in);
|
||||
}
|
||||
|
||||
public static final Creator<ABlockedRoadParams> CREATOR = new Creator<ABlockedRoadParams>() {
|
||||
public static final Creator<ABlockedRoad> CREATOR = new Creator<ABlockedRoad>() {
|
||||
@Override
|
||||
public ABlockedRoadParams createFromParcel(Parcel in) {
|
||||
return new ABlockedRoadParams(in);
|
||||
public ABlockedRoad createFromParcel(Parcel in) {
|
||||
return new ABlockedRoad(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ABlockedRoadParams[] newArray(int size) {
|
||||
return new ABlockedRoadParams[size];
|
||||
public ABlockedRoad[] newArray(int size) {
|
||||
return new ABlockedRoad[size];
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
package net.osmand.aidlapi.navigation;
|
||||
|
||||
parcelable AddBlockedRoadParams;
|
|
@ -0,0 +1,46 @@
|
|||
package net.osmand.aidlapi.navigation;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcel;
|
||||
|
||||
import net.osmand.aidlapi.AidlParams;
|
||||
|
||||
public class AddBlockedRoadParams extends AidlParams {
|
||||
|
||||
private ABlockedRoad blockedRoad;
|
||||
|
||||
public AddBlockedRoadParams(ABlockedRoad blockedRoad) {
|
||||
this.blockedRoad = blockedRoad;
|
||||
}
|
||||
|
||||
public AddBlockedRoadParams(Parcel in) {
|
||||
readFromParcel(in);
|
||||
}
|
||||
|
||||
public static final Creator<AddBlockedRoadParams> CREATOR = new Creator<AddBlockedRoadParams>() {
|
||||
@Override
|
||||
public AddBlockedRoadParams createFromParcel(Parcel in) {
|
||||
return new AddBlockedRoadParams(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AddBlockedRoadParams[] newArray(int size) {
|
||||
return new AddBlockedRoadParams[size];
|
||||
}
|
||||
};
|
||||
|
||||
public ABlockedRoad getBlockedRoad() {
|
||||
return blockedRoad;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToBundle(Bundle bundle) {
|
||||
bundle.putParcelable("blockedRoad", blockedRoad);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readFromBundle(Bundle bundle) {
|
||||
bundle.setClassLoader(ABlockedRoad.class.getClassLoader());
|
||||
blockedRoad = bundle.getParcelable("blockedRoad");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
package net.osmand.aidlapi.navigation;
|
||||
|
||||
parcelable RemoveBlockedRoadParams;
|
|
@ -0,0 +1,46 @@
|
|||
package net.osmand.aidlapi.navigation;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcel;
|
||||
|
||||
import net.osmand.aidlapi.AidlParams;
|
||||
|
||||
public class RemoveBlockedRoadParams extends AidlParams {
|
||||
|
||||
private ABlockedRoad blockedRoad;
|
||||
|
||||
public RemoveBlockedRoadParams(ABlockedRoad blockedRoad) {
|
||||
this.blockedRoad = blockedRoad;
|
||||
}
|
||||
|
||||
public RemoveBlockedRoadParams(Parcel in) {
|
||||
readFromParcel(in);
|
||||
}
|
||||
|
||||
public static final Creator<RemoveBlockedRoadParams> CREATOR = new Creator<RemoveBlockedRoadParams>() {
|
||||
@Override
|
||||
public RemoveBlockedRoadParams createFromParcel(Parcel in) {
|
||||
return new RemoveBlockedRoadParams(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RemoveBlockedRoadParams[] newArray(int size) {
|
||||
return new RemoveBlockedRoadParams[size];
|
||||
}
|
||||
};
|
||||
|
||||
public ABlockedRoad getBlockedRoad() {
|
||||
return blockedRoad;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToBundle(Bundle bundle) {
|
||||
bundle.putParcelable("blockedRoad", blockedRoad);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readFromBundle(Bundle bundle) {
|
||||
bundle.setClassLoader(ABlockedRoad.class.getClassLoader());
|
||||
blockedRoad = bundle.getParcelable("blockedRoad");
|
||||
}
|
||||
}
|
|
@ -43,7 +43,7 @@ import net.osmand.aidl.tiles.ASqliteDbFile;
|
|||
import net.osmand.aidlapi.customization.AProfile;
|
||||
import net.osmand.aidlapi.info.AppInfoParams;
|
||||
import net.osmand.aidlapi.map.ALatLon;
|
||||
import net.osmand.aidlapi.navigation.ABlockedRoadParams;
|
||||
import net.osmand.aidlapi.navigation.ABlockedRoad;
|
||||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
|
@ -2376,14 +2376,25 @@ public class OsmandAidlApi {
|
|||
return true;
|
||||
}
|
||||
|
||||
public boolean getBlockedRoads(List<ABlockedRoadParams> blockedRoads) {
|
||||
public boolean getBlockedRoads(List<ABlockedRoad> blockedRoads) {
|
||||
Map<LatLon, AvoidRoadInfo> impassableRoads = app.getAvoidSpecificRoads().getImpassableRoads();
|
||||
for (AvoidRoadInfo info : impassableRoads.values()) {
|
||||
blockedRoads.add(new ABlockedRoadParams(info.id, info.latitude, info.longitude, info.direction, info.name, info.appModeKey));
|
||||
blockedRoads.add(new ABlockedRoad(info.id, info.latitude, info.longitude, info.direction, info.name, info.appModeKey));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean addRoadBlock(ABlockedRoad road) {
|
||||
LatLon latLon = new LatLon(road.getLatitude(), road.getLongitude());
|
||||
app.getAvoidSpecificRoads().addImpassableRoad(null, latLon, false, false, null);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean removeRoadBlock(ABlockedRoad road) {
|
||||
app.getAvoidSpecificRoads().removeImpassableRoad(new LatLon(road.getLatitude(), road.getLongitude()));
|
||||
return true;
|
||||
}
|
||||
|
||||
private static class FileCopyInfo {
|
||||
long startTime;
|
||||
long lastAccessTime;
|
||||
|
|
|
@ -73,14 +73,16 @@ import net.osmand.aidlapi.navdrawer.NavDrawerFooterParams;
|
|||
import net.osmand.aidlapi.navdrawer.NavDrawerHeaderParams;
|
||||
import net.osmand.aidlapi.navdrawer.NavDrawerItem;
|
||||
import net.osmand.aidlapi.navdrawer.SetNavDrawerItemsParams;
|
||||
import net.osmand.aidlapi.navigation.ABlockedRoadParams;
|
||||
import net.osmand.aidlapi.navigation.ABlockedRoad;
|
||||
import net.osmand.aidlapi.navigation.ANavigationUpdateParams;
|
||||
import net.osmand.aidlapi.navigation.ANavigationVoiceRouterMessageParams;
|
||||
import net.osmand.aidlapi.navigation.AddBlockedRoadParams;
|
||||
import net.osmand.aidlapi.navigation.MuteNavigationParams;
|
||||
import net.osmand.aidlapi.navigation.NavigateGpxParams;
|
||||
import net.osmand.aidlapi.navigation.NavigateParams;
|
||||
import net.osmand.aidlapi.navigation.NavigateSearchParams;
|
||||
import net.osmand.aidlapi.navigation.PauseNavigationParams;
|
||||
import net.osmand.aidlapi.navigation.RemoveBlockedRoadParams;
|
||||
import net.osmand.aidlapi.navigation.ResumeNavigationParams;
|
||||
import net.osmand.aidlapi.navigation.StopNavigationParams;
|
||||
import net.osmand.aidlapi.navigation.UnmuteNavigationParams;
|
||||
|
@ -1399,7 +1401,7 @@ public class OsmandAidlServiceV2 extends Service implements AidlCallbackListener
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean getBlockedRoads(List<ABlockedRoadParams> blockedRoads) {
|
||||
public boolean getBlockedRoads(List<ABlockedRoad> blockedRoads) {
|
||||
try {
|
||||
OsmandAidlApi api = getApi("getBlockedRoads");
|
||||
return api != null && api.getBlockedRoads(blockedRoads);
|
||||
|
@ -1408,6 +1410,38 @@ public class OsmandAidlServiceV2 extends Service implements AidlCallbackListener
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addRoadBlock(AddBlockedRoadParams params) {
|
||||
try {
|
||||
OsmandAidlApi api = getApi("addRoadBlock");
|
||||
if (params != null && api != null) {
|
||||
ABlockedRoad road = params.getBlockedRoad();
|
||||
if (road != null) {
|
||||
return api.addRoadBlock(road);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
handleException(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeRoadBlock(RemoveBlockedRoadParams params) {
|
||||
try {
|
||||
OsmandAidlApi api = getApi("removeRoadBlock");
|
||||
if (params != null && api != null) {
|
||||
ABlockedRoad road = params.getBlockedRoad();
|
||||
if (road != null) {
|
||||
return api.removeRoadBlock(road);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
handleException(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
private void setCustomization(OsmandAidlApi api, CustomizationInfoParams params) {
|
||||
|
|
|
@ -393,6 +393,7 @@ public class AvoidSpecificRoads {
|
|||
if (object != null) {
|
||||
avoidRoadInfo.id = object.id;
|
||||
// avoidRoadInfo.direction = object.directionRoute(0, true);
|
||||
avoidRoadInfo.direction = Double.NaN;
|
||||
} else {
|
||||
avoidRoadInfo.id = 0;
|
||||
avoidRoadInfo.direction = Double.NaN;
|
||||
|
@ -406,7 +407,7 @@ public class AvoidSpecificRoads {
|
|||
|
||||
public static class AvoidRoadInfo {
|
||||
public long id;
|
||||
public double direction;
|
||||
public double direction = Double.NaN;
|
||||
public double latitude;
|
||||
public double longitude;
|
||||
public String name;
|
||||
|
|
Loading…
Reference in a new issue