playframework源码
㈠ Android Framework 之 使用系统编译的文件 添加到 SDK 的源码
在上一篇文章中: Android Framework 添加新的 系统服务
我们添加了 新的 系统服务 DemoManagerService, 客户端可以通过 DemoManager.java 访问。
但是 使用 Android Studio 新建一个项目时,是不能直接使用DemoManager.java, 因为当前Android Studio使用的是Google 原生的SDK (API31),并没没有我们新增的服务.
由此,产生一个debug 的需求: 使用系统编译的文件 替换掉 SDK 的源码
以达到我们可以在Android studio 可以使用新的服务。
总的思想是,将新增、修改的类的编译成字节码文件,然后把它放到 android.jar中.
(JAVA_LIBRARIES, 不同厂商产物不一样)
例如路径: androidout argetcommonobjJAVA_LIBRARIESframework_intermediates
然后解压这个路径下 class 的 jar 包
则可以在路径:
(1) androidapp 下, 找到:
(2) androidcontent
先找到 如: [SDK安装路径]platformsandroid-31目录,
将目录下的 android.jar 解压,将上面的五个文件, 添加到SDK 源码对应的目录中,即
[SDK安装路径]platformsandroid-31androidandroidapp
[SDK安装路径]platformsandroid-31androidandroidcontent
然后,重新压缩 android文件, 并把后缀改为 android.jar (即替换掉原来的android.jar)
则可以使用DemoManager
㈡ android 怎么看framework层源码
查看函数的调用树,变量的数据流。第二种是借助 debug 工具或者 log 日志在代码动态执行的过程中查看程序的执行情况。
在 android studio 中使用 alt + f7,可以快速查看某个符号被使用的位置,包括函数名、字段名、变量名等等,还可以快速查看到该函数的调用树,变量的数据流
如果代码执行逻辑我们自己可控制,在我们可以控制的地方添加 log 打印,可以很快检测该分支逻辑执行情况;如果代码不是我们自己可以控制的,就只能使用 debug 调试查看代码分支的执行起情况了
在 debug 的时候使用跳转到函数的内部,可以追踪到 framework 层源码的执行逻辑
在 debug 的时候可以看到函数的调用栈,能够一下子就明白在这种场景下,该函数在
㈢ 如何调试跟踪Android Framework源代码
本文讲解如何在Eclipse中导入Android源代码(包括Framework和Application的代码),然后通过模拟器或真机跟踪/调试Android的Java代码,区别于一般基于Android SDK的纯应用开发,这里可以跟踪/调试Framework中的代码。
一、准备工作
确保机器上已经安装并配置下列软件环境:JDK/ Eclipse / Android SDK / ADT
即,机器上已经安装了Eclipse下Android应用开发所需的环境。如果还未配置,移步《搭建Windows下Android应用开发环境——Eclipse/Android/ADT》。
另外,为了跟踪调试Android源码,你还需要有Android源码,并有源码的编译环境,可以是:
虚拟机环境 虚拟机中安装Linux,Linux下编译Android源码。此环境下,如果要在宿主机的Eclipse中调试,还需要把Android的源码路径共享出来,宿主机可访问到;
有单独的可编译Android的网络环境 在你的客户端的机器上访问服务器共享出来的Android的源码路径;
Linux环境下直接通过Eclipse跟踪调试本机上的Android源码。
-Xms40m
-Xmx384m
-Xms128m
-Xmx512m
注意:不管哪种工作方式,Android源码要都是已经编译过的,且编译时采用的是Eng模式(vs User mode)。编译Android Platform和Kernel的过程,可参考《Ubuntu10.10下编译Android2.2平台》及《Ubuntu10.10下编译Android2.2内核》。
二、基本设置
准备工作完毕之后,现在做一些基本的设置。
1. 把Android源码路径<Android_ROOT>下的developmentideeclipse中的.classpath文件复制到<Android_ROOT>下;如果需要在模拟器中进行调试的话,需要复制三个img(具体方法见http://wenku..com/view/26d9063c87c24028915fc366.html)
2. 修改Eclipse的设置
修改eclipse.ini文件,更改下列内容:
[plain]view plain
改为:
[java]view plain
这里增大最小Java堆大小到128MB,增大最大Java堆大小到512MB。
三、Eclipse中创建工程
1. File > New > Java Project
㈣ 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