Temporary root feature on USER releases

On USER releases, we need to get root privileges to handle
some things during DVT. This feature will be removed at the
start of MP phase.

Bug:FP4S-162
Test:
 1. fastboot oem enable-root
 2. fastboot oem disable-root

Change-Id: I2f81f6694542e25e73e0c645dfcab054342a024e
diff --git a/init/property_service.cpp b/init/property_service.cpp
index 600f279..fe019d0 100644
--- a/init/property_service.cpp
+++ b/init/property_service.cpp
@@ -1120,7 +1120,23 @@
     }
 }
 
+void DefaultPropertyT2M() {
+    bool inproduction = android::base::GetBoolProperty("ro.boot.inproductionflag", false);
+
+    //FP4-492, root for user, liquan.zhou.t2m, 20210601
+    bool is_t2m_debug = android::base::GetBoolProperty("ro.boot.t2mdebugflag", false);
+
+    if(inproduction || is_t2m_debug){
+        InitPropertySet("ro.debuggable", "1");
+        InitPropertySet("ro.adb.secure", "0");
+    }
+
+}
+
 void PropertyLoadBootDefaults() {
+
+    DefaultPropertyT2M();
+
     // We read the properties and their values into a map, in order to always allow properties
     // loaded in the later property files to override the properties in loaded in the earlier
     // property files, regardless of if they are "ro." properties or not.
diff --git a/init/selinux.cpp b/init/selinux.cpp
index 958810b..e9722d5 100644
--- a/init/selinux.cpp
+++ b/init/selinux.cpp
@@ -126,6 +126,19 @@
     return flag;
 }
 
+//FP4-492, root for user, liquan.zhou.t2m, 20210601
+bool isT2MDebugFlagStatus() {
+    bool flag = false ;
+
+    ImportKernelCmdline([&](const std::string& key, const std::string& value) {
+        if (key == "androidboot.t2mdebugflag" && value == "true") {
+            flag = true;
+        }
+    });
+
+    return flag;
+}
+
 bool IsEnforcing() {
 
     // FP4-263, set selinux permissive if innproduct flag is true, liquan.zhou.t2m, 20210509.
@@ -134,6 +147,12 @@
         return false;
     }
 
+    //FP4-492, root for user, liquan.zhou.t2m, 20210601
+    if (isT2MDebugFlagStatus()) {
+        LOG(INFO) << "odm debugflag is true";
+        return false;
+    }
+
     if (ALLOW_PERMISSIVE_SELINUX) {
         return StatusFromProperty() == SELINUX_ENFORCING;
     }