Posts

Dig into Https client connection in Android

Dig into Https client connection in Android Table of Contents reference resources Java Keytool Certificate formats Use Https in Android Client Java SSLContext Two ways SSL verification TLSDemo 1 reference resources http://developer.android.com/training/articles/security-ssl.html http://ogrelab.ikratko.com/using-android-volley-with-self-signed-certificate/ http://stackoverflow.com/questions/2138940/import-pem-into-java-key-store http://stackoverflow.com/questions/3685548/java-keytool-easy-way-to-add-server-cert-from-url-port 2 Java Keytool Java keystore is like a database which store certificates and private keys and protect them by a password maybe. There are at least three format s of that, JKS, PKCS12, JCEKS, and many more. But in this tutorial, I only consider two formats of that JKS which is the Java's default format and BKS which is the Android's default format. How to import a certificate to the BKS style KeyStore? First step was to pr...

Merge branches in Git

Merge branches in Git Few days ago, my superior gave a task to make a presentation about the daily usage of git for R&D department, so I resumed the git pro book to prepare this presentation. And the following article is to recognize my former wrong and unclear opinion about branch merging in git, and a little suggestion about branch management. So how to merge two branches? There are two methods to merge two branches, merge and rebase. Merge method is to merge two branch and generate a new commitment, whose parents are the two HEAD of the older branch. This is called a cross in the branch network. While the rebase method is to re-play every commitment of a branch to another branch, and there are no cross between them after two branch's rebase. And the best way to check the branches is working in right way is to check if there are crosses in branches. So the recommended method of combine two branches is to always use rebase instead of the merge. Because If you always u...

How to configure Samba Server in Ubuntu?

How to configure Samba Server in Ubuntu? Table of Contents What is Samba? Target Prepare configure /etc/samba/smb.conf 1 What is Samba? Samba is a linux implementation of file share and transaction protocol for LAN, which mainly used in Windows OS. Samba is more convenient than FTP in my opinion, and it is useful in a small group who works in a same LAN, but its members are familiar with different OS, Bob works in Mac, David works in Ubuntu, while Mars likes Windows more. 2  Target This tutorial is a step to step document of how to build a Samba Server which met the following requirement: Share a Directory with both readable and writable authority for Guest. Share a Directory with both readable and writable authority for certain Users. Share a Directory with only readable authority for Guest. 3 Prepare addgroup smbgrp adduser abc smbgrp smbpasswd -a abc mkdir /xxx/path chown -R abc:smbgrp /xxx/path mkdir /xxx/public chown -R nobody:nogroup...

How to configure Android project's build types in Gradle?

Image
How to configure Android project's build types in Gradle? Table of Contents Generate Java Constants Generate Android resources A few days ago, our team needs to configure the Gradle's build scripts to auto build the project. Here is the requirement, to build three versions of app, release, development and test, from the command line. I found the ways from the following link, http://stackoverflow.com/questions/17197636/is-it-possible-to-declare-a-variable-in-gradle-usable-in-java Actually, we can generate the Java constants and Android resources from the Gradle's build script: 1 Generate Java Constants android { buildTypes { debug { buildConfigField "int" , "FOO" , "42" buildConfigField "String" , "FOO_STRING" , "\"foo\"" } release { buildConfigField "int" , "FOO" , "52" ...

My Android JNI Tutorial

Image
My Android JNI Tutorial Since I worked for my current employer, I found out my passion of writing was dropping down dramatically. My salary was raised and also got a promotion, but my ambition for the software looks have not evolved. So what is my favorite? coding and writing. I should keep that in my mind. I reviewed what I did in the last few months, there are one thing suit my desire of writing. I wrote a JNI module to process the jbig compressed image, both decoding and encoding, actually I initially allocated this job to one of my former colleague, but it looks so sucks, then I have to refactor his code after his resignation, basically rewrote the code. This is my first time to wrote JNI code with android-ndk, also my former jobs included a few JNI tasks, but it is in android system development not as an app developer. Here are my experience and summary of JNI coding. 1. How to design JNI code? Load the sharable library in static code in java part.   ...

How to extract or backup apk from android system?

As an android developer, I always wanna hack awesome app to learn its design inside. The first step of that is to get the APK file itself, and the obvious way to do that is to extract it from our android phone. There are two ways to make that, both of them need no root privilege. 1. Use android adb backup command adb shell pm list packages adb backup -apk com.google.android.wearable.app dd if=backup.ab bs=1 skip=24 | python -c “import zlib,sys;sys.stdout.write(zlib.decompress(sys.stdin.read()))” | tar -xvf - 2. Use adb package management cmd  adb shell pm list packages  adb shell pm path com.google.android.wearable.app  adb pull /data/app/com.google.android.wearable.app-1.apk

Learning a new way to release and package python source code

Image
This article is one part of learning notebook after I read the youtube-dl 's source code, I learned a lot of knowledge from this software, I guess the most interesting part is found two porn website inside it, haha. The anther interesting thing, I learned from its source code, is a python packaging technology. It is a new way to release or publish python software. Before I learned this way, I always use the following two methods to publish python software. Just release the raw source code. Use the package management tools like setuptools or distutils But, youtube-dl release itself in a standalone executable single file. So I read its build script, it zipped all its source code into a package and it is its way to make an executable file. I guess python interpreter has the capacity of interpreting source code from the zip file. As usual, I wrote some sample code to illustrate how this way works, and you can browser sample code from the following site. https://githu...