blob: a54b0607f4f3e0b97190264aea6855b5f3e1d482 [file] [log] [blame]
The Android Open Source Project52d4c302009-03-03 19:29:09 -08001#!/bin/bash
2
3if [ "$1" == "-h" ]
4then
5 cat <<- EOH
6 Usage: $0 [-p] [folder]
7 -p option prints out unused strings, otherwise a total count is printed
8 folder option causes only that app folder to be scanned, default is to scan all folders onder apps/
9 EOH
10 exit
11fi
12
13showall=no
14if [ "$1" == "-p" ]
15then
16 showall=yes
17 shift
18fi
19
20apps=$1
21if [ "$apps" == "" ]
22then
23 apps=$ANDROID_BUILD_TOP/packages/apps/*
24fi
25
26for app in $apps
27do
28 if [ -d $app/res ]
29 then
30 pushd $app > /dev/null
31 for i in $(grep -R "\(string\|plurals\) name=" res | sed 's/.*<\(string\|plurals\) name="//'|sed 's/".*$//'|sort -u)
32 do
33 echo $i $(grep -Rw R.plurals.$i\\\|R.string.$i\\\|@string/$i .|wc -l)
34 done | grep ' 0$' | {
35 if [ "$showall" == "yes" ]
36 then
37 echo $app
38 cat
39 else
40 count=$(wc -l)
41 if [ "$count" != "0" ]
42 then
43 echo $app: $count unused strings
44 fi
45 fi
46 }
47 popd $app > /dev/null
48 fi
49done