Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7313cc32 authored by David Girault's avatar David Girault
Browse files

Don't instantiate unused power buttons in StatusBarService.

New power buttons in the StatusBar is a great thing. But, on my HTC Hero,
I got a lot of the following error in logcat:

E/FlashlightButton(  133): getFlashlightEnabled failed
E/FlashlightButton(  133): java.io.FileNotFoundException: /sys/class/leds/flashlight/brightness (No such file or directory)
E/FlashlightButton(  133):      at org.apache.harmony.luni.platform.OSFileSystem.openImpl(Native Method)
E/FlashlightButton(  133):      at org.apache.harmony.luni.platform.OSFileSystem.open(OSFileSystem.java:152)
E/FlashlightButton(  133):      at java.io.FileInputStream.<init>(FileInputStream.java:82)
E/FlashlightButton(  133):      at java.io.FileInputStream.<init>(FileInputStream.java:134)
E/FlashlightButton(  133):      at com.android.server.status.widget.FlashlightButton.getFlashlightEnabled(FlashlightButton.java:73)
E/FlashlightButton(  133):      at com.android.server.status.widget.FlashlightButton.updateState(FlashlightButton.java:47)
E/FlashlightButton(  133):      at com.android.server.status.StatusBarService.updateStates(StatusBarService.java:2043)
E/FlashlightButton(  133):      at com.android.server.status.StatusBarService.updateWidget(StatusBarService.java:2065)
E/FlashlightButton(  133):      at com.android.server.status.StatusBarService.access$800(StatusBarService.java:120)
E/FlashlightButton(  133):      at com.android.server.status.StatusBarService$7.onReceive(StatusBarService.java:2094)
E/FlashlightButton(  133):      at android.app.ActivityThread$PackageInfo$ReceiverDispatcher$Args.run(ActivityThread.java:892)
E/FlashlightButton(  133):      at android.os.Handler.handleCallback(Handler.java:587)
E/FlashlightButton(  133):      at android.os.Handler.dispatchMessage(Handler.java:92)
E/FlashlightButton(  133):      at android.os.Looper.loop(Looper.java:123)
E/FlashlightButton(  133):      at com.android.server.ServerThread.run(SystemServer.java:524)

This is beacause, all power buttons are instantiate, even if unused or
functionnality is missing. So, I remove most calls to getInstance() for
all of them and use a HashMap to store the buttons used and only call
them in updateStates() and updateWidget().

Additionnaly, my change reduce memory usage of the status bar.

Fixed tabs, some indents and long lines.

Change-Id: I22b98bddc791c547d02b50a09b561aa469cc25b7
parent 6bcf8b9a
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment