Skip to content

Commit

Permalink
Refactor tv android app into platfor-app(in preperation to add conten…
Browse files Browse the repository at this point in the history
…t-app) (#17378)

* Refactor tv android app into platfor-app(in preperation to add content-app) and refactor package names and other strings.

* Modify tesdata to include the new build targets
  • Loading branch information
amitnj authored and pull[bot] committed Jan 26, 2024
1 parent 2c670c0 commit 4552449
Show file tree
Hide file tree
Showing 41 changed files with 118 additions and 31 deletions.
2 changes: 1 addition & 1 deletion examples/tv-app/android/App/.idea/.name

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

2 changes: 1 addition & 1 deletion examples/tv-app/android/App/.idea/gradle.xml

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

11 changes: 11 additions & 0 deletions examples/tv-app/android/App/.idea/misc.xml

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

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ android {
compileSdk 30

defaultConfig {
applicationId "com.tcl.chip.chiptvserver"
applicationId "com.matter.tv.server"
minSdk 24
targetSdk 30
versionCode 1
Expand Down Expand Up @@ -39,7 +39,7 @@ android {

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

// uncomment this code to debug
// java.srcDirs = [
Expand All @@ -54,7 +54,7 @@ android {
}

dependencies {
implementation fileTree(dir: "libs", include: ["*.jar","*.so"])
implementation fileTree(dir: "../app/libs", include: ["*.jar","*.so"])
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.tcl.chip.chiptvserver;
package com.matter.tv.server;

import static org.junit.Assert.*;

Expand All @@ -19,6 +19,6 @@ public class ExampleInstrumentedTest {
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.tcl.chip.chiptvslave", appContext.getPackageName());
assertEquals("com.matter.tv.server", appContext.getPackageName());
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.tcl.chip.chiptvserver">
package="com.matter.tv.server">

<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
Expand All @@ -19,17 +19,17 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:name=".ChipTvServerApplication"
android:theme="@style/Theme.CHIPTVSlave">
<activity android:name=".MainActivity"
android:name="com.matter.tv.server.MatterTvServerApplication"
android:theme="@style/Theme.MatterTVSlave">
<activity android:name="com.matter.tv.server.MainActivity"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name=".service.MatterServantService" />
<service android:name="com.matter.tv.server.service.MatterServantService" />
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.tcl.chip.chiptvserver;
package com.matter.tv.server;

import android.graphics.Bitmap;
import android.os.Bundle;
Expand All @@ -10,7 +10,7 @@
import chip.setuppayload.DiscoveryCapability;
import chip.setuppayload.SetupPayload;
import chip.setuppayload.SetupPayloadParser;
import com.tcl.chip.chiptvserver.service.MatterServant;
import com.matter.tv.server.service.MatterServant;
import java.util.HashSet;

public class MainActivity extends AppCompatActivity {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.tcl.chip.chiptvserver;
package com.matter.tv.server;

import android.app.Application;
import android.content.Intent;
import android.os.Build;
import com.tcl.chip.chiptvserver.service.MatterServantService;
import com.matter.tv.server.service.MatterServantService;

public class ChipTvServerApplication extends Application {
public class MatterTvServerApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.tcl.chip.chiptvserver;
package com.matter.tv.server;

import android.graphics.Bitmap;
import android.graphics.Color;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*
*/
package com.tcl.chip.chiptvserver.service;
package com.matter.tv.server.service;

import android.content.Context;
import androidx.annotation.NonNull;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.tcl.chip.chiptvserver.service;
package com.matter.tv.server.service;

import android.app.Notification;
import android.app.NotificationChannel;
Expand All @@ -10,8 +10,8 @@
import android.os.IBinder;
import androidx.annotation.Nullable;
import androidx.core.app.NotificationCompat;
import com.tcl.chip.chiptvserver.MainActivity;
import com.tcl.chip.chiptvserver.R;
import com.matter.tv.server.MainActivity;
import com.matter.tv.server.R;

public class MatterServantService extends Service {
private static final String CHANNEL_ID = "Matter";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
tools:context="com.matter.tv.server.MainActivity">

<TextView
android:id="@+id/qrCodeTxt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.CHIPTVSlave" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<style name="Theme.MatterTVSlave" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_200</item>
<item name="colorPrimaryVariant">@color/purple_700</item>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<resources>
<string name="app_name">MatterTVServer</string>
</resources>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.CHIPTVSlave" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<style name="Theme.MatterTVSlave" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_500</item>
<item name="colorPrimaryVariant">@color/purple_700</item>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.tcl.chip.chiptvserver;
package com.matter.tv.server;

import static org.junit.Assert.*;

Expand Down
4 changes: 2 additions & 2 deletions examples/tv-app/android/App/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
rootProject.name = "CHIPTVServer"
include ':app'
rootProject.name = "MatterTVAndroid"
include ':platform-app'
2 changes: 2 additions & 0 deletions scripts/build/build/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,8 @@ def AndroidTargets():
yield target.Extend('androidstudio-x64-chip-tool', board=AndroidBoard.AndroidStudio_X64, app=AndroidApp.CHIP_TOOL)
yield target.Extend('arm64-chip-tvserver', board=AndroidBoard.ARM64, app=AndroidApp.CHIP_TVServer)
yield target.Extend('arm-chip-tvserver', board=AndroidBoard.ARM, app=AndroidApp.CHIP_TVServer)
yield target.Extend('x86-chip-tvserver', board=AndroidBoard.X86, app=AndroidApp.CHIP_TVServer)
yield target.Extend('x64-chip-tvserver', board=AndroidBoard.X64, app=AndroidApp.CHIP_TVServer)
yield target.Extend('arm64-chip-tv-casting-app', board=AndroidBoard.ARM64, app=AndroidApp.CHIP_TV_CASTING_APP)
yield target.Extend('arm-chip-tv-casting-app', board=AndroidBoard.ARM, app=AndroidApp.CHIP_TV_CASTING_APP)

Expand Down
2 changes: 2 additions & 0 deletions scripts/build/testdata/all_targets_except_host.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ android-arm64-chip-tool
android-arm64-chip-tv-casting-app
android-arm64-chip-tvserver
android-x64-chip-tool
android-x64-chip-tvserver
android-x86-chip-tool
android-x86-chip-tvserver
bl602-light
cc13x2x7_26x2x7-all-clusters
cc13x2x7_26x2x7-lock-ftd
Expand Down
70 changes: 70 additions & 0 deletions scripts/build/testdata/build_all_except_host.txt
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,36 @@ python3 build/chip/java/tests/generate_jars_for_test.py
# Setting up Android deps through Gradle
python3 third_party/android_deps/set_up_android_deps.py

# Generating android-x64-chip-tvserver
gn gen --check --fail-on-unused-args {out}/android-x64-chip-tvserver '--args=target_os="android" target_cpu="x64" android_ndk_root="TEST_ANDROID_NDK_HOME" android_sdk_root="TEST_ANDROID_HOME" chip_config_network_layer_ble=false ' --root={root}/examples/tv-app/android/

# Accepting NDK licenses @ tools
bash -c 'yes | TEST_ANDROID_HOME/tools/bin/sdkmanager --licenses >/dev/null'

# Generating JARs for Java build rules test
python3 build/chip/java/tests/generate_jars_for_test.py

# Setting up Android deps through Gradle
python3 third_party/android_deps/set_up_android_deps.py

# Generating android-x86-chip-tool
gn gen --check --fail-on-unused-args {out}/android-x86-chip-tool '--args=target_os="android" target_cpu="x86" android_ndk_root="TEST_ANDROID_NDK_HOME" android_sdk_root="TEST_ANDROID_HOME" '

# Accepting NDK licenses @ tools
bash -c 'yes | TEST_ANDROID_HOME/tools/bin/sdkmanager --licenses >/dev/null'

# Generating JARs for Java build rules test
python3 build/chip/java/tests/generate_jars_for_test.py

# Setting up Android deps through Gradle
python3 third_party/android_deps/set_up_android_deps.py

# Generating android-x86-chip-tvserver
gn gen --check --fail-on-unused-args {out}/android-x86-chip-tvserver '--args=target_os="android" target_cpu="x86" android_ndk_root="TEST_ANDROID_NDK_HOME" android_sdk_root="TEST_ANDROID_HOME" chip_config_network_layer_ble=false ' --root={root}/examples/tv-app/android/

# Accepting NDK licenses @ tools
bash -c 'yes | TEST_ANDROID_HOME/tools/bin/sdkmanager --licenses >/dev/null'

# Generating bl602-light
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/bouffalolab/bl602 '--args=bl602_board="BL-HWC-G1"' {out}/bl602-light

Expand Down Expand Up @@ -1141,6 +1165,29 @@ cp {out}/android-x64-chip-tool/lib/src/platform/android/AndroidPlatform.jar {roo
# Building APP android-x64-chip-tool
{root}/src/android/CHIPTool/gradlew -p {root}/src/android/CHIPTool -PmatterBuildSrcDir={out}/android-x64-chip-tool -PmatterSdkSourceBuild=false -PbuildDir={out}/android-x64-chip-tool assembleDebug

# Building JNI android-x64-chip-tvserver
ninja -C {out}/android-x64-chip-tvserver

# Prepare Native libs android-x64-chip-tvserver
mkdir -p {root}/examples/tv-app/android/App/app/libs/jniLibs/x86_64

cp {out}/android-x64-chip-tvserver/lib/jni/x86_64/libSetupPayloadParser.so {root}/examples/tv-app/android/App/app/libs/jniLibs/x86_64/libSetupPayloadParser.so

cp {out}/android-x64-chip-tvserver/lib/jni/x86_64/libc++_shared.so {root}/examples/tv-app/android/App/app/libs/jniLibs/x86_64/libc++_shared.so

cp {out}/android-x64-chip-tvserver/lib/jni/x86_64/libTvApp.so {root}/examples/tv-app/android/App/app/libs/jniLibs/x86_64/libTvApp.so

cp {out}/android-x64-chip-tvserver/lib/third_party/connectedhomeip/src/setup_payload/java/SetupPayloadParser.jar {root}/examples/tv-app/android/App/app/libs/SetupPayloadParser.jar

cp {out}/android-x64-chip-tvserver/lib/third_party/connectedhomeip/src/platform/android/AndroidPlatform.jar {root}/examples/tv-app/android/App/app/libs/AndroidPlatform.jar

cp {out}/android-x64-chip-tvserver/lib/third_party/connectedhomeip/src/app/server/java/CHIPAppServer.jar {root}/examples/tv-app/android/App/app/libs/CHIPAppServer.jar

cp {out}/android-x64-chip-tvserver/lib/TvApp.jar {root}/examples/tv-app/android/App/app/libs/TvApp.jar

# Building Example android-x64-chip-tvserver
{root}/examples/tv-app/android/App/gradlew -p {root}/examples/tv-app/android/App/ -PmatterBuildSrcDir={out}/android-x64-chip-tvserver -PmatterSdkSourceBuild=false -PbuildDir={out}/android-x64-chip-tvserver assembleDebug

# Building JNI android-x86-chip-tool
ninja -C {out}/android-x86-chip-tool

Expand All @@ -1162,6 +1209,29 @@ cp {out}/android-x86-chip-tool/lib/src/platform/android/AndroidPlatform.jar {roo
# Building APP android-x86-chip-tool
{root}/src/android/CHIPTool/gradlew -p {root}/src/android/CHIPTool -PmatterBuildSrcDir={out}/android-x86-chip-tool -PmatterSdkSourceBuild=false -PbuildDir={out}/android-x86-chip-tool assembleDebug

# Building JNI android-x86-chip-tvserver
ninja -C {out}/android-x86-chip-tvserver

# Prepare Native libs android-x86-chip-tvserver
mkdir -p {root}/examples/tv-app/android/App/app/libs/jniLibs/x86

cp {out}/android-x86-chip-tvserver/lib/jni/x86/libSetupPayloadParser.so {root}/examples/tv-app/android/App/app/libs/jniLibs/x86/libSetupPayloadParser.so

cp {out}/android-x86-chip-tvserver/lib/jni/x86/libc++_shared.so {root}/examples/tv-app/android/App/app/libs/jniLibs/x86/libc++_shared.so

cp {out}/android-x86-chip-tvserver/lib/jni/x86/libTvApp.so {root}/examples/tv-app/android/App/app/libs/jniLibs/x86/libTvApp.so

cp {out}/android-x86-chip-tvserver/lib/third_party/connectedhomeip/src/setup_payload/java/SetupPayloadParser.jar {root}/examples/tv-app/android/App/app/libs/SetupPayloadParser.jar

cp {out}/android-x86-chip-tvserver/lib/third_party/connectedhomeip/src/platform/android/AndroidPlatform.jar {root}/examples/tv-app/android/App/app/libs/AndroidPlatform.jar

cp {out}/android-x86-chip-tvserver/lib/third_party/connectedhomeip/src/app/server/java/CHIPAppServer.jar {root}/examples/tv-app/android/App/app/libs/CHIPAppServer.jar

cp {out}/android-x86-chip-tvserver/lib/TvApp.jar {root}/examples/tv-app/android/App/app/libs/TvApp.jar

# Building Example android-x86-chip-tvserver
{root}/examples/tv-app/android/App/gradlew -p {root}/examples/tv-app/android/App/ -PmatterBuildSrcDir={out}/android-x86-chip-tvserver -PmatterSdkSourceBuild=false -PbuildDir={out}/android-x86-chip-tvserver assembleDebug

# Building bl602-light
ninja -C {out}/bl602-light

Expand Down
2 changes: 2 additions & 0 deletions scripts/build/testdata/glob_star_targets_except_host.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ android-arm64-chip-tool
android-arm64-chip-tv-casting-app
android-arm64-chip-tvserver
android-x64-chip-tool
android-x64-chip-tvserver
android-x86-chip-tool
android-x86-chip-tvserver
bl602-light
cc13x2x7_26x2x7-all-clusters
cc13x2x7_26x2x7-lock-ftd
Expand Down

0 comments on commit 4552449

Please sign in to comment.