Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 6, 2026

Recent versions show increased battery drain from automatic static analysis and hosts updates running on battery. Static analysis was also triggering on app updates instead of only new installs.

Changes

  • Battery constraints for background tasks

    • Added setRequiresCharging(true) to TrackerAnalysisWorker (automatic triggers only)
    • Added setRequiresCharging(true) to HostsDownloadWorker periodic updates
    • Manual analysis bypasses constraint via startAnalysis(packageName, allowOnBattery=true)
  • Static analysis completion notification

    • Shows tracker count when analysis finishes
    • Opens app details on tap
    • Uses dedicated "analysis" notification channel
  • App update filtering (verified existing)

    • Confirmed static analysis only runs when Intent.EXTRA_REPLACING is false (new installs)
    • No code changes needed - already implemented correctly in ServiceSinkhole

Implementation

// TrackerAnalysisManager.java
public void startAnalysis(String packageName, boolean allowOnBattery) {
    OneTimeWorkRequest.Builder builder = new OneTimeWorkRequest.Builder(TrackerAnalysisWorker.class)
            .setInputData(inputData)
            .addTag(packageName);
    
    if (!allowOnBattery) {
        builder.setConstraints(new Constraints.Builder()
                .setRequiresCharging(true)
                .build());
    }
    // ...
}

Files modified: ActivitySettings.java, TrackerAnalysisManager.java, TrackerAnalysisWorker.java, TrackersListAdapter.java

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • dl.google.com
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED -Xmx4608m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -cp /home/REDACTED/.gradle/wrapper/dists/gradle-8.13-bin/5xuhj0ry160q40clulazy9h7d/gradle-8.13/lib/gradle-daemon-main-8.13.jar (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Battery use</issue_title>
<issue_description>It seems that battery use is slightly increased in recent versions. This might be due to changes to the underlying c code or the new workers, for updates of hosts and static analysis. Or something else. Should be checked. In particular, the static analysis shouldn't run automatically when on battery and also not automatically on app update, only on new installs. Show a notification when a static analysis is finished.</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Fix increased battery use in recent versions Add battery constraints to background workers and completion notifications Jan 6, 2026
Copilot AI requested a review from kasnder January 6, 2026 23:58
@kasnder
Copy link
Member

kasnder commented Jan 7, 2026

What if TrackerAnalysisWorker fails? Will it try again?

@kasnder kasnder closed this Jan 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Battery use

2 participants