Thursday, May 28, 2015

Android Development**

Work in Progress....
Android Arsenal:
http://android-arsenal.com/

Android Developers Blog:
http://android-developers.blogspot.com/
http://developer.android.com/develop/index.html

Google i/o 2015:
https://events.google.com/io2015/

Google design Guidelines:
http://www.google.com/design/articles/design-from-ios-to-android/

icons:
https://www.google.com/design/icons/

Backend for Android:
https://www.parse.com/
https://www.firebase.com/

Android Security:
https://www.airpair.com/android/posts/adding-tampering-detection-to-your-android-app
https://manifestsecurity.com/android-application-security-part-21/


Android Dev Sumit:
FYI Android Dev Summit Videos are on youtube.
Day two https://www.youtube.com/watch?v=JtdqDvgWGNA

Code samples from the conference:

CodePath Resources:
RecyclerView:
Android UI:

Security Tools:
2. Drozer- 
 Android UI testing w/ espresso:

testing:

Monday, May 11, 2015

Android and Gradle

Gradle: is a build system for Android apps.

First install gradlehttps://gradle.org/downloads/

Info:
Below image shows three directories
1. Vanilla
2. Strawberry
3. Main

Vanilla and Strawberry are the apk build flavors, this both dirctories by default will use the settings from Main folders(java/... ; res/...; AndroidManifest.xml), if we declare this folders inside Vanilla or Strawberry it will override the setting from Main.
Ex:
Change icon for Vanilla apk. You can modified the app icon by adding res directory to the project.


Commands:
run: $chmod +x gradlew

info: $./gradlew -P
Generate APKs: $./gradlew assemble
Generate Taks: $./gradlew tasks 
Install apk build genreated by tasks: $./gradlew installVanillaDebug 

build- generates .apk file, need to configure: $./gradlew build

clean- deletes the generated .apk file: $./gradlew clean

version: $./gradlew -v

Enable the Gradle Daemon:
Via properties file - add org.gradle.daemon=true to GRADLE_USER_HOME»/gradle.properties
Reference:

Thursday, April 9, 2015

Good Resources/Tutorials

Good Readings:
IBM http://securityintelligence.com/mobile-insecurity/#.VSbwmXDF-Xw

Good tutorials:
https://geekytheory.com
http://hackr.io/


Security:
http://builditsecure.ly/
https://androidsecuritywiki.com/
Good Android tutorial:
http://www.learncomputer.com/android-interview-questions/

tools:
http://www.android4devs.com/2014/07/5-tools-every-android-developer-must.html

Gradle:
http://www.techotopia.com/index.php/An_Overview_of_Gradle_in_Android_Studio
https://www.youtube.com/watch?v=g56O_HeefBE
https://gradle.org/getting-started-android/#build-operator
https://gradle.org/docs/current/userguide/tutorial_using_tasks.html


Material Design:
http://www.androidhive.info/2015/04/android-getting-started-with-material-design/

-proguard:
http://developer.android.com/tools/help/proguard.html

-lifecycle:
http://programmerguru.com/android-tutorial/activity-life-cycle/

-sharedata:
http://programmerguru.com/android-tutorial/how-to-send-simple-data-to-other-apps/

-facebook:
https://code.facebook.com/projects/android/
https://newsroom.fb.com/news/2015/04/introducing-hello/
https://www.hackerrank.com

-Interview questions:
http://www.toptal.com/android/interview-questions
http://www.itechaleart.com/2015/02/android-interview-qa.html
good:
http://www.androidinterview.com/android-fragment-tutorial-example/
file:///Users/andres/Downloads/Android%20Interview%20Questions.pdf


Scala:
http://www.scala-lang.org/docu/files/ScalaByExample.pdf

Java:
Big O-
http://bigocheatsheet.com/
http://www.corejavainterviewquestions.com/idiots-guide-big-o/

Java Interview q's:
http://www.programmingsimplified.com/java/source-code/java-program-find-factorial
http://www.newthinktank.com/category/web-design/java-video-tutorial/
https://www.youtube.com/watch?v=M6lYob8STMI
http://www.tutorialspoint.com/java/java_basic_operators.html
http://java2novice.com/java-interview-programs/fibonacci-series/


People Skills:
https://www.linkedin.com/pulse/7-skills-extraordinarily-likable-people-jeff-haden


Work/Family Balance:

Phone Screens:
https://sites.google.com/site/steveyegge2/five-essential-phone-screen-questions


Common Interview questions:
https://www.themuse.com/advice/interview-translation-what-4-common-questions-really-mean

https://www.facebook.com/notes/facebook-engineering/get-that-job-at-facebook/10150964382448920





Wednesday, April 8, 2015

List of useful Linux commands (Work in progress)

Email me if you know other useful/cool commands :)

Command: tree
Displays file structure of directory
Install:
$brew update (first install brew how to Install)
$brew install tree
$tree



Command: >
Saves output of command to a file
$cat device.config > device.txt


Other commands:
ls
cd

vi
:wq
:q!


More commands coming soon :)

Work in Progress...

Wednesday, April 1, 2015

How to recognize USB in VirtualBox. (to use $adb devices)

Today I had an issue using Ubunutu14 with my VirtualBox image, it was not able to recognize when I plugin my android device. When I type $adb devices it didnt appear.

Steps to resolve:
1. You need to install gnome-system-tools
$sudo apt-get install gnome-system-tools

2. Dash home and type: users, select Users and Groups -> Advanced settings


3.  Select: Use VirtualBox virtualization solution

4. Reboot 

5. Now go to your VM and it will recognize the USB and you are able. 
$adb devices , and your device will appear. 




Reference:
http://askubuntu.com/questions/140081/virtualbox-doesnt-recognize-usb

Thursday, March 12, 2015

How to install Python3 with brew(mac)

$brew install python3

You will see below process:
==> Installing dependencies for python3: xz, pkg-config, readline, sqlite, gdbm, openssl
==> Installing python3 dependency: xz
==> Downloading https://homebrew.bintray.com/bottles/xz-5.2.1.yosemite.bottle.tar.gz
######################################################################## 100.0%
==> Pouring xz-5.2.1.yosemite.bottle.tar.gz
🍺  /usr/local/Cellar/xz/5.2.1: 59 files, 1.7M
==> Installing python3 dependency: pkg-config
==> Downloading https://homebrew.bintray.com/bottles/pkg-config-0.28.yosemite.bottle.2.tar.gz
######################################################################## 100.0%
==> Pouring pkg-config-0.28.yosemite.bottle.2.tar.gz
🍺  /usr/local/Cellar/pkg-config/0.28: 10 files, 612K
==> Installing python3 dependency: readline
==> Downloading https://homebrew.bintray.com/bottles/readline-6.3.8.yosemite.bottle.tar.gz
######################################################################## 100.0%
==> Pouring readline-6.3.8.yosemite.bottle.tar.gz
==> Caveats
This formula is keg-only, which means it was not symlinked into /usr/local.

Mac OS X provides similar software, and installing this software in
parallel can cause all kinds of trouble.

OS X provides the BSD libedit library, which shadows libreadline.
In order to prevent conflicts when programs look for libreadline we are
defaulting this GNU Readline installation to keg-only.

Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

    LDFLAGS:  -L/usr/local/opt/readline/lib
    CPPFLAGS: -I/usr/local/opt/readline/include

==> Summary
🍺  /usr/local/Cellar/readline/6.3.8: 40 files, 2.1M
==> Installing python3 dependency: sqlite
==> Downloading https://homebrew.bintray.com/bottles/sqlite-3.8.8.3.yosemite.bottle.tar.gz
######################################################################## 100.0%
==> Pouring sqlite-3.8.8.3.yosemite.bottle.tar.gz
==> Caveats
This formula is keg-only, which means it was not symlinked into /usr/local.

Mac OS X already provides this software and installing another version in
parallel can cause all kinds of trouble.

OS X provides an older sqlite3.

Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

    LDFLAGS:  -L/usr/local/opt/sqlite/lib
    CPPFLAGS: -I/usr/local/opt/sqlite/include

==> Summary
🍺  /usr/local/Cellar/sqlite/3.8.8.3: 9 files, 2.1M
==> Installing python3 dependency: gdbm
==> Downloading https://homebrew.bintray.com/bottles/gdbm-1.11.yosemite.bottle.2.tar.gz
######################################################################## 100.0%
==> Pouring gdbm-1.11.yosemite.bottle.2.tar.gz
🍺  /usr/local/Cellar/gdbm/1.11: 17 files, 532K
==> Installing python3 dependency: openssl
==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2.yosemite.bottle.tar.gz
######################################################################## 100.0%
==> Pouring openssl-1.0.2.yosemite.bottle.tar.gz
==> Caveats
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
  /usr/local/etc/openssl/certs

and run
  /usr/local/opt/openssl/bin/c_rehash

This formula is keg-only, which means it was not symlinked into /usr/local.

Mac OS X already provides this software and installing another version in
parallel can cause all kinds of trouble.

Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries

Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

    LDFLAGS:  -L/usr/local/opt/openssl/lib
    CPPFLAGS: -I/usr/local/opt/openssl/include

