今天开始launcher2分析系列,Launcher2的代码路径为:$ANDROID_SRC/packages/apps/Launcher2

项目构成:
AndroidManifest.xml         项目Launcher2的描述文件
CleanSpec.mk                android项目授权文件?
NOTICE                      apache授权协议
Android.mk                  Launcher2编译的makefile
MODULE_LICENSE_APACHE2  空文件
proguard.flags          -keep clashh
res目录                 描述文件以及icon资源的位置
src目录                     源代码目录
先看AndroidManifest.xml文件,该文件是对Launcher2的配置文件

<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 2008, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<manifest
    xmlns:android="http://schemas.android.com/apk/res/android"

    package="com.android.launcher"
    android:sharedUserId="@string/sharedUserId"
    >
<!--package配置我们应用程序的包名 -->
    <original-package android:name="com.android.launcher2" />
<!--对系统资源访问的权限控制 -->
    <permission
        android:name="com.android.launcher.permission.INSTALL_SHORTCUT"
        android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
        android:protectionLevel="normal"
        android:label="@string/permlab_install_shortcut"
        android:description="@string/permdesc_install_shortcut" />
    <permission
        android:name="com.android.launcher.permission.UNINSTALL_SHORTCUT"
        android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
        android:protectionLevel="normal"
        android:label="@string/permlab_uninstall_shortcut"
        android:description="@string/permdesc_uninstall_shortcut"/>
    <permission
        android:name="com.android.launcher.permission.READ_SETTINGS"
        android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
        android:protectionLevel="normal"
        android:label="@string/permlab_read_settings"
        android:description="@string/permdesc_read_settings"/>
    <permission
        android:name="com.android.launcher.permission.WRITE_SETTINGS"
        android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
        android:protectionLevel="normal"
        android:label="@string/permlab_write_settings"
        android:description="@string/permdesc_write_settings"/>

<uses-permission android:name="android.permission.CALL_PHONE" />
    <uses-permission android:name="android.permission.EXPAND_STATUS_BAR" />
    <uses-permission android:name="android.permission.GET_TASKS" />
    <uses-permission android:name="android.permission.READ_CONTACTS"/>
    <uses-permission android:name="android.permission.SET_WALLPAPER" />
    <uses-permission android:name="android.permission.SET_WALLPAPER_HINTS" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.WRITE_SETTINGS" />
    <uses-permission android:name="android.permission.BIND_APPWIDGET" />
    <uses-permission android:name="com.android.launcher.permission.READ_SETTINGS" />
    <uses-permission android:name="com.android.launcher.permission.WRITE_SETTINGS"/>
    <!--对我们应用程序的配置 -->
    <application
        android:name="com.android.launcher2.LauncherApplication"
        android:process="@string/process"
        android:label="@string/application_name"
        android:icon="@drawable/ic_launcher_home">

    <!--配置应用程序额的名字,进程,标签,和图标

        label的值为values/strings.xml中application_name 键值对的值

        icon为drawable目录下名为的ic_launcher_home的图片

        实际上该图片的位置位于drawable-hdpi(高分辨率)目录下,是个小房子

    -->

<activity
            android:name="com.android.launcher2.Launcher"
            android:launchMode="singleTask"
            android:clearTaskOnLaunch="true"
            android:stateNotNeeded="true"
            android:theme="@style/Theme"
            android:screenOrientation="nosensor"
            android:windowSoftInputMode="stateUnspecified|adjustPan">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.HOME" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.MONKEY"/>
            </intent-filter>
        </activity>
 <!--一个项目可能有很多activity,设置intent-filter可以先启动该activity -->
        <activity
            android:name="com.android.launcher2.WallpaperChooser"
            android:label="@string/pick_wallpaper"
            android:icon="@drawable/ic_launcher_wallpaper"
            android:screenOrientation="nosensor"
            android:finishOnCloseSystemDialogs="true">
            <intent-filter>
                <action android:name="android.intent.action.SET_WALLPAPER" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
 <!--设置wallpapaer的activity -->
        <!-- Intent received used to install shortcuts from other applications -->
        <receiver
            android:name="com.android.launcher2.InstallShortcutReceiver"
            android:permission="com.android.launcher.permission.INSTALL_SHORTCUT">
            <intent-filter>
                <action android:name="com.android.launcher.action.INSTALL_SHORTCUT"/>
            </intent-filter>
        </receiver>
 <!--安装快捷方式的intent -->
        <!-- Intent received used to uninstall shortcuts from other applications -->
        <receiver
            android:name="com.android.launcher2.UninstallShortcutReceiver"
            android:permission="com.android.launcher.permission.UNINSTALL_SHORTCUT">
            <intent-filter>
                <action android:name="com.android.launcher.action.UNINSTALL_SHORTCUT" />
            </intent-filter>
        </receiver>
 <!--设置删除快捷方式的intent -->
        <!-- The settings provider contains Home -->

好吧,现在我们来看res目录里的布局文件,布局文件都放在layout*目录里。
本以为launcher的layout都放在layout目录里,由于屏幕放置方式的不同会对桌面造成一定的影响,所以google的android项目组就决定因地制宜。比如当你横着放置屏幕的时候就会使用layout-land目录里的文件来对系统launcher进行布局,竖着屏幕的时候会使用layout-port内的布局文件来对launcher来布局。
横竖屏幕切换之际,会重新进行布局。那我们就以layout-land目录为例来看吧。
layout-land/launcuer.xml

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2007 The Android Open Source Project

Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at
  
          http://www.apache.org/licenses/LICENSE-2.0
  
     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->

<com.android.launcher2.DragLayer
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher"

android:id="@+id/drag_layer"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

<include layout="@layout/all_apps" />

<!-- The workspace contains 3 screens of cells -->
    <com.android.launcher2.Workspace
        android:id="@+id/workspace"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scrollbars="horizontal"
        android:fadeScrollbars="true"
        launcher:defaultScreen="2">
    <!-- 上面这行可以确定屏幕横放时默认的桌面号 -->
        <include android:id="@+id/cell1" layout="@layout/workspace_screen" />
        <include android:id="@+id/cell2" layout="@layout/workspace_screen" />
        <include android:id="@+id/cell3" layout="@layout/workspace_screen" />
        <include android:id="@+id/cell4" layout="@layout/workspace_screen" />
        <include android:id="@+id/cell5" layout="@layout/workspace_screen" />
    </com.android.launcher2.Workspace>
<!-- 上面这几行描述了几个工作区的屏幕,描述代码为layout-land/workspace_screen

      而模拟器上能看到左右各两个小白点可以控制工作区的移动

-->

<!-- 应该对应的是ClippedImageView类-->
    <com.android.launcher2.ClippedImageView
        android:id="@+id/previous_screen"
        android:layout_width="93dip"
        android:layout_height="@dimen/button_bar_height"
        android:layout_gravity="bottom|left"
        android:layout_marginLeft="6dip"

android:scaleType="center"
        android:src="@drawable/home_arrows_left"
        
        android:onClick="previousScreen"

launcher:ignoreZone="56dip"

android:focusable="true"
        android:clickable="true" />
<!-- 定义了previousScreen 按钮,即左下脚的白色小点,用来控制移动-->
    <com.android.launcher2.ClippedImageView
        android:id="@+id/next_screen"
        android:layout_width="93dip"
        android:layout_height="@dimen/button_bar_height"
        android:layout_gravity="bottom|right"
        android:layout_marginRight="6dip"

android:scaleType="center"
        android:src="@drawable/home_arrows_right"
        
        android:onClick="nextScreen"
        
        launcher:ignoreZone="-56dip"
        
        android:focusable="true"
        android:clickable="true" />
<!-- 底部右边的两个白色小点 -->
    <com.android.launcher2.DeleteZone
        android:id="@+id/delete_zone"
        android:layout_width="@dimen/delete_zone_size"
        android:layout_height="@dimen/delete_zone_size"
        android:paddingLeft="@dimen/delete_zone_padding"
        android:layout_marginBottom="@dimen/half_status_bar_height"
        android:layout_gravity="right|center_vertical"

android:scaleType="center"
        android:src="@drawable/delete_zone_selector"
        android:visibility="invisible"
        launcher:direction="vertical"
        />
<!-- 定义Trash放置的位置 右侧,中间平放-->
    <RelativeLayout
        android:id="@+id/all_apps_button_cluster"
        android:layout_height="fill_parent"
        android:layout_width="@dimen/button_bar_height_portrait"
        android:layout_gravity="right|center_vertical"
        android:layout_marginBottom="@dimen/half_status_bar_height"
        >
<!-- 定义右侧 靠近屏幕边缘的三个按钮,中间一个是all-apps

之下是phone按钮,之上是浏览器按钮,绑定响应函数

-->
        <com.android.launcher2.HandleView
            style="@style/HotseatButton"
            android:id="@+id/all_apps_button"
            android:layout_centerVertical="true"
            android:layout_alignParentRight="true"

android:src="@drawable/all_apps_button"
            launcher:direction="vertical"
            />

<ImageView
            android:id="@+id/hotseat_left"
            style="@style/HotseatButton.Left"
            android:layout_below="@id/all_apps_button"

android:src="@drawable/hotseat_phone"

android:onClick="launchHotSeat"
            />
<!-- onClick的值为响应方法-->
        <ImageView
            android:id="@+id/hotseat_right"
            style="@style/HotseatButton.Right"
            android:layout_above="@id/all_apps_button"

android:src="@drawable/hotseat_browser"

android:onClick="launchHotSeat"
            />
<!-- 对浏览器进行的描述-->
    </RelativeLayout>
</com.android.launcher2.DragLayer>

转载于:https://www.cnblogs.com/greywolf/archive/2012/12/24/2831342.html

manifest分析相关推荐

  1. android短信安全,[原创]分析了一款android短信木马

    2014-2-20 09:56 本地整合了一些分析工具整合了,大部分是androguard,一些manifest分析和droidbox. 诸葛建伟他们参与的核高基项目中貌似用到intent fuzz, ...

  2. Windows COM 免注册 manifest 清单文件

    一.原理 XP以上的操作系统支持COM免注册技术,操作系统在加载EXE时会自动扫描是否包含配套的manifest信息,若有则读取manifest内容加载组件,否则读取注册表. manifest描述了E ...

  3. Android 详解第三方介质交互之NFC,并且实现读你的交通卡,酒店房卡,学生证!

    转载请注明出处王亟亟的大牛之路 最近一段时间都在自己学习啊,看看东西敲敲代码什么的,熟悉业务逻辑啊之类的,因为刚跳槽,外加又不怎么忙,所以就还算时间蛮多的,自己利用呗,昨天被老大问有没有做过NFC.. ...

  4. MobSF移动安全检测框架简述

    移动安全分析框架 (MobSF) 是一个智能的.集成型的.开源移动App(安卓/iOS)自动检测框架,能用于静态检测和动态检测.该框架可以进行高效迅速的移动应用安全分析.文章将介绍MobSF的使用指南 ...

  5. Android调试--创建文件失败(设置了权限)

    背景 真机调试:小米4:系统Android6.0.1:API版本号23. 下午在学习文件的建立,建立N久,查了很多资料都没找到. 看了一些资料说设置权限,实际上大多是说下面那条语句没有添加,但是我是添 ...

  6. 锐浪报表 Grid++Report 免注册DLL C/S报表开发(一)

    Grid++Report报表,传统的发送方式,除了发布程序以外外,还要为客户注册DLL.由于,多数客户已经使用Win10,Win10在注册Dll时,对权限要求比较严,客户自己注册比较困难,使得软件发布 ...

  7. Android APK 签名文件MANIFEST.MF、CERT.SF、CERT.RSA分析

    首先我们找一个已经签名的apk文件,修改后缀名为zip,然后解压.可以看到里面有一个META-INF文件夹,里面就是签名验证的文件.有三个文件MANIFEST.MF.CERT.SF.CERT.RSA分 ...

  8. webpack打包原理和manifest文件分析

    打包工具要解决的问题: 文件依赖管理 梳理文件之间的依赖关系 资源加载管理 处理文件的加载顺序(先后时机)和文件的加载数量(合并.嵌入.拆分) 效率与优化管理 提高开发效率,完成页面优化 webpac ...

  9. Android系统默认Home应用程序(Launcher)的启动过程源代码分析

    在前面一篇文章中,我们分析了Android系统在启动时安装应用程序的过程,这些应用程序安装好之后,还需要有一个Home应用程序来负责把它们在桌面上展示出来,在Android系统中,这个默认的Home应 ...

最新文章

  1. .Net MVC3中取得当前区域的名字(Area name)
  2. html随机播放不同的音乐,如何随机播不同的背景音乐
  3. H3C大数据产品介绍
  4. 11 | 排序(上):为什么插入排序比冒泡排序更受欢迎?
  5. 360 java插件设置_jdk环境变量一键设置 管理員运行
  6. LVS_TUN 实验
  7. SecureCRT信号灯超时时间已到
  8. Git系列——删除文件的找回
  9. 8种绝对成交的销售话术技巧
  10. cache tier 分级缓存
  11. 高级搜索:搜索指定网址
  12. lua 16进制转10 10转16进制
  13. 微信小程序——点击不同的标签,弹出显示不同的内容
  14. 计算机历史博物馆观后感:阿达·洛芙莱斯生平9(完结)
  15. DELPHI 键盘HOOK,DLL注入,带窗口DLL注入及释放
  16. java am pm_java – 如何以AM / PM格式显示时间
  17. linux驱动学习(七) ioctl中的cmd和_IO() , _IOR() , IOW() ,_IOWR() 以及_IOC_NR()的关系
  18. Vue 实现锚点定位
  19. 坐标变换的艺术—PMSM高频注入法公式推导
  20. 外汇mt4软件的优势

热门文章

  1. 机器人搬运礼盒程序_机器人搬运程序.doc
  2. java迭代法求圆周率用梯形_感悟数学“近似计算”之美——“望星楼”里的圆周率...
  3. mysql通用mapper_通用Mapper(Mybatis)
  4. 用c语言ipv6组播,需要适用于iOS 9的IPv6组播C代码
  5. 知识图谱组队学习Task04——知识库的查询语句
  6. java第三方登录接口_第三方登录接入-qq,weibo-java
  7. java 修改源码_再谈给应用程序diy启动画面和java源代码补丁修改
  8. matlab gpu 编程 macOS,MATLAB GPU编程基础
  9. 在大项目中,实施顾问主要负责什么具体工作?
  10. Linux内核源代码分析——swap实现