21
21
// STL:
22
22
#include < chrono>
23
23
24
+ #if AMDT_BUILD_TARGET == AMDT_LINUX_OS
25
+ #include < unistd.h>
26
+ #endif
27
+
24
28
// / @brief Interval between ADB system queries.
25
29
static constexpr auto gs_ADBMonitorTimerInterval = std::chrono::milliseconds{ 2000 };
26
30
@@ -113,6 +117,21 @@ void LPGPU2ppADBCommandExecutor::OnStartMonitoring()
113
117
m_adbObserverTimerId = startTimer (gs_ADBMonitorTimerInterval.count ());
114
118
}
115
119
120
+ // /@brief TIZEN FIX do not monitor during capture as this leads to high CPU utilization
121
+ void LPGPU2ppADBCommandExecutor::PauseMonitoring ()
122
+ {
123
+ if (m_adbObserverTimerId != -1 )
124
+ {
125
+ killTimer (m_adbObserverTimerId);
126
+ }
127
+ }
128
+
129
+ // /@brief TIZEN FIX resume device status monitoring after capture has finished
130
+ void LPGPU2ppADBCommandExecutor::ResumeMonitoring ()
131
+ {
132
+ m_adbObserverTimerId = startTimer (gs_ADBMonitorTimerInterval.count ());
133
+ }
134
+
116
135
// / @brief Handles request to start ADB as a server.
117
136
// / @warning If ADB is already running this method does nothing.
118
137
void LPGPU2ppADBCommandExecutor::OnStartADB ()
@@ -150,7 +169,19 @@ void LPGPU2ppADBCommandExecutor::OnStartRAgent()
150
169
if (m_bIsADBRunning && m_bIsRAgentInstalled && !m_bIsRAgentRunning)
151
170
{
152
171
gtString output;
153
- if (ExecADBCommand (L" shell am start -W -n agent.remote.lpgpu2.lpgpu2ragent/agent.remote.lpgpu2.lpgpu2ragent.MainActivity -a android.intent.action.MAIN -c android.intent.category.LAUNCHER" , output) == lpgpu2::PPFnStatus::success)
172
+ gtString command;
173
+
174
+ if (!m_bIsTizenTarget)
175
+ {
176
+ command = L" shell am start -W -n agent.remote.lpgpu2.lpgpu2ragent/agent.remote.lpgpu2.lpgpu2ragent.MainActivity"
177
+ " -a android.intent.action.MAIN -c android.intent.category.LAUNCHER" ;
178
+ }
179
+ else
180
+ {
181
+ command = L" shell \" nohup /opt/usr/lpgpu2-remote-agent/start_ragent.sh > /tmp/lpgpu2-remote-agent.log\" " ;
182
+ }
183
+
184
+ if (ExecADBCommand (command, output) == lpgpu2::PPFnStatus::success)
154
185
{
155
186
const auto bIsRAgentRunning = GetRAgentRunningStatus ();
156
187
SetRAgentRunning (bIsRAgentRunning);
@@ -165,7 +196,15 @@ void LPGPU2ppADBCommandExecutor::OnStopRAgent()
165
196
if (m_bIsADBRunning && m_bIsRAgentInstalled && m_bIsRAgentRunning)
166
197
{
167
198
gtString output;
168
- ExecADBCommand (L" shell am force-stop agent.remote.lpgpu2.lpgpu2ragent" , output);
199
+ if (!m_bIsTizenTarget)
200
+ {
201
+ ExecADBCommand (L" shell am force-stop agent.remote.lpgpu2.lpgpu2ragent" , output);
202
+ }
203
+ else
204
+ {
205
+ ExecADBCommand (L" shell /opt/usr/lpgpu2-remote-agent/stop_ragent.sh" , output);
206
+ }
207
+
169
208
const auto bIsRAgentRunning = GetRAgentRunningStatus ();
170
209
SetRAgentRunning (bIsRAgentRunning);
171
210
}
@@ -278,6 +317,26 @@ bool LPGPU2ppADBCommandExecutor::GetADBRunningStatus() const
278
317
#if AMDT_BUILD_TARGET == AMDT_WINDOWS_OS
279
318
return osIsProcessAlive (L" adb.exe" );
280
319
#elif AMDT_BUILD_TARGET == AMDT_LINUX_OS
320
+ // Tizen - use the specified debug bridge if set
321
+ if (!m_ADBPath.isEmpty ())
322
+ {
323
+ gtString adbFilename;
324
+ m_ADBPath.getFileNameAndExtension (adbFilename);
325
+
326
+ // Resolve a symbolic link if necessary
327
+ const char * pPathAsChars = m_ADBPath.asString ().asASCIICharArray ();
328
+ gtString adbFilepath = m_ADBPath.asString ();
329
+ char buf[512 ] = {};
330
+ int count = readlink (pPathAsChars, buf, sizeof (buf));
331
+ if (count > 0 )
332
+ {
333
+ gtString name;
334
+ adbFilename.fromASCIIString (buf);
335
+ }
336
+
337
+ return osIsProcessAlive (adbFilename);
338
+ }
339
+
281
340
return osIsProcessAlive (L" adb" );
282
341
#else
283
342
#error Unsupported OS
@@ -292,9 +351,19 @@ bool LPGPU2ppADBCommandExecutor::GetRAgentInstallationStatus() const
292
351
auto bReturn = false ;
293
352
294
353
gtString output;
295
- if (ExecADBCommand ( L" shell pm list packages | grep package:agent.remote.lpgpu2.lpgpu2ragent " , output) == lpgpu2::PPFnStatus::success )
354
+ if (!m_bIsTizenTarget )
296
355
{
297
- bReturn = output.trim ().compareNoCase (L" package:agent.remote.lpgpu2.lpgpu2ragent" ) == 0 ;
356
+ if (ExecADBCommand (L" shell pm list packages | grep package:agent.remote.lpgpu2.lpgpu2ragent" , output) == lpgpu2::PPFnStatus::success)
357
+ {
358
+ bReturn = output.trim ().compareNoCase (L" package:agent.remote.lpgpu2.lpgpu2ragent" ) == 0 ;
359
+ }
360
+ }
361
+ else
362
+ {
363
+ if (ExecADBCommand (L" shell rpm -qa | grep lpgpu2-remote-agent-0.0.1-01.armv7l" , output) == lpgpu2::PPFnStatus::success)
364
+ {
365
+ bReturn = output.trim ().compareNoCase (L" lpgpu2-remote-agent-0.0.1-01.armv7l" ) == 0 ;
366
+ }
298
367
}
299
368
300
369
return bReturn;
@@ -308,9 +377,19 @@ bool LPGPU2ppADBCommandExecutor::GetRAgentRunningStatus() const
308
377
auto bReturn = false ;
309
378
310
379
gtString output;
311
- if (ExecADBCommand (L" shell ps | grep agent.remote.lpgpu2.lpgpu2ragent" , output) == lpgpu2::PPFnStatus::success)
380
+ if (!m_bIsTizenTarget)
381
+ {
382
+ if (ExecADBCommand (L" shell ps | grep agent.remote.lpgpu2.lpgpu2ragent" , output) == lpgpu2::PPFnStatus::success)
383
+ {
384
+ bReturn = !output.isEmpty ();
385
+ }
386
+ }
387
+ else
312
388
{
313
- bReturn = !output.isEmpty ();
389
+ if (ExecADBCommand (L" shell ps -ef | grep lpgpu2-remote-agent" , output) == lpgpu2::PPFnStatus::success)
390
+ {
391
+ bReturn = !output.isEmpty ();
392
+ }
314
393
}
315
394
316
395
return bReturn;
@@ -361,6 +440,15 @@ gtVector<gtString> LPGPU2ppADBCommandExecutor::GetAttachedDevices() const
361
440
deviceModelCmd += L" shell getprop ro.product.model" ;
362
441
if (ExecADBCommand (deviceModelCmd, output, bNoDevice) == lpgpu2::PPFnStatus::success)
363
442
{
443
+ // Fallback to Tizen
444
+ if (output.find (L" command not found" ))
445
+ {
446
+ deviceModelCmd = L" -s " ;
447
+ deviceModelCmd += deviceName;
448
+ deviceModelCmd += L" shell cat /etc/info.ini | grep Model" ;
449
+ ExecADBCommand (deviceModelCmd, output, bNoDevice);
450
+ }
451
+
364
452
deviceName += L" (" ;
365
453
deviceName += output.trim ();
366
454
deviceName += L" )" ;
@@ -404,6 +492,15 @@ void LPGPU2ppADBCommandExecutor::ValidateADBPath()
404
492
if (line.find (searchText) != -1 )
405
493
{
406
494
line.getSubString (searchText.length () + 1 , line.length (), m_ADBVersion);
495
+ m_bIsTizenTarget = false ;
496
+ }
497
+
498
+ // Tizen support
499
+ searchText = L" Smart Development Bridge version" ;
500
+ if (line.find (searchText) != -1 )
501
+ {
502
+ line.getSubString (searchText.length () + 1 , line.length (), m_ADBVersion);
503
+ m_bIsTizenTarget = true ;
407
504
}
408
505
409
506
searchText = L" Revision" ;
0 commit comments