How to fix HARDWARE_TEST permission error? - android

i'm developing an android app which uses some hardware parts like camera or Wi-Fi, and i'm using HARDWARE_TEST permission in the manifiest:
<uses-permission android:name="android.permission.HARDWARE_TEST">
I never have had any issue with that, but now suddenly when I eclipse and manifiest file, a new error is shown in this line:
"Permission is only granted to system apps"
The only way i've got to fix it is deleting this line.
Why is this error?? How can I fix it?
Thanks
Edited:
I have found the solution and answer my own question:
My problem was in android:targetSdkVersion value in manifiest which was 15 and proyect build target was checked API level 16 (Android 4.1.2)
<uses-sdk
android:minSdkVersion="2"
android:targetSdkVersion="15" />
So i have changed android:targetSdkVersion value to 16 and Proyect properties > Android > "Proyect Buid Target" checked 16 too.

There are several permission protection level for Android Permissions: Normal, Dangerous, System and signatureOrSystem.
signatureOrSystem Permission can only be granted to System applications. And For permissions in signature level:
A permission that the system grants only if the requesting application
is signed with the same certificate as the application that declared
the permission. If the certificates match, the system automatically
grants the permission without notifying the user or asking for the
user's explicit approval.
Here is the permission definition syntax.
Here is the definition of the HARDWARE_TEST permission:
<!-- Allows access to hardware peripherals. Intended only for hardware testing -->
<permission android:name="android.permission.HARDWARE_TEST"
android:permissionGroup="android.permission-group.HARDWARE_CONTROLS"
android:protectionLevel="signature"
android:label="#string/permlab_hardware_test"
android:description="#string/permdesc_hardware_test" />
It is a signature permission in Android 4.2, so it can only be granted to app with the same signature(signed by vendor). So your application cannot request that permission.
If you want to directly manipulate hardware, you may need a rooted device.

Related

Android studio does not compile permission in manifest

I bumped into a very strange problem, the studio compiles all the manifest permissions except one:
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
Tested in other compilers - the permissions successfully compiled.
How can you solve this truly strange problem?
My full list of permissions:
<uses-permission android:name="android.permission.BIND_ACCESSIBILITY_SERVICE" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
If the app targets API level 23 or higher, the app user must explicitly grant this permission to the app through a permission management screen. The app requests the user's approval by sending an intent with action ACTION_MANAGE_OVERLAY_PERMISSION. The app can check whether it has this authorization by calling Settings.canDrawOverlays().
I solved this problem by modifying the build.gradle file.
I changed targetSdkVersion from 26 to 19 (any version that <19)
But I'm not sure if this is the best solution
You cannot use SYSTEM_ALERT_WINDOW permission, because it has signature protection level.
See signature protection level - clarifying
and see https://developer.android.com/guide/topics/manifest/permission-element.html
Also you cannot use BIND_ACCESSIBILITY_SERVICE permission, it has signature protection level too.

Android: java.net.SocketException: Permission denied

Some of my app users are seeing the "Permission denied" exception
Specially for the following device: Xiaomi MI MAX Android OS: 7.0
Other devices are able to access Internet.
I've added the required permissions before the application tag, like this,
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application>
...
</application>
Can anyone please help what is wrong here?
For Android 6.0 and above, there is a new way of requesting permission from the user, which is called runtime permission, which means permission is granted when the app is running, not when it is installed like earlier versions.
Check the official guide for complete explanation

java.lang.SecurityException Neither user 10145 nor current process has android.permission.WAKE_LOCK

