Internet, we have to go through the operator's gateway, so in order not to invalidate the NAT mapping table, we need to send the data to the Internet on a timed basis, because otherwise the NAT mapping table fails, so we only need to send the data with a length of 0. This is the time to use the timer, on the Android system, timers usually have two kinds:1.java.util.timer2.android.app.alarmmanagerAnalysis:Timer: You can perform related tasks according to the schedule or time period. However, the
From: http://gmier.com/books/understanding-android-system/chapter2-kernel
We say that android is based on Linux, and the most fundamental reason is that android uses the Linux kernel.
2.1 Android kernel features
The android kernel is based on the Linux 2.6 kernel (the latest version is 2.6.31). It is an enhanced kernel version. Apart from modifying some bugs, it provides device drivers for supporting Android platforms, including:
Android Binder
A Driver Based on the openbinder framewor
Driver Based on the standard Linux power management system, which has been optimized for embedded devices. Source code is located:
Kernel/power/earlysuspend. c
Kernel/power/consoleearlysuspend. c
Kernel/power/fbearlysuspend. c
Kernel/power/wakelock. c
Kernel/power/userwakelock. c
3) Low Memory Manager (low memory killer)It is more flexible than the standard out of memory mechanism in Linux. It can kill processes as needed to release the required memo
Preface I have been studying Android for a while. In order to further understand how Android applications are designed and developed, I decided to study several open-source Android applications in detail. From some open-source applications to absorb something, while accumulating the amount, while exploring Android learning and research directions. Here, I first selected the jwood standup timer project. This article will sort out the study content notes and create an index list. Standup timer is
current battery state through reading from the following files:
"/Sys/class/Power_Supply/AC/online"
"/Sys/class/Power_Supply/USB/online"
"/Sys/class/Power_Supply/battery/status"
"/Sys/class/Power_Supply/battery/Health"
"/Sys/class/Power_Supply/battery/present"
"/Sys/class/Power_Supply/battery/capacity"
"/Sys/class/Power_Supply/battery/batt_vol"
"/Sys/class/Power_Supply/battery/batt_temp"
"/Sys/class/Power_Supply/battery/technology"
How to Use
To call power module in APP, the following is the sa
example, a network request is required to receive a new message, and the network request consumes CPU. How can we lock the screen and even after the system goes to sleep, still keep the network status of the system and wake up the mobile phone through the program? The answer is the wakelock mechanism in Android.
[*] Run-Time PM core functionality
The config_pm_runtime startup function allows the IO Device to enter the energy-saving (or automatic sus
To implement custom screen lock on Android phones, you often need to unlock the screen lock before entering the custom screen lock interface to smoothly enter the custom screen lock interface, it also facilitates other operations in real time. The following code is used to implement this function:1. Enable the screen and unlock the system lock
//light the screen PowerManager pm = (PowerManager)getSystemService(POWER_SERVICE); WakeLock mWakelock = pm
system from entering the idle state;
The wake lock can also be set to time-out. The lock is automatically released once the time is reached.
The wake lock code is in: kernel/power/wakelock. C.
4. Power status migration
After the kernel is started, the power management system will create three files in the sysfs File System:
/Sys/power/State
/Sys/power/wake_lock
/Sys/power/wake_unlock
The power status migration is first initiated by the
are added to the global linked list early_suspend_handlers in order of level values.
3. Workflow
First, we start with the initialization function in kernel/power/wakelock. C:
static int __init wakelocks_init(void){int ret;int i; ......for (i = 0; i
We can see that the array of the initialization active_wake_locks chain table is displayed, and then the main_wake_lock is initialized and locked, and the platform device power_device is register
reference path:2. Memory JitterIf the code has the behavior of allocating objects in code that executes multiple times, such as OnDraw or for loops, it can result in more GC times during the run and affect UI smoothness. In general, these problems can be detected through the lint tool.Five, power consumption optimization recommendationsPower optimization is mainly to pay attention to try not to affect the phone into hibernation, that is, the correct application and release of
child controls when one gets the focus for the view.There are three types of values for the property:Beforedescendants:viewgroup takes precedence over its subclass control and gets to focusAfterdescendants:viewgroup only gets focus when its subclass control does not need to get focusBlocksdescendants:viewgroup overrides the subclass control and gets the focus directly9, mobile phone screen controlPowerManager pm = (powermanager) mactivity.getsystemservice (Context.power_service);
the server retransmission message.I started thinking that it was the sleep mechanism of Android to break the WiFi, I put all kinds of wifilock, Wakelock are held, or out of this situation. Later inadvertently found that Xiaomi for each app has a background execution when agreed to the Internet switch, I opened it, really good for a while, and then began to repeat the situation before, I thought it was Mina IO thread was killed or how, with DDMS see t
1. PrefaceLinux embedded devices are developed for high power consumption requirements. In the case of problems, the positioning means are limited.About power consumption is a static power consumption, refers to a certain state of the power consumption situation, in this state to minimize the power dissipation, such as Cpuidle, suspend, Cpuhotplug, etc.The other is the dynamic power consumption, refers to the various states of the switch, such as Susped-resume, Cpuidle different state switches,
consumption of electricity:
• We should try to minimize the number of wake-up screens and duration, use Wakelock to deal with wake-up problems, be able to perform wake-up actions correctly, and turn off the operation in a timely manner to sleep.• Some operations that do not have to be performed immediately, such as uploading songs, image processing, etc., can wait until the device is in a charging state or when the battery is sufficient.• The operat
In the MediaPlayer when playing video
Mmediaplayer.setscreenonwhileplaying (TRUE); has been set, there is no problem with native Android and there is no problem on the defy, one to Samsung's Galaxy has a problem, do not know where Samsung they changed. General words are set up to play the video screen without automatic. But there was a problem on Samsung. I had to look again. There are two ways to set up general words.
As follows:
Copy Code code as follows:
1. GetWindow (). Addf
brightness
221
Improve screen brightness
223
System hibernation
224
Light the screen.
231
Turn on The voice assistant
276
Let the system hibernate if there is no wakelock
Here are input Some examples of the use of commands.Power keyCommand:adb shell input keyevent 26The execution effect is equivalent to pressing the power key.Menu keyCommand:adb sh
wait,wakeup are done using this condition, which enables directed wakeup and avoids broadcasts.2.2.2 Lock TableSession1: Requested Lock_type = Tl_writeSession2: Requested Lock_type = Tl_readThere are 14 kinds of thr_lock_type, namely:Tl_ignore=-1, Tl_unlock, tl_read_default,tl_read, tl_read_with_shared_locks,tl_ Read_high_priority,tl_read_no_insert,tl_write_allow_write,tl_write_concurrent_insert,tl_write_delayed,tl_write _default,tl_write_low_priority,tl_write,tl_write_onl
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.