packages/apps/CMFileManager
Revision | 56d14850714219e98f4def409da7ed0a5efa14c1 (tree) |
---|---|
Time | 2015-12-18 11:56:08 |
Author | Gianmarco Reverberi <gianmarco.reverberi@gmai...> |
Commiter | Raj Yengisetty |
cmfm: this is TOYBOX
* busybox is deprecated
* remove awk usage
* fix file system info
Change-Id: I7c2bcbd5024e3be283c9fd6ad699183b6fb5bf1a
@@ -37,38 +37,36 @@ | ||
37 | 37 | /system/bin/cat, |
38 | 38 | /system/bin/chmod, |
39 | 39 | /system/bin/chown, |
40 | + /system/bin/cp, | |
41 | + /system/bin/cut, | |
40 | 42 | /system/bin/dd, |
41 | 43 | /system/bin/df, |
44 | + /system/bin/dirname, | |
45 | + /system/bin/echo, | |
46 | + /system/bin/find, | |
47 | + /system/bin/grep, | |
48 | + /system/bin/groups, | |
42 | 49 | /system/bin/gzip, |
43 | 50 | /system/bin/id, |
44 | 51 | /system/bin/kill, |
45 | 52 | /system/bin/ln, |
46 | 53 | /system/bin/ls, |
54 | + /system/bin/md5sum, | |
47 | 55 | /system/bin/mkdir, |
48 | 56 | /system/bin/mount, |
49 | 57 | /system/bin/mv, |
50 | 58 | /system/bin/ps, |
59 | + /system/bin/pwd, | |
60 | + /system/bin/readlink, | |
51 | 61 | /system/bin/rm, |
52 | 62 | /system/bin/sh, |
53 | - /system/xbin/awk, | |
54 | - /system/xbin/bunzip2, | |
55 | - /system/xbin/busybox, | |
63 | + /system/bin/sha1sum, | |
64 | + /system/bin/stat, | |
65 | + /system/bin/tar, | |
66 | + /system/bin/toybox, | |
67 | + /system/bin/xargs, | |
56 | 68 | /system/xbin/bzip2, |
57 | - /system/xbin/cp, | |
58 | - /system/xbin/cut, | |
59 | - /system/xbin/dirname, | |
60 | - /system/xbin/echo, | |
61 | - /system/xbin/find, | |
62 | - /system/xbin/grep, | |
63 | - /system/xbin/groups, | |
64 | - /system/xbin/gunzip, | |
65 | - /system/xbin/pwd, | |
66 | - /system/xbin/readlink, | |
67 | - /system/xbin/stat, | |
68 | - /system/xbin/tar, | |
69 | - /system/xbin/xargs, | |
70 | - /system/xbin/md5sum, | |
71 | - /system/xbin/sha1sum | |
69 | + /system/xbin/gunzip | |
72 | 70 | </string> |
73 | 71 | |
74 | 72 | <!-- The root command --> |
@@ -31,16 +31,16 @@ | ||
31 | 31 | --> |
32 | 32 | <CommandList xmlns="http://schemas.android.com/apk/res/com.cyanogenmod.filemanager"> |
33 | 33 | <!-- Start code (append to commands; for retrieve the exit code) --> |
34 | - <startcode commandId="startcode" commandPath="/system/xbin/echo -n %1$s0%2$s ; " /> | |
34 | + <startcode commandId="startcode" commandPath="/system/bin/echo -n %1$s0%2$s ; " /> | |
35 | 35 | <!-- Exit code (append to commands; for retrieve the exit code) --> |
36 | - <exitcode commandId="exitcode" commandPath=" ; /system/xbin/echo -n %1$s$?%2$s" /> | |
36 | + <exitcode commandId="exitcode" commandPath=" ; /system/bin/echo -n %1$s$?%2$s" /> | |
37 | 37 | |
38 | 38 | <!-- Shell commands --> |
39 | 39 | <command commandId="bash" commandPath="/system/bin/sh" commandArgs="" /> |
40 | 40 | <command commandId="su" commandPath="/system/xbin/su" commandArgs="" /> |
41 | 41 | |
42 | 42 | <!-- Console info --> |
43 | - <command commandId="groups" commandPath="/system/xbin/groups" commandArgs="" /> | |
43 | + <command commandId="groups" commandPath="/system/bin/groups" commandArgs="" /> | |
44 | 44 | <command commandId="id" commandPath="/system/bin/id" commandArgs="" /> |
45 | 45 | |
46 | 46 | <!-- FileSystem --> |
@@ -48,58 +48,58 @@ | ||
48 | 48 | <command commandId="mountpointinfo" commandPath="/system/bin/mount" commandArgs="" /> |
49 | 49 | |
50 | 50 | <!-- List/Find/Info --> |
51 | - <command commandId="ls" commandPath="/system/bin/ls" commandArgs="%1$s 1> /dev/null && /system/xbin/stat -t %1$s.* %1$s* 2> /dev/null" /> | |
52 | - <command commandId="fileinfo" commandPath="/system/xbin/stat" commandArgs="-t %1$s" /> | |
53 | - <command commandId="find" commandPath="/system/xbin/find" commandArgs="%1$s \\( -name %2$s -o -name %3$s -o -name %4$s -o -name %5$s -o -name %6$s \\) -exec /system/xbin/stat -t {} 2>&1 \\;" /> | |
54 | - <command commandId="quickfoldersearch" commandPath="/system/bin/ls" commandArgs="-aFd %1$s.* %1$s* 2> /dev/null | /system/xbin/grep -e '^d' -e '^ld' | /system/xbin/cut -d" " -f2-" /> | |
55 | - <command commandId="readlink" commandPath="/system/bin/ls" commandArgs="%1$s 1> /dev/null && /system/xbin/stat -tL %1$s 2>&1" /> | |
51 | + <command commandId="ls" commandPath="/system/bin/ls" commandArgs="%1$s 1> /dev/null && /system/bin/stat -t %1$s.* %1$s* 2> /dev/null" /> | |
52 | + <command commandId="fileinfo" commandPath="/system/bin/stat" commandArgs="-t %1$s" /> | |
53 | + <command commandId="find" commandPath="/system/bin/find" commandArgs="%1$s \\( -name %2$s -o -name %3$s -o -name %4$s -o -name %5$s -o -name %6$s \\) -exec /system/bin/stat -t {} 2>&1 \\;" /> | |
54 | + <command commandId="quickfoldersearch" commandPath="/system/bin/ls" commandArgs="-aFd %1$s.* %1$s* 2> /dev/null | /system/bin/grep -e '^d' -e '^ld' | /system/bin/cut -d" " -f2-" /> | |
55 | + <command commandId="readlink" commandPath="/system/bin/ls" commandArgs="%1$s 1> /dev/null && /system/bin/stat -t -L %1$s 2>&1" /> | |
56 | 56 | |
57 | 57 | <!-- Operational --> |
58 | 58 | <command commandId="chmod" commandPath="/system/bin/chmod" commandArgs="%1$s %2$s" /> |
59 | 59 | <command commandId="chown" commandPath="/system/bin/chown" commandArgs="%1$s.%2$s %3$s" /> |
60 | - <command commandId="cp" commandPath="/system/xbin/cp" commandArgs="-af %1$s %2$s" /> | |
60 | + <command commandId="cp" commandPath="/system/bin/cp" commandArgs="-af %1$s %2$s" /> | |
61 | 61 | <command commandId="link" commandPath="/system/bin/ln" commandArgs="-s %1$s %2$s" /> |
62 | 62 | <command commandId="mkdir" commandPath="/system/bin/mkdir" commandArgs="-p %1$s" /> |
63 | - <command commandId="mv" commandPath="/system/bin/mv" commandArgs="%1$s %2$s || ( /system/xbin/cp -af %1$s %2$s && /system/bin/rm -R %1$s )" /> | |
63 | + <command commandId="mv" commandPath="/system/bin/mv" commandArgs="%1$s %2$s || ( /system/bin/cp -af %1$s %2$s && /system/bin/rm -R %1$s )" /> | |
64 | 64 | <command commandId="rm" commandPath="/system/bin/rm" commandArgs="%1$s" /> |
65 | 65 | <command commandId="rmdir" commandPath="/system/bin/rm" commandArgs="-R %1$s" /> |
66 | 66 | |
67 | 67 | <!-- Usage --> |
68 | - <command commandId="diskusage" commandPath="/system/bin/df" commandArgs="%1$s" /> | |
69 | - <command commandId="diskusageall" commandPath="/system/bin/df" commandArgs="" /> | |
70 | - <command commandId="folderusage" commandPath="/system/xbin/busybox" commandArgs="ls -alR %1$s 2> /dev/null" /> | |
68 | + <command commandId="diskusage" commandPath="/system/bin/df" commandArgs="-h %1$s" /> | |
69 | + <command commandId="diskusageall" commandPath="/system/bin/df" commandArgs="-h" /> | |
70 | + <command commandId="folderusage" commandPath="/system/bin/ls" commandArgs="-alR %1$s 2> /dev/null" /> | |
71 | 71 | |
72 | 72 | <!-- I/O --> |
73 | 73 | <command commandId="read" commandPath="/system/bin/cat" commandArgs="%1$s" /> |
74 | - <command commandId="touch" commandPath="/system/xbin/echo" commandArgs="-n '' >> %1$s" /> | |
74 | + <command commandId="touch" commandPath="/system/bin/echo" commandArgs="-n '' >> %1$s" /> | |
75 | 75 | <command commandId="write" commandPath="/system/bin/dd" commandArgs="bs=4k of=%1$s" /> |
76 | 76 | |
77 | 77 | <!-- Run --> |
78 | 78 | <command commandId="exec" commandPath="/system/bin/sh" commandArgs="%1$s" /> |
79 | 79 | |
80 | 80 | <!-- Misc --> |
81 | - <command commandId="dirname" commandPath="/system/xbin/dirname" commandArgs="%1$s" /> | |
82 | - <command commandId="echo" commandPath="/system/xbin/echo" commandArgs="%1$s" /> | |
83 | - <command commandId="checksum" commandPath="/system/xbin/md5sum" commandArgs="%1$s && /system/xbin/sha1sum %1$s" /> | |
81 | + <command commandId="dirname" commandPath="/system/bin/dirname" commandArgs="%1$s" /> | |
82 | + <command commandId="echo" commandPath="/system/bin/echo" commandArgs="%1$s" /> | |
83 | + <command commandId="checksum" commandPath="/system/bin/md5sum" commandArgs="%1$s && /system/bin/sha1sum %1$s" /> | |
84 | 84 | |
85 | 85 | <!-- Process control and info --> |
86 | - <command commandId="pid_shell" commandPath="/system/xbin/echo" commandArgs="$$" /> | |
87 | - <command commandId="pid_shell_cmds" commandPath="/system/bin/ps" commandArgs="| /system/xbin/grep -w %1$s | /system/xbin/awk '{print $2}' | /system/xbin/grep -v -w %1$s" /> | |
88 | - <command commandId="pid_cmd" commandPath="/system/bin/ps" commandArgs="| /system/xbin/grep %1$s | /system/xbin/grep -w %2$s | /system/xbin/awk '{print $2}'" /> | |
86 | + <command commandId="pid_shell" commandPath="/system/bin/echo" commandArgs="$$" /> | |
87 | + <command commandId="pid_shell_cmds" commandPath="/system/bin/ps" commandArgs="| /system/bin/grep -w %1$s | /system/bin/cut -c 11-16 | /system/bin/grep -v -w %1$s" /> | |
88 | + <command commandId="pid_cmd" commandPath="/system/bin/ps" commandArgs="| /system/bin/grep %1$s | /system/bin/grep -w %2$s | /system/bin/cut -c 11-16" /> | |
89 | 89 | <command commandId="sendsignal" commandPath="/system/bin/kill" commandArgs="-%1$s %2$s" /> |
90 | 90 | <command commandId="terminate" commandPath="/system/bin/kill" commandArgs="%1$s" /> |
91 | 91 | |
92 | 92 | <!-- Compress --> |
93 | - <command commandId="tar" commandPath="/system/xbin/tar" commandArgs="-C%1$s -%2$scvf %3$s [@]" /> | |
93 | + <command commandId="tar" commandPath="/system/bin/tar" commandArgs="-C%1$s -%2$scvf %3$s [@]" /> | |
94 | 94 | <command commandId="gzip" commandPath="/system/bin/gzip" commandArgs="%1$s" /> |
95 | 95 | <command commandId="bzip" commandPath="/system/xbin/bzip2" commandArgs="-f %1$s" /> |
96 | 96 | <command commandId="zip" commandPath="cd" commandArgs="%1$s && ( /system/xbin/zip -9 -r -y %2$s [@] || cd /)" /> |
97 | 97 | |
98 | 98 | <!-- Uncompress --> |
99 | - <command commandId="untar" commandPath="/system/bin/mkdir" commandArgs="-p %2$s && /system/xbin/tar -C %2$s -%1$sxvf %3$s" /> | |
99 | + <command commandId="untar" commandPath="/system/bin/mkdir" commandArgs="-p %2$s && /system/bin/tar -C %2$s -%1$sxvf %3$s" /> | |
100 | 100 | <command commandId="unzip" commandPath="/system/bin/mkdir" commandArgs="-p %1$s && /system/xbin/unzip -o %2$s -d %1$s" /> |
101 | 101 | <command commandId="gunzip" commandPath="/system/xbin/gunzip" commandArgs="-f %1$s" /> |
102 | - <command commandId="bunzip" commandPath="/system/xbin/bunzip2" commandArgs="-f %1$s" /> | |
102 | + <command commandId="bunzip" commandPath="/system/xbin/bzip2" commandArgs="-d -f %1$s" /> | |
103 | 103 | <command commandId="unlzma" commandPath="/system/xbin/unlzma" commandArgs="-f %1$s" /> |
104 | 104 | <command commandId="uncompress" commandPath="/system/xbin/uncompress" commandArgs="-f %1$s" /> |
105 | 105 | <command commandId="unxz" commandPath="/system/xbin/unxz" commandArgs="-f %1$s" /> |
@@ -254,13 +254,14 @@ public final class ParseHelper { | ||
254 | 254 | */ |
255 | 255 | public static DiskUsage toDiskUsage(final String src) throws ParseException { |
256 | 256 | |
257 | - // Filesystem Size Used Free Blksize | |
258 | - // /dev 414M 48K 414M 4096 | |
259 | - // /mnt/asec 414M 0K 414M 4096 | |
260 | - // /mnt/secure/asec: Permission denied | |
257 | + // Filesystem Size Used Avail Use% Mounted on | |
258 | + // tmpfs 1.3G 88K 1.3G 1% /dev | |
259 | + // tmpfs 1.3G 0 1.3G 0% /mnt | |
260 | + // /dev/block/mmcblk0p14 1.2G 966M 337M 75% /system | |
261 | + // /dev/fuse 55G 18G 37G 34% /storage/emulated | |
261 | 262 | |
262 | 263 | try { |
263 | - final int fields = 5; | |
264 | + final int fields = 6; | |
264 | 265 | |
265 | 266 | //Permission denied or invalid statistics |
266 | 267 | if (src.indexOf(":") != -1) { //$NON-NLS-1$ |
@@ -279,7 +280,7 @@ public final class ParseHelper { | ||
279 | 280 | } |
280 | 281 | |
281 | 282 | //Return the disk usage |
282 | - return new DiskUsage(data[0], toBytes(data[1]), toBytes(data[2]), toBytes(data[3])); | |
283 | + return new DiskUsage(data[5], toBytes(data[1]), toBytes(data[2]), toBytes(data[3])); | |
283 | 284 | |
284 | 285 | } catch (Exception e) { |
285 | 286 | throw new ParseException(e.getMessage(), 0); |
@@ -295,34 +296,38 @@ public final class ParseHelper { | ||
295 | 296 | */ |
296 | 297 | public static MountPoint toMountPoint(final String src) throws ParseException { |
297 | 298 | |
298 | - // rootfs / rootfs ro,relatime 0 0 | |
299 | - // tmpfs /dev tmpfs rw,nosuid,relatime,mode=755 0 0 | |
300 | - // devpts /dev/pts devpts rw,relatime,mode=600 0 0 | |
301 | - // /dev/block/vold/179:25 /mnt/emmc vfat rw,dirsync,nosuid,nodev,noexec,relatime,uid=1000, gid=1015,fmask=0702,dmask=0702,allow_utime=0020,codepage=cp437,iocharset=iso8859-1, shortname=mixed,utf8,errors=remount-ro 0 0 | |
299 | + // rootfs on / type rootfs (ro,seclabel,relatime) | |
300 | + // tmpfs on /dev type tmpfs (rw,seclabel,nosuid,relatime,size=1460476k,nr_inodes=142719,mode=755) | |
301 | + // devpts on /dev/pts type devpts (rw,seclabel,relatime,mode=600) | |
302 | + // /dev/block/mmcblk0p14 on /system type ext4 (rw,seclabel,relatime,data=ordered) | |
302 | 303 | |
303 | 304 | try { |
304 | 305 | |
305 | 306 | //Extract all the info |
306 | 307 | String line = src; |
307 | - int pos = line.lastIndexOf(" "); //$NON-NLS-1$ | |
308 | - int pass = Integer.parseInt(line.substring(pos + 1)); | |
309 | - line = line.substring(0, pos).trim(); | |
310 | - pos = line.lastIndexOf(" "); //$NON-NLS-1$ | |
311 | - int dump = Integer.parseInt(line.substring(pos + 1)); | |
312 | - line = line.substring(0, pos).trim(); | |
313 | - pos = line.indexOf(" "); //$NON-NLS-1$ | |
308 | + // Device | |
309 | + int pos = line.indexOf(" "); //$NON-NLS-1$ | |
314 | 310 | String device = line.substring(0, pos).trim(); |
315 | 311 | line = line.substring(pos).trim(); |
316 | - pos = line.lastIndexOf(" "); //$NON-NLS-1$ | |
317 | - String options = line.substring(pos + 1).trim(); | |
318 | - line = line.substring(0, pos).trim(); | |
319 | - pos = line.lastIndexOf(" "); //$NON-NLS-1$ | |
320 | - String type = line.substring(pos + 1).trim(); | |
312 | + // Skip "on" | |
313 | + pos = line.indexOf(" "); //$NON-NLS-1$ | |
314 | + line = line.substring(pos).trim(); | |
315 | + // Mount point | |
316 | + pos = line.indexOf(" "); //$NON-NLS-1$ | |
321 | 317 | String mountPoint = line.substring(0, pos).trim(); |
322 | - | |
318 | + line = line.substring(pos).trim(); | |
319 | + // Skip "type" | |
320 | + pos = line.indexOf(" "); //$NON-NLS-1$ | |
321 | + line = line.substring(pos).trim(); | |
322 | + // Type | |
323 | + pos = line.indexOf(" "); //$NON-NLS-1$ | |
324 | + String type = line.substring(0, pos).trim(); | |
325 | + line = line.substring(pos).trim(); | |
326 | + // Options | |
327 | + String options = line.substring(1, line.length() - 1).trim(); | |
323 | 328 | |
324 | 329 | //Return the mount point |
325 | - return new MountPoint(mountPoint, device, type, options, dump, pass, false, false); | |
330 | + return new MountPoint(mountPoint, device, type, options, /*dump*/0, /*pass*/0, false, false); | |
326 | 331 | |
327 | 332 | } catch (Exception e) { |
328 | 333 | throw new ParseException(e.getMessage(), 0); |