diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java index c8acf5b1f8..9ebaf7a32a 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java @@ -1852,6 +1852,7 @@ public class OsmandAidlApi { public void loadConnectedApps() { try { + connectedApps.clear(); JSONArray array = new JSONArray(app.getSettings().API_CONNECTED_APPS_JSON.get()); for (int i = 0; i < array.length(); i++) { JSONObject obj = array.getJSONObject(i); diff --git a/OsmAnd/src/net/osmand/plus/OsmandPlugin.java b/OsmAnd/src/net/osmand/plus/OsmandPlugin.java index 4bd1eaa35b..410e3e6d12 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandPlugin.java +++ b/OsmAnd/src/net/osmand/plus/OsmandPlugin.java @@ -170,6 +170,22 @@ public abstract class OsmandPlugin { } } + public static void updateActivatedPlugins(OsmandApplication app, Set enabledPlugins) { + for (OsmandPlugin plugin : allPlugins) { + if (enabledPlugins.contains(plugin.getId())) { + try { + if (plugin.init(app, null)) { + plugin.setActive(true); + } + } catch (Exception e) { + LOG.error("Plugin initialization failed " + plugin.getId(), e); + } + } else if (plugin.isActive()) { + plugin.setActive(false); + } + } + } + private static void checkMarketPlugin(@NonNull OsmandApplication app, @NonNull Set enabledPlugins, @NonNull OsmandPlugin plugin, boolean paid, String id, String id2) { boolean marketEnabled = Version.isMarketEnabled(app); diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java index aeb39499ee..8622892543 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -370,7 +370,7 @@ public class OsmandSettings { OsmandAidlApi aidlApi = ctx.getAidlApi(); if (aidlApi != null) { aidlApi.loadConnectedApps(); - OsmandPlugin.initPlugins(ctx); + OsmandPlugin.updateActivatedPlugins(ctx, getEnabledPlugins()); } fireEvent(oldMode);