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