Developed and built-in App with system permissions (system) (Android10)

I. Introduction

       In the Android system, ordinary apps that we usually develop and install cannot access some resources and functions of the system due to permission restrictions. For example, you can't kill other apps, develop airplane mode, set screen timeout, change debug mode, etc. in ordinary apps. In the process of system customization, if you want your own developed app to have more superpowers, you need to upgrade your app to system permissions. Once you have the system permissions, the app will be the same as the system's app "settings", with super powers to do many things related to the control system.

2. Develop apps with system permissions

Use Android Studio to create a project, and then add the following configuration to the AndroidManifest.xml file:

android:sharedUserId="android.uid.system"

The following is my personal configuration:

image

 

After the configuration is complete, the required functions are developed and packaged into an apk. Then built into the phone. Built-in apk to mobile phone system reference:

Fun Android10 source code development and customization (eight) built-in Apk to the system

Three, some precautions in the process of developing built-in

 

1. After the  app project is configured "android:sharedUserId="android.uid.system"", it cannot be directly installed on the phone for testing. You can comment it out before installing and testing it. Configure and package the apk.

 

2. When it is  built in, Android.mk needs to configure the LOCAL_CERTIFICATE signature mode as platform, otherwise the app will not run with system permission after it is built. The following is one of my configuration

# ///ADD START
# ///ADD END
# 设置当前工作路径
LOCAL_PATH:= $(call my-dir)

# 清除变量值
include $(CLEAR_VARS)
# 生成的模块名称
LOCAL_MODULE := SecurityManager

# 生成的模块类型
LOCAL_MODULE_CLASS := APPS
# 生成的模块后缀名,此处为apk
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
# 设置模块tag,tags取值可以为:user debug eng tests optional
# optional表示全平台编译
LOCAL_MODULE_TAGS := optional

LOCAL_BUILT_MODULE_STEM := package.apk

# 设置源文件
LOCAL_SRC_FILES := $(LOCAL_MODULE).apk
# 这个地方非常重要,需要配置为platform平台签名方式
LOCAL_CERTIFICATE := platform
# 此处表示预编译方式
include $(BUILD_PREBUILT)

 

Previous articlePlay with Android10 source code development and customization (16) The system of compiling user mode in LineageOS

 

The big guys keep a concern before leaving, and follow-up wonderful articles continueimage

image

Guess you like

Origin blog.csdn.net/u011426115/article/details/112855801