device源码
‘壹’ 如何把应用程序app编译进android系统
把常用的应用程序编译到img文件中,就成了系统的一部分,用户不必自己安装,当然也卸载不了;
同时也可以删减系统自带的应用程序,精简系统;
1.\build\target\proct 目录下generic.mk文件:
java代码 收藏代码
PRODUCT_PACKAGES := \
AccountAndSyncSettings \
DeskClock \
AlarmProvider \
Bluetooth \
Calculator \
Calendar \
Camera \
testMid \
CertInstaller \
DrmProvider \
Email \
Gallery3D \
LatinIME \
Launcher2 \
Mms \
Music \
我们添加一个testMid \ 应用名称。
2.把testMid包放入
\packages\apps 目录下,修改android.mk文件。
Java代码 收藏代码
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := $(call all-subdir-java-files)
LOCAL_PACKAGE_NAME := testMid
LOCAL_CERTIFICATE := platform
include $(BUILD_PACKAGE)
注:LOCAL_PACKAGE_NAME := testMid (包名必须和generic.mk中添加的相同)
编译源码,可以看到在
\out\target\proct\smdkv210\system\app
目录下生存了testMid.apk了。这时system.img也包含了此应用。
-------------------------------------------------------------------
特殊情况:有时,应用需要包含jar包,这时的app导入源码时会出现问题:
MODULE.TARGET.JAVA_LIBRARIES.libarity already defined by ... stop
由于 LOCAL_STATIC_JAVA_LIBRARIES := libarity 会引发错误信息。
目前解决方法是:
\build\core 目录下修改base_rules.mk
注释掉错误信息:
ifdef $(mole_id)
#$(error $(LOCAL_PATH): $(mole_id) already defined by $($(mole_id)))
endif
$(mole_id) := $(LOCAL_PATH)
--重新编译,这时可以通过了。
(2)、删除原厂(Telchips)带源码的应用程序,如DTV_DVBT
在/device/telechips/m801/device.mk
注释掉相应语句:
# PRODUCT_PACKAGES += \
# SampleDVBTPlayer \
同时,在/out/target/proct/m801/system/app 找到相应的.APK包,并删除
‘贰’ 参数传递文件和DTS文件一样吗
摘要 亲^3^,您好,不好意思,DTS即Device Tree Source 设备树源码, Device Tree是一种描述硬件的数据结构,它起源于 OpenFirmware (OF)。
‘叁’ 怎样从源码编译rom
本帖最后由 pigjohn 于 2014-2-10 20:24 编辑
一、你需要:
1.linux系统环境
教程使用ubuntu 12.04(LTS)
硬盘安装或虚拟机安装应该都ok。
2.电脑配置不要太差
二、搭建编译环境:
1.java安装配置
1) 删除旧版本java
ctrl+alt+t 打开终端。
sudo apt-get purge openjdk-\* icedtea-\* icedtea6-\*
sudo apt-get purge sun-java
复制代码
2) 安装java 1.6
添加软件源,打开终端输入
sudo add-apt-repository ppa:webupd8team/java
复制代码
下载安装,打开终端输入
sudo apt-get update && sudo apt-get install oracle-java6-installer
复制代码
跟随屏幕提示,你需要接受使用条款。
安装完成后,终端输入java -version,你会看到java版本信息。类似
java version “1.6.0_37″
Java(TM) SE Runtime Environment (build 1.6.0_37-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.12-b01, mixed mode)
复制代码
2.安装依赖软件
sudo apt-get install git-core gnupg flex bison gperf build-essential \
zip curl zlib1g-dev zlib1g-dev:i386 libc6-dev lib32ncurses5-dev \
ia32-libs x11proto-core-dev libx11-dev:i386 libreadline6-dev:i386 \
lib32z-dev libgl1-mesa-dev g++-multilib mingw32 \
tofrodos python-markdown libxml2-utils xsltproc readline-common \
libreadline6-dev libreadline6 lib32readline-gplv2-dev libncurses5-dev \
lib32readline5 lib32readline6 libreadline-dev libreadline6-dev:i386 \
libreadline6:i386 bzip2 libbz2-dev libbz2-1.0 libghc-bzlib-dev lib32bz2-dev \
libsdl1.2-dev libesd0-dev squashfs-tools pngcrush schedtool libwxgtk2.6-dev
复制代码
等待安装配置完成
sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
复制代码
三、源码下载
1.repo脚本下载
$ mkdir ~/bin
$ PATH=~/bin:$PATH
$ curl [url]https://dl-ssl.google.com/dl/googlesource/git-repo/repo[/url] > ~/bin/repo
$ chmod a+x ~/bin/repo
复制代码
2.初始化repo同步
mkdir ~/cm11
cd ~/cm11
repo init -u git://github.com/CyanogenMod/android.git -b cm-11.0
复制代码
你需要按提示输入用户名和邮箱。
3.9003device源码
cd ~/cm11/.repo
mkdir local_manifests && cd local_manifests
gedit roomservice.xml
复制代码
粘贴以下内容
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<project name="dhiru1602/android_device_samsung_galaxysl" path="device/samsung/galaxysl" remote="github" revision="cm-11.0" />
<project name="dhiru1602/android_vendor_samsung_galaxysl" path="vendor/samsung/galaxysl" remote="github" revision="cm-11.0" />
<project name="dhiru1602/android_kernel_samsung_latona" path="kernel/samsung/latona" remote="github" revision="cm-11.0" />
<project name="CyanogenMod/android_packages_apps_SamsungServiceMode" path="packages/apps/SamsungServiceMode" remote="github" revision="cm-11.0"/>
</manifest>
复制代码
保存。
4.同步源码
cd ~/cm11
repo sync -j8
复制代码
源码有好几个G,同步时间长短取决于你的网络速度。
四、编译
1.编译之前同步最新源码
repo sync
复制代码
2.初始化环境
. build/envsetup.sh
复制代码
3.编译
brunch galaxysl
复制代码
接着喝杯茶,编译时间长短取决于你的电脑配置。
不出意外,你会最终得到~/cm11/out/target/proct/galaxysl/cm-11-XXXXX-UNOFFICIAL-galaxysl.zip
五、刷机测试
以上就是编译cm11的过程。
对于其他rom,类似。
mokee:
mkdir ~/mokee && cd ~/mokee
repo init -u https://github.com/MoKee/android.git -b kk_mkt
‘肆’ android_studio手机蓝牙串口通信源代码
初涉android的蓝牙操作,按照固定MAC地址连接获取Device时,程序始终是异常终止,查了好多天代码都没查出原因。今天改了一下API版本,突然就成功连接了。总结之后发现果然是个坑爹之极的错误。
为了这种错误拼命查原因浪费大把时间是非常不值得的,但是问题不解决更是揪心。可惜我网络了那么多,都没有给出确切原因。今天特此mark,希望后来者遇到这个问题的时候能轻松解决。
下面是我的连接过程,中间崩溃原因及解决办法。
1:用AT指令获得蓝牙串口的MAC地址,地址是简写的,按照常理猜测可得标准格式。
2:开一个String adress= "************" //MAC地址, String MY_UUID= "************"//UUID根据通信而定,网上都有。
3:取得本地Adapter用getDefaultAdapter(); 远程的则用getRemoteDevice(adress); 之后便可用UUID开socket进行通信。
如果中途各种在getRemoteDevice处崩溃,大家可以查看一下当前的API版本,如果是2.1或以下版本的话,便能确定是API版本问题,只要换成2.2或者以上就都可以正常运行了~ 这么坑爹的错误的确很为难初学者。 唉·········· 为这种小trick浪费很多时间真是难过。
(另外有个重要地方,别忘了给manifest里面加以下两个蓝牙操作权限哦~)
<uses-permissionandroid:name="android.permission.BLUETOOTH"></uses-permission>
<uses-permissionandroid:name="android.permission.BLUETOOTH_ADMIN"></uses-permission>
=null;
=null;
privateOutputStreamoutStream=null;
privateInputStreaminStream=null;
privatestaticfinalUUIDMY_UUID=UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");//这条是蓝牙串口通用的UUID,不要更改
privatestaticStringaddress="00:12:02:22:06:61";//<==要连接的蓝牙设备MAC地址
/*获得通信线路过程*/
/*1:获取本地BlueToothAdapter*/
mBluetoothAdapter=BluetoothAdapter.getDefaultAdapter();
if(mBluetoothAdapter==null)
{
Toast.makeText(this,"Bluetoothisnotavailable.",Toast.LENGTH_LONG).show();
finish();
return;
}
if(!mBluetoothAdapter.isEnabled())
{
Toast.makeText(this,"-runthisprogram.",Toast.LENGTH_LONG).show();
finish();
return;
}
/*2:获取远程BlueToothDevice*/
BluetoothDevicedevice=mBluetoothAdapter.getRemoteDevice(address);
if(mBluetoothAdapter==null)
{
Toast.makeText(this,"Can'tgetremotedevice.",Toast.LENGTH_LONG).show();
finish();
return;
}
/*3:获得Socket*/
try{
btSocket=device.(MY_UUID);
}catch(IOExceptione){
Log.e(TAG,"ONRESUME:Socketcreationfailed.",e);
}
/*4:取消discovered节省资源*/
mBluetoothAdapter.cancelDiscovery();
/*5:连接*/
try{
btSocket.connect();
Log.e(TAG,"ONRESUME:BTconnectionestablished,datatransferlinkopen.");
}catch(IOExceptione){
try{
btSocket.close();
}catch(IOExceptione2){
Log.e(TAG,"ONRESUME:",e2);
}
}
/*此时可以通信了,放在任意函数中*/
/*try{
outStream=btSocket.getOutputStream();
inStream=btSocket.getInputStream();//可在TextView里显示
}catch(IOExceptione){
Log.e(TAG,"ONRESUME:Outputstreamcreationfailed.",e);
}
Stringmessage="1";
byte[]msgBuffer=message.getBytes();
try{
outStream.write(msgBuffer);
}catch(IOExceptione){
Log.e(TAG,"ONRESUME:Exceptionringwrite.",e);
}
*/
packagecom.example.seed2;
importandroid.app.Activity;
importandroid.app.AlertDialog;
importandroid.app.Dialog;
importandroid.os.Bundle;
importjava.io.IOException;
importjava.io.InputStream;
importjava.io.OutputStream;
importjava.util.UUID;
importandroid.bluetooth.BluetoothAdapter;
importandroid.bluetooth.BluetoothDevice;
importandroid.bluetooth.BluetoothSocket;
importandroid.content.DialogInterface;
importandroid.util.Log;
importandroid.view.KeyEvent;
importandroid.widget.Toast;
{
privatestaticfinalStringTAG="BluetoothTest";
=null;
=null;
privateOutputStreamoutStream=null;
privateInputStreaminStream=null;
privateVerticalSeekBarvskb=null;
privatestaticfinalUUIDMY_UUID=UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");//这条是蓝牙串口通用的UUID,不要更改
privatestaticStringaddress="00:12:02:22:06:61";//<==要连接的蓝牙设备MAC地址
/**.*/
@Override
publicvoidonCreate(BundlesavedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
this.vskb=(VerticalSeekBar)super.findViewById(R.id.mskb);
this.vskb.setOnSeekBarChangeListener(newOnSeekBarChangeListenerX());
mBluetoothAdapter=BluetoothAdapter.getDefaultAdapter();
if(mBluetoothAdapter==null)
{
Toast.makeText(this,"Bluetoothisnotavailable.",Toast.LENGTH_LONG).show();
finish();
return;
}
if(!mBluetoothAdapter.isEnabled())
{
Toast.makeText(this,"-runthisprogram.",Toast.LENGTH_LONG).show();
finish();
return;
}
}
.OnSeekBarChangeListener{
publicvoidonProgressChanged(VerticalSeekBarseekBar,intprogress,booleanfromUser){
//Main.this.clue.setText(seekBar.getProgress());
/*Stringmessage;
byte[]msgBuffer;
try{
outStream=btSocket.getOutputStream();
}catch(IOExceptione){
Log.e(TAG,"ONRESUME:OutputStreamcreationfailed.",e);
}
message=Integer.toString(seekBar.getProgress());
msgBuffer=message.getBytes();
try{
outStream.write(msgBuffer);
}catch(IOExceptione){
Log.e(TAG,"ONRESUME:Exceptionringwrite.",e);
}*/
}
(VerticalSeekBarseekBar){
Stringmessage;
byte[]msgBuffer;
try{
outStream=btSocket.getOutputStream();
}catch(IOExceptione){
Log.e(TAG,"ONRESUME:OutputStreamcreationfailed.",e);
}
message=Integer.toString(seekBar.getProgress());
msgBuffer=message.getBytes();
try{
outStream.write(msgBuffer);
}catch(IOExceptione){
Log.e(TAG,"ONRESUME:Exceptionringwrite.",e);
}
}
publicvoidonStopTrackingTouch(VerticalSeekBarseekBar){
Stringmessage;
byte[]msgBuffer;
try{
outStream=btSocket.getOutputStream();
}catch(IOExceptione){
Log.e(TAG,"ONRESUME:OutputStreamcreationfailed.",e);
}
message=Integer.toString(seekBar.getProgress());
msgBuffer=message.getBytes();
try{
outStream.write(msgBuffer);
}catch(IOExceptione){
Log.e(TAG,"ONRESUME:Exceptionringwrite.",e);
}
}
}
@Override
publicvoidonStart()
{
super.onStart();
}
@Override
publicvoidonResume()
{
super.onResume();
BluetoothDevicedevice=mBluetoothAdapter.getRemoteDevice(address);
try{
btSocket=device.(MY_UUID);
}catch(IOExceptione){
Log.e(TAG,"ONRESUME:Socketcreationfailed.",e);
}
mBluetoothAdapter.cancelDiscovery();
try{
btSocket.connect();
Log.e(TAG,"ONRESUME:BTconnectionestablished,datatransferlinkopen.");
}catch(IOExceptione){
try{
btSocket.close();
}catch(IOExceptione2){
Log.e(TAG,"ONRESUME:",e2);
}
}
//.
/*try{
outStream=btSocket.getOutputStream();
inStream=btSocket.getInputStream();
}catch(IOExceptione){
Log.e(TAG,"ONRESUME:Outputstreamcreationfailed.",e);
}
Stringmessage="read";
byte[]msgBuffer=message.getBytes();
try{
outStream.write(msgBuffer);
}catch(IOExceptione){
Log.e(TAG,"ONRESUME:Exceptionringwrite.",e);
}
intret=-1;
while(ret!=-1)
{
try{
ret=inStream.read();
}catch(IOExceptione)
{
e.printStackTrace();
}
}
*/
}
@Override
下面附上Android蓝牙操作中用固定MAC地址传输信息的模板,通用搜索模式日后再补删模板:
通用搜索模式代码模板:
简洁简洁方式1 demo
作用: 用VerticalSeekBar控制一个 LED屏幕的亮暗。
直接上码咯~
‘伍’ android 源码 怎么只编译 systemui
Google提供的Android包含了原始Android的目标机代码,主机编译工具、仿真环境,下载的代码包经过解压后(这里是Android2.2的源码包),源代码的第一层目录结构如下: -- Makefile -- bionic (bionic C库) -- bootable (启动引导相关代码) -- build (存放系统编译规则及generic等基础开发包配置) -- cts (Android兼容性测试套件标准) -- dalvik (dalvik JAVA虚拟机) -- development (应用程序开发相关) -- external (android使用的一些开源的模组) -- frameworks (核心框架——java及C++语言) -- hardware (主要保护硬解适配层HAL代码) -- libcore -- ndk -- device -- out (编译完成后的代码输出与此目录) -- packages (应用程序包) -- prebuilt (x86和arm架构下预编译的一些资源) -- sdk (sdk及模拟器) -- system (文件系统库、应用及组件——c语言) `-- vendor (厂商定制代码) bionic 目录 -- libc (C库) -- arch-arm (ARM架构,包含系统调用汇编实现) -- arch-x86 (x86架构,包含系统调用汇编实现) -- bionic (由C实现的功能,架构无关) -- docs (文档) -- include (头文件) -- inet -- kernel (Linux内核中的一些头文件) -- netbsd (?netbsd系统相关,具体作用不明) -- private (?一些私有的头文件) -- stdio (stdio实现) -- stdlib (stdlib实现) -- string (string函数实现) -- tools (几个工具) -- tzcode (时区相关代码) -- unistd (unistd实现) `-- zoneinfo (时区信息) -- libdl (libdl实现,dl是动态链接,提供访问动态链接库的功能) -- libm (libm数学库的实现,) -- alpha (apaha架构) -- amd64 (amd64架构) -- arm (arm架构) -- bsdsrc (?bsd的源码) -- i386 (i386架构) -- i387 (i387架构?) -- ia64 (ia64架构) -- include (头文件) -- man (数学函数,后缀名为.3,一些为freeBSD的库文件) -- powerpc (powerpc架构) -- sparc64 (sparc64架构) `-- src (源代码) -- libstdc++ (libstdc++ C++实现库) -- include (头文件) `-- src (源码) -- libthread_db (多线程程序的调试器库) `-- include (头文件) `-- linker (动态链接器) `-- arch (支持arm和x86两种架构) bootable 目录 -- bootloader (适合各种bootloader的通用代码) `-- legacy (估计不能直接使用,可以参考) -- arch_armv6 (V6架构,几个简单的汇编文件) -- arch_msm7k (高通7k处理器架构的几个基本驱动) -- include (通用头文件和高通7k架构头文件) -- libboot (启动库,都写得很简单) -- libc (一些常用的c函数) -- nandwrite (nandwirte函数实现) `-- usbloader (usbloader实现) -- diskinstaller (android镜像打包器,x86可生产iso) `-- recovery (系统恢复相关) -- edify (升级脚本使用的edify脚本语言) -- etc (init.rc恢复脚本) -- minui (一个简单的UI) -- minzip (一个简单的压缩工具) -- mttils (mtd工具) -- res (资源) `-- images (一些图片) -- tools (工具) `-- ota (OTA Over The Air Updates升级工具) `-- updater (升级器) build目录 -- core (核心编译规则) -- history (历史记录) -- libs `-- host (主机端库,有android “cp”功能替换) -- target (目标机编译对象) -- board (开发平台) -- emulator (模拟器) -- generic (通用) -- idea6410 (自己添加的) `-- sim (最简单) `-- proct (开发平台对应的编译规则) `-- security (密钥相关) `-- tools (编译中主机使用的工具及脚本) -- acp (Android "acp" Command) -- apicheck (api检查工具) -- applypatch (补丁工具) -- apriori (预链接工具) -- atree (tree工具) -- bin2asm (bin转换为asm工具) -- check_prereq (检查编译时间戳工具) -- dexpreopt (模拟器相关工具,具体功能不明) -- droiddoc (?作用不明,java语言,网上有人说和JDK5有关) -- fs_config (This program takes a list of files and directories) -- fs_get_stats (获取文件系统状态) -- iself (判断是否ELF格式) -- isprelinked (判断是否prelinked) -- kcm (按键相关) -- lsd (List symbol dependencies) -- releasetools (生成镜像的工具及脚本) -- rgb2565 (rgb转换为565) -- signapk (apk签名工具) -- soslim (strip工具) `-- zipalign (zip archive alignment tool) dalvik目录 dalvik虚拟机 . -- dalvikvm (main.c的目录) -- dexmp (dex反汇编) -- dexlist (List all methods in all concrete classes in a DEX file.) -- dexopt (预验证与优化) -- docs (文档) -- dvz (和zygote相关的一个命令) -- dx (dx工具,将多个java转换为dex) -- hit (?java语言写成) -- libcore (核心库) -- libcore-disabled (?禁用的库) -- libdex (dex的库) -- libnativehelper (Support functions for Android's class libraries) -- tests (测试代码) -- tools (工具) `-- vm (虚拟机实现) development 目录 (开发者需要的一些例程及工具) -- apps (一些核心应用程序) -- BluetoothDebug (蓝牙调试程序) -- CustomLocale (自定义区域设置) -- Development (开发) -- Fallback (和语言相关的一个程序) -- FontLab (字库) -- GestureBuilder (手势动作) -- NinePatchLab (?) -- OBJViewer (OBJ查看器) -- SdkSetup (SDK安装器) -- SpareParts (高级设置) -- Term (远程登录) `-- launchperf (?) -- build (编译脚本模板) -- cmds (有个monkey工具) -- data (配置数据) -- docs (文档) -- host (主机端USB驱动等) -- ide (集成开发环境) -- ndk (本地开发套件——c语言开发套件) -- pdk (Plug Development Kit) -- samples (演示程序) -- AliasActivity () -- ApiDemos (API演示程序) -- BluetoothChat (蓝牙聊天) -- BrowserPlugin (浏览器插件) -- BusinessCard (商业卡) -- Compass (指南针) -- ContactManager (联系人管理器) -- CubeLiveWall** (动态壁纸的一个简单例程) -- FixedGridLayout (像是布局) -- GlobalTime (全球时间) -- HelloActivity (Hello) -- Home (Home) -- JetBoy (jetBoy游戏) -- LunarLander (貌似又是一个游戏) -- MailSync (邮件同步) -- MultiResolution (多分辨率) -- MySampleRss (RSS) -- NotePad (记事本) -- RSSReader (RSS阅读器) -- SearchableDictionary (目录搜索) -- **JNI (JNI例程) -- SkeletonApp (空壳APP) -- Snake (snake程序) -- SoftKeyboard (软键盘) -- Wiktionary (?维基) `-- Wiktionary**(?维基例程) -- scripts (脚本) -- sdk (sdk配置) -- simulator (?模拟器) -- testrunner (?测试用) `-- tools (一些工具)
‘陆’ 引用android 源码device目录下的类为什么会显示不存在
Eclipse只能查看API的注释及说明,而且是必须与jar包关联以后才能查看 jar包与docs关联方式: 1. 打开Eclipse,随便新建一个Android项目,在此项目目录下面有个Android 4.4,点击遍出现了android.jar。 2. 右键此包---->Properties,在弹出的窗口中,选择 Java Source Attachment------>External Location------>External File, 然后选择下载下来的source-19_r02.zip,便成功在Eclipse中绑定Android源代码。 3. ctl+鼠标左键 跳转到源代码 在想要查看源代码的地方,ctl+鼠标左键就可以跳转到源代码的地方。 Android Studio源代码关联方式: 1.打开菜单File ->Project Structure (或者按F4)。 2.在左边列表中选择Moles。 3.选择工程,然后在第三个标签页页找到Dependencies。 4.按“+”按钮,在弹出窗口中选择android-support-v4.jar所在文件夹(在SDK目录下),然后确认即可
‘柒’ ccs怎么添加其他device
安装时选择安装这个包就行了,没有字装就修复然后选要增加的包,不能把包直接拿来用,因为你没选TMS 编译器都没有安装。我看到 你的图片了,这人显示是安装的源码和数据手册而已,
你要TMS的源码要再安装另一个软件controlSUITE,这个里面才会提供你要的源码包和数据手册。
你完全安装后就不用再安装什么处理器的Packages了啊,直接就可以编译了啊;你要更新的编译器工具,可以用软件自带的更新到官网下载。
‘捌’ vb6 无驱摄像头编程 求源码
发下是我几年前写的(参照)一个VB驱动摄像头的代码,不知道现在还能不能用,因为文件总的很长,这只是其中的一小部分,希望对你有所用.(要不就和我联系,给你源码)
Private Sub Form_Load()
On Error Resume Next
Dim retVal As Boolean
Dim numDevs As Long
bCaramaPlaying = True
'load trivial settings first
Me.BackColor = Val(GetSetting(App.Title, "preferences", "backcolor", "&H404040")) 'default to dk gray
numDevs = VBEnumCapDrivers(Me)
If 0 = numDevs Then
MsgBox "没有找到视频捕捉设备!", vbCritical, App.Title
' frmPlayer.Visible = True
' If bIsVisible = True And vbPlayFormIsVisible = True And vbFrmPlayFrameHided = False Then
' frmPlayFrame.Visible = True
' End If
Unload Me
Exit Sub
End If
nDriverIndex = Val(GetSetting(App.Title, "driver", "index", "0"))
'if invalid entry is in registry use default (0)
If mnuDriver.UBound < nDriverIndex Then
nDriverIndex = 0
End If
mnuDriver(nDriverIndex).Checked = True
'//Create Capture Window
'Call capGetDriverDescription( nDriverIndex, lpszName, 100, lpszVer, 100 '// Retrieves driver info
hCapWnd = capCreateCaptureWindow("VB CAP WINDOW", WS_CHILD Or WS_VISIBLE, 0, 0, 160, 120, Me.hWnd, 0)
If 0 = hCapWnd Then
MsgBox "不能创建捕捉窗口!", vbCritical, App.Title
Exit Sub
End If
retVal = ConnectCapDriver(hCapWnd, nDriverIndex)
If False = retVal Then
MsgBox "不能连接到视频设备!", vbInformation, App.Title
Else
#If USECALLBACKS = 1 Then
' if we have a valid capwnd we can enable our status callback function
Call capSetCallbackOnStatus(hCapWnd, AddressOf StatusProc)
Debug.Print "---Callback set on capture status---"
#End If
End If
'// Set the video stream callback function
' capSetCallbackOnVideoStream lwndC, AddressOf MyVideoStreamCallback
' capSetCallbackOnFrame lwndC, AddressOf MyFrameCallback
Dim bPlayFrameTop As Boolean
bPlayFrameTop = GetSetting(MyName, "setting" & "-" & Trim(Str(App.Major)) & "-" & Trim(Str(App.Minor)), "bPlayFrameTop", "False")
If bPlayFrameTop = True Then
Me.mnuOptionTop.Checked = True
'放在最前
SetWindowPos Me.hWnd, HWND_TOPMOST, Me.Left / Screen.TwipsPerPixelX, Me.Top / Screen.TwipsPerPixelY, Me.Width / Screen.TwipsPerPixelX, Me.Height / Screen.TwipsPerPixelY, &H20
Else
Me.mnuOptionTop.Checked = False
'不放在最前
SetWindowPos Me.hWnd, HWND_NOTOPMOST, Me.Left / Screen.TwipsPerPixelX, Me.Top / Screen.TwipsPerPixelY, Me.Width / Screen.TwipsPerPixelX, Me.Height / Screen.TwipsPerPixelY, &H20
End If
Me.Left = (Screen.Width - Me.Width) / 2
Me.Top = (Screen.Height - Me.Height) / 2
Me.picShowMenu.ZOrder 0
End Sub
'以下是一个模块文件
Option Explicit
'application specific routines are here
Public Const ONE_MEGABYTE As Long = 1048576
'Public Const MMSYSERR_NOERROR As Long = 0
Public Const INDEX_15_MINUTES As Long = 27000 '(30fps * 60sec * 15min)
Public Const INDEX_3_HOURS As Long = 324000 ' (30fps * 60sec * 60min * 3hr)
Public Function GetFreeSpace() As Long
'this function gets the amount of free disk space and adds the size
'of the current capture file
Dim freedisk As Long
Dim path As String
'get Cap File length
path = capFileGetCaptureFile(frmCaramaMain.capwnd)
If path <> "" Then
On Error Resume Next
freedisk = FileLen(path)
freedisk = freedisk / ONE_MEGABYTE
End If
'now get free disk space from that drive
path = Left$(path, 3)
GetFreeSpace = freedisk + vbGetAvailableMBytes(path)
End Function
Sub ResizeCaptureWindow(ByVal hCapWnd As Long)
Dim retVal As Boolean
Dim capStat As CAPSTATUS
'Get the capture window attributes
retVal = capGetStatus(hCapWnd, capStat)
If retVal Then
'Resize the main form to fit
Call SetWindowPos(frmCaramaMain.hWnd, _
0&, _
0&, _
0&, _
capStat.uiImageWidth + (frmCaramaMain.XBorder * 2), _
capStat.uiImageHeight + (frmCaramaMain.YBorder * 4) _
+ frmCaramaMain.CaptionHeight + frmCaramaMain.MenuHeight, _
Swp_nomove Or SWP_NOZORDER Or SWP_NOSENDCHANGING)
'Resize the capture window to format size
Call SetWindowPos(hCapWnd, _
0&, _
0&, _
0&, _
capStat.uiImageWidth, _
capStat.uiImageHeight, _
Swp_nomove Or SWP_NOZORDER Or SWP_NOSENDCHANGING)
End If
Call frmCaramaMain.Form_Resize
End Sub
Public Function VBEnumCapDrivers(ByRef frm As frmCaramaMain) As Long
'/*
' * Enumerate the potential capture drivers and add the list to the Options
' * menu. This function is only called once at startup.
' * Returns 0 if no drivers are available.
' */
Const MAXVIDDRIVERS As Long = 9
Const CAP_STRING_MAX As Long = 128
Dim numDrivers As Long
Dim driverStrings(0 To MAXVIDDRIVERS - 1) As String
Dim Index As Long
Dim Device As String
Dim Version As String
Dim menu As VB.menu
Device = String$(CAP_STRING_MAX, 0)
Version = String$(CAP_STRING_MAX, 0)
numDrivers = 0
For Index = 0 To (MAXVIDDRIVERS - 1) Step 1
If 0 <> capGetDriverDescription(Index, _
Device, _
CAP_STRING_MAX, _
Version, _
CAP_STRING_MAX) _
Then
'extend the menu
If Index > 0 Then
Load frm.mnuDriver(Index)
End If
Set menu = frm.mnuDriver(Index) 'get an object pointer to the new menu
'Concatenate the device name and version strings to the new menu item
menu.Caption = Left$(Device, InStr(Device, vbNullChar) - 1)
menu.Caption = menu.Caption & " "
menu.Caption = menu.Caption & Left$(Version, InStr(Version, vbNullChar) - 1)
menu.Enabled = True
numDrivers = numDrivers + 1
End If
Next
VBEnumCapDrivers = numDrivers
End Function
Public Function ConnectCapDriver(ByVal hCapWnd As Long, ByVal nDriverIndex As Long) As Boolean
Dim retVal As Boolean
Dim Caps As CAPDRIVERCAPS
Dim i As Long
Debug.Assert (nDriverIndex < 10) And (nDriverIndex >= 0)
'// Connect the capture window to the driver
retVal = capDriverConnect(hCapWnd, nDriverIndex)
If False = retVal Then
'return False
Exit Function
End If
'// Get the capabilities of the capture driver
retVal = capDriverGetCaps(hCapWnd, Caps)
If False <> retVal Then
'reset menus (very app-specific)
With frmCaramaMain
For i = 0 To .mnuDriver.UBound
.mnuDriver(i).Checked = False 'make sure all drivers are unchecked
Next
.mnuDriver(nDriverIndex).Checked = True 'then check the new driver
'disable all hardware feature menu items
.mnuSource.Enabled = False
.mnuFormat.Enabled = False
.mnuDisplay.Enabled = False
.mnuOverlay.Enabled = False
'Then enable the ones which are supported by the new driver
If Caps.fHasDlgVideoSource <> 0 Then .mnuSource.Enabled = True
If Caps.fHasDlgVideoFormat <> 0 Then .mnuFormat.Enabled = True
If Caps.fHasDlgVideoDisplay <> 0 Then .mnuDisplay.Enabled = True
If Caps.fHasOverlay <> 0 Then .mnuOverlay.Enabled = True
End With
End If
'// Set the preview rate in milliseconds
Call capPreviewRate(hCapWnd, 66) '15 FPS
'// Start previewing the image from the camera
Call capPreview(hCapWnd, True)
'default to showing a preview each time
frmCaramaMain.mnuPreview.Checked = True
'// Resize the capture window to show the whole image
Call ResizeCaptureWindow(hCapWnd)
ConnectCapDriver = True
End Function
Public Function StatusProc(ByVal hCapWnd As Long, ByVal StatusCode As Long, ByVal lpStatusString As Long) As Long
Select Case StatusCode
Case 0 'this is recommended in docs
'when zero is sent, clear old status messages
'frmCaramaMain.Caption = App.Title
Case IDS_CAP_END ' Video Capture has finished
frmCaramaMain.Caption = App.Title
Case IDS_CAP_STAT_VIDEOAUDIO, IDS_CAP_STAT_VIDEOONLY
MsgBox LPSTRtoVBString(lpStatusString), vbInformation, App.Title
Case Else
'use this function if you need a real VB string
'frmCaramaMain.Caption = LPSTRtoVBString(lpStatusString)
'or, just pass the LPCSTR to a WINAPI function
Call SetWindowTextAsLong(frmCaramaMain.hWnd, lpStatusString)
End Select
Debug.Print "Driver returned code " & StatusCode & " to StatusProc"
StatusProc = -(True) '- converts Boolean to C BOOL
End Function
‘玖’ 怎么在cm10.1源码树添加自己的device编译
怎么在cm10.1源码树添加自己的device编译
打开,可以看到
for combo in $(curl -s https://raw.github.com/CyanogenMod/hudson/master/cm-build-targets | sed -e 's/#.*$//' | grep cm-10.1 | awk {'print $1'})
do
add_lunch_combo $combo
done
在这里添加自己需要编译的设备就可以了,改成如下:
for combo in $(curl -s https://raw.github.com/CyanogenMod/hudson/master/cm-build-targets | sed -e 's/#.*$//' | grep cm-10.1 | awk {'print $1'})
do
add_lunch_combo $combo
add_lunch_combo cm_u8833
done
改好之后执行. build/envsetup.sh
再执行 lunch