From 83fd8a54f54033837f168bbd61012fa5373a4e4c Mon Sep 17 00:00:00 2001
From: Felipe Leme <felipeal@google.com>
Date: Tue, 1 Dec 2015 18:03:05 -0800
Subject: [PATCH] Increase communication surface between dumpstate and Shell:

- Add a new 'dumpstate' context for system properties. This context
  will be used to share state between dumpstate and Shell. For example,
  as dumpstate progresses, it will update a system property, which Shell
  will use to display the progress in the UI as a system
  notification. The user could also rename the bugreport file, in which
  case Shell would use another system property to communicate such
  change to dumpstate.
- Allow Shell to call 'ctl.bugreport stop' so the same system
  notification can be used to stop dumpstate.

BUG: 25794470

Change-Id: I74b80bda07292a91358f2eea9eb8444caabc5895
---
 dumpstate.te      | 4 ++++
 property.te       | 1 +
 property_contexts | 1 +
 shell.te          | 2 ++
 4 files changed, 8 insertions(+)

diff --git a/dumpstate.te b/dumpstate.te
index 19eacfd05..1a001dcc7 100644
--- a/dumpstate.te
+++ b/dumpstate.te
@@ -111,3 +111,7 @@ allow dumpstate { service_manager_type -gatekeeper_service }:service_manager fin
 allow dumpstate servicemanager:service_manager list;
 
 allow dumpstate devpts:chr_file rw_file_perms;
+
+# Set properties.
+# dumpstate_prop is used to share state with the Shell app.
+set_prop(dumpstate, dumpstate_prop)
diff --git a/property.te b/property.te
index 9e97b6027..a9c5fe6dc 100644
--- a/property.te
+++ b/property.te
@@ -1,6 +1,7 @@
 type default_prop, property_type;
 type shell_prop, property_type;
 type debug_prop, property_type;
+type dumpstate_prop, property_type;
 type persist_debug_prop, property_type;
 type debuggerd_prop, property_type;
 type dhcp_prop, property_type;
diff --git a/property_contexts b/property_contexts
index 989be5a41..c1caed426 100644
--- a/property_contexts
+++ b/property_contexts
@@ -29,6 +29,7 @@ bluetooth.              u:object_r:bluetooth_prop:s0
 
 debug.                  u:object_r:debug_prop:s0
 debug.db.               u:object_r:debuggerd_prop:s0
+dumpstate.              u:object_r:dumpstate_prop:s0
 log.                    u:object_r:shell_prop:s0
 service.adb.root        u:object_r:shell_prop:s0
 service.adb.tcp.port    u:object_r:shell_prop:s0
diff --git a/shell.te b/shell.te
index 90b12d87b..06d08a86e 100644
--- a/shell.te
+++ b/shell.te
@@ -62,7 +62,9 @@ r_dir_file(shell, apk_data_file)
 
 # Set properties.
 set_prop(shell, shell_prop)
+set_prop(shell, ctl_bugreport_prop)
 set_prop(shell, ctl_dumpstate_prop)
+set_prop(shell, dumpstate_prop)
 set_prop(shell, debug_prop)
 set_prop(shell, powerctl_prop)
 
-- 
GitLab