Build Controlpanel Service application for Android
- Controlpanel 서비스 빌드
- 준비사항
- AllJoyn Full Source
- Build tools and libraries
- Build
# cd services/base/controlpanel
# scons OS=android CPU=arm BINDINGS=core,cpp SERVICES=about,controlpanel BUILD_SERVICES_SAMPLES=off WS=off ANDROID_NDK=/data4/dsshin/Android/android-ndk-r9d ANDROID_SRC=/data4/dsshin/TCC_STB_JELLYBEAN/SDK_v13.05/ VARIANT=debug
- Contorlpanel controlee application 만들기
- xml 파일로 code 생성하기
- 참고: https://allseenalliance.org/docs-and-downloads/documentation/alljoyn-control-panel-service-framework-10-usage-guide-linux-cpp#unique_17
- SampleXMLs 밑에 샘플 xml 파일들 있으니 참고
- 아래와 같이 실행하면 지정한 디렉토리에 여러개 파일들이 생김
- 생성 된 파일들을 가져와서 Android binary application 으로 빌드 한다.
- Android.mk 생성
- 보면 stdc++ 까지 static 으로 넣어 버렸는데 이는 빌드 에러 때문에..
- generated 디렉토리에 자동으로 생성된 파일들이 모두 위치해 있고, provided 디렉토리에는 generated 에서 action 버튼이 눌려졌을때 호출 된 함수들을 정의해 놓았다.
- Build 하면된다.
- provided 에 있는 파일 내용
- 간단하다. 각각애 대해서 파워/볼륨 키 입력되도록 해버림~
# cd cpp/tools/CPSAppGenerator
# mkdir path_for_generated_files
# python generateCPSApp.py <XML file the generate code from> -p <destination path for generated files>
아래는 내 xml 파일
<?xml version="1.0"?>
<controlPanelDevice xmlns="http://www.alljoyn.org/controlpanel/gen">
<name>M370_Control</name>
<headerCode>#include "ControlPanelProvided.h"</headerCode>
<languageSet name="myLanguages">
<language>en</language>
</languageSet>
<controlPanels>
<controlPanel languageSet="myLanguages">
<rootContainer>
<name>rootContainer</name>
<secured>false</secured>
<enabled>true</enabled>
<bgcolor>0x1e90ff</bgcolor>
<hints>
<hint>vertical_linear</hint>
<hint>horizontal_linear</hint>
</hints>
<elements>
<container>
<name>powerControl</name>
<secured>false</secured>
<enabled>true</enabled>
<bgcolor>0x200</bgcolor>
<hints>
<hint>vertical_linear</hint>
</hints>
<elements>
<action>
<name>powerOnOff</name>
<onAction>
<executeCode>powerOnOff();</executeCode>
</onAction>
<secured>false</secured>
<enabled>true</enabled>
<label>
<value type="literal" language="en">Power</value>
</label>
<bgcolor>0x400</bgcolor>
<hints>
<hint>actionButton</hint>
</hints>
</action>
</elements>
</container>
<container>
<name>volumeControl</name>
<secured>false</secured>
<enabled>true</enabled>
<bgcolor>0x200</bgcolor>
<hints>
<hint>vertical_linear</hint>
</hints>
<elements>
<action>
<name>volumeUp</name>
<onAction>
<executeCode>volumeUp();</executeCode>
</onAction>
<secured>false</secured>
<enabled>true</enabled>
<label>
<value type="literal" language="en">Volume Up</value>
</label>
<bgcolor>0x400</bgcolor>
<hints>
<hint>actionButton</hint>
</hints>
</action>
<action>
<name>volumeDown</name>
<onAction>
<executeCode>volumeDown();</executeCode>
</onAction>
<secured>false</secured>
<enabled>true</enabled>
<label>
<value type="literal" language="en">Volume Down</value>
</label>
<bgcolor>0x400</bgcolor>
<hints>
<hint>actionButton</hint>
</hints>
</action>
</elements>
</container>
</elements>
</rootContainer>
</controlPanel>
</controlPanels>
</controlPanelDevice>
LOCAL_PATH:=$(call my-dir)
NDK_DIR = /Android/android-ndk-r9d/sources/cxx-stl/gnu-libstdc++/4.6
GEN_DIR = generated
PRO_DIR = provided
SAM_DIR = samples_common
include $(CLEAR_VARS)
# for static libs
LOCAL_PREBUILT_LIBS := \
lib/libajrouter.a \
lib/liballjoyn-daemon.a \
lib/liballjoyn.a \
lib/liballjoyn_controlpanel.a \
lib/libbbdaemon-lib.a \
lib/liballjoyn_about.a \
lib/liballjoyn_services_common.a \
lib/libbundledRouter.a \
lib/libgnustl_static.a \
lib/libstdc++.a
include $(BUILD_MULTI_PREBUILT)
include $(CLEAR_VARS)
include $(BUILD_PREBUILT)
include $(CLEAR_VARS)
# for binary build
LOCAL_MODULE := control_panel
LOCAL_CPP_EXTENSION := .cc
LOCAL_CFLAGS := -Wall -Wno-psabi -Wno-write-strings -DANDROID_NDK -DTARGET_ANDROID -DLINUX -DQCC_OS_GROUP_POSIX -DQCC_OS_ANDROID -DQCC_CPU_ARM -DANDROID
LOCAL_SRC_FILES := \
main_ControlPanel.cc
LOCAL_SRC_FILES += \
$(GEN_DIR)/ControlPanelGenerated.cc \
$(GEN_DIR)/M370_ControlPowerOnOff.cc \
$(GEN_DIR)/M370_ControlVolumeDown.cc \
$(GEN_DIR)/M370_ControlVolumeUp.cc
LOCAL_SRC_FILES += \
$(PRO_DIR)/ControlPanelProvided.cc
LOCAL_SRC_FILES += \
$(SAM_DIR)/AnnounceHandlerImpl.cc \
$(SAM_DIR)/AsyncSessionJoiner.cc \
$(SAM_DIR)/CommonBusListener.cc \
$(SAM_DIR)/CommonSampleUtil.cc \
$(SAM_DIR)/IniParser.cc \
$(SAM_DIR)/PropertyStoreImpl.cc \
$(SAM_DIR)/SessionListenerImpl.cc \
$(SAM_DIR)/SrpKeyXListener.cc
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/inc \
$(LOCAL_PATH)/innopia_M370_generated \
$(LOCAL_PATH)/innopia_M370_provided \
$(LOCAL_PATH)/samples_common \
$(NDK_DIR)/include \
$(NDK_DIR)/libs/armeabi/include
LOCAL_STATIC_LIBRARIES := libajrouter liballjoyn-daemon liballjoyn liballjoyn_controlpanel libbbdaemon-lib liballjoyn_about liballjoyn_services_common libbundledRouter \
libgnustl_static libstdc++
LOCAL_SHARED_LIBRARIES := libcrypto libssl
include $(BUILD_EXECUTABLE)
#include <stdlib.h>
#include "ControlPanelProvided.h"
void powerOnOff() {
printf("powerOff called!!\n");
system("input keyevent 26");
}
void volumeUp() {
printf("volumeUp called!!\n");
system("input keyevent 24");
}
void volumeDown() {
printf("volumeDown called!!\n");
system("input keyevent 25");
}