reduced the checkforapp function call to reduce unwanted log info

Change-Id: I5a665969b3fcd6c444307685eaf4800e32cb435f
diff --git a/gui/action.cpp b/gui/action.cpp
index bccf269..06de41e 100755
--- a/gui/action.cpp
+++ b/gui/action.cpp
@@ -1958,48 +1958,10 @@
 	operation_start("Check for TWRP App");
 	if (!simulate)
 	{
-		string sdkverstr = TWFunc::System_Property_Get("ro.build.version.sdk");
-		int sdkver = 0;
-		if (!sdkverstr.empty()) {
-			sdkver = atoi(sdkverstr.c_str());
-		}
-		if (sdkver <= 13) {
-			if (sdkver == 0)
-				LOGINFO("Unable to read sdk version from build prop\n");
-			else
-				LOGINFO("SDK version too low for TWRP app (%i < 14)\n", sdkver);
-			DataManager::SetValue("tw_app_install_status", 1); // 0 = no status, 1 = not installed, 2 = already installed or do not install
-			goto exit;
-		}
-		if (TWFunc::Is_TWRP_App_In_System()) {
-			DataManager::SetValue("tw_app_install_status", 2); // 0 = no status, 1 = not installed, 2 = already installed or do not install
-			goto exit;
-		}
-		if (PartitionManager.Mount_By_Path("/data", false)) {
-			const char parent_path[] = "/data/app";
-			const char app_prefix[] = "me.twrp.twrpapp-";
-			DIR *d = opendir(parent_path);
-			if (d) {
-				struct dirent *p;
-				while ((p = readdir(d))) {
-					if (p->d_type != DT_DIR || strlen(p->d_name) < strlen(app_prefix) || strncmp(p->d_name, app_prefix, strlen(app_prefix)))
-						continue;
-					closedir(d);
-					LOGINFO("App found at '%s/%s'\n", parent_path, p->d_name);
-					DataManager::SetValue("tw_app_install_status", 2); // 0 = no status, 1 = not installed, 2 = already installed or do not install
-					goto exit;
-				}
-				closedir(d);
-			}
-		} else {
-			LOGINFO("Data partition cannot be mounted during app check\n");
-			DataManager::SetValue("tw_app_install_status", 2); // 0 = no status, 1 = not installed, 2 = already installed or do not install
-		}
+		TWFunc::checkforapp();
 	} else
 		simulate_progress_bar();
-	LOGINFO("App not installed\n");
-	DataManager::SetValue("tw_app_install_status", 1); // 0 = no status, 1 = not installed, 2 = already installed
-exit:
+
 	operation_end(0);
 	return 0;
 }
@@ -2112,6 +2074,7 @@
 	} else
 		simulate_progress_bar();
 exit:
+	TWFunc::checkforapp();
 	operation_end(0);
 	return 0;
 }
@@ -2165,6 +2128,7 @@
 	} else
 		simulate_progress_bar();
 exit:
+	TWFunc::checkforapp();
 	operation_end(0);
 	return 0;
 }
diff --git a/gui/theme/common/landscape.xml b/gui/theme/common/landscape.xml
index 9315720..010e08e 100755
--- a/gui/theme/common/landscape.xml
+++ b/gui/theme/common/landscape.xml
@@ -3442,13 +3442,6 @@
 		</page>
 
 		<page name="advanced">
-			<action>
-				<action function="checkforapp"></action>
-				<action function="page">advanced1</action>
-			</action>
-		</page>
-
-		<page name="advanced1">
 			<template name="page"/>
 
 			<text style="text_l">
diff --git a/gui/theme/common/portrait.xml b/gui/theme/common/portrait.xml
index 711139f..b78191d 100755
--- a/gui/theme/common/portrait.xml
+++ b/gui/theme/common/portrait.xml
@@ -3563,13 +3563,6 @@
 		</page>
 
 		<page name="advanced">
-			<action>
-				<action function="checkforapp"></action>
-				<action function="page">advanced1</action>
-			</action>
-		</page>
-
-		<page name="advanced1">
 			<template name="page"/>
 
 			<text style="text_l">
diff --git a/gui/theme/common/watch.xml b/gui/theme/common/watch.xml
index d76a1d3..7debf3a 100755
--- a/gui/theme/common/watch.xml
+++ b/gui/theme/common/watch.xml
@@ -4214,13 +4214,6 @@
 		</page>
 
 		<page name="advanced2">
