Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Applications Sample Camera
提交
9a57a468
A
Applications Sample Camera
项目概览
OpenHarmony
/
Applications Sample Camera
9 个月 前同步成功
通知
5
Star
25
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
Applications Sample Camera
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
9a57a468
编写于
6月 17, 2021
作者:
Z
zili
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
use powermgr interface to set screen saver state
Signed-off-by:
N
zili
<
songzili@huawei.com
>
上级
63bc7e50
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
9 addition
and
76 deletion
+9
-76
setting/BUILD.gn
setting/BUILD.gn
+1
-0
setting/setting/src/main/cpp/setting_display_ability_slice.cpp
...ng/setting/src/main/cpp/setting_display_ability_slice.cpp
+4
-47
setting/setting/src/main/cpp/setting_display_ability_slice.h
setting/setting/src/main/cpp/setting_display_ability_slice.h
+4
-29
未找到文件。
setting/BUILD.gn
浏览文件 @
9a57a468
...
...
@@ -31,6 +31,7 @@ shared_library("setting") {
"${aafwk_lite_path}/frameworks/ability_lite:aafwk_abilitykit_lite",
"${appexecfwk_lite_path}/frameworks/bundle_lite:bundle",
"//base/startup/syspara_lite/frameworks/parameter:parameter",
"//base/powermgr/powermgr_lite/frameworks:powermgr",
"//foundation/communication/ipc_lite:liteipc_adapter",
"//foundation/distributedschedule/samgr_lite/samgr:samgr",
"//foundation/graphic/surface",
...
...
setting/setting/src/main/cpp/setting_display_ability_slice.cpp
浏览文件 @
9a57a468
...
...
@@ -15,14 +15,13 @@
#include "setting_display_ability_slice.h"
#include <iostream>
#include <power_screen_saver.h>
#include <securec.h>
#include "gfx_utils/style.h"
namespace
OHOS
{
REGISTER_AS
(
SettingDisplayAbilitySlice
)
const
char
*
const
BATTERY_MANAGE_SERVICE
=
"power_service"
;
const
char
*
const
PERM_INNER
=
"power_feature"
;
#define COM_SET_ON 0
#define COM_SET_OFF 1
#define COM_GET_STATUS 2
...
...
@@ -64,37 +63,6 @@ static int Callback(IOwner owner, int code, IpcIo *reply)
return
0
;
}
static
int
GetDisapayStatus
(
IClientProxy
*
defaultApi
)
{
if
(
defaultApi
==
NULL
)
{
printf
(
"[Error] defaultApi == NULL)
\n
"
);
return
-
1
;
}
int
ret
;
int
com
=
COM_GET_DISPLAY_STATUS
;
IpcIo
request
;
char
data
[
MAX_DATA_LEN
];
IpcIoInit
(
&
request
,
data
,
sizeof
(
data
),
0
);
defaultApi
->
Invoke
(
defaultApi
,
com
,
&
request
,
&
ret
,
Callback
);
printf
(
"[setting]ret get for ret -> %d
\n
"
,
ret
);
return
ret
;
}
static
IClientProxy
*
CASE_GetRemoteIUnknown
(
void
)
{
IClientProxy
*
demoApi
=
nullptr
;
printf
(
"[setting] service -> %s
\n
"
,
BATTERY_MANAGE_SERVICE
);
IUnknown
*
iUnknown
=
SAMGR_GetInstance
()
->
GetFeatureApi
(
BATTERY_MANAGE_SERVICE
,
PERM_INNER
);
if
(
iUnknown
==
nullptr
)
{
printf
(
"[ERR] SAMGR_GetInstance()->GetFeatureApi(POWER_SERVICE)
\n
"
);
return
nullptr
;
}
(
void
)
iUnknown
->
QueryInterface
(
iUnknown
,
CLIENT_PROXY_VER
,
(
void
**
)
&
demoApi
);
printf
(
"[setting]iUnknown->QueryInterface suc
\n
"
);
return
demoApi
;
}
void
SettingDisplayAbilitySlice
::
SetButtonListener
(
void
)
{
auto
onClick
=
[
this
](
UIView
&
view
,
const
Event
&
event
)
->
bool
{
...
...
@@ -148,14 +116,10 @@ void SettingDisplayAbilitySlice::SetToggleButton(void)
lablelFont
->
SetStyle
(
STYLE_TEXT_COLOR
,
DE_TITLE_TEXT_COLOR
);
toggleButtonView_
->
Add
(
lablelFont
);
int
ret
=
GetDisapayStatus
(
remoteApi_
);
SetScreenSaverState
(
TRUE
);
UIToggleButton
*
togglebutton
=
new
UIToggleButton
();
if
(
ret
==
0
)
{
togglebutton
->
SetState
(
true
);
}
else
{
togglebutton
->
SetState
(
false
);
}
changeListener_
=
new
DisBtnOnStateChangeListener
(
remoteApi_
,
togglebutton
);
togglebutton
->
SetState
(
true
);
changeListener_
=
new
DisBtnOnStateChangeListener
(
togglebutton
);
togglebutton
->
SetOnClickListener
(
changeListener_
);
togglebutton
->
SetPosition
(
DE_TOGGLE_BUTTON_X
,
DE_TOGGLE_BUTTON_Y
);
toggleButtonView_
->
Add
(
togglebutton
);
...
...
@@ -170,13 +134,6 @@ void SettingDisplayAbilitySlice::OnStart(const Want& want)
rootView_
->
SetStyle
(
STYLE_BACKGROUND_COLOR
,
DE_ROOT_BACKGROUND_COLOR
);
SetButtonListener
();
SetHead
();
remoteApi_
=
CASE_GetRemoteIUnknown
();
if
(
remoteApi_
!=
NULL
)
{
printf
(
"[setting]remoteApi_ is ok
\n
"
);
}
else
{
printf
(
"[setting] remoteApi_ is faild
\n
"
);
}
SetToggleButton
();
SetUIContent
(
rootView_
);
}
...
...
setting/setting/src/main/cpp/setting_display_ability_slice.h
浏览文件 @
9a57a468
...
...
@@ -20,6 +20,7 @@
#include <cstdio>
#include <cstring>
#include <iproxy_client.h>
#include <power_screen_saver.h>
#include "ability_loader.h"
#include "components/ui_label.h"
...
...
@@ -34,23 +35,10 @@
#include "setting_utils.h"
namespace
OHOS
{
/*
0: on
1: off
2:return 0:off, return 1:on
*/
enum
ComDisplay
{
COM_SET_DISPLAY_STEADY_ON
,
COM_SET_DISPLAY_NO_STEADY_ON
,
COM_GET_DISPLAY_STATUS
,
};
const
int
MAX_DATA_LEN
=
0x100
;
class
DisBtnOnStateChangeListener
:
public
OHOS
::
UICheckBox
::
OnChangeListener
,
public
OHOS
::
UIView
::
OnClickListener
{
public:
~
DisBtnOnStateChangeListener
()
{}
explicit
DisBtnOnStateChangeListener
(
IClientProxy
*
iClientProxy
,
UIToggleButton
*
togglebutton
)
:
myIClientProxy
(
iClientProxy
),
myTogglebutton
(
togglebutton
)
{}
explicit
DisBtnOnStateChangeListener
(
UIToggleButton
*
togglebutton
)
:
myTogglebutton
(
togglebutton
)
{}
bool
OnChange
(
UICheckBox
::
UICheckBoxState
state
)
override
{
...
...
@@ -58,24 +46,12 @@ public:
}
bool
OnClick
(
UIView
&
view
,
const
ClickEvent
&
event
)
override
{
int
com
;
bool
status
=
myTogglebutton
->
GetState
();
if
(
status
==
true
)
{
com
=
COM_SET_DISPLAY_NO_STEADY_ON
;
}
else
{
com
=
COM_SET_DISPLAY_STEADY_ON
;
}
IpcIo
request
;
char
data
[
MAX_DATA_LEN
];
IpcIoInit
(
&
request
,
data
,
sizeof
(
data
),
0
);
if
(
myIClientProxy
!=
NULL
)
{
myIClientProxy
->
Invoke
(
myIClientProxy
,
com
,
&
request
,
NULL
,
NULL
);
}
SetScreenSaverState
(
status
?
TRUE
:
FALSE
);
return
true
;
}
private:
int
funcId_
=
0
;
IClientProxy
*
myIClientProxy
;
UIToggleButton
*
myTogglebutton
;
};
...
...
@@ -98,7 +74,6 @@ private:
void
SetHead
();
void
SetToggleButton
();
IClientProxy
*
remoteApi_
=
nullptr
;
UIViewGroup
*
headView_
;
UIViewGroup
*
toggleButtonView_
;
RootView
*
rootView_
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录