Wednesday, February 9, 2011

Installing Packages in Linux

Here's one of my oldest articles. I'm glad I found a few of them. This one was written on 12th Jan'05, when I was pursuing my engg degree.
:-)

Linux Mandrake – Installation Guide

Here's one of my oldest articles. I'm glad I found a few of them. This one was written on 12th Dec'04, when I was pursuing my engg degree.
:-)

Monday, January 31, 2011

GMail and associated networks hacked all over the world

The world is watching and Google and its associated networks are being hacked in bulk all over the world. GMail, Orkut, GMail authenticated social networks, i.e. Facebook etc.
Google has proved to be the worst in providing security to the end-users compromising the precious user-data at the hands of a few miscreants.
Google developers are helpless as they face attack in a bulk. They have no idea about whats happening around.

It hires brightest minds just to pay. Now, when it comes to show the hi-quality work, its designed system seemed so fragile!! Now, more and more people are moving to other e-mail providers.

People speak, ""Anything but GMail!!"

I'd love to go for an e-mail provider thats paid and gives me security so that even if my account is hacked, I can activate it by calling the customer care and get all my deleted data back.

Majid

Thursday, January 20, 2011

Android ANR Debug tools


From API level 9, Android provides a tool, i.e.StrictMode class to look for UI blocking issues commonly known to dev as ANR(Application Not Responding). It happens when the main EDT(Event Dispatch Thread) doesn't return in the specified time. For BroadcastReceiver, its 10 secs, 5 secs for touch events etc. Android works on Single Thread mechanism for interrupt handling and paint routines.
 
Using the Strict mode class, you can specify the types of blocking issues, you want to catch, i.e. disk I/O, network, logs etc.
 
I'm surprised even accessing the shared preferences on a UI thread is treated as a violation. The reason presented by Android is that the Shared Preferences is actually a xml file saved onto the disk. So, accessing it in the main thread is also a violation. I wonder if if there's a workaround on this. Nobody wants another thread to deal with SharedPrefs.
 
Otherwise, a good tool(in fact, a class) to use. Only can be tested on 2.3 platform onwards. So, its time to make good use of the emulator.
 
if (DEVELOPER_MODE) {
         StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
                 .detectDiskReads()
                 .detectDiskWrites()
                 .detectNetwork()   // or .detectAll() for all detectable problems
                 .penaltyLog()
                 .build());
         StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
                 .detectLeakedSqlLiteObjects()
                 .penaltyLog()
                 .penaltyDeath()
                 .build());
     }
 
 
For more info, have a look at,
 
 
 

Software Versioning - The Magic Numbers


Its always benefecial to have the version number of a project clearly defining its current, past and future state. Some of the techniques are discussed below.
 
X.Y.Z. versioning
The common versioning sceme is X.Y.Z.
Z -> pure bug fix releases (can only change function implementation)
Y -> can introduce new functions, new symbolic and enumerated constants, and deprecate existing functions
X  -> Any kind of change can be made during a major version release (New features etc.)
 
The main difference between these three version numbers are Forward and Backward compatibility.
 
For more info, please have a look at the Apache page,
or
 
 
Alpha-numeric versioning
Another approach is using an alpha-numeric string, i.e.
1.0b1, 1.0b2 (with some fixes), 1.0rc1 (stable enough)
 
1. Pre-alpha - prior to testing (different milestones)
2. Alpha - first phase to begin software testing (usually ends with a feature freeze)
3. Beta - feature complete, for usability testing. often useful for demonstrations and previews within an organisation and to prospective customers (preview, prototype, technical preview (TP), or early access)
4. Open and closed Beta - closed beta versions are released to a select group of individuals for a user test, while open betas are to a larger community group, sometimes to anybody interested
5. Release candidate - code complete when the development team agrees that no entirely new source code will be added to this release
6. Release - RTM - Release to manufacturing or Release to marketing - delivered or provided to the customer
                 - GA - General Availability - commercialization activities completed. software has been made available to the general market either via the web or physical media
 
 
 
