Skip to content

Add Queries for Java Android#6

Open
Dibeo wants to merge 13 commits intodevfrom
add-queries
Open

Add Queries for Java Android#6
Dibeo wants to merge 13 commits intodevfrom
add-queries

Conversation

@Dibeo
Copy link
Collaborator

@Dibeo Dibeo commented Mar 22, 2026

Ajout de la regle :

Everlasting Service : If someone calls Context#startService() then the system will retrieve the service (creating it and calling its onCreate() method if needed) and then call its onStartCommand(Intent, int, int) method with the arguments supplied by the client. The service will at this point continue running until Context#stopService() or Service#stopSelf() is called. Failing to call any of these methods can lead to uncontrolled energy leakage.

@Dibeo Dibeo added the 🗃️ rule rule improvment or rule development or bug label Mar 22, 2026
@Dibeo Dibeo changed the title Add queries Add queries Avoid Everlasting Service Mar 22, 2026
@Dibeo
Copy link
Collaborator Author

Dibeo commented Mar 22, 2026

Ajout de la regle :

Internet In The Loop : Opening and closing internet connection continuously is extremely battery-inefficient since HTTP exchange is the most consuming operation of the network. This bug typically occurs when one obtain a new HttpURLConnection by calling URL#openConnection() within a loop control structure (while, for, do-while, for-each). Also, this bad practice must be early prevented because it is the root of another evil that consists in polling data at regular intervals, instead of using push notifications to save a lot of battery power.

@Dibeo
Copy link
Collaborator Author

Dibeo commented Mar 23, 2026

Ajout de la regle :

Wifi Multicast Lock : Normally the Wifi stack filters out packets not explicitly addressed to the device. Acquiring a Multicast Lock with WifiManager.MulticastLock#acquire() will cause the stack to receive packets addressed to multicast addresses. Processing these extra packets can cause a noticeable battery drain and must be disabled when not needed with to a call to WifiManager.MulticastLock#release().

@Dibeo
Copy link
Collaborator Author

Dibeo commented Mar 23, 2026

Ajout de la regle :

Uncompressed Data Transmission : Transmitting a file over a network infrastructure without compressing it consumes more energy than with compression. More precisely, energy efficiency is improved in case the data is compressed at least by 10%, transmitted and decompressed at the other network node. From the Android client side, it means making a post HTTP request using a GZIPOutputStream instead of the classical OutputStream, along with the HttpURLConnection object.

@Dibeo
Copy link
Collaborator Author

Dibeo commented Mar 25, 2026

Ajout de la regle :

Uncached Data Reception : Caching all of the application's HTTP responses to the filesystem (application-specific cache directory) so they may be reused, allow to save energy. To that purpose the class HttpResponseCache supports HttpURLConnection and HttpsURLConnection; there is no platform-provided cache for further clients. Installing the cache at application startup is done with the static method HttpResponseCache.install(File directory, long maxSize).

@Dibeo Dibeo changed the title Add queries Avoid Everlasting Service Add Queries for Java Android Mar 25, 2026
@Dibeo
Copy link
Collaborator Author

Dibeo commented Mar 25, 2026

Ajout de la regle :

Dark UI : Developers are allowed to apply native themes for their app, or derive new ones throught inheritence. This decision has a significant impact on energy consumption since displaying dark colors is particularly beneficial for mobile devices with (AM)OLED screens (under certain conditions). By default Android will set a dark style and hence switching to the light theme (parent style Theme.*.Light) within the manifest should be avoided. Of course, custom resources like bright colors values and bitmap images with too high luminance should be avoided too.

Ajout de la regle :

Day Night Mode : Dark theme is available in Android 10 (API level 29) and higher. It allows the user to switch its system to a dark mode and the apps ought to adapt accordingly. In order to support Dark theme, the app's theme must inherit from the DayNight theme with parent="Theme.*.DayNight". In addition, developers may provide resources specific to DayNight mode in a directory res/values-night/.

Important

Peut etre que ces 2 règles peuvent etre en une seul (flag deja commun)

@Dibeo
Copy link
Collaborator Author

Dibeo commented Mar 25, 2026

Ajout de la regle :

Brightness Override : Introduced in Android 9, the adaptive brightness feature raises or lower the brightness of the screen depending on the light in the current environment. For some reasons, developpers may disable this feature programmatically, setting the field WindowManager.LayoutParams#screenBrightness with the constant BRIGHTNESS_OVERRIDE_FULL. This intelligent feature was introduced to improve battery life. Its deactivation is a very bad idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🗃️ rule rule improvment or rule development or bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant