简体   繁体   English

如何在 aosp 中构建自定义系统权限应用程序

[英]How to build custom system privilege app in aosp

I am trying to implement custom system app which has system privilege.我正在尝试实现具有系统权限的自定义系统应用程序。 I searched about it and I learned to make system app built in system image build result needs to be placed in system/app我搜索了一下,我学会了在系统映像中构建系统应用程序,构建结果需要放在系统/应用程序中

First I put my custom app's java file, resource file, cpp file as in this below directory(packages/apps).首先,我将自定义应用程序的 java 文件、资源文件、cpp 文件放在下面的目录(包/应用程序)中。

在此处输入图片说明

And I made Android.mk file like this below.我制作了如下所示的 Android.mk 文件。

LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)

$(info Ojt System Module)

#LOCAL_MODULE_CLASS := APPS
#LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)

LOCAL_PACKAGE_NAME := OjtTestApp
LOCAL_CERTIFICATE := platform
LOCAL_PRIVILEGED_MODULE := true
LOCAL_UNINSTALLABLE_MODULE := true

LOCAL_SRC_FILES := $(call all-java-files-under,src)

LOCAL_STATIC_ANDROID_LIBRARIES := \
android-support-v13 \
android-support-v4 \
android-support-compat \
    android-support-v7-appcompat \
    android-support-v7-gridlayout

LOCAL_JNI_SHARED_LIBRARIES := libojt

LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
LOCAL_SDK_VERSION := current

LOCAL_PROGUARD_ENABLED := disabled

LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_PATH := $(TARGET_OUT_APPS)

include $(BUILD_PACKAGE)

#include $(BUILD_PREBUILT)
include $(call all-makefiles-under,$(LOCAL_PATH))

I also putted package name in aosp_sailfish.mk(device/google/marlin/aosp_sailfish.mk) file like this below.我还在 aosp_sailfish.mk(device/google/marlin/aosp_sailfish.mk) 文件中输入了包名,如下所示。

PRODUCT_PACKAGE += OjtTestApp

After that I build my app by make OjtTestApp and build was completed without error.之后,我通过 make OjtTestApp 构建我的应用程序,并且构建没有错误地完成。 I tried to make apk file as in this post to system/app so that my custom app can built in system image but It keeps gave me following output(obj/APPS).我试图让apk文件在这个岗位到系统/应用程序,以便我的自定义应用程序可以在内置的系统映像,但它一直给我下面的输出(OBJ / APPS)。

[100% 8/8] target Package: OjtTestApp (out/target/product/sailfish/obj/APPS/OjtTestApp_intermediates/package.apk) 【100% 8/8】目标包:OjtTestApp(out/target/product/sailfish/obj/APPS/OjtTestApp_intermediates/package.apk)

Please help me I can't find error in my Android.mk file.请帮助我我在我的 Android.mk 文件中找不到错误。

You don't need to go to that length.你不需要去那个长度。 Build your apk normally don't sign it or sign it with system certificate.构建您的 apk 通常不要对其进行签名或使用系统证书对其进行签名。 Now include the apk by writing a rule in as below in platform specific device.mk file PRODUCT_PACKAGES += \\ AppName现在通过在平台特定的 device.mk 文件PRODUCT_PACKAGES += \\ AppName编写如下规则来包含 apk

Sample mk file示例 mk 文件

LOCAL_PATH := $(call my-dir)


####################################
$(warning dont't include $(call my-dir)/Android.mk )

include $(CLEAR_VARS)
LOCAL_MODULE := <your app name>
LOCAL_MODULE_TAGS := optional
LOCAL_CERTIFICATE := PRESIGNED #If you have signed already using system key
LOCAL_PRIVILEGED_MODULE := true
LOCAL_MODULE_CLASS := APPS
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
LOCAL_SRC_FILES := $(LOCAL_MODULE).apk
#LOCAL_REQUIRED_MODULES := libnative-lib
include $(BUILD_PREBUILT)

For full privilege use android:sharedUserId="android.uid.system" in Manifest要获得完全权限,请在 Manifest 中使用android:sharedUserId="android.uid.system"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM