Showing posts with label Mobile Device Management. Show all posts
Showing posts with label Mobile Device Management. Show all posts

Sunday, July 15, 2012

Force android check for update OTA?


Your android phone is programmed to check for update every X hours, but you can force this check by doing this:

1 open your phone dialer
2 insert this number *#*#2432546#*#* this mean *#*#checkin#*#*
3 If every thing went ok, you will see an exclamation icon in your notification bar, and if you have an update pending you should be notified.

Tuesday, July 10, 2012

Android – Task Manager Primitive Prototype





Setup The Android Manifest With The “Android.Permission.GET_TASKS” Permission

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="org.apache.hello">
    <uses-permission id="android.permission.GET_TASKS"/>
    <application>
        <activity class=".HelloApp" android:label="HelloApp">
            <intent-filter>
                <action android:value="android.intent.action.MAIN" />
                <category android:value="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest> 

Code A Simple ListActivity

package org.apache.hello;


import android.app.ActivityManagerNative;
import android.app.IActivityManager;
import android.app.ListActivity;
import android.os.Bundle;
import android.os.DeadObjectException;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;


import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;


public class HelloApp extends ListActivity {


    final IActivityManager manager = ActivityManagerNative.getDefault();


    /**
     * Called with the activity is first created.
     */
    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);


        updateTaskList();


        this.getListView().setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            public void onItemSelected(AdapterView adapterview, View view, int i, long l) {
                try {
                    manager.moveTaskToFront(i);
                } catch (DeadObjectException e) {
                    Log.e("HelloApp", e.getMessage(), e);
                }
            }


            public void onNothingSelected(AdapterView adapterview) {
            }
        });
    }


    public void onWindowFocusChanged(boolean flag) {
        updateTaskList();
    }


    private void updateTaskList() {
        ArrayList items = new ArrayList();
        try {
            List tasks = manager.getTasks(10, 0, null);
            int i = 1;
            for (Iterator iterator = tasks.iterator(); iterator.hasNext();) {
                IActivityManager.TaskInfo item = (IActivityManager.TaskInfo) iterator.next();
                items.add(new String((i++) + " : " + item.baseActivity.getPackageName()));
            }
        } catch (DeadObjectException e) {
            Log.e("HelloApp", e.getMessage(), e);
        }
        setListAdapter(new ArrayAdapter(this,
                android.R.layout.simple_list_item_1, items));
    }
}

Get active Application name in Android ?


ActivityManager am = (ActivityManager)this.getSystemService(ACTIVITY_SERVICE);
List l = am.getRunningAppProcesses();
Iterator i = l.iterator();
PackageManager pm = this.getPackageManager();
while(i.hasNext()) {
  ActivityManager.RunningAppProcessInfo info = (ActivityManager.RunningAppProcessInfo)(i.next());
  try {
    CharSequence c = pm.getApplicationLabel(pm.getApplicationInfo(info.processName, PackageManager.GET_META_DATA));
    Log.w("LABEL", c.toString());
  }catch(Exception e) {
    //Name Not FOund Exception
  }
}

Tuesday, June 19, 2012

Troubleshooting Android’s ‘adb devices’?


I’ve been playing around a bit with Android development lately, and — for the second time — spent a while trying to work out whyadb deviceswasn’t showing me anything:
$ adb devices
List of devices attached

$
Thanks, adb. I’m pretty sure I’ve got a Dream plugged in there, you know. I did get it working in the end, so I thought I’d write up some of the troubleshooting steps so that I’ll have something to refer to the next time I run into this problem.
First off, it’s worth mentioned that if you’re on Windows, you apparently need to install some USB drivers first (and it appears that the 32-bit and 64-bit versions aren’t compatible, so you need to pick the right version too). I’m not using Windows, though, so I don’t know a whole lot about this step.
However, life’s not all rosy on Linux: the adbcommand scans /dev/bus/usb/ rather than /proc/bus/usb/ (as provided by usbdevfs) or /sys/bus/usb/ (ditto, sysfs). This is absolutely the right thing to do (lsusb works the same way), but it means that there’s another step (udev) between the device detection and being able to use the device.
Evidently some of the default udev rules (possibly only on some distributions; in particular, on Ubuntu) create device nodes that aren’t world-readable, meaning that the device node is created, but adb can’t read it. The easiest way to tell whether you’re having this problem is to kill the adb daemon and restart it as root:
$ adb kill-server
$ sudo adb start-server
* daemon not running. starting it now *
* daemon started successfully *
$ adb devices
(The adb daemon appears in ps as  “adb fork-server server, by the way.) I’ve also seen suggestions that you should be able to runsudo adb devices to start the server as root, but when I tried that I ended up with a daemon running as myself again.
If this is your problem, the fix is mentioned on the setup page.I mentioned previously: you create a file called something like/etc/udev/rules.d/51-android.rules that contains rules telling udev to make the device node world-writable when a matching device is found.
The example rule provided in the Developer Guide matches any HTC devices, which might be a bit wide-ranging: you could presumably restrict the match to just the device’s id. (The HTC Dream and Magic share the same device id, 0bb4:0c02, or, strangely,0bb4:0c01when booting into HBOOT/fastboot mode.)
Finally, there’s one very important thing that I’d completely forgotten about: if the devices appears in lsusb output but adb devices still shows nothing,check that the phone is set up to allow debugging via USB(Settings⇒Applications⇒Development⇒USB debugging). If this is off, you’ll see nothing… and that was the step I’d forgotten about.
Things went much better after that: I think I might have had to restart the phone once when it was being insistent that there wasn’t a USB connection, but other than that, it’s all happy:
$ adb devices
List of devices attached
HT851N003417  device

