Merge "Fix privacy tags based on PWG review meeting." into pi-dev
diff --git a/core/java/android/os/Looper.java b/core/java/android/os/Looper.java
index 04cceb8..848c596 100644
--- a/core/java/android/os/Looper.java
+++ b/core/java/android/os/Looper.java
@@ -331,7 +331,6 @@
         final long looperToken = proto.start(fieldId);
         proto.write(LooperProto.THREAD_NAME, mThread.getName());
         proto.write(LooperProto.THREAD_ID, mThread.getId());
-        proto.write(LooperProto.IDENTITY_HASH_CODE, System.identityHashCode(this));
         mQueue.writeToProto(proto, LooperProto.QUEUE);
         proto.end(looperToken);
     }
diff --git a/core/java/android/os/PowerManager.java b/core/java/android/os/PowerManager.java
index 97d415e..66fa629 100644
--- a/core/java/android/os/PowerManager.java
+++ b/core/java/android/os/PowerManager.java
@@ -1643,12 +1643,12 @@
         public void writeToProto(ProtoOutputStream proto, long fieldId) {
             synchronized (mToken) {
                 final long token = proto.start(fieldId);
-                proto.write(PowerManagerProto.WakeLockProto.HEX_STRING,
-                        Integer.toHexString(System.identityHashCode(this)));
-                proto.write(PowerManagerProto.WakeLockProto.HELD, mHeld);
-                proto.write(PowerManagerProto.WakeLockProto.INTERNAL_COUNT, mInternalCount);
+                proto.write(PowerManagerProto.WakeLock.TAG, mTag);
+                proto.write(PowerManagerProto.WakeLock.PACKAGE_NAME, mPackageName);
+                proto.write(PowerManagerProto.WakeLock.HELD, mHeld);
+                proto.write(PowerManagerProto.WakeLock.INTERNAL_COUNT, mInternalCount);
                 if (mWorkSource != null) {
-                    mWorkSource.writeToProto(proto, PowerManagerProto.WakeLockProto.WORK_SOURCE);
+                    mWorkSource.writeToProto(proto, PowerManagerProto.WakeLock.WORK_SOURCE);
                 }
                 proto.end(token);
             }
diff --git a/core/proto/android/content/configuration.proto b/core/proto/android/content/configuration.proto
index 74b47d2..6a174e8 100644
--- a/core/proto/android/content/configuration.proto
+++ b/core/proto/android/content/configuration.proto
@@ -32,7 +32,7 @@
 
   optional float font_scale = 1;
   optional uint32 mcc = 2;
-  optional uint32 mnc = 3;
+  optional uint32 mnc = 3 [ (.android.privacy).dest = DEST_EXPLICIT ];
   repeated LocaleProto locales = 4;
   optional uint32 screen_layout = 5;
   optional uint32 color_mode = 6;
diff --git a/core/proto/android/content/intent.proto b/core/proto/android/content/intent.proto
index 5e0ed11..3b2c4fc 100644
--- a/core/proto/android/content/intent.proto
+++ b/core/proto/android/content/intent.proto
@@ -59,7 +59,7 @@
     optional ComponentNameProto component = 7;
     optional string source_bounds = 8;
     optional string clip_data = 9 [ (.android.privacy).dest = DEST_EXPLICIT ];
-    optional string extras = 10 [ (.android.privacy).dest = DEST_EXPLICIT ];
+    optional string extras = 10 [ (.android.privacy).dest = DEST_LOCAL ];
     optional int32 content_user_hint = 11;
     optional string selector = 12;
 }
