File: findunusedstrings

package info (click to toggle)
android-platform-development 8.1.0%2Br23-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 37,780 kB
  • sloc: ansic: 166,133; xml: 75,737; java: 19,329; python: 11,511; cpp: 8,221; sh: 2,075; lisp: 261; ruby: 183; asm: 132; perl: 129; makefile: 18
file content (50 lines) | stat: -rwxr-xr-x 1,221 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash

if [ "$1" == "-h" ]
then
    cat <<- EOH
		    Usage: $0 [-p] [folder]
		      -p option prints out unused strings, otherwise a total count is printed
		      folder option causes only that app folder to be scanned, default is to scan all folders onder apps/
		EOH
    exit
fi

showall=no
if [ "$1" == "-p" ]
then
    showall=yes
    shift
fi

apps=$1
if [ "$apps" == "" ]
then
    apps=$ANDROID_BUILD_TOP/packages/apps/*
fi

for app in $apps
do
    if [ -d $app/res ]
    then
        pushd $app > /dev/null
        # Two sed's were needed because the | operator is not supported on the mac
        for i in $(grep -Rs "\(string\|plurals\) name=" res | sed 's/.*string name=\"//' | sed 's/.*plurals name=\"//'|sed 's/".*$//'|sort -u)
        do
            echo $i $(grep -Rws R.plurals.$i\\\|R.string.$i\\\|@string/$i .|wc -l)
        done | grep ' 0$' | {
            if [ "$showall" == "yes" ]
            then
                echo $app
                cat
            else
                count=$(wc -l)
                if [ "$count" != "0" ]
                then
                    echo $app: $count unused strings
                fi
            fi
        }
        popd $app > /dev/null
    fi
done