FileDocCategorySizeDatePackage
ProfilesLoader.javaAPI DocAndroid 1.5 API2537Wed May 06 22:41:10 BST 2009com.android.hierarchyviewer.scene

ProfilesLoader

public class ProfilesLoader extends Object

Fields Summary
Constructors Summary
Methods Summary
public static double[]loadProfiles(com.android.ddmlib.Device device, com.android.hierarchyviewer.device.Window window, java.lang.String params)

        Socket socket = null;
        BufferedReader in = null;
        BufferedWriter out = null;

        try {
            socket = new Socket();
            socket.connect(new InetSocketAddress("127.0.0.1",
                    DeviceBridge.getDeviceLocalPort(device)));

            out = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
            in = new BufferedReader(new InputStreamReader(socket.getInputStream()));

            out.write("PROFILE " + window.encode() + " " + params);
            out.newLine();
            out.flush();

            String response = in.readLine();
            String[] data = response.split(" ");

            double[] profiles = new double[data.length];
            for (int i = 0; i < data.length; i++) {
                profiles[i] = (Long.parseLong(data[i]) / 1000.0) / 1000.0; // convert to ms
            }
            return profiles;
        } catch (IOException e) {
            // Empty
        } finally {
            try {
                if (out != null) {
                    out.close();
                }
                if (in != null) {
                    in.close();
                }
                if (socket != null) {
                    socket.close();
                }
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }

        return null;