OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014, the Dart project authors. | 2 * Copyright (c) 2014, the Dart project authors. |
3 * | 3 * |
4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u
se this file except | 4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u
se this file except |
5 * in compliance with the License. You may obtain a copy of the License at | 5 * in compliance with the License. You may obtain a copy of the License at |
6 * | 6 * |
7 * http://www.eclipse.org/legal/epl-v10.html | 7 * http://www.eclipse.org/legal/epl-v10.html |
8 * | 8 * |
9 * Unless required by applicable law or agreed to in writing, software distribut
ed under the License | 9 * Unless required by applicable law or agreed to in writing, software distribut
ed under the License |
10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K
IND, either express | 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K
IND, either express |
11 * or implied. See the License for the specific language governing permissions a
nd limitations under | 11 * or implied. See the License for the specific language governing permissions a
nd limitations under |
12 * the License. | 12 * the License. |
13 */ | 13 */ |
14 package com.google.dart.tools.debug.core.mobile; | 14 package com.google.dart.tools.debug.core.mobile; |
15 | 15 |
16 import com.google.dart.engine.utilities.instrumentation.InstrumentationBuilder; | 16 import com.google.dart.engine.utilities.instrumentation.InstrumentationBuilder; |
17 import com.google.dart.tools.core.mobile.AndroidDebugBridge; | 17 import com.google.dart.tools.core.mobile.AndroidDebugBridge; |
18 import com.google.dart.tools.core.mobile.AndroidDevice; | 18 import com.google.dart.tools.core.mobile.AndroidDevice; |
| 19 import com.google.dart.tools.core.mobile.MobileUrlConnectionException; |
19 import com.google.dart.tools.debug.core.DartDebugCorePlugin; | 20 import com.google.dart.tools.debug.core.DartDebugCorePlugin; |
20 import com.google.dart.tools.debug.core.DartLaunchConfigWrapper; | 21 import com.google.dart.tools.debug.core.DartLaunchConfigWrapper; |
21 import com.google.dart.tools.debug.core.DartLaunchConfigurationDelegate; | 22 import com.google.dart.tools.debug.core.DartLaunchConfigurationDelegate; |
22 import com.google.dart.tools.debug.core.DebugUIHelper; | 23 import com.google.dart.tools.debug.core.DebugUIHelper; |
23 import com.google.dart.tools.debug.core.pubserve.PubCallback; | 24 import com.google.dart.tools.debug.core.pubserve.PubCallback; |
24 import com.google.dart.tools.debug.core.pubserve.PubResult; | 25 import com.google.dart.tools.debug.core.pubserve.PubResult; |
25 import com.google.dart.tools.debug.core.pubserve.PubServeManager; | 26 import com.google.dart.tools.debug.core.pubserve.PubServeManager; |
26 import com.google.dart.tools.debug.core.pubserve.PubServeResourceResolver; | 27 import com.google.dart.tools.debug.core.pubserve.PubServeResourceResolver; |
27 import com.google.dart.tools.debug.core.util.BrowserManager; | 28 import com.google.dart.tools.debug.core.util.BrowserManager; |
28 import com.google.dart.tools.debug.core.util.IRemoteConnectionDelegate; | 29 import com.google.dart.tools.debug.core.util.IRemoteConnectionDelegate; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 if (result.isError()) { | 100 if (result.isError()) { |
100 DebugUIHelper.getHelper().showError( | 101 DebugUIHelper.getHelper().showError( |
101 "Launch Error", | 102 "Launch Error", |
102 "Pub serve communication error: " + result.getErrorMessage()); | 103 "Pub serve communication error: " + result.getErrorMessage()); |
103 return; | 104 return; |
104 } | 105 } |
105 | 106 |
106 try { | 107 try { |
107 String launchUrl = result.getResult(); | 108 String launchUrl = result.getResult(); |
108 launchOnMobile(launchUrl, true, new NullProgressMonitor()); | 109 launchOnMobile(launchUrl, true, new NullProgressMonitor()); |
| 110 } catch (MobileUrlConnectionException e) { |
| 111 // DartDebugCorePlugin.logError(e); |
| 112 DebugUIHelper.getHelper().showError("Dartium Launch Error", e); |
109 } catch (CoreException e) { | 113 } catch (CoreException e) { |
110 DartDebugCorePlugin.logError(e); | 114 DartDebugCorePlugin.logError(e); |
111 DebugUIHelper.getHelper().showError("Dartium Launch Error", e.getMessage
()); | 115 DebugUIHelper.getHelper().showError("Dartium Launch Error", e); |
112 } | 116 } |
113 } | 117 } |
114 | 118 |
115 }; | 119 }; |
116 | 120 |
117 private DartLaunchConfigWrapper wrapper; | 121 private DartLaunchConfigWrapper wrapper; |
118 | 122 |
119 private static final int REMOTE_DEBUG_PORT = 9224; | 123 private static final int REMOTE_DEBUG_PORT = 9224; |
120 | 124 |
121 @Override | 125 @Override |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 DartDebugCorePlugin.PLUGIN_ID, | 227 DartDebugCorePlugin.PLUGIN_ID, |
224 "No devices detected.\n\nConnect device, enable USB debugging and try
again.")); | 228 "No devices detected.\n\nConnect device, enable USB debugging and try
again.")); |
225 } | 229 } |
226 if (device.getDeviceId() == null) { | 230 if (device.getDeviceId() == null) { |
227 throw new CoreException(new Status( | 231 throw new CoreException(new Status( |
228 IStatus.ERROR, | 232 IStatus.ERROR, |
229 DartDebugCorePlugin.PLUGIN_ID, | 233 DartDebugCorePlugin.PLUGIN_ID, |
230 "Unauthorized device detected.\n\nAuthorize device and try again.")); | 234 "Unauthorized device detected.\n\nAuthorize device and try again.")); |
231 } | 235 } |
232 | 236 |
| 237 if (!devBridge.isHtmlPageAccessible(device, launchUrl).isOK()) { |
| 238 // pub serve is always localhost over USB while old dev server is always o
ver wifi |
| 239 boolean localhostOverUsb = usePubServe; |
| 240 throw new MobileUrlConnectionException(launchUrl, localhostOverUsb); |
| 241 } |
| 242 |
233 if (wrapper.getInstallContentShell()) { | 243 if (wrapper.getInstallContentShell()) { |
234 if (!devBridge.installContentShellApk(device.getDeviceId())) { | 244 if (!devBridge.installContentShellApk(device)) { |
235 throw new CoreException(new Status( | 245 throw new CoreException(new Status( |
236 IStatus.ERROR, | 246 IStatus.ERROR, |
237 DartDebugCorePlugin.PLUGIN_ID, | 247 DartDebugCorePlugin.PLUGIN_ID, |
238 "Failed to install content shell on mobile")); | 248 "Failed to install content shell on mobile")); |
239 } | 249 } |
240 } | 250 } |
241 devBridge.launchContentShell(device.getDeviceId(), launchUrl); | 251 devBridge.launchContentShell(device.getDeviceId(), launchUrl); |
242 | 252 |
243 // check if remote connection is alive | 253 // check if remote connection is alive |
244 if (!isRemoteConnected()) { | 254 if (!isRemoteConnected()) { |
245 devBridge.setupPortForwarding(Integer.toString(REMOTE_DEBUG_PORT)); | 255 devBridge.setupPortForwarding(Integer.toString(REMOTE_DEBUG_PORT)); |
246 // TODO(keertip): check if host needs to be the ip for wifi connections | 256 // wait for content shell to open to get the tabs to connect |
| 257 try { |
| 258 Thread.sleep(500); |
| 259 } catch (InterruptedException e) { |
| 260 |
| 261 } |
247 performRemoteConnection("localhost", REMOTE_DEBUG_PORT, monitor, usePubSer
ve); | 262 performRemoteConnection("localhost", REMOTE_DEBUG_PORT, monitor, usePubSer
ve); |
248 } | 263 } |
249 } | 264 } |
250 | 265 |
251 private String getUrlFromResourceServer(IResource resource) throws IOException
, CoreException, | 266 private String getUrlFromResourceServer(IResource resource) throws IOException
, CoreException, |
252 URISyntaxException { | 267 URISyntaxException { |
253 | 268 |
254 ResourceServer server = ResourceServerManager.getServer(); | 269 ResourceServer server = ResourceServerManager.getServer(); |
255 String resPath = resource.getFullPath().toPortableString(); | 270 String resPath = resource.getFullPath().toPortableString(); |
256 String localAddress = server.getLocalAddress(); | 271 String localAddress = server.getLocalAddress(); |
(...skipping 21 matching lines...) Expand all Loading... |
278 return true; | 293 return true; |
279 } | 294 } |
280 } catch (DebugException e) { | 295 } catch (DebugException e) { |
281 | 296 |
282 } | 297 } |
283 } | 298 } |
284 return false; | 299 return false; |
285 } | 300 } |
286 | 301 |
287 } | 302 } |
OLD | NEW |