Search This Blog

Tuesday, December 23, 2014

Add JavaScript/CSS syntax highlighting in Android Studio

  • From Android Studio Menu, go to File -> Import Settings...
  • Locate the settings.jar file from this repository
  • From "Select Components to Import" make sure you have "File types" checked, then press OK

Download this file:
https://github.com/manifestinteractive/android-studio-filetypes/blob/master/settings.jar



Friday, December 12, 2014

Android: get sha from *.apk file; validate *.apk content; check apk integrity

The apk file might get destroyed when it's transferred through a network. If the file is signed with a certificate (most Android applications are signed by the publisher) you can check the file integrity from the command line before installing the application. The following methods check the certificate validity as well as validate apk file contents.



keytool -list -printcert -jarfile app-sa.apk

(java/jre/bin/keytool)


 Signer #1:  
   
 Signature:  
   
 Owner: CN=Somevalue, OU=Developers, O=Somevalue. Somevalue, L=Somevalue, ST=Somevalue, C=PL  
 Issuer: CN=Somevaluei, OU=Developers, O=Somevalue Somevalue, L=Somevalue, ST=Somevalue, C=PL  
 Serial number: Somevalue  
 Valid from: Thu Jul 17 11:25:00 CEST 2014 until: Mon Jul 11 11:25:00 CEST 2039  
 Certificate fingerprints:  
       MD5: 11:11:11:11:11:11:11:11:11:11:A3:D8:B5:11:11:11  
       SHA1: 11:11:11:11:11:11:11:11:11:0D:42:BC:2D:01:11:11:11:11:11:11  
       SHA256: 11:11:11:11:11:11:11:11:11:11:11:11:D4:7C:B7:1C:C8:14:8E:43:11:11:11:11:11:11:11:11:3E:11:11:11  
       Signature algorithm name: SHA256withRSA  
       Version: 3  
   
 Extensions:   
   
 #1: ObjectId: 2.5.29.14 Criticality=false  
 SubjectKeyIdentifier [  
 KeyIdentifier [  
 0000: 11 11 11 11 11 11 11 11  11 11 11 11 11 11 36 F3 ..]....%.B....6.  
 0010: 11 11 11 11                    ....  
 ]  
 ]  
   



jarsigner -verbose -verify -certs app-sa.apk

(java/jre/bin/jarsigner)


 sm    162096 Thu Dec 11 16:39:46 CET 2014 resources.arsc

      X.509, CN=Somevalue, OU=Developers, O=Somevalue Somevalue, L=Somevalue, ST=Somevalue, C=PL
      [certificate is valid from 7/17/14 11:25 AM to 7/11/39 11:25 AM]
      [CertPath not validated: Path does not chain with any of the trust anchors]

sm    4416396 Thu Dec 11 16:40:46 CET 2014 classes.dex

      X.509, CN=Somevalue, OU=Developers, O=Somevalue Somevalue, L=Somevalue, ST=Somevalue, C=PL
      [certificate is valid from 7/17/14 11:25 AM to 7/11/39 11:25 AM]
      [CertPath not validated: Path does not chain with any of the trust anchors]

sm       621 Thu Dec 11 16:40:48 CET 2014 androidannotations-api.properties

      X.509, CN=Somevalue, OU=Developers, O=Somevalue Somevalue, L=Somevalue, ST=Somevalue, C=PL
      [certificate is valid from 7/17/14 11:25 AM to 7/11/39 11:25 AM]
      [CertPath not validated: Path does not chain with any of the trust anchors]

s      32963 Thu Dec 11 16:40:50 CET 2014 META-INF/MANIFEST.MF

      X.509, CN=Somevalue, OU=Developers, O=Somevalue Somevalue, L=Somevalue, ST=Somevalue, C=PL
      [certificate is valid from 7/17/14 11:25 AM to 7/11/39 11:25 AM]
      [CertPath not validated: Path does not chain with any of the trust anchors]

       32984 Thu Dec 11 16:40:50 CET 2014 META-INF/CERT.SF
        1495 Thu Dec 11 16:40:50 CET 2014 META-INF/CERT.RSA

  s = signature was verified 
  m = entry is listed in manifest
  k = at least one certificate was found in keystore
  i = at least one certificate was found in identity scope

jar verified.
The latter of the methods verifies apk content as well. 



Monday, December 8, 2014

Android Studio - new Android 5.0 Lollipop emulators; Intel hardware-assisted virtualization; Android Studio Android 5.0 emulator landscape mode


Google has released the new Android Studio 1.0 RC 4. It consists new Android emulators (in the SDK of course) which take full advantage of Intel hardware-assisted virtualization and can use the host GPU.

Here is how to enable these on your Intel machine.


Android Emulator Shortcuts

Ctrl+F11 Switch layout orientation portrait/landscape backwards

Ctrl+F12 Switch layout orientation portrait/landscape forwards

Main Device Keys
Home Home Button

F2 Left Softkey / Menu / Settings button (or Page up)

Shift+f2 Right Softkey / Star button (or Page down)

Esc Back Button

F3 Call/ dial Button

F4 Hang up / end call button

F5 Search Button

Other Device Keys
Ctrl+F5 Volume up (or + on numeric keyboard with Num Lock off) Ctrl+F6 Volume down (or + on numeric keyboard with Num Lock off) F7 Power Button Ctrl+F3 Camera Button

Ctrl+F11 Switch layout orientation portrait/landscape backwards

Ctrl+F12 Switch layout orientation portrait/landscape forwards

F8 Toggle cell network

F9 Toggle code profiling

Alt+Enter Toggle fullscreen mode

F6 Toggle trackball mode



Sunday, December 7, 2014

Ubuntu mount nfs share

Ubuntu does not come with nfs server so we need to install it:

$ sudo apt-get install nfs-kernel-server

Then we can mount nfs shares like this:

$ sudo mount 1.2.3.4:/home /home/user/nfs/home


to check whether the share mounted successfully:

mount -t nfs


more info