Skip to content

Commit ad0d224

Browse files
committed
Delete the white spaces
1 parent b3e8284 commit ad0d224

File tree

1 file changed

+43
-42
lines changed

1 file changed

+43
-42
lines changed

library/machineFileOperations.sh

Lines changed: 43 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
function checkMachineSubFolder() {
1313
#$1 - main folder absolute path
1414
#$2 - subfolder
15-
#$return -
15+
#$return -
1616
if [ $# -lt 2 ]; then
1717
writeToLogsFile "@@ No 2 argument passed to ${FUNCNAME[0]}() in ${BASH_SOURCE} called from $( basename ${0} )"
1818
exit 1
@@ -21,7 +21,7 @@ function checkMachineSubFolder() {
2121
appInstallFromPath="$appInstallFromPath/$2"
2222
else # if there is no subfolder with the specified name, check if the user wants to search the default folder
2323
local useDefaultFolderOption
24-
24+
2525
echo -e -n " ${txtBld}$2${txtRst} folder doesnot exists in $1 ...\n\n Do you want to install from ${txtPur}${txtBld}$1${txtRst} instead [y/n]: "
2626
stty -echo && read -n 1 useDefaultFolderOption && stty echo
2727
formatYesNoOption $useDefaultFolderOption
@@ -108,9 +108,9 @@ function compareMachineFiles(){
108108
#check if files are same or diff. If SAME, it will return blank. If DIFF, it will return diff status
109109
#diffResult=`diff -q "${1}" "${2}" | rev | cut -d" " -f1 | rev | tr -d "\r\n"`
110110
diffResult=`diff -q "${1}" "${2}"`
111-
111+
112112
if [ -n "${diffResult}" ]; then
113-
diffStatus="diff"
113+
diffStatus="diff"
114114
else
115115
diffStatus="same"
116116
fi
@@ -167,7 +167,7 @@ function buildMachineInstallFileArray() {
167167
local installAppsSelectedList=""
168168
local installAppOption="n"
169169
local appName=""
170-
170+
171171
local appInstallFromPath="${1}"
172172
local machineFilesList=("${!2}")
173173
local machineFilesArray=( $machineFilesList )
@@ -178,7 +178,7 @@ function buildMachineInstallFileArray() {
178178
#local appName=${i##*/}
179179
local apkSubPath=${i#$appInstallFromPath}
180180

181-
formatMessage " Do you want to install [y/n] - " "Q"
181+
formatMessage " Do you want to install [y/n] - " "Q"
182182
formatMessage "$apkSubPath : "
183183
stty -echo && read -n 1 installAppOption && stty echo
184184
formatYesNoOption $installAppOption
@@ -224,15 +224,15 @@ function compareAndCopyMachineFiles(){
224224
# compare source and destination folder for the file
225225
#echo " Comparing "${srcFolder}/${fileName}" "${dstFolder}/${fileName}"\n"
226226
compareFileStatus=$( compareMachineFiles "${srcFolder}/${fileName}" "${dstFolder}/${fileName}" )
227-
227+
228228
# If files are "same", do nothing
229229

230230
#If files are "diff", copy the file to destination
231231
if [ "$compareFileStatus" == "diff" ]; then
232232
echo -e -n " ${fileName} ${txtGrn}was found and has changed${txtRst}. Will copy to ${dstFolder}...\n"
233233
#cp "${srcFolder}/${fileName}" "${dstFolder}/${fileName[}"
234234
#TODO: Auto copy if the source is latest. If destination is latest, then ask if they want to copy/overwrite
235-
copySelectedFiles="$copySelectedFiles ${fileName}"
235+
copySelectedFiles="$copySelectedFiles ${fileName}"
236236
#If the file is not present in the destination, confirm and copy the file to destination
237237
elif [ "$compareFileStatus" == "NoDst" ]; then
238238
echo -e -n " ${fileName} ${txtRed}was not found${txtRst} in destination directory. Do you want to copy ? [y/n] : "
@@ -319,7 +319,7 @@ function getMachineApkPackageName() {
319319
exit 1
320320
else
321321
if [[ "$( checkYesNoOption $( checkMachineFileExist ${1} ) )" == "yes" ]]; then
322-
local machineApkPackageName=`aapt dump badging "${1}" | awk '/package/{gsub("name=|'"'"'",""); print $2}'`
322+
local machineApkPackageName=`aapt dump badging "${1}" | awk '/package/{gsub("name=|'"'"'",""); print $2}'`
323323
echo -e -n ${machineApkPackageName} # returns 'com.google.android.music'
324324
else
325325
writeToLogsFile "'${1}' File Not Found - ${FUNCNAME[0]}() in ${BASH_SOURCE} called from $( basename ${0} )"
@@ -375,17 +375,17 @@ function getDeviceApkVersion() {
375375
exit 1
376376
else
377377
local i=0
378-
378+
379379
local machineApkPackageName=`getMachineApkPackageName ${2}`
380-
380+
381381
while read line
382382
do
383383
if [ -n "$line" ]; then
384384
deviceApkVersion[i]="$line"
385385
let i=$i+1
386386
fi
387387
done < <(adb -s ${1} wait-for-device shell dumpsys package ${machineApkPackageName} | grep -i versionname | cut -f2 -d"=" | tr -d "\r")
388-
388+
389389
echo -e -n ${deviceApkVersion[0]}
390390
fi
391391
}
@@ -412,7 +412,7 @@ function checkDeviceApkCompatibility(){
412412
local apkType=$(getApkForDeviceType "${2}")
413413
local deviceType=$(getDeviceType "${1}")
414414
local compatible=""
415-
415+
416416
case $apkType in
417417
[pP][hH][oO][nN][eE]) #phone
418418
if [[ "$deviceType" == "phone" || "$deviceType" == "tablet" ]]; then
@@ -492,7 +492,7 @@ function adbInstallApk(){
492492
function forceInstallApk() {
493493
#$1 - deviceSerial
494494
#$2 - apk file complete path in machine
495-
#return -
495+
#return -
496496
if [ $# -lt 2 ]; then
497497
writeToLogsFile "@@ No argument passed to ${FUNCNAME[0]}() in ${BASH_SOURCE} called from $( basename ${0} )"
498498
exit 1
@@ -514,7 +514,7 @@ function forceInstallApk() {
514514
function installApk() {
515515
#$1 - deviceSerial
516516
#$2 - apk file complete path in machine
517-
#return -
517+
#return -
518518
if [ $# -lt 2 ]; then
519519
writeToLogsFile "@@ No 2 argument passed to ${FUNCNAME[0]}() in ${BASH_SOURCE} called from $( basename ${0} )"
520520
exit 1
@@ -524,7 +524,8 @@ function installApk() {
524524
local installApkChoice="yes"
525525

526526
if [ "$isCompatible" == "false" ]; then
527-
formatMessage "\n Apk is not compatible for the selected device. Do you still want to try to install it? [y/n]: " "E"
527+
formatMessage "\n Apk may not be compatible for the selected device." "E"
528+
formatMessage "\n Do you still want to try installing it? [y/n]: " "Q"
528529

529530
stty -echo && read -n 1 installApkChoice && stty echo
530531
formatYesNoOption $installApkChoice
@@ -547,7 +548,7 @@ function installApk() {
547548
function installApkReinstall() {
548549
#$1 - deviceSerial
549550
#$2 - apk file complete path in machine
550-
#return -
551+
#return -
551552
if [ $# -lt 2 ]; then
552553
writeToLogsFile "@@ No 2 argument passed to ${FUNCNAME[0]}() in ${BASH_SOURCE} called from $( basename ${0} )"
553554
exit 1
@@ -556,15 +557,15 @@ function installApkReinstall() {
556557

557558
formatMessage " - The application '${machineApkApplicationName}' is already installed in your device" "E"
558559
formatMessage "\n\n Do you still want to reinstall? [y/n] : " "Q"
559-
560+
560561
stty -echo && read -n 1 reinstallApkChoice && stty echo
561562
formatYesNoOption $reinstallApkChoice
562563
echo ""
563564

564565
if [ "$( checkYesNoOption $reinstallApkChoice )" == "yes" ]; then
565566
local output=$( adbInstallApk ${1} ${2} "-r")
566567
local status=`echo ${output} | cut -f3 -d" " | tr -d "\r"`
567-
568+
568569
installApkStatusReason "$1" "$2" "$output" "$status"
569570

570571
elif [ "$( checkYesNoOption $reinstallApkChoice )" == "no" ]; then
@@ -577,34 +578,34 @@ function installApkReinstall() {
577578
function installApkDowngrade() {
578579
#$1 - deviceSerial
579580
#$2 - apk file complete path in machine
580-
#return -
581+
#return -
581582
if [ $# -lt 2 ]; then
582583
writeToLogsFile "@@ No 2 argument passed to ${FUNCNAME[0]}() in ${BASH_SOURCE} called from $( basename ${0} )"
583584
exit 1
584585
else
585586
local machineApkPackageName=`getMachineApkPackageName ${2}`
586587
local machineApkVersion=`getMachineApkVersion ${2}`
587588
local deviceApkVersion=`getDeviceApkVersion ${1} ${2}`
588-
589+
589590
formatMessage " - There is a higher version currently installed in your device" "E"
590591
echo -e -n "\n\n Installed in Device - ${deviceApkVersion}"
591592
echo -e -n "\n About to install - ${machineApkVersion}\n"
592593
formatMessage "\n Do you still want to install? [y/n] : " "Q"
593-
594+
594595
stty -echo && read -n 1 downgradeApkChoice && stty echo
595596
formatYesNoOption $downgradeApkChoice
596597
echo ""
597598

598599
if [ "$( checkYesNoOption $downgradeApkChoice )" == "yes" ]; then
599-
600+
600601
if [ $( getDeviceBuildVersion $1 ) > "4.1" ]; then
601602
local output=$( adbInstallApk ${1} ${2} "-r -d" )
602603
else
603604
local output=$( adbInstallApk ${1} ${2} "-r" )
604605
fi
605-
606+
606607
local status=`echo ${output} | cut -f3 -d" " | tr -d "\r"`
607-
608+
608609
installApkStatusReason "$1" "$2" "$output" "$status"
609610

610611
elif [ "$( checkYesNoOption $downgradeApkChoice )" == "no" ]; then
@@ -619,7 +620,7 @@ function installApkStatusReason() {
619620
#$2 - apk file complete path in machine
620621
#$3 - complete output of adb install command
621622
#$4 - status of adb install command [Success / Failure]
622-
#return -
623+
#return -
623624
if [ $# -lt 4 ]; then
624625
writeToLogsFile "@@ No 4 argument passed to ${FUNCNAME[0]}() in ${BASH_SOURCE} called from $( basename ${0} )"
625626
exit 1
@@ -629,9 +630,9 @@ function installApkStatusReason() {
629630
echo ""
630631
elif [ "${4}" == "Failure" ]; then
631632
echo -e -n " Status : ${txtRed}$status${txtRst}"
632-
633+
633634
local reason=`echo ${3} | cut -f4 -d" " | cut -f2 -d"[" | cut -f1 -d"]" | tr -d "\r"`
634-
635+
635636
case "$reason" in
636637
"INSTALL_FAILED_ALREADY_EXISTS")
637638
installApkReinstall $1 "$2"
@@ -648,7 +649,7 @@ function installApkStatusReason() {
648649
exit 1
649650
;;
650651
esac
651-
652+
652653
else
653654
formatMessage " Status : $status\n"
654655
fi
@@ -661,7 +662,7 @@ function apkInstall() {
661662
#$1 - device serial
662663
#$2 - folder absolute path
663664
#$3 - apk Sub path
664-
#return -
665+
#return -
665666
if [ $# -lt 3 ]; then
666667
writeToLogsFile "@@ No 3 arguments passed to ${FUNCNAME[0]}() in ${BASH_SOURCE} called from $( basename ${0} )"
667668
exit 1
@@ -690,22 +691,22 @@ function installFromPath(){
690691
#$1 - device serial
691692
#$2 - folder absolute path
692693
#$3 - search string
693-
#return -
694+
#return -
694695
if [ $# -lt 3 ]; then
695696
writeToLogsFile "@@ No 2 arguments passed to ${FUNCNAME[0]}() in ${BASH_SOURCE} called from $( basename ${0} )"
696697
exit 1
697-
else
698+
else
698699
local appInstallFromPath="${2}"
699700
local machineFilesList=$(buildMachineFilesList "$appInstallFromPath" "$3")
700701
local machineFilesArray=( $machineFilesList )
701702
local machineFilesCount=${#machineFilesArray[*]}
702703

703704
if [ $machineFilesCount -gt 0 ]; then
704-
705+
705706
if [ $machineFilesCount -gt 1 ]; then #<-- if there is more than 1 matching file
706707
formatMessage " There are $machineFilesCount matching files in the folder : " "I"
707708
formatMessage "$appInstallFromPath\n\n"
708-
709+
709710
buildMachineInstallFileArray "$appInstallFromPath" "machineFilesList[@]"
710711
#local installAppsArray=( $installAppsList )
711712
#local installAppsCount=${#installAppsArray[*]}
@@ -714,7 +715,7 @@ function installFromPath(){
714715
do
715716
apkInstall $1 ${appInstallFromPath} ${i}
716717
done
717-
718+
718719
else #<-- if there is only 1 file
719720
#local apkName="${machineFilesArray[0]}"
720721
#local apkName=${machineFilesArray[0]##*/}
@@ -725,17 +726,17 @@ function installFromPath(){
725726
formatMessage "$appInstallFromPath\n\n"
726727
formatMessage " Do you want to install [y/n] - " "Q"
727728
formatMessage "$apkName : "
728-
729+
729730
stty -echo && read -n 1 installAppOption && stty echo
730731
formatYesNoOption $installAppOption
731732

732733
if [ "$( checkYesNoOption $installAppOption )" == "yes" ]; then
733734
apkInstall $1 ${appInstallFromPath} ${machineFilesArray[0]}
734735
fi
735736
fi
736-
737+
737738
echo ""
738-
739+
739740
else #<-- if the file count is less than zero, i.e., there is no files
740741
formatMessage " There are no matching files in the directory : " "E"
741742
formatMessage "$appInstallFromPath\n\n"
@@ -750,11 +751,11 @@ function installMachineFiles() {
750751
#$2 - main folder absolute path
751752
#$3 - sub folder
752753
#$4 - search string
753-
#$return -
754+
#$return -
754755
if [ $# -lt 4 ]; then
755756
writeToLogsFile "@@ No 4 arguments passed to ${FUNCNAME[0]}() in ${BASH_SOURCE} called from $( basename ${0} )"
756757
exit 1
757-
else
758+
else
758759
local appInstallFromPath="${2}"
759760
checkMachineSubFolder $2 $3
760761

@@ -817,7 +818,7 @@ function isApkForPhone(){
817818
}
818819

819820
function getApkForDeviceType(){
820-
#$1 - apk file complete path
821+
#$1 - apk file complete path
821822
if [ $# -lt 1 ]; then
822823
writeToLogsFile "@@ No argument passed to ${FUNCNAME[0]}() in ${BASH_SOURCE} called from $( basename ${0} )"
823824
exit 1
@@ -883,4 +884,4 @@ function checkTifFolder() {
883884
fi
884885
fi
885886
fi
886-
}
887+
}

0 commit comments

Comments
 (0)