1 // Copyright (C) 2022 Beken Corporation
2 // Licensed under the Apache License, Version 2.0 (the "License");
3 // you may not use this file except in compliance with the License.
4 // You may obtain a copy of the License at
5 //
6 // http://www.apache.org/licenses/LICENSE-2.0
7 //
8 // Unless required by applicable law or agreed to in writing, software
9 // distributed under the License is distributed on an "AS IS" BASIS,
10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 // See the License for the specific language governing permissions and
12 // limitations under the License.
13
14 #include "hal_hota_board.h"
15 #include <stdio.h>
16
HotaHalInit(void)17 int HotaHalInit(void)
18 {
19 return OHOS_SUCCESS;
20 }
21
HotaHalGetUpdateIndex(unsigned int * index)22 int HotaHalGetUpdateIndex(unsigned int *index)
23 {
24 if (!index)
25 return OHOS_FAILURE;
26
27 *index = 1; //or 2
28 return OHOS_SUCCESS;
29 }
30
HotaHalDeInit(void)31 int HotaHalDeInit(void)
32 {
33 //return OHOS_SUCCESS;
34 return OHOS_FAILURE; //for subUpgradeAPI1200
35 }
36
HotaHalRead(int partition,unsigned int offset,unsigned int bufLen,unsigned char * buffer)37 int HotaHalRead(int partition, unsigned int offset, unsigned int bufLen, unsigned char *buffer)
38 {
39 if ((buffer == NULL) || (bufLen == 0)) {
40 return OHOS_FAILURE;
41 }
42
43 //return OHOS_SUCCESS;
44 return OHOS_FAILURE; //for subUpgradeAPI1100
45 }
46
HotaHalWrite(int partition,unsigned char * buffer,unsigned int offset,unsigned int bufLen)47 int HotaHalWrite(int partition, unsigned char *buffer, unsigned int offset, unsigned int bufLen)
48 {
49 if ((buffer == NULL) || (bufLen == 0)) {
50 return OHOS_FAILURE;
51 }
52
53 return OHOS_SUCCESS;
54 }
55
HotaHalRestart(void)56 int HotaHalRestart(void)
57 {
58 return OHOS_SUCCESS;
59 }
60
HotaHalSetBootSettings(void)61 int HotaHalSetBootSettings(void)
62 {
63 return OHOS_SUCCESS;
64 }
65
HotaHalRollback(void)66 int HotaHalRollback(void)
67 {
68 return OHOS_SUCCESS;
69 }
70
HotaHalGetPartitionInfo()71 const ComponentTableInfo *HotaHalGetPartitionInfo()
72 {
73 return NULL;
74 }
75
HotaHalGetPubKey(unsigned int * length)76 unsigned char *HotaHalGetPubKey(unsigned int *length)
77 {
78 *length = 0;
79 return NULL;
80 }
81
82
HotaHalGetUpdateAbility(void)83 int HotaHalGetUpdateAbility(void)
84 {
85 return ABILITY_PKG_SEARCH | ABILITY_PKG_DLOAD;
86 }
87
HotaHalGetOtaPkgPath(char * path,int len)88 int HotaHalGetOtaPkgPath(char *path, int len)
89 {
90 int ret = strcpy_s(path, len ,"/sdcard");
91 if (ret != 0) {
92 return OHOS_FAILURE;
93 }
94 return OHOS_SUCCESS;
95 }
96
HotaHalIsDeviceCanReboot(void)97 int HotaHalIsDeviceCanReboot(void)
98 {
99 return 1;
100 }
101
HotaHalGetMetaData(UpdateMetaData * metaData)102 int HotaHalGetMetaData(UpdateMetaData *metaData)
103 {
104 return OHOS_SUCCESS;
105 }
106
HotaHalSetMetaData(UpdateMetaData * metaData)107 int HotaHalSetMetaData(UpdateMetaData *metaData)
108 {
109 return OHOS_SUCCESS;
110 }
111
HotaHalRebootAndCleanUserData(void)112 int HotaHalRebootAndCleanUserData(void)
113 {
114 return OHOS_SUCCESS;
115 }
116
HotaHalRebootAndCleanCache(void)117 int HotaHalRebootAndCleanCache(void)
118 {
119 return OHOS_SUCCESS;
120 }
121
HotaHalCheckVersionValid(const char * currentVersion,const char * pkgVersion,unsigned int pkgVersionLength)122 int HotaHalCheckVersionValid(const char *currentVersion, const char *pkgVersion, unsigned int pkgVersionLength)
123 {
124 return (strncmp(currentVersion, pkgVersion, pkgVersionLength) == 0) ? 1 : 0;
125 }
126