$
One more thing: while looking around, I found  an issue reported against the Android project that states that adb is broken against Linux kernel versions 2.6.27 and later, with identical symptoms. I’m currently using 2.6.24, so I can’t test it, but it’s worth being aware of.

Saturday, June 16, 2012

How to change the android rules in ubuntu through terminal in ubuntu?


The first thing to do is download android sdk from http://developer.android.com/sdk/index.html and extract it to wherever you want then log in as root and create a new plain text document in

/etc/udev/rules.d

and name it

51-android.rules

In the text document type:

SUBSYSTEM=="usb",SYSFS{idVendor}=="22b8",MODE="0666"

and save it to that directory.Then open Terminal and execute

chmod a+r /etc/udev/rules.d/51-android.rules

Restart the computer and go to the adb directory and execute

./adb devices

If the device ID shows instead of the question marks you should be ready to execute any adb commands.ENJOY!
(Dont forget to enable USB debugging on you're phone!)

I followed following step so that i can get writing permission in rules file,so first step login through root....


shailesh@shailesh-desktop:~$ sudo -i
root@shailesh-desktop:~# cd /
root@shailesh-desktop:/# cd etc/
root@shailesh-desktop:/etc# cd udev/
root@shailesh-desktop:/etc/udev# 
root@shailesh-desktop:/etc/udev# cd rules.d/
root@shailesh-desktop:/etc/udev/rules.d# chmod 777 51-android.rules

//No we can write and save after saving type the below command....

root@shailesh-desktop:/etc/udev/rules.d# chmod a+r 51-android.rules

Monday, February 20, 2012

How to Create Android Update Zip Package?


There are several ways to install applications or  library files to an Android Phone. You can use Marketapplication to find and install or adb command line tool to install or push the files to Android file system. These are all easy to implement for  single  file but if you have several applications or library files to install at once, it might be better to use update zip file. The update zip file is Android advanced system to install applications or lib files to Android file system using recovery tool. This method is commonly used by rom or theme developers to distribute their package.
Creating an update zip file is quite easy, all you have to do is put the files in corresponding directory in Android file system and an update-script file to copy the files. For example, to install Calculator.apkinto system/app and copy libsec-ril.so file into system/lib :
  • Create an empty folder (eg. C:\myupdate)
  • Create C:\myupdate\system\app folder for Calculator.apk and  C:\myupdate\system\lib folder for libsec-ril.so
  • Create C:\myupdate\META-INF\com\google\android folder for update-script file.
  • Create the update-script file with the following syntax:
      show_progress 0.1 0

      copy_dir PACKAGE:system SYSTEM:

      show_progress 0.1 10
    Line 1&5 : show progress bar Line 3: copy system folder from update package to Android’s /system
    Note: you should add one extra  line at the end of the file (Line 6)
  • Compress the entire contents of C:\myupdate folder to zip (not the myupdate folder itself)
  • Sign the myupdate.zip file
  • java -jar signapk.jar certificate.pem key.pk8 myupdate.zip update.zip
    Note: you can find tutorial on how to sign the update.zip file here
  • Copy the update.zip file to sdcard and apply it from recovery console
update-script syntax reference (definitions from recovery.c android source code):
  • copy_dir
  • Syntax: copy_dir <src-dir> <dst-dir> [<timestamp>] Copy the contents of <src-dir> to  <dst-dir>. The original contents of <dst-dir> are preserved unless something in <src-dir> overwrote them. Ex: copy_dir PACKAGE:system SYSTEM:
  • format
  • Syntax: format <root> Format a partiti0n Ex: format SYSTEM:, will format entire /system . Note: formatting erases data irreversibly.
  • delete
  • Syntax: delete <file1> [... <fileN>] Delete  file. EX: delete SYSTEM:app/Calculator.apk, will delete Calculator.apk from system/app directory.
  • delete_recursive
  • Syntax: delete_recursive <file-or-dir1> [... <file-or-dirN>] Delete a file or directory with all of it’s contents recursively Ex: delete_recursive DATA:dalvik-cache, will delete /data/dalvik-cache directory with all of it’s contents
  • run_program
  • Syntax: run_program <program-file> [<args> ...] Run an external program included in the update package. Ex: run_program PACKAGE:install_busybox.sh, will run install_busybox.sh script (shell command) included in the update package.
  • set_perm
  • Syntax: set_perm <uid> <gid> <mode> <path> [... <pathN>] Set ownership and permission of single file or entire directory trees, like ‘chmod’, ‘chown’, and ‘chgrp’ all in one Ex: set_perm 0 2000 0550 SYSTEM:etc/init.goldfish.sh
  • set_perm_recursive
  • Syntax: set_perm_recursive <uid> <gid> <dir-mode> <file-moe> <path> [... <pathN>] Set ownership and permission of a directory with all of it’s contents recursively
    Ex: set_perm_recursive 0 0 0755 0644 SYSTEM:app
  • show_progress
  • Syntax: show_progress <fraction> <duration> Use of the on-screen progress meter for the next operation, automatically advancing the meter over <duration> seconds (or more rapidly if the actual rate of progress can be determined). Ex: show_progress 0.1 0
  • symlink
  • Syntax: symlink <link-target> <link-path>
    Create a symlink (like ‘ln-s’). The <link-path> is in root:path format, but <link-target> is for the target filesystem (and may be relative)
Definition of roots and partitions (from root.c android source code)
ROOT:
(Linux block device) /mountpoint/ fs, size
Description.
  BOOT:     (/dev/mtdblock[?]) / (RAM)  Raw
    Kernel, ramdisk and  boot config.
  DATA:     (/dev/mtdblock5)   /data/   yaffs2, 91904kb
    User, system config,  app config, and apps (without  a2sd)
  CACHE:    (/dev/mtdblock4)   /cache/  yaffs2, 30720kb
    OTA cache,  Recovery/update config and temp
  MISC:     (/dev/mtdblock[?]) N/A     Raw
    [TODO: Get info on MISC:]
  PACKAGE:  (Relative to package file) N/A
    Pseudo-filesystem for update  package.
  RECOVERY: (/dev/mtdblock[?]) / (RAM) Raw,     [?]kb
    The recovery  and update environment's kernel and ramdisk.
    Similar to BOOT:.
  SDCARD:   (/dev/mmcblk0(p1)) /sdcard/ fat32,  32MB-32GB
    The microSD card. Update zip is usually here.
  SYSTEM:   (/dev/mtdblock3)   /system/ yaffs2, 92160kb
    The OS partition,    static and read-only.
  TMP:                         /tmp/    in RAM
    Standard Linux temporary directory.
    Cleared on poweroff/reboot.

Wednesday, February 8, 2012

Difference between SMTP, POP3 and IMAP ?



Definition

SMTP or Simple Mail Transfer Protocol is used in the delivery of email from an email client to an email server. It is also used to deliver email from one server to another. The technology uses port 25. POP3 or Post Office Protocol is an email client that allows users to download email from email servers. A relatively simple protocol, POP3 has a relatively small feature set, and it doesn't really offer very much aside from download. POP3 works on the assumption that users download all the email from the server, before deleting them and disconnecting. POP3 uses port 110. IMAP or Internet Message Access Protocol is quite similar to POP3, in that it is also used to download email from a server. Aside from this function however, IMAP also allows users to keep their email on the server after accessing them. Because the protocol leaves the email on the server, IMAP has a lot more requirements with regard to disk space and CPU resources. IMAP uses port 143.

Advantages And Disadvantages 

The main drawback to SMTP is that it can be used only to send email and not to receive them. In addition, the use of SMTP is dependent on the system's network and/or ISP settings. The main advantage of POP3 on the other hand, is that the email can be stored on the server even after downloading it. This allows users to read their email at their own pace, even after cutting off Internet connection. The main drawback is that you may inadvertently delete spam email and even viruses in the process. The main advantage of IMAP is speed, since it requires only a relatively small amount of data to be passed.  Email messages will only be downloaded upon a specific request from the user. Other advantages include the ability to create email folders and/or mailboxes on the server itself, and user ability to delete messages.

In Use

SMTP is typically used by the Mail Transfer Agent or MTA for the delivery of email to the recipient's mail server. As mentioned previously, SMTP can only be used for sending emails. POP3 offers users a simple system for accessing mailboxes and downloading email messages. With POP3, the user has the option to download email from the server while retaining copies for later retrieval. IMAP requires the transfer of only a small amount of data, which means that it will work well even slow connections. In addition, IMAP offers a host of user access services as well.



  • Post Office Protocol 3 (POP3) servers hold incoming e‑mail messages until you check your e‑mail, at which point they're transferred to your computer. POP3 is the most common account type for personal e‑mail. Messages are typically deleted from the server when you check your e‑mail.
  • Internet Message Access Protocol (IMAP) servers let you work with e‑mail messages without downloading them to your computer first. You can preview, delete, and organize messages directly on the e‑mail server, and copies are stored on the server until you choose to delete them. IMAP is commonly used for business e‑mail accounts.
  • Simple Mail Transfer Protocol (SMTP) servers handle the sending of your e‑mail messages to the Internet. The SMTP server handles outgoing e‑mail, and is used in conjunction with a POP3 or IMAP incoming e‑mail server.

Summary

SMTP
  • Used in delivering email from one server to another
  • Cannot be used for receiving emails
POP3
  • Allows users to store email on the server even after downloading them
  • Is pretty basic compared to the other protocols
IMAP
  • Requires only small amount of data to be transferred 
  • Will work even with slow Internet connections