From a3320ef3abb497def8ee85bb262dc397e5e5a11c Mon Sep 17 00:00:00 2001
From: "Jason P. Leasure"
Date: Thu, 25 Jun 2020 13:37:46 -0400
Subject: [PATCH] clean up OSGi state reporting and help page
---
.../topics/BundleManager/BundleManager.htm | 12 ++++++++--
.../app/plugin/core/osgi/BundleHost.java | 23 +++++++++----------
.../core/osgi/BundleStatusTableModel.java | 6 ++---
3 files changed, 24 insertions(+), 17 deletions(-)
diff --git a/Ghidra/Features/Base/src/main/help/help/topics/BundleManager/BundleManager.htm b/Ghidra/Features/Base/src/main/help/help/topics/BundleManager/BundleManager.htm
index c39ad2d2a5..51b94f217f 100644
--- a/Ghidra/Features/Base/src/main/help/help/topics/BundleManager/BundleManager.htm
+++ b/Ghidra/Features/Base/src/main/help/help/topics/BundleManager/BundleManager.htm
@@ -162,8 +162,16 @@
active - the bundle is built and classes within
can be loaded
-
- The normally hidden column "OSGi State" is also available.
+
+ The normally hidden column "OSGi State" is also available. In addition to the Bundle
+ state, this column will report
+
+ - (DISABLED) - if the bundle is disabled
+
- (ENABLED) - if the bundle is enabled, but the bundle manager has no handle to it.
+ If this state persists, there is likely an internal error
+
- (UNINSTALLED) - if the bundle is enabled, but the framework has released its handle.
+ This is typical for an inactive bundle
+
Adding and removing bundles from the manager
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleHost.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleHost.java
index 6bdf8a0668..9090cc431e 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleHost.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleHost.java
@@ -193,14 +193,14 @@ public class BundleHost {
public Collection add(List bundleFiles, boolean enabled,
boolean systemBundle) {
Map newBundleMap = bundleFiles.stream()
- .collect(Collectors.toUnmodifiableMap(Function.identity(),
- bundleFile -> createGhidraBundle(BundleHost.this, bundleFile, enabled,
- systemBundle)));
+ .collect(Collectors.toUnmodifiableMap(Function.identity(),
+ bundleFile -> createGhidraBundle(BundleHost.this, bundleFile, enabled,
+ systemBundle)));
fileToBundleMap.putAll(newBundleMap);
bundleLocationToBundleMap.putAll(newBundleMap.values()
- .stream()
- .collect(Collectors.toUnmodifiableMap(GhidraBundle::getLocationIdentifier,
- Function.identity())));
+ .stream()
+ .collect(Collectors.toUnmodifiableMap(GhidraBundle::getLocationIdentifier,
+ Function.identity())));
Collection newBundles = newBundleMap.values();
fireBundlesAdded(newBundles);
return newBundles;
@@ -482,7 +482,7 @@ public class BundleHost {
}
frameworkBundleContext
- .addBundleListener(new MyBundleListener(frameworkBundleContext.getBundle()));
+ .addBundleListener(new MyBundleListener(frameworkBundleContext.getBundle()));
try {
felixFramework.start();
@@ -659,8 +659,8 @@ public class BundleHost {
monitor.setMaximum(bundlesRemaining.size());
while (!bundlesRemaining.isEmpty() && !monitor.isCancelled()) {
List resolvableBundles = bundlesRemaining.stream()
- .filter(bundle -> canResolveAll(bundle.getAllRequirements()))
- .collect(Collectors.toList());
+ .filter(bundle -> canResolveAll(bundle.getAllRequirements()))
+ .collect(Collectors.toList());
if (resolvableBundles.isEmpty()) {
// final round, try everything we couldn't resolve to generate errors
resolvableBundles = bundlesRemaining;
@@ -881,7 +881,8 @@ public class BundleHost {
String.format("not a GhidraBundle: %s\n", osgiBundle.getLocation()));
}
break;
- case BundleEvent.UNINSTALLED:
+ // force "inactive" updates for all other states
+ default:
bundle = bundleLocationToBundleMap.get(osgiBundle.getLocation());
if (bundle != null) {
fireBundleActivationChange(bundle, false);
@@ -891,8 +892,6 @@ public class BundleHost {
String.format("not a GhidraBundle: %s\n", osgiBundle.getLocation()));
}
break;
- default:
- break;
}
}
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleStatusTableModel.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleStatusTableModel.java
index b3ed9433b2..b72e2b6b2d 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleStatusTableModel.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleStatusTableModel.java
@@ -411,7 +411,7 @@ public class BundleStatusTableModel
public String getValue(BundleStatus status, Settings settings, List data,
ServiceProvider serviceProvider0) throws IllegalArgumentException {
if (!status.isEnabled()) {
- return "(disabled)";
+ return "(DISABLED)";
}
GhidraBundle bundle = bundleHost.getExistingGhidraBundle(status.getFile());
if (bundle != null) {
@@ -419,9 +419,9 @@ public class BundleStatusTableModel
if (osgiBundle != null) {
return OSGiUtils.getStateString(osgiBundle);
}
- return "uninstalled";
+ return "(UNINSTALLED)";
}
- return "(enabled)";
+ return "(ENABLED)";
}
@Override