其實就到處 grep download。
frame/base/core/java/android/webkit/CallbackProxy.java:
的 handleMessage(Message msg)
 
 switch (msg.what) {
  ....
           case DOWNLOAD_FILE:
                if (mDownloadListener != null) {
                    String url = msg.getData().getString("url");
                    String userAgent = msg.getData().getString("userAgent");
                    String contentDisposition =
                        msg.getData().getString("contentDisposition");
                    String mimetype = msg.getData().getString("mimetype");
                    Long contentLength = msg.getData().getLong("contentLength");
                    mDownloadListener.onDownloadStart(url, userAgent,
                            contentDisposition, mimetype, contentLength);
                }
                break;
但是grep DOWNLOAD_FILE,好像是 CallbackProxy.java 自己的 constant。
只有在 :
    public boolean onDownloadStart(String url, String userAgent,
使用到。
CallbackProxy -- call: DownloadListener.onDownloadStart
---結果 DownloadListener 是 interface,
有 implement DownloadListener 這個 interface 的有:
.. ? 只有 packages/apps/Browser/src/com/android/browser/BrowserActivity.java
.. 所以是 ap 自己要負責 ?
BrowserActivity 真的在 implement onDownloadStart( ) 時,很盡職的準備好 intent,然後用 StartActivity 叫起 DownloadManager (我猜的..)
所以要回去 trace CallbackProxy 了:
CallbackProxy.onDownloadStart( ) 準備好 message,然後CallbackProxy.handleMessage( ) 才去 call DownloadListener.onDownloadStart( )。
-- 所以是 callbackProxy.onDownloadStart 起的頭。
/framework/base/core/java/android/webkit/LoadListener.java:
    void downloadFile() {
        // remove the cache
        WebViewWorker.getHandler().obtainMessage(
                WebViewWorker.MSG_REMOVE_CACHE, this).sendToTarget();
        // Inform the client that they should download a file
        mBrowserFrame.getCallbackProxy().onDownloadStart(url(), 
                mBrowserFrame.getUserAgentString(),
                mHeaders.getContentDisposition(), 
                mMimeType, mContentLength);
        // Cancel the download. We need to stop the http load.
        // The native loader object will get cleared by the call to
        // cancel() but will also be cleared on the WebCore side
        // when this function returns.
        cancel();
    }
然後....找不到 call downloadFile 的 code....
function 的 comment 非常好心的說明:
    /*
     * This function is called from native WebCore code to
     * notify this LoadListener that the content it is currently
     * downloading should be saved to a file and not sent to
     * WebCore.
     */
所以去找找 WebCore ..改 Browser 就好。
download 的動作是 callback..
所以改 Browser 的 BrowserActivity.java:
其中:OnDownloadStartNoStream( ) 是負責將 download 排入 downloadmanager 的 function。
所以comment 掉 call 這個 function 的 code 就可以。
沒有留言:
張貼留言