之前5.0版夭折了,现在搞4.4.2要轻松许多
继续按5.0的格式来。
1,不锁屏
跟5.0一模一样,以下直接copy from 02 start
①设置默认锁屏时间
文件
/home/senrsl/android/source/WORKING_DIRECTORY/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
修改
之前为60000,修改为-1不锁屏。
- <integer name="def_screen_off_timeout">-1</integer>
②开机不锁屏
这个文件跑的比较快
4.0版本的时候,在frameworks/base/policy/src/com/android/internal/policy /impl/KeyguardViewMediator.java
4.4版本的时候,在 frameworks/base/packages/Keyguard/src/com/android/keyguard/KeyguardViewMediator.java
5.0版本的时候,在/home/senrsl/android/source/WORKING_DIRECTORY/frameworks /base/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
就是改个不锁屏而已,谷歌你大爷的至于吗。。。。
我用的5.0版本,第206行,改值为false
这样便实现开机不锁屏,且长时间不用也不锁屏问题。
- private boolean mExternallyEnabled = false;
copy from 02 end
经验证,4.4.2的mExternallyEnabled在192行。
4.4.2改完发现开机还是锁屏。。。。
然后,还是这个文件,搞四步
1)当然是最经典的private boolean mExternallyEnabled = false;,大概是192行;
2)给他设置默认值private boolean mShowing = false;大概是205行;
3)大概是515行,这个赋值注释掉
//mShowing = (mUpdateMonitor.isDeviceProvisioned() || mLockPatternUtils.isSecure())
// && !mLockPatternUtils.isLockScreenDisabled();
4)大概是1067行,这个handle处理注释掉//handleShow((Bundle) msg.obj);
这样4.4.2的锁屏搞定。
2,开机画面
跟02基本类似
①第一屏
第一屏默认是不显示的,要编译内核的时候开启。
修改内核配置文件/home/senrsl/android/source/kernel/goldfish/arch/arm/configs /goldfish_armv7_defconfig
在最后面加上
这样启动的时候倒是显示了第一屏,但是一直闪,也能进系统操作,但是一直闪啊闪。。。。
- #CONFIG_FRAMEBUFFER_CONSOLE=y
- CONFIG_LOGO=y
好吧,换个方式,用make menuconfig来搞
- senrsl@senrsl-ubuntu:~/android/source/kernel/goldfish$ make menuconfig
- *** Unable to find the ncurses libraries or the
- *** required header files.
- *** 'make menuconfig' requires the ncurses libraries.
- ***
- *** Install ncurses (ncurses-devel) and try again.
- ***
- make[1]: *** [scripts/kconfig/dochecklxdialog] 错误 1
- make: *** [menuconfig] 错误 2
- senrsl@senrsl-ubuntu:~$ sudo apt-get install libncurses5-dev
- [sudo] password for senrsl:
- 正在读取软件包列表... 完成
- 正在分析软件包的依赖关系树
- 正在读取状态信息... 完成
- 建议安装的软件包:
- ncurses-doc
- 下列【新】软件包将被安装:
- libncurses5-dev
- 升级了 0 个软件包,新安装了 1 个软件包,要卸载 0 个软件包,有 0 个软件包未被升级。
- 需要下载 170 kB 的软件包。
- 解压缩后会消耗掉 1,056 kB 的额外空间。
- 获取:1 http://cn.archive.ubuntu.com/ubuntu/ trusty/main libncurses5-dev amd64 5.9+20140118-1ubuntu1 [170 kB]
- 下载 170 kB,耗时 0秒 (1,063 kB/s)
- Selecting previously unselected package libncurses5-dev:amd64.
- (正在读取数据库 ... 系统当前共安装有 213031 个文件和目录。)
- Preparing to unpack .../libncurses5-dev_5.9+20140118-1ubuntu1_amd64.deb ...
- Unpacking libncurses5-dev:amd64 (5.9+20140118-1ubuntu1) ...
- 正在设置 libncurses5-dev:amd64 (5.9+20140118-1ubuntu1) ...
- senrsl@senrsl-ubuntu:~/android/source/kernel/goldfish$ make menuconfig
- HOSTCC scripts/kconfig/conf.o
- HOSTCC scripts/kconfig/lxdialog/checklist.o
- HOSTCC scripts/kconfig/lxdialog/inputbox.o
- HOSTCC scripts/kconfig/lxdialog/menubox.o
- HOSTCC scripts/kconfig/lxdialog/textbox.o
- HOSTCC scripts/kconfig/lxdialog/util.o
- HOSTCC scripts/kconfig/lxdialog/yesno.o
- HOSTCC scripts/kconfig/mconf.o
- HOSTCC scripts/kconfig/zconf.tab.o
- HOSTLD scripts/kconfig/mconf
- scripts/kconfig/mconf Kconfig
- #
- # configuration written to .config
- #
- *** End of the configuration.
- *** Execute 'make' to start the build or try 'make help'.
- senrsl@senrsl-ubuntu:~/android/source/kernel/goldfish$ make
- 。。。。
这个地方的配置:
CONFIG_FRAMEBUFFER_CONSOLE:
Device Drivers ---> Graphics support ---> Console display driver support ---> Framebuffer Console support
CONFIG_LOGO:
Device Drivers ---> Graphics support ---> Bootup logo
make完成后使用,依旧是闪屏。。。。
//TODO 待解决的闪屏
②第二屏
默认不显示,开启了第一个的显示后显示了。
在android里改显示,位置在/home/senrsl/android/source/WORKING_DIRECTORY/system /core/init/init.c 第678行。
用中文乱码,显示方块。。。。
- " 你好,我是中文。 ";//A N D R O I D
- " Hello,nice too meet you!\n\n\n\t\t\t Beijing ";//A N D R O I D
③第三屏
跟02的一样
动画位置
代码位置
- /home/senrsl/android/source/WORKING_DIRECTORY/frameworks/base/core/res/assets/images/android-logo-mask.png
- /home/senrsl/android/source/WORKING_DIRECTORY/frameworks/base/core/res/assets/images/android-logo-shine.png
这里面俩图片轮播是BootAnimation::android()这个方法,bootanimation.zip是bool BootAnimation::movie()这个方法,到底进哪个在bool BootAnimation::threadLoop()里进行判断。
- /home/senrsl/android/source/WORKING_DIRECTORY/frameworks/base/cmds/bootanimation/BootAnimation.cpp
3,系统UI定制
跟02相同
①SystemUI是
/home/senrsl/android/source/WORKING_DIRECTORY/frameworks/base/packages/SystemUI
这个是基本的UI相关
②设置是
/home/senrsl/android/source/WORKING_DIRECTORY/packages/apps/Settings
4,默认中文
文件
/home/senrsl/android/source/WORKING_DIRECTORY/build/target/product下的
full.mk或者full_base.mk
在后面增加
如此
- #默认语言
- PRODUCT_LOCALES := zh_CN
然后编译,清空用户数据启动
效果
- senrsl@senrsl-ubuntu:~/android/source/WORKING_DIRECTORY$ emulator -wipe-data -kernel /home/senrsl/android/source/kernel/goldfish/arch/arm/boot/zImage &
5,程序开机自启
①广播过滤
②注册监听
- /**
- * 开机自启
- * 1,写这个类监听开机广播
- * 2,manifest里注册receiver事件
- * 3,增加权限
- *
- * @ClassName: AutoBootReceiver
- * @author senrsl
- *
- * @Package: dc.study
- * @CreateTime: 2015-3-23 上午11:03:18
- */
- public class AutoBootReceiver extends BroadcastReceiver {
- /*
- * (non-Javadoc)
- *
- * @see android.content.BroadcastReceiver#onReceive(android.content.Context,
- * android.content.Intent)
- */
- @Override
- public void onReceive(Context context, Intent intent) {
- if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
- Toast.makeText(context, "开机自启", Toast.LENGTH_LONG).show();
- Intent mainActivityIntent = new Intent(context, WelcomeActivity.class);
- mainActivityIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- context.startActivity(mainActivityIntent);
- }
- }
- }
android:priority="1000"为提升广播优先级,范围为-1000到+1000
③增加权限
- <receiver android:name=".AutoBootReceiver" >
- <intent-filter android:priority="1000">
- <action android:name="android.intent.action.BOOT_COMPLETED" />
- <category android:name="android.intent.category.HOME" />
- </intent-filter>
- </receiver>
上面的①和②可以改成这样,能省几行代码
- <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
①广播过滤
- /**
- *
- *
- * @ClassName: AutoBootReceiver
- * @author senrsl
- *
- * @Package: cn.senrsl.android.vsf.receiver
- * @CreateTime: 2015-3-25 下午5:25:49
- */
- public class AutoBootReceiver extends BroadcastReceiver {
- /* (non-Javadoc)
- * @see android.content.BroadcastReceiver#onReceive(android.content.Context, android.content.Intent)
- */
- @Override
- public void onReceive(Context context, Intent intent) {
- Logger.w("开机自启");
- //此处启动数据本地支持
- }
- }
②注册监听
- <receiver android:name=".receiver.AutoBootReceiver" >
- <intent-filter android:priority="1000" >
- <action android:name="android.intent.action.BOOT_COMPLETED" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </receiver>
6,源码下编译apk
①eclipse项目,把项目放进
/home/senrsl/android/source/WORKING_DIRECTORY/packages/apps/
②删除bin和gen之类的缓存,查看当前结构
上面那些~跟.*的也可以删。。。。
- senrsl@senrsl-ubuntu:~/android/source/WORKING_DIRECTORY/packages/apps/secondHallo$ ll
- 总用量 64
- drwxrwxr-x 5 senrsl senrsl 4096 3月 23 14:38 ./
- drwxrwxr-x 47 senrsl senrsl 4096 3月 23 13:42 ../
- -rw-rw-r-- 1 senrsl senrsl 1495 3月 23 11:31 AndroidManifest.xml
- -rw-rw-r-- 1 senrsl senrsl 350 3月 23 14:38 Android.mk
- -rw-rw-r-- 1 senrsl senrsl 350 3月 23 14:38 Android.mk~
- -rw-rw-r-- 1 senrsl senrsl 466 12月 15 15:25 .classpath
- -rw-rw-r-- 1 senrsl senrsl 2227 3月 20 13:37 CleanSpec.mk
- -rw-rw-r-- 1 senrsl senrsl 0 3月 20 13:37 MODULE_LICENSE_APACHE2
- -rw-rw-r-- 1 senrsl senrsl 10695 3月 20 13:37 NOTICE
- -rw-rw-r-- 1 senrsl senrsl 1248 12月 15 15:25 proguard.cfg
- -rw-rw-r-- 1 senrsl senrsl 847 12月 15 15:25 .project
- -rw-rw-r-- 1 senrsl senrsl 361 12月 15 15:25 project.properties
- drwxrwxr-x 7 senrsl senrsl 4096 12月 15 15:25 res/
- drwxrwxr-x 2 senrsl senrsl 4096 12月 15 15:25 .settings/
- drwxrwxr-x 3 senrsl senrsl 4096 12月 15 15:25 src/
③创建Android.mk
其他的如CleanSpec.mk跟MODULE_LICENSE_APACHE2还有NOTICE什么的都可以无视。
- LOCAL_PATH:= $(call my-dir)
- include $(CLEAR_VARS)
- LOCAL_MODULE_TAGS := optional
- LOCAL_SRC_FILES := $(call all-java-files-under, src)
- LOCAL_PACKAGE_NAME := secondHallo
- LOCAL_SDK_VERSION := current
- LOCAL_CERTIFICATE := platform
- LOCAL_PROGUARD_FLAG_FILES := proguard.cfg
- include $(BUILD_PACKAGE)
- include $(call all-makefiles-under,$(LOCAL_PATH))
④执行编译
⑤查看结果
- senrsl@senrsl-ubuntu:~/android/source/WORKING_DIRECTORY/packages/apps/secondHallo$ mm
- ============================================
- PLATFORM_VERSION_CODENAME=REL
- PLATFORM_VERSION=4.4.2
- TARGET_PRODUCT=aosp_arm
- TARGET_BUILD_VARIANT=eng
- TARGET_BUILD_TYPE=release
- TARGET_BUILD_APPS=
- TARGET_ARCH=arm
- TARGET_ARCH_VARIANT=armv7-a
- TARGET_CPU_VARIANT=generic
- HOST_ARCH=x86
- HOST_OS=linux
- HOST_OS_EXTRA=Linux-3.13.0-37-generic-x86_64-with-Ubuntu-14.04-trusty
- HOST_BUILD_TYPE=release
- BUILD_ID=KVT49L
- OUT_DIR=out
- ============================================
- make:进入目录'/home/senrsl/android/source /WORKING_DIRECTORY'
- Proguard: out/target/common/obj/APPS/secondHallo_intermediates/proguard.classes.jar
- ProGuard, version 4.4
- Reading input...
- Reading program jar [/home/senrsl/android/source/WORKING_DIRECTORY/out/target/common/obj/APPS/secondHallo_intermediates/classes.jar]
- Reading library jar [/home/senrsl/android/source/WORKING_DIRECTORY/out/target/common/obj/JAVA_LIBRARIES/android_stubs_current_intermediates/classes.jar]
- Initializing...
- Note: the configuration refers to the unknown class 'com.android.vending.licensing.ILicensingService'
- Note: there were 1 references to unknown classes.
- You should check your configuration for typos.
- Ignoring unused library classes...
- Original number of library classes: 3412
- Final number of library classes: 3412
- Shrinking...
- Removing unused program classes and class elements...
- Original number of program classes: 15
- Final number of program classes: 8
- Writing output...
- Preparing output jar [/home/senrsl/android/source/WORKING_DIRECTORY/out/target/common/obj/APPS/secondHallo_intermediates/proguard.classes.jar]
- Copying resources from program jar [/home/senrsl/android/source/WORKING_DIRECTORY/out/target/common/obj/APPS/secondHallo_intermediates/classes.jar]
- target Dex: secondHallo
- Copying: out/target/common/obj/APPS/secondHallo_intermediates/classes.dex
- target Package: secondHallo (out/target/product/generic/obj/APPS/secondHallo_intermediates/package.apk)
- Warning: AndroidManifest.xml already defines versionCode (in http://schemas.android.com/apk/res/android); using existing value in manifest.
- Warning: AndroidManifest.xml already defines versionName (in http://schemas.android.com/apk/res/android); using existing value in manifest.
- Warning: AndroidManifest.xml already defines minSdkVersion (in http://schemas.android.com/apk/res/android); using existing value in manifest.
- Processing target/product/generic/obj/APPS/secondHallo_intermediates/package.apk
- Done!
- Install: out/target/product/generic/system/app/secondHallo.odex
- Notice file: packages/apps/secondHallo/NOTICE -- out/target/product/generic/obj/NOTICE_FILES/src//system/app/secondHallo.apk.txt
- Install: out/target/product/generic/system/app/secondHallo.apk
- make:离开目录"/home/senrsl/android/source /WORKING_DIRECTORY"senrsl@senrsl-ubuntu:~/android/source/WORKING_DIRECTORY/packages/apps/secondHallo$ mm
- ============================================
- PLATFORM_VERSION_CODENAME=REL
- PLATFORM_VERSION=4.4.2
- TARGET_PRODUCT=aosp_arm
- TARGET_BUILD_VARIANT=eng
- TARGET_BUILD_TYPE=release
- TARGET_BUILD_APPS=
- TARGET_ARCH=arm
- TARGET_ARCH_VARIANT=armv7-a
- TARGET_CPU_VARIANT=generic
- HOST_ARCH=x86
- HOST_OS=linux
- HOST_OS_EXTRA=Linux-3.13.0-37-generic-x86_64-with-Ubuntu-14.04-trusty
- HOST_BUILD_TYPE=release
- BUILD_ID=KVT49L
- OUT_DIR=out
- ============================================
- make:进入目录'/home/senrsl/android/source /WORKING_DIRECTORY'
- Proguard: out/target/common/obj/APPS/secondHallo_intermediates/proguard.classes.jar
- ProGuard, version 4.4
- Reading input...
- Reading program jar [/home/senrsl/android/source/WORKING_DIRECTORY/out/target/common/obj/APPS/secondHallo_intermediates/classes.jar]
- Reading library jar [/home/senrsl/android/source/WORKING_DIRECTORY/out/target/common/obj/JAVA_LIBRARIES/android_stubs_current_intermediates/classes.jar]
- Initializing...
- Note: the configuration refers to the unknown class 'com.android.vending.licensing.ILicensingService'
- Note: there were 1 references to unknown classes.
- You should check your configuration for typos.
- Ignoring unused library classes...
- Original number of library classes: 3412
- Final number of library classes: 3412
- Shrinking...
- Removing unused program classes and class elements...
- Original number of program classes: 15
- Final number of program classes: 8
- Writing output...
- Preparing output jar [/home/senrsl/android/source/WORKING_DIRECTORY/out/target/common/obj/APPS/secondHallo_intermediates/proguard.classes.jar]
- Copying resources from program jar [/home/senrsl/android/source/WORKING_DIRECTORY/out/target/common/obj/APPS/secondHallo_intermediates/classes.jar]
- target Dex: secondHallo
- Copying: out/target/common/obj/APPS/secondHallo_intermediates/classes.dex
- target Package: secondHallo (out/target/product/generic/obj/APPS/secondHallo_intermediates/package.apk)
- Warning: AndroidManifest.xml already defines versionCode (in http://schemas.android.com/apk/res/android); using existing value in manifest.
- Warning: AndroidManifest.xml already defines versionName (in http://schemas.android.com/apk/res/android); using existing value in manifest.
- Warning: AndroidManifest.xml already defines minSdkVersion (in http://schemas.android.com/apk/res/android); using existing value in manifest.
- Processing target/product/generic/obj/APPS/secondHallo_intermediates/package.apk
- Done!
- Install: out/target/product/generic/system/app/secondHallo.odex
- Notice file: packages/apps/secondHallo/NOTICE -- out/target/product/generic/obj/NOTICE_FILES/src//system/app/secondHallo.apk.txt
- Install: out/target/product/generic/system/app/secondHallo.apk
- make:离开目录"/home/senrsl/android/source /WORKING_DIRECTORY"
生成的结果在
/home/senrsl/android/source/WORKING_DIRECTORY/out/target/product/generic/system/app/secondHallo.apk
可以直接安装
⑥注意:中文乱码
- senrsl@senrsl-ubuntu:~/android/source/WORKING_DIRECTORY/out/target/product/generic/system/app$ adb install secondHallo.apk
- 283 KB/s (13565 bytes in 0.046s)
- pkg: /data/local/tmp/secondHallo.apk
- Success
项目应使用UTF-8编码,若使用GBK编码,中文会全部乱码。
7,预装软件
A,预装apk
①基于源码的预装
之前的配置基于6,源码下编译apk
默认的,编译完成后make -16源码不会把软件预装,这需要配置。
默认的/home/senrsl/android/source/WORKING_DIRECTORY/packages/apps下的大部分 app都在
/home/senrsl/android/source/WORKING_DIRECTORY/build/target/product /sdk.mk文件配置;
把secondHallo放进去发现不行,然后发现这个目录改过默认语言,是full.mk,在里面引用了emulator.mk
那就在emulator.mk里加试试
重新make -j16启动发现可行。
- # Host modules
- PRODUCT_PACKAGES += \
- emulator \
- emulator-x86 \
- emulator-arm \
- emulator-mips \
- emulator64-x86 \
- emulator64-arm \
- emulator64-mips \
- libOpenglRender \
- libGLES_CM_translator \
- libGLES_V2_translator \
- libEGL_translator \
- lib64OpenglRender \
- lib64GLES_CM_translator \
- lib64GLES_V2_translator \
- lib64EGL_translator \
- secondHallo
这个方案并不合适,应该根据实际情况来改,大致就是这么个意思。
②基于apk的预装
还是上面那个emulator.mk,后面增加
执行make -j16,报错
- PRODUCT_COPY_FILES += \
- device/generic/goldfish/fstab.goldfish:root/fstab.goldfish \
- device/generic/goldfish/init.goldfish.rc:root/init.goldfish.rc \
- device/generic/goldfish/init.goldfish.sh:system/etc/init.goldfish.sh \
- device/generic/goldfish/ueventd.goldfish.rc:root/ueventd.goldfish.rc \
- vendor/SENRSL/emulator/apk/TestVD_Thread.apk:system/app/TestVD_Thread.apk
这个问题,改这个文件/home/senrsl/android/source/WORKING_DIRECTORY/build/core /Makefile,第22行开始
- build/core/Makefile:32: *** Prebuilt apk found in PRODUCT_COPY_FILES: vendor/SENRSL/emulator/apk/TestVD_Thread.apk:system/app/TestVD_Thread.apk, use BUILD_PREBUILT instead!。 停止。
加注释:
- #取消
- #拷贝文件如果是apk,报错
- #define check-product-copy-files
- #$(if $(filter %.apk, $(1)),$(error \
- # Prebuilt apk found in PRODUCT_COPY_FILES: $(1), use BUILD_PREBUILT instead!))
没有评论 :
发表评论