Search code examples
androidgoogle-analyticsandroid-manifestandroid-permissionsgoogle-analytics-firebase

Do I need android.permission.WAKE_LOCK for Google Play Services if I only release in Google Play Store?


I am trying to integrate Google Analytics for Android. As per the documentation here, it asks to add android.permission.WAKE_LOCK (provides the comment note below). I dont understand it clearly. If I am releasing the app ONLY in the Google Play Store, do I still need this?

I really do not want to ask users for an additional permission if this is not absolutely necessary.

<!-- Optional permission for reliable local dispatching on non-Google Play devices -->
<uses-permission android:name="android.permission.WAKE_LOCK" />

In particular, I do not understand what this note actually means here:

Optionally a WAKE_LOCK permission can be requested to improve dispatching on non-Google Play devices.


Solution

  • WAKE_LOCK

    Allows using PowerManager WakeLocks to keep processor from sleeping or screen from dimming.

    On Google Play devices, a background service is almost always running as "Google Play Services", so WAKE_LOCK is not required.

    On non-Google Play devices, WAKE_LOCK helps keeping the dispatching process / service of Google Analytics alive so it has more chances to report / upload data.

    EDIT

    Also, it is unclear what happens to dangerous permissions in permission groups that are not ones that the user can control via Settings, such as SYSTEM_TOOLS.

    https://commonsware.com/blog/2015/06/02/random-musings-m-developer-preview-bad.html