RemoteConfigService

Remote search service is built on the Internet (uniconnect) above services across the remote service of the machine. The service is similar to Android Preference, can be in the local application through the XML configuration mode, generate the corresponding configuration view layout, in the remote device on the same, by modifying the configuration items in this view, you can configure the direct configuration of the remote device.

Basic concept

RemoteConfigManager

Use it to manage configuration information for a remote device, for example, which configuration applications are requested by the remote device, request configuration information for a configuration application, etc..

RemoteConfig

As a base class for a remote configuration item, it functions like a Android TextView control that is used to display text.

SwitchRemoteConfig

On the basis of the RemoteConfig added a switch control (Switch), the value of the Switch as the value of the configuration item, open the corresponding value of the configuration item is true, when closed, false.

CheckBoxRemoteConfig

On the basis of the RemoteConfig adds a check box control (CheckBox), the value of the CheckBox as the value of the configuration items, tick the corresponding value of the configuration item true, otherwise false.

EditTextRemoteConfig

Click the configuration item, a dialog EditText, by modifying the value of EditText to configure the configuration value configuration value corresponding to the description will cover the subtitle.

ListRemoteConfig

Click the configuration item, a dialog ListView, by selecting one option in ListView to determine the values of the configuration items, configuration item value corresponding to the description will cover the subtitle.

RemoteConfigGroup

Similar to ViewGroup, is a container control that is used to combine the above single controls, which cannot be used to configure any type of configuration value.

RemoteConfigView

Used to display remote configuration information of the View, through the control can display an application of all the configuration information.

General XML Attributes of the RemoteConfig element (all remote configuration items have these elements)

  • icon:Config item icon
  • key:Unique ID for each RemoteConfig control, the only representative of this item
  • enabled:The RemoteConfig enable,default is true
  • title:The RemoteConfig title
  • summary:The RemoteConfig summary

General XML Attributes of SwitchRemoteConfig and CheckBoxRemoteConfig element:

  • checked:on or off

General XML Attributes of EditTextRemoteConfig and ListRemoteConfig element:

  • dialogIcon
  • dialogTitle
  • dialogMessage
  • negativeButtonText
  • positiveButtonText

ListRemoteConfig unique to XML Attributes element (that should be paid attention to in its subtitle configuration, please make sure that the value contained in the entries):

  • entries:Selectmanylistbox list option value corresponding to the description, this description will cover the subtitle in the user selected
  • entryValues:The value of the list option in the list box, which is the configuration value of the configuration item

How to use

Configure XML as a provider of RemoteConfig in the application of a local device, such as YourAppProject/res/xml/config.xml, the following is the config of the config in Demo:

<?xml version="1.0" encoding="utf-8"?>
<!--主容器,标示应用-->
<RemoteConfigGroup
    icon="@drawable/ic_launcher"
    key="com.ingenic.remoteconfig3"
    title="@string/app_name" >

    <!--子容器1,该应用内的第一个配置组,此项表示可以被点击/修改的配置项内容,enabled="true",默认可被点击/修改-->
    <RemoteConfigGroup
        icon="@drawable/ic_launcher"
        key="enable"
        title="可点击/修改" >

        <!--配置组内的配置项-->

        <!--文本配置项,只包含图标和标题-->
        <RemoteConfig
            icon="@drawable/ic_launcher"
            key="1"
            title="1" />

        <!--文本配置项,包含图标、标题和副标题-->
        <RemoteConfig
            icon="@drawable/ic_launcher"
            key="2"
            summary="summary"
            title="2" />

        <!--开关配置项-->
        <SwitchRemoteConfig
            checked="true"
            icon="@drawable/ic_launcher"
            key="3"
            summary="summary"
            title="3" />

        <!--复选框配置项-->
        <CheckBoxRemoteConfig
            checked="true"
            icon="@drawable/ic_launcher"
            key="20"
            summary="summary"
            title="20" />

        <!--输入框配置项-->
        <EditTextRemoteConfig
            dialogTitle="DialogTitle"
            icon="@drawable/ic_launcher"
            key="21"
            negativeButtonText="取消"
            positiveButtonText="确定"
            summary="summary or edittext"
            title="21" />

        <!--单选列表框配置项-->
        <ListRemoteConfig
            dialogTitle="DialogTitle"
            entries="@array/window_animation_scale_entries"
            entryValues="@array/window_animation_scale_values"
            icon="@drawable/ic_launcher"
            key="22"
            negativeButtonText="取消"
            summary="关闭动画"
            title="22" />
    </RemoteConfigGroup>

    <!--子容器2,该应用内的第二个配置组,此项表示可以被点击/修改的配置项内容,enabled="false"-->
    <RemoteConfigGroup
        icon="@drawable/ic_launcher"
        key="disable"
        enabled="false"
        title="不可点击/修改" >
        <RemoteConfig
            enabled="false"
            icon="@drawable/ic_launcher"
            key="23"
            title="23" />
        <RemoteConfig
            enabled="false"
            icon="@drawable/ic_launcher"
            key="24"
            summary="summary"
            title="24" />

        <SwitchRemoteConfig
            checked="false"
            enabled="false"
            icon="@drawable/ic_launcher"
            key="25"
            summary="summary"
            title="25" />

        <CheckBoxRemoteConfig
            checked="false"
            enabled="false"
            icon="@drawable/ic_launcher"
            key="26"
            summary="summary"
            title="26" />

        <EditTextRemoteConfig
            dialogTitle="DialogTitle"
            enabled="false"
            icon="@drawable/ic_launcher"
            key="27"
            negativeButtonText="取消"
            positiveButtonText="确定"
            summary="summary or edittext"
            title="27" />

        <ListRemoteConfig
            dialogTitle="DialogTitle"
            enabled="false"
            entries="@array/window_animation_scale_entries"
            entryValues="@array/window_animation_scale_values"
            icon="@drawable/ic_launcher"
            key="28"
            negativeButtonText="取消"
            summary="关闭动画"
            title="28" />
    </RemoteConfigGroup>