==> Summary
🍺  /usr/local/Cellar/openssl/1.0.2: 459 files,  18M
==> Installing python3
==> Downloading https://www.python.org/ftp/python/3.4.3/Python-3.4.3.tar.xz
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/python3/3.4.3 --enable-ipv6 --datarootdir=/usr/local/Cellar/python3/3.4.3/share --datadir=/u
==> make
==> make install PYTHONAPPSDIR=/usr/local/Cellar/python3/3.4.3
==> make frameworkinstallextras PYTHONAPPSDIR=/usr/local/Cellar/python3/3.4.3/share/python3
==> Downloading https://pypi.python.org/packages/source/s/setuptools/setuptools-12.2.tar.gz
######################################################################## 100.0%
==> Downloading https://pypi.python.org/packages/source/p/pip/pip-6.0.8.tar.gz
######################################################################## 100.0%
==> Caveats
Pip and setuptools have been installed. To update them
  pip3 install --upgrade pip setuptools

You can install Python packages with
  pip3 install <package>

They will install into the site-package directory
  /usr/local/lib/python3.4/site-packages

See: https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/Homebrew-and-Python.md

.app bundles were installed.
Run `brew linkapps python3` to symlink these to /Applications.
==> /usr/local/Cellar/python3/3.4.3/bin/python3 -s setup.py --no-user-cfg install --force --verbose --install-scripts=/usr/local/Cellar
==> /usr/local/Cellar/python3/3.4.3/bin/python3 -s setup.py --no-user-cfg install --force --verbose --install-scripts=/usr/local/Cellar
==> Summary
🍺  /usr/local/Cellar/python3/3.4.3: 5899 files, 100M, built in 2.7 minutes
Andress-MBP:~ andres$ python
Python 2.7.6 (default, Sep  9 2014, 15:04:36) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

>>> 

Add django:
Andress-MBP:/ andres$ open usr/local/Cellar/python3.4.3
location:
$open /usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4

Wednesday, March 11, 2015

Handy ADB commands

More cool adb tricks here
  • Command to find location of apk for specific appName
$adb shell pm list packages -f | grep AppName
output:
package:/data/app/com.packageName.AppName-2/base.apk=com.packageName. AppName
  • Pull App apk
$adb pull /data/app/com.packageName.AppName-2/base.apk /Download/Location 

ADB root access:
$adb shell
$su //now you have adb root access

Android 6.0 Permissions:
Granting and revoking runtime permissions:
$adb shell pm grant/revoke my.package.name some.permission.NAME

Installing an app with all permissions granted:
$adb install -g my.package.name

Dumping app permission state:
$adb shell dumpsys package my.package.name

Show all Android permissions:
adb shell pm list permissions -d -g


To display ADB commands:
open terminal and type $adb help

AndroidSs-MacBook-Air:~ android$ adb help
Android Debug Bridge version 1.0.32

 -a                            - directs adb to listen on all interfaces for a connection
 -d                            - directs command to the only connected USB device
                                 returns an error if more than one USB device is present.
 -e                            - directs command to the only running emulator.
                                 returns an error if more than one emulator is running.
 -s <specific device>          - directs command to the device or emulator with the given
                                 serial number or qualifier. Overrides ANDROID_SERIAL
                                 environment variable.
 -p <product name or path>     - simple product name like 'sooner', or
                                 a relative/absolute path to a product
                                 out directory like 'out/target/product/sooner'.
                                 If -p is not specified, the ANDROID_PRODUCT_OUT
                                 environment variable is used, which must
                                 be an absolute path.
 -H                            - Name of adb server host (default: localhost)
 -P                            - Port of adb server (default: 5037)
 devices [-l]                  - list all connected devices
                                 ('-l' will also list device qualifiers)
 connect <host>[:<port>]       - connect to a device via TCP/IP
                                 Port 5555 is used by default if no port number is specified.
 disconnect [<host>[:<port>]]  - disconnect from a TCP/IP device.
                                 Port 5555 is used by default if no port number is specified.
                                 Using this command with no additional arguments
                                 will disconnect from all connected TCP/IP devices.

