how to start the HAL service, only after specific android HAL service - hal

Could you please let me know how to start the HAL service, only after specific android HAL service is available.
Like adding requires or after is systemd service files in linux

suppose there are 2 HALs A and B. And you want to wait for HAL B to run HAL A then you can add different class name in their own .rc files like
service A /vendor/bin/HAL_A
class hal_a
service B /vendor/bin/HAL_B
class hal_b
After the files system is mounted by "on fs" trigger you can start the HAL B by using
class_start "<\class_name>" in your case class name will be hal_b
class_start "<\class_name>" in your case class name will be hal_a
Place a while loop in hal_a before hal_a itself register with hwservicemanager and check the hal_b using getservice() method of hwservicemanager one you get the binder interface then start hal_a and add it to hwservice manager.

Related

SecurityManager deprecation and reflection with suppressAccessChecks

I'm an university lecturer and I'm revising my lecture on Java reflection.
Other years when teaching about the horrors of suppressAccessChecks I was showing
that you could set up a SecurityManager and do something like
if ("suppressAccessChecks".equals(p.getName())){
StackTraceElement[] st = Thread.currentThread().getStackTrace();
if(.. st ..) { throw new SecurityException(); }
}
In this way you can allow for whitelisted deserializers only to call suppressAccessChecks.
However, now they are deprecating the SecurityManager.
I think the new module system is supposed to help here, but I'm failing to find resources explaining how to support the idea of the whitelisted deserializers above.
Any hint?
With Java modules, setAccessible is already restricted, even without a security manager:
This method may be used by a caller in class C to enable access to a member of declaring class D if any of the following hold:
C and D are in the same module.
The member is public and D is public in a package that the module containing D exports to at least the module containing C.
The member is protected static, D is public in a package that the module containing D exports to at least the module containing C, and C is a subclass of D.
D is in a package that the module containing D opens to at least the module containing C. All packages in unnamed and open modules are open to all modules and so this method always succeeds when D is in an unnamed or open module.
If we assume a typical scenario of a module M using a persistence service in module P and the members are not accessible anyway, only the last bullet applies; M must open the package(s) to P to enable the access override.
This can be done via a qualified opens directive
module M {
opens aPackage.needing.persistence to P;
}
This way, only the explicitly specified module(s), i.e. P, can use setAccessible for members of types in aPackage.needing.persistence.
In case of the HotSpot JVM, there’s the option --add-opens allowing to add qualified opens relationships at startup, in addition to declared ones, but there is no option for a module of an already running application to create such a relationship at runtime to gain additional access rights itself (unless the security is already subverted). It’s imaginable that other environments do not even support such a startup option.
It’s worth mentioning that there are still some new restrictions which can’t be circumvented this way. As also mentioned in setAccessible’s documentation:
This method cannot be used to enable write access to a non-modifiable final field. The following fields are non-modifiable:
static final fields declared in any class or interface
final fields declared in a hidden class
final fields declared in a record
See also this answer
In other words, in case of a record type, the persistence service still must use the constructor to deserialize an instance, even when suppressing access checks.

Can the ConfigurationAPI in Liferay DXP be used for Plugin sdk portlet?

