Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Android DDMS File Explorer only show 3 directories?

Tags:

android

adb

ddms

Why does Android DDMS File Explorer only show data, mnt, and system directories? There are other directories and files if I execute "adb shell ls -l"

like image 336
user1265015 Avatar asked Nov 05 '22 03:11

user1265015


1 Answers

I did some digging and found that ADT's File Explorer view is restricted by a class named

com.android.ddmlib.FileListingService

Inside of it, you will see a listing of approved top level directories:

/** 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$

private final static String[] sRootLevelApprovedItems = {
    DIRECTORY_DATA,
    DIRECTORY_SDCARD,
    DIRECTORY_SYSTEM,
    DIRECTORY_TEMP,
    DIRECTORY_MNT,
};

Later, this listing is consulted and if it is in the approved list, you will see it in the File Explorer in Eclipse:

            // if the parent is root, we only accept selected items
            if (mParentEntry.isRoot()) {
                boolean found = false;
                for (String approved : sRootLevelApprovedItems) {
                    if (approved.equals(name)) {
                        found = true;
                        break;
                    }
                }

                // if it's not in the approved list we skip this entry.
                if (found == false) {
                    continue;
                }
            }

So, if you wanted to explore the entire contents of the device, you could change the code to approve all top-level directories by removing that entire block of code. Then you'd have to recompile and install your custom ADT plug-in.

Further, when you execute the command:

adb shell ls -l

then you are going into a low-level shell that is like a terminal into your Android device. There's no such filtering at this level.

like image 75
louielouie Avatar answered Nov 10 '22 17:11

louielouie