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

(cherry picked from commit 8e1ff8262e6b88e918d417189c088a23a78cf2f8)
Change check for syncActive

In Manage Account settings if account is in syncing state
option provided to user is "sync now" which should be
"Cancel sync".

syncActive is set to true if getCurrentSyncsAsUser() returns
an empty list which means there are no active syncs.

syncActive should be set to false if getCurrentSyncsAsUser()
returns an empty list.

Change-Id: If78247a90bbca3e1a12553b6facb1315321f52cf

(cherry picked from commit e2172ea8e12ce92adf84f04989d17783adf0dd4c)