My app has added this permission , but in some device has this error message, all in android 4.4(4.4.2)
java.lang.SecurityException Neither user 10145 nor current process has
android.permission.WAKE_LOCK.
If You Are Using Acra Library Check This Answer :
https://stackoverflow.com/a/50972790/7377631
Your app is probably using a new version of ACRA library. In new the version they added to the lib AndroidManifest.xml file. The android:maxSdkVersion="25" is silently merged to main app AndroidManifest.xml file, hence the app doesn't have WAKE_LOCK permission on Oreo devices. The solution is add tools:node="replace" to your uses-permission declaration.
For example <uses-permission android:name="android.permission.WAKE_LOCK" tools:node="replace"/>.
Android permissions are case sensitive. So check whether you have added the permission correctly.
<uses-permission android:name="android.permission.WAKE_LOCK"/>
Also there is a known bug in Marshmallow. So try building by changing your targetsdk version is it is Android 6.0.

No prompt or toggle for Android permission

In my app on Android 7, targetSdkVersion 24, I am trying to request an Android permission WRITE_EXTERNAL_STORAGE. However, when I run the app, it never prompts me for this permission, and when on my device I go to Settings > Apps > MyApp > Permissions, I do not see a toggle for anything related to WRITE_EXTERNAL_STORAGE.
Have I missed a step somewhere?
AndroidManifest.xml (complete file on pastebin)
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
MyActivity.java
int permission = activity.checkSelfPermission(perm);
if (permission != PackageManager.PERMISSION_GRANTED)
activity.requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1);
After spending some time to investigate, I have developed a theory on this issue.
My app has some dependencies that has this in their AndroidManifest.xml:
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="18" />
What this does is auto deny WRITE_EXTERNAL_STORAGE permission if the SDK is higher than 18. That's consistent with the issues I am getting; Permission getting denied and not even prompt the user.
Then I test adding this to my App AndroidManifest.xml in attempt to override the lib dependency permission settings:
android:maxSdkVersion="25"
It then fails to build due to Merge conflict on masSdkVersion. This further confirms my suspicions on the issue; the android:maxSdkVersion propagated to the App module.
After digging through the docs, I can't find the solution, but I have a work around. READ_EXTERNAL_STORAGE is in the same group as the WRITE_EXTERNAL_STORAGE, and the doc says asking a permission for the same group would apply to the rest of permission for the whole group.
So I tested asking READ permission throughout my App and AndroidManifest.xml, it works, but I think it's stupid.
I will update when I find a proper way to resolved.

google play warns about added permission 'android.permission.READ_CALL_LOG'

I've just tried to submit a new version of my app without any changes in the permissions. However, google play's upload apk tells me that I've added the permission 'android.permission.READ_CALL_LOG', which I didn't. These are currently my permissions:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
Any ideas what the reason could be for this? (I don't want to add a new permission, my users don't like that very much)
I had this:
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="14" />
Which led to that in aapt dump badging:
uses-permission:'android.permission.READ_CALL_LOG'
uses-implied-permission:'android.permission.READ_CALL_LOG','targetSdkVersion < 16 and requested READ_CONTACTS'
Then I changed it to that:
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="16" />
Now the implied permission went away.
This just happened to me. My app has :
ACCESS_WIFI_STATE, INTERNET, and BROADCAST_STICKY
but when I upload the apk to google play I get 6 permissions:
android.permission.ACCESS_WIFI_STATE
android.permission.INTERNET
android.permission.BROADCAST_STICKY
android.permission.WRITE_EXTERNAL_STORAGE
android.permission.READ_PHONE_STATE
android.permission.READ_EXTERNAL_STORAGE
I changed the min and target sdk versions from 3 to 4 and the extra permissions went away.
My "aapt dump badging" tells that READ_CALL_LOG is implied by READ_CONTACTS.
uses-implied-permission:'android.permission.READ_CALL_LOG','targetSdkVersion < 16 and requested READ_CONTACTS'
Still, this appears to have been changed at some time. All my previous version (last 2 weeks ago) of the same app don't imply that permission, although I did not change any permissions for months.
Change the targetSdkVersion to 16 will cause the menu key disappeared on the devices > 4.0.
For I add the sherlock project in the app.
The doc already mentions this
http://developer.android.com/reference/android/Manifest.permission.html

Categories

Resources