• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 Huawei Device Co., Ltd.
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 #ifndef I_SCREENLOCK_INNER_LISTENER_H
17 #define I_SCREENLOCK_INNER_LISTENER_H
18 
19 #include "iremote_broker.h"
20 #include "iremote_object.h"
21 #include "screenlock_common.h"
22 
23 namespace OHOS {
24 namespace ScreenLock {
25 class InnerListener : public virtual RefBase {
26 public:
InnerListener(int32_t userId)27     explicit InnerListener(int32_t userId) : userId_(userId) {};
28     virtual ~InnerListener() = default;
GetUserId()29     int32_t GetUserId() { return userId_; }
30     virtual void OnStateChanged(int32_t userId, int32_t state) = 0;
31 private:
32     int32_t userId_ = static_cast<int32_t>(SpecialUserId::USER_UNDEFINED);
33 };
34 
35 
36 class StrongAuthListener : public InnerListener {
37 public:
StrongAuthListener(int32_t userId)38     explicit StrongAuthListener(int32_t userId) : InnerListener(userId) {};
39     virtual ~StrongAuthListener() = default;
40     virtual void OnStrongAuthChanged(int32_t userId, int32_t authenticated) = 0;
OnStateChanged(int32_t userId,int32_t state)41     void OnStateChanged(int32_t userId, int32_t state) override
42     {
43         OnStrongAuthChanged(userId, state);
44     }
45 };
46 
47 class DeviceLockedListener : public InnerListener {
48 public:
DeviceLockedListener(int userId)49     explicit DeviceLockedListener(int userId): InnerListener(userId) {};
50     virtual ~DeviceLockedListener() = default;
51     virtual void OnDeviceLockStateChanged(int userId, bool isDeviceLocked) = 0;
OnStateChanged(int32_t userId,int32_t state)52     void OnStateChanged(int32_t userId, int32_t state) override
53     {
54         if (state == 0) {
55             OnDeviceLockStateChanged(userId, false);
56         } else {
57             OnDeviceLockStateChanged(userId, true);
58         }
59     }
60 };
61 } // namespace ScreenLock
62 } // namespace OHOS
63 
64 #endif // I_SCREENLOCK_INNER_LISTENER_H