Android versioning
On Android, we've 2 options for versioning, one for public release, the other for internal debug releases, called,
versionCode, i.e."2" and versionName, i.e."0.0.0.25" respectively.
 
The company should follow the standard that suits its needs.

View current DLLs and memory-mapped files


Ever wondered which program has a particular file or directory open? Now you can find out.
 
 
Its a good tool. Try the dll mode.

Android 2.3 SDK(Gingerbread) released


 
Also, SDK for Samsung Galaxy Tab is released. Please update your SDK if required. The most interesting feature added is Enhanced Native support for activity lifecycle(NativeActivity), persistence, graphics and audio.
 
 
The first Android 2.3 phone, Google Samsung Nexus S.
 
 
Quick link for Platform 9 API changes,
 

Meego Conference


Intel and Nokia MeeGo roadshow was organised on 10th Nov'10 at Surya Crowne Plaza. It was informative but not 100% complete. Also, hands-on lab was cancelled at the last moment citing reasons that the laptops were held at the customs. There were presentations on MeeGo platform-intro, MeeGo Installation and use-info(by Prem Rao, Intel), AppUp Market-info(by Preethi Raj, Intel) and WindRiver(by Thilak Kumar, WindRiver).
Here's a summary about MeeGo and some tips to start developing MeeGo Apps.
Introduction
MeeGo is a combination of Intel Moblin and Nokia Maemo projects. Nokia was working on Maemo 6 after porting Maemo 5 on Nokia N900. Intel was disaapointed by the Micorosft support for Intel Atom processor. So, Intel joined hands with Nokia to make a platform which can work on a variety of devices, i.e. Smartphones, Netbook, In-car Infotainment Systems,  MIDs, Tablet PCs etc and perform much better than windows. MeeGo can work on ARM as well as Intel Atom processor.
MeeGo can work on all these devices, but the source needs to be cross-compiled for the platform required, i.e.one MeeGo binary cannot be used for all the paltforms. The default format of the MeeGo application is .rpm.
There was a discussion on the interaction between OEMs, ODMs, ISVs etc.
Development
MeeGo is open source project hosted by The Linux Foundation. MeeGo apps are based on Qt (pronounced as "Cute" by Intel/Nokia people). So, the easiest and best way to start development is download the SDK for Linux install it. The default SDK(approx. 600MB) consists of a Qt Creator(IDE), Maemo Simulator, Debugging tools, Qt Localization tool, Qt UI creator(based on XML) etc. Full dev support on Windows/Mac is yet to come.
Qt is cross-platform and supported on most OS. So, if you first want to brush up/learn C++/Qt without downloading the SDK, its already provided with most of the Linux distribution. Install Ubuntu(v10.0+) and check if Qt 4.0+ libraries and headers are installed. Two prime libraries are-QtGui and QtCore. There are 3 simple steps to compile a Qt project. QMake is a tool which does the Qt related work for you.
(i) Go to the project dir where you've placed your src files.
(ii) $ qmake -project
It'll create a .pro file. You can modify it as per your requirement and put CONFIG += qt if its not already added.
(iii) $ qmake
It'll create the Makefile in the current directory. You can review it.
(iv) $ make
It'll create the binary for you.
Working on Qemu and Xephyr with MeeGo image
Currently netbook and handset images are available. They can be used with Qemu or Xephyr. Xephyr is only supported on Intel Graphics card and uses chroot and works faster than Qemu. Both can be used to simulate a MeeGo OS environment.
Selling the App(Intel AppUp Store)
Intel AppUp store is now supported in India. The developer can register(its free for one year now) and submit the app to the AppStore. The dev can receive upto 70% of the revenue from the app sales. The store currently has Maemo/MeeGo apps for sale/download.
WindRiver
Windriver is a 100% Intel owned subsidiary. It is known for its popular software, i.e. VxWorks. Its into building software for Space crafts, aircrafts, ships etc. Its now also has started work in the Telecom domain. It has modified and enhanced the MeeGo source to have better speed, stability, performance and UI enhancements and thus created and enhanced version of MeeGo which is commercial. So, the OEMs looking for a customized and enhanced MeeGo can contact WindRiver for the solution. It also provides an automated test framework, also a validation tool called FAST. They support FOTA (Firmware Over-The-Air) upgrade.
New features include but not limited to enhanced framework interface, device management software, drivers, UI framework etc.
WindRiver is concentrated on the embedded devices, i.e. Smartphones, In-vehicle Infotainment systems, Tablets.
They work on a CMMi Level 3 certified process. The IP rights is with the OEMs. The latest version is compatible with MeeGo v1.1.
Q&A
I asked a few questions to the presenters and I must say I was not satisfied with the answers. The presenters' knowledge were not upto the mark.
Q.1. What is the memory assigned to a MeeGo Application?
Ans: Presenter->It depends. (not satisfied with the answer)
Q.2. Will MeeGo support a JVM or will it follow Apple's princinple of not allowing a Java App(J2ME MIDlet) to run?
Ans: Presenter->No, we don't have any plans to support Java.
Q.3. What about the Sandbox model in MeeGo? How will the App Manager restrict the App not to hurt the system?
Ans: Presenter-> It'll be as per the Kernel security. (not a complete answer as a device app needs a lot of permissions which is the job of Security Manager)
Q.4. Is AppUp Store the only way to install the App on the MeeGo device? Can we have an offline installation of a MeeGo binary(.rpm)?
Ans: Presenters-> Yes you can install it like a regular .rpm file (not a complete answer as a device package needs a lot of validation before a successful installation which is the job of App Manager. Its not a PC rpm package.)
Q.5. Why was rpm chosen as the default format not .deb as Maemo is based on .deb and Moblin is based on .rpm?
Ans: Presenter-> Most of the code is migrated from Fedora.