device commands:
  adb push [-p] <local> <remote>
                               - copy file/dir to device
                                 ('-p' to display the transfer progress)
  adb pull [-p] [-a] <remote> [<local>]
                               - copy file/dir from device
                                 ('-p' to display the transfer progress)
                                 ('-a' means copy timestamp and mode)
  adb sync [ <directory> ]     - copy host->device only if changed
                                 (-l means list but don't copy)
                                 (see 'adb help all')
  adb shell                    - run remote shell interactively
  adb shell <command>          - run remote shell command
  adb emu <command>            - run emulator console command
  adb logcat [ <filter-spec> ] - View device log
  adb forward --list           - list all forward socket connections.
                                 the format is a list of lines with the following format:
                                    <serial> " " <local> " " <remote> "\n"
  adb forward <local> <remote> - forward socket connections
                                 forward specs are one of: 
                                   tcp:<port>
                                   localabstract:<unix domain socket name>
                                   localreserved:<unix domain socket name>
                                   localfilesystem:<unix domain socket name>
                                   dev:<character device name>
                                   jdwp:<process pid> (remote only)
  adb forward --no-rebind <local> <remote>
                               - same as 'adb forward <local> <remote>' but fails
                                 if <local> is already forwarded
  adb forward --remove <local> - remove a specific forward socket connection
  adb forward --remove-all     - remove all forward socket connections
  adb reverse --list           - list all reverse socket connections from device
  adb reverse <remote> <local> - reverse socket connections
                                 reverse specs are one of:
                                   tcp:<port>
                                   localabstract:<unix domain socket name>
                                   localreserved:<unix domain socket name>
                                   localfilesystem:<unix domain socket name>
  adb reverse --norebind <remote> <local>
                               - same as 'adb reverse <remote> <local>' but fails
                                 if <remote> is already reversed.
  adb reverse --remove <remote>
                               - remove a specific reversed socket connection
  adb reverse --remove-all     - remove all reversed socket connections from device
  adb jdwp                     - list PIDs of processes hosting a JDWP transport
  adb install [-lrtsd] <file>
  adb install-multiple [-lrtsdp] <file...>
                               - push this package file to the device and install it
                                 (-l: forward lock application)
                                 (-r: replace existing application)
                                 (-t: allow test packages)
                                 (-s: install application on sdcard)
                                 (-d: allow version code downgrade)
                                 (-p: partial application install)
  adb uninstall [-k] <package> - remove this app package from the device
                                 ('-k' means keep the data and cache directories)
  adb bugreport                - return all information from the device
                                 that should be included in a bug report.

  adb backup [-f <file>] [-apk|-noapk] [-obb|-noobb] [-shared|-noshared] [-all] [-system|-nosystem] [<packages...>]
                               - write an archive of the device's data to <file>.
                                 If no -f option is supplied then the data is written
                                 to "backup.ab" in the current directory.
                                 (-apk|-noapk enable/disable backup of the .apks themselves
                                    in the archive; the default is noapk.)
                                 (-obb|-noobb enable/disable backup of any installed apk expansion
                                    (aka .obb) files associated with each application; the default
                                    is noobb.)
                                 (-shared|-noshared enable/disable backup of the device's
                                    shared storage / SD card contents; the default is noshared.)
                                 (-all means to back up all installed applications)
                                 (-system|-nosystem toggles whether -all automatically includes
                                    system applications; the default is to include system apps)
                                 (<packages...> is the list of applications to be backed up.  If
                                    the -all or -shared flags are passed, then the package
                                    list is optional.  Applications explicitly given on the
                                    command line will be included even if -nosystem would
                                    ordinarily cause them to be omitted.)

  adb restore <file>           - restore device contents from the <file> backup archive

  adb help                     - show this help message
  adb version                  - show version num

scripting:
  adb wait-for-device          - block until device is online
  adb start-server             - ensure that there is a server running
  adb kill-server              - kill the server if it is running
  adb get-state                - prints: offline | bootloader | device
  adb get-serialno             - prints: <serial-number>
  adb get-devpath              - prints: <device-path>
  adb status-window            - continuously print device status for a specified device
  adb remount                  - remounts the /system and /vendor (if present) partitions on the device read-write
  adb reboot [bootloader|recovery] - reboots the device, optionally into the bootloader or recovery program
  adb reboot-bootloader        - reboots the device into the bootloader
  adb root                     - restarts the adbd daemon with root permissions
  adb usb                      - restarts the adbd daemon listening on USB
  adb tcpip <port>             - restarts the adbd daemon listening on TCP on the specified port
networking:
  adb ppp <tty> [parameters]   - Run PPP over USB.
 Note: you should not automatically start a PPP connection.
 <tty> refers to the tty for PPP stream. Eg. dev:/dev/omap_csmi_tty1
 [parameters] - Eg. defaultroute debug dump local notty usepeerdns

adb sync notes: adb sync [ <directory> ]
  <localdir> can be interpreted in several ways:

  - If <directory> is not specified, /system, /vendor (if present), and /data partitions will be updated.

  - If it is "system", "vendor" or "data", only the corresponding partition
    is updated.

environmental variables:
  ADB_TRACE                    - Print debug information. A comma separated list of the following values
                                 1 or all, adb, sockets, packets, rwx, usb, sync, sysdeps, transport, jdwp
  ANDROID_SERIAL               - The serial number to connect to. -s takes priority over this if given.
  ANDROID_LOG_TAGS             - When used with the logcat option, only these debug tags are printed.