The document discusses Android power management and compares it to Linux power management and other standards like APM and ACPI. It describes how Android builds upon Linux power management by adding additional states and mechanisms like wake locks. Wake locks allow applications to prevent the device from sleeping by keeping the CPU powered on. The document outlines the different types of wake locks and how they control screen, CPU and other power states. It explains how wake locks are managed between the kernel and Java layers in Android and the flows when wake locks are acquired and released.
Power Management from Linux Kernel to
Android
For normal desktop computer, power management (PM) is used to reduce power
consumption and reduce cooling requirements. Lower power consumption means
lower heat dissipation, which increases system stability, and less energy use, which
saves money and reduces the impact on the environment. For mobile device and
embedded system device, it’s much more important because the battery power is very
limited. Nowadays, android phone and iPhone are more and more pervasive. There
are more and more sensors and I/O in mobile device that can be used to improve the
effectiveness of PM. The PM needs to be tuned for new mobile device’s need. In this
survey, we want to not only know the power management system used before, but
also want to compare them with the design of Android PM.
Power Management from Linux Kernel to
Android
For normal desktop computer, power management (PM) is used to reduce power
consumption and reduce cooling requirements. Lower power consumption means
lower heat dissipation, which increases system stability, and less energy use, which
saves money and reduces the impact on the environment. For mobile device and
embedded system device, it’s much more important because the battery power is very
limited. Nowadays, android phone and iPhone are more and more pervasive. There
are more and more sensors and I/O in mobile device that can be used to improve the
effectiveness of PM. The PM needs to be tuned for new mobile device’s need. In this
survey, we want to not only know the power management system used before, but
also want to compare them with the design of Android PM.
Embedded Android System Development - Part II talks about Hardware Abstraction Layer (HAL). HAL is an interfacing layer through which Android service can place a request to device. Uses functions provided by Linux system to service the request from android framework. A C/C++ layer with purely vendor specific implementation. Packaged into modules (.so) file & loaded by Android system at appropriate time
In order to understand HAL layers of Android Framework, having Linux device driver knowledge is important. Hence Day-2 of the workshop focuses on the same.
The presentation deals with the range of features of the Linux sound subsystem — Advanced Linux Sound Architecture (ALSA). During the presentation, the participants were provided with case studies of the difference it makes for the development of audio drivers for PC and embedded systems. Also, it was
shared an overview of the state-of-the-art tendencies in the development of audio drivers for embedded systems.
This presentation by Vadym Shovkoplias (Senior Software Engineer, GlobalLogic Kharkiv) was delivered at GlobalLogic Kharkiv Embedded TechTalk #1 on March 13, 2018.
For new age touch-based embedded devices, Android is becoming a popular OS going beyond mobile phones. With its roots from Embedded Linux, Android framework offers benefits in terms of rich libraries, open-source and multi-device support. Emertxe’s hands-on Embedded Android Training Course is designed to customize, build and deploy custom Embedded OS on ARM target. Rich set of projects will make your learning complete.
A deep dive into Android OpenSource Project(AOSP)Siji Sunny
A deep dive into Android openSource project presented at
International Centre for Free and Open Source Software (ICFOSS), Kerala's OpenSource Mobile Computing Conference
Android Audio HAL – Audio Architecture – Audio HAL interface – Audio Policy – Audio HAL compilation & verification – Overview of Tinyalsa
Android Video HAL – Camera Architecture – Overview of camera HAL interface – Overview of V4L2 – Enabling V4l2 in kernel – Camera HAL compilation and verification
binder-for-linux is an experimental project to evaluate the feasibility of porting Android Binder IPC subsystem to Ubuntu Linux.
GitHub: https://github.com/hungys/binder-for-linux
Android Things is the latest attempt from Google to connect the dots between the cloud and devices by introducing an OS that is exclusively built for IoT devices. Initially announced as project Brillo, Android Things helps developers to build devices faster and enable them integrate with cloud services. This presentation traces the architectural aspects of Android Things by connecting it back with Embedded Linux, Embedded Android and Brillo.
Binder is what differentiates Android from Linux, it is most important internal building block of Android, it is a subject every Android programmer should be familiar with
Embedded Android System Development - Part II talks about Hardware Abstraction Layer (HAL). HAL is an interfacing layer through which Android service can place a request to device. Uses functions provided by Linux system to service the request from android framework. A C/C++ layer with purely vendor specific implementation. Packaged into modules (.so) file & loaded by Android system at appropriate time
In order to understand HAL layers of Android Framework, having Linux device driver knowledge is important. Hence Day-2 of the workshop focuses on the same.
The presentation deals with the range of features of the Linux sound subsystem — Advanced Linux Sound Architecture (ALSA). During the presentation, the participants were provided with case studies of the difference it makes for the development of audio drivers for PC and embedded systems. Also, it was
shared an overview of the state-of-the-art tendencies in the development of audio drivers for embedded systems.
This presentation by Vadym Shovkoplias (Senior Software Engineer, GlobalLogic Kharkiv) was delivered at GlobalLogic Kharkiv Embedded TechTalk #1 on March 13, 2018.
For new age touch-based embedded devices, Android is becoming a popular OS going beyond mobile phones. With its roots from Embedded Linux, Android framework offers benefits in terms of rich libraries, open-source and multi-device support. Emertxe’s hands-on Embedded Android Training Course is designed to customize, build and deploy custom Embedded OS on ARM target. Rich set of projects will make your learning complete.
A deep dive into Android OpenSource Project(AOSP)Siji Sunny
A deep dive into Android openSource project presented at
International Centre for Free and Open Source Software (ICFOSS), Kerala's OpenSource Mobile Computing Conference
Android Audio HAL – Audio Architecture – Audio HAL interface – Audio Policy – Audio HAL compilation & verification – Overview of Tinyalsa
Android Video HAL – Camera Architecture – Overview of camera HAL interface – Overview of V4L2 – Enabling V4l2 in kernel – Camera HAL compilation and verification
binder-for-linux is an experimental project to evaluate the feasibility of porting Android Binder IPC subsystem to Ubuntu Linux.
GitHub: https://github.com/hungys/binder-for-linux
Android Things is the latest attempt from Google to connect the dots between the cloud and devices by introducing an OS that is exclusively built for IoT devices. Initially announced as project Brillo, Android Things helps developers to build devices faster and enable them integrate with cloud services. This presentation traces the architectural aspects of Android Things by connecting it back with Embedded Linux, Embedded Android and Brillo.
Binder is what differentiates Android from Linux, it is most important internal building block of Android, it is a subject every Android programmer should be familiar with
Linux power management: are you doing it right?Chris Simmonds
Devices operating on battery power need effective power management: anything you can do to reduce power usage will increase battery life. Even for devices running on mains power, better power managements has benefits in reducing the need for cooling and lower energy costs. This presentation describes the four principles of power management: don't rush if you don't have to; don't be ashamed of being idle; turn off things you are not using; and sleep when there is nothing else to do. Each of these has a counterpart in the Linux kernel.
Session will discuss the design and work done to get S2I working on the qualcomm 410c platform. In addition, session will provide the implementation details/requirements to support suspend to idle on ARM platforms.
Show performance numbers for latency and power consumption for S2I vs S2R (if available). Highlight possible improvements to decrease latency for S2I.
These slides were presented during technical event at my organization. It focuses on overview to find a root cause of the unexpected system down events. It is mainly useful for Linux or Unix system administrators. Here, I tried to cover all aspects of the topic. It took me more than 2 hours to present these slides, but one can also cover these slides within short time-span. Gray background of slides is implemented to hide the company logo and to preserve the confidentially of private template. However, The Knowledge is not restricted :)
The openSUSE Tumbleweed kernel is lockded-down since v6.4.3 when secure boot is enabled. It means that the behavior of Tumbleweed kernel will align with SLE and openSUSE Leap when secure boot is enabled.
SA_IT241_3
WHAT ARE THE SECURITY VIOLATION CATEGORIES?
1. Breach of confidentiality: unauthorized reading of data.
2. Breach of integrity: unauthorized modification of data.
3. Breach of availability: unauthorized destruction of data.
4. Theft of service: unauthorized use of resources.
5. Denial of Service(DOS): Prevention of legitimate use.
WHAT ARE THE SECURITY VIOLATION METHODS?
1. Masquerading (authentication breach): pretending to be an authorized user.
2. Replay Attack: Replaying the same message or adding a modification to it.
3. Man-in-the-middle attack: intruder sits in data flow, masquerading as sender to receiver and vice versa.
4. Session hijacking: intercepting a session which is already on going to by-pass authentication.
5. Privilege escalation: A really Common attack, access of resources that a user is not supposed to have.
WHAT ARE THE OTHER VARIATIONS OF HYPERVISORS?
1. Paravirtualization: guest OS is modified to work with VMM.
2. Programming-environment virtualization: VMMS do not virtualize hardware which creates optimized virtual system (Used by Oracle Java and Microsoft.Net).
3. Emulators: Allows applications written for one hardware to run on different hardware environments.
4. Application Containment: Not virtualization but, provides features like it by segregating application making them more secure and manageable.
Oracle Solaris Zones, BSD Jails, IBM AIX WPARs.
• Much variation is due to breadth, depth, and importance of virtualization.
WHAT ARE THE STEPS OF LIVE MIGRATION?
1. VMM start connection with the target VMM.
2. Target created a new guest (by creating a new VCPU).
3. VMM sends read-only files to target VMM.
4. VMM sends read-write files to target VMM.
5. Repeat 4 unit done as not all read-write data can be sent (could be a dirty read).
6. If step 4 and 5 becomes very short then, VMM freezes guest, send remaining stuff.
7. Target starts running the freezed guest.
WHAT ARE THE REASONS FOR DISTRIBUTED SYSTEMS?
1. Resource sharing
Sharing files, information, printing.
Using remote GPUs.
2. Computation speedup
dsitribute processing needed to multicomputers.
Load balancing: moving jobs to more lightly-laoded sites.
3. Reliability: detect and recover failurs.
WHAT ARE THE WIDELY USED ARCHITECTURES?
1. Client-server model.
2. Cluster-based model.
WHAT ARE THE CHALLENGES?
1. Naming and transparency.
2. Remote file access.
3. Caching and caching consistency.
WHAT WAS GFS WAS INFLUNECNED BY?
1. Hardware failure should be expected routinely.
2. Most files are changed by appending new data (rather than overwriting existing data).
3. Modularized software layer MapReduce sit on top of GFS to carry out large-scale parallel computations.
WHAT ARE THE ADVANTAGES OF DISK CACHES?
1. Reliable
2. Cached data kept on disk do not need to be fetched again while recovery.
ADVANTAGES OF MAIN MEMORY CACHES?
1. Can make workstations diskless.
2. Quicker data access.
3. Performance speed up in bigger memories.
4. Server c
The Art of the Pitch: WordPress Relationships and SalesLaura Byrne
Clients don’t know what they don’t know. What web solutions are right for them? How does WordPress come into the picture? How do you make sure you understand scope and timeline? What do you do if sometime changes?
All these questions and more will be explored as we talk about matching clients’ needs with what your agency offers without pulling teeth or pulling your hair out. Practical tips, and strategies for successful relationship building that leads to closing the deal.
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf91mobiles
91mobiles recently conducted a Smart TV Buyer Insights Survey in which we asked over 3,000 respondents about the TV they own, aspects they look at on a new TV, and their TV buying preferences.
Elevating Tactical DDD Patterns Through Object CalisthenicsDorra BARTAGUIZ
After immersing yourself in the blue book and its red counterpart, attending DDD-focused conferences, and applying tactical patterns, you're left with a crucial question: How do I ensure my design is effective? Tactical patterns within Domain-Driven Design (DDD) serve as guiding principles for creating clear and manageable domain models. However, achieving success with these patterns requires additional guidance. Interestingly, we've observed that a set of constraints initially designed for training purposes remarkably aligns with effective pattern implementation, offering a more ‘mechanical’ approach. Let's explore together how Object Calisthenics can elevate the design of your tactical DDD patterns, offering concrete help for those venturing into DDD for the first time!
DevOps and Testing slides at DASA ConnectKari Kakkonen
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
The publishing industry has been selling digital audiobooks and ebooks for over a decade and has found its groove. What’s changed? What has stayed the same? Where do we go from here? Join a group of leading sales peers from across the industry for a conversation about the lessons learned since the popularization of digital books, best practices, digital book supply chain management, and more.
Link to video recording: https://bnctechforum.ca/sessions/selling-digital-books-in-2024-insights-from-industry-leaders/
Presented by BookNet Canada on May 28, 2024, with support from the Department of Canadian Heritage.
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionAggregage
Join Maher Hanafi, VP of Engineering at Betterworks, in this new session where he'll share a practical framework to transform Gen AI prototypes into impactful products! He'll delve into the complexities of data collection and management, model selection and optimization, and ensuring security, scalability, and responsible use.
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™UiPathCommunity
In questo evento online gratuito, organizzato dalla Community Italiana di UiPath, potrai esplorare le nuove funzionalità di Autopilot, il tool che integra l'Intelligenza Artificiale nei processi di sviluppo e utilizzo delle Automazioni.
📕 Vedremo insieme alcuni esempi dell'utilizzo di Autopilot in diversi tool della Suite UiPath:
Autopilot per Studio Web
Autopilot per Studio
Autopilot per Apps
Clipboard AI
GenAI applicata alla Document Understanding
👨🏫👨💻 Speakers:
Stefano Negro, UiPath MVPx3, RPA Tech Lead @ BSP Consultant
Flavio Martinelli, UiPath MVP 2023, Technical Account Manager @UiPath
Andrei Tasca, RPA Solutions Team Lead @NTT Data
State of ICS and IoT Cyber Threat Landscape Report 2024 previewPrayukth K V
The IoT and OT threat landscape report has been prepared by the Threat Research Team at Sectrio using data from Sectrio, cyber threat intelligence farming facilities spread across over 85 cities around the world. In addition, Sectrio also runs AI-based advanced threat and payload engagement facilities that serve as sinks to attract and engage sophisticated threat actors, and newer malware including new variants and latent threats that are at an earlier stage of development.
The latest edition of the OT/ICS and IoT security Threat Landscape Report 2024 also covers:
State of global ICS asset and network exposure
Sectoral targets and attacks as well as the cost of ransom
Global APT activity, AI usage, actor and tactic profiles, and implications
Rise in volumes of AI-powered cyberattacks
Major cyber events in 2024
Malware and malicious payload trends
Cyberattack types and targets
Vulnerability exploit attempts on CVEs
Attacks on counties – USA
Expansion of bot farms – how, where, and why
In-depth analysis of the cyber threat landscape across North America, South America, Europe, APAC, and the Middle East
Why are attacks on smart factories rising?
Cyber risk predictions
Axis of attacks – Europe
Systemic attacks in the Middle East
Download the full report from here:
https://sectrio.com/resources/ot-threat-landscape-reports/sectrio-releases-ot-ics-and-iot-security-threat-landscape-report-2024/
A tale of scale & speed: How the US Navy is enabling software delivery from l...sonjaschweigert1
Rapid and secure feature delivery is a goal across every application team and every branch of the DoD. The Navy’s DevSecOps platform, Party Barge, has achieved:
- Reduction in onboarding time from 5 weeks to 1 day
- Improved developer experience and productivity through actionable findings and reduction of false positives
- Maintenance of superior security standards and inherent policy enforcement with Authorization to Operate (ATO)
Development teams can ship efficiently and ensure applications are cyber ready for Navy Authorizing Officials (AOs). In this webinar, Sigma Defense and Anchore will give attendees a look behind the scenes and demo secure pipeline automation and security artifacts that speed up application ATO and time to production.
We will cover:
- How to remove silos in DevSecOps
- How to build efficient development pipeline roles and component templates
- How to deliver security artifacts that matter for ATO’s (SBOMs, vulnerability reports, and policy evidence)
- How to streamline operations with automated policy checks on container images
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...UiPathCommunity
💥 Speed, accuracy, and scaling – discover the superpowers of GenAI in action with UiPath Document Understanding and Communications Mining™:
See how to accelerate model training and optimize model performance with active learning
Learn about the latest enhancements to out-of-the-box document processing – with little to no training required
Get an exclusive demo of the new family of UiPath LLMs – GenAI models specialized for processing different types of documents and messages
This is a hands-on session specifically designed for automation developers and AI enthusiasts seeking to enhance their knowledge in leveraging the latest intelligent document processing capabilities offered by UiPath.
Speakers:
👨🏫 Andras Palfi, Senior Product Manager, UiPath
👩🏫 Lenka Dulovicova, Product Program Manager, UiPath
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfPeter Spielvogel
Building better applications for business users with SAP Fiori.
• What is SAP Fiori and why it matters to you
• How a better user experience drives measurable business benefits
• How to get started with SAP Fiori today
• How SAP Fiori elements accelerates application development
• How SAP Build Code includes SAP Fiori tools and other generative artificial intelligence capabilities
• How SAP Fiori paves the way for using AI in SAP apps
2. • Concept
• Linux Power Management
• Android Power Management Design
• Wake Locks
• System Sleep (Suspend)
• Battery Service
3. • Designed for mobile devices
• Goal is to prolong battery life
• Build on top of Linux Power Management
o Not directly suitable for a mobile device
• Designed for devices which have a 'default-off' behaviour
o The phone is not supposed to be on when we do not want to use it
o Powered on only when requested to be run, off by default
o Unlike PC, which has a default on behaviour
4. Two popular power management standards
1. APM (Advanced Power Management)
2. ACPI (Advanced Configuration and Power Interface)
5. APM
• Control resides in BIOS
• Uses activity timeouts to determine when to power down a device
• BIOS rarely used in embedded systems
• Makes power-management decisions without informing OS or
individual applications
• No knowledge of add-in cards or new devices
6. APM
• Uses layered approach to
manage devices
• APM-aware applications
(including device drivers)
talk to an OS-specific
APM driver
• The driver communicates
to the APM-aware BIOS,
which controls the
hardware
7. APM
• Communication occurs in
both directions; power
management events are
sent from the BIOS to the
APM driver, and the APM
driver sends information
and requests to the BIOS
via function calls
• In this way the APM
driver is an intermediary
between the BIOS and
the operating system
8. APM
• Power management
happens in two ways;
through function calls
from the APM driver to
the BIOS requesting
power state changes, and
automatically based on
device activity
10. ACPI
• Control divided between BIOS and OS
• Decisions managed through the OS
• Enables sophisticated power policies for general-purpose
computers with standard usage patterns and hardware
• No knowledge of device-specific scenarios (e.g. need to provide
predictable response times or to respond to critical events over
extended period)
11. ACPI
ACPI specification defines the following four Global ‘Gx’ states and six
Sleep ‘Sx’ states for an ACPI-compliant computer-system:
• G0 (S0)
oWorking
o‘Awaymode’ is a subset of S0, where monitor is off but background
tasks are running
12. ACPI
• G1, Sleeping, subdivides into the four states S1 through S4:
o S1 : All processor caches are flushed, and the CPU(s) stop executing
instructions. Power to the CPU(s) and RAM is maintained; devices that
do not indicate they must remain on may be powered down
o S2: CPU powered off. Dirty cache is flushed to RAM
o S3(mem): Commonly referred to as Standby, Sleep, or Suspend to RAM.
RAM remains powered
o S4: Hibernation/Suspend-to-Disk - All content of main memory is
saved to non-volatile memory such as a hard drive, and is powered
down
13. ACPI
• G2 (S5), Soft Off
• G3, Mechanical Off
oThe computer's power has been totally removed via a mechanical
switch
• Legacy State : The state on an operating system which does not
support ACPI. In this state, the hardware and power are not
managed via ACPI, effectively disabling ACPI.
15. • Power mode interface is on sysfs
o /sys/power/state
• sysfs is a virtual file system provided by Linux. sysfs exports
information about devices and drivers from the kernel device
model to user space, and is also used for configuration
• Changing state done by
o # echo mem > /sys/power/state
o # echo disk > /sys/power/state
o # echo standby > /sys/power/state
17. • Built as a wrapper to Linux Power Management
• In the Kernel
o Added 'on' state in the power state
o Added Early Suspend framework
o Added Partial Wake Lock mechanism
• Apps and services must request CPU resource with ‘wake locks’
through the Android application framework and native Linux
libraries in order to keep power on, otherwise Android will shut
down the CPU
• Android PM uses wake locks and time out mechanism to switch state
of system power, so that system power consumption decreases
18. • By default, Android tries to put the system into a sleep or better a
suspend mode as soon as possible
• Applications running in the Dalvik VM can prevent the system from
entering a sleep or suspend state, i.e. applications can assure that
the screen stays on or the CPU stays awake to react quickly to
interrupts
• The means Android provides for this task is wake locks
• If there are no active wake locks, CPU will be turned off
• If there are partial wake locks, screen and keyboard will be turned
off
19. Types of Wake Locks
• PARTIAL_WAKE_LOCK
o Ensures that the CPU is running
o The screen might not be on
• SCREEN_DIM_WAKE_LOCK
o Wake lock that ensures that the screen is on, but the keyboard backlight
will be allowed to go off, and the screen backlight will be allowed to go
dim
• SCREEN_BRIGHT_WAKE_LOCK
o Wake lock that ensures that the screen is on at full brightness; the
keyboard backlight will be allowed to go off
• FULL_WAKE_LOCK
o Full device ON, including backlight and screen
20. • Android implements an application framework on top of the
kernel called Android Power Management Applications
Framework
• The Android PM Framework is like a driver. It is written in Java
which connects to Android power driver through JNI
• Currently Android only supports screen, keyboard, buttons
backlight, and the brightness of screen
21. Through the framework, user space applications can use
‘PowerManger’ class to control the power state of the device
23. Touchscreen or keyboard user activity
event or full wake locks acquired
AWAKE
NOTIFI
SLEEP CATION
All partial wake locks
released
Partial Wake Lock Acquired
24. • When a user application acquire full wake lock or
screen/keyboard touch activity event occur, the machine will
enter ‘AWAKE’ state
• If timeout happens or power key is pressed, the machine will
enters ‘NOTIFICATION’ state
oIf partial wake locks are acquired, it will remain in ‘NOTIFICATION’
oIf all partial locks are released, the machine will go into ‘SLEEP’
25. • Android PM Framework provides a service for user space
applications through the class PowerManger to achieve power
saving
• The flow of exploring Wake locks are :
o Acquire handle to the PowerManager service by calling
Context.getSystemService()
o Create a wake lock and specify the power management flags for
screen, timeout, etc.
o Acquire wake lock
o Perform operation such as play MP3
o Release wake lock
26. • Used to prevent system from entering suspend or low-power-
state
• Partial Wake Lock behaviour
• Can be acquired/released from Native apps through Power.c
interface
• Can be acquired/released internally from kernel
27. How are Wake Locks Managed
• Wake Locks are mainly managed in Java layer
• When an android application takes a wake lock, a new instance of
wake lock is registered in the PowerManagerService
o PowerManagerService is running in the java layer
• Registered wake locks are put in a list
28. How are Wake Locks Managed
• A Single Partial Wake Lock in Kernel is needed to protect multiple
instance of Partial Wake Locks in Java
oIt is taken on behalf of PowerManagerService class with the name
PowerManagerService
• Other wake lock residing in kernel side are either from Native code
via Power.c API or taken internally in the Kernel
o E.g. Partial wake lock for keyboard
• There is one main wake lock called ‘main’ in the kernel to keep the
kernel awake
• It will be the last wake lock to be released when system goes to
suspend
29. How are Wake Locks Managed
WakeLock in
Java layer
WakeLock
in Kernel
30. Working
• By default, a time out is set to off the screen
• If FULL_WAKE_LOCK or SCREEN_BRIGHT_WAKE_LOCK has been taken,
when a request comes to the system to go to sleep, the system does
not go to sleep
• If no locks are currently being taken, request is sent through JNI to
suspend the device
31. Special behaviour of Partial Wake Lock
• PARTIAL_WAKE_LOCK is maintained in the kernel, not in Java
• When a PARTIAL_WAKE_LOCK in Java layer is taken, internally in the
Kernel a PARTIAL_WAKE_LOCK is taken
• All of the PARTIAL_WAKE_LOCK in the Java layer is protected by one
wake lock in the Kernel
• What is it used for ?
o If a PARTIAL_WAKE_LOCK has been take in java, when system tries to go
to sleep, the android will ask the kernel to go to sleep
o But kernel will check if a PARTIAL_WAKE_LOCK has been taken. If so it
will not suspend the CPU
o CPU could run at a reduced frequency/low power mode for running the
background app
32. Special behaviour of Partial Wake Lock
• EG : Audio playback
o When an audio is played, the audio handler, like an ALSA driver, will
take a wake lock in the kernel
o So whenever the device is turned off, we can still hear the audio
because the kernel never fully suspend the audio processing
33.
34. The flow when a Wake Lock is acquired
• Request sent to PowerManager to acquire a wake lock
• PowerManagerService to take a wake lock
• Add wake lock to the list
• Set the power state
o For a FULL_WAKE_LOCK, PowerState would be set to ON
• For taking Partial wake lock, if it is the first partial wake
lock, a kernel wake lock is taken. This will protect all the
partial wake locks. For subsequent requests, kernel wake
lock is not taken, but just added to the list
36. The flow when a Wake Lock is released
• Request to release wake lock sent to PowerManager
• Wake Lock removed from the list
• For PARTIAL_WAKE_LOCK release, if the wake lock to be
released is the last PARTIAL_WAKE_LOCK,
PowerManagerService will also release the wake lock in
the kernel. Will bring kernel to suspend
• setPowerState
o If it is the last wake lock, power state will be set to
mem, which will bring the device to standby
38. • Extension of Linux Power Management Suspend Hooks
• Used by drivers that need to handle power mode settings to the
device before kernel is suspended
• Used to turn off screen and non-wakeup source input devices
• Any driver can register its own early suspend and late_resume
handler using register_early_suspend() API
• Unregistration is done using unregister_early_suspend() API
• When the system is brought to suspend mode, early suspend is
called first. Depending on how the early suspend hook is
implemented, various things can be done
39.
40. • For e.g. consider a display driver
o In early suspend, the screen can be turned off
o In the suspend, other things like closing the driver can be done
• When system is resumed, resume is called first, followed by
resume late
41.
42.
43. • API to bring device to sleep when we press the power button
• Require DEVICE_POWER permission
• Can only be called in system process context by verifying uid
and pid
• When power button is presed, an API goToSleep() is called in
the PowerManager
44. • goToSleep() will force release all wake locks
• When force releasing all locks, power state will be set to off
• In the JNI bridge there is a function setScreenState.
setScreenState is set to off
• Then setPowerState to mem, ie write a mem to
/sys/power/state
45.
46. • The BatteryService monitors the battery status, level,
temperature etc.
• A Battery Driver in the kernel interacts with the physical
battery via ADC [to read battery voltage] and I²C ( Inter-
Integrated Circuit: a multi-master serial single-ended
computer bus used to attach low-speed peripherals to an
electronic device)
• Whenever BatteryService receives information from the
BatteryDriver, it will act accordingly
E.g. if battery level is low, it will ask system to shutdown
47. • Using power supply class in Linux Kernel
/sys/class/power_supply
• Utilize uevent mechanism to update battery status
• uevent : An asynchronous communication channel for kernel
• Battery Service will monitor the battery status based on
received uevent from the kernel
48.
49.
50. • Android Power Management Hacks, Slow Boot
• Power Management from Linux Kernel to Android, Matt Hsu &
Jim Huang, 0xlab
• Analysis of the Android Architecture. Stefan Brahler