14.01.2013 Views

Android™ Application Development - Bahar Ali Khan

Android™ Application Development - Bahar Ali Khan

Android™ Application Development - Bahar Ali Khan

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 11: Advanced Android <strong>Development</strong><br />

Paranoid Android<br />

354<br />

Much of Android’s security is native to the underlying Linux kernel. Resources are sandboxed to their<br />

owner applications, making them inaccessible from other applications. Android provides broadcast<br />

Intents, Services, and Content Providers to let you relax these strict process boundaries, using the permission<br />

mechanism to maintain application-level security.<br />

You’ve already used the permission system to request access to native system services — notably the<br />

location-based services and contacts Content Provider — for your applications.<br />

The following sections provide a more detailed look at the security available. For a comprehensive view,<br />

the Android documentation provides an excellent resource that describes the security features in depth<br />

at code.google.com/android/devel/security.html.<br />

Linux Kernel Security<br />

Each Android package has a unique Linux userID assigned to it during installation. This has the effect<br />

of sandboxing the process and the resources it creates, so that it can’t affect (or be affected by) other<br />

applications.<br />

Because of this kernel-level security, you need to take additional steps to communicate between applications.<br />

Enter Content Providers, broadcast Intents, and AIDL interfaces. Each of these mechanisms<br />

opens a tunnel for information to fl ow between applications. Android permissions act as border<br />

guards at either end to control the traffi c allowed through these tunnels.<br />

Introducing Permissions<br />

Permissions are an application-level security mechanism that lets you restrict access to application components.<br />

Permissions are used to prevent malicious applications from corrupting data, gaining access<br />

to sensitive information, or making excessive (or unauthorized) use of hardware resources or external<br />

communication channels.<br />

As you’ve learned in earlier chapters, many of Android’s native components have permission requirements.<br />

The native permission strings used by native Android Activities and Services can be found as<br />

static constants in the android.Manifest.permission class.<br />

To use permission-protected components, you need to add uses-permission tags to application manifests,<br />

specifying the permission string that each application requires.<br />

When an application package is installed, the permissions requested in its manifest are analyzed and<br />

granted (or denied) by checks with trusted authorities and user feedback.<br />

Unlike many existing mobile platforms, all Android permission checks are done at installation. Once<br />

an application is installed, the user will not be prompted to reevaluate those permissions.<br />

There’s no guarantee that your application will be granted the permissions it requests, so it’s good practice<br />

to write defensive code that ensures it fails gracefully in these circumstances.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!