Store Layer ownerUid based on metadata or callingUid.

In most cases we want the Layer ownerUid to be the same as the
callingUid since the caller requesting to create the layer should be the
owner. However, in cases when the requst to create the layer comes from
a system process, we should attempt to use the UID passed into the
metadata. This is because the system process could request to create a
layer on behalf of another process.

Test: adb shell dumpsys SurfaceFlinger shows correct uid
Bug: 155825630
Change-Id: I633f293e087cdf413f7cb5e296bd923d83da841c
diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h
index 99b1bb1..5fbdc34 100644
--- a/services/surfaceflinger/Layer.h
+++ b/services/surfaceflinger/Layer.h
@@ -967,6 +967,8 @@
      */
     virtual bool needsInputInfo() const { return hasInputInfo(); }
 
+    uid_t getOwnerUid() { return mOwnerUid; }
+
 protected:
     compositionengine::OutputLayer* findOutputLayerForDisplay(const DisplayDevice*) const;
 
@@ -1089,6 +1091,10 @@
     pid_t mCallingPid;
     uid_t mCallingUid;
 
+    // The owner of the layer. If created from a non system process, it will be the calling uid.
+    // If created from a system process, the value can be passed in.
+    uid_t mOwnerUid;
+
     // The current layer is a clone of mClonedFrom. This means that this layer will update it's
     // properties based on mClonedFrom. When mClonedFrom latches a new buffer for BufferLayers,
     // this layer will update it's buffer. When mClonedFrom updates it's drawing state, children,