Add getBlockedRoads to aidl api
This commit is contained in:
parent
5b900f8bfc
commit
f0cbbc2344
5 changed files with 88 additions and 3 deletions
|
@ -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<AProfile> profiles);
|
||||
|
||||
boolean getBlockedRoads(out List<ABlockedRoadParams> blockedRoads);
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
package net.osmand.aidlapi.navigation;
|
||||
|
||||
parcelable ABlockedRoadParams;
|
|
@ -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<ABlockedRoadParams> CREATOR = new Creator<ABlockedRoadParams>() {
|
||||
@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);
|
||||
}
|
||||
}
|
|
@ -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"));
|
||||
|
@ -2368,6 +2370,14 @@ public class OsmandAidlApi {
|
|||
return true;
|
||||
}
|
||||
|
||||
public boolean getBlockedRoads(List<ABlockedRoadParams> blockedRoads) {
|
||||
Map<LatLon, AvoidRoadInfo> 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;
|
||||
|
|
|
@ -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<ABlockedRoadParams> 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) {
|
||||
|
|
Loading…
Reference in a new issue