不積跬步無以至千里
一.前摘
近期項目有個需求,就是當手機電量低於15%時候,此時QuickSettings中的手電筒功能是不能開啓手電筒的,因爲此時電量已不夠用了,繼續使用手電筒就加速了電池電量的消耗,因此這個需求也是合理的。
二.修改
代碼路徑:
app/src/com/android/systemui/qs/tiles/FlashlightTile.java
import static android.os.BatteryManager.EXTRA_LEVEL;
private boolean mReceiverRegistered;
private int mLevel;
private final int LOW_BATTERY;
@Inject
public FlashlightTile(QSHost host, FlashlightController flashlightController) {
super(host);
mFlashlightController = flashlightController;
mFlashlightController.observe(getLifecycle(), this);
// modify start
mContext.registerReceiver(mRecei