Q.6. Is there a GPS emulation support in the emulator?
Ans: Presenter-> Not sure.
The presenter showed us one video with MeeGo Graphics running on a device, and it looked really awesome. The UI page floated like a curtain/wave. The icons and the widgets looked awesome!! It was announced that BMW cars will have MeeGo running on their in-vehicle systems.

Android debug tips(shell)


Here's a set of a few Android debugging tips. I've found them quite helpful.
 
1. You've installed an APK and want to know its package name, i.e. mapping APK to the package name.
    $ adb shell
    # pm list packages -f
 
2. Try to mount rw the data/system partition of a dev phone.
    $ adb remount
3. Sync the device after any pull/push operation.
    $ adb shell sync
 
4. Manually start an activity.
    $ adb shell
    # am -D <intent>
 
5. Manually start an activity with package and activity name.
    $ adb shell
    # am start -a <action> -n <package name>/<activity name>
 
6. Manually send a broadcast.   
    $ adb shell
    # am broadcast <intent> 
 
7. View/Change Kernel params of an android phone.
    $ adb shell
    # getprop
    # setprop <key> <value>
 
8. Search a package on the Android Market,
    market://search?q=pname:<package_name>
 
9. View an APK's content:
    $ aapt l <apk>
 
10. View an APK's Manifest file:
       
    Get Manifest main info.
    $ aapt d badging <APK>

11. dexdump - Dissembling the classes.dex.
    Extract the APK or if its installed find it from here and do adb pull for classes.dex,
    $ adb shell
    # cd /data/dalvik-cache
    # ls
-rw-rw-rw- root root 73852 2007-11-27 05:16 system@app@Contacts.apk@classes.dex
-rw-rw-rw- app_0 app_0 64172 2007-11-27 05:17 system@app@ContactsProvider.apk@classes.dex
 
    $ dexdump classes.dex -d -f -h [-l xml/plain] >> classes.dexdump
Here's an example of xml dexdump.
<class name="MyClass"extends="com.abc.xyz.Parent"abstract="false"static="false"final="false"visibility="public"><constructor name="MyClass"type="com.abc.xyz.MyClass"static="false"final="false"visibility="public"></constructor><method name="invalidateView"return="void"abstract="false"native="false"synchronized="false"static="false"final="false"visibility="public">