Settings App: Fix to resolve NULL pointer exceptions

This fix resolves any NULL pointer exceptions and
Array Index Out of Bounds exceptions seen in
Settings Application code space.

CRs-Fixed: 760115
Change-Id: I8c2b7b8e19d362a5c5789d8693bcd3656c32e38d
Fix memory leak issue in application settings

If opening Main menu->Settings->Apps, and rotating the phone
about 50 times, Settings force closes and out of memory occur.
This is because after ManageApplications onDestroy, references
of ApplicationsState have not been release. So, they will not
be garbage collected. It leads to OOM and force close. To
avoid this we need to release the references of
ApplicationsState when ManageApplications onDestroy.

Also, when exiting ManageApplications or InstalledApps in
Settings there is a memory leak due to not releasing some
objects. This fix releases the Session objects to avoid
memory leak.

Change-Id: Icca7100bded0653a4ec7f2b4bd48a29262432a3b