레이블이 Android인 게시물을 표시합니다. 모든 게시물 표시
레이블이 Android인 게시물을 표시합니다. 모든 게시물 표시

2016년 9월 2일 금요일

Download data uri in Chromium Android

As a nice demo website shows, web developer can save a file via data uri. I am writing to explain how data uri is saved in chromium in this post.

When we open data uri, chromium starts a new blob url request job and when it finishes reading header information, then it will notify the completion of it.

Blob is handled by storage module and data response handling is done by net and browser loader modules.

|STORAGE| --> |NET| --> |CONTENT/BROWSER/LOADER|

From code level, we can start from loader module in content browser by |ThrottlingResourceHandler::OnResponseStarted|

This function iterated pre-registered throttles to be confirmed if any specific throttle wants to handle it. For example, when we see |InterceptDownloadResourceThrottle::ProcessDownloadRequest|, HTTP or HTTPS are handled by Android specific download delegate. However, as this post focuses on data uri handling, code will be interrupted by below condition.

  if (!url.SchemeIsHTTPOrHTTPS()) {
    RecordInterceptFailureReasons(NON_HTTP_OR_HTTPS);
    return;
  }


Let's go back where I described about pre-registered throttles iteration. So suppose there is no throttle want to handle response, code will flow into next handler. e.g. |DownloadRequestCore::OnResponseStarted|

From this point, we will see bunch of asynchronous operation happened in same browser process but sometimes in different thread. In my humble opinion, this prevents system from not responding status that hurts user experience. By the way, brief code flows are:

<Download>
|DownloadResourceHandler::OnStart| --> |DownloadManagerImpl::StartDownload| --> |DownloadItemImpl::Start| --> |DownloadFile::Initialize|

<Notify download started>
|DownloadFile::Initialize| --> |DownloadController::OnDownloadStarted| -> |ChromeDownloadDelegate::OnDownloadStarted| --> |ChromeDownloadDelegate#onDownloadStarted|

I also recommend to read nice sequence diagrame.

Hope this post saves your time from debugging. Happy hacking!

(Debugging was done with 53.0.2785.0 version)

2015년 10월 13일 화요일

Gradle build error on multidex library

When you meet this kind of error:

Could not resolve com.android.support:multidex:1.0.1

 You probably have added multidex support for targets lower than Android 5.0 like:

multiDexEnabled true

Solution is to install 'Android Support Repository' in 'SDK Manager'


[1] https://developer.android.com/tools/support-library/features.html#multidex
[2] https://developer.android.com/tools/support-library/setup.html#libs-without-res

2011년 12월 6일 화요일

How to use Android 4.0 ICS sdk manager on linux behind firewall

I am not 100% sure if there is other ways to use sdk manager on linux for ICS sdk manager.
My tips are:

pre-condition : suppose you have source code of ICS

1. Modify 'sdk/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/SettingsController.java'
- In 'getForceHttp' method,
return true;
//return Boolean.parseBoolean(mProperties.getProperty(ISettingsPage.KEY_FORCE_HTTP));

2. 'sdk/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/UrlOpener.java'
- In 'openWithHttpClient' method
add 2 lines of import..

import org.apache.http.conn.params.ConnRoutePNames;
import org.apache.http.HttpHost;

and modify like below

// use the simple one
final DefaultHttpClient httpClient = new DefaultHttpClient();

// newly added
HttpHost proxy = new HttpHost("{proxy address}", {proxy port});
httpClient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);

2011년 12월 5일 월요일

Get Android 4.0 ICS source code behind firewall

I've just pulled Android 4.0 ICS source code by using repo shell command behind firewall.
What I've done are:
1. In home directory
$ mkdir bin # create bin directory as Android recommends
$ vi .bashrc # add bin directory to PATH environment
2. Add below line to .bashrc file
export PATH=/home/{user_name}/bin:$PATH
3. Save and adapt changes
$ source .bashrc
4. Get repo shell
# install curl if you don't have it by using synaptic package installer or apt-get ...
$ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo
> ~/bin/repo --proxy {proxy_ip}:{proxy_port}
$ chmod a+x ~/bin/repo # add executable attribute to shell file
5. Create working directory and move into it
$ mkdir Android && cd Android
6. export http_proxy attribute
$ export http_proxy={proxy_ip}:{proxy_port}
7. Init repo branch
$ repo init -u https://android.googlesource.com/platform/manifest # for checking out other branches see android developer page
8. Finally you can get the source code
$ repo sync

Enjoy ICS!