-			<action>
-				<action function="checkforapp"></action>
-				<action function="page">advanced3</action>
-			</action>
-		</page>
-
-		<page name="advanced3">
 			<template name="page"/>
 
 			<template name="statusbar"/>
diff --git a/twrp-functions.cpp b/twrp-functions.cpp
index 82af082..cefaf91 100755
--- a/twrp-functions.cpp
+++ b/twrp-functions.cpp
@@ -1327,6 +1327,53 @@
 	return false;
 }
 
+void TWFunc::checkforapp(){
+
+	string sdkverstr = System_Property_Get("ro.build.version.sdk");
+	int sdkver = 0;
+	if (!sdkverstr.empty()) {
+		sdkver = atoi(sdkverstr.c_str());
+	}
+	if (sdkver <= 13) {
+		if (sdkver == 0)
+			LOGINFO("Unable to read sdk version from build prop\n");
+		else
+			LOGINFO("SDK version too low for TWRP app (%i < 14)\n", sdkver);
+		DataManager::SetValue("tw_app_install_status", 1); // 0 = no status, 1 = not installed, 2 = already installed or do not install
+		goto exit;
+	}
+	if (Is_TWRP_App_In_System()) {
+		DataManager::SetValue("tw_app_install_status", 2); // 0 = no status, 1 = not installed, 2 = already installed or do not install
+		goto exit;
+	}
+	if (PartitionManager.Mount_By_Path("/data", false)) {
+		const char parent_path[] = "/data/app";
+		const char app_prefix[] = "me.twrp.twrpapp-";
+		DIR *d = opendir(parent_path);
+		if (d) {
+			struct dirent *p;
+			while ((p = readdir(d))) {
+				if (p->d_type != DT_DIR || strlen(p->d_name) < strlen(app_prefix) || strncmp(p->d_name, app_prefix, strlen(app_prefix)))
+					continue;
+				closedir(d);
+				LOGINFO("App found at '%s/%s'\n", parent_path, p->d_name);
+				DataManager::SetValue("tw_app_install_status", 2); // 0 = no status, 1 = not installed, 2 = already installed or do not install
+				goto exit;
+			}
+			closedir(d);
+		}
+	} else {
+		LOGINFO("Data partition cannot be mounted during app check\n");
+		DataManager::SetValue("tw_app_install_status", 2); // 0 = no status, 1 = not installed, 2 = already installed or do not install
+	}
+
+	LOGINFO("App not installed\n");
+	DataManager::SetValue("tw_app_install_status", 1); // 0 = no status, 1 = not installed, 2 = already installed
+exit:
+	return;
+
+}
+
 int TWFunc::Property_Override(string Prop_Name, string Prop_Value) {
 #ifdef TW_INCLUDE_LIBRESETPROP
     return setprop(Prop_Name.c_str(), Prop_Value.c_str(), false);
diff --git a/twrp-functions.hpp b/twrp-functions.hpp
index d185398..3e013c3 100755
--- a/twrp-functions.hpp
+++ b/twrp-functions.hpp
@@ -118,6 +118,7 @@
 	static std::string get_log_dir(); // return recovery log storage directory
 	static void check_selinux_support(); // print whether selinux support is enabled to console
 	static bool Is_TWRP_App_In_System(); // Check if the TWRP app is installed in the system partition
+	static void checkforapp();
 	static int Property_Override(string Prop_Name, string Prop_Value); // Override properties (including ro. properties)
 	static bool Get_Encryption_Policy(ext4_encryption_policy &policy, std::string path); // return encryption policy for path
 	static bool Set_Encryption_Policy(std::string path, const ext4_encryption_policy &policy); // set encryption policy for path
diff --git a/twrp.cpp b/twrp.cpp
index 6df37d9..eb05b2d 100755
--- a/twrp.cpp
+++ b/twrp.cpp
@@ -397,6 +397,8 @@
 	twrpAdbBuFifo *adb_bu_fifo = new twrpAdbBuFifo();
 	adb_bu_fifo->threadAdbBuFifo();
 
+	TWFunc::checkforapp(); //Checking compatibility for TWRP app
+
 	// Launch the main GUI
 	gui_start();