I have followed given 2 tutorials to use COnfigurationAPI in a Liferay dxp plugins SDK portlet built using Ant/Ivy.
COnfiguration API 1
COnfiguration API 2.
Below is the configuration class used:
package com.preferences.interfaces;
import com.liferay.portal.configuration.metatype.annotations.ExtendedObjectClassDefinition;
import aQute.bnd.annotation.metatype.Meta;
#ExtendedObjectClassDefinition(
category = "preferences",
scope = ExtendedObjectClassDefinition.Scope.GROUP
)
#Meta.OCD(
id = "com.preferences.interfaces.UnsupportedBrowserGroupServiceConfiguration",
name = "UnsupportedBrowser.group.service.configuration.name"
)
public interface UnsupportedBrowserGroupServiceConfiguration {
#Meta.AD(deflt = "", required = false)
public String displayStyle();
#Meta.AD(deflt = "0", required = false)
public long displayStyleGroupId(long defaultDisplayStyleGroupId);
}
Post following the steps,I am getting the below error:
ERROR [CM Configuration Updater (ManagedService Update: pid=[com.preferences.interfaces.UnsupportedBrowserGroupServiceConfiguration])][org_apache_felix_configadmin:97] [org.osgi.service.cm.ManagedService, id=7082, bundle=297//com.liferay.portal.configuration.settings-2.0.15.jar?lpkgPath=C:\dev\Liferay\osgi\marketplace\Liferay Foundation.lpkg]: Unexpected problem updating configuration com.preferences.interfaces.UnsupportedBrowserGroupServiceConfiguration {org.osgi.service.cm.ConfigurationAdmin}={service.vendor=Apache Software Foundation, service.pid=org.apache.felix.cm.ConfigurationAdmin, service.description=Configuration Admin Service Specification 1.2 Implementation, service.id=56, service.bundleid=643, service.scope=bundle}
Caused by: java.lang.IllegalArgumentException: wrong number of arguments
So,does this process need a osgi module as mandatory or can we do it using plusings sdk portlet built using ant as well?
Without disecting the error message Caused by: java.lang.IllegalArgumentException: wrong number of arguments:
The way you build your plugin (Ant, Maven, Gradle, manually) doesn't make a difference, as long as you build a plugin that will be understood by the runtime. aQute.bnd.annotation.metatype.Meta points firmly into the OSGi world, and makes it almost certain that you'll need an OSGi module. You can build this with Ant, of course. Even in Ant you can embed tools like bnd, or you can write the proper Manifest.mf to include in your module manually (just kidding - you don't want to do it manually, but it would work).
Recommendation: Instead of moving everything over: Try to reproduce this with a minimal example in gradle or better Liferay Workspace (which is gradle based), just to get all the automatic wiring in. Check if it makes a difference and compare the generated output from your Ant build process with the workspace output. Pay specific attention to the Manifest.
In order to build the proper Manifest, you want to use bnd - if the Manifest turns out to be your issue: Find a way to embrace bnd - if that's by saying goodby to Ant, or by tweaking your build script remains your decision.

Know intended RestController in Spring implementation of ResponseBodyAdvice

The Spring ResponseBodyAdvice allows for handling the JSON-Response. I want to write it to the logger but by this would also like to add the name of the RestController being invoked in this transaction.
Can anyone tell, whether the classname is somewhere available in the parameters of the instance of ResponseBodyAdvice.
Got it. The parameter "MethodParameter" supplied to the "beforeBodyWrite"-method contains the attribute "containingClass" which provides the name of the intended Controller (I found this with testing - did not find any docs about the use of this attribute until now). That will do for me

Accessing REST api from Windows CE

I have one Windows Handheld device application which has the requirement of accessing a REST API. The REST API gives me JSON output which I am going to handle via Newton.JSON. Now to achieve modular structure I want to have the communication to the REST API be handled via a different module altogether something like a Class Library. But unfortunately it seems that it is not possible to do so via a class library(or maybe possible). So my question is what is the best alternative to do so?
Please note that I don't want to include those connectivity operations in my front end application project. And I am using .Net framework 3.5 & Windows Mobile SDK 6.0
Thanks in advance
Pseudo class library code:
public function void startQuery() //starts a thread that does the JSON query
//inside thread on query result use OnDone() delegate
private delegate void OnDone(string dateTimeString);
//In main GUI code add a reference to the class lib and init a new object then add an event handler to the OnDone delegate of the class lib
JSONClassLib myJson=new JSONClassLib();
...
myJson.OnDone+=new EventHandler(myEventHandler);
void myEventHandler(sender this, objext o){
//will be called when query is done
}
//you need to use Control.Invoke if you want to update the GUI from myEventHandler
//to start a query use something like this from your class lib
myJson.doQuery(string);
If you add your existing code we may help with creating a class lib and async code
Now I got my answer. Sorry I did a mistake while selecting the project type. I selected "Windows Form Class Library" project instead of "Smart Device Class Library" project. Now that I have selected the right one it is working fine for me.
BTW thanks for those responses.
Cheers

Pass proxy to loaded module in a PureMVC MultiCore app?

I'm creating a flash campaign which will be loaded into a client's framework, which I have no control over. The framework will already have loaded a few things such as locale, fonts and copy, and will pass these things to my swf upon initialization.
Since the size of my swf (let's call it the shell) is restricted it will in turn display a campaign-specific preloader and then load another swf (let's call this the campaign) with the rest of the site.
The shell and the campaign will both be PureMVC modules. The shell will create a few proxies and populate these with data passed from the framework (locale constants, fonts etc), before loading in the campaign.
When the campaign is loaded it too will need locale and fonts etc. so my question is, what is the best way to pass this data along to the campaign module from the shell module?
I could create the same proxies in the campaign module and load the data again, which will be cached, but this obviously feels like the wrong way to go.
I've investigated the use of the pipes utility but this seems like a bit of an overkill in my case since the communication will be one-way and will just happen once during the initialization of the campaign.
Would it be "ok" from a design pattern point of view to pass the proxies to an init method of the campaign module and then register these proxies in the campaign module startup command? This seems wrong since these proxies have references to my shell application facade through notification names. Would it be ok if I move the notification names to some "NotificationConstants" class which both modules can use?
I could create similar proxies in the campaign module but this time populate them with the data objects from my old proxies passed to the previously mentioned init method? Spontaneously this feels like the best way to do it since the data objects don't have any references to my shell module but the "old" proxies do..
The solution I usually use is to create an interface:
interface Campaign {
function set campaignDetails(value:CampaignDetails):void;
//...
}
The campaign-module should implement this interface - in the implementation I recommend you to use a different proxy in the module, so that you would avoid having duplicated notifications and references.
When the shell is ready with the loading of the module it just has to:
if (module is Campaign)
{
(module as Campaign).campaignDetails = ...;
}
I'm sure I'm telling you nothing new. You just need to make sure to keep the acquaintance between the shell and the module only on an interface level. Then you just pass the data and leave the module MVC core to deal with it independently from the shell.