Fix aidl copy file
This commit is contained in:
parent
3d49967332
commit
95d7078fb6
9 changed files with 452 additions and 307 deletions
|
@ -524,13 +524,4 @@ public class AndroidUtils {
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void deleteRecursive(File fileOrDir){
|
|
||||||
if(fileOrDir.isDirectory()) {
|
|
||||||
for (File child: fileOrDir.listFiles()) {
|
|
||||||
deleteRecursive(child);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fileOrDir.delete();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,7 @@ import net.osmand.aidl.gpx.CreateGpxBitmapParams;
|
||||||
import net.osmand.aidl.tiles.ASqliteDbFile;
|
import net.osmand.aidl.tiles.ASqliteDbFile;
|
||||||
|
|
||||||
import net.osmand.aidl.plugins.PluginParams;
|
import net.osmand.aidl.plugins.PluginParams;
|
||||||
import net.osmand.aidl.tiles.CopyFileParams;
|
import net.osmand.aidl.copyfile.CopyFileParams;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package net.osmand.aidl;
|
package net.osmand.aidl;
|
||||||
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
|
@ -29,6 +28,7 @@ import android.widget.ArrayAdapter;
|
||||||
import net.osmand.CallbackWithObject;
|
import net.osmand.CallbackWithObject;
|
||||||
import net.osmand.IndexConstants;
|
import net.osmand.IndexConstants;
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
|
import net.osmand.aidl.copyfile.CopyFileParams;
|
||||||
import net.osmand.aidl.favorite.AFavorite;
|
import net.osmand.aidl.favorite.AFavorite;
|
||||||
import net.osmand.aidl.favorite.group.AFavoriteGroup;
|
import net.osmand.aidl.favorite.group.AFavoriteGroup;
|
||||||
import net.osmand.aidl.gpx.AGpxBitmap;
|
import net.osmand.aidl.gpx.AGpxBitmap;
|
||||||
|
@ -45,7 +45,6 @@ import net.osmand.aidl.navdrawer.NavDrawerFooterParams;
|
||||||
import net.osmand.aidl.plugins.PluginParams;
|
import net.osmand.aidl.plugins.PluginParams;
|
||||||
import net.osmand.aidl.search.SearchResult;
|
import net.osmand.aidl.search.SearchResult;
|
||||||
import net.osmand.aidl.tiles.ASqliteDbFile;
|
import net.osmand.aidl.tiles.ASqliteDbFile;
|
||||||
import net.osmand.aidl.tiles.CopyFileParams;
|
|
||||||
import net.osmand.data.FavouritePoint;
|
import net.osmand.data.FavouritePoint;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
import net.osmand.data.PointDescription;
|
import net.osmand.data.PointDescription;
|
||||||
|
@ -100,13 +99,26 @@ import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.TreeMap;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import static net.osmand.aidl.OsmandAidlConstants.*;
|
import static net.osmand.aidl.OsmandAidlConstants.COPY_FILE_IO_ERROR;
|
||||||
|
import static net.osmand.aidl.OsmandAidlConstants.COPY_FILE_MAX_LOCK_TIME_MS;
|
||||||
|
import static net.osmand.aidl.OsmandAidlConstants.COPY_FILE_PARAMS_ERROR;
|
||||||
|
import static net.osmand.aidl.OsmandAidlConstants.COPY_FILE_PART_SIZE_LIMIT;
|
||||||
|
import static net.osmand.aidl.OsmandAidlConstants.COPY_FILE_PART_SIZE_LIMIT_ERROR;
|
||||||
|
import static net.osmand.aidl.OsmandAidlConstants.COPY_FILE_UNSUPPORTED_FILE_TYPE_ERROR;
|
||||||
|
import static net.osmand.aidl.OsmandAidlConstants.COPY_FILE_WRITE_LOCK_ERROR;
|
||||||
|
import static net.osmand.aidl.OsmandAidlConstants.OK_RESPONSE;
|
||||||
import static net.osmand.plus.OsmAndCustomizationConstants.DRAWER_ITEM_ID_SCHEME;
|
import static net.osmand.plus.OsmAndCustomizationConstants.DRAWER_ITEM_ID_SCHEME;
|
||||||
|
|
||||||
|
|
||||||
public class OsmandAidlApi {
|
public class OsmandAidlApi {
|
||||||
private static final Log LOG = PlatformUtil.getLog(OsmandAidlApi.class);
|
private static final Log LOG = PlatformUtil.getLog(OsmandAidlApi.class);
|
||||||
private static final String AIDL_REFRESH_MAP = "aidl_refresh_map";
|
private static final String AIDL_REFRESH_MAP = "aidl_refresh_map";
|
||||||
|
@ -1738,7 +1750,7 @@ public class OsmandAidlApi {
|
||||||
private void clearNavDrawerItems(String appPackage) {
|
private void clearNavDrawerItems(String appPackage) {
|
||||||
try {
|
try {
|
||||||
JSONObject allItems = new JSONObject(app.getSettings().API_NAV_DRAWER_ITEMS_JSON.get());
|
JSONObject allItems = new JSONObject(app.getSettings().API_NAV_DRAWER_ITEMS_JSON.get());
|
||||||
allItems.put(appPackage, null);
|
allItems.put(appPackage, new JSONArray());
|
||||||
app.getSettings().API_NAV_DRAWER_ITEMS_JSON.set(allItems.toString());
|
app.getSettings().API_NAV_DRAWER_ITEMS_JSON.set(allItems.toString());
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -1965,92 +1977,96 @@ public class OsmandAidlApi {
|
||||||
private Map<String, FileCopyInfo> copyFilesCache = new ConcurrentHashMap<>();
|
private Map<String, FileCopyInfo> copyFilesCache = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
private class FileCopyInfo {
|
private class FileCopyInfo {
|
||||||
long start;
|
long startTime;
|
||||||
long lastAccess;
|
long lastAccessTime;
|
||||||
FileOutputStream FileOutputStream;
|
FileOutputStream fileOutputStream;
|
||||||
|
|
||||||
FileCopyInfo(long start, long lastAccess, FileOutputStream fileOutputStream) {
|
FileCopyInfo(long startTime, long lastAccessTime, FileOutputStream fileOutputStream) {
|
||||||
this.start = start;
|
this.startTime = startTime;
|
||||||
this.lastAccess = lastAccess;
|
this.lastAccessTime = lastAccessTime;
|
||||||
FileOutputStream = fileOutputStream;
|
this.fileOutputStream = fileOutputStream;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int copyFile(final CopyFileParams filePart) {
|
int copyFile(final CopyFileParams params) {
|
||||||
if (Algorithms.isEmpty(filePart.getFilename()) || filePart.getFilePartData() == null) {
|
if (Algorithms.isEmpty(params.getFileName()) || params.getFilePartData() == null) {
|
||||||
return COPY_FILE_PARAMS_ERROR;
|
return COPY_FILE_PARAMS_ERROR;
|
||||||
}
|
}
|
||||||
if (filePart.getFilename().endsWith(IndexConstants.SQLITE_EXT)) {
|
if (params.getFilePartData().length > COPY_FILE_PART_SIZE_LIMIT) {
|
||||||
return copyFileImpl(filePart,
|
return COPY_FILE_PART_SIZE_LIMIT_ERROR;
|
||||||
IndexConstants.TILES_INDEX_DIR);
|
}
|
||||||
|
if (params.getFileName().endsWith(IndexConstants.SQLITE_EXT)) {
|
||||||
|
return copyFileImpl(params, IndexConstants.TILES_INDEX_DIR);
|
||||||
} else {
|
} else {
|
||||||
return COPY_FILE_UNSUPPORTED_FILE_TYPE_ERROR;
|
return COPY_FILE_UNSUPPORTED_FILE_TYPE_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int copyFileImpl(CopyFileParams fileParams, String destination){
|
private int copyFileImpl(CopyFileParams params, String destinationDir) {
|
||||||
|
File file = app.getAppPath(IndexConstants.TEMP_DIR + params.getFileName());
|
||||||
if (fileParams.getFilePartData().length > 256*1024) {
|
File tempDir = app.getAppPath(IndexConstants.TEMP_DIR);
|
||||||
return COPY_FILE_PART_SIZE_LIMIT_ERROR;
|
if (!tempDir.exists()) {
|
||||||
|
tempDir.mkdirs();
|
||||||
}
|
}
|
||||||
|
String fileName = params.getFileName();
|
||||||
File file = app.getAppPath(IndexConstants.TEMP_DIR + fileParams.getFilename());
|
File destFile = app.getAppPath(destinationDir + fileName);
|
||||||
FileOutputStream fos;
|
long currentTime = System.currentTimeMillis();
|
||||||
String key = fileParams.getFilename();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!copyFilesCache.containsKey(key)){
|
FileCopyInfo info = copyFilesCache.get(fileName);
|
||||||
if (fileParams.getActionId() == COPY_FILE_START_FLAG) {
|
if (info == null) {
|
||||||
file.delete();
|
FileOutputStream fos = new FileOutputStream(file, true);
|
||||||
file.getParentFile().mkdirs();
|
copyFilesCache.put(fileName,
|
||||||
fos = new FileOutputStream(file, true);
|
new FileCopyInfo(params.getStartTime(), currentTime, fos));
|
||||||
fos.write(fileParams.getFilePartData());
|
if (params.isDone()) {
|
||||||
copyFilesCache.put(
|
if (!finishFileCopy(params, file, fos, fileName, destFile)) {
|
||||||
key, new FileCopyInfo(fileParams.getStartTime(), System.currentTimeMillis(),
|
return COPY_FILE_IO_ERROR;
|
||||||
fos));
|
|
||||||
return COPY_FILE_OK_RESPONSE;
|
|
||||||
} else if (fileParams.getActionId() == COPY_FILE_FINISH_FLAG) {
|
|
||||||
file.delete();
|
|
||||||
file.getParentFile().mkdirs();
|
|
||||||
fos = new FileOutputStream(file, true);
|
|
||||||
fos.write(fileParams.getFilePartData());
|
|
||||||
file.renameTo(app.getAppPath(destination + fileParams.getFilename()));
|
|
||||||
return COPY_FILE_OK_RESPONSE;
|
|
||||||
} else {
|
|
||||||
return COPY_FILE_PARAMS_ERROR;
|
|
||||||
}
|
}
|
||||||
} else if (copyFilesCache.containsKey(key)) {
|
|
||||||
fos = copyFilesCache.get(key).FileOutputStream;
|
|
||||||
if (fileParams.getActionId() == COPY_FILE_START_FLAG) {
|
|
||||||
if (copyFilesCache.get(key).lastAccess - copyFilesCache.get(key).start > COPY_FILE_VALID_PAUSE) {
|
|
||||||
file.delete();
|
|
||||||
fos.close();
|
|
||||||
copyFilesCache.remove(key);
|
|
||||||
file.getParentFile().mkdirs();
|
|
||||||
fos = new FileOutputStream(file, true);
|
|
||||||
fos.write(fileParams.getFilePartData());
|
|
||||||
copyFilesCache.put(key,
|
|
||||||
new FileCopyInfo(fileParams.getStartTime(), System.currentTimeMillis(), fos));
|
|
||||||
return COPY_FILE_OK_RESPONSE;
|
|
||||||
} else {
|
} else {
|
||||||
|
fos.write(params.getFilePartData());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (info.startTime != params.getStartTime()) {
|
||||||
|
if (currentTime - info.lastAccessTime < COPY_FILE_MAX_LOCK_TIME_MS) {
|
||||||
return COPY_FILE_WRITE_LOCK_ERROR;
|
return COPY_FILE_WRITE_LOCK_ERROR;
|
||||||
}
|
|
||||||
} else if (fileParams.getActionId() == COPY_FILE_FINISH_FLAG) {
|
|
||||||
fos.close();
|
|
||||||
copyFilesCache.remove(key);
|
|
||||||
file.renameTo(app.getAppPath(destination + fileParams.getFilename()));
|
|
||||||
return COPY_FILE_OK_RESPONSE;
|
|
||||||
} else {
|
} else {
|
||||||
copyFilesCache.get(key).lastAccess = System.currentTimeMillis();
|
file.delete();
|
||||||
fos.write(fileParams.getFilePartData());
|
copyFilesCache.remove(fileName);
|
||||||
return COPY_FILE_OK_RESPONSE;
|
return copyFileImpl(params, destinationDir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FileOutputStream fos = info.fileOutputStream;
|
||||||
|
info.lastAccessTime = currentTime;
|
||||||
|
if (params.isDone()) {
|
||||||
|
if (!finishFileCopy(params, file, fos, fileName, destFile)) {
|
||||||
|
return COPY_FILE_IO_ERROR;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fos.write(params.getFilePartData());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LOG.error(e.getMessage(), e);
|
LOG.error(e.getMessage(), e);
|
||||||
}
|
|
||||||
return COPY_FILE_IO_ERROR;
|
return COPY_FILE_IO_ERROR;
|
||||||
}
|
}
|
||||||
|
return OK_RESPONSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean finishFileCopy(CopyFileParams params, File file, FileOutputStream fos, String fileName, File destFile) throws IOException {
|
||||||
|
boolean res = true;
|
||||||
|
byte[] data = params.getFilePartData();
|
||||||
|
if (data.length > 0) {
|
||||||
|
fos.write(data);
|
||||||
|
}
|
||||||
|
if (destFile.exists() && !destFile.delete()) {
|
||||||
|
res = false;
|
||||||
|
}
|
||||||
|
if (res && !file.renameTo(destFile)) {
|
||||||
|
file.delete();
|
||||||
|
res = false;
|
||||||
|
}
|
||||||
|
copyFilesCache.remove(fileName);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
private static class GpxAsyncLoaderTask extends AsyncTask<Void, Void, GPXFile> {
|
private static class GpxAsyncLoaderTask extends AsyncTask<Void, Void, GPXFile> {
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,20 @@ package net.osmand.aidl;
|
||||||
|
|
||||||
public interface OsmandAidlConstants {
|
public interface OsmandAidlConstants {
|
||||||
|
|
||||||
|
int OK_RESPONSE = 0;
|
||||||
|
|
||||||
|
int MIN_UPDATE_TIME_MS = 1000;
|
||||||
|
long COPY_FILE_PART_SIZE_LIMIT = 256 * 1024;
|
||||||
|
long COPY_FILE_MAX_LOCK_TIME_MS = 10000;
|
||||||
|
|
||||||
|
int CANNOT_ACCESS_API_ERROR = -5;
|
||||||
|
int UNKNOWN_API_ERROR = -2;
|
||||||
|
|
||||||
|
int MIN_UPDATE_TIME_MS_ERROR = -1;
|
||||||
|
|
||||||
int COPY_FILE_PARAMS_ERROR = -1001;
|
int COPY_FILE_PARAMS_ERROR = -1001;
|
||||||
int COPY_FILE_PART_SIZE_LIMIT_ERROR = -1002;
|
int COPY_FILE_PART_SIZE_LIMIT_ERROR = -1002;
|
||||||
int COPY_FILE_WRITE_LOCK_ERROR = -1003;
|
int COPY_FILE_WRITE_LOCK_ERROR = -1003;
|
||||||
int COPY_FILE_IO_ERROR = -1004;
|
int COPY_FILE_IO_ERROR = -1004;
|
||||||
int COPY_FILE_UNSUPPORTED_FILE_TYPE_ERROR = -1005;
|
int COPY_FILE_UNSUPPORTED_FILE_TYPE_ERROR = -1005;
|
||||||
int COPY_FILE_START_FLAG = 1001;
|
|
||||||
int COPY_FILE_FINISH_FLAG = 1002;
|
|
||||||
int COPY_FILE_IN_PROGRESS_FLAG = 1000;
|
|
||||||
long COPY_FILE_VALID_PAUSE = 10000;
|
|
||||||
int COPY_FILE_OK_RESPONSE = 0;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ import net.osmand.aidl.plugins.PluginParams;
|
||||||
import net.osmand.aidl.search.SearchParams;
|
import net.osmand.aidl.search.SearchParams;
|
||||||
import net.osmand.aidl.search.SearchResult;
|
import net.osmand.aidl.search.SearchResult;
|
||||||
import net.osmand.aidl.tiles.ASqliteDbFile;
|
import net.osmand.aidl.tiles.ASqliteDbFile;
|
||||||
import net.osmand.aidl.tiles.CopyFileParams;
|
import net.osmand.aidl.copyfile.CopyFileParams;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
|
@ -77,16 +77,17 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
import static net.osmand.aidl.OsmandAidlConstants.CANNOT_ACCESS_API_ERROR;
|
||||||
|
import static net.osmand.aidl.OsmandAidlConstants.MIN_UPDATE_TIME_MS;
|
||||||
|
import static net.osmand.aidl.OsmandAidlConstants.MIN_UPDATE_TIME_MS_ERROR;
|
||||||
|
import static net.osmand.aidl.OsmandAidlConstants.UNKNOWN_API_ERROR;
|
||||||
|
|
||||||
public class OsmandAidlService extends Service {
|
public class OsmandAidlService extends Service {
|
||||||
|
|
||||||
private static final Log LOG = PlatformUtil.getLog(OsmandAidlService.class);
|
private static final Log LOG = PlatformUtil.getLog(OsmandAidlService.class);
|
||||||
|
|
||||||
private static final String DATA_KEY_RESULT_SET = "resultSet";
|
private static final String DATA_KEY_RESULT_SET = "resultSet";
|
||||||
|
|
||||||
private static final int MIN_UPDATE_TIME_MS = 1000;
|
|
||||||
|
|
||||||
private static final int MIN_UPDATE_TIME_MS_ERROR = -1;
|
|
||||||
|
|
||||||
private Map<Long, IOsmAndAidlCallback> callbacks;
|
private Map<Long, IOsmAndAidlCallback> callbacks;
|
||||||
private Handler mHandler = null;
|
private Handler mHandler = null;
|
||||||
HandlerThread mHandlerThread = new HandlerThread("OsmAndAidlServiceThread");
|
HandlerThread mHandlerThread = new HandlerThread("OsmAndAidlServiceThread");
|
||||||
|
@ -137,7 +138,7 @@ public class OsmandAidlService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean refreshMap() throws RemoteException {
|
public boolean refreshMap() {
|
||||||
try {
|
try {
|
||||||
OsmandAidlApi api = getApi("refreshMap");
|
OsmandAidlApi api = getApi("refreshMap");
|
||||||
return api != null && api.reloadMap();
|
return api != null && api.reloadMap();
|
||||||
|
@ -149,7 +150,7 @@ public class OsmandAidlService extends Service {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addFavoriteGroup(AddFavoriteGroupParams params) throws RemoteException {
|
public boolean addFavoriteGroup(AddFavoriteGroupParams params) {
|
||||||
try {
|
try {
|
||||||
OsmandAidlApi api = getApi("addFavoriteGroup");
|
OsmandAidlApi api = getApi("addFavoriteGroup");
|
||||||
return params != null && api != null && api.addFavoriteGroup(params.getFavoriteGroup());
|
return params != null && api != null && api.addFavoriteGroup(params.getFavoriteGroup());
|
||||||
|
@ -160,7 +161,7 @@ public class OsmandAidlService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean removeFavoriteGroup(RemoveFavoriteGroupParams params) throws RemoteException {
|
public boolean removeFavoriteGroup(RemoveFavoriteGroupParams params) {
|
||||||
try {
|
try {
|
||||||
OsmandAidlApi api = getApi("removeFavoriteGroup");
|
OsmandAidlApi api = getApi("removeFavoriteGroup");
|
||||||
return params != null && api != null && api.removeFavoriteGroup(params.getFavoriteGroup());
|
return params != null && api != null && api.removeFavoriteGroup(params.getFavoriteGroup());
|
||||||
|
@ -171,7 +172,7 @@ public class OsmandAidlService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean updateFavoriteGroup(UpdateFavoriteGroupParams params) throws RemoteException {
|
public boolean updateFavoriteGroup(UpdateFavoriteGroupParams params) {
|
||||||
try {
|
try {
|
||||||
OsmandAidlApi api = getApi("updateFavoriteGroup");
|
OsmandAidlApi api = getApi("updateFavoriteGroup");
|
||||||
return params != null && api != null && api.updateFavoriteGroup(params.getFavoriteGroupPrev(), params.getFavoriteGroupNew());
|
return params != null && api != null && api.updateFavoriteGroup(params.getFavoriteGroupPrev(), params.getFavoriteGroupNew());
|
||||||
|
@ -182,7 +183,7 @@ public class OsmandAidlService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addFavorite(AddFavoriteParams params) throws RemoteException {
|
public boolean addFavorite(AddFavoriteParams params) {
|
||||||
try {
|
try {
|
||||||
OsmandAidlApi api = getApi("addFavorite");
|
OsmandAidlApi api = getApi("addFavorite");
|
||||||
return params != null && api != null && api.addFavorite(params.getFavorite());
|
return params != null && api != null && api.addFavorite(params.getFavorite());
|
||||||
|
@ -193,7 +194,7 @@ public class OsmandAidlService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean removeFavorite(RemoveFavoriteParams params) throws RemoteException {
|
public boolean removeFavorite(RemoveFavoriteParams params) {
|
||||||
try {
|
try {
|
||||||
OsmandAidlApi api = getApi("removeFavorite");
|
OsmandAidlApi api = getApi("removeFavorite");
|
||||||
return params != null && api != null && api.removeFavorite(params.getFavorite());
|
return params != null && api != null && api.removeFavorite(params.getFavorite());
|
||||||
|
@ -204,7 +205,7 @@ public class OsmandAidlService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean updateFavorite(UpdateFavoriteParams params) throws RemoteException {
|
public boolean updateFavorite(UpdateFavoriteParams params) {
|
||||||
try {
|
try {
|
||||||
OsmandAidlApi api = getApi("updateFavorite");
|
OsmandAidlApi api = getApi("updateFavorite");
|
||||||
return params != null && api != null && api.updateFavorite(params.getFavoritePrev(), params.getFavoriteNew());
|
return params != null && api != null && api.updateFavorite(params.getFavoritePrev(), params.getFavoriteNew());
|
||||||
|
@ -215,7 +216,7 @@ public class OsmandAidlService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addMapMarker(AddMapMarkerParams params) throws RemoteException {
|
public boolean addMapMarker(AddMapMarkerParams params) {
|
||||||
try {
|
try {
|
||||||
OsmandAidlApi api = getApi("addMapMarker");
|
OsmandAidlApi api = getApi("addMapMarker");
|
||||||
return params != null && api != null && api.addMapMarker(params.getMarker());
|
return params != null && api != null && api.addMapMarker(params.getMarker());
|
||||||
|
@ -225,7 +226,7 @@ public class OsmandAidlService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean removeMapMarker(RemoveMapMarkerParams params) throws RemoteException {
|
public boolean removeMapMarker(RemoveMapMarkerParams params) {
|
||||||
try {
|
try {
|
||||||
OsmandAidlApi api = getApi("removeMapMarker");
|
OsmandAidlApi api = getApi("removeMapMarker");
|
||||||
return params != null && api != null && api.removeMapMarker(params.getMarker());
|
return params != null && api != null && api.removeMapMarker(params.getMarker());
|
||||||
|
@ -236,7 +237,7 @@ public class OsmandAidlService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean updateMapMarker(UpdateMapMarkerParams params) throws RemoteException {
|
public boolean updateMapMarker(UpdateMapMarkerParams params) {
|
||||||
try {
|
try {
|
||||||
OsmandAidlApi api = getApi("updateMapMarker");
|
OsmandAidlApi api = getApi("updateMapMarker");
|
||||||
return params != null && api != null && api.updateMapMarker(params.getMarkerPrev(), params.getMarkerNew());
|
return params != null && api != null && api.updateMapMarker(params.getMarkerPrev(), params.getMarkerNew());
|
||||||
|
@ -247,7 +248,7 @@ public class OsmandAidlService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addMapWidget(AddMapWidgetParams params) throws RemoteException {
|
public boolean addMapWidget(AddMapWidgetParams params) {
|
||||||
try {
|
try {
|
||||||
OsmandAidlApi api = getApi("addMapWidget");
|
OsmandAidlApi api = getApi("addMapWidget");
|
||||||
return params != null && api != null && api.addMapWidget(params.getWidget());
|
return params != null && api != null && api.addMapWidget(params.getWidget());
|
||||||
|
@ -258,7 +259,7 @@ public class OsmandAidlService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean removeMapWidget(RemoveMapWidgetParams params) throws RemoteException {
|
public boolean removeMapWidget(RemoveMapWidgetParams params) {
|
||||||
try {
|
try {
|
||||||
OsmandAidlApi api = getApi("removeMapWidget");
|
OsmandAidlApi api = getApi("removeMapWidget");
|
||||||
return params != null && api != null && api.removeMapWidget(params.getId());
|
return params != null && api != null && api.removeMapWidget(params.getId());
|
||||||
|
@ -268,7 +269,7 @@ public class OsmandAidlService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean updateMapWidget(UpdateMapWidgetParams params) throws RemoteException {
|
public boolean updateMapWidget(UpdateMapWidgetParams params) {
|
||||||
try {
|
try {
|
||||||
OsmandAidlApi api = getApi("updateMapWidget");
|
OsmandAidlApi api = getApi("updateMapWidget");
|
||||||
return params != null && api != null && api.updateMapWidget(params.getWidget());
|
return params != null && api != null && api.updateMapWidget(params.getWidget());
|
||||||
|
@ -279,7 +280,7 @@ public class OsmandAidlService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean showMapPoint(ShowMapPointParams params) throws RemoteException {
|
public boolean showMapPoint(ShowMapPointParams params) {
|
||||||
try {
|
try {
|
||||||
OsmandAidlApi api = getApi("showMapPoint");
|
OsmandAidlApi api = getApi("showMapPoint");
|
||||||
return params != null && api != null && api.showMapPoint(params.getLayerId(), params.getPoint());
|
return params != null && api != null && api.showMapPoint(params.getLayerId(), params.getPoint());
|
||||||
|
@ -290,7 +291,7 @@ public class OsmandAidlService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addMapPoint(AddMapPointParams params) throws RemoteException {
|
public boolean addMapPoint(AddMapPointParams params) {
|
||||||
try {
|
try {
|
||||||
OsmandAidlApi api = getApi("addMapPoint");
|
OsmandAidlApi api = getApi("addMapPoint");
|
||||||
return params != null && api != null && api.putMapPoint(params.getLayerId(), params.getPoint());
|
return params != null && api != null && api.putMapPoint(params.getLayerId(), params.getPoint());
|
||||||
|
@ -301,7 +302,7 @@ public class OsmandAidlService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean removeMapPoint(RemoveMapPointParams params) throws RemoteException {
|
public boolean removeMapPoint(RemoveMapPointParams params) {
|
||||||
try {
|
try {
|
||||||
OsmandAidlApi api = getApi("removeMapPoint");
|
OsmandAidlApi api = getApi("removeMapPoint");
|
||||||
return params != null && api != null && api.removeMapPoint(params.getLayerId(), params.getPointId());
|
return params != null && api != null && api.removeMapPoint(params.getLayerId(), params.getPointId());
|
||||||
|
@ -312,7 +313,7 @@ public class OsmandAidlService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean updateMapPoint(UpdateMapPointParams params) throws RemoteException {
|
public boolean updateMapPoint(UpdateMapPointParams params) {
|
||||||
try {
|
try {
|
||||||
OsmandAidlApi api = getApi("updateMapPoint");
|
OsmandAidlApi api = getApi("updateMapPoint");
|
||||||
return params != null && api != null && api.putMapPoint(params.getLayerId(), params.getPoint());
|
return params != null && api != null && api.putMapPoint(params.getLayerId(), params.getPoint());
|
||||||
|
@ -323,7 +324,7 @@ public class OsmandAidlService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addMapLayer(AddMapLayerParams params) throws RemoteException {
|
public boolean addMapLayer(AddMapLayerParams params) {
|
||||||
try {
|
try {
|
||||||
OsmandAidlApi api = getApi("addMapLayer");
|
OsmandAidlApi api = getApi("addMapLayer");
|
||||||
return params != null && api != null && api.addMapLayer(params.getLayer());
|
return params != null && api != null && api.addMapLayer(params.getLayer());
|
||||||
|
@ -334,7 +335,7 @@ public class OsmandAidlService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean removeMapLayer(RemoveMapLayerParams params) throws RemoteException {
|
public boolean removeMapLayer(RemoveMapLayerParams params) {
|
||||||
try {
|
try {
|
||||||
OsmandAidlApi api = getApi("removeMapLayer");
|
OsmandAidlApi api = getApi("removeMapLayer");
|
||||||
return params != null && api != null && api.removeMapLayer(params.getId());
|
return params != null && api != null && api.removeMapLayer(params.getId());
|
||||||
|
@ -345,7 +346,7 @@ public class OsmandAidlService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean updateMapLayer(UpdateMapLayerParams params) throws RemoteException {
|
public boolean updateMapLayer(UpdateMapLayerParams params) {
|
||||||
try {
|
try {
|
||||||
OsmandAidlApi api = getApi("updateMapLayer");
|
OsmandAidlApi api = getApi("updateMapLayer");
|
||||||
return params != null && api != null && api.updateMapLayer(params.getLayer());
|
return params != null && api != null && api.updateMapLayer(params.getLayer());
|
||||||
|
@ -356,7 +357,8 @@ public class OsmandAidlService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean importGpx(ImportGpxParams params) throws RemoteException {
|
public boolean importGpx(ImportGpxParams params) {
|
||||||
|
try {
|
||||||
if (params != null && !Algorithms.isEmpty(params.getDestinationPath())) {
|
if (params != null && !Algorithms.isEmpty(params.getDestinationPath())) {
|
||||||
OsmandAidlApi api = getApi("importGpx");
|
OsmandAidlApi api = getApi("importGpx");
|
||||||
if (api != null) {
|
if (api != null) {
|
||||||
|
@ -373,59 +375,94 @@ public class OsmandAidlService extends Service {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
} catch (Exception e) {
|
||||||
|
handleException(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean showGpx(ShowGpxParams params) throws RemoteException {
|
public boolean showGpx(ShowGpxParams params) {
|
||||||
|
try {
|
||||||
if (params != null && params.getFileName() != null) {
|
if (params != null && params.getFileName() != null) {
|
||||||
OsmandAidlApi api = getApi("showGpx");
|
OsmandAidlApi api = getApi("showGpx");
|
||||||
return api != null && api.showGpx(params.getFileName());
|
return api != null && api.showGpx(params.getFileName());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
} catch (Exception e) {
|
||||||
|
handleException(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hideGpx(HideGpxParams params) throws RemoteException {
|
public boolean hideGpx(HideGpxParams params) {
|
||||||
|
try {
|
||||||
if (params != null && params.getFileName() != null) {
|
if (params != null && params.getFileName() != null) {
|
||||||
OsmandAidlApi api = getApi("hideGpx");
|
OsmandAidlApi api = getApi("hideGpx");
|
||||||
return api != null && api.hideGpx(params.getFileName());
|
return api != null && api.hideGpx(params.getFileName());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
} catch (Exception e) {
|
||||||
|
handleException(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getActiveGpx(List<ASelectedGpxFile> files) throws RemoteException {
|
public boolean getActiveGpx(List<ASelectedGpxFile> files) {
|
||||||
|
try {
|
||||||
OsmandAidlApi api = getApi("getActiveGpx");
|
OsmandAidlApi api = getApi("getActiveGpx");
|
||||||
return api != null && api.getActiveGpx(files);
|
return api != null && api.getActiveGpx(files);
|
||||||
|
} catch (Exception e) {
|
||||||
|
handleException(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getImportedGpx(List<AGpxFile> files) throws RemoteException {
|
public boolean getImportedGpx(List<AGpxFile> files) {
|
||||||
|
try {
|
||||||
OsmandAidlApi api = getApi("getImportedGpx");
|
OsmandAidlApi api = getApi("getImportedGpx");
|
||||||
return api != null && api.getImportedGpx(files);
|
return api != null && api.getImportedGpx(files);
|
||||||
|
} catch (Exception e) {
|
||||||
|
handleException(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean removeGpx(RemoveGpxParams params) throws RemoteException {
|
public boolean removeGpx(RemoveGpxParams params) {
|
||||||
|
try {
|
||||||
if (params != null && params.getFileName() != null) {
|
if (params != null && params.getFileName() != null) {
|
||||||
OsmandAidlApi api = getApi("removeGpx");
|
OsmandAidlApi api = getApi("removeGpx");
|
||||||
return api != null && api.removeGpx(params.getFileName());
|
return api != null && api.removeGpx(params.getFileName());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
} catch (Exception e) {
|
||||||
|
handleException(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setMapLocation(SetMapLocationParams params) throws RemoteException {
|
public boolean setMapLocation(SetMapLocationParams params) {
|
||||||
|
try {
|
||||||
if (params != null) {
|
if (params != null) {
|
||||||
OsmandAidlApi api = getApi("setMapLocation");
|
OsmandAidlApi api = getApi("setMapLocation");
|
||||||
return api != null && api.setMapLocation(params.getLatitude(), params.getLongitude(),
|
return api != null && api.setMapLocation(params.getLatitude(), params.getLongitude(),
|
||||||
params.getZoom(), params.isAnimated());
|
params.getZoom(), params.isAnimated());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
} catch (Exception e) {
|
||||||
|
handleException(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean calculateRoute(CalculateRouteParams params) throws RemoteException {
|
public boolean calculateRoute(CalculateRouteParams params) {
|
||||||
|
try {
|
||||||
if (params == null || params.getEndPoint() == null) {
|
if (params == null || params.getEndPoint() == null) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -473,10 +510,14 @@ public class OsmandAidlService extends Service {
|
||||||
*/
|
*/
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
handleException(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean startGpxRecording(StartGpxRecordingParams params) throws RemoteException {
|
public boolean startGpxRecording(StartGpxRecordingParams params) {
|
||||||
try {
|
try {
|
||||||
OsmandAidlApi api = getApi("startGpxRecording");
|
OsmandAidlApi api = getApi("startGpxRecording");
|
||||||
return api != null && api.startGpxRecording(params);
|
return api != null && api.startGpxRecording(params);
|
||||||
|
@ -487,7 +528,7 @@ public class OsmandAidlService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean stopGpxRecording(StopGpxRecordingParams params) throws RemoteException {
|
public boolean stopGpxRecording(StopGpxRecordingParams params) {
|
||||||
try {
|
try {
|
||||||
OsmandAidlApi api = getApi("stopGpxRecording");
|
OsmandAidlApi api = getApi("stopGpxRecording");
|
||||||
return api != null && api.stopGpxRecording(params);
|
return api != null && api.stopGpxRecording(params);
|
||||||
|
@ -498,7 +539,7 @@ public class OsmandAidlService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean takePhotoNote(TakePhotoNoteParams params) throws RemoteException {
|
public boolean takePhotoNote(TakePhotoNoteParams params) {
|
||||||
try {
|
try {
|
||||||
OsmandAidlApi api = getApi("takePhotoNote");
|
OsmandAidlApi api = getApi("takePhotoNote");
|
||||||
return params != null && api != null && api.takePhotoNote(params.getLatitude(), params.getLongitude());
|
return params != null && api != null && api.takePhotoNote(params.getLatitude(), params.getLongitude());
|
||||||
|
@ -509,7 +550,7 @@ public class OsmandAidlService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean startVideoRecording(StartVideoRecordingParams params) throws RemoteException {
|
public boolean startVideoRecording(StartVideoRecordingParams params) {
|
||||||
try {
|
try {
|
||||||
OsmandAidlApi api = getApi("startVideoRecording");
|
OsmandAidlApi api = getApi("startVideoRecording");
|
||||||
return params != null && api != null && api.startVideoRecording(params.getLatitude(), params.getLongitude());
|
return params != null && api != null && api.startVideoRecording(params.getLatitude(), params.getLongitude());
|
||||||
|
@ -520,7 +561,7 @@ public class OsmandAidlService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean startAudioRecording(StartAudioRecordingParams params) throws RemoteException {
|
public boolean startAudioRecording(StartAudioRecordingParams params) {
|
||||||
try {
|
try {
|
||||||
OsmandAidlApi api = getApi("startAudioRecording");
|
OsmandAidlApi api = getApi("startAudioRecording");
|
||||||
return params != null && api != null && api.startAudioRecording(params.getLatitude(), params.getLongitude());
|
return params != null && api != null && api.startAudioRecording(params.getLatitude(), params.getLongitude());
|
||||||
|
@ -531,7 +572,7 @@ public class OsmandAidlService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean stopRecording(StopRecordingParams params) throws RemoteException {
|
public boolean stopRecording(StopRecordingParams params) {
|
||||||
try {
|
try {
|
||||||
OsmandAidlApi api = getApi("stopRecording");
|
OsmandAidlApi api = getApi("stopRecording");
|
||||||
return api != null && api.stopRecording();
|
return api != null && api.stopRecording();
|
||||||
|
@ -542,7 +583,7 @@ public class OsmandAidlService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean navigate(NavigateParams params) throws RemoteException {
|
public boolean navigate(NavigateParams params) {
|
||||||
try {
|
try {
|
||||||
OsmandAidlApi api = getApi("navigate");
|
OsmandAidlApi api = getApi("navigate");
|
||||||
return params != null && api != null && api.navigate(
|
return params != null && api != null && api.navigate(
|
||||||
|
@ -556,7 +597,7 @@ public class OsmandAidlService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean navigateGpx(NavigateGpxParams params) throws RemoteException {
|
public boolean navigateGpx(NavigateGpxParams params) {
|
||||||
try {
|
try {
|
||||||
OsmandAidlApi api = getApi("navigateGpx");
|
OsmandAidlApi api = getApi("navigateGpx");
|
||||||
return params != null && api != null && api.navigateGpx(params.getData(), params.getUri(), params.isForce());
|
return params != null && api != null && api.navigateGpx(params.getData(), params.getUri(), params.isForce());
|
||||||
|
@ -567,7 +608,7 @@ public class OsmandAidlService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean pauseNavigation(PauseNavigationParams params) throws RemoteException {
|
public boolean pauseNavigation(PauseNavigationParams params) {
|
||||||
try {
|
try {
|
||||||
OsmandAidlApi api = getApi("pauseNavigation");
|
OsmandAidlApi api = getApi("pauseNavigation");
|
||||||
return api != null && api.pauseNavigation();
|
return api != null && api.pauseNavigation();
|
||||||
|
@ -578,7 +619,7 @@ public class OsmandAidlService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean resumeNavigation(ResumeNavigationParams params) throws RemoteException {
|
public boolean resumeNavigation(ResumeNavigationParams params) {
|
||||||
try {
|
try {
|
||||||
OsmandAidlApi api = getApi("resumeNavigation");
|
OsmandAidlApi api = getApi("resumeNavigation");
|
||||||
return api != null && api.resumeNavigation();
|
return api != null && api.resumeNavigation();
|
||||||
|
@ -589,7 +630,7 @@ public class OsmandAidlService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean stopNavigation(StopNavigationParams params) throws RemoteException {
|
public boolean stopNavigation(StopNavigationParams params) {
|
||||||
try {
|
try {
|
||||||
OsmandAidlApi api = getApi("stopNavigation");
|
OsmandAidlApi api = getApi("stopNavigation");
|
||||||
return api != null && api.stopNavigation();
|
return api != null && api.stopNavigation();
|
||||||
|
@ -600,7 +641,7 @@ public class OsmandAidlService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean muteNavigation(MuteNavigationParams params) throws RemoteException {
|
public boolean muteNavigation(MuteNavigationParams params) {
|
||||||
try {
|
try {
|
||||||
OsmandAidlApi api = getApi("muteNavigation");
|
OsmandAidlApi api = getApi("muteNavigation");
|
||||||
return api != null && api.muteNavigation();
|
return api != null && api.muteNavigation();
|
||||||
|
@ -611,7 +652,7 @@ public class OsmandAidlService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean unmuteNavigation(UnmuteNavigationParams params) throws RemoteException {
|
public boolean unmuteNavigation(UnmuteNavigationParams params) {
|
||||||
try {
|
try {
|
||||||
OsmandAidlApi api = getApi("unmuteNavigation");
|
OsmandAidlApi api = getApi("unmuteNavigation");
|
||||||
return api != null && api.unmuteNavigation();
|
return api != null && api.unmuteNavigation();
|
||||||
|
@ -622,7 +663,7 @@ public class OsmandAidlService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setNavDrawerItems(SetNavDrawerItemsParams params) throws RemoteException {
|
public boolean setNavDrawerItems(SetNavDrawerItemsParams params) {
|
||||||
try {
|
try {
|
||||||
OsmandAidlApi api = getApi("setNavDrawerItems");
|
OsmandAidlApi api = getApi("setNavDrawerItems");
|
||||||
return params != null && api != null && api.setNavDrawerItems(params.getAppPackage(), params.getItems());
|
return params != null && api != null && api.setNavDrawerItems(params.getAppPackage(), params.getItems());
|
||||||
|
@ -633,7 +674,7 @@ public class OsmandAidlService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean search(SearchParams params, final IOsmAndAidlCallback callback) throws RemoteException {
|
public boolean search(SearchParams params, final IOsmAndAidlCallback callback) {
|
||||||
try {
|
try {
|
||||||
OsmandAidlApi api = getApi("search");
|
OsmandAidlApi api = getApi("search");
|
||||||
return params != null && api != null && api.search(params.getSearchQuery(), params.getSearchType(),
|
return params != null && api != null && api.search(params.getSearchQuery(), params.getSearchType(),
|
||||||
|
@ -658,7 +699,7 @@ public class OsmandAidlService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean navigateSearch(NavigateSearchParams params) throws RemoteException {
|
public boolean navigateSearch(NavigateSearchParams params) {
|
||||||
try {
|
try {
|
||||||
OsmandAidlApi api = getApi("navigateSearch");
|
OsmandAidlApi api = getApi("navigateSearch");
|
||||||
return params != null && api != null && api.navigateSearch(
|
return params != null && api != null && api.navigateSearch(
|
||||||
|
@ -672,7 +713,8 @@ public class OsmandAidlService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long registerForUpdates(long updateTimeMS, IOsmAndAidlCallback callback) throws RemoteException {
|
public long registerForUpdates(long updateTimeMS, IOsmAndAidlCallback callback) {
|
||||||
|
try {
|
||||||
if (updateTimeMS >= MIN_UPDATE_TIME_MS) {
|
if (updateTimeMS >= MIN_UPDATE_TIME_MS) {
|
||||||
updateCallbackId++;
|
updateCallbackId++;
|
||||||
callbacks.put(updateCallbackId, callback);
|
callbacks.put(updateCallbackId, callback);
|
||||||
|
@ -681,44 +723,79 @@ public class OsmandAidlService extends Service {
|
||||||
} else {
|
} else {
|
||||||
return MIN_UPDATE_TIME_MS_ERROR;
|
return MIN_UPDATE_TIME_MS_ERROR;
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
handleException(e);
|
||||||
|
return UNKNOWN_API_ERROR;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean unregisterFromUpdates(long callbackId) throws RemoteException {
|
public boolean unregisterFromUpdates(long callbackId) {
|
||||||
|
try {
|
||||||
return callbacks.remove(callbackId) != null;
|
return callbacks.remove(callbackId) != null;
|
||||||
|
} catch (Exception e) {
|
||||||
|
handleException(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setNavDrawerLogo(String imageUri) throws RemoteException {
|
public boolean setNavDrawerLogo(String imageUri) {
|
||||||
|
try {
|
||||||
OsmandAidlApi api = getApi("setNavDrawerLogo");
|
OsmandAidlApi api = getApi("setNavDrawerLogo");
|
||||||
return api != null && api.setNavDrawerLogo(imageUri);
|
return api != null && api.setNavDrawerLogo(imageUri);
|
||||||
|
} catch (Exception e) {
|
||||||
|
handleException(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setEnabledIds(List<String> ids) throws RemoteException {
|
public boolean setEnabledIds(List<String> ids) {
|
||||||
|
try {
|
||||||
OsmandAidlApi api = getApi("setFeaturesEnabledIds");
|
OsmandAidlApi api = getApi("setFeaturesEnabledIds");
|
||||||
return api != null && api.setEnabledIds(ids);
|
return api != null && api.setEnabledIds(ids);
|
||||||
|
} catch (Exception e) {
|
||||||
|
handleException(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setDisabledIds(List<String> ids) throws RemoteException {
|
public boolean setDisabledIds(List<String> ids) {
|
||||||
|
try {
|
||||||
OsmandAidlApi api = getApi("setFeaturesDisabledIds");
|
OsmandAidlApi api = getApi("setFeaturesDisabledIds");
|
||||||
return api != null && api.setDisabledIds(ids);
|
return api != null && api.setDisabledIds(ids);
|
||||||
|
} catch (Exception e) {
|
||||||
|
handleException(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setEnabledPatterns(List<String> patterns) throws RemoteException {
|
public boolean setEnabledPatterns(List<String> patterns) {
|
||||||
|
try {
|
||||||
OsmandAidlApi api = getApi("setFeaturesEnabledPatterns");
|
OsmandAidlApi api = getApi("setFeaturesEnabledPatterns");
|
||||||
return api != null && api.setEnabledPatterns(patterns);
|
return api != null && api.setEnabledPatterns(patterns);
|
||||||
|
} catch (Exception e) {
|
||||||
|
handleException(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setDisabledPatterns(List<String> patterns) throws RemoteException {
|
public boolean setDisabledPatterns(List<String> patterns) {
|
||||||
|
try {
|
||||||
OsmandAidlApi api = getApi("setFeaturesDisabledPatterns");
|
OsmandAidlApi api = getApi("setFeaturesDisabledPatterns");
|
||||||
return api != null && api.setDisabledPatterns(patterns);
|
return api != null && api.setDisabledPatterns(patterns);
|
||||||
|
} catch (Exception e) {
|
||||||
|
handleException(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void startRemoteUpdates(final long updateTimeMS, final long callbackId, final IOsmAndAidlCallback callback) {
|
void startRemoteUpdates(final long updateTimeMS, final long callbackId, final IOsmAndAidlCallback callback) {
|
||||||
|
try {
|
||||||
mHandler.postDelayed(new Runnable() {
|
mHandler.postDelayed(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -735,79 +812,135 @@ public class OsmandAidlService extends Service {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, updateTimeMS);
|
}, updateTimeMS);
|
||||||
|
} catch (Exception e) {
|
||||||
|
handleException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean regWidgetVisibility(SetWidgetsParams params) throws RemoteException {
|
public boolean regWidgetVisibility(SetWidgetsParams params) {
|
||||||
|
try {
|
||||||
OsmandAidlApi api = getApi("regWidgetVisibility");
|
OsmandAidlApi api = getApi("regWidgetVisibility");
|
||||||
return api != null && api.regWidgetVisibility(params.getWidgetKey(), params.getAppModesKeys());
|
return api != null && api.regWidgetVisibility(params.getWidgetKey(), params.getAppModesKeys());
|
||||||
|
} catch (Exception e) {
|
||||||
|
handleException(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean regWidgetAvailability(SetWidgetsParams params) throws RemoteException {
|
public boolean regWidgetAvailability(SetWidgetsParams params) {
|
||||||
|
try {
|
||||||
OsmandAidlApi api = getApi("regWidgetVisibility");
|
OsmandAidlApi api = getApi("regWidgetVisibility");
|
||||||
return api != null && api.regWidgetAvailability(params.getWidgetKey(), params.getAppModesKeys());
|
return api != null && api.regWidgetAvailability(params.getWidgetKey(), params.getAppModesKeys());
|
||||||
|
} catch (Exception e) {
|
||||||
|
handleException(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean customizeOsmandSettings(OsmandSettingsParams params) throws RemoteException {
|
public boolean customizeOsmandSettings(OsmandSettingsParams params) {
|
||||||
|
try {
|
||||||
OsmandAidlApi api = getApi("customizeOsmandSettings");
|
OsmandAidlApi api = getApi("customizeOsmandSettings");
|
||||||
return api != null && api.customizeOsmandSettings(params.getSharedPreferencesName(), params.getBundle());
|
return api != null && api.customizeOsmandSettings(params.getSharedPreferencesName(), params.getBundle());
|
||||||
|
} catch (Exception e) {
|
||||||
|
handleException(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getSqliteDbFiles(List<ASqliteDbFile> files) throws RemoteException {
|
public boolean getSqliteDbFiles(List<ASqliteDbFile> files) {
|
||||||
|
try {
|
||||||
OsmandAidlApi api = getApi("getSqliteDbFiles");
|
OsmandAidlApi api = getApi("getSqliteDbFiles");
|
||||||
return api != null && api.getSqliteDbFiles(files);
|
return api != null && api.getSqliteDbFiles(files);
|
||||||
|
} catch (Exception e) {
|
||||||
|
handleException(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getActiveSqliteDbFiles(List<ASqliteDbFile> files) throws RemoteException {
|
public boolean getActiveSqliteDbFiles(List<ASqliteDbFile> files) {
|
||||||
|
try {
|
||||||
OsmandAidlApi api = getApi("getActiveSqliteDbFiles");
|
OsmandAidlApi api = getApi("getActiveSqliteDbFiles");
|
||||||
return api != null && api.getActiveSqliteDbFiles(files);
|
return api != null && api.getActiveSqliteDbFiles(files);
|
||||||
|
} catch (Exception e) {
|
||||||
|
handleException(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean showSqliteDbFile(String fileName) throws RemoteException {
|
public boolean showSqliteDbFile(String fileName) {
|
||||||
|
try {
|
||||||
OsmandAidlApi api = getApi("showSqliteDbFile");
|
OsmandAidlApi api = getApi("showSqliteDbFile");
|
||||||
return api != null && api.showSqliteDbFile(fileName);
|
return api != null && api.showSqliteDbFile(fileName);
|
||||||
|
} catch (Exception e) {
|
||||||
|
handleException(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hideSqliteDbFile(String fileName) throws RemoteException {
|
public boolean hideSqliteDbFile(String fileName) {
|
||||||
|
try {
|
||||||
OsmandAidlApi api = getApi("hideSqliteDbFile");
|
OsmandAidlApi api = getApi("hideSqliteDbFile");
|
||||||
return api != null && api.hideSqliteDbFile(fileName);
|
return api != null && api.hideSqliteDbFile(fileName);
|
||||||
|
} catch (Exception e) {
|
||||||
|
handleException(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setNavDrawerLogoWithParams(NavDrawerHeaderParams params) throws RemoteException {
|
public boolean setNavDrawerLogoWithParams(NavDrawerHeaderParams params) {
|
||||||
|
try {
|
||||||
OsmandAidlApi api = getApi("setNavDrawerLogoWithParams");
|
OsmandAidlApi api = getApi("setNavDrawerLogoWithParams");
|
||||||
return api != null && api.setNavDrawerLogoWithParams(
|
return api != null && api.setNavDrawerLogoWithParams(
|
||||||
params.getImageUri(), params.getPackageName(), params.getIntent());
|
params.getImageUri(), params.getPackageName(), params.getIntent());
|
||||||
|
} catch (Exception e) {
|
||||||
|
handleException(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setNavDrawerFooterWithParams(NavDrawerFooterParams params)
|
public boolean setNavDrawerFooterWithParams(NavDrawerFooterParams params) {
|
||||||
throws RemoteException {
|
try {
|
||||||
OsmandAidlApi api = getApi("setNavDrawerFooterParams");
|
OsmandAidlApi api = getApi("setNavDrawerFooterParams");
|
||||||
return api != null && api.setNavDrawerFooterWithParams(params);
|
return api != null && api.setNavDrawerFooterWithParams(params);
|
||||||
|
} catch (Exception e) {
|
||||||
|
handleException(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean restoreOsmand() {
|
public boolean restoreOsmand() {
|
||||||
|
try {
|
||||||
OsmandAidlApi api = getApi("restoreOsmand");
|
OsmandAidlApi api = getApi("restoreOsmand");
|
||||||
return api != null && api.restoreOsmand();
|
return api != null && api.restoreOsmand();
|
||||||
|
} catch (Exception e) {
|
||||||
|
handleException(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean changePluginState(PluginParams params) {
|
public boolean changePluginState(PluginParams params) {
|
||||||
|
try {
|
||||||
OsmandAidlApi api = getApi("changePluginState");
|
OsmandAidlApi api = getApi("changePluginState");
|
||||||
return api != null && api.changePluginState(params);
|
return api != null && api.changePluginState(params);
|
||||||
|
} catch (Exception e) {
|
||||||
|
handleException(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean registerForOsmandInitListener(final IOsmAndAidlCallback callback)
|
public boolean registerForOsmandInitListener(final IOsmAndAidlCallback callback) {
|
||||||
throws RemoteException {
|
|
||||||
try {
|
try {
|
||||||
OsmandAidlApi api = getApi("registerForOsmandInitListener");
|
OsmandAidlApi api = getApi("registerForOsmandInitListener");
|
||||||
return api != null && api.registerForOsmandInitialization(new OsmandAppInitCallback() {
|
return api != null && api.registerForOsmandInitialization(new OsmandAppInitCallback() {
|
||||||
|
@ -827,7 +960,7 @@ public class OsmandAidlService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getBitmapForGpx(CreateGpxBitmapParams params, final IOsmAndAidlCallback callback) throws RemoteException {
|
public boolean getBitmapForGpx(CreateGpxBitmapParams params, final IOsmAndAidlCallback callback) {
|
||||||
try {
|
try {
|
||||||
OsmandAidlApi api = getApi("getBitmapForGpx");
|
OsmandAidlApi api = getApi("getBitmapForGpx");
|
||||||
return params != null && api != null && api.getBitmapForGpx(params.getGpxUri(), params.getDensity(), params.getWidthPixels(), params.getHeightPixels(), params.getColor(), new GpxBitmapCreatedCallback() {
|
return params != null && api != null && api.getBitmapForGpx(params.getGpxUri(), params.getDensity(), params.getWidthPixels(), params.getHeightPixels(), params.getColor(), new GpxBitmapCreatedCallback() {
|
||||||
|
@ -848,11 +981,16 @@ public class OsmandAidlService extends Service {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int copyFile(CopyFileParams copyFileParams) {
|
public int copyFile(CopyFileParams copyFileParams) {
|
||||||
|
try {
|
||||||
OsmandAidlApi api = getApi("copyFile");
|
OsmandAidlApi api = getApi("copyFile");
|
||||||
if (api==null) {
|
if (api == null) {
|
||||||
return -5;
|
return CANNOT_ACCESS_API_ERROR;
|
||||||
}
|
}
|
||||||
return api.copyFile(copyFileParams);
|
return api.copyFile(copyFileParams);
|
||||||
|
} catch (Exception e) {
|
||||||
|
handleException(e);
|
||||||
|
return UNKNOWN_API_ERROR;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
3
OsmAnd/src/net/osmand/aidl/copyfile/CopyFileParams.aidl
Normal file
3
OsmAnd/src/net/osmand/aidl/copyfile/CopyFileParams.aidl
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
package net.osmand.aidl.copyfile;
|
||||||
|
|
||||||
|
parcelable CopyFileParams;
|
|
@ -1,33 +1,32 @@
|
||||||
package net.osmand.aidl.tiles;
|
package net.osmand.aidl.copyfile;
|
||||||
|
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import java.util.Arrays;
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
public class CopyFileParams implements Parcelable {
|
public class CopyFileParams implements Parcelable {
|
||||||
private String filename;
|
private String fileName;
|
||||||
private byte[] filePartData;
|
private byte[] filePartData;
|
||||||
private long startTime;
|
private long startTime;
|
||||||
private int actionId;
|
private boolean done;
|
||||||
|
|
||||||
public CopyFileParams(String filename, byte[] filePartData, long startTime, int actionId) {
|
public CopyFileParams(@NonNull String fileName, @NonNull byte[] filePartData, long startTime, boolean done) {
|
||||||
this.filename = filename;
|
this.fileName = fileName;
|
||||||
this.filePartData = filePartData;
|
this.filePartData = filePartData;
|
||||||
this.startTime = startTime;
|
this.startTime = startTime;
|
||||||
this.actionId = actionId;
|
this.done = done;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFilename() {
|
public String getFileName() {
|
||||||
return filename;
|
return fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public byte[] getFilePartData() {
|
public byte[] getFilePartData() {
|
||||||
return filePartData;
|
return filePartData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getActionId() {
|
public boolean isDone() {
|
||||||
return actionId;
|
return done;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getStartTime() {
|
public long getStartTime() {
|
||||||
|
@ -35,10 +34,10 @@ public class CopyFileParams implements Parcelable {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CopyFileParams(Parcel in) {
|
protected CopyFileParams(Parcel in) {
|
||||||
filename = in.readString();
|
fileName = in.readString();
|
||||||
filePartData = in.createByteArray();
|
filePartData = in.createByteArray();
|
||||||
startTime = in.readLong();
|
startTime = in.readLong();
|
||||||
actionId = in.readInt();
|
done = in.readByte() == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Creator<CopyFileParams> CREATOR = new Creator<CopyFileParams>() {
|
public static final Creator<CopyFileParams> CREATOR = new Creator<CopyFileParams>() {
|
||||||
|
@ -61,22 +60,19 @@ public class CopyFileParams implements Parcelable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "CopyFileParams{" +
|
return "CopyFileParams {" +
|
||||||
"filename='" + filename + '\'' +
|
" fileName=" + fileName +
|
||||||
", filePartData=" + filePartData +
|
", filePartData size=" + filePartData.length +
|
||||||
", startTime=" + startTime +
|
", startTime=" + startTime +
|
||||||
", actionId=" + actionId +
|
", done=" + done +
|
||||||
'}';
|
" }";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
public void writeToParcel(Parcel dest, int flags) {
|
||||||
dest.writeString(filename);
|
dest.writeString(fileName);
|
||||||
dest.writeByteArray(filePartData);
|
dest.writeByteArray(filePartData);
|
||||||
dest.writeLong(startTime);
|
dest.writeLong(startTime);
|
||||||
dest.writeInt(actionId);
|
dest.writeByte((byte) (done ? 0 : 1));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,3 +0,0 @@
|
||||||
package net.osmand.aidl.tiles;
|
|
||||||
|
|
||||||
parcelable CopyFileParams;
|
|
|
@ -26,7 +26,6 @@ import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
|
||||||
import net.osmand.CallbackWithObject;
|
import net.osmand.CallbackWithObject;
|
||||||
import net.osmand.IndexConstants;
|
import net.osmand.IndexConstants;
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
|
@ -172,7 +171,7 @@ public class OsmandApplication extends MultiDexApplication {
|
||||||
externalStorageDirectory = osmandSettings.getInternalAppPath();
|
externalStorageDirectory = osmandSettings.getInternalAppPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
AndroidUtils.deleteRecursive(this.getAppPath(IndexConstants.TEMP_DIR));
|
Algorithms.removeAllFiles(this.getAppPath(IndexConstants.TEMP_DIR));
|
||||||
|
|
||||||
checkPreferredLocale();
|
checkPreferredLocale();
|
||||||
appInitializer.onCreateApplication();
|
appInitializer.onCreateApplication();
|
||||||
|
|
Loading…
Reference in a new issue