</RemoteConfigGroup>

The Remote Search service is a subservice of the IWDS system service, which is used in accordance with the IWDS service framework.

    ServiceClient mServiceClient = new ServiceClient(mContext,
                ServiceManagerContext.SERVICE_REMOTE_CONFIG, mConnectionCallbacks);
    mServiceClient.connect();
    //在 mConnectionCallbacks 的回调函数onConnected中获取RemoteConfigManager实例

    @Override
    public void onConnected(ServiceClient serviceClient) {
        mRemoteConfigManager = (RemoteConfigManager) serviceClient
                .getServiceManagerContext();
        // 注册远程配置服务回调
        mRemoteConfigManager.registerRemoteConfigCallback(this);

        // 请求远程设备中所有的远程配置应用信息
        mRemoteConfigManager.requestRemoteConfigProvidersOnly();
    }

Interface

RemoteConfigManager:

    /**
    * 注册远程配置的回调接口,一个管理器只能注册一个回调接口,
    * 后注册的接口会替换掉之前注册的接口。
    *
    * @param callback
    *            远程配置回调接口
    */
    public void registerRemoteConfigCallback(RemoteConfigCallback callback);

    /**
    * 请求远程设备的所有远程配置提供者提供的所有配置信息
    * <p>
    * 在大多数情况下,客户应该使用
    * {@link RemoteConfigCallback#onRemoteConfigProvidersResult(HashMap)}
    * 获取请求结果,除非设备连接异常
    */
    public void requestRemoteConfigProviders();

    /**
    * 请求远程设备的所有远程配置提供者的信息
    * <p>
    * 在大多数情况下,客户应该使用
    * {@link RemoteConfigCallback#onRemoteConfigProvidersOnlyResult(List)}
    * 获取请求结果,除非设备连接异常
    */
    public void requestRemoteConfigProvidersOnly();

    /**
    * 请求远程设备的所有远程配置中包名为{@code packageName}的提供者的所有配置信息
    * <p>
    * 在大多数情况下,客户应该使用
    * {@link RemoteConfigCallback#onRemoteConfigForPackageResult(RemoteConfigGroup)}
    * 获取请求结果,除非设备连接异常
    *
    * @param packageName
    */
    public void requestRemoteConfigForPackage(String packageName);

    /**
    * 请求修改远程配置项信息<br/>
    *
    * @param infos
    */
    public void requestUpdateRemoteConfigs(List<RemoteConfigValueInfo> infos);

    /**
    * 远程配置服务回调接口
    */
    public interface RemoteConfigCallback {

        /**
        * 请求远程配置提供者的回调接口
        *
        * @param providers
        *            所有的远程配置信息
        * @see {@link RemoteConfigManager#requestRemoteConfigProviders()}
        */
        public void onRemoteConfigProvidersResult(
                HashMap<String, RemoteConfigGroup> providers);

        /**
        * 请求对用包名的远程配置的回调接口
        *
        * @param group 远程配置
        *(结合{@link RemoteConfigView#syncRemoteConfig(Context, RemoteConfigGroup)}使用)
        * @see {@link RemoteConfigManager#requestRemoteConfigForPackage(String)}
        */
        public void onRemoteConfigForPackageResult(RemoteConfigGroup group);

        /**
        * 接收到远程配置的Icon
        *
        * @param info 远程配置的Icon
        */
        public void onRemoteConfigIconArrived(RemoteConfigIconInfo info);

        /**
        * 请求发送结果
        *
        * @param resultCode 请求发送的返回码
        */
        public void onRequestSendResult(int resultCode);

        /**
        * 远程配置提供者改变
        * <p>
        * 你可以通过再次想远程设备发出请求来获取新的远程配置信息
        *
        * @see {@link RemoteConfigManager#requestRemoteConfigProviders()} or
        * @see {@link RemoteConfigManager#requestRemoteConfigProvidersOnly()} or
        * @see {@link RemoteConfigManager#requestRemoteConfigForPackage(String)}
        */
        public void onProviderChanged(ProviderChangedCmdInfo info);

        /**
        * 请求远程配置提供者的回调接口
        *
        * @param providers
        * @see {@link RemoteConfigManager#requestRemoteConfigProvidersOnly()}
        */
        public void onRemoteConfigProvidersOnlyResult(
                List<RemoteConfig> providers);

        /**
        * 远程设备连接状态改变
        * @param isAvailable
        */
        public void onAvailableChanged(boolean isAvailable);
    }

RemoteConfigView:

    /**
    * 同步(设置)远程配置信息,设置后,配置项信息会以列表的信息显示在RemoteConfigView中
    */
    public void syncRemoteConfig(Context context, 
            RemoteConfigGroup remoteConfigGroup);

    /**
    * 同步配置项的图标,因为图片信息的信息量比较大,为了显示更快,这里单独提供同步图标的接口
    */
    public void syncRemoteConfigIcon(RemoteConfigIconInfo info);

    /**
    * 获取被修改的配置项信息,第一次获取时还没有更改,这时候会返回null
    */
    public List<RemoteConfigValueInfo> getChangedRemoteConfigInfo();

    /**
    * 获取装配置信息用的ListView,你可以用来自定义列表的样式
    */
    public ListView getListView();

Demo

RemoteConfigDemo:elf/samples/RemoteConfigDemo

  • RemoteConfigProvider
  • RemoteConfigTest