<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Wakelock - Xiaomi Firmware</title>
	<atom:link href="https://xiaomifirmware.com/tag/wakelock/feed/" rel="self" type="application/rss+xml" />
	<link>https://xiaomifirmware.com/tag/wakelock/</link>
	<description>MIUI Android Devices Tips &#38; Guides</description>
	<lastBuildDate>Wed, 22 Aug 2018 01:00:24 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.5</generator>

<image>
	<url>https://xiaomifirmware.com/wp-content/uploads/2016/09/cropped-Untitled-design-32x32.png</url>
	<title>Wakelock - Xiaomi Firmware</title>
	<link>https://xiaomifirmware.com/tag/wakelock/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Excessive Battery Drain on Xiaomi Mi A1? Deal with Wakelocks</title>
		<link>https://xiaomifirmware.com/guides-and-tips/excessive-battery-drain-xiaomi-mi-a1/</link>
					<comments>https://xiaomifirmware.com/guides-and-tips/excessive-battery-drain-xiaomi-mi-a1/#respond</comments>
		
		<dc:creator><![CDATA[Hiram K.]]></dc:creator>
		<pubDate>Mon, 20 Aug 2018 20:23:05 +0000</pubDate>
				<category><![CDATA[Guides and Tips]]></category>
		<category><![CDATA[Mi A1]]></category>
		<category><![CDATA[Wakelock]]></category>
		<guid isPermaLink="false">https://xiaomifirmware.com/?p=9935</guid>

					<description><![CDATA[<p>The Xiaomi Mi A1 has the chops to run multimedia content like a perfect, budget phone. It packs a Snapdragon 625 chipset, 4GB RAM, and 1080p screen combination. These give it the power to run most content with ease. Yet, users have complained about the excessive battery drain on Xiaomi Mi A1. Is excessive battery drain on Xiaomi Mi A1 such an issue? Many people are displeased about how fast their Mi A1s are losing battery power. For example, XDA member [&#8230;]</p>
<p>The post <a href="https://xiaomifirmware.com/guides-and-tips/excessive-battery-drain-xiaomi-mi-a1/">Excessive Battery Drain on Xiaomi Mi A1? Deal with Wakelocks</a> appeared first on <a href="https://xiaomifirmware.com">Xiaomi Firmware</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>The Xiaomi Mi A1 has the chops to run multimedia content like a perfect, budget phone. It packs a Snapdragon 625 chipset, 4GB RAM, and 1080p screen combination. These give it the power to run most content with ease. Yet, users have complained about the excessive battery drain on Xiaomi Mi A1.</p>
<h2>Is excessive battery drain on Xiaomi Mi A1 such an issue?</h2>
<p>Many people are displeased about how fast their Mi A1s are losing battery power.</p>
<p>For example, XDA member <a href="https://forum.xda-developers.com/member.php?u=6858416">felipovicc</a> complained that his device didn&#8217;t go into deep sleep when it was idle. As the screenshot below shows, a kernel service named <code>7000000.ssusb</code> used up to 59% of the battery power.</p>
<figure id="attachment_9936" aria-describedby="caption-attachment-9936" style="width: 169px" class="wp-caption aligncenter"><a href="https://xiaomifirmware.com/wp-content/uploads/2018/08/Screenshot_BetterBatteryStats_20180708-145253.png"><img fetchpriority="high" decoding="async" class="wp-image-9936 size-medium" src="https://xiaomifirmware.com/wp-content/uploads/2018/08/Screenshot_BetterBatteryStats_20180708-145253-169x300.png" alt="Kernel wakelocks causing excessive battery drain" width="169" height="300" srcset="https://xiaomifirmware.com/wp-content/uploads/2018/08/Screenshot_BetterBatteryStats_20180708-145253-169x300.png 169w, https://xiaomifirmware.com/wp-content/uploads/2018/08/Screenshot_BetterBatteryStats_20180708-145253-768x1365.png 768w, https://xiaomifirmware.com/wp-content/uploads/2018/08/Screenshot_BetterBatteryStats_20180708-145253-576x1024.png 576w, https://xiaomifirmware.com/wp-content/uploads/2018/08/Screenshot_BetterBatteryStats_20180708-145253.png 1080w" sizes="(max-width: 169px) 100vw, 169px" /></a><figcaption id="caption-attachment-9936" class="wp-caption-text">Kernel services consuming battery power on an idle Mi A1. Source: <a href="https://forum.xda-developers.com/mi-a1/help/help-wakelocks-t3814378">XDA</a></figcaption></figure>
<p>MIUI senior member <a href="http://en.miui.com/space-uid-2245764833.html">Kintsugi</a> also complained about <code>7000000.ssusb</code>. He found out that it used about half of his Mi A1&#8217;s idle battery power. See the screenshot below.</p>
<figure id="attachment_9937" aria-describedby="caption-attachment-9937" style="width: 169px" class="wp-caption aligncenter"><a href="https://xiaomifirmware.com/wp-content/uploads/2018/08/y5YRyJX.png"><img decoding="async" class="wp-image-9937 size-medium" src="https://xiaomifirmware.com/wp-content/uploads/2018/08/y5YRyJX-169x300.png" alt="View kernel wakelocks" width="169" height="300" srcset="https://xiaomifirmware.com/wp-content/uploads/2018/08/y5YRyJX-169x300.png 169w, https://xiaomifirmware.com/wp-content/uploads/2018/08/y5YRyJX-768x1365.png 768w, https://xiaomifirmware.com/wp-content/uploads/2018/08/y5YRyJX-576x1024.png 576w, https://xiaomifirmware.com/wp-content/uploads/2018/08/y5YRyJX.png 1080w" sizes="(max-width: 169px) 100vw, 169px" /></a><figcaption id="caption-attachment-9937" class="wp-caption-text">Kernel wakelocks. Source: <a href="http://en.miui.com/thread-2133819-1-1.html">Xiaomi MIUI Official Forum</a></figcaption></figure>
<p>XDA member <a href="https://forum.xda-developers.com/member.php?u=9232387">AkCullen</a> tried out a few things to reduce the excessive battery drain. Yet, despite <a href="https://forum.xda-developers.com/mi-a1/help/huge-battery-drain-t3803602">stopping background apps and calibrating the battery</a> his device lost about 80% of its power while in idle mode.</p>
<h3>What are wakelocks?</h3>
<p>Smartphones have smaller battery sizes than, say, laptops or PCs. Battery life is thus a key concern for most phone users. Besides, most manufacturers market their devices by claiming that they can last a full day on a single charge.</p>
<p>Android 7 introduced the <a href="https://source.android.com/devices/tech/power/platform_mgmt#doze">Doze mode</a> to force devices to go into deep sleep. So, in ideal situations, a Xiaomi Mi A1 phone should activate Doze when its screen is off and a user has not touched it for some time.</p>
<p>Still, at times, apps need to <a href="https://developer.android.com/training/scheduling/wakelock">wake up the CPU or screen</a> to complete some tasks. These apps use wakelocks, which prevent devices from going into deep sleep fully.</p>
<h3>Android power management</h3>
<p>Android&#8217;s <code>PowerManager</code> APIs expose wakelocks to apps. Using wakelocks, apps can then prevent devices from entering suspend mode. These APIs assume that wakelocks would work for short periods of time. So, once background services have completed their tasks, they are supposed to release them. Otherwise, wakelocks that linger on may drain battery power quickly.</p>
<p><strong>Examples wakelocks&#8217; states</strong></p>
<p>The Android <code>PowerManager</code> API defines several wakelock states. See below.</p>
<ul>
<li><code>PARTIAL_WAKE_LOCK</code>:
<ul>
<li>Wakes up the CPU</li>
</ul>
</li>
<li><code>SCREEN_DIM_WAKE_LOCK</code>:
<ul>
<li>Wakes up the CPU</li>
<li>Activates the screen in <em>dim</em> mode</li>
</ul>
</li>
<li><code>SCREEN_BRIGHT_WAKE_LOCK</code>:
<ul>
<li>Wakes up the CPU</li>
<li>Activates the screen in <em>bright</em> mode</li>
</ul>
</li>
<li><code>FULL_WAKE_LOCK</code>:
<ul>
<li>Wakes up the CPU</li>
<li>Activates the screen in <em>bright</em> mode</li>
<li>Lights up the keyboard</li>
</ul>
</li>
</ul>
<h4>Power management on Android 9 pie</h4>
<p>Android Pie has introduced new ways of improving battery performance. The OS tries to give resources to those apps that need them the most. It uses two major features:</p>
<ol>
<li><strong>Restricting resource usage when battery saver is on</strong>: It applies the limits on all apps.</li>
<li><strong>App standby buckets</strong>: The system monitors app usage patterns. Then, it limits the use of resources, like CPU, depending on the apps&#8217; needs.</li>
</ol>
<p>Thus, a simple method of improving the battery performance on Xiaomi Mi A1 is to install Android Pie.</p>
<blockquote><p><strong>Related</strong>: <a href="https://xiaomifirmware.com/guides-and-tips/unofficial-android-9-pie-gsi-on-xiaomi-mi-a1/">Install Android 9 Pie on Xiaomi Mi A1</a></p></blockquote>
<h3>Wakelocks vs. wakeups</h3>
<p>Some apps can wake up devices at a specific time. They use the <code><a href="https://developer.android.com/reference/android/app/AlarmManager.html">AlarmManager</a></code> API to force a device to come out of sleep mode. Using the <code>PARTIAL_WAKE_LOCK</code> flag, they can run given tasks by activating the <code>AlarmManager</code> API.</p>
<p>Yet, poor app design causes some services to make excessive wakeup calls. Such applications may lead to quick battery drainage.</p>
<h2>How to deal with rogue wakelocks on Xiaomi Mi A1</h2>
<p>An earlier post shared tips on <a href="https://xiaomifirmware.com/guides-and-tips/optimize-battery-performance-xiaomi-mi-a1/">how to make the Xiaomi Mi A1&#8217;s last longer</a>. It listed tactics like turning off Google Sync and disabling unused services. It also advised users to install apps like <a href="https://play.google.com/store/apps/details?id=com.oasisfeng.greenify">Greenify</a>, <a href="https://play.google.com/store/apps/details?id=com.asksven.betterbatterystats">BetterBatteryStats</a>, and <a href="https://play.google.com/store/apps/details?id=com.gsamlabs.bbm">GSam Battery Monitor</a>.</p>
<p>Likewise, today I&#8217;ll share three <em>working</em> methods of dealing with excessive battery drain on Xiaomi Mi A1. The first one requires root while the last two don&#8217;t.</p>
<h3>How to stop wakelocks on Xiaomi Mi A1 <em>with</em> root</h3>
<p>This method uses the <strong><a href="https://play.google.com/store/apps/details?id=com.ryansteckler.nlpunbounce">Amplify</a></strong> app.</p>
<p>It also needs two things to work:</p>
<ol>
<li><strong>Root access</strong>: See the guide on <a href="https://xiaomifirmware.com/guides-and-tips/guide-root-xiaomi-mi-a1/">how to root Xiaomi Mi A1</a></li>
<li><strong>Xposed Framework</strong>: See steps for installation below</li>
</ol>
<h4>Installing the Xposed Framework on Xiaomi Mi A1</h4>
<ul>
<li>Download the Xposed Framework for your OS&#8217;s variant below:
<ul>
<li><strong>Android 7.1</strong>: <strong><a href="https://dl-xda.xposed.info/framework/sdk25/arm64/xposed-v89-sdk25-arm64.zip">xposed-v89-sdk25-arm64.zip</a></strong></li>
<li><strong>Android 8.0</strong>: <strong><a href="https://dl-xda.xposed.info/framework/sdk26/arm64/xposed-v90-sdk26-arm64-beta3.zip">xposed-v90-sdk26-arm64-beta3.zip</a></strong></li>
<li><strong>Android 8.1</strong>: <strong><a href="https://dl-xda.xposed.info/framework/sdk27/arm64/xposed-v90-sdk27-arm64-beta3.zip">xposed-v90-sdk27-arm64-beta3.zip</a></strong></li>
</ul>
</li>
<li>Flash the right .zip file using, say, TWRP custom recovery</li>
</ul>
<blockquote><p><strong>Related</strong>: <a href="https://xiaomifirmware.com/guides-and-tips/download-twrp-custom-recovery-xiaomi-mi-a1/">Download TWRP custom recovery for Xiaomi Mi A1</a></p></blockquote>
<ul>
<li>Install the Xposed installer. Using the .apk file below
<ul>
<li><strong>Xposed installer</strong>: <strong><a href="https://dw.uptodown.com/dwn/LdQiUxoEobYmjqYCye9PWChLBidcuddBIDKG_NheFbaDkUF4Ym6_jNilxh0Os5c1HiGCNoyoRc_RHu8t0G2jitgHw5-e1hLSQ140rCtbvSGy-oQ_kx1d27CT4NpSa5IF/HynW6bXUQZPN7MNgRErLlXymrgcYeU0jr7BwsleJNYna40vHaCXZGAbFnSYeT0dk8PnzvFEWuEsGwIoqdpBIp6AsozVbsAfA6h_YVKoAiq1Cm065S0Zcg-buxKhXxzuM/DZLhaK0oN9vjzqPMZ6YoIfi29-JWFyoc0B3tCxB6lgLXDvA7nixgwlYtAy32w3G-geCGQcmR16poQ1eRioEL4prgZPwQLEb6hJi1uACatAi1ztQqKhfYJJSjQ3FcFYzE/_kJjHzuFwyyH5N1H7MahYvPPkgwT6JoA6Q_S4hIuzD1HIGofSO1rtREdoR4aKBhl/">xposed-installer-3-1-5.apk</a></strong></li>
</ul>
</li>
</ul>
<p>With that out of the way, go ahead and install the <strong>Amplify</strong> app. Find the Play Store link above.</p>
<p>Use the app&#8217;s recommended defaults if you&#8217;re unsure of how to proceed. Otherwise, the app has ways of customizing the behavior of all services, alarms, and wakelocks running on your device.</p>
<h3>How to stop wakelocks on Xiaomi Mi A1 <em>without</em> root</h3>
<p><a href="https://play.google.com/store/apps/details?id=com.uzumapps.wakelockdetector.noroot"><strong>Wakelock Detector Lite</strong></a> and <strong>BetterBatteryStats</strong> <em>do not require root access</em> to manage wakelocks. Still, you&#8217;ll need to set up ADB drivers for the two to work.</p>
<blockquote><p><strong>Related</strong>:</p>
<p><a href="https://xiaomifirmware.com/guides-and-tips/guide-install-adb-fastboot-drivers-pc/">How to install ADB/Fastboot drivers on PC</a><br />
<a href="https://xiaomifirmware.com/guides-and-tips/install-adb-fastboot-driver-mac-os/">How to install ADB and Fastboot Drivers on Mac OS</a><br />
<a href="https://xiaomifirmware.com/guides-and-tips/flash-recovery-img-install-adb-linux-os/">How to flash recovery.img and install ADB on Linux OS</a></p></blockquote>
<h4>Using the Wakelock Detector</h4>
<p>You can use the <strong>Wakelock Detector</strong> method in two ways. One, where you install a chrome extension. And two, where you pass permissions to the app using the terminal/command line.</p>
<h5>Using a chrome browser extension</h5>
<blockquote><p>The app&#8217;s browser extension works <strong>on Google Chrome only</strong>. Thus, you&#8217;ll have to install the browser if you don&#8217;t have it on your PC already.</p></blockquote>
<p><strong>Prerequisites</strong>:</p>
<ol>
<li>Download and install<strong> Wakelock Detector Lite</strong> on your Mi A1</li>
<li>Install the Google Chrome extension for<strong> Wakelock Detector</strong>: <strong><a href="https://chrome.google.com/webstore/detail/unlocker-for-wakelockdete/bgeplmmblegmdackkcemjkpngngocgjp">Unlocker for WakeLockDetector</a></strong></li>
<li>Enable USB debugging mode on your device</li>
</ol>
<p><strong>Steps</strong>:</p>
<ol>
<li>Connect your device to PC using USB</li>
<li>Connect the phone&#8217;s as a media device. Go to <code>Storage/USB computer connection</code>, then, select connect as <code>Media device (MTP)</code>.</li>
<li>Run the <strong>Wakelock Detector Lite</strong> app on your phone</li>
<li>Run the <strong>Unlocker for WakelockDetector</strong> extension on Chrome browser. You should get a screen like the one below.</li>
<li>Press the USB icon named <code>Connection mode</code> on the extension</li>
<li>The extension will make your phone to bring up a dialog asking for RSA confirmation. Select <code>Allow from this computer</code>, then press <code>OK</code></li>
<li>As another option, the <code>Grant Battery stats</code> button may turn to a thumbs up icon. If this happens, press it instead of the USB icon to give the app the required permissions</li>
</ol>
<figure id="attachment_9938" aria-describedby="caption-attachment-9938" style="width: 362px" class="wp-caption aligncenter"><img decoding="async" class="size-full wp-image-9938" src="https://xiaomifirmware.com/wp-content/uploads/2018/08/wld-unlocker.png" alt="WLD Unlock for Chrome" width="362" height="399" srcset="https://xiaomifirmware.com/wp-content/uploads/2018/08/wld-unlocker.png 362w, https://xiaomifirmware.com/wp-content/uploads/2018/08/wld-unlocker-272x300.png 272w" sizes="(max-width: 362px) 100vw, 362px" /><figcaption id="caption-attachment-9938" class="wp-caption-text">Xiaomi Mi A1 connected to <strong>Unlocker for WakelockDetector</strong> Chrome extension</figcaption></figure>
<h5>Using the terminal/command line</h5>
<ol>
<li>Connect your device to a computer using a USB cable</li>
<li>Type the commands below on the terminal or command line</li>
</ol>
<pre><code>$ adb tcpip 5555

$ adb shell pm grant com.uzumapps.wakelockdetector.noroot android.permission.BATTERY_STATS</code></pre>
<p>After that, you may use the app to stop rogue wakelocks by:</p>
<ol>
<li>Charging your device to full charge</li>
<li>Disconnecting the charger and using the phone for about one to two hours</li>
<li>Opening the app and noting the services or apps showing excessive wakelock usage</li>
<li>Stopping the offending apps from draining your device&#8217;s battery</li>
</ol>
<h4>Using BetterBatteryStats</h4>
<p>The <strong>BetterBatteryStats</strong> method is very similar to the one by the <strong>Wakelock Detector</strong> app. The key difference is that with <strong>BetterBatteryStats, </strong>you will use the command line alone.</p>
<p>If you have the ADB drivers all set up, you should thus start managing wakelocks using the steps below.</p>
<ol>
<li>Download and install the <a href="https://play.google.com/store/apps/details?id=com.csdroid.pkg"><strong>Package Name Viewer</strong></a> app from Play Store. You&#8217;ll see in a second how the application comes in handy when you need to stop specific wakelocks.</li>
<li>Enable USB debugging on your device</li>
<li>Connect it to a computer using a USB cable</li>
<li>Run the command: <code>adb devices</code></li>
<li>If the terminal responds with the name of your device (or, if using Linux, it returns: <code>no permissions</code>), you can proceed to the next step. If this step fails, it means that your ADB drivers&#8217; installation has a problem.</li>
<li>Give the <code>BATTERY_STATS</code> permission to the <strong>BetterBatteryStats</strong> app using the commands below:</li>
</ol>
<pre><code>$ adb -d shell pm grant com.asksven.betterbatterystats android.permission.BATTERY_STATS

$ adb -d shell pm grant com.asksven.betterbatterystats android.permission.DUMP

$ adb -d shell pm grant com.asksven.betterbatterystats android.permission.PACKAGE_USAGE_STATS</code></pre>
<p>After that, you may run the app on your phone to see which services are running excessive wakelocks.</p>
<p>If you&#8217;ve noticed an offending app/service or two, use the steps below to stop their wakelocks.</p>
<ol>
<li>Run <strong>Package Name Viewer</strong> to find out the package name of the culprit. Note that package name somewhere. So, let&#8217;s say the app draining your battery is <strong>Facebook Lite</strong>. Its package name is <code>com.facebook.lite</code></li>
<li>Then, connect your phone to a computer using USB, then run the <code>adb devices</code> command</li>
<li>If successful, run the command: <code>adb shell</code></li>
<li>Then: <code>cmd appops set com.facebook.lite WAKE_LOCK ignore</code></li>
</ol>
<p><em>That&#8217;s it! You&#8217;ve managed to force your device to turn down all unruly wakelock requests.</em></p>
<h3>Over to you</h3>
<p>In this post, we&#8217;ve seen that wakelocks may cause your smartphone to drain its battery power quickly. Remember, some Xiaomi Mi A1 users claim that the problem is so bad that they lose up to 80% of their charge in only two hours of idle time.</p>
<p>Remember, wakelock requests are not bad things <em>per se</em>. Still, if your device seems to lose its battery power without reason, you may have to install apps like the ones we&#8217;ve seen above. These will help you kill services or apps that misbehave.</p>
<p><em>So, these are just but some of the ways that may deal with wakelocks on an Android device. If you&#8217;ve tried them out, please share your experience in the comments section. Also, don&#8217;t hesitate to point out new, better ways of handling excessive battery drain.</em></p>
<p>The post <a href="https://xiaomifirmware.com/guides-and-tips/excessive-battery-drain-xiaomi-mi-a1/">Excessive Battery Drain on Xiaomi Mi A1? Deal with Wakelocks</a> appeared first on <a href="https://xiaomifirmware.com">Xiaomi Firmware</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://xiaomifirmware.com/guides-and-tips/excessive-battery-drain-xiaomi-mi-a1/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
