Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Let's dig into android source code:</p> <hr> <p><strong>BatteryService</strong></p> <p>There is a <a href="http://codesearch.google.com/codesearch#uX1GffpyOZk/services/java/com/android/server/BatteryService.java&amp;q=BatteryService&amp;exact_package=git://android.git.kernel.org/platform/frameworks/base.git"><code>BatteryService</code></a> which is responsible for detecting when battery is low and if this happens it sends appropriate broadcast. The exact place that detects whether battery is low can be found <a href="http://codesearch.google.com/codesearch#uX1GffpyOZk/services/java/com/android/server/BatteryService.java&amp;q=BatteryService&amp;exact_package=git://android.git.kernel.org/platform/frameworks/base.git&amp;type=cs&amp;l=288">here</a>.</p> <pre><code>/* The ACTION_BATTERY_LOW broadcast is sent in these situations: * - is just un-plugged (previously was plugged) and battery level is * less than or equal to WARNING, or * - is not plugged and battery level falls to WARNING boundary * (becomes &lt;= mLowBatteryWarningLevel). */ final boolean sendBatteryLow = !plugged &amp;&amp; mBatteryStatus != BatteryManager.BATTERY_STATUS_UNKNOWN &amp;&amp; mBatteryLevel &lt;= mLowBatteryWarningLevel &amp;&amp; (oldPlugged || mLastBatteryLevel &gt; mLowBatteryWarningLevel); ... if (sendBatteryLow) { mSentLowBatteryBroadcast = true; statusIntent.setAction(Intent.ACTION_BATTERY_LOW); mContext.sendBroadcast(statusIntent); } </code></pre> <p>You won't be able to modify this behavior without rebuilding the Android OS. You could probably change <code>mLowBatteryWarningLevel</code> value because its taken from <code>com.android.internal.R.integer.config_lowBatteryWarningLevel</code> resource. But this requires root and will invalidate the signature of package where this resources is located.</p> <hr> <p><strong>StatusBarPolicy</strong></p> <p>So we now know that <code>BatteryService</code> sends broadcast when batter gets low. But its clear from the source code that it does not show the warning. So next step was to find who actually shows that "low battery" warning. The class responsible for this is <a href="http://codesearch.google.com/codesearch#uX1GffpyOZk/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarPolicy.java&amp;q=Intent.ACTION_BATTERY_LOW&amp;exact_package=git://android.git.kernel.org/platform/frameworks/base.git&amp;type=cs"><code>StatusBarPolicy</code></a>. Its not documented. Two pieces of code that can be interesting to you are <a href="http://codesearch.google.com/codesearch#uX1GffpyOZk/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarPolicy.java&amp;q=Intent.ACTION_BATTERY_LOW&amp;exact_package=git://android.git.kernel.org/platform/frameworks/base.git&amp;type=cs&amp;l=759"><code>onBatteryLow()</code></a> and <a href="http://codesearch.google.com/codesearch#uX1GffpyOZk/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarPolicy.java&amp;q=Intent.ACTION_BATTERY_LOW&amp;exact_package=git://android.git.kernel.org/platform/frameworks/base.git&amp;type=cs&amp;l=794"><code>showLowBatteryWarning()</code></a> functions. </p> <p>But these two functions have no reasonable influence points from outter world. So no hacks will help you here also.</p> <hr> <p>So it looks like this will be impossible without root. And even if you had root this would be challenging as you need to modify either resources or code (and then re-sign them).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload