目录

Message

Class Info

public class Message

Message, which carries all the data to be donated, including Session and Content.

Public Method Summary

Qualifier and Type

Method Name

void

setSession(Session session)

void

setContent(Content content)

Public Methods

[h2]setSession

Method

public void setSession(Session session)

Sets Session for a data donation message.

Parameters

Name

Description

session

Indicates the message name, version, and ID.

Example:

"session": {
        "messageId": "1",
        "messageName": "featurePrediction", // Message name.
        "messageVersion": "1.1",
        "deviceModel": " MHA-AL00",
        "deviceCategory": "",
        "deviceName": "",
        "packageName": "com.huawei.packagename"
    },

[h2]setContent

Method

Public void setContent(Content content)

Sets the content of a data donation message.

Parameters

Name

Description

content

Indicates the data type, specifications (key, value, and unit), and time when a data record is generated. One content can contain a maximum of 10 records of contentData.

Example:

"content": {
        "contentVersion": "2.1",
        "contentData": [
            {
                "header": {
                    "namespace": "event",  
                    "name": "featurePrediction"  // Feature prediction.
                },
                "payload": {
                    "eventCommonInfo": {
                        "creationTime": 1637393112, // Time when an event is created.
                        "effectiveTime": 1637393112, // Time when an event takes effect, corresponding to the start time specified in predictInfo.
                        "expirationTime": 1637394112, // End time of an event, corresponding to the end time specified in predictInfo.
                        "timeZone": "+8" // Time zone.
                    },    
                    "predictInfo":{
                           "featureName":"",          
                           "timelineInfo":[  // Timeline of feature prediction.
                            {
                                "startTime":1637393112,
                                "endTime":1637393112
                            },
                            {
                                "startTime":1637393112,
                                "endTime":1637393112
                            },
                            {
                                "startTime":1637393112,
                                "endTime":1637393112
                            }
                        ]
                    },
                    "faFormInfo": {
                        "bundleName": "aaa",
                        "moudleName": "bbb",
                        "abilityName": "ccc",
                        "formName": "ddd",
                        "formDimension": "fff",
                        "formParams": { 
                            "hwChannelId": "xxx",
                            "key1": "value1",
                            "key2": "value2"
                        }
                    }
                }
            }
        ]
    }