diff --git a/core/proto/android/os/looper.proto b/core/proto/android/os/looper.proto
index 435c648..dce65d3 100644
--- a/core/proto/android/os/looper.proto
+++ b/core/proto/android/os/looper.proto
@@ -25,8 +25,8 @@
 message LooperProto {
     option (.android.msg_privacy).dest = DEST_AUTOMATIC;
 
-    optional string thread_name = 1 [ (.android.privacy).dest = DEST_EXPLICIT ];
+    // the thread name, usually set by developers.
+    optional string thread_name = 1;
     optional int64 thread_id = 2;
-    optional int32 identity_hash_code = 3;
-    optional android.os.MessageQueueProto queue = 4;
+    optional android.os.MessageQueueProto queue = 3;
 }
diff --git a/core/proto/android/os/powermanager.proto b/core/proto/android/os/powermanager.proto
index 78a28ed..20b0a74 100644
--- a/core/proto/android/os/powermanager.proto
+++ b/core/proto/android/os/powermanager.proto
@@ -36,13 +36,14 @@
     }
 
     // WakeLock class in android.os.PowerManager, it is the one used by sdk
-    message WakeLockProto {
+    message WakeLock {
         option (.android.msg_privacy).dest = DEST_AUTOMATIC;
 
-        optional string hex_string = 1;
-        optional bool held = 2;
-        optional int32 internal_count = 3;
-        optional WorkSourceProto work_source = 4;
+        optional string tag = 1;
+        optional string package_name = 2;
+        optional bool held = 3;
+        optional int32 internal_count = 4;
+        optional WorkSourceProto work_source = 5;
     }
 }
 
diff --git a/core/proto/android/server/activitymanagerservice.proto b/core/proto/android/server/activitymanagerservice.proto
index 3b9150f..5491ca5 100644
--- a/core/proto/android/server/activitymanagerservice.proto
+++ b/core/proto/android/server/activitymanagerservice.proto
@@ -157,7 +157,7 @@
   optional BroadcastRecordProto current = 5;
   optional bool linked_to_death = 6;
   repeated BroadcastFilterProto filters = 7;
-  optional string hex_hash = 8; // this hash is used to find the object in IntentResolver
+  optional string hex_hash = 8; // used to find this ReceiverList object in IntentResolver
 }
 
 message ProcessRecordProto {
@@ -184,7 +184,7 @@
 
   optional .android.content.IntentFilterProto intent_filter = 1;
   optional string required_permission = 2;
-  optional string hex_hash = 3; // used to find the object in IntentResolver
+  optional string hex_hash = 3; // used to find the BroadcastFilter object in IntentResolver
   optional int32 owning_user_id = 4;
 }
 
@@ -458,13 +458,12 @@
   option (.android.msg_privacy).dest = DEST_AUTOMATIC;
 
   optional string short_name = 1;
-  optional string hex_hash = 2;
-  optional bool is_running = 3; // false if the application service is null
-  optional int32 pid = 4;
-  optional .android.content.IntentProto intent = 5;
-  optional string package_name = 6;
-  optional string process_name = 7;
-  optional string permission = 8;
+  optional bool is_running = 2; // false if the application service is null
+  optional int32 pid = 3;
+  optional .android.content.IntentProto intent = 4;
+  optional string package_name = 5;
+  optional string process_name = 6;
+  optional string permission = 7;
 
   message AppInfo {
     option (.android.msg_privacy).dest = DEST_EXPLICIT;
@@ -473,11 +472,11 @@
     optional string res_dir = 2;
     optional string data_dir = 3;
   }
-  optional AppInfo appinfo = 9;
-  optional ProcessRecordProto app = 10;
-  optional ProcessRecordProto isolated_proc = 11;
-  optional bool whitelist_manager = 12;
-  optional bool delayed = 13;
+  optional AppInfo appinfo = 8;
+  optional ProcessRecordProto app = 9;
+  optional ProcessRecordProto isolated_proc = 10;
+  optional bool whitelist_manager = 11;
+  optional bool delayed = 12;
 
   message Foreground {
     option (.android.msg_privacy).dest = DEST_AUTOMATIC;
@@ -485,13 +484,13 @@
     optional int32 id = 1;
     optional .android.app.NotificationProto notification = 2;
   }
-  optional Foreground foreground = 14;
+  optional Foreground foreground = 13;
 
-  optional .android.util.Duration create_real_time = 15;
-  optional .android.util.Duration starting_bg_timeout = 16;
-  optional .android.util.Duration last_activity_time = 17;
-  optional .android.util.Duration restart_time = 18;
-  optional bool created_from_fg = 19;
+  optional .android.util.Duration create_real_time = 14;
+  optional .android.util.Duration starting_bg_timeout = 15;
+  optional .android.util.Duration last_activity_time = 16;
+  optional .android.util.Duration restart_time = 17;
+  optional bool created_from_fg = 18;
 
   // variables used to track states related to service start
   message Start {
@@ -503,7 +502,7 @@
     optional bool call_start = 4;
     optional int32 last_start_id = 5;
   }
-  optional Start start = 20;
+  optional Start start = 19;
 
   message ExecuteNesting {
     option (.android.msg_privacy).dest = DEST_AUTOMATIC;
@@ -512,9 +511,9 @@
     optional bool execute_fg = 2;
     optional .android.util.Duration executing_start = 3;
   }
-  optional ExecuteNesting execute = 21;
+  optional ExecuteNesting execute = 20;
 
-  optional .android.util.Duration destory_time = 22;
+  optional .android.util.Duration destory_time = 21;
 
   message Crash {
     option (.android.msg_privacy).dest = DEST_AUTOMATIC;
@@ -524,9 +523,9 @@
     optional .android.util.Duration next_restart_time = 3;
     optional int32 crash_count = 4;
   }
-  optional Crash crash = 23;
+  optional Crash crash = 22;
 
-  message StartItemProto {
+  message StartItem {
     option (.android.msg_privacy).dest = DEST_AUTOMATIC;
 
     optional int32 id = 1;
@@ -537,17 +536,20 @@
     optional NeededUriGrantsProto needed_grants = 6;
     optional UriPermissionOwnerProto uri_permissions = 7;
   }
-  repeated StartItemProto delivered_starts = 24;
-  repeated StartItemProto pending_starts = 25;
+  repeated StartItem delivered_starts = 23;
+  repeated StartItem pending_starts = 24;
 
-  repeated IntentBindRecordProto bindings = 26;
-  repeated ConnectionRecordProto connections = 27;
+  repeated IntentBindRecordProto bindings = 25;
+  repeated ConnectionRecordProto connections = 26;
+
+  // Next Tag: 27
 }
 
 message ConnectionRecordProto {
   option (.android.msg_privacy).dest = DEST_AUTOMATIC;
 
-  optional string hex_hash = 1;
+  // used to find same record, e.g. AppBindRecord has the hex_hash
+  optional string hex_hash = 1; // cross reference the object and avoid double logging.
   optional int32 user_id = 2;
 
   enum Flag {
@@ -570,30 +572,28 @@
   }
   repeated Flag flags = 3;
   optional string service_name = 4;
-  optional string conn_hex_hash = 5;
 }
 
 message AppBindRecordProto {
   option (.android.msg_privacy).dest = DEST_AUTOMATIC;
 
-  optional string hex_hash = 1;
-  optional ProcessRecordProto client = 2;
-  repeated ConnectionRecordProto connections = 3;
+  optional string service_name = 1;
+  optional string client_proc_name = 2;
+  repeated string connections = 3; // hex_hash of ConnectionRecordProto
 }
 
 message IntentBindRecordProto {
   option (.android.msg_privacy).dest = DEST_AUTOMATIC;
 
-  optional string hex_hash = 1;
-  optional bool is_create = 2;
-  optional .android.content.IntentProto intent = 3;
-  optional string binder = 4;
-  optional bool requested = 5;
-  optional bool received = 6;
-  optional bool has_bound = 7;
-  optional bool do_rebind = 8;
+  optional .android.content.IntentProto intent = 1;
+  optional string binder = 2;
+  optional bool auto_create = 3; // value of BIND_AUTO_CREATE flag.
+  optional bool requested = 4;
+  optional bool received = 5;
+  optional bool has_bound = 6;
+  optional bool do_rebind = 7;
 
-  repeated AppBindRecordProto apps = 9;
+  repeated AppBindRecordProto apps = 8;
 }
 
 // TODO: "dumpsys activity --proto processes"
