Device Control UI BizBundle

Last Updated on : 2024-06-24 08:30:46download

Device Control UI BizBundle for Android is the core container of the control panel for each Connected by Tuya device. Based on Commercial Lighting Smart App SDK for Android, the UI BizBundle encapsulates the APIs to load and control panels and accelerates the application development process.

Feature overview

The UI BizBundle supports the following features:

  • Panel loading: supports device panels of multiple protocols, such as Wi-Fi, Zigbee, Bluetooth, and Bluetooth mesh.
  • Device control: controls a single device. Device groups cannot be managed.

Prerequisites

Tuya Smart App SDK for Android is integrated into your project with Android Studio. The Commercial Lighting App SDK and Device Control UI BizBundle are added to your project.

Things to note

The UI BizBundle includes the open source React Native framework (v0.59.10).

  • If your Android project does not integrate with React Native, follow the procedure in this topic to integrate with the UI BizBundle.

  • If your Android project has integrated with React Native, perform the following steps to check whether the UI BizBundle can be integrated:

    • If React Native has been integrated and its version is later than v0.59.10, the UI BizBundle cannot be integrated due to version incompatibility.
    • If React Native has been integrated and its version is later than v0.51 and equal to or earlier than v0.59.10, the Tuya panels cannot be accessed as expected due to the repeated uses of the React Native library. Use either of the following methods to troubleshoot the problem:
      1. Remove React Native from your Android project and use React Native v0.59.10 that the UI BizBundle depends on.
      2. Rename React Native that is integrated with your Android project to avoid the repeated React Native library.
  • If the version of the Commercial Lighting App SDK you are using is greater than or equal to v1.11.3, the version of the panel Bizbundle also needs to be upgraded to v1.11.3 simultaneously. Otherwise, you cannot enable the device panel.

    If both methods failed, the UI BizBundle cannot be integrated.

Configure the UI BizBundle

  • Configure the build.gradle file.

    dependencies {
    	api enforcedPlatform("com.thingclips.smart:thingsmart-BizBundlesBom:2.8.0-bizbundle-lamp-2.8.0.27")
            api ("com.thingclips.smart:thingsmart-bizbundle-lamp_panel")
    }
    
  • Obfuscate the code.

    # react-native
    -keep,allowobfuscation @interface com.facebook.common.internal.DoNotStrip
    -keep,allowobfuscation @interface com.facebook.proguard.annotations.DoNotStrip
    -keep,allowobfuscation @interface com.facebook.proguard.annotations.KeepGettersAndSetters
    # Do not strip any method/class that is annotated with @DoNotStrip
    -keep @com.facebook.proguard.annotations.DoNotStrip class *
    -keep @com.facebook.common.internal.DoNotStrip class *
    -keepclassmembers class * {
    	@com.facebook.proguard.annotations.DoNotStrip *;
    	@com.facebook.common.internal.DoNotStrip *;
    }
    -keepclassmembers @com.facebook.proguard.annotations.KeepGettersAndSetters class * {
    	void set*(***);
    	*** get*();
    }
    -keep class * extends com.facebook.react.bridge.JavaScriptModule { *; }
    -keep class * extends com.facebook.react.bridge.NativeModule { *; }
    -keepclassmembers,includedescriptorclasses class * { native <methods>; }
    -keepclassmembers class *  { @com.facebook.react.uimanager.UIProp <fields>; }
    -keepclassmembers class *  { @com.facebook.react.uimanager.annotations.ReactProp <methods>; }
    -keepclassmembers class *  { @com.facebook.react.uimanager.annotations.ReactPropGroup <methods>; }
    -dontwarn com.facebook.react.**
        -keep class com.facebook.** { *; }
    -keep,includedescriptorclasses class com.facebook.react.bridge.** { *; }
    
    # AutoNavi
    -dontwarn com.amap.**
    -keep class com.amap.api.maps.** { *; }
    -keep class com.autonavi.** { *; }
    -keep class com.amap.api.trace.** { *; }
    -keep class com.amap.api.navi.** { *; }
    -keep class com.autonavi.** { *; }
    -keep class com.amap.api.location.** { *; }
    -keep class com.amap.api.fence.** { *; }
    -keep class com.autonavi.aps.amapapi.model.** { *; }
    -keep class com.amap.api.maps.model.** { *; }
    -keep class com.amap.api.services.** { *; }
    
    #Google Play Services
    -keep class com.google.android.gms.common.** {*;}
    -keep class com.google.android.gms.ads.identifier.** {*;}
    -keepattributes Signature,*Annotation*,EnclosingMethod
    -dontwarn com.google.android.gms.**
    
    #MPAndroidChart
    -keep class com.github.mikephil.charting.** { *; }
    -dontwarn com.github.mikephil.charting.**
    
    -keep class com.tuya.**.**{*;}
    -dontwarn com.tuya.**.**
    
        -keep class com.thingclips.**.**{*;}
        -dontwarn com.thingclips.**.**
    
        -keep,includedescriptorclasses class com.facebook.v8.** { *; }
    
        #TTT
        -keep class * extends com.thingclips.android.universal.base.ThingBaseUniPlugin { *; }
        -keep class com.thingclips.smart.plugin.*.bean.**{ *; }
    

Open a device panel

Enters a device panel by device ID.

API description

goPanelWithCheckAndTip(Activity activity, String devId)

Parameters

Parameter Description
activity The context of the current page.
devId The device ID, which can be obtained from the SDK.

Example

AbsPanelCallerService service = MicroContext.getServiceManager().findServiceByInterface(AbsPanelCallerService.class.getName());
service.goPanelWithCheckAndTip(PanelActivity.this, bean.devId);

Error codes

Error code Description
1901 Failed to download a specified panel.
1902 Failed to download a specified multilingual package.
1903 The specified device type is not supported.
1904 No devices are found in a specified group.
1905 The specified project ID is incorrect.
1906 DeviceBean is set to null.
1907 No panel resources can be downloaded.
1908 The specified firmware version is incorrect.
1909 An unknown error has occurred.