android中的系统应用
重點 (Top highlight)
Android’s underlying kernel is based on Linux, but it has been customized to suit Google’s directions. There is no support for the GNU libraries and it does not have a native X Windows system. Inside the Linux kernel are found drivers for the display, camera, flash memory, keypad, WiFi and audio. The Linux kernel serves as an abstraction between the hardware and the rest of the software on the phone. It also takes care of core system services like security, memory management, process management, and the network stack.
Android的基礎內核基于Linux,但已針對Google的指示進行了自定義。 不支持GNU庫,它沒有本機X Windows系統。 在Linux內核中可以找到顯示器,相機,閃存,小鍵盤,WiFi和音頻的驅動程序。 Linux內核是電話上的硬件和其余軟件之間的抽象。 它還負責核心系統服務,例如安全性,內存管理,進程管理和網絡堆棧。
Installing apps on your Android device is an absolute breeze. Just search for the app on the Play Store and click on the Install button. You can install it either as system apps or as user apps.
在您的Android設備上安裝應用程序絕對是一件輕而易舉的事。 只需在Play商店中搜索該應用,然后單擊“安裝”按鈕即可。 您可以將其安裝為系統應用程序或用戶應用程序。
什么是系統應用程序? (What is System App?)
In simple words “The App which came as pre-installed or as a system.img (AOSP system image as an android OS), called system App. System apps can easily access some platform(app-framework) level API call”.
簡而言之,“該應用是作為預安裝的或作為system.img(作為Android操作系統的AOSP系統映像)提供的,稱為系統App。 系統應用程序可以輕松訪問某些平臺(應用程序框架)級的API調用”。
System apps are pre-installed apps in the system partition with your ROM. In other words, a system app is simply an app placed under /system/app folder on an Android device.
系統應用程序是ROM在系統分區中的預安裝應用程序。 換句話說,系統應用程序就是放置在Android設備上/ system / app文件夾下的應用程序。
/system/app is a read-only folder. Android device users do not have access to this partition. Hence, users cannot directly install or uninstall apps to/from it.
/ system / app是只讀文件夾。 Android設備用戶無權訪問此分區。 因此,用戶無法直接從中安裝或卸載應用程序。
Apps such as camera, settings, messages, Google Play Store, etc. come pre-installed with the phone and manufacturers do not generally provide an option to remove such apps as this might impact the functioning of your device. If you want to remove a system app you need to root your device first.
手機預裝了相機,設置,消息,Google Play商店等應用,制造商通常不提供刪除此類應用的選項,因為這可能會影響設備的功能。 如果要刪除系統應用程序,則需要先對設備進行root用戶操作。
什么是非系統APP? (What is a Non-System APP?)
Non-system/third-party/User apps are apps downloaded from Google Play Store or sideloaded with an APK file.
非系統/第三方/用戶應用程序是從Google Play商店下載的應用程序,或側載有APK文件的應用程序。
A non-system app is installed under /data/app folder and has read, write privileges. If there are apps that you have installed but you no longer use, you can simply uninstall them to free up storage space.
非系統應用程序安裝在/ data / app文件夾下,并且具有讀取和寫入權限。 如果有已安裝但不再使用的應用程序,則只需卸載它們即可釋放存儲空間。
普通應用和系統應用之間的區別 (Difference between the normal app and system app)
A System application is NOT an application that is signed by the OS’s platform signatures. This is a common mistake believed by many and we shall come to this later on. A System application is merely an application that is placed under /system/app folder in an Android device. An application can only be installed in that folder if we have access to the OS’s ROM (system.img). The application is placed under /app folder after the ROM has been extracted. A device which loads the custom ROM will have the new System application added. The benefit of a System application is that the application cannot be removed from the device (cannot be uninstalled by the user). This is only because /system/app is a read-only folder. A non-System application is an ordinary application, which will be installed under /data/app folder, and which is read-write. A user can uninstall such applications normally from the Settings application. One can check if an application is a System application or not using “ApplicationInfo.FLAG_SYSTEM”. If the constant returns true, then the application in question is a System application.
系統應用程序不是由操作系統的平臺簽名簽名的應用程序。 這是許多人都相信的常見錯誤,我們將在稍后討論。 系統應用程序僅僅是位于Android設備中/ system / app文件夾下的應用程序 。 如果我們可以訪問操作系統的ROM(system.img),則只能將應用程序安裝在該文件夾中。 提取ROM后,該應用程序將放置在/ app文件夾下。 加載自定義ROM的設備將添加新的系統應用程序。 系統應用程序的好處是無法從設備中刪除該應用程序(用戶無法將其卸載)。 這僅是因為/ system / app是只讀文件夾。 非系統應用程序是普通應用程序,它將安裝在/ data / app文件夾下,并且是可讀寫的。 用戶可以從“設置”應用程序正常卸載此類應用程序。 可以使用“ ApplicationInfo.FLAG_SYSTEM”檢查應用程序是否為系統應用程序 。 如果常量返回true,則說明該應用程序是系統應用程序。
Permission: System apps are granted the ability to request certain system-only permissions that are never available to user apps. This is not the same as root/sudo/su permissions. One example that I know of and use daily is the ability to reset the missed call notification counter. I have Go Dialer, which is a replacement for the stock dialer and contact app (how you make phone calls). When I miss a call, android lets me know that with a notification. However, Go Dialer is not allowed to reset this counter, even though it asks for that permission when you install the app. Android 2.2 and earlier let user apps reset it, but made this permission system-only accessible permission for android 2.3
權限:系統應用程序被授予請求某些特定于系統的權限的能力,這些權限永遠不會對用戶應用程序可用。 這是不一樣的根/須藤/蘇權限。 我知道并每天使用的一個示例是重置未接來電通知計數器的功能。 我有Go Dialer,它可以代替股票撥號器和聯系人應用程序(撥打電話的方式)。 當我錯過來電時,Android會通過通知告知我。 但是,即使Go Dialer在安裝應用程序時要求該許可,也不允許重置該計數器。 Android 2.2及更早版本允許用戶應用重置它,但為Android 2.3設置了僅系統可訪問的權限
Updates: System apps can be updated just like user apps, but the update is never integrated into the original rom. That is, system apps have the unique ability to roll back to the version that existed when the rom was first installed.
更新:系統應用程序可以像用戶應用程序一樣進行更新,但是更新從未集成到原始rom中。 也就是說,系統應用程序具有獨特的功能,可以回滾到首次安裝rom時存在的版本。
Moved to SD: Android lets users move user apps from internal memory to the sd card. System apps cannot be moved and always take up some internal space. Most (all?) devices, though, have internal user apps on a different partition, so uninstalling a system app would not give you any more user app space (other than the Dalvik-cache being removed).
移至SD: Android允許用戶將user應用程序從內部存儲器移至SD卡。 系統應用程序無法移動,并且始終占用一些內部空間。 但是,大多數(所有?)設備在不同的分區上都具有內部用戶應用程序,因此,卸載系統應用程序不會給您更多的用戶應用程序空間(除了要刪除的Dalvik緩存外)。
To see the complete list of user apps in android device type below command on terminal:
要查看android設備中用戶應用的完整列表,請在終端上鍵入以下命令:
adb shell pm list packages -3To see the complete list of installed system apps type below command on the terminal:
要查看已安裝系統應用程序的完整列表,請在終端上鍵入以下命令:
adb shell pm list packages -sNote: Make sure adb installed and android device connected to the computer.
注意:確保已安裝adb,并且android設備已連接到計算機。
系統應用程序相對于用戶應用程序的優勢 (Advantages of System apps over User apps)
Google provides limited permissions on user apps. We cannot use various permissions, especially at the system level. With system apps, we can get additional permissions for our application. For example, we want to make an application that is able to install other applications (like the Google Play Store), we can get INSTALL_PACKAGES permission. We can also restart our Android device with REBOOT permissions. In addition, we can set the time on our Android system with SET_TIME permissions.
Google對用戶應用程序提供了有限的權限。 我們不能使用各種權限,尤其是在系統級別。 使用系統應用程序,我們可以獲得應用程序的其他權限。 例如,我們要制作一個能夠安裝其他應用程序的應用程序(例如Google Play商店),我們可以獲得INSTALL_PACKAGES權限。 我們還可以使用REBOOT權限重新啟動我們的Android設備。 此外,我們可以使用SET_TIME權限在Android系統上設置時間。
To see more lists of permissions on our Android device, please type the command below the computer terminal.
要查看我們的Android設備上的更多權限列表,請在計算機終端下方輸入命令。
adb shell pm list permissions -g如何制作系統應用程序? (How to make system apps?)
The mandatory thing to do with our application is to add android: sharedUserId = “android.uid.system” in the application tag in AndroidManifest.xml.
我們的應用程序必須執行的操作是添加android: sharedUserId =“ android.uid.system” 在AndroidManifest.xml的application標簽中。
Then build the APK of our Android project that is ready. After that, just place the APK file in the directory / system / app / or for Android versions of KitKat and above, it can go to the / system / priv-app / director
然后構建我們準備好的Android項目的APK。 之后,只需將APK文件放在目錄/ system / app /中,或者將Android文件安裝到KitKat及更高版本中,即可將其轉到/ system / priv-app / director
The first is to use a signing key. Signing key consists of 2 files, namely certificate (.pem) and private key (.pk8). The signing key here must be the same as the one used for signing our Android ROM. SO signing key is always specific to OEM’S(Samsung, Nokia etc.) And as I explained above, that system apps use permissions at the system level, so potentially people will create dangerous malware for Samsung devices. So keep it a secret for the trusted developer.
第一種是使用簽名密鑰。 簽名密鑰包含2個文件,即證書(.pem)和私鑰(.pk8)。 此處的簽名密鑰必須與用于簽署我們的Android ROM的密鑰相同。 SO簽名密鑰始終特定于OEM'S(三星,諾基亞等)。如上所述,系統應用程序使用系統級別的權限,因此潛在的人們可能會為三星設備創建危險的惡意軟件。 因此,對于可信任的開發人員來說,要保密。
But if we have our own custom ROM, or then we can actually get our Android ROM signing key. We can sign the APK we can use the method below. The signapk.jar file can be found here.
但是,如果我們有自己的自定義ROM,則實際上可以獲取我們的Android ROM簽名密鑰。 我們可以使用以下方法對APK進行簽名。 您可以在此處找到signapk.jar文件。
java -jar signapk.jar certificate.pem key.pk8 file-name.apk file-name-signed.apkThen install the name-file-signed.apk on your Android device as usual. The Android system will automatically recognize it as system apps because it has the same signing key as the ROM and then places it in the partition / system.
然后像往常一樣在您的Android設備上安裝name-file-signed.apk。 Android系統會自動將其識別為系統應用程序,因為它具有與ROM相同的簽名密鑰,然后將其放置在分區/系統中。
There are two ways to create system apps:
有兩種創建系統應用程序的方法:
Step 1 Create a folder inside packages/apps/ First, create a folder for your app ( Let say MyTestApp) inside packages/apps/ of your android AOSP downloaded source code. Then create a Android.mk file inside the folder(MyTestApp), and in last copy your app source code inside the folder(MyTestApp) as for example following folder and file
步驟1在packages / apps /內創建一個文件夾首先,在您的android AOSP下載源代碼的packages / apps /內為您的應用創建一個文件夾(假設為MyTestApp)。 然后在文件夾(MyTestApp)內創建一個Android.mk文件,最后在文件夾(MyTestApp)內復制您的應用程序源代碼,例如,跟隨文件夾和文件
- assets, 資產,
- build, 建立,
- res, RES,
- src and src和
- AndroidManifest.xml etc AndroidManifest.xml等
Step 2 open Android.mk file and add folowing code Snippet
第2步打開Android.mk文件并添加以下代碼段
LOCAL_PATH:= $(call my-dir)include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_UNINSTALLABLE_MODULE := true
LOCAL_MODULE_PATH := $(TARGET_OUT_APPS)
LOCAL_CERTIFICATE := platform LOCAL_SRC_FILES
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_PACKAGE_NAME := MyTestApp
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_PRIVILEGED_MODULE := true
LOCAL_STATIC_JAVA_LIBRARIES := libarity android-support-v4
include $(BUILD_PACKAGE)
include $(call all-makefiles-under,$(LOCAL_PATH))
save this mk file.
保存此mk文件。
Step 3 put your app name in build/target/product/ folder open core.mk file from build/target/product/ folder and add your app name(MyTestApp) inPRODUCT_PACKAGES tag at the bottom MyTestApp.Note:-for the specific vendor, you can find the path like this vendor/manufacturer/device/vendor_device.mk
步驟3將您的應用程序名稱放入build / target / product /文件夾中的build / target / product /文件夾中打開core.mk文件,并在MyTestApp底部的PRODUCT_PACKAGES標簽中添加您的應用程序名稱(MyTestApp)。注意:-對于特定的供應商,您可以找到此供應商/制造商/設備/vendor_device.mk的路徑
Now step by step procedure for .apk file Step 1 will be same like above only change is that in place of src, res folder just put your .apk file.
現在,.apk文件的分 步 過程 第1步將與上面相同,只是更改是在src的位置,res文件夾只是放置了.apk文件。
step 2 open Android.mk file and add folowing code Snippet
第2步打開Android.mk文件并添加以下代碼段
LOCAL_PATH := $(call my-dir)include $(CLEAR_VARS)LOCAL_MODULE_TAGS := optionalLOCAL_UNINSTALLABLE_MODULE := true
LOCAL_MODULE_PATH := $(TARGET_OUT_APPS)LOCAL_MODULE := MyTestAppLOCAL_SRC_FILES := $(LOCAL_MODULE).apkLOCAL_MODULE_CLASS := APPSLOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
# if Apk is signed then use it. Otherwise use platform
LOCAL_CERTIFICATE := PRESIGNED include $(BUILD_PREBUILT)
Step 3 will be the same as an above mention for Android source code (a)This is all about how to make an android app as a system App.
步驟3將與上述針對Android源代碼的說明相同(a)這都是關于如何將android應用制作為系統應用的信息。
If you an apk file and wants to install a system app through adb commands, in that case, we have to push the .apk to the phone to the System partition. the path of the folder is /system/app or /system/priv-app (Android 4.3) using adb
如果您是一個apk文件,并且想通過adb命令安裝系統應用程序,那么在這種情況下,我們必須將.apk推送到手機的“系統”分區中。 文件夾的路徑是使用adb的 / system / app或/ system / priv-app (Android 4.3)
adb rootadb remount
adb push <file name> .apk / system / priv-app /
adb shell chmod 644 / system / priv-app / <file name> .apk
adb reboot
If SD card, then place your apk file in sdcard like this:
如果是SD卡,則將您的apk文件放入sdcard中,如下所示:
adb push my-app.apk /sdcard/adb shell
su
cd /sdcard
mv my-app.apk /system/app
# or when using Android 4.3 or higher
mv my-app.apk /system/priv-app
Note: All System-Apps need to have the permissions rw-r — r — . So we can change them via adb with the change mode command like chmod 644 /path_to/your_file
注意:所有系統應用程序都需要具有權限rw-r — r —。 因此,我們可以使用chmod 644 / path_to / your_file等更改模式命令通過adb更改它們
In this article, I have written about the system apps. I will write some more useful articles subjected to android so to know about that please keep following and clapping if you liked it.
在本文中,我寫了有關系統應用程序的文章。 我將寫一些適用于android的更有用的文章,以便了解這一點,如果您喜歡它,請繼續關注并鼓掌。
I hope you enjoyed this session. If you have any comments or questions, please join the forum discussion below!
我希望你喜歡這次會議。 如果您有任何意見或疑問,請加入下面的論壇討論!
To have a look for other articles, PFA link:
要查看其他文章,PFA鏈接:
Thanks for the support :)
感謝您的支持 :)
Android Developers, AndroidPIT.com, Xyz Zyx, Android, The Funtasty Android Devs, Sundar Pichai, Elye, Medium Staff, Cesar Valiente, Google Developers
Android開發者 , AndroidPIT.com , 的Xyz ZYX , 安卓 , 該Funtasty Android的離散事件 , 桑德爾·皮蔡 , Elye , 中等職員 , 塞薩爾巴連特 , 谷歌開發者
翻譯自: https://android.jlelse.eu/system-app-in-android-f003d418b4cc
總結
以上是生活随笔為你收集整理的android中的系统应用的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Android 系统应用升级的坑
- 下一篇: 梦幻西游两个不同服务器的名字出现在跨服华