Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(299)

Side by Side Diff: platform_tools/android/app/src/com/skia/SkiaIntentService.java

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

Powered by Google App Engine
This is Rietveld 408576698