1 /*
2 * Copyright (c) 2022 HPMicro
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "hal_hota_board.h"
17 #include "stdio.h"
18 static BOOL HOTA_STATUS = 0;
HotaHalInit(void)19 int HotaHalInit(void)
20 {
21 if (HOTA_STATUS == 1) {
22 return OHOS_FAILURE;
23 } else {
24 HOTA_STATUS = 1;
25 return OHOS_SUCCESS;
26 }
27 }
28
HotaHalGetUpdateIndex(unsigned int * index)29 int HotaHalGetUpdateIndex(unsigned int *index)
30 {
31 return OHOS_SUCCESS;
32 }
33
HotaHalDeInit(void)34 int HotaHalDeInit(void)
35 {
36 if (HOTA_STATUS == 0) {
37 return OHOS_FAILURE;
38 } else {
39 HOTA_STATUS = 0;
40 return OHOS_SUCCESS;
41 }
42 }
43
HotaHalRead(int partition,unsigned int offset,unsigned int bufLen,unsigned char * buffer)44 int HotaHalRead(int partition, unsigned int offset, unsigned int bufLen,
45 unsigned char *buffer)
46 {
47 return -1;
48 }
49
HotaHalWrite(int partition,unsigned char * buffer,unsigned int offset,unsigned int bufLen)50 int HotaHalWrite(int partition, unsigned char *buffer, unsigned int offset,
51 unsigned int bufLen)
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 0;
74 }
75
HotaHalGetPubKey(unsigned int * length)76 unsigned char *HotaHalGetPubKey(unsigned int *length)
77 {
78 return 0;
79 }
80
81
HotaHalGetUpdateAbility(void)82 int HotaHalGetUpdateAbility(void)
83 {
84 return ABILITY_PKG_SEARCH | ABILITY_PKG_DLOAD;
85 }
86
HotaHalGetOtaPkgPath(char * path,int len)87 int HotaHalGetOtaPkgPath(char *path, int len)
88 {
89 return OHOS_SUCCESS;
90 }
91
HotaHalIsDeviceCanReboot(void)92 int HotaHalIsDeviceCanReboot(void)
93 {
94 return 1;
95 }
96
HotaHalGetMetaData(UpdateMetaData * metaData)97 int HotaHalGetMetaData(UpdateMetaData *metaData)
98 {
99 return OHOS_SUCCESS;
100 }
101
HotaHalSetMetaData(UpdateMetaData * metaData)102 int HotaHalSetMetaData(UpdateMetaData *metaData)
103 {
104 return OHOS_SUCCESS;
105 }
106
HotaHalRebootAndCleanUserData(void)107 int HotaHalRebootAndCleanUserData(void)
108 {
109 return OHOS_SUCCESS;
110 }
111
HotaHalRebootAndCleanCache(void)112 int HotaHalRebootAndCleanCache(void)
113 {
114 return OHOS_SUCCESS;
115 }
116
HotaHalIsDevelopMode(void)117 int HotaHalIsDevelopMode(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