3

이 허가가 필요한 응용 프로그램을 개발 중입니다 : android.permission.MANAGE_USB.permission.android.MANAGE_USB는 Jolllybean에서 작동하지만 Lollipop OS에서는 작동하지 않습니다.


이 사용 권한은 시스템 응용 프로그램에서만 제공된다는 사실을 알고 있습니다.

응용 프로그램을 안드로이드 4.1.2에서 시스템 응용 프로그램으로 설치하면 응용 프로그램이 제대로 작동합니다.

내가 권한이 없습니다하는 시스템 응용 프로그램으로 안드로이드 5.1에서 다음 디버그 로그 인쇄 그것을 설치하려고한다면 :

오류 :

W/System.err: java.lang.SecurityException: 
Neither user 10074 nor current process has android.permission.MANAGE_USB. 

는 누구인가 왜 안드로이드 5.1에서이 오류를 계속 내고 있는지 알아?

매니페스트 :

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
package="com.example.app"> 

<uses-permission android:name="android.permission.MANAGE_USB" 
    android:protectionLevel="signature" /> 
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> 
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" /> 
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/> 
<uses-permission android:name="android.permission.WAKE_LOCK" /> 
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" /> 
<uses-permission android:name="android.permission.READ_PHONE_STATE" /> 
<uses-permission android:name="android.permission.GET_TASKS"/> 
<permission android:name="android.permission.SET_TIME" 
android:protectionLevel="signatureOrSystem" 
    /> 
<uses-feature android:name="android.hardware.usb.host" 
    android:required="true"/> 


<application 
    android:name=".services.AppContext" 
    android:allowBackup="true" 
    android:icon="@mipmap/ic_launcher" 
    android:label="@string/app_name" 
    android:largeHeap="true" 
    android:supportsRtl="true" 
    android:hardwareAccelerated="false" 
    android:theme="@style/AppTheme"> 
    <service android:name=".services.KioskService" android:exported="false"/> 
    <activity 
     android:name=".MainActivity" 
     android:launchMode="singleInstance" 
     android:stateNotNeeded="true" 
     android:screenOrientation="sensorLandscape"> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 
      <category android:name="android.intent.category.HOME" /> 
      <category android:name="android.intent.category.DEFAULT" /> 
      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 
    <service 
     android:name="com.example.app.services.UsbService" 
     android:enabled="true"> 
    </service> 

    <receiver android:name=".services.PowerDisconnectReceiver"> 
     <intent-filter> 
      <action android:name="android.intent.action.ACTION_POWER_DISCONNECTED"/> 
     </intent-filter> 
    </receiver> 

    <receiver android:name=".services.UsbPermissionReceiver"> 
     <intent-filter> 
      <action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"/> 
     </intent-filter> 
    </receiver> 

</application> 

</manifest> 
+2

AndroidManifest.xml을 게시 할 수 있습니까? –

+1

두 장치 모두에 뿌리가 있습니까? 또한 매니페스트를 표시하는 것이 중요하거나 추측 할 수만 있습니다. – Mauker

+0

괜찮습니다. 매니페스트를 추가했습니다. 예 두 장치가 루팅됩니다. 644 권한으로 system/app 폴더에 응용 프로그램을 설치했습니다. –

답변

3

내가 android:protectionLevelsignatureOrSystem에 변경하려고 할 것이다 : 나는 당신이 서명 키에 액세스 할 수 없다는 것을 이해

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.

:

A permission that the system grants only to applications that are in the Android system image or that are signed with the same certificate as the application that declared the permission. Please avoid using this option, as the signature protection level should be sufficient for most needs and works regardless of exactly where applications are installed. The "signatureOrSystem" permission is used for certain special situations where multiple vendors have applications built into a system image and need to share specific features explicitly because they are being built together.

signature 들어 안드로이드 OS를 컴파일 한 사람이 사용한다. 기기에서 사용중인 이미지이므로 signatureprotectionLevel와 (과) 일치하지 않으며 권한을 부여하지 않습니다.

https://developer.android.com/guide/topics/manifest/permission-element.html

업데이트를 참조하십시오 완성도를 위해, 나는 대답에 carlo.S 코멘트 @ 추가 해요 : 물론

In Lollipop, an app to be considered as a system application needs to be installed under the system/priv-app folder and not system/app folder like in Android 4.2.2! Also, app needs to have 644 permissions.

는 장치가 뿌리를 할 필요가있다.

+0

_ "당신은 안드로이드 OS 개발자와 같은 서명 키에 접근해야합니다."_ 무엇을 의미합니까? –

+0

APK에 서명하는 데 사용되는 키를 의미합니다. 공개 키/개인 키는 사용중인 Android 이미지를 컴파일 한 사람이 사용합니다. 내 대답에 대한 설명을 추가했습니다. –

+0

안드로이드의 이전 버전에서 작동하는 데 사용되는 응용 프로그램 '보호 수준'없이 나는 롤리팝에서 왜 작동을 멈추는 지 이해하지 못합니다 ... –