android中的系统应用
重點(diǎn) (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的基礎(chǔ)內(nèi)核基于Linux,但已針對Google的指示進(jìn)行了自定義。 不支持GNU庫,它沒有本機(jī)X Windows系統(tǒng)。 在Linux內(nèi)核中可以找到顯示器,相機(jī),閃存,小鍵盤,WiFi和音頻的驅(qū)動程序。 Linux內(nèi)核是電話上的硬件和其余軟件之間的抽象。 它還負(fù)責(zé)核心系統(tǒng)服務(wù),例如安全性,內(nèi)存管理,進(jìn)程管理和網(wǎng)絡(luò)堆棧。
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設(shè)備上安裝應(yīng)用程序絕對是一件輕而易舉的事。 只需在Play商店中搜索該應(yīng)用,然后單擊“安裝”按鈕即可。 您可以將其安裝為系統(tǒng)應(yīng)用程序或用戶應(yīng)用程序。
什么是系統(tǒng)應(yīng)用程序? (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”.
簡而言之,“該應(yīng)用是作為預(yù)安裝的或作為system.img(作為Android操作系統(tǒng)的AOSP系統(tǒng)映像)提供的,稱為系統(tǒng)App。 系統(tǒng)應(yīng)用程序可以輕松訪問某些平臺(應(yīng)用程序框架)級的API調(diào)用”。
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.
系統(tǒng)應(yīng)用程序是ROM在系統(tǒng)分區(qū)中的預(yù)安裝應(yīng)用程序。 換句話說,系統(tǒng)應(yīng)用程序就是放置在Android設(shè)備上/ system / app文件夾下的應(yīng)用程序。
/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設(shè)備用戶無權(quán)訪問此分區(qū)。 因此,用戶無法直接從中安裝或卸載應(yīng)用程序。
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.
手機(jī)預(yù)裝了相機(jī),設(shè)置,消息,Google Play商店等應(yīng)用,制造商通常不提供刪除此類應(yīng)用的選項,因?yàn)檫@可能會影響設(shè)備的功能。 如果要刪除系統(tǒng)應(yīng)用程序,則需要先對設(shè)備進(jìn)行root用戶操作。
什么是非系統(tǒng)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.
非系統(tǒng)/第三方/用戶應(yīng)用程序是從Google Play商店下載的應(yīng)用程序,或側(cè)載有APK文件的應(yīng)用程序。
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.
非系統(tǒng)應(yīng)用程序安裝在/ data / app文件夾下,并且具有讀取和寫入權(quán)限。 如果有已安裝但不再使用的應(yīng)用程序,則只需卸載它們即可釋放存儲空間。
普通應(yīng)用和系統(tǒng)應(yīng)用之間的區(qū)別 (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.
系統(tǒng)應(yīng)用程序不是由操作系統(tǒng)的平臺簽名簽名的應(yīng)用程序。 這是許多人都相信的常見錯誤,我們將在稍后討論。 系統(tǒng)應(yīng)用程序僅僅是位于Android設(shè)備中/ system / app文件夾下的應(yīng)用程序 。 如果我們可以訪問操作系統(tǒng)的ROM(system.img),則只能將應(yīng)用程序安裝在該文件夾中。 提取ROM后,該應(yīng)用程序?qū)⒎胖迷?strong>/ app文件夾下。 加載自定義ROM的設(shè)備將添加新的系統(tǒng)應(yīng)用程序。 系統(tǒng)應(yīng)用程序的好處是無法從設(shè)備中刪除該應(yīng)用程序(用戶無法將其卸載)。 這僅是因?yàn)?strong>/ system / app是只讀文件夾。 非系統(tǒng)應(yīng)用程序是普通應(yīng)用程序,它將安裝在/ data / app文件夾下,并且是可讀寫的。 用戶可以從“設(shè)置”應(yīng)用程序正常卸載此類應(yīng)用程序。 可以使用“ ApplicationInfo.FLAG_SYSTEM”檢查應(yīng)用程序是否為系統(tǒng)應(yīng)用程序 。 如果常量返回true,則說明該應(yīng)用程序是系統(tǒng)應(yīng)用程序。
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
權(quán)限:系統(tǒng)應(yīng)用程序被授予請求某些特定于系統(tǒng)的權(quán)限的能力,這些權(quán)限永遠(yuǎn)不會對用戶應(yīng)用程序可用。 這是不一樣的根/須藤/蘇權(quán)限。 我知道并每天使用的一個示例是重置未接來電通知計數(shù)器的功能。 我有Go Dialer,它可以代替股票撥號器和聯(lián)系人應(yīng)用程序(撥打電話的方式)。 當(dāng)我錯過來電時,Android會通過通知告知我。 但是,即使Go Dialer在安裝應(yīng)用程序時要求該許可,也不允許重置該計數(shù)器。 Android 2.2及更早版本允許用戶應(yīng)用重置它,但為Android 2.3設(shè)置了僅系統(tǒng)可訪問的權(quán)限
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.
更新:系統(tǒng)應(yīng)用程序可以像用戶應(yīng)用程序一樣進(jìn)行更新,但是更新從未集成到原始rom中。 也就是說,系統(tǒng)應(yīng)用程序具有獨(dú)特的功能,可以回滾到首次安裝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應(yīng)用程序從內(nèi)部存儲器移至SD卡。 系統(tǒng)應(yīng)用程序無法移動,并且始終占用一些內(nèi)部空間。 但是,大多數(shù)(所有?)設(shè)備在不同的分區(qū)上都具有內(nèi)部用戶應(yīng)用程序,因此,卸載系統(tǒng)應(yīng)用程序不會給您更多的用戶應(yīng)用程序空間(除了要刪除的Dalvik緩存外)。
To see the complete list of user apps in android device type below command on terminal:
要查看android設(shè)備中用戶應(yīng)用的完整列表,請在終端上鍵入以下命令:
adb shell pm list packages -3To see the complete list of installed system apps type below command on the terminal:
要查看已安裝系統(tǒng)應(yīng)用程序的完整列表,請在終端上鍵入以下命令:
adb shell pm list packages -sNote: Make sure adb installed and android device connected to the computer.
注意:確保已安裝adb,并且android設(shè)備已連接到計算機(jī)。
系統(tǒng)應(yīng)用程序相對于用戶應(yīng)用程序的優(yōu)勢 (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對用戶應(yīng)用程序提供了有限的權(quán)限。 我們不能使用各種權(quán)限,尤其是在系統(tǒng)級別。 使用系統(tǒng)應(yīng)用程序,我們可以獲得應(yīng)用程序的其他權(quán)限。 例如,我們要制作一個能夠安裝其他應(yīng)用程序的應(yīng)用程序(例如Google Play商店),我們可以獲得INSTALL_PACKAGES權(quán)限。 我們還可以使用REBOOT權(quán)限重新啟動我們的Android設(shè)備。 此外,我們可以使用SET_TIME權(quán)限在Android系統(tǒng)上設(shè)置時間。
To see more lists of permissions on our Android device, please type the command below the computer terminal.
要查看我們的Android設(shè)備上的更多權(quán)限列表,請在計算機(jī)終端下方輸入命令。
adb shell pm list permissions -g如何制作系統(tǒng)應(yīng)用程序? (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.
我們的應(yīng)用程序必須執(zhí)行的操作是添加android: sharedUserId =“ android.uid.system” 在AndroidManifest.xml的application標(biāo)簽中。
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
然后構(gòu)建我們準(zhǔn)備好的Android項目的APK。 之后,只需將APK文件放在目錄/ system / app /中,或者將Android文件安裝到KitKat及更高版本中,即可將其轉(zhuǎn)到/ 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(三星,諾基亞等)。如上所述,系統(tǒng)應(yīng)用程序使用系統(tǒng)級別的權(quán)限,因此潛在的人們可能會為三星設(shè)備創(chuàng)建危險的惡意軟件。 因此,對于可信任的開發(fā)人員來說,要保密。
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,則實(shí)際上可以獲取我們的Android ROM簽名密鑰。 我們可以使用以下方法對APK進(jìn)行簽名。 您可以在此處找到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設(shè)備上安裝name-file-signed.apk。 Android系統(tǒng)會自動將其識別為系統(tǒng)應(yīng)用程序,因?yàn)樗哂信cROM相同的簽名密鑰,然后將其放置在分區(qū)/系統(tǒng)中。
There are two ways to create system apps:
有兩種創(chuàng)建系統(tǒng)應(yīng)用程序的方法:
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 /內(nèi)創(chuàng)建一個文件夾首先,在您的android AOSP下載源代碼的packages / apps /內(nèi)為您的應(yīng)用創(chuàng)建一個文件夾(假設(shè)為MyTestApp)。 然后在文件夾(MyTestApp)內(nèi)創(chuàng)建一個Android.mk文件,最后在文件夾(MyTestApp)內(nèi)復(fù)制您的應(yīng)用程序源代碼,例如,跟隨文件夾和文件
- assets, 資產(chǎn),
- 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將您的應(yīng)用程序名稱放入build / target / product /文件夾中的build / target / product /文件夾中打開core.mk文件,并在MyTestApp底部的PRODUCT_PACKAGES標(biāo)簽中添加您的應(yīng)用程序名稱(MyTestApp)。注意:-對于特定的供應(yīng)商,您可以找到此供應(yīng)商/制造商/設(shè)備/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.
現(xiàn)在,.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)這都是關(guān)于如何將android應(yīng)用制作為系統(tǒng)應(yīng)用的信息。
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命令安裝系統(tǒng)應(yīng)用程序,那么在這種情況下,我們必須將.apk推送到手機(jī)的“系統(tǒng)”分區(qū)中。 文件夾的路徑是使用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
注意:所有系統(tǒng)應(yīng)用程序都需要具有權(quán)限r(nóng)w-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.
在本文中,我寫了有關(guān)系統(tǒng)應(yīng)用程序的文章。 我將寫一些適用于android的更有用的文章,以便了解這一點(diǎn),如果您喜歡它,請繼續(xù)關(guān)注并鼓掌。
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開發(fā)者 , AndroidPIT.com , 的Xyz ZYX , 安卓 , 該Funtasty Android的離散事件 , 桑德爾·皮蔡 , Elye , 中等職員 , 塞薩爾巴連特 , 谷歌開發(fā)者
翻譯自: https://android.jlelse.eu/system-app-in-android-f003d418b4cc
總結(jié)
以上是生活随笔為你收集整理的android中的系统应用的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Android 系统应用升级的坑
- 下一篇: 梦幻西游两个不同服务器的名字出现在跨服华