1. 在应用程序的AndroidManifest.xml中的manifest节点中加入android:sharedUserId="android.uid.system"这个属性。
2. 修改Android.mk文件,加入LOCAL_CERTIFICATE := platform这一行
3. 使用mm命令来编译,生成的apk就有system权限了
将 工程目录拷贝到:
packages/apps/
进入添加Android.mk文件
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_PACKAGE_NAME := Wifi_Test1
LOCAL_CERTIFICATE := platform
include $(BUILD_PACKAGE)
# Use the folloing include to make our test apk.
include $(call all-makefiles-under,$(LOCAL_PATH))
修改 AndroidManifest.xml
添加:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.wpstar.Wifi_Test1"
android:versionCode="1"
android:sharedUserId="android.uid.system"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />
目录下运行 mm
则:
Copying: out/target/common/obj/APPS/Wifi_Test1_intermediates/classes-jarjar.jar
Copying: out/target/common/obj/APPS/Wifi_Test1_intermediates/emma_out/lib/classes-jarjar.jar
Copying: out/target/common/obj/APPS/Wifi_Test1_intermediates/classes.jar
Copying: out/target/common/obj/APPS/Wifi_Test1_intermediates/noproguard.classes.jar
target Dex: Wifi_Test1
Copying: out/target/common/obj/APPS/Wifi_Test1_intermediates/noproguard.classes.dex
target Package: Wifi_Test1 (out/target/product/generic/obj/APPS/Wifi_Test1_intermediates/package.apk)
Warning: AndroidManifest.xml already defines versionCode (in ); using existing value in manifest.
Warning: AndroidManifest.xml already defines versionName (in ); using existing value in manifest.
Warning: AndroidManifest.xml already defines minSdkVersion (in ); using existing value in manifest.
'out/target/common/obj/APPS/Wifi_Test1_intermediates//classes.dex' as 'classes.dex'...
Install: out/target/product/generic/system/app/Wifi_Test1.apk
安装成功..
运行后:
查看进程::
system 1618 1134 72084 16956 ffffffff afd0c51c S com.wpstar.Wifi_Test1