NsdService does not clean up after exiting clients

When a client of the NsdService exits, NsdService should
clean up the requests it has sent to the mDNS daemon:
cancel any pending resource-discovery and resource-resolution
queries, and remove any services registered by this client.

If this isn't done, several bad things happen. The daemon will
continue to run unnecessarily, will report service discoveries
that can't be forwarded on to the client, and will continue to
advertise service ports for an application which is no longer
running until the device is rebooted (mDNS pollution).

Bug: 9801184
Change-Id: I0aa7311480322aefcff16f902fbbf34f50985d38
Signed-off-by: houst0nn <houstonn@gmail.com>
Don't allow MemoryFiles of negative length.

Prevents us from converting a (signed) jint into an
(unsigned) size_t and having horrible things happen.

Change-Id: I0f04e2eb9852ae7fc49b435fd0974f56e86751a4
Signed-off-by: houst0nn <houstonn@gmail.com>
Avoid SystemUI crash due to NPE

BaseStatusBar.createNotificationViews() returns null
when it reports handleNotificationError(), leading to
a forced crash of the misbehaving app. However, it
should not add a null object of Notification.Entry
since it will also crash SystemUI (crashing at compare).

Change-Id: I86678c8024e931420b0fbab1f36b330e7e75d581
Signed-off-by: houst0nn <houstonn@gmail.com>
Quicksettings: Correct alignment.

* Fix issues cumulated during quick settings rework, restore android behaviour for margins and ditch empty views (that were applied only to basic constructed tiles).
* Wrap battery views into a separate parent layout so we align only that one that contains both.
* Clean circle battery sizes calculations and ditch inside padding for external margin (derp).
* Increase dual switch area a bit, since is an overlaied view is fine does not affects margins.

Before:
* https://drive.google.com/file/d/0B2UbDLX5_0AjWkFmcEtKN3hJcHM/edit?usp=sharing
* https://drive.google.com/file/d/0B2UbDLX5_0Ajb1F3MWw4UjVpYzg/edit?usp=sharing

After:
* https://drive.google.com/file/d/0B2UbDLX5_0AjY3ZvUm54S1ZURGc/edit?usp=sharing
* https://drive.google.com/file/d/0B2UbDLX5_0AjUXJrMlpTSlpVLTQ/edit?usp=sharing

Signed-off-by: Carlo Savignano <stevewatersy@gmail.com>