Menu Home

android framework

Android FW: Create Floating Window

private void initFloatingWindow() { mWindowManager = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE); mWindow = PolicyManager.makeNewWindow(mContext); mWindow.setWindowManager(mWindowManager, null, null); mWindow.requestFeature(Window.FEATURE_NO_TITLE); mDecor = mWindow.getDecorView(); mDecor.setOnTouchListener(mTouchListener); mWindow.setContentView(this); mWindow.setBackgroundDrawableResource(android.R.color.transparent); // While the media controller is up, the volume control keys should // affect the media stream type mWindow.setVolumeControlStream(AudioManager.STREAM_MUSIC); setFocusable(true); setFocusableInTouchMode(true); setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS); requestFocus(); } ref:

Android FW: make file 引用三方库

LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-subdir-Iaidl-files) LOCAL_JAVA_LIBRARIES := services telephony-common LOCAL_STATIC_JAVA_LIBRARIES := MyLib LOCAL_PACKAGE_NAME := Keyguard LOCAL_CERTIFICATE := platform LOCAL_PRIVILEGED_MODULE := true LOCAL_PROGUARD_FLAG_FILES := proguard.flags include $(BUILD_PACKAGE) include $(CLEAR_VARS) LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := MyLib:libs/mylib-v8.jar include $(BUILD_MULTI_PREBUILT)

Android: Check Long Press Helper

基本思想: 在Down事件中向UI线程塞入一个定时任务,如果在定时时间终了前任务没有被取消,就认为是一个长按事件。 /* * Copyright (C) 2012 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 * * * […]

Android的坑: Intent setData and setType

public Intent setData (Uri data) Added in API level 1 Set the data this intent is operating on. This method automatically clears any type that was previously set by setType(String) or setTypeAndNormalize(String). Note: scheme matching in the Android framework is case-sensitive, unlike the formal RFC. As a result, you should […]

Android:onTouchEvent & TouchListener的执行

public boolean dispatchTouchEvent(MotionEvent event) { if (mInputEventConsistencyVerifier != null) { mInputEventConsistencyVerifier.onTouchEvent(event, 0); } if (onFilterTouchEventForSecurity(event)) { // noinspection SimplifiableIfStatement ListenerInfo li = mListenerInfo; if (li != null && li.mOnTouchListener != null && (mViewFlags & ENABLED_MASK) == ENABLED && li.mOnTouchListener.onTouch(this, event)) { return true; } if (onTouchEvent(event)) { return true; } […]

Android OTA升级中的一些零碎知识

OTA升级脚本 build/tools/releasetools recovery-resource.dat # Recovery is generated as a patch using both the boot image # (which contains the same linux kernel as recovery) and the file # /system/etc/recovery-resource.dat (which contains all the images # used in the recovery UI) as sources. This lets us minimize the # size of […]

windows python跨进程访问文件

OS: windows 7 python: 2.7 最近在把Android OTA的整套东西移植到windows上,涉及了很多python脚本,要疯了。暂不说没写过一行python了,就是windows系统也有很多年头没动过了,这个牛X的系统,居然还是那么难用。 问题描述: temp_zip_file = tempfile.NamedTemporaryFile() #同一线程访问temp_zip_file #不同线程访问temp_zip_file temp_zip_file.close() 运行时提示错误: 另一个程序正在使用此文件,进程无法访问。 靠啊,这么简单的一条语句还能出啥问题啊,在Linux上也是没有问题的,查查文档,发现下面这句话: tempfile.NamedTemporaryFile([mode=’w+b'[, bufsize=-1[, suffix=”[, prefix=’tmp'[, dir=None[, delete=True]]]]]]) This function operates exactly as TemporaryFile() does, except that the file is guaranteed to have a visible name in the file system (on Unix, the directory entry […]

How to change Kernel Version String

OS: Android 4.4 Kernel: 3.10.28 这里所谓的修改kernel version string并不是真的修改linux的版本号,因为那样会导致非常多的问题(比如一些驱动会不能用,等等)。所以这里修改的仅仅是/proc系统下的version,而从/proc/version中读取kernel version string是一个通常的做法,所以只需要修改这个就可以了。 kernel/fs/proc/version.c static int version_proc_show(struct seq_file *m, void *v) { seq_printf(m, linux_proc_banner, utsname()->sysname, utsname()->release, utsname()->version); return 0; } seq_printf和printf的功能很类似,可以输出经格式化的字符串。这里的linux_proc_banner参数实际上是一个格式化字符串,它的定义在文件kernel/init/version.c中: const char linux_proc_banner[] = “%s version %s” ” (” LINUX_COMPILE_BY “@” LINUX_COMPILE_HOST “)” ” (” LINUX_COMPILER “) %s\n”; 所以很明显你可以通过修改上面2个文件来定制你自己的version string. 接下来看看Android的setttings中是如何来读取kernel version的: […]