Well, presumably that means you'll have some code like this in 
SystemServer.java somewhere, in order for the service to be created and 
registered inside system_server:

MyCustomService newService = new MyCustomService();
ServiceManager.addService("custom_service", newService);


In order for the framework build to compile, you will need to provide the 
code for that new class in a library somewhere. You could create a prebuilt 
module for the JAR file with a separate Android.mk like so:

LOCAL_PATH := $(my-dir) 
include $(CLEAR_VARS) 

LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := libprivate:private-service-lib.jar

include $(BUILD_MULTI_PREBUILT)


…then take that library name and add it to frameworks/base/Android.mk 
somewhere:

LOCAL_STATIC_JAVA_LIBRARIES := libprivate

You might have to tweak some, but that's the general idea.

Cheers,
Dave Smith, PE
@devunwired

On Tuesday, May 3, 2016 at 9:25:04 AM UTC-6, Andre Zuban wrote:
>
> It's the former. It's OK to include some registration code in the source 
> our partner uses to do the build. Do you know any details on how to include 
> the JAR in their build?
>
> Andre
>
> On Monday, May 2, 2016 at 10:25:45 AM UTC-4, Dave Smith wrote:
>>
>> Andre -
>>
>> How did you plan to integrate the system service at runtime? Are you 
>> injecting the code into system_server, or are you packaging the result 
>> into a separate application process (a la the pattern used by the Bluetooth 
>> and NFC services)? If the latter, the issue should be fairly 
>> straightforward as you can just provide the APK and the final build can 
>> include it using BUILD_PREBUILT. This is generally my preferred approach 
>> to adding system services.
>>
>> If the former, that may be more difficult as there isn't a clean 
>> separation between the code you are adding and the framework code that you 
>> change. In this case, at least some of the code to register the service may 
>> be need to be in the sources, while the service implementation itself could 
>> be a JAR listed as a dependency in the makefile of framework core.
>>
>> Cheers,
>> Dave Smith, PE
>> @devunwired
>>
>> On 29 Apr 2016, at 17:18, Andre Zuban wrote:
>>
>> Hello!
>>
>> I know how to add another Android system service to the platform build
>> when I do the final builds, but in a situation when some partners do
>> the actual builds and produce the final FW I need to give them the
>> service in a prebuilt form (I guess as a jar file) to be included into
>> their platform build because I cannot give them the sources (for
>> intellectual property reasons). How can I do that? I guess this should
>> be easily achievable.
>>
>> Thanks,
>> Andre
>>
>> -- 
>> -- 
>> You received this message because you are subscribed to the "Android 
>> Building" mailing list.
>> To post to this group, send email to [email protected]
>> To unsubscribe from this group, send email to
>> [email protected]
>> For more options, visit this group at
>> http://groups.google.com/group/android-building?hl=en
>> ------------------------------
>>
>> You received this message because you are subscribed to the Google Groups 
>> "Android Building" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected].
>> For more options, visit https://groups.google.com/d/optout.
>>
>>

-- 
-- 
You received this message because you are subscribed to the "Android Building" 
mailing list.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-building?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"Android Building" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to