diff --git a/cpufreq/cpufreq_03.sh b/cpufreq/cpufreq_03.sh
index 85118d7..7b08da0 100755
--- a/cpufreq/cpufreq_03.sh
+++ b/cpufreq/cpufreq_03.sh
@@ -49,8 +49,9 @@ check_governor() {
     set_governor $cpu $oldgov
 }
 
-if [ $(id -u) -ne 0 ]; then
-    log_skip "run as non-root"
+get_uid
+if [ $? -ne 0 ]; then
+    log_skip "user is not root"
     exit 0
 fi
 
diff --git a/cpufreq/cpufreq_04.sh b/cpufreq/cpufreq_04.sh
index 4a07315..9609f65 100755
--- a/cpufreq/cpufreq_04.sh
+++ b/cpufreq/cpufreq_04.sh
@@ -33,6 +33,12 @@ if [ $? -ne 0 ]; then
 	exit 0
 fi
 
+get_uid
+if [ $? -ne 0 ]; then
+    log_skip "user is not root"
+    exit 0
+fi
+
 check_frequency() {
 
     local cpu=$1
@@ -52,11 +58,6 @@ check_frequency() {
     set_governor $cpu $oldgov
 }
 
-if [ $(id -u) -ne 0 ]; then
-    log_skip "run as non-root"
-    exit 0
-fi
-
 supported=$(cat $CPU_PATH/cpu0/cpufreq/scaling_available_governors | grep "userspace")
 if [ -z "$supported" ]; then
     log_skip "userspace not supported"
diff --git a/cpufreq/cpufreq_05.sh b/cpufreq/cpufreq_05.sh
index 3c76bc1..1702ab7 100755
--- a/cpufreq/cpufreq_05.sh
+++ b/cpufreq/cpufreq_05.sh
@@ -33,8 +33,9 @@ if [ $? -ne 0 ]; then
 	exit 0
 fi
 
-if [ $(id -u) -ne 0 ]; then
-    log_skip "run as non-root"
+get_uid
+if [ $? -ne 0 ]; then
+    log_skip "user is not root"
     exit 0
 fi
 
diff --git a/cpufreq/cpufreq_06.sh b/cpufreq/cpufreq_06.sh
index 157b1ef..ac81288 100755
--- a/cpufreq/cpufreq_06.sh
+++ b/cpufreq/cpufreq_06.sh
@@ -107,8 +107,9 @@ check_deviation() {
     for_each_frequency $cpu check_freq_deviation
 }
 
-if [ $(id -u) -ne 0 ]; then
-    log_skip "run as non-root"
+get_uid
+if [ $? -ne 0 ]; then
+    log_skip "user is not root"
     exit 0
 fi
 
diff --git a/cpufreq/cpufreq_07.sh b/cpufreq/cpufreq_07.sh
index 10fe909..f9dca2e 100755
--- a/cpufreq/cpufreq_07.sh
+++ b/cpufreq/cpufreq_07.sh
@@ -83,8 +83,9 @@ check_ondemand() {
     return 1
 }
 
-if [ $(id -u) -ne 0 ]; then
-    log_skip "run as non-root"
+get_uid
+if [ $? -ne 0 ]; then
+    log_skip "user is not root"
     exit 0
 fi
 
diff --git a/cpufreq/cpufreq_08.sh b/cpufreq/cpufreq_08.sh
index 8ab33b7..749b4bf 100755
--- a/cpufreq/cpufreq_08.sh
+++ b/cpufreq/cpufreq_08.sh
@@ -72,8 +72,9 @@ check_userspace() {
 
 save_governors
 
-if [ $(id -u) -ne 0 ]; then
-    log_skip "run as non-root"
+get_uid
+if [ $? -ne 0 ]; then
+    log_skip "user is not root"
     exit 0
 fi
 
diff --git a/cpufreq/cpufreq_09.sh b/cpufreq/cpufreq_09.sh
index 832c303..8baac8f 100755
--- a/cpufreq/cpufreq_09.sh
+++ b/cpufreq/cpufreq_09.sh
@@ -68,8 +68,9 @@ check_powersave() {
 
 save_governors
 
-if [ $(id -u) -ne 0 ]; then
-    log_skip "run as non-root"
+get_uid
+if [ $? -ne 0 ]; then
+    log_skip "user is not root"
     exit 0
 fi
 
diff --git a/cpuidle/cpuidle_02.sh b/cpuidle/cpuidle_02.sh
index e604a8b..d5020c0 100755
--- a/cpuidle/cpuidle_02.sh
+++ b/cpuidle/cpuidle_02.sh
@@ -29,8 +29,9 @@ source ../include/functions.sh
 
 CPUIDLE_KILLER=./cpuidle_killer
 
-if [ $(id -u) -ne 0 ]; then
-    log_skip "run as non-root"
+get_uid
+if [ $? -ne 0 ]; then
+    log_skip "user is not root"
     exit 0
 fi
 
diff --git a/cpuidle/cpuidle_03.sh b/cpuidle/cpuidle_03.sh
index b07bc89..4ef5538 100755
--- a/cpuidle/cpuidle_03.sh
+++ b/cpuidle/cpuidle_03.sh
@@ -29,8 +29,9 @@ source ../include/functions.sh
 
 CPUIDLE_KILLER=./cpuidle_killer
 
-if [ $(id -u) -ne 0 ]; then
-    log_skip "run as non-root"
+get_uid
+if [ $? -ne 0 ]; then
+    log_skip "user is not root"
     exit 0
 fi
 
@@ -49,7 +50,8 @@ check_cpuidle_kill() {
     check "cpuidle program runs successfully (120 secs)" "./$CPUIDLE_KILLER"
 }
 
-if [ $(id -u) -ne 0 ]; then
+get_uid
+if [ $? -ne 0 ]; then
     log_skip "run as non-root"
     exit 0
 fi
diff --git a/cpuidle/cpuidle_04.sh b/cpuidle/cpuidle_04.sh
index 1688873..a489cb6 100644
--- a/cpuidle/cpuidle_04.sh
+++ b/cpuidle/cpuidle_04.sh
@@ -27,8 +27,9 @@ source ../include/functions.sh
 
 CPUIDLE_STATS=./cpuidle_stats
 
-if [ $(id -u) -ne 0 ]; then
-    log_skip "run as non-root"
+get_uid
+if [ $? -ne 0 ]; then
+    log_skip "user is not root"
     exit 0
 fi
 
diff --git a/include/functions.sh b/include/functions.sh
index 2124ceb..2307cde 100644
--- a/include/functions.sh
+++ b/include/functions.sh
@@ -348,3 +348,29 @@ sigtrap() {
 cpufreq_enabled() {
     test -d /sys/devices/system/cpu/cpufreq
 }
+
+# currently we support ubuntu and android
+get_os() {
+    lsb_release -a 2>&1 | grep -i ubuntu > /dev/null
+    if [ $? -eq 0 ]; then
+        # for ubuntu
+        return 1
+    else
+        # for android (if needed can look for build.prop)
+        return 2
+    fi
+}
+
+get_uid() {
+    local ret
+    get_os
+    if [ $? -eq 1 ]; then
+        # for ubuntu
+        ret=$(id -u)
+	return $ret
+    else
+        # for android
+        ret=$(id | sed -n 's/uid=//p' | sed -n 's/(root) [a-z]*=[0-9]*(log)//p')
+	return $ret
+    fi
+}