@@ -688,10 +688,10 @@
   optional SleepStatus sleep_status = 27;
 
   message VoiceProto {
-    option (.android.msg_privacy).dest = DEST_EXPLICIT;
+    option (.android.msg_privacy).dest = DEST_AUTOMATIC;
 
     optional string session = 1;
-    optional .android.os.PowerManagerProto.WakeLockProto wakelock = 2;
+    optional .android.os.PowerManagerProto.WakeLock wakelock = 2;
   }
   optional VoiceProto running_voice = 28;
 
@@ -780,8 +780,8 @@
   optional bool call_finish_booting = 44;
   optional bool boot_animation_complete = 45;
   optional int64 last_power_check_uptime_ms = 46;
-  optional .android.os.PowerManagerProto.WakeLockProto going_to_sleep = 47;
-  optional .android.os.PowerManagerProto.WakeLockProto launching_activity = 48;
+  optional .android.os.PowerManagerProto.WakeLock going_to_sleep = 47;
+  optional .android.os.PowerManagerProto.WakeLock launching_activity = 48;
   optional int32 adj_seq = 49;
   optional int32 lru_seq = 50;
   optional int32 num_non_cached_procs = 51;
@@ -813,14 +813,13 @@
 message UidRecordProto {
   option (.android.msg_privacy).dest = DEST_AUTOMATIC;
 
-  optional string hex_hash = 1;
-  optional int32 uid = 2;
-  optional .android.app.ProcessStateEnum current = 3;
-  optional bool ephemeral = 4;
-  optional bool fg_services = 5;
-  optional bool whilelist = 6;
-  optional .android.util.Duration last_background_time = 7;
-  optional bool idle = 8;
+  optional int32 uid = 1;
+  optional .android.app.ProcessStateEnum current = 2;
+  optional bool ephemeral = 3;
+  optional bool fg_services = 4;
+  optional bool whilelist = 5;
+  optional .android.util.Duration last_background_time = 6;
+  optional bool idle = 7;
 
   enum Change {
     CHANGE_GONE = 0;
@@ -829,8 +828,8 @@
     CHANGE_CACHED = 3;
     CHANGE_UNCACHED = 4;
   }
-  repeated Change last_reported_changes = 9;
-  optional int32 num_procs = 10;
+  repeated Change last_reported_changes = 8;
+  optional int32 num_procs = 9;
 
   message ProcStateSequence {
     option (.android.msg_privacy).dest = DEST_AUTOMATIC;
@@ -839,7 +838,9 @@
     optional int64 last_network_updated = 2;
     optional int64 last_dispatched = 3;
   }
-  optional ProcStateSequence network_state_update = 11;
+  optional ProcStateSequence network_state_update = 10;
+
+  // Next Tag: 11
 }
 
 // proto of class ImportanceToken in ActivityManagerService
diff --git a/core/proto/android/server/intentresolver.proto b/core/proto/android/server/intentresolver.proto
index 0ada895..e67723e 100644
--- a/core/proto/android/server/intentresolver.proto
+++ b/core/proto/android/server/intentresolver.proto
@@ -24,9 +24,9 @@
 message IntentResolverProto {
     option (.android.msg_privacy).dest = DEST_AUTOMATIC;
 
-
+    // A mapping bewteen some key string to IntentFilter's toString().
     message ArrayMapEntry {
-        option (.android.msg_privacy).dest = DEST_EXPLICIT;
+        option (.android.msg_privacy).dest = DEST_AUTOMATIC;
 
         optional string key = 1;
         repeated string values = 2;
diff --git a/core/proto/android/service/diskstats.proto b/core/proto/android/service/diskstats.proto
index e5bdc8b..f55f0e7 100644
--- a/core/proto/android/service/diskstats.proto
+++ b/core/proto/android/service/diskstats.proto
@@ -37,8 +37,8 @@
     }
     // Whether the latency test resulted in an error
     optional bool has_test_error = 1;
-    // If the test errored, error message is contained here
-    optional string error_message = 2 [ (android.privacy).dest = DEST_EXPLICIT ];
+    // If the test errored, error message is contained here, it is just IOException.
+    optional string error_message = 2;
     // 512B write latency in milliseconds, if the test was successful
     optional int32 write_512b_latency_millis = 3;
     // Free Space in the major partitions
diff --git a/services/core/java/com/android/server/am/AppBindRecord.java b/services/core/java/com/android/server/am/AppBindRecord.java
index 7b38597..972a692 100644
--- a/services/core/java/com/android/server/am/AppBindRecord.java
+++ b/services/core/java/com/android/server/am/AppBindRecord.java
@@ -66,14 +66,13 @@
 
     void writeToProto(ProtoOutputStream proto, long fieldId) {
         long token = proto.start(fieldId);
-        proto.write(AppBindRecordProto.HEX_HASH,
-                Integer.toHexString(System.identityHashCode(this)));
-        if (client != null) {
-            client.writeToProto(proto, AppBindRecordProto.CLIENT);
-        }
+        proto.write(AppBindRecordProto.SERVICE_NAME, service.shortName);
+        proto.write(AppBindRecordProto.CLIENT_PROC_NAME, client.processName);
         final int N = connections.size();
         for (int i=0; i<N; i++) {
-            connections.valueAt(i).writeToProto(proto, AppBindRecordProto.CONNECTIONS);
+            ConnectionRecord conn = connections.valueAt(i);
+            proto.write(AppBindRecordProto.CONNECTIONS,
+                Integer.toHexString(System.identityHashCode(conn)));
         }
         proto.end(token);
     }
diff --git a/services/core/java/com/android/server/am/ConnectionRecord.java b/services/core/java/com/android/server/am/ConnectionRecord.java
index d320fb1..a8e9ad9 100644
--- a/services/core/java/com/android/server/am/ConnectionRecord.java
+++ b/services/core/java/com/android/server/am/ConnectionRecord.java
@@ -176,10 +176,6 @@
         if (binding.service != null) {
             proto.write(ConnectionRecordProto.SERVICE_NAME, binding.service.shortName);
         }
-        if (conn != null) {
-            proto.write(ConnectionRecordProto.CONN_HEX_HASH,
-                    Integer.toHexString(System.identityHashCode(conn.asBinder())));
-        }
         proto.end(token);
     }
 }
diff --git a/services/core/java/com/android/server/am/IntentBindRecord.java b/services/core/java/com/android/server/am/IntentBindRecord.java
index 01ce64c..3457a80 100644
--- a/services/core/java/com/android/server/am/IntentBindRecord.java
+++ b/services/core/java/com/android/server/am/IntentBindRecord.java
@@ -113,10 +113,6 @@
 
     public void writeToProto(ProtoOutputStream proto, long fieldId) {
         long token = proto.start(fieldId);
-        proto.write(IntentBindRecordProto.HEX_HASH,
-                Integer.toHexString(System.identityHashCode(this)));
-        proto.write(IntentBindRecordProto.IS_CREATE,
-                (collectFlags()&Context.BIND_AUTO_CREATE) != 0);
         if (intent != null) {
             intent.getIntent().writeToProto(proto,
                     IntentBindRecordProto.INTENT, false, true, false, false);
@@ -124,6 +120,8 @@
         if (binder != null) {
             proto.write(IntentBindRecordProto.BINDER, binder.toString());
         }
+        proto.write(IntentBindRecordProto.AUTO_CREATE,
+                (collectFlags()&Context.BIND_AUTO_CREATE) != 0);
         proto.write(IntentBindRecordProto.REQUESTED, requested);
         proto.write(IntentBindRecordProto.RECEIVED, received);
         proto.write(IntentBindRecordProto.HAS_BOUND, hasBound);
diff --git a/services/core/java/com/android/server/am/ServiceRecord.java b/services/core/java/com/android/server/am/ServiceRecord.java
index b6eff00..49a55cb 100644
--- a/services/core/java/com/android/server/am/ServiceRecord.java
+++ b/services/core/java/com/android/server/am/ServiceRecord.java
@@ -164,21 +164,20 @@
 
         public void writeToProto(ProtoOutputStream proto, long fieldId, long now) {
             long token = proto.start(fieldId);
-            proto.write(ServiceRecordProto.StartItemProto.ID, id);
+            proto.write(ServiceRecordProto.StartItem.ID, id);
             ProtoUtils.toDuration(proto,
-                    ServiceRecordProto.StartItemProto.DURATION, deliveredTime, now);
-            proto.write(ServiceRecordProto.StartItemProto.DELIVERY_COUNT, deliveryCount);
-            proto.write(ServiceRecordProto.StartItemProto.DONE_EXECUTING_COUNT, doneExecutingCount);
+                    ServiceRecordProto.StartItem.DURATION, deliveredTime, now);
+            proto.write(ServiceRecordProto.StartItem.DELIVERY_COUNT, deliveryCount);
+            proto.write(ServiceRecordProto.StartItem.DONE_EXECUTING_COUNT, doneExecutingCount);
             if (intent != null) {
-                intent.writeToProto(proto, ServiceRecordProto.StartItemProto.INTENT, true, true,
+                intent.writeToProto(proto, ServiceRecordProto.StartItem.INTENT, true, true,
                         true, false);
             }
             if (neededGrants != null) {
-                neededGrants.writeToProto(proto, ServiceRecordProto.StartItemProto.NEEDED_GRANTS);
+                neededGrants.writeToProto(proto, ServiceRecordProto.StartItem.NEEDED_GRANTS);
             }
             if (uriPermissions != null) {
-                uriPermissions.writeToProto(proto,
-                        ServiceRecordProto.StartItemProto.URI_PERMISSIONS);
+                uriPermissions.writeToProto(proto, ServiceRecordProto.StartItem.URI_PERMISSIONS);
             }
             proto.end(token);
         }
@@ -236,8 +235,6 @@
     void writeToProto(ProtoOutputStream proto, long fieldId) {
         long token = proto.start(fieldId);
         proto.write(ServiceRecordProto.SHORT_NAME, this.shortName);
-        proto.write(ServiceRecordProto.HEX_HASH,
-                Integer.toHexString(System.identityHashCode(this)));
         proto.write(ServiceRecordProto.IS_RUNNING, app != null);
         if (app != null) {
             proto.write(ServiceRecordProto.PID, app.pid);
diff --git a/services/core/java/com/android/server/am/UidRecord.java b/services/core/java/com/android/server/am/UidRecord.java
index 3886e5a..d49f3ba 100644
--- a/services/core/java/com/android/server/am/UidRecord.java
+++ b/services/core/java/com/android/server/am/UidRecord.java
@@ -148,7 +148,6 @@
 
     void writeToProto(ProtoOutputStream proto, long fieldId) {
         long token = proto.start(fieldId);
-        proto.write(UidRecordProto.HEX_HASH, Integer.toHexString(System.identityHashCode(this)));
         proto.write(UidRecordProto.UID, uid);
         proto.write(UidRecordProto.CURRENT, ProcessList.makeProcStateProtoEnum(curProcState));
         proto.write(UidRecordProto.EPHEMERAL, ephemeral);