[Huawei Developers] Mike-mei:
To create is human nature. It is this urge that has driven the rapid growth of self-media. But wherever content is created, it is at risk of being copied or stolen, which is why regulators, content platforms, and creators are trying to crack down on plagiarism and protect the rights of creators.

As a solution to this challenge, DCI Kit, developed by Huawei and Copyright Protection Center of China (CPCC), safeguards digital works' copyright by leveraging technologies such as blockchain and big data. It now offers capabilities like DCI user registration, copyright registration, and copyright safeguarding. Information about successfully registered works (including their DCI codes) will be stored in the blockchain, ensuring that all copyright information is reliable and traceable. In this respect, DCI Kit offers all-round copyright protection for creators anywhere.

Effects​

After a DCI user initiates a request to register copyright for a work, CPCC will record the copyright-related information and issue a DCI code for the registered work. With blockchain and big data technologies, DCI Kit frees creators from the tedious process of registering for copyright protection, helping maximize the copyright value.

View attachment 5452421​

Development Preparations​

1. Configuring the Build Dependency for the DCI SDK

Add build dependencies on the DCI SDK in the dependencies block in the app-level build.gradle file.

// Add DCI SDK dependencies.
implementation 'com.huawei.hms:dci:3.0.1.300'

2. Configuring AndroidManifest.xml

Open the AndroidManifest.xml file in the main folder. Add the following information before <application> to apply for the storage read and write permissions and Internet access permission as needed.

<!-- Permission to write data into and read data from storage. -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<!-- Permission to access the Internet. -->
<uses-permission
android:name="android.permission.INTERNET" />

Development Procedure​

1. Initializing the DCI SDK

Initialize the DCI SDK in the onCreate() method of Application.

@Override
public void onCreate() {
super.onCreate();
// Initialize the DCI SDK.
HwDciPublicClient.initApplication(this);
}

2. Registering a User as the DCI User

// Obtain the OpenID and access token through Account Kit.
AccountAuthParams authParams = new AccountAuthParamsHelper(AccountAuthParams.DEFAULT_AUTH_REQUEST_PARAM)
.setAccessToken()
.setProfile()
.createParams();
AccountAuthService service = AccountAuthManager.getService(activity, authParams);
Task<AuthAccount> mTask = service.silentSignIn();
mTask.addOnSuccessListener(new OnSuccessListener<AuthAccount() {
@Override
public void onSuccess(AuthAccount authAccount) {
// Obtain the OpenID.
String hmsOpenId = authAccount.getOpenId();
// Obtain the access token.
String hmsAccessToken= authAccount.getAccessToken();
}
});

// Set the input parameters.
ParamsInfoEntity paramsInfoEntity = new ParamsInfoEntity();
// Pass the app ID obtained from AppGallery Connect.
paramsInfoEntity.setHmsAppId(hmsAppId);
// Pass the OpenID.
paramsInfoEntity.setHmsOpenId(hmsOpenId);
// hmsPushToken: push token provided by Push Kit. If you do not integrate Push Kit, do not pass this value.
paramsInfoEntity.setHmsPushToken(hmsPushToken);
// Pass the access token.
paramsInfoEntity.setHmsToken(hmsAccessToken);
// Customize the returned code, which is used to check whether the result belongs to your request.
int myRequestCode = 1;
// Launch the user registration screen.
HwDciPublicClient.registerDciAccount(activity,paramsInfoEntity ,myRequestCode);

// After the registration is complete, the registration result can be obtained from onActivityResult.
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode != myRequestCode || resultCode != RESULT_OK || data == null) {
return;
}
int code = data.getIntExtra(HwDciConstant.DCI_REGISTER_RESULT_CODE, 0);
if (code == 200) {
// A DCI UID is returned if the DCI user registration is successful.
AccountInfoEntity accountInfoEntity = data.getParcelableExtra(HwDciConstant.DCI_ACCOUNT_INFO_KEY);
String dciUid = accountInfoEntity.getUserId();
} else {
// Process the failure based on the code if the DCI user registration fails.
}
}

3. Registering Copyright for a Work

Pass information related to the work by calling applyDciCode of HwDciPublicClient to register its copyright.

paramsInfoEntity.setDciUid(dciUid);
paramsInfoEntity.setHmsAppId(hmsAppId);
paramsInfoEntity.setHmsOpenId(hmsOpenId);
paramsInfoEntity.setHmsToken(hmsToken);

// Obtain the local path for storing the digital work.
String imageFilePath = imageFile.getAbsolutePath();
// Obtain the name of the city where the user is now located.
String local = "Beijing";
// Obtain the digital work creation time, which is displayed as a Unix timestamp. The current time is used as an example.
long currentTime = System.currentTimeMillis();
// Call the applyDciCode method.
HwDciPublicClient.applyDciCode(paramsInfoEntity, imageFilePath,local,currentTime, new HwDciClientCallBack<String>() {
@Override
public void onSuccess(String workId) {
// After the copyright registration request is submitted, save workId locally, which will be used to query the registration result.
}

@Override
public void onFail(int code, String msg) {
// Failed to submit the request for copyright registration.
}
});

4. Querying the Copyright Registration Result

Call queryWorkDciInfo of HwDciPublicClient to check the copyright registration result according to the returned code. If the registration is successful, obtain the DCI code issued for the work.

ParamsInfoEntity paramsInfoEntity = new ParamsInfoEntity();
paramsInfoEntity.setDciUid(dciUid);
paramsInfoEntity.setHmsAppId(hmsAppId);
paramsInfoEntity.setHmsOpenId(hmsOpenId);
paramsInfoEntity.setHmsToken(hmsToken);
paramsInfoEntity.setWorkId(workId);
HwDciPublicClient.queryWorkDciInfo(paramsInfoEntity, new HwDciClientCallBack<WorkDciInfoEntity>() {
@Override
public void onSuccess(WorkDciInfoEntity result) {
if (result == null) {
return;
}
// Check the copyright registration result based on the returned status code. 0 indicates that the registration is being processed, 1 indicates that the registration is successful, and 2 indicates that the registration failed.
if (result.getRegistrationStatus() == 1) {
// If the copyright registration is successful, a DCI code will be returned.
mDciCode = result.getDciCode();
}else if (result.getRegistrationStatus() == 0) {
// The copyright registration is being processed.
}else {
// If the copyright registration fails, a failure cause will be returned.
String message = result.getMessage()
}
}
@Override
public void onFail(int code, String msg) {
// Query failed.
}});

5. Adding a DCI Icon for a Digital Work

Call addDciWatermark of HwDciPublicClient to add a DCI icon for the work whose copyright has been successfully registered. The icon serves as an identifier, indicating that the work copyright has been registered.

// Pass the local path of the digital work that requires a DCI icon.
String imageFilePath = imageFile.getAbsolutePath();
HwDciPublicClient.addDciWatermark(imageFilePath, new HwDciClientCallBack<String>() {
@Override
public void onSuccess(String imageBase64String) {
// After the DCI icon is successfully added, the digital work is returned as a Base64-encoded character string.
}

@Override
public void onFail(int code, String msg) {
// Failed to add the DCI icon.
}
});

Source Code​

To obtain the source code, please visit GitHub sample code repo.