Skip to content

Commit

Permalink
Wakeonlan and media input cluster to android (#12142)
Browse files Browse the repository at this point in the history
* added WakeOnLanManager into java

* added MediaInputManager into java

* fix GetCurrentInput encode error

* Restyled by whitespace

* Restyled by google-java-format

* Restyled by clang-format

* Restyled by gn

* fix rebase issue

Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Feb 7, 2022
1 parent c2990e8 commit d88e7c9
Show file tree
Hide file tree
Showing 19 changed files with 765 additions and 258 deletions.
2 changes: 1 addition & 1 deletion examples/tv-app/android/App/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ android {
// 'src/main/java',
// '../../third_party/connectedhomeip/src/setup_payload/java/src',
// '../../third_party/connectedhomeip/src/platform/android/java',
// '../../third_party/connectedhomeip/src/app/server/java/src/',
// '../../java/src',
// ]
}
Expand All @@ -57,7 +58,6 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
implementation files('libs/AndroidPlatform.jar')
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
import chip.setuppayload.SetupPayload;
import chip.setuppayload.SetupPayloadParser;
import com.tcl.chip.tvapp.KeypadInputManagerStub;
import com.tcl.chip.tvapp.MediaInputManagerStub;
import com.tcl.chip.tvapp.TvApp;
import com.tcl.chip.tvapp.WakeOnLanManagerStub;
import java.util.HashSet;

public class MainActivity extends AppCompatActivity {
Expand All @@ -34,6 +36,8 @@ protected void onCreate(Bundle savedInstanceState) {
mManualPairingCodeTxt = findViewById(R.id.manualPairingCodeTxt);
TvApp tvApp = new TvApp();
tvApp.setKeypadInputManager(new KeypadInputManagerStub());
tvApp.setWakeOnLanManager(new WakeOnLanManagerStub());
tvApp.setMediaInputManager(new MediaInputManagerStub());

AndroidChipPlatform chipPlatform =
new AndroidChipPlatform(
Expand Down
13 changes: 9 additions & 4 deletions examples/tv-app/android/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,19 @@ shared_library("jni") {
"include/endpoint-configuration/EndpointConfigurationStorage.h",
"include/low-power/LowPowerManager.cpp",
"include/low-power/LowPowerManager.h",
"include/media-input/MediaInputManager.cpp",
"include/media-input/MediaInputManager.h",
"include/media-playback/MediaPlaybackManager.cpp",
"include/media-playback/MediaPlaybackManager.h",
"include/target-navigator/TargetNavigatorManager.cpp",
"include/target-navigator/TargetNavigatorManager.h",
"include/tv-channel/TvChannelManager.cpp",
"include/tv-channel/TvChannelManager.h",
"include/wake-on-lan/WakeOnLanManager.cpp",
"include/wake-on-lan/WakeOnLanManager.h",
"java/KeypadInputManager.cpp",
"java/KeypadInputManager.h",
"java/MediaInputManager.cpp",
"java/MediaInputManager.h",
"java/TVApp-JNI.cpp",
"java/WakeOnLanManager.cpp",
"java/WakeOnLanManager.h",
]

deps = [
Expand Down Expand Up @@ -85,7 +85,12 @@ android_library("java") {
sources = [
"java/src/com/tcl/chip/tvapp/KeypadInputManager.java",
"java/src/com/tcl/chip/tvapp/KeypadInputManagerStub.java",
"java/src/com/tcl/chip/tvapp/MediaInputInfo.java",
"java/src/com/tcl/chip/tvapp/MediaInputManager.java",
"java/src/com/tcl/chip/tvapp/MediaInputManagerStub.java",
"java/src/com/tcl/chip/tvapp/TvApp.java",
"java/src/com/tcl/chip/tvapp/WakeOnLanManager.java",
"java/src/com/tcl/chip/tvapp/WakeOnLanManagerStub.java",
]

javac_flags = [ "-Xlint:deprecation" ]
Expand Down
55 changes: 0 additions & 55 deletions examples/tv-app/android/include/cluster-init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@
#include "application-launcher/ApplicationLauncherManager.h"
#include "audio-output/AudioOutputManager.h"
#include "content-launcher/ContentLauncherManager.h"
#include "media-input/MediaInputManager.h"
#include "target-navigator/TargetNavigatorManager.h"
#include "tv-channel/TvChannelManager.h"
#include "wake-on-lan/WakeOnLanManager.h"

#include <app-common/zap-generated/attribute-id.h>
#include <app-common/zap-generated/cluster-id.h>
Expand Down Expand Up @@ -80,32 +78,6 @@ void emberAfApplicationBasicClusterInitCallback(chip::EndpointId endpoint)
}
}

/** @brief Wake On LAN Cluster Init
*
* This function is called when a specific cluster is initialized. It gives the
* application an opportunity to take care of cluster initialization procedures.
* It is called exactly once for each endpoint where cluster is present.
*
* @param endpoint Ver.: always
*
*/
void emberAfWakeOnLanClusterInitCallback(chip::EndpointId endpoint)
{
CHIP_ERROR err = CHIP_NO_ERROR;
WakeOnLanManager & wolManager = WakeOnLanManager::GetInstance();
err = wolManager.Init();
if (CHIP_NO_ERROR == err)
{
char macAddress[32] = "";
wolManager.setMacAddress(endpoint, macAddress);
wolManager.store(endpoint, macAddress);
}
else
{
ChipLogError(Zcl, "Failed to store mac address for endpoint: %d. Error:%s", endpoint, chip::ErrorStr(err));
}
}

namespace {

TvAttrAccess<TvChannelManager, app::Clusters::TvChannel::Attributes::TvChannelList::TypeInfo,
Expand Down Expand Up @@ -236,33 +208,6 @@ void emberAfContentLauncherClusterInitCallback(EndpointId endpoint)

namespace {

TvAttrAccess<MediaInputManager, app::Clusters::MediaInput::Attributes::MediaInputList::TypeInfo,
&MediaInputManager::proxyGetInputList>
gMediaInputAttrAccess;

} // anonymous namespace

/** @brief Media Input Cluster Init
*
* This function is called when a specific cluster is initialized. It gives the
* application an opportunity to take care of cluster initialization procedures.
* It is called exactly once for each endpoint where cluster is present.
*
* @param endpoint Ver.: always
*
*/
void emberAfMediaInputClusterInitCallback(EndpointId endpoint)
{
static bool attrAccessRegistered = false;
if (!attrAccessRegistered)
{
registerAttributeAccessOverride(&gMediaInputAttrAccess);
attrAccessRegistered = true;
}
}

namespace {

TvAttrAccess<TargetNavigatorManager, app::Clusters::TargetNavigator::Attributes::TargetNavigatorList::TypeInfo,
&TargetNavigatorManager::proxyGetTargetInfoList>
gTargetNavigatorAttrAccess;
Expand Down
80 changes: 0 additions & 80 deletions examples/tv-app/android/include/media-input/MediaInputManager.cpp

This file was deleted.

32 changes: 0 additions & 32 deletions examples/tv-app/android/include/media-input/MediaInputManager.h

This file was deleted.

73 changes: 0 additions & 73 deletions examples/tv-app/android/include/wake-on-lan/WakeOnLanManager.cpp

This file was deleted.

Loading

0 comments on commit d88e7c9

Please sign in to comment.