在Android APP开发过程中,Manifest文件举足轻重。每一个apk都要有一个Manifest文件,它配置了apk在Android系统上的基本信息。

如下 frameworks/base/packages/SystemUI/AndroidManifest.xml

        xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
        package="com.android.systemui"
        android:sharedUserId="android.uid.systemui"
        coreApp="true">


   
   
   
   
   
   


   
   
   


   
   
   
   


   
   
   
   
   
   


   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   


   
   
   
   
   
   
   
   
   
   
   
   
   


   
   
   
   
   
   
   


   
   
   


   
   


   
   
   
   
   
   
   
   
   
   
   
   
   
   


   
   


   
   


   
   


   


   
   


   
   
   
   
   


   
                android:protectionLevel="signature" />
   


   
   


            android:name=".SystemUIApplication"
        android:persistent="true"
        android:allowClearUserData="false"
        android:allowBackup="false"
        android:hardwareAccelerated="true"
        android:label="@string/app_label"
        android:icon="@drawable/icon"
        android:process="com.android.systemui"
        android:supportsRtl="true"
        android:theme="@style/systemui_theme">
       


       
                    android:exported="true"
            />


       
                    android:process=":screenshot"
            android:exported="false" />


                        android:exported="true" />


                        android:permission="android.permission.BIND_WALLPAPER"
                android:exported="true" />


       
           
               
           

       



                        androidprv:primaryUserOnly="true">
           
               
           

       



                          android:label="@*android:string/usb_storage_activity_title"
                  android:excludeFromRecents="true">
       


                          android:enabled="false"
                  android:icon="@drawable/tuner"
                  android:theme="@android:style/Theme.Material.Settings"
                  android:label="@string/system_ui_tuner"
                  android:process=":tuner"
                  android:exported="true">
           
               
               
           

                                android:value="com.android.settings.category.system" />
       


       
                          android:label="@string/accessibility_desc_recent_apps"
                  android:exported="false"
                  android:launchMode="singleInstance"
                  android:excludeFromRecents="true"
                  android:stateNotNeeded="true"
                  android:resumeWhilePausing="true"
                  android:screenOrientation="behind"
                  android:theme="@style/config_recents_activity_theme">
           
               
           

       


                          android:exported="false">
           
               
               
               
               
               
           

       



       
                          android:process=":screenshot"
                  android:exported="false" />


       
                          android:process=":screenshot"
                  android:exported="false" />


       
                    android:exported="true"
            android:permission="android.permission.MANAGE_USB"
            android:theme="@style/Theme.SystemUI.Dialog.Alert"
            android:finishOnCloseSystemDialogs="true"
            android:excludeFromRecents="true">
       


       
                    android:exported="true"
            android:permission="android.permission.MANAGE_USB"
            android:theme="@style/Theme.SystemUI.Dialog.Alert"
            android:finishOnCloseSystemDialogs="true"
            android:excludeFromRecents="true">
       


       
                    android:exported="true"
            android:permission="android.permission.MANAGE_USB"
            android:theme="@style/Theme.SystemUI.Dialog.Alert"
            android:finishOnCloseSystemDialogs="true"
            android:excludeFromRecents="true">
       


       
                    android:exported="true"
            android:permission="android.permission.MANAGE_USB"
            android:theme="@style/Theme.SystemUI.Dialog.Alert"
            android:finishOnCloseSystemDialogs="true"
            android:excludeFromRecents="true">
       


       
                    android:permission="android.permission.MANAGE_USB"
            android:theme="@style/Theme.SystemUI.Dialog.Alert"
            android:finishOnCloseSystemDialogs="true"
            android:excludeFromRecents="true">
       
                    android:theme="@style/Theme.SystemUI.Dialog.Alert"
            android:finishOnCloseSystemDialogs="true"
            android:excludeFromRecents="true">
       


       
                    android:name=".net.NetworkOverLimitActivity"
            android:exported="true"
            android:permission="android.permission.MANAGE_NETWORK_POLICY"
            android:theme="@android:style/Theme.DeviceDefault.Light.Panel"
            android:finishOnCloseSystemDialogs="true"
            android:launchMode="singleTop"
            android:taskAffinity="com.android.systemui.net"
            android:excludeFromRecents="true" />


       
                    android:name=".media.MediaProjectionPermissionActivity"
            android:exported="true"
            android:theme="@style/Theme.AlertDialogHost"
            android:finishOnCloseSystemDialogs="true"
            android:launchMode="singleTop"
            android:excludeFromRecents="true" />


       
                    android:name=".DessertCase"
            android:exported="true"
            android:label="@string/dessert_case"
            android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
            android:hardwareAccelerated="true"
            android:launchMode="singleInstance"
            android:screenOrientation="locked"
            android:process=":sweetsweetdesserts"
            android:excludeFromRecents="true">
           
               
               
           

       


                          android:theme="@android:style/Theme.Material.NoActionBar"
                  android:exported="true"
                  android:icon="@drawable/icon"
                  android:label="@string/mland"
                  android:hardwareAccelerated="true"
                  android:launchMode="singleInstance"
                  android:screenOrientation="locked"
                  android:process=":sweetsweetdesserts"
                  android:excludeFromRecents="true">
           
               
               
               
           

       


       
                    android:name=".DessertCaseDream"
            android:exported="true"
            android:label="@string/dessert_case"
            android:permission="android.permission.BIND_DREAM_SERVICE"
            android:enabled="false"
            android:process=":sweetsweetdesserts"
            >
           
               
               
           

       



                    android:name=".keyguard.KeyguardService"
            android:exported="true"
            android:enabled="@bool/config_enableKeyguardService" />


                    android:label="@string/start_dreams"
            android:icon="@mipmap/ic_launcher_dreams"
            android:theme="@android:style/Theme.Wallpaper.NoTitleBar"
            android:exported="true"
            android:excludeFromRecents="true"
            >
           
           
               
               
               
           

       


                    android:name=".settings.BrightnessDialog"
            android:label="@string/quick_settings_brightness_dialog_title"
            android:theme="@android:style/Theme.DeviceDefault.Dialog"
            android:finishOnCloseSystemDialogs="true"
            android:launchMode="singleInstance"
            android:excludeFromRecents="true"
            android:exported="true">
           
               
               
           

       


       
                    android:name=".doze.DozeService"
            android:exported="true"
            android:singleUser="true"
            android:permission="android.permission.BIND_DREAM_SERVICE" />
       
                    android:name="com.mediatek.systemui.floatpanel.FloatWindowProvider"
            android:authorities="com.android.systemui.floatwindow"
            android:exported="true" />
         
           
               
               
               
               
               
           

           
               
           

       



                    android:name=".tuner.TunerService$ClearReceiver"
            android:exported="false">
           
               
           

       
   



 1,manifest标签和其自身的属性

Manifest文件是标准xml文件,是其根标签,所有文件内容都要包含在这个标签中。

xmlns:android

这个表示xml中要用到的名空间,这个名空间定义了所有android相关的关键字,例如android:name,android:process。

名空间定义了xml中的合法标签,是XML语言的范畴,此处就不细说了。

xmlns:androidprv

与xmlns:android一样,说明androidprv相关的名字会被用到。这里之所以引用这个,是因为这个android应用程序的配置中用到了以androidprv:primaryUserOnly命名的属性。

package="com.android.systemui"

由于android的应用程序是Java书写,manifest通过这个属性直接指明此应用程序对应的Java package包。

android:sharedUserId="android.uid.systemui"

Android为每个应用程序分配一个用户ID,通过这个标识应用程序。如果两个应用拥有相同的UserID,它们就能够互相访问对方的数据,如果需要,还可以运行在同样的进程中。SytemUI声明自己的ID就是“android.uid.systemui”。也就是说,如果要编写一个应用程序,需要访问systemui这个应用程序的数据,那么在他的manifest标签中,配置同样的属性就可以了。当然,还有另外的方法,就是使用uses-permission标签,会在下面介绍。

coreApp="true"

    标识systemui是coreApp中的一个,coreApp是android在bootmode下系统启动的最小子集。在这个模式下,有一组最少的,必须的app需要启动,systemui就是其中之一。

2, 下面分别看标签中包含的两个tag,一个是,另外一个是

上面描述android:sharedUserId提到,每个android应用程序都有一个唯一的ID来标识自己。这个ID也是一个安全壁垒,可以让每个应用的数据只能被自己所访问。

除了android:sharedUserId之外,还有一个机制就是permission。如果应用程序想对自己的数据加以保护,则可以用android:permission这个配置项来声明,而使用者,则需要用uses-permission来声明。

在这里,SystemUI应用程序说明它要用使用android.permission.RECEIVE_BOOT_COMPLETED,也就是SystemUI会在系统启动完成的时候收到通知,如果没有这个声明,就收不到通知。

同样,表明SystemUI可以访问蓝牙。

   

        android:name=".SystemUIApplication"
        android:persistent="true"
        android:allowClearUserData="false"
        android:allowBackup="false"
        android:hardwareAccelerated="true"
        android:label="@string/app_label"
        android:icon="@drawable/icon"
        android:process="com.android.systemui"
        android:supportsRtl="true"
        android:theme="@style/systemui_theme">

application模块定义一个应用程序的基本配置。应用程序是Android上的基本运行单位,每个程序都拥有一个独立的Linux ID。


android:persistent="true"

这个属性指定systemUI会在启动后一直运行下去。如果这个标记为false,则这个应用程序会被系统在资源匮乏的时候回收。大部分应用程序都是不会被设置为true的,而systemUI是一个系统程序,所以被设置为true。

android:allowClearUserData和android:allowBackup

标记应用程序的data是否允许被用户清除,这个会在BackupManagerService.java中用到。

android:allowBackup标记是否允许一个应用使用backup机制。

Androidbackup机制允许用户通过backup manager将应用程序的相关数据存储到云端,当手机被重置或者程序重新安装之后,原来backup的数据可以从云端取回,不会丢失。

android:hardwareAccelerated="true"

使用硬件加速

Android的每个版本都会增加一些功能,而为了使得新功能不引入意想不到的麻烦,就需要将这个功能能够开关,就要加入相应的标记。android:hardwareAccelerated就是之一,Android3.0引入了这个功能。

android:supportsRtl

这是Android4.1引入的一个功能,能够让排版支持从右到左,例如阿拉伯语。

3,在内部,是Android应用程序的主要部分,可以包含四大组件,每个组件都包含很多配置属性,这里不再详述,仅仅列举其中的一个来看

               android:label="@string/accessibility_desc_recent_apps"

               android:theme="@style/RecentsStyle"

               android:excludeFromRecents="true"

               android:launchMode="singleInstance"

                android:exported="true">

android:name

是AndroidManifest与Java程序的一个桥梁,通过它,指定Java程序的执行类。

android:theme

theme就是能够应用于所有Activity或者application的显示风格。这是Android显示机制中的一个概念。

android:excludeFromRecents

如果这个Activity是一个新进程的根Activity,设置此标记为'true'则表示通过这个Activity启动的任务是否会排除在”recent apps” 之外。所谓recent apps,就是长按Home键,会通过一个list显示最近访问的app。

同样,如果你不想让你的进程显示在其中,则可以置这个属性为true.

android:launchMode="singleInstance"

说明这个Activity是独占一个任务的,而且这个任务不能有其他的Activity存在。也可以看到,SystemUI中所有的Activity都是独占模式打开的。

android:exported="true"

这个属性用于指示该服务是否能够被其他应用程序组件调用或跟它交互。现在设置为true,说明它能够被其他应用程序调用。

4,小结

通过这个manifest文件,可以初步了解systemUI是android平台的一个核心应用程序,它一旦启动,就会长久运行下去。它的所有component都拥有独占的任务。这个应用程序的所有数据不会被备份到云端。

在systemui的进程中,会运行多个components。其中有一个recentActivity,也是运行在他的进程中,这个Activity不会出现在rencent list中。



更多相关文章

  1. Android ScrollView去掉滚动条及ScrollView属性
  2. [置顶] 安卓开发-标签总结
  3. android webview css z-index属性无效

随机推荐

  1. android Linearlayout中有关gravity与lay
  2. 【Arcgis for android】保存地图截图到sd
  3. android 缓存Bitmap
  4. android XML下searchable.xml
  5. Android UI开发第三十三篇——Navigation
  6. [小代码]在Android和PHP之间的加密/解密,
  7. android AudioManager类 详解
  8. android 使用Intent传递数据之剪切板
  9. Android获取运营商代码
  10. Android(安卓)中如何复制文件的操作