如何在 AOSP 构建中授予 priv-app 权限
how to grand permission to priv-app in AOSP built
我想在我的 AOSP A11 版本中添加不同的默认启动器。我有一个位于 /prebuilts/prebuitapks 的 selfbuild apk。我创建了一个 android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := Peace-Launcher
LOCAL_CERTIFICATE := platform
LOCAL_SRC_FILES := Peace-Launcher.apk
LOCAL_MODULE_CLASS := APPS
LOCAL_PRIVILEGED_MODULE := true
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
include $(BUILD_PREBUILT)
include $(CLEAR_VARS)
LOCAL_MODULE := privapp-permissions-com.harvey186.peace.dev.xml
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := ETC
LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/permissions
LOCAL_SRC_FILES := $(LOCAL_MODULE)
include $(BUILD_PREBUILT)
和一个permission.xml
<?xml version="1.0" encoding="utf-8"?>
<permissions>
<privapp-permissions package="com.harvey186.peace.dev">
<permission name="android.permission.WRITE_SYNC_SETTINGS" />
<permission name="android.permission.READ_SYNC_SETTINGS" />
<permission name="android.permission.WRITE_SETTINGS" />
<permission name="android.permission.ACCESS_NETWORK_STATE" />
<permission name="android.permission.ACCESS_WIFI_STATE" />
<permission name="android.permission.BLUETOOTH" />
<permission name="android.permission.BLUETOOTH_ADMIN" />
<permission name="android.permission.CALL_PHONE" />
<permission name="android.permission.SET_WALLPAPER" />
<permission name="android.permission.SET_WALLPAPER_HINTS" />
<permission name="android.permission.BIND_APPWIDGET" />
<permission name="android.permission.READ_EXTERNAL_STORAGE" />
<permission name="android.permission.RECEIVE_BOOT_COMPLETED" />
<permission name="android.permission.REQUEST_DELETE_PACKAGES" />
<permission name="android.permission.READ_DEVICE_CONFIG" />
<permission name="android.permission.QUERY_ALL_PACKAGES" />
<permission name="android.permission.MANAGE_DOCUMENTS" />
<permission name="android.permission.READ_EXTERNAL_STORAGE"/>
<permission name="android.permission.WRITE_EXTERNAL_STORAGE"/>
</privapp-permissions>
</permission>
但在 building/flashing/booting 之后,应用仍然拥有 none 这些权限。但需要该应用程序可以访问 'files and media'
我做错了什么?
android.permission.READ_EXTERNAL_STORAGE 和 android.permission.WRITE_EXTERNAL_STORAGE 是运行时权限。
你应该授予 runtime permission like this:
<exceptions>
<exception
package="com.google.android.apps.pixelmigrate">
<!-- External storage -->
<permission name="android.permission.READ_EXTERNAL_STORAGE" fixed="false"/>
<permission name="android.permission.WRITE_EXTERNAL_STORAGE" fixed="false"/>
<!-- Contacts -->
<permission name="android.permission.READ_CONTACTS" fixed="false"/>
<permission name="android.permission.WRITE_CONTACTS" fixed="false"/>
<!-- Call logs -->
<permission name="android.permission.READ_CALL_LOG" fixed="false"/>
<permission name="android.permission.WRITE_CALL_LOG" fixed="false"/>
<!-- SMS -->
<permission name="android.permission.RECEIVE_SMS" fixed="false"/>
<permission name="android.permission.READ_PHONE_NUMBERS" fixed="false"/>
</exception>
</exceptions>
privapp-permissions 用于安装特权权限。他们是 .
我想在我的 AOSP A11 版本中添加不同的默认启动器。我有一个位于 /prebuilts/prebuitapks 的 selfbuild apk。我创建了一个 android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := Peace-Launcher
LOCAL_CERTIFICATE := platform
LOCAL_SRC_FILES := Peace-Launcher.apk
LOCAL_MODULE_CLASS := APPS
LOCAL_PRIVILEGED_MODULE := true
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
include $(BUILD_PREBUILT)
include $(CLEAR_VARS)
LOCAL_MODULE := privapp-permissions-com.harvey186.peace.dev.xml
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := ETC
LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/permissions
LOCAL_SRC_FILES := $(LOCAL_MODULE)
include $(BUILD_PREBUILT)
和一个permission.xml
<?xml version="1.0" encoding="utf-8"?>
<permissions>
<privapp-permissions package="com.harvey186.peace.dev">
<permission name="android.permission.WRITE_SYNC_SETTINGS" />
<permission name="android.permission.READ_SYNC_SETTINGS" />
<permission name="android.permission.WRITE_SETTINGS" />
<permission name="android.permission.ACCESS_NETWORK_STATE" />
<permission name="android.permission.ACCESS_WIFI_STATE" />
<permission name="android.permission.BLUETOOTH" />
<permission name="android.permission.BLUETOOTH_ADMIN" />
<permission name="android.permission.CALL_PHONE" />
<permission name="android.permission.SET_WALLPAPER" />
<permission name="android.permission.SET_WALLPAPER_HINTS" />
<permission name="android.permission.BIND_APPWIDGET" />
<permission name="android.permission.READ_EXTERNAL_STORAGE" />
<permission name="android.permission.RECEIVE_BOOT_COMPLETED" />
<permission name="android.permission.REQUEST_DELETE_PACKAGES" />
<permission name="android.permission.READ_DEVICE_CONFIG" />
<permission name="android.permission.QUERY_ALL_PACKAGES" />
<permission name="android.permission.MANAGE_DOCUMENTS" />
<permission name="android.permission.READ_EXTERNAL_STORAGE"/>
<permission name="android.permission.WRITE_EXTERNAL_STORAGE"/>
</privapp-permissions>
</permission>
但在 building/flashing/booting 之后,应用仍然拥有 none 这些权限。但需要该应用程序可以访问 'files and media'
我做错了什么?
android.permission.READ_EXTERNAL_STORAGE 和 android.permission.WRITE_EXTERNAL_STORAGE 是运行时权限。
你应该授予 runtime permission like this:
<exceptions>
<exception
package="com.google.android.apps.pixelmigrate">
<!-- External storage -->
<permission name="android.permission.READ_EXTERNAL_STORAGE" fixed="false"/>
<permission name="android.permission.WRITE_EXTERNAL_STORAGE" fixed="false"/>
<!-- Contacts -->
<permission name="android.permission.READ_CONTACTS" fixed="false"/>
<permission name="android.permission.WRITE_CONTACTS" fixed="false"/>
<!-- Call logs -->
<permission name="android.permission.READ_CALL_LOG" fixed="false"/>
<permission name="android.permission.WRITE_CALL_LOG" fixed="false"/>
<!-- SMS -->
<permission name="android.permission.RECEIVE_SMS" fixed="false"/>
<permission name="android.permission.READ_PHONE_NUMBERS" fixed="false"/>
</exception>
</exceptions>
privapp-permissions 用于安装特权权限。他们是