android修改源码启动指定应用

参考http://blog.csdn.net/mr_raptor/article/details/8006721 4. Android系统企业级定制

原理替换luncher

一、项目修改

将eclipse下编译好的项目如MyLunch2放入 

/home/proud/AndroidSource/code/packages/apps下

添加Android.mk文件,可从其他项目内复制 加以修改

#
# Copyright (C) 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.
#

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)

LOCAL_MODULE_TAGS := optional

#LOCAL_STATIC_JAVA_LIBRARIES := android-common android-support-v13

LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-renderscript-files-under, src)


LOCAL_PACKAGE_NAME := MyLunch2
LOCAL_CERTIFICATE := shared
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_OVERRIDES_PACKAGES := Home

#LOCAL_PROGUARD_FLAG_FILES := proguard.flags

include $(BUILD_PACKAGE)

include $(call all-makefiles-under,$(LOCAL_PATH))
修改AndroidManifest.xml去掉versioncode versionname user-sdk的信息,编译的时候会有warm,源码中带的也没有

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.mylunch2"
  >
    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity android:name="com.test.lunch.Main" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.FS_HOME" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
    </application>
</manifest>


 <category android:name="android.intent.category.FS_HOME" />  这个是关键,第二步修改的,系统发出的只有该应用可接收到

二、修改frameWork

找到/home/proud/AndroidSource/code/frameworks/base/core/java/android/content

修改intent.java

   @SdkConstant(SdkConstantType.INTENT_CATEGORY)
 public static final String CATEGORY_HOME = "android.intent.category.FS_HOME";
   // public static final String CATEGORY_HOME = "android.intent.category.HOME";

修改/home/proud/AndroidSource/code/frameworks/base/api 目录下对应api的.txt和current.txt

将其中的android.intent.category.HOME换成android.intent.category.FS_HOME

 field public static final java.lang.String CATEGORY_HOME = "android.intent.category.FS_HOME";


三、修改编译选项

/home/proud/AndroidSource/code/build/target/product目录下的

generic.mk文件

#
# 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.
#

# This is a generic phone product that isn't specialized for a specific device.
# It includes the base Android platform.

$(call inherit-product, $(SRC_TARGET_DIR)/product/generic_no_telephony.mk)
$(call inherit-product, $(SRC_TARGET_DIR)/product/telephony.mk)

# Overrides
PRODUCT_BRAND := generic
PRODUCT_DEVICE := generic
PRODUCT_NAME := generic

引入了generic_no_telephony.mk文件 

PRODUCT_PACKAGES := \
    AccountAndSyncSettings \
    DeskClock \
    AlarmProvider \
    Bluetooth \
    Calculator \
    Calendar \
    CertInstaller \
    DrmProvider \
    Email \
    Exchange \
    Gallery2 \
    LatinIME \
    Launcher2 \
    Music \
    MusicFX \
    Provision \
    MyLunch2\
    Phone \
    QuickSearchBox \
    Settings \
    Sync \
    SystemUI \
    Updater \
    CalendarProvider \
    SyncProvider
在文件中添加MyLunch2\

重新编译整个项目





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Android Killer是一个工具,它可以帮助开发者修改Android的源代码并进行二次打包。 首先,为了使用Android Killer,我们需要下载并安装它。安装完成后,可以在命令行中输入“androidkiller”来启动它。 接下来,我们需要准备Android源码Android源码可以从Google官方网站上下载。下载完成后,我们需要将源码解压缩到一个指定的目录中。 在Android Killer中,我们需要指定源码所在的路径。我们可以在命令行中输入“androidkiller --path [源码路径]”来设置源码路径。 完成以上准备工作后,我们可以开始修改源码。通过修改源码,我们可以添加新功能、修改现有功能或者删除功能。要修改源码,我们需要具备Java编程的基础知识和Android开发的经验。 在完成源码修改后,我们可以使用Android Killer进行二次打包。二次打包的过程包括编译源码、生成APK文件和签名APK文件。 通过Android Killer,我们可以执行以下命令来进行二次打包: 1. 编译源码:输入“androidkiller --build”来编译源码。编译过程可能需要一些时间,具体视源码大小和电脑性能而定。 2. 生成APK文件:编译完成后,我们可以在输出目录中找到生成的APK文件。APK文件是二次打包后的最终产物。 3. 签名APK文件:为了能够在Android设备上安装和运行APK文件,我们需要对APK文件进行签名。我们可以使用以下命令来签名APK文件:“androidkiller --sign [APK文件路径] [签名文件路径]”。 以上就是使用Android Killer修改源码并进行二次打包的基本流程。通过修改源码,我们可以定制化我们的Android系统和应用,以满足自己的需求。使用Android Killer,我们可以更加灵活地进行二次开发和定制。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值