Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
0e7ea05c
S
Startup Init Lite
项目概览
OpenHarmony
/
Startup Init Lite
9 个月 前同步成功
通知
3
Star
37
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Startup Init Lite
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
0e7ea05c
编写于
9月 27, 2022
作者:
O
openharmony_ci
提交者:
Gitee
9月 27, 2022
浏览文件
操作
浏览文件
下载
差异文件
!1307 optimize partitionslot_host service ondemand
Merge pull request !1307 from cheng_jinsong/partitionslot
上级
43c3f7ad
67ff22b9
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
59 addition
and
9 deletion
+59
-9
services/begetctl/BUILD.gn
services/begetctl/BUILD.gn
+5
-2
services/begetctl/partitionslot.cpp
services/begetctl/partitionslot.cpp
+54
-7
未找到文件。
services/begetctl/BUILD.gn
浏览文件 @
0e7ea05c
...
...
@@ -123,8 +123,11 @@ if (defined(ohos_lite)) {
if (enable_ohos_startup_init_feature_ab_partition) {
sources += [ "partitionslot.cpp" ]
external_deps +=
[ "drivers_interface_partitionslot:libpartitionslot_proxy_1.0" ]
include_dirs += [ "//drivers/hdf_core/adapter/uhdf2/include" ]
external_deps += [
"drivers_interface_partitionslot:libpartitionslot_proxy_1.0",
"hdf_core:libhdi",
]
symlink_target_name += [ "partitionslot" ]
}
...
...
services/begetctl/partitionslot.cpp
浏览文件 @
0e7ea05c
...
...
@@ -16,22 +16,51 @@
#include <iostream>
#include "begetctl.h"
#include "hdi/idevmgr_hdi.h"
#include "v1_0/ipartition_slot.h"
using
namespace
OHOS
::
HDI
::
Partitionslot
::
V1_0
;
using
OHOS
::
HDI
::
DeviceManager
::
V1_0
::
IDeviceManager
;
static
const
int32_t
PARTITION_ARGC
=
2
;
static
int
LoadDevice
()
{
auto
devmgr
=
IDeviceManager
::
Get
();
if
(
devmgr
!=
nullptr
)
{
return
devmgr
->
LoadDevice
(
"partition_slot_service"
);
}
else
{
std
::
cout
<<
"Get devmgr failed"
<<
std
::
endl
;
return
-
1
;
}
}
static
void
UnloadDevice
()
{
auto
devmgr
=
IDeviceManager
::
Get
();
if
(
devmgr
!=
nullptr
)
{
devmgr
->
UnloadDevice
(
"partition_slot_service"
);
}
else
{
std
::
cout
<<
"Get devmgr failed"
<<
std
::
endl
;
}
}
static
int
GetSlot
(
BShellHandle
handle
,
int32_t
argc
,
char
*
argv
[])
{
if
(
LoadDevice
()
!=
0
)
{
std
::
cout
<<
"Load partitionslot device failed"
<<
std
::
endl
;
return
-
1
;
}
std
::
cout
<<
"Command: partitionslot getslot"
<<
std
::
endl
;
sptr
<
IPartitionSlot
>
partitionslot
=
IPartitionSlot
::
Get
();
int
bootSlots
=
0
;
int
currentSlot
=
0
;
if
(
partitionslot
==
nullptr
)
{
return
0
;
std
::
cout
<<
"Get partitionslot failed"
<<
std
::
endl
;
return
-
1
;
}
partitionslot
->
GetCurrentSlot
(
currentSlot
,
bootSlots
);
std
::
cout
<<
"The number of slots: "
<<
bootSlots
<<
","
<<
"current slot: "
<<
currentSlot
<<
std
::
endl
;
UnloadDevice
();
return
0
;
}
...
...
@@ -39,17 +68,23 @@ static int GetSuffix(BShellHandle handle, int32_t argc, char *argv[])
{
if
(
argc
!=
PARTITION_ARGC
)
{
BShellCmdHelp
(
handle
,
argc
,
argv
);
return
0
;
return
-
1
;
}
if
(
LoadDevice
()
!=
0
)
{
std
::
cout
<<
"Load partitionslot device failed"
<<
std
::
endl
;
return
-
1
;
}
std
::
cout
<<
"Command: partitionslot getsuffix"
<<
std
::
endl
;
int
slot
=
atoi
(
argv
[
1
]);
std
::
string
suffix
=
""
;
sptr
<
IPartitionSlot
>
partitionslot
=
IPartitionSlot
::
Get
();
if
(
partitionslot
==
nullptr
)
{
return
0
;
std
::
cout
<<
"Get partitionslot failed"
<<
std
::
endl
;
return
-
1
;
}
partitionslot
->
GetSlotSuffix
(
slot
,
suffix
);
std
::
cout
<<
"The slot "
<<
slot
<<
" matches with suffix: "
<<
suffix
<<
std
::
endl
;
UnloadDevice
();
return
0
;
}
...
...
@@ -57,16 +92,22 @@ static int SetActiveSlot(BShellHandle handle, int32_t argc, char *argv[])
{
if
(
argc
!=
PARTITION_ARGC
)
{
BShellCmdHelp
(
handle
,
argc
,
argv
);
return
0
;
return
-
1
;
}
if
(
LoadDevice
()
!=
0
)
{
std
::
cout
<<
"Load partitionslot device failed"
<<
std
::
endl
;
return
-
1
;
}
std
::
cout
<<
"Command: partitionslot setactive"
<<
std
::
endl
;
int
slot
=
atoi
(
argv
[
1
]);
sptr
<
IPartitionSlot
>
partitionslot
=
IPartitionSlot
::
Get
();
if
(
partitionslot
==
nullptr
)
{
return
0
;
std
::
cout
<<
"Get partitionslot failed"
<<
std
::
endl
;
return
-
1
;
}
partitionslot
->
SetActiveSlot
(
slot
);
std
::
cout
<<
"Set active slot: "
<<
slot
<<
std
::
endl
;
UnloadDevice
();
return
0
;
}
...
...
@@ -74,16 +115,22 @@ static int SetUnbootSlot(BShellHandle handle, int32_t argc, char *argv[])
{
if
(
argc
!=
PARTITION_ARGC
)
{
BShellCmdHelp
(
handle
,
argc
,
argv
);
return
0
;
return
-
1
;
}
if
(
LoadDevice
()
!=
0
)
{
std
::
cout
<<
"Load partitionslot device failed"
<<
std
::
endl
;
return
-
1
;
}
std
::
cout
<<
"Command: partitionslot setunboot"
<<
std
::
endl
;
int
slot
=
atoi
(
argv
[
1
]);
sptr
<
IPartitionSlot
>
partitionslot
=
IPartitionSlot
::
Get
();
if
(
partitionslot
==
nullptr
)
{
return
0
;
std
::
cout
<<
"Get partitionslot failed"
<<
std
::
endl
;
return
-
1
;
}
partitionslot
->
SetSlotUnbootable
(
slot
);
std
::
cout
<<
"Set unboot slot: "
<<
slot
<<
std
::
endl
;
UnloadDevice
();
return
0
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录