android修改源码启动指定应用

来源:互联网 发布:php和mysql web开发 编辑:程序博客网 时间:2024/06/06 14:11

参考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-v13LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-renderscript-files-under, src)LOCAL_PACKAGE_NAME := MyLunch2LOCAL_CERTIFICATE := sharedLOCAL_PROGUARD_ENABLED := disabledLOCAL_OVERRIDES_PACKAGES := Home#LOCAL_PROGUARD_FLAG_FILES := proguard.flagsinclude $(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)# OverridesPRODUCT_BRAND := genericPRODUCT_DEVICE := genericPRODUCT_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