2 * Copyright (C) 2009 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package com.android.hierarchyviewer.scene;
19 import com.android.ddmlib.IDevice;
20 import com.android.hierarchyviewer.device.Window;
21 import com.android.hierarchyviewer.device.DeviceBridge;
23 import java.net.Socket;
24 import java.net.InetSocketAddress;
25 import java.io.BufferedWriter;
26 import java.io.OutputStreamWriter;
27 import java.io.IOException;
28 import java.io.BufferedReader;
29 import java.io.InputStreamReader;
31 public class ProfilesLoader {
32 public static double[] loadProfiles(IDevice device, Window window, String params) {
34 BufferedReader in = null;
35 BufferedWriter out = null;
38 socket = new Socket();
39 socket.connect(new InetSocketAddress("127.0.0.1",
40 DeviceBridge.getDeviceLocalPort(device)));
42 out = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
43 in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
45 out.write("PROFILE " + window.encode() + " " + params);
49 String response = in.readLine();
50 String[] data = response.split(" ");
52 double[] profiles = new double[data.length];
53 for (int i = 0; i < data.length; i++) {
54 profiles[i] = (Long.parseLong(data[i]) / 1000.0) / 1000.0; // convert to ms
57 } catch (IOException e) {
70 } catch (IOException ex) {