Fix descriptor leak after accepting connections

After accepting a connection on a listening socket and
storing the resulting FileDescriptor into a newly created
LocalSocketImpl, the new impl's "descriptor was created
locally and should be closed normally" flag should be set.

(cherrypicked from 3e7305c6bf6062b5cb1e2ddcec6c6d30b4a8bc0d)

Bug: 11805817
Change-Id: I0a1a7c62ec3fbcf647a44a22110ddc778d14e5f4
Validate objects are from the correct context.

Change-Id: I7d87b0e253b8d2e36d1aed790cfe3a7dd23e158f
Harden NsdManager against null-dereference crashes

Due to race conditions or programming errors, the NsdManager
can attempt to process an asynchronous status message (and issue
a callback to the listener) after the listener has already been
removed from the NsdManager state.  This causes dereferencing of
null objects, and a crash.

Split out the three async-queue message cases:  these are ones
in which message.arg2 does not hold an NsdManager array index
and the code should not interpret this field as if it were.

Add an explicit check for "null listener" (the array index in the
message has already been released), log a warning, and exit early.

Safeguard accesses to the "NSD service type" string from a (possibly
null) NsdServiceInfo object... return a constant "?" string rather
than crashing.

Bug: 9016259

Change-Id: I40aabdfc65d86fdd0eaac7a1e7e56e6ff69796cf
Avoid duplication of AppWindowToken in created Task

When WindowManagerService creates a new Task, it passes atoken to the
Task constructor. In this case atoken is added to mAppTokens list by
the Task constructor and then it is added manually again by calling
newTask.mAppTokens.add(atoken). As a result, the same atoken is present
in mAppTokens list twice.

When another window token is added to the list, it may be placed in
beetwen duplicated tokens and corresponding window will be hidden from
the screen by corresponding duplicated windows.
From user perspective it means that some windows will not be displayed
on the screen.

The issue is fixed by avoid adding atoken to mAppTokens list manually
when it was added already in Task constructor.

Change-Id: I10628e68186160fffdde07beb7d84ab3cecb7051
Fix null check for BaseObj.equals.

Change-Id: I4f060697db175cbf0b5617c1220db853bbe53f1f
Restore some fling parameters

one of the bugs I'm flailing on that are nagging at me is related to skippiness when flinging at high velocity

it's either related to constants in ViewConfiguration or(/and) animation stuff that could be handled more efficiently

MAXIMUM_FLING_VELOCITY:
stock     8000
ours was 15000

px = dp * (dpi / 160)
gsf = 430 dpi
15000 dp/s * (430 / 160) = 40312.5 px/s
on a 1080x1920 device, that's 21 screen-heights per second fling
I don't think we need to worry about flings being initiated with a 21 screen-height/second
so, returning MAXIMUM_FLING_VELOCITY to 8000 (stock val)

SCROLL_FRICTION:
stock    0.011
ours was 0.015
DADDY LIKES A SMOOTH RIDE, but this seems like it could lead to scroll inertia eventually
outrunning the scrolling cache. To prevent that, let's try the stock value.

Change-Id: I098399cf6f32661020d947eb27742bfda69161dd
systemui: turn off debugging

should be all of it

-VanirAOSP

Change-Id: Ia279a1be6968f67a4ad448cf51743f4c455af88a
Signed-off-by: scott <scott@ubuntu.com>

Conflicts:
	packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
notification/settingspanel: stop getting a gesture recorder

We're currently getting gesture information on fling even
if the log ouput for DEBUG_GESTURES is turned off so.. lets stop.

-Vanir

Change-Id: I70810fb2fb9e4b134492ffdd1ac844fe65f7fb75
wifistatetracker: silence more logging

Change-Id: I3d8e7cf0ed028b1213149d89088a2021c838e433
SearchPanelView: disable gesture debugging

Change-Id: I7ce5e2420fa7a1a3f9533ea2e04cd94e13939724
Signed-off-by: scott <scott@ubuntu.com>

Conflicts:
	packages/SystemUI/src/com/android/systemui/AOKPSearchPanelView.java
Remove java.io.tmpdir assignment in AndroidRuntime.

This value is overridden by the framework anyway
(see ActivityThread.handleBindApplication). Besides,
it doesn't seem like a great idea to let tools clutter
/sdcard/ with temp files.

Change-Id: I26c710cbea7397f89e6103e54a73044a87da95b1
Fixed a possible infinite loop in JsonReader#skipValue()

Bug: https://code.google.com/p/android/issues/detail?id=65846

Change-Id: Idaa0e75fc5612550c4b9ccb9afa5535ea5b189df
Structure device not freed in error case

In case of an error in the call usb_device_get_fd()
the memory created by usb_open_device() is never
freed.

Added a call to usb_device_close in case of error to
release the allocated memory.

Change-Id: Iaa83674f000242d80604dd30c782236f7afd90c2