diff options
author | Bonyong.lee <bonyong.lee@samsung.com> | 2013-05-23 15:51:44 +0900 |
---|---|---|
committer | Bonyong.lee <bonyong.lee@samsung.com> | 2013-05-23 15:51:44 +0900 |
commit | 8c89e925e2140e333baa50d406bcd24694faf56c (patch) | |
tree | 42a52c62c851598b05d91dfd4cf69d347f054064 /org.tizen.common.sdblib | |
parent | d88c76ac2c6a1734db70e540a4c186ff938f9e29 (diff) | |
download | common-eplugin-8c89e925e2140e333baa50d406bcd24694faf56c.tar.gz common-eplugin-8c89e925e2140e333baa50d406bcd24694faf56c.tar.bz2 common-eplugin-8c89e925e2140e333baa50d406bcd24694faf56c.zip |
[Title] Refactoring sdblib
[Desc.] Move FileEntry to org.tizen.sdblib.service and extract
constants to FileEntryConstants
[Issue]
Diffstat (limited to 'org.tizen.common.sdblib')
4 files changed, 456 insertions, 413 deletions
diff --git a/org.tizen.common.sdblib/src/org/tizen/sdblib/service/FileEntry.java b/org.tizen.common.sdblib/src/org/tizen/sdblib/service/FileEntry.java new file mode 100644 index 000000000..a62c9fc68 --- /dev/null +++ b/org.tizen.common.sdblib/src/org/tizen/sdblib/service/FileEntry.java @@ -0,0 +1,351 @@ +package org.tizen.sdblib.service;
+
+import static org.tizen.sdblib.service.FileEntryConstants.FILE_SEPARATOR;
+import static org.tizen.sdblib.service.FileEntryConstants.PKG_PATTERN;
+import static org.tizen.sdblib.service.FileEntryConstants.REFRESH_TEST;
+import static org.tizen.sdblib.service.FileEntryConstants.TYPE_DIRECTORY;
+import static org.tizen.sdblib.service.FileEntryConstants.TYPE_DIRECTORY_LINK;
+import static org.tizen.sdblib.service.FileEntryConstants.TYPE_ROOT_DEVICE;
+import static org.tizen.sdblib.service.FileEntryConstants.TYPE_ROOT_EMULATOR;
+
+import java.util.ArrayList;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Represents an entry in a directory. This can be a file or a directory.
+ */
+public class FileEntry
+{
+ private static final String FILE_ROOT = "/"; //$NON-NLS-1$
+
+ /** Pattern to escape filenames for shell command consumption. */
+ private final static Pattern sEscapePattern = Pattern.compile("([\\\\\"$])"); //$NON-NLS-1$
+
+ FileEntry parent;
+ String name;
+ String info;
+ String permissions;
+ String size;
+ String date;
+ String time;
+ String owner;
+ String group;
+ String linkPath;
+ FileListingService fileListingService;
+ int type;
+ boolean isAppPackage;
+
+ boolean isRoot;
+
+ /**
+ * Indicates whether the entry content has been fetched yet, or not.
+ */
+ long fetchTime = 0;
+
+ final ArrayList<FileEntry> mChildren = new ArrayList<FileEntry>();
+
+ /**
+ * Creates a new file entry.
+ *
+ * @param parent
+ * parent entry or null if entry is root
+ * @param name
+ * name of the entry.
+ * @param type
+ * entry type. Can be one of the following:
+ * {@link FileListingService#TYPE_FILE},
+ * {@link FileListingService#TYPE_DIRECTORY},
+ * {@link FileListingService#TYPE_OTHER}.
+ */
+ public FileEntry(FileEntry parent, String name, int type, boolean isRoot, FileListingService service)
+ {
+ this.parent = parent;
+ this.name = name;
+ this.type = type;
+ this.isRoot = isRoot;
+ this.fileListingService = service;
+ }
+
+ /**
+ * Returns the name of the entry
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ /**
+ * Returns the size string of the entry, as returned by <code>ls</code>.
+ */
+ public String getSize()
+ {
+ return size;
+ }
+
+ /**
+ * Returns the size of the entry.
+ */
+ public int getSizeValue()
+ {
+ return Integer.parseInt(size);
+ }
+
+ /**
+ * Returns the date string of the entry, as returned by <code>ls</code>.
+ */
+ public String getDate()
+ {
+ return date;
+ }
+
+ /**
+ * Returns the time string of the entry, as returned by <code>ls</code>.
+ */
+ public String getTime()
+ {
+ return time;
+ }
+
+ /**
+ * Returns the permission string of the entry, as returned by
+ * <code>ls</code>.
+ */
+ public String getPermissions()
+ {
+ return permissions;
+ }
+
+ /**
+ * Returns the extra info for the entry.
+ * <p/>
+ * For a link, it will be a description of the link.
+ * <p/>
+ * For an application apk file it will be the application package as
+ * returned by the Package Manager.
+ */
+ public String getInfo()
+ {
+ return info;
+ }
+
+ public String getLinkFullPath()
+ {
+ return linkPath;
+ }
+
+ /**
+ * Return the full path of the entry.
+ *
+ * @return a path string using {@link FileListingService#FILE_SEPARATOR}
+ * as separator.
+ */
+ public String getFullPath()
+ {
+ if (isRoot)
+ {
+ return FILE_ROOT;
+ }
+ StringBuilder pathBuilder = new StringBuilder();
+ fillPathBuilder(pathBuilder, false);
+
+ return pathBuilder.toString();
+ }
+
+ /**
+ * Return the fully escaped path of the entry. This path is safe to use
+ * in a shell command line.
+ *
+ * @return a path string using {@link FileListingService#FILE_SEPARATOR}
+ * as separator
+ */
+ public String getFullEscapedPath()
+ {
+ StringBuilder pathBuilder = new StringBuilder();
+ fillPathBuilder(pathBuilder, true);
+
+ return pathBuilder.toString();
+ }
+
+ /**
+ * Returns the path as a list of segments.
+ */
+ public String[] getPathSegments()
+ {
+ ArrayList<String> list = new ArrayList<String>();
+ fillPathSegments(list);
+
+ return list.toArray(new String[list.size()]);
+ }
+
+ /**
+ * Returns true if the entry is a directory, false otherwise;
+ */
+ public int getType()
+ {
+ return type;
+ }
+
+ public FileListingService getFileListingService()
+ {
+ return fileListingService;
+ }
+
+ /**
+ * Returns if the entry is a folder or a link to a folder.
+ */
+ public boolean isDirectory()
+ {
+ return type == TYPE_DIRECTORY || type == TYPE_DIRECTORY_LINK
+ || type == TYPE_ROOT_DEVICE || type == TYPE_ROOT_EMULATOR ;
+ }
+
+ /**
+ * Returns the parent entry.
+ */
+ public FileEntry getParent()
+ {
+ return parent;
+ }
+
+ /**
+ * Returns the cached children of the entry. This returns the cache
+ * created from calling <code>FileListingService.getChildren()</code>.
+ */
+ public FileEntry[] getCachedChildren()
+ {
+ return mChildren.toArray(new FileEntry[mChildren.size()]);
+ }
+
+ /**
+ * Returns the child {@link FileEntry} matching the name. This uses the
+ * cached children list.
+ *
+ * @param name
+ * the name of the child to return.
+ * @return the FileEntry matching the name or null.
+ */
+ public FileEntry findChild(String name)
+ {
+ for (FileEntry entry : mChildren)
+ {
+ if (entry.name.equals(name))
+ {
+ return entry;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns whether the entry is the root.
+ */
+ public boolean isRoot()
+ {
+ return isRoot;
+ }
+
+ void addChild(FileEntry child)
+ {
+ mChildren.add(child);
+ }
+
+ void setChildren(ArrayList<FileEntry> newChildren)
+ {
+ mChildren.clear();
+ mChildren.addAll(newChildren);
+ }
+
+ boolean needFetch()
+ {
+ if (fetchTime == 0)
+ {
+ return true;
+ }
+ long current = System.currentTimeMillis();
+ if (current - fetchTime > REFRESH_TEST)
+ {
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Returns if the entry is a valid application package.
+ */
+ public boolean isApplicationPackage()
+ {
+ return isAppPackage;
+ }
+
+ /**
+ * Returns if the file name is an application package name.
+ */
+ public boolean isAppFileName()
+ {
+ Matcher m = PKG_PATTERN.matcher(name);
+ return m.matches();
+ }
+
+ /**
+ * Recursively fills the pathBuilder with the full path
+ *
+ * @param pathBuilder
+ * a StringBuilder used to create the path.
+ * @param escapePath
+ * Whether the path need to be escaped for consumption by a
+ * shell command line.
+ */
+ protected void fillPathBuilder(StringBuilder pathBuilder, boolean escapePath)
+ {
+ if (isRoot)
+ {
+ return;
+ }
+
+ if (parent != null)
+ {
+ parent.fillPathBuilder(pathBuilder, escapePath);
+ }
+ pathBuilder.append(FILE_SEPARATOR);
+ pathBuilder.append(escapePath ? escape(name) : name);
+ }
+
+ /**
+ * Recursively fills the segment list with the full path.
+ *
+ * @param list
+ * The list of segments to fill.
+ */
+ protected void fillPathSegments(ArrayList<String> list)
+ {
+ if (isRoot)
+ {
+ return;
+ }
+
+ if (parent != null)
+ {
+ parent.fillPathSegments(list);
+ }
+
+ list.add(name);
+ }
+
+ /**
+ * Returns an escaped version of the entry name.
+ *
+ * @param entryName
+ */
+ private String escape(String entryName)
+ {
+ return sEscapePattern.matcher(entryName).replaceAll("\\\\$1"); //$NON-NLS-1$
+ }
+
+}
diff --git a/org.tizen.common.sdblib/src/org/tizen/sdblib/service/FileEntryConstants.java b/org.tizen.common.sdblib/src/org/tizen/sdblib/service/FileEntryConstants.java new file mode 100644 index 000000000..8afdfeca8 --- /dev/null +++ b/org.tizen.common.sdblib/src/org/tizen/sdblib/service/FileEntryConstants.java @@ -0,0 +1,64 @@ +package org.tizen.sdblib.service;
+
+import java.util.regex.Pattern;
+
+public class FileEntryConstants
+{
+ /** Pattern to find filenames that match "*.tpk" */
+ public final static Pattern PKG_PATTERN = Pattern.compile(".*\\.apk", Pattern.CASE_INSENSITIVE); //$NON-NLS-1$
+
+ public final static String PM_FULL_LISTING = "pm list packages -f"; //$NON-NLS-1$
+
+ /**
+ * Pattern to parse the output of the 'pm -lf' command.<br>
+ * The output format looks like:<br>
+ * /data/app/myapp.apk=com.mypackage.myapp
+ */
+ public final static Pattern sPmPattern = Pattern.compile("^package:(.+?)=(.+)$"); //$NON-NLS-1$
+
+ /** Top level data folder. */
+ public final static String DIRECTORY_DATA = "data"; //$NON-NLS-1$
+ /** Top level sdcard folder. */
+ public final static String DIRECTORY_SDCARD = "sdcard"; //$NON-NLS-1$
+ /** Top level mount folder. */
+ public final static String DIRECTORY_MNT = "mnt"; //$NON-NLS-1$
+ /** Top level system folder. */
+ public final static String DIRECTORY_SYSTEM = "system"; //$NON-NLS-1$
+ /** Top level temp folder. */
+ public final static String DIRECTORY_TEMP = "tmp"; //$NON-NLS-1$
+ /** Application folder. */
+ public final static String DIRECTORY_APP = "app"; //$NON-NLS-1$
+
+ public static final long REFRESH_RATE = 5000L;
+ /**
+ * Refresh test has to be slightly lower for precision issue.
+ */
+ static final long REFRESH_TEST = (long) (REFRESH_RATE * .8);
+
+ /** Entry type: File */
+ public static final int TYPE_FILE = 0;
+ /** Entry type: Directory */
+ public static final int TYPE_DIRECTORY = 1;
+ /** Entry type: Directory Link */
+ public static final int TYPE_DIRECTORY_LINK = 2;
+ /** Entry type: Block */
+ public static final int TYPE_BLOCK = 3;
+ /** Entry type: Character */
+ public static final int TYPE_CHARACTER = 4;
+ /** Entry type: Link */
+ public static final int TYPE_LINK = 5;
+ /** Entry type: Socket */
+ public static final int TYPE_SOCKET = 6;
+ /** Entry type: FIFO */
+ public static final int TYPE_FIFO = 7;
+ /** Entry type: Other */
+ public static final int TYPE_OTHER = 8;
+ /** Entry type: root */
+ public static final int TYPE_ROOT_EMULATOR = 9;
+ public static final int TYPE_ROOT_DEVICE = 10;
+
+ /** Device side file separator. */
+ public static final String FILE_SEPARATOR = "/"; //$NON-NLS-1$
+
+
+}
diff --git a/org.tizen.common.sdblib/src/org/tizen/sdblib/service/FileListingService.java b/org.tizen.common.sdblib/src/org/tizen/sdblib/service/FileListingService.java index c2257fa46..fa1047ebf 100644 --- a/org.tizen.common.sdblib/src/org/tizen/sdblib/service/FileListingService.java +++ b/org.tizen.common.sdblib/src/org/tizen/sdblib/service/FileListingService.java @@ -25,6 +25,21 @@ */ package org.tizen.sdblib.service; +import static org.tizen.sdblib.service.FileEntryConstants.FILE_SEPARATOR; +import static org.tizen.sdblib.service.FileEntryConstants.PM_FULL_LISTING; +import static org.tizen.sdblib.service.FileEntryConstants.TYPE_BLOCK; +import static org.tizen.sdblib.service.FileEntryConstants.TYPE_CHARACTER; +import static org.tizen.sdblib.service.FileEntryConstants.TYPE_DIRECTORY; +import static org.tizen.sdblib.service.FileEntryConstants.TYPE_DIRECTORY_LINK; +import static org.tizen.sdblib.service.FileEntryConstants.TYPE_FIFO; +import static org.tizen.sdblib.service.FileEntryConstants.TYPE_FILE; +import static org.tizen.sdblib.service.FileEntryConstants.TYPE_LINK; +import static org.tizen.sdblib.service.FileEntryConstants.TYPE_OTHER; +import static org.tizen.sdblib.service.FileEntryConstants.TYPE_ROOT_DEVICE; +import static org.tizen.sdblib.service.FileEntryConstants.TYPE_ROOT_EMULATOR; +import static org.tizen.sdblib.service.FileEntryConstants.TYPE_SOCKET; +import static org.tizen.sdblib.service.FileEntryConstants.sPmPattern; + import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -49,64 +64,6 @@ public class FileListingService { - /** Pattern to find filenames that match "*.tpk" */ - private final static Pattern PKG_PATTERN = Pattern.compile(".*\\.apk", Pattern.CASE_INSENSITIVE); //$NON-NLS-1$ - - private final static String PM_FULL_LISTING = "pm list packages -f"; //$NON-NLS-1$ - - /** - * Pattern to parse the output of the 'pm -lf' command.<br> - * The output format looks like:<br> - * /data/app/myapp.apk=com.mypackage.myapp - */ - private final static Pattern sPmPattern = Pattern.compile("^package:(.+?)=(.+)$"); //$NON-NLS-1$ - - /** Top level data folder. */ - public final static String DIRECTORY_DATA = "data"; //$NON-NLS-1$ - /** Top level sdcard folder. */ - public final static String DIRECTORY_SDCARD = "sdcard"; //$NON-NLS-1$ - /** Top level mount folder. */ - public final static String DIRECTORY_MNT = "mnt"; //$NON-NLS-1$ - /** Top level system folder. */ - public final static String DIRECTORY_SYSTEM = "system"; //$NON-NLS-1$ - /** Top level temp folder. */ - public final static String DIRECTORY_TEMP = "tmp"; //$NON-NLS-1$ - /** Application folder. */ - public final static String DIRECTORY_APP = "app"; //$NON-NLS-1$ - - public static final long REFRESH_RATE = 5000L; - /** - * Refresh test has to be slightly lower for precision issue. - */ - static final long REFRESH_TEST = (long) (REFRESH_RATE * .8); - - /** Entry type: File */ - public static final int TYPE_FILE = 0; - /** Entry type: Directory */ - public static final int TYPE_DIRECTORY = 1; - /** Entry type: Directory Link */ - public static final int TYPE_DIRECTORY_LINK = 2; - /** Entry type: Block */ - public static final int TYPE_BLOCK = 3; - /** Entry type: Character */ - public static final int TYPE_CHARACTER = 4; - /** Entry type: Link */ - public static final int TYPE_LINK = 5; - /** Entry type: Socket */ - public static final int TYPE_SOCKET = 6; - /** Entry type: FIFO */ - public static final int TYPE_FIFO = 7; - /** Entry type: Other */ - public static final int TYPE_OTHER = 8; - /** Entry type: root */ - public static final int TYPE_ROOT_EMULATOR = 9; - public static final int TYPE_ROOT_DEVICE = 10; - - /** Device side file separator. */ - public static final String FILE_SEPARATOR = "/"; //$NON-NLS-1$ - - private static final String FILE_ROOT = "/"; //$NON-NLS-1$ - /** * Regexp pattern to parse the result from ls. Do not think the same format * between Emulator and Device such as "ls -l --time-style=long-iso" @@ -136,357 +93,23 @@ FileListingService private final ArrayList<Thread> mThreadList = new ArrayList<Thread>(); /** - * Represents an entry in a directory. This can be a file or a directory. + * Comparator object for FileEntry */ - public final static class FileEntry + private static Comparator<FileEntry> sEntryComparator = new Comparator<FileEntry>() { - /** Pattern to escape filenames for shell command consumption. */ - private final static Pattern sEscapePattern = Pattern.compile("([\\\\\"$])"); //$NON-NLS-1$ - - /** - * Comparator object for FileEntry - */ - private static Comparator<FileEntry> sEntryComparator = new Comparator<FileEntry>() - { - @Override - public int compare(FileEntry o1, FileEntry o2) - { - if (o1 instanceof FileEntry && o2 instanceof FileEntry) - { - FileEntry fe1 = (FileEntry) o1; - FileEntry fe2 = (FileEntry) o2; - return fe1.name.compareTo(fe2.name); - } - return 0; - } - }; - - FileEntry parent; - String name; - String info; - String permissions; - String size; - String date; - String time; - String owner; - String group; - String linkPath; - FileListingService fileListingService; - int type; - boolean isAppPackage; - - boolean isRoot; - - /** - * Indicates whether the entry content has been fetched yet, or not. - */ - long fetchTime = 0; - - final ArrayList<FileEntry> mChildren = new ArrayList<FileEntry>(); - - /** - * Creates a new file entry. - * - * @param parent - * parent entry or null if entry is root - * @param name - * name of the entry. - * @param type - * entry type. Can be one of the following: - * {@link FileListingService#TYPE_FILE}, - * {@link FileListingService#TYPE_DIRECTORY}, - * {@link FileListingService#TYPE_OTHER}. - */ - public FileEntry(FileEntry parent, String name, int type, boolean isRoot, FileListingService service) - { - this.parent = parent; - this.name = name; - this.type = type; - this.isRoot = isRoot; - this.fileListingService = service; - } - - /** - * Returns the name of the entry - */ - public String getName() - { - return name; - } - - public void setName(String name) - { - this.name = name; - } - - /** - * Returns the size string of the entry, as returned by <code>ls</code>. - */ - public String getSize() - { - return size; - } - - /** - * Returns the size of the entry. - */ - public int getSizeValue() - { - return Integer.parseInt(size); - } - - /** - * Returns the date string of the entry, as returned by <code>ls</code>. - */ - public String getDate() - { - return date; - } - - /** - * Returns the time string of the entry, as returned by <code>ls</code>. - */ - public String getTime() - { - return time; - } - - /** - * Returns the permission string of the entry, as returned by - * <code>ls</code>. - */ - public String getPermissions() - { - return permissions; - } - - /** - * Returns the extra info for the entry. - * <p/> - * For a link, it will be a description of the link. - * <p/> - * For an application apk file it will be the application package as - * returned by the Package Manager. - */ - public String getInfo() - { - return info; - } - - public String getLinkFullPath() - { - return linkPath; - } - - /** - * Return the full path of the entry. - * - * @return a path string using {@link FileListingService#FILE_SEPARATOR} - * as separator. - */ - public String getFullPath() - { - if (isRoot) - { - return FILE_ROOT; - } - StringBuilder pathBuilder = new StringBuilder(); - fillPathBuilder(pathBuilder, false); - - return pathBuilder.toString(); - } - - /** - * Return the fully escaped path of the entry. This path is safe to use - * in a shell command line. - * - * @return a path string using {@link FileListingService#FILE_SEPARATOR} - * as separator - */ - public String getFullEscapedPath() - { - StringBuilder pathBuilder = new StringBuilder(); - fillPathBuilder(pathBuilder, true); - - return pathBuilder.toString(); - } - - /** - * Returns the path as a list of segments. - */ - public String[] getPathSegments() - { - ArrayList<String> list = new ArrayList<String>(); - fillPathSegments(list); - - return list.toArray(new String[list.size()]); - } - - /** - * Returns true if the entry is a directory, false otherwise; - */ - public int getType() - { - return type; - } - - public FileListingService getFileListingService() - { - return fileListingService; - } - - /** - * Returns if the entry is a folder or a link to a folder. - */ - public boolean isDirectory() - { - return type == TYPE_DIRECTORY || type == TYPE_DIRECTORY_LINK - || type == TYPE_ROOT_DEVICE || type == TYPE_ROOT_EMULATOR ; - } - - /** - * Returns the parent entry. - */ - public FileEntry getParent() - { - return parent; - } - - /** - * Returns the cached children of the entry. This returns the cache - * created from calling <code>FileListingService.getChildren()</code>. - */ - public FileEntry[] getCachedChildren() - { - return mChildren.toArray(new FileEntry[mChildren.size()]); - } - - /** - * Returns the child {@link FileEntry} matching the name. This uses the - * cached children list. - * - * @param name - * the name of the child to return. - * @return the FileEntry matching the name or null. - */ - public FileEntry findChild(String name) - { - for (FileEntry entry : mChildren) - { - if (entry.name.equals(name)) - { - return entry; - } - } - return null; - } - - /** - * Returns whether the entry is the root. - */ - public boolean isRoot() - { - return isRoot; - } - - void addChild(FileEntry child) - { - mChildren.add(child); - } - - void setChildren(ArrayList<FileEntry> newChildren) - { - mChildren.clear(); - mChildren.addAll(newChildren); - } - - boolean needFetch() - { - if (fetchTime == 0) - { - return true; - } - long current = System.currentTimeMillis(); - if (current - fetchTime > REFRESH_TEST) - { - return true; - } - - return false; - } - - /** - * Returns if the entry is a valid application package. - */ - public boolean isApplicationPackage() - { - return isAppPackage; - } - - /** - * Returns if the file name is an application package name. - */ - public boolean isAppFileName() - { - Matcher m = PKG_PATTERN.matcher(name); - return m.matches(); - } - - /** - * Recursively fills the pathBuilder with the full path - * - * @param pathBuilder - * a StringBuilder used to create the path. - * @param escapePath - * Whether the path need to be escaped for consumption by a - * shell command line. - */ - protected void fillPathBuilder(StringBuilder pathBuilder, boolean escapePath) - { - if (isRoot) - { - return; - } - - if (parent != null) - { - parent.fillPathBuilder(pathBuilder, escapePath); - } - pathBuilder.append(FILE_SEPARATOR); - pathBuilder.append(escapePath ? escape(name) : name); - } - - /** - * Recursively fills the segment list with the full path. - * - * @param list - * The list of segments to fill. - */ - protected void fillPathSegments(ArrayList<String> list) + @Override + public int compare(FileEntry o1, FileEntry o2) { - if (isRoot) - { - return; - } - - if (parent != null) + if (o1 instanceof FileEntry && o2 instanceof FileEntry) { - parent.fillPathSegments(list); + FileEntry fe1 = (FileEntry) o1; + FileEntry fe2 = (FileEntry) o2; + return fe1.name.compareTo(fe2.name); } - - list.add(name); + return 0; } + }; - /** - * Returns an escaped version of the entry name. - * - * @param entryName - */ - private String escape(String entryName) - { - return sEscapePattern.matcher(entryName).replaceAll("\\\\$1"); //$NON-NLS-1$ - } - } private class LsReceiver extends MultiLineReceiver { @@ -781,9 +404,9 @@ FileListingService { if (mRoot == null) { - int deviceType = FileListingService.TYPE_ROOT_DEVICE; + int deviceType = TYPE_ROOT_DEVICE; if (mDevice.isEmulator()) - deviceType = FileListingService.TYPE_ROOT_EMULATOR; + deviceType = TYPE_ROOT_EMULATOR; mRoot = new FileEntry(null, mDevice.getDeviceName(), deviceType, true, this); } @@ -972,7 +595,7 @@ FileListingService // create the command String lsCommand = null; String teeCommand = ""; - if (entry.getType() == FileListingService.TYPE_LINK || entry.getType() == FileListingService.TYPE_DIRECTORY_LINK) + if (entry.getType() == TYPE_LINK || entry.getType() == TYPE_DIRECTORY_LINK) { if (entry.getLinkFullPath().charAt(0) == '/') lsCommand = "ls -l " + getStringWithDoubleQuote(entry.getLinkFullPath()); //$NON-NLS-1$ @@ -1013,7 +636,7 @@ FileListingService entry.fetchTime = System.currentTimeMillis(); // sort the children and set them as the new children - Collections.sort(entryList, FileEntry.sEntryComparator); + Collections.sort(entryList, sEntryComparator); entry.setChildren(entryList); } diff --git a/org.tizen.common.sdblib/src/org/tizen/sdblib/service/SyncService.java b/org.tizen.common.sdblib/src/org/tizen/sdblib/service/SyncService.java index d9fc839b9..91334fa21 100644 --- a/org.tizen.common.sdblib/src/org/tizen/sdblib/service/SyncService.java +++ b/org.tizen.common.sdblib/src/org/tizen/sdblib/service/SyncService.java @@ -16,6 +16,12 @@ package org.tizen.sdblib.service; +import static org.tizen.sdblib.service.FileEntryConstants.TYPE_DIRECTORY; +import static org.tizen.sdblib.service.FileEntryConstants.TYPE_DIRECTORY_LINK; +import static org.tizen.sdblib.service.FileEntryConstants.TYPE_FILE; +import static org.tizen.sdblib.service.FileEntryConstants.TYPE_LINK; +import static org.tizen.sdblib.service.FileEntryConstants.TYPE_ROOT_DEVICE; +import static org.tizen.sdblib.service.FileEntryConstants.TYPE_ROOT_EMULATOR; import static org.tizen.sdblib.util.ObjectUtil.nvl; import java.io.Closeable; @@ -34,7 +40,6 @@ import org.tizen.sdblib.SdbResponse; import org.tizen.sdblib.SmartDevelopmentBridge; import org.tizen.sdblib.exception.SdbCommandRejectedException; import org.tizen.sdblib.exception.TimeoutException; -import org.tizen.sdblib.service.FileListingService.FileEntry; import org.tizen.sdblib.util.ArrayHelper; import org.tizen.sdblib.util.Log; import org.tizen.sdblib.util.Preferences; @@ -610,12 +615,12 @@ public final class SyncService implements Closeable { int count = 0; for (FileEntry e : entries) { int type = e.getType(); - if (type == FileListingService.TYPE_DIRECTORY || type == FileListingService.TYPE_ROOT_DEVICE - || type == FileListingService.TYPE_ROOT_EMULATOR) { + if (type == TYPE_DIRECTORY || type == TYPE_ROOT_DEVICE + || type == TYPE_ROOT_EMULATOR) { // get the children FileEntry[] children = fls.getChildren(e, false, null); count += getTotalRemoteFileSize(children, fls) + 1; - } else if (type == FileListingService.TYPE_FILE) { + } else if (type == TYPE_FILE) { count += e.getSizeValue(); } } @@ -639,12 +644,12 @@ public final class SyncService implements Closeable { throw new InterruptedException("The long running operation was cancelled"); } int type = e.getType(); - if (type == FileListingService.TYPE_DIRECTORY || type == FileListingService.TYPE_ROOT_DEVICE - || type == FileListingService.TYPE_ROOT_EMULATOR | type == FileListingService.TYPE_LINK | type == FileListingService.TYPE_DIRECTORY_LINK) { + if (type == TYPE_DIRECTORY || type == TYPE_ROOT_DEVICE + || type == TYPE_ROOT_EMULATOR | type == TYPE_LINK | type == TYPE_DIRECTORY_LINK) { // get the children FileEntry[] children = fls.getChildren(e, false, null); count += getTotalRemoteFileSizeLong(children, fls, monitor) + 1; - } else if (type == FileListingService.TYPE_FILE) { + } else if (type == TYPE_FILE) { count += e.getSizeValue(); } } |