if (Boolean.getBoolean(PROP_FORCED_RESTART)) {  Bundle systemBundle = context.getBundle(0); int i = 0; while (i < 5000 && (systemBundle.getState() & (Bundle.ACTIVE | Bundle.STOPPING)) != 0) { i += 200; try { Thread.sleep(200); } catch (InterruptedException e) { break; } } }
	private static void refreshPackages(Bundle[] bundles) {		ServiceReference packageAdminRef = context.getServiceReference(PackageAdmin.class.getName());		PackageAdmin packageAdmin = null;		if (packageAdminRef != null) {			packageAdmin = (PackageAdmin) context.getService(packageAdminRef);			if (packageAdmin == null)				return;		}		// TODO this is such a hack it is silly.  There are still cases for race conditions etc		// but this should allow for some progress...		final Semaphore semaphore = new Semaphore(0);		FrameworkListener listener = new FrameworkListener() {			public void frameworkEvent(FrameworkEvent event) {				if (event.getType() == FrameworkEvent.PACKAGES_REFRESHED)					semaphore.release();			}		};		context.addFrameworkListener(listener);		packageAdmin.refreshPackages(bundles);		semaphore.acquire();		context.removeFrameworkListener(listener);		context.ungetService(packageAdminRef);	}