• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.platform.systemui_tapl.ui
18 
19 import android.platform.systemui_tapl.utils.DeviceUtils.sysuiResSelector
20 import android.platform.uiautomatorhelpers.DeviceHelpers.assertInvisible
21 import android.platform.uiautomatorhelpers.DeviceHelpers.assertVisible
22 import android.platform.uiautomatorhelpers.DeviceHelpers.waitForObj
23 import com.android.settingslib.flags.Flags.newStatusBarIcons
24 import org.junit.Assume.assumeFalse
25 
26 /** StatusBar visible from the lockscreen. */
27 class LockscreenStatusBar internal constructor() {
28 
29     init {
<lambda>null30         KEYGUARD_STATUS_BAR_SELECTOR.assertVisible { "Lockscreen statusbar not found." }
31     }
32 
33     /**
34      * Returns the value of the battery level on lockscreen statusbar. Experimental.
35      *
36      * TODO(b/328785514): this method will no longer work with the rollout of NEW_STATUS_BAR_ICONS
37      */
getBatteryLevelnull38     fun getBatteryLevel(): String {
39         assumeFalse(newStatusBarIcons())
40         return waitForObj(sysuiResSelector(StatusBar.BATTERY_LEVEL_TEXT_ID)) {
41                 "Battery percentage not found on lock screen statusbar."
42             }
43             .text
44     }
45 
46     /** Gets user switcher chip. */
47     val userSwitcherChip: UserSwitcherChip
48         get() = UserSwitcherChip()
49 
50     /** Asserts that user switcher chip is invisible. */
assertUserSwitcherChipIsInvisiblenull51     fun assertUserSwitcherChipIsInvisible() {
52         sysuiResSelector(UserSwitcherChip.USER_SWITCHER_CONTAINER_ID).assertInvisible()
53     }
54 
55     private companion object {
56         // https://hsv.googleplex.com/6309313707507712?node=45
57         val KEYGUARD_STATUS_BAR_SELECTOR = sysuiResSelector("keyguard_header")
58     }
59 }
60