OSDN Git Service

Handle new sdcard mount point in DDMS.
authorXavier Ducrohet <xav@android.com>
Fri, 12 Mar 2010 22:21:23 +0000 (14:21 -0800)
committerXavier Ducrohet <xav@android.com>
Sat, 13 Mar 2010 00:59:01 +0000 (16:59 -0800)
Bug: 2482010
Change-Id: I68e7f3361bc44251b3767ffe6bcba21e649c4407

ddms/libs/ddmlib/src/com/android/ddmlib/Device.java
ddms/libs/ddmlib/src/com/android/ddmlib/DeviceMonitor.java
ddms/libs/ddmlib/src/com/android/ddmlib/FileListingService.java
ddms/libs/ddmlib/src/com/android/ddmlib/IDevice.java
ddms/libs/ddmlib/tests/src/com/android/ddmlib/testrunner/RemoteAndroidTestRunnerTest.java

index e23d817..8d14d00 100644 (file)
@@ -50,6 +50,7 @@ final class Device implements IDevice {
 
     /** Device properties. */
     private final Map<String, String> mProperties = new HashMap<String, String>();
+    private final Map<String, String> mMountPoints = new HashMap<String, String>();
 
     private final ArrayList<Client> mClients = new ArrayList<Client>();
     private DeviceMonitor mMonitor;
@@ -164,6 +165,10 @@ final class Device implements IDevice {
         return mProperties.get(name);
     }
 
+    public String getMountPoint(String name) {
+        return mMountPoints.get(name);
+    }
+
 
     @Override
     public String toString() {
@@ -418,6 +423,10 @@ final class Device implements IDevice {
         mProperties.put(label, value);
     }
 
+    void setMountingPoint(String name, String value) {
+        mMountPoints.put(name, value);
+    }
+
     /**
      * {@inheritDoc}
      */
index 402699c..0fd0651 100644 (file)
@@ -420,6 +420,10 @@ final class DeviceMonitor {
             device.executeShellCommand(GetPropReceiver.GETPROP_COMMAND,
                     new GetPropReceiver(device));
 
+            queryNewDeviceForMountingPoint(device, IDevice.MNT_EXTERNAL_STORAGE);
+            queryNewDeviceForMountingPoint(device, IDevice.MNT_DATA);
+            queryNewDeviceForMountingPoint(device, IDevice.MNT_ROOT);
+
             // now get the emulator Virtual Device name (if applicable).
             if (device.isEmulator()) {
                 EmulatorConsole console = EmulatorConsole.getConsole(device);
@@ -432,6 +436,25 @@ final class DeviceMonitor {
         }
     }
 
+    private void queryNewDeviceForMountingPoint(final Device device, final String name)
+            throws IOException {
+        device.executeShellCommand("echo $" + name, new MultiLineReceiver() { //$NON-NLS-1$
+            public boolean isCancelled() {
+                return false;
+            }
+
+            @Override
+            public void processNewLines(String[] lines) {
+                for (String line : lines) {
+                    if (line.length() > 0) {
+                        // this should be the only one.
+                        device.setMountingPoint(name, line);
+                    }
+                }
+            }
+        });
+    }
+
     /**
      * Starts a monitoring service for a device.
      * @param device the device to monitor.
index b50cf79..f85d020 100644 (file)
@@ -45,6 +45,8 @@ public final class FileListingService {
     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. */
@@ -56,7 +58,8 @@ public final class FileListingService {
         DIRECTORY_DATA,
         DIRECTORY_SDCARD,
         DIRECTORY_SYSTEM,
-        DIRECTORY_TEMP
+        DIRECTORY_TEMP,
+        DIRECTORY_MNT,
     };
 
     public static final long REFRESH_RATE = 5000L;
@@ -206,7 +209,7 @@ public final class FileListingService {
          * 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.  
+         * by the Package Manager.
          */
         public String getInfo() {
             return info;
index 8096abd..47db08a 100755 (executable)
@@ -45,6 +45,10 @@ public interface IDevice {
     /** @deprecated Use {@link #PROP_BUILD_API_LEVEL}. */
     public final static String PROP_BUILD_VERSION_NUMBER = PROP_BUILD_API_LEVEL;
 
+    public final static String MNT_EXTERNAL_STORAGE = "EXTERNAL_STORAGE"; //$NON-NLS-1$
+    public final static String MNT_ROOT = "ANDROID_ROOT"; //$NON-NLS-1$
+    public final static String MNT_DATA = "ANDROID_DATA"; //$NON-NLS-1$
+
     /**
      * The state of a device.
      */
@@ -111,6 +115,16 @@ public interface IDevice {
     public String getProperty(String name);
 
     /**
+     * Returns a mount point.
+     * @param name the name of the mount point to return
+     *
+     * @see #MNT_EXTERNAL_STORAGE
+     * @see #MNT_ROOT
+     * @see #MNT_DATA
+     */
+    public String getMountPoint(String name);
+
+    /**
      * Returns if the device is ready.
      * @return <code>true</code> if {@link #getState()} returns {@link DeviceState#ONLINE}.
      */
index 29ec9fe..02a6b7d 100644 (file)
@@ -168,6 +168,10 @@ public class RemoteAndroidTestRunnerTest extends TestCase {
             throw new UnsupportedOperationException();
         }
 
+        public String getMountPoint(String name) {
+            throw new UnsupportedOperationException();
+        }
+
         public RawImage getScreenshot() throws IOException {
             throw new UnsupportedOperationException();
         }