mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-09-03 15:45:10 +00:00
Check plugin permissions before calling onCreate
Otherwise if we call something in onCreate for which we don't (yet) have permission we get a permission violation
This commit is contained in:
@@ -754,25 +754,16 @@ public class Device implements BaseLink.PacketReceiver {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean success;
|
|
||||||
try {
|
|
||||||
success = plugin.onCreate();
|
|
||||||
} catch (Exception e) {
|
|
||||||
success = false;
|
|
||||||
Log.e("KDE/addPlugin", "plugin failed to load " + pluginKey, e);
|
|
||||||
}
|
|
||||||
|
|
||||||
plugins.put(pluginKey, plugin);
|
plugins.put(pluginKey, plugin);
|
||||||
|
|
||||||
if (!plugin.checkRequiredPermissions()) {
|
if (!plugin.checkRequiredPermissions()) {
|
||||||
Log.e("KDE/addPlugin", "No permission " + pluginKey);
|
Log.e("KDE/addPlugin", "No permission " + pluginKey);
|
||||||
plugins.remove(pluginKey);
|
plugins.remove(pluginKey);
|
||||||
pluginsWithoutPermissions.put(pluginKey, plugin);
|
pluginsWithoutPermissions.put(pluginKey, plugin);
|
||||||
success = false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
Log.i("KDE/addPlugin", "Permissions OK " + pluginKey);
|
Log.i("KDE/addPlugin", "Permissions OK " + pluginKey);
|
||||||
pluginsWithoutPermissions.remove(pluginKey);
|
pluginsWithoutPermissions.remove(pluginKey);
|
||||||
|
|
||||||
if (plugin.checkOptionalPermissions()) {
|
if (plugin.checkOptionalPermissions()) {
|
||||||
Log.i("KDE/addPlugin", "Optional Permissions OK " + pluginKey);
|
Log.i("KDE/addPlugin", "Optional Permissions OK " + pluginKey);
|
||||||
pluginsWithoutOptionalPermissions.remove(pluginKey);
|
pluginsWithoutOptionalPermissions.remove(pluginKey);
|
||||||
@@ -782,7 +773,12 @@ public class Device implements BaseLink.PacketReceiver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return success;
|
try {
|
||||||
|
return plugin.onCreate();
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e("KDE/addPlugin", "plugin failed to load " + pluginKey, e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized boolean removePlugin(String pluginKey) {
|
private synchronized boolean removePlugin(String pluginKey) {
|
||||||
|
Reference in New Issue
Block a user