0

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.

Charles
  • 50,943
  • 13
  • 104
  • 142
Charlie
  • 3
  • 1
  • 4
  • Probably the same problem as [here](http://stackoverflow.com/questions/13801984/permission-is-only-granted-to-system-app) – PCoder Mar 08 '13 at 13:33

1 Answers1

0

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.

StarPinkER
  • 14,081
  • 7
  • 55
  • 81