So I had created a new Service and added to AOSP. The service runs fine when being called from apps. But I want to call few methods of the service from inside the framework code (Source/frameworks/base/core/java/android/content/pm/PackageParser.java).
Is there a special way I need to call create the instance for the service in order for it to be used inside the frameworks.
ITestService om = ITestService.Stub.asInterface(ServiceManager.getService("Test"));
The above is the way I make an instance to the service inside the PackageParser.java, (the same worked fine when I tried to access it from an app).
The below is the snippet of errors I got from logcat:
***********************************************
F/SystemServer( 500): BOOT FAILURE starting Input Manager Service
F/SystemServer( 500): java.lang.RuntimeException: Unable to get provider com.android.providers.settings.SettingsProvider: java.lang.ClassNotFoundException: com.android.providers.settings.SettingsProvider
F/SystemServer( 500): at android.app.ActivityThread.installProvider(ActivityThread.java:4201)
F/SystemServer( 500): at android.app.ActivityThread.getProvider(ActivityThread.java:4010)
F/SystemServer( 500): at android.app.ActivityThread.acquireProvider(ActivityThread.java:4026)
F/SystemServer( 500): at android.app.ContextImpl$ApplicationContentResolver.acquireProvider(ContextImpl.java:1612)
F/SystemServer( 500): at android.content.ContentResolver.acquireProvider(ContentResolver.java:948)
F/SystemServer( 500): at android.provider.Settings$NameValueCache.getString(Settings.java:701)
F/SystemServer( 500): at android.provider.Settings$Secure.getString(Settings.java:2207)
F/SystemServer( 500): at com.android.server.InputMethodManagerService.buildInputMethodListLocked(InputMethodManagerService.java:1966)
F/SystemServer( 500): at com.android.server.InputMethodManagerService.(InputMethodManagerService.java:556)
F/SystemServer( 500): at com.android.server.ServerThread.run(SystemServer.java:273)
F/SystemServer( 500): Caused by: java.lang.ClassNotFoundException: com.android.providers.settings.SettingsProvider
F/SystemServer( 500): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
F/SystemServer( 500): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
F/SystemServer( 500): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
F/SystemServer( 500): at android.app.ActivityThread.installProvider(ActivityThread.java:4186)
F/SystemServer( 500): ... 9 more
I/SystemServer( 500): Accessibility Manager
W/SystemServer( 500): ***********************************************
F/SystemServer( 500): BOOT FAILURE making display ready
Just before this error I was able to see the success log message saying my service has been started.
I just commented one line which makes instance to my service in PackageParser.java, and the code seemed to work creating the system.img
Any inputs on this problem could help me a lot.
Thank you in advance.
This was because of the dex opt signature mismatch for SettingsProvider.apk For testing purposes I was able to get around this issue by disabling this check achieved by setting the below env variables:
export WITH_DEXPREOPT=false
export DISABLE_DEXPREOPT=true
Courtesy: https://groups.google.com/forum/#!msg/android-building/vJCkg8Yq9Ic/mgev8ODDia4J