通过将在/系统/应用程序获得Android系统的权限? [英] Get Android system permissions by putting app in /system/app?
问题描述
从AOSP一些较新的Android的API进行实验,我发现了一些需要android.permission.BLUETOOTH_PRIVILEGED许可。按照文档,允许是不提供给第三方第三方应用程序。
我在别处读到您可以通过在/ system / app目录中安装您的应用程序获得root权限的设备上的系统级权限。我已经试过这对我的根的Nexus 5,但我的应用程序仍然没有得到想要的特权。 (见code及以下LogCat中输出。)
<一个href="http://stackoverflow.com/questions/9731004/how-to-grant-system-permissions-to-my-android-app">An替代听说是建立自己定制的Android ROM,然后登录使用相同的密钥的应用程序。我能做到这一点,但强烈preFER才能够使用一只股票的图像,如果它是可能的。
因此,这是什么呢?是否有可能获得系统级权限上有根电话与股票的形象?如果是这样,我是不是做错了什么?
活动:
@覆盖
保护无效的onCreate(包savedInstanceState){
super.onCreate(savedInstanceState);
如果((this.getApplicationInfo()标志&安培;!ApplicationInfo.FLAG_SYSTEM)= 0){
Log.d(TAG,这是一个系统的应用程序);
}
其他 {
Log.d(TAG,这不是一个系统的应用程序);
}
如果(getApplicationContext()。checkCallingOrSelfPermission(android.permission.BLUETOOTH_PRIVILEGED)== PackageManager.PERMISSION_GRANTED){
Log.d(TAG,我android.permission.BLUETOOTH_PRIVILEGED);
}
其他 {
Log.d(TAG,我没有android.permission.BLUETOOTH_PRIVILEGED);
}
...
}
LogCat中输出:
W / PackageManager(788):未授予权限android.permission.BLUETOOTH_PRIVILEGED打包com.radiusnetworks.testapp(的ProtectionLevel = 18标志= 0x8be47)
I / ActivityManager(788):启动PROC com.radiusnetworks.testapp的活动com.radiusnetworks.testapp / .MainActivity:PID = 3124的uid = 10075导报= {50075,3002,3001}
D / MainActivity(3124):这是一个系统的应用
D / MainActivity(3124):我没有android.permission.BLUETOOTH_PRIVILEGED
清单:
&LT; XML版本=1.0编码=UTF-8&GT?;
&LT;舱单的xmlns:机器人=http://schemas.android.com/apk/res/android
包=com.radiusnetworks.testapp
安卓版code =1
机器人:VERSIONNAME =1.0&GT;
&LT;用途-SDK
安卓的minSdkVersion =19
机器人:targetSdkVersion =19/&GT;
&LT;使用-权限的Android:名称=android.permission.BLUETOOTH/&GT;
&LT;使用,许可
机器人:名称=android.permission.BLUETOOTH_PRIVILEGED/&GT;
&LT;使用-权限的Android:名称=android.permission.BLUETOOTH_ADMIN/&GT;
&lt;应用
机器人:allowBackup =真
机器人:图标=@可绘制/ ic_launcher
机器人:标签=@字符串/ APP_NAME
机器人:主题=@风格/ AppTheme&GT;
&LT;活动
机器人:名称=com.radiusnetworks.testapp.MainActivity
机器人:标签=@字符串/ APP_NAME&GT;
&LT;意向滤光器&gt;
&lt;作用机器人:名称=android.intent.action.MAIN/&GT;
&LT;类机器人:名称=android.intent.category.LAUNCHER/&GT;
&所述; /意图滤光器&gt;
&LT; /活性GT;
&LT; /用途&gt;
&LT; /舱单&GT;
由于Android 4.4系统中,特权的应用程序必须把/系统/应用程序在/系统/私法-应用程序来代替。有一次,我搬到我的应用程序在那里,它得到了预期的特权。
在这里看到: AOSP特权VS系统的应用
Experimenting with some newer Android APIs from the AOSP, I have found some that require the android.permission.BLUETOOTH_PRIVILEGED permission. According to the docs, the permission "is not available to third party applications."
I have read elsewhere that you can get system level permissions on a rooted device by installing your app in the /system/app directory. I have tried this on my rooted Nexus 5, but my app still does not get the desired privilege. (See code and LogCat output below.)
An alternative I have heard is to build your own custom Android ROM, then sign the app with the same key. I could do this, but would strongly prefer to be able to use a stock image if it is possible.
So which is it? Is it possible to get system level permissions on a rooted phone with a stock image? If so, am I doing something wrong?
Activity:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if ((this.getApplicationInfo().flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
Log.d(TAG, "This is a system application");
}
else {
Log.d(TAG, "This is not a system application");
}
if (getApplicationContext().checkCallingOrSelfPermission("android.permission.BLUETOOTH_PRIVILEGED") == PackageManager.PERMISSION_GRANTED) {
Log.d(TAG, "I have android.permission.BLUETOOTH_PRIVILEGED");
}
else {
Log.d(TAG, "I do not have android.permission.BLUETOOTH_PRIVILEGED");
}
...
}
LogCat output:
W/PackageManager( 788): Not granting permission android.permission.BLUETOOTH_PRIVILEGED to package com.radiusnetworks.testapp (protectionLevel=18 flags=0x8be47)
I/ActivityManager( 788): Start proc com.radiusnetworks.testapp for activity com.radiusnetworks.testapp/.MainActivity: pid=3124 uid=10075 gids={50075, 3002, 3001}
D/MainActivity( 3124): This is a system application
D/MainActivity( 3124): I do not have android.permission.BLUETOOTH_PRIVILEGED
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.radiusnetworks.testapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="19"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission
android:name="android.permission.BLUETOOTH_PRIVILEGED"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.radiusnetworks.testapp.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
As of Android 4.4, Privileged Apps must be put in /system/priv-app instead of /system/app. Once I moved my app there, it got the privilege as expected.
See here: AOSP Privileged vs System app
这篇关于通过将在/系统/应用程序获得Android系统的权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!