mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-31 14:15:14 +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;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
if (!plugin.checkRequiredPermissions()) {
|
||||
Log.e("KDE/addPlugin", "No permission " + pluginKey);
|
||||
plugins.remove(pluginKey);
|
||||
pluginsWithoutPermissions.put(pluginKey, plugin);
|
||||
success = false;
|
||||
return false;
|
||||
} else {
|
||||
Log.i("KDE/addPlugin", "Permissions OK " + pluginKey);
|
||||
pluginsWithoutPermissions.remove(pluginKey);
|
||||
|
||||
if (plugin.checkOptionalPermissions()) {
|
||||
Log.i("KDE/addPlugin", "Optional Permissions OK " + 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) {
|
||||
|
Reference in New Issue
Block a user