diff --git a/OsmAnd-api/src/net/osmand/aidlapi/IOsmAndAidlInterface.aidl b/OsmAnd-api/src/net/osmand/aidlapi/IOsmAndAidlInterface.aidl index ca19b48c83..0325c2a723 100644 --- a/OsmAnd-api/src/net/osmand/aidlapi/IOsmAndAidlInterface.aidl +++ b/OsmAnd-api/src/net/osmand/aidlapi/IOsmAndAidlInterface.aidl @@ -92,6 +92,7 @@ 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.contextmenu.ContextMenuButtonsParams; import net.osmand.aidlapi.contextmenu.UpdateContextMenuButtonsParams; @@ -892,4 +893,6 @@ interface IOsmAndAidlInterface { boolean selectProfile(in SelectProfileParams params); boolean getProfiles(out List profiles); + + boolean getBlockedRoads(out List blockedRoads); } \ No newline at end of file diff --git a/OsmAnd-api/src/net/osmand/aidlapi/navigation/ABlockedRoadParams.aidl b/OsmAnd-api/src/net/osmand/aidlapi/navigation/ABlockedRoadParams.aidl new file mode 100644 index 0000000000..ff967858c0 --- /dev/null +++ b/OsmAnd-api/src/net/osmand/aidlapi/navigation/ABlockedRoadParams.aidl @@ -0,0 +1,3 @@ +package net.osmand.aidlapi.navigation; + +parcelable ABlockedRoadParams; \ No newline at end of file diff --git a/OsmAnd-api/src/net/osmand/aidlapi/navigation/ABlockedRoadParams.java b/OsmAnd-api/src/net/osmand/aidlapi/navigation/ABlockedRoadParams.java new file mode 100644 index 0000000000..02c59c0ae5 --- /dev/null +++ b/OsmAnd-api/src/net/osmand/aidlapi/navigation/ABlockedRoadParams.java @@ -0,0 +1,57 @@ +package net.osmand.aidlapi.navigation; + +import android.os.Bundle; +import android.os.Parcel; + +import net.osmand.aidlapi.AidlParams; + +public class ABlockedRoadParams extends AidlParams { + + public long roadId; + public double latitude; + public double longitude; + public String name; + public String appModeKey; + + public ABlockedRoadParams(long roadId, double latitude, double longitude, String name, String appModeKey) { + this.roadId = roadId; + this.latitude = latitude; + this.longitude = longitude; + this.name = name; + this.appModeKey = appModeKey; + } + + protected ABlockedRoadParams(Parcel in) { + readFromParcel(in); + } + + public static final Creator CREATOR = new Creator() { + @Override + public ABlockedRoadParams createFromParcel(Parcel in) { + return new ABlockedRoadParams(in); + } + + @Override + public ABlockedRoadParams[] newArray(int size) { + return new ABlockedRoadParams[size]; + } + }; + + @Override + protected void readFromBundle(Bundle bundle) { + roadId = bundle.getLong("roadId"); + latitude = bundle.getDouble("latitude"); + longitude = bundle.getDouble("longitude"); + name = bundle.getString("name"); + appModeKey = bundle.getString("appModeKey"); + } + + @Override + public void writeToBundle(Bundle bundle) { + bundle.putLong("roadId", roadId); + bundle.putDouble("latitude", latitude); + bundle.putDouble("longitude", longitude); + bundle.putString("name", name); + bundle.putString("appModeKey", appModeKey); + } +} \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java index 6b9bb29dea..514916e51b 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java @@ -43,6 +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.data.FavouritePoint; import net.osmand.data.LatLon; import net.osmand.data.PointDescription; @@ -62,6 +63,7 @@ import net.osmand.plus.SQLiteTileSource; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.audionotes.AudioVideoNotesPlugin; import net.osmand.plus.dialogs.GpxAppearanceAdapter; +import net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo; import net.osmand.plus.helpers.ColorDialogs; import net.osmand.plus.helpers.ExternalApiHelper; import net.osmand.plus.helpers.LockHelper; @@ -208,7 +210,7 @@ public class OsmandAidlApi { private static final ApplicationMode DEFAULT_PROFILE = ApplicationMode.CAR; - private static final ApplicationMode[] VALID_PROFILES = new ApplicationMode[]{ + private static final ApplicationMode[] VALID_PROFILES = new ApplicationMode[] { ApplicationMode.CAR, ApplicationMode.BICYCLE, ApplicationMode.PEDESTRIAN @@ -287,7 +289,7 @@ public class OsmandAidlApi { } private void initOsmandTelegram() { - String[] packages = new String[]{"net.osmand.telegram", "net.osmand.telegram.debug"}; + String[] packages = new String[] {"net.osmand.telegram", "net.osmand.telegram.debug"}; Intent intent = new Intent("net.osmand.telegram.InitApp"); for (String pack : packages) { intent.setComponent(new ComponentName(pack, "net.osmand.telegram.InitAppBroadcastReceiver")); @@ -2167,7 +2169,7 @@ public class OsmandAidlApi { } boolean getBitmapForGpx(final Uri gpxUri, final float density, final int widthPixels, - final int heightPixels, final int color, final GpxBitmapCreatedCallback callback) { + final int heightPixels, final int color, final GpxBitmapCreatedCallback callback) { if (gpxUri == null || callback == null) { return false; } @@ -2368,6 +2370,14 @@ public class OsmandAidlApi { return true; } + public boolean getBlockedRoads(List blockedRoads) { + Map impassableRoads = app.getAvoidSpecificRoads().getImpassableRoads(); + for (AvoidRoadInfo info : impassableRoads.values()) { + blockedRoads.add(new ABlockedRoadParams(info.id, info.latitude, info.longitude, info.name, info.appModeKey)); + } + return true; + } + private static class FileCopyInfo { long startTime; long lastAccessTime; diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlServiceV2.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlServiceV2.java index 9943257c03..c28ef2842b 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlServiceV2.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlServiceV2.java @@ -73,6 +73,7 @@ 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.ANavigationUpdateParams; import net.osmand.aidlapi.navigation.ANavigationVoiceRouterMessageParams; import net.osmand.aidlapi.navigation.MuteNavigationParams; @@ -1396,6 +1397,17 @@ public class OsmandAidlServiceV2 extends Service implements AidlCallbackListener return false; } } + + @Override + public boolean getBlockedRoads(List blockedRoads) { + try { + OsmandAidlApi api = getApi("getBlockedRoads"); + return api != null && api.getBlockedRoads(blockedRoads); + } catch (Exception e) { + handleException(e); + return false; + } + } }; private void setCustomization(OsmandAidlApi api, CustomizationInfoParams params) {