Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 659
user1406716 Avatar asked Jun 21 '15 00:06

user1406716


People also ask

How do I get rid of sensitive permissions to allow for app update on Google Play console?

Try to examine Artifact library in your play console. Click on version code's down arrow of apk/bundle file and check for required permissions section, are still able to see call,sms permissions? If yes, you need to check manifest file again and remove sensitive permissions.

What is android permission dump?

The DUMP permission is defined as android:protectionLevel="signatureOrSystem" so you can't get it unless your app is signed with the platform key, or installed in the system partition.

What is android permission Receive_boot_completed?

run at startup. Allows the app to have itself started as soon as the system has finished booting. This can make it take longer to start the phone and allow the app to slow down the overall phone by always running.


3 Answers

Update: As of Android 6 (API level 23, WAKE_LOCK is classed as a "normal" permission, meaning the permission is automatically granted. Removing the WAKE_LOCK permission will often cause apps to crash (see below) so I would avoid doing it.


I'm in the same position. I don't want to add an extra permission as it will significantly reduce the number of people using the latest version of the app (as new permissions mean the user must explicitly opt in to receive the app update).

I believe I have managed to find a solution by combining a few of the answers on this SO question.

First, add "tools" namespace to the app's manifest

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools">

Second, add the "WAKE_LOCK" permission but use the remove option

<uses-permission android:name="android.permission.WAKE_LOCK" tools:node="remove" />

Now, when I upload a new APK I can see the permission is no longer required:

wake lock permission removed

Important

It seems like this solution may no longer be viable. I'm now getting a huge number of RuntimeExceptions being thrown with the message "Neither user 10182 nor current process has android.permission.WAKE_LOCK."

Fatal Exception: java.lang.RuntimeException
Unable to start receiver com.google.android.gms.measurement.AppMeasurementReceiver: java.lang.SecurityException: Neither user 10182 nor current process has android.permission.WAKE_LOCK.
like image 171
Ian Avatar answered Oct 02 '22 19:10

Ian


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

like image 45
shkschneider Avatar answered Oct 02 '22 19:10

shkschneider


When removing WAKE_LOCK, also remove AnalyticsReceiver and AnalyticsService.

That way is written on this site. http://coffeee.hatenablog.com/entry/2017/11/26/035828

  1. open AndroidManifest.xml
  2. click the tab of "Marged Manifest" Merged Manifest
  3. right click on WAKE_LOCK and remove Remove WAKE_LOCK
  4. remove AnalyticsReceiver and AnalyticsService Remove Receiver and Service

Good Luck

like image 41
cobbee Avatar answered Oct 02 '22 21:10

cobbee