1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
// Copyright 2012 Google Inc. All Rights Reserved.
package com.skia;
import android.app.IntentService;
import android.content.Intent;
import android.os.Bundle;
import android.os.IBinder;
import android.util.Log;
/**
* @author borenet@google.com (Eric Boren)
*
*/
public class SkiaIntentService extends IntentService {
public SkiaIntentService() {
super("SkiaIntentService");
}
@Override
public IBinder onBind(Intent arg0) {
return null;
}
@Override
public void onCreate() {
super.onCreate();
}
@Override
public void onDestroy() {
super.onDestroy();
}
@Override
public void onHandleIntent(Intent intent) {
// Extract command-line arguments
Bundle bundle = intent.getExtras();
// Number of times to repeat the SkiaReturnCode in the log.
int returnRepeats = bundle.getInt("returnRepeats", 1);
// We require at least the program name to be specified.
if (!bundle.containsKey("args")) {
Log.e("skia",
"No command line arguments supplied. Unable to continue.");
SkiaReturn(-1, returnRepeats);
return;
}
String cmd = bundle.getString("args").trim();
String[] args = cmd.split("\\s+");
Log.d("skia", "Executing Command: " + cmd);
// Load the requested library
String lib = args[0];
try {
System.loadLibrary("skia_android");
System.loadLibrary(lib);
} catch (UnsatisfiedLinkError e) {
Log.e("skia", "Library " + lib +
" could not be linked! Unable to continue.");
SkiaReturn(-1, returnRepeats);
throw e;
}
// JNI call to run the program
int retval = run(args);
SkiaReturn(retval, returnRepeats);
}
/**
* Print out the exit code of the native program. Skia's buildbots watch the
* logcat output for this line. The buildbots occasionally have to restart
* a dead adb process, which causes them to miss some log output (Bug:
* https://code.google.com/p/skia/issues/detail?id=809). If this
* "SKIA_RETURN_CODE" line is missed while adb is being restarted, then the
* test may never finish. Therefore, we print the line as many times as the
* caller specifies, waiting one second in between.
*/
private void SkiaReturn(int code, int repeats) {
Log.d("skia", "SKIA_RETURN_CODE " + code);
for (int i = 1; i < repeats; ++i) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
return;
}
Log.d("skia", "SKIA_RETURN_CODE " + code);
}
}
native int run(String[] args);
}
|