Skip to content

Commit

Permalink
Move Tvserver to examples (#11780)
Browse files Browse the repository at this point in the history
* move share lib and tv-common(zzz_generated/tv-app/zap-generated) link to example, so that we cloud have different android tv apps for different clusters

* make it buildable under example

* move CHIPTVServer to examples/tv-app/android

* fix runtime issue, force load jni before using AndroidChipPlatform

* change build_example.py for new app struct

* fix restyled-io and ci issues
  • Loading branch information
xylophone21 authored and pull[bot] committed Nov 25, 2021
1 parent 86eecd7 commit 1044094
Show file tree
Hide file tree
Showing 61 changed files with 432 additions and 127 deletions.
25 changes: 25 additions & 0 deletions examples/tv-app/android/.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright (c) 2020 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import("//build_overrides/build.gni")

# The location of the build configuration file.
buildconfig = "${build_root}/config/BUILDCONFIG.gn"

# CHIP uses angle bracket includes.
check_system_includes = true

default_args = {
import("//args.gni")
}
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions examples/tv-app/android/App/.idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
File renamed without changes.
30 changes: 30 additions & 0 deletions examples/tv-app/android/App/.idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,19 @@ android {
targetCompatibility JavaVersion.VERSION_1_8
}


sourceSets {
main {
jniLibs.srcDirs = ['libs/jniLibs']

// uncomment this code to debug
// java.srcDirs = [
// 'src/main/java',
// '../../third_party/connectedhomeip/src/setup_payload/java/src',
// '../../third_party/connectedhomeip/src/platform/android/java',
// '../../java/src',
// ]
}
}




}

dependencies {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import chip.setuppayload.DiscoveryCapability;
import chip.setuppayload.SetupPayload;
import chip.setuppayload.SetupPayloadParser;
import com.tcl.tvapp.TvApp;
import java.util.HashSet;

public class MainActivity extends AppCompatActivity {
Expand All @@ -30,7 +31,7 @@ protected void onCreate(Bundle savedInstanceState) {
mQrCodeImg = findViewById(R.id.qrCodeImg);
mQrCodeTxt = findViewById(R.id.qrCodeTxt);
mManualPairingCodeTxt = findViewById(R.id.manualPairingCodeTxt);
ChipAppServer chipAppServer = new ChipAppServer();
TvApp tvApp = new TvApp();
AndroidChipPlatform chipPlatform =
new AndroidChipPlatform(
new AndroidBleManager(),
Expand Down Expand Up @@ -63,6 +64,7 @@ protected void onCreate(Bundle savedInstanceState) {
e.printStackTrace();
}

ChipAppServer chipAppServer = new ChipAppServer();
chipAppServer.startApp();
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
49 changes: 47 additions & 2 deletions examples/tv-app/android/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@
import("//build_overrides/build.gni")
import("//build_overrides/chip.gni")

import("${build_root}/config/android_abi.gni")
import("${chip_root}/build/chip/java/rules.gni")
import("${chip_root}/build/chip/tools.gni")

# Todo: copy from examples/tv-app/linux but later will be moved to jni and upto java workd
source_set("android-tv-app") {
shared_library("jni") {
output_name = "libTvApp"

sources = [
"${chip_root}/examples/tv-app/tv-common/include/CHIPProjectAppConfig.h",
"include/account-login/AccountLoginManager.cpp",
Expand Down Expand Up @@ -49,13 +52,55 @@ source_set("android-tv-app") {
"include/tv-channel/TvChannelManager.h",
"include/wake-on-lan/WakeOnLanManager.cpp",
"include/wake-on-lan/WakeOnLanManager.h",
"java/TVApp-JNI.cpp",
]

deps = [
"${chip_root}/examples/tv-app/tv-common",
"${chip_root}/src/app/server/java:jni",
"${chip_root}/src/lib",
"${chip_root}/third_party/inipp",
]

cflags = [ "-Wconversion" ]

output_dir = "${root_out_dir}/lib/jni/${android_abi}"

ldflags = [ "-Wl,--gc-sections" ]
}

android_library("java") {
output_name = "TvApp.jar"

deps = [
":android",
"${chip_root}/third_party/android_deps:annotation",
]

data_deps = [
":jni",
"${chip_root}/build/chip/java:shared_cpplib",
]

sources = [ "java/src/com/tcl/tvapp/TvApp.java" ]

javac_flags = [ "-Xlint:deprecation" ]

# TODO: add classpath support (we likely need to add something like
# ..../platforms/android-21/android.jar to access BLE items)
}

java_prebuilt("android") {
jar_path = "${android_sdk_root}/platforms/android-21/android.jar"
}

group("default") {
deps = [
":android",
":java",
":jni",
"${chip_root}/src/app/server/java",
"${chip_root}/src/platform/android:java",
"${chip_root}/src/setup_payload/java",
]
}
27 changes: 27 additions & 0 deletions examples/tv-app/android/args.gni
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright (c) 2020 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import("//build_overrides/chip.gni")

import("${chip_root}/config/standalone/args.gni")

chip_device_project_config_include = "<CHIPProjectAppConfig.h>"
chip_project_config_include = "<CHIPProjectAppConfig.h>"
chip_system_project_config_include = "<SystemProjectConfig.h>"

chip_project_config_include_dirs =
[ "${chip_root}/examples/tv-app/tv-common/include" ]
chip_project_config_include_dirs += [ "${chip_root}/config/standalone" ]

chip_build_libshell = true
1 change: 1 addition & 0 deletions examples/tv-app/android/build_overrides
37 changes: 37 additions & 0 deletions examples/tv-app/android/java/TVApp-JNI.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2021 Project CHIP Authors
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

/**
* @file
* Implementation of JNI bridge for Tv App on Android.
*
*/
#include <app/server/java/AndroidAppServerWrapper.h>
#include <jni.h>
#include <lib/core/CHIPError.h>
#include <lib/support/CHIPJNIError.h>

jint JNI_OnLoad(JavaVM * jvm, void * reserved)
{
return AndroidAppServerJNI_OnLoad(jvm, reserved);
}

void JNI_OnUnload(JavaVM * jvm, void * reserved)
{
return AndroidAppServerJNI_OnUnload(jvm, reserved);
}
26 changes: 26 additions & 0 deletions examples/tv-app/android/java/src/com/tcl/tvapp/TvApp.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright (c) 2021 Project CHIP Authors
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.tcl.tvapp;

public class TvApp {
public TvApp() {}

static {
System.loadLibrary("TvApp");
}
}
1 change: 1 addition & 0 deletions examples/tv-app/android/third_party/connectedhomeip
Loading

0 comments on commit 1044094

Please sign in to comment.