blob: 30a968ffd33d92fd284b8e5abe0b5ccd7e03f389 [file] [log] [blame]
Dianne Hackbornd4c4b762011-10-27 12:58:16 -07001/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16
17package com.android.frameworkperf;
18
19import android.app.Activity;
Dianne Hackborn6b57b7e2011-11-07 14:45:49 -080020import android.content.ComponentName;
Dianne Hackbornd4c4b762011-10-27 12:58:16 -070021import android.content.Intent;
Dianne Hackborn6b57b7e2011-11-07 14:45:49 -080022import android.content.ServiceConnection;
Dianne Hackborndd137932011-11-08 10:59:28 -080023import android.os.Binder;
Dianne Hackbornd4c4b762011-10-27 12:58:16 -070024import android.os.Bundle;
25import android.os.Handler;
Dianne Hackborn6b57b7e2011-11-07 14:45:49 -080026import android.os.IBinder;
27import android.os.Message;
28import android.os.Messenger;
Dianne Hackbornd4c4b762011-10-27 12:58:16 -070029import android.os.PowerManager;
Dianne Hackborn6b57b7e2011-11-07 14:45:49 -080030import android.os.RemoteException;
Dianne Hackbornd4c4b762011-10-27 12:58:16 -070031import android.util.Log;
Dianne Hackbornd4c4b762011-10-27 12:58:16 -070032import android.view.View;
33import android.view.WindowManager;
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -070034import android.widget.AdapterView;
35import android.widget.ArrayAdapter;
Dianne Hackborn28695e02011-11-02 21:59:51 -070036import android.widget.Button;
Dianne Hackborn6b57b7e2011-11-07 14:45:49 -080037import android.widget.CheckBox;
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -070038import android.widget.Spinner;
Dianne Hackbornd4c4b762011-10-27 12:58:16 -070039import android.widget.TextView;
40
41import java.util.ArrayList;
42
43/**
44 * So you thought sync used up your battery life.
45 */
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -070046public class FrameworkPerfActivity extends Activity
47 implements AdapterView.OnItemSelectedListener {
Dianne Hackborn2e9562a2011-10-28 17:12:12 -070048 static final String TAG = "Perf";
Dianne Hackborndd137932011-11-08 10:59:28 -080049 static final boolean DEBUG = false;
Dianne Hackborn2e9562a2011-10-28 17:12:12 -070050
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -070051 Spinner mFgSpinner;
52 Spinner mBgSpinner;
Christopher Tate80a682b2011-11-18 17:14:14 -080053 Spinner mLimitSpinner;
54 TextView mLimitLabel;
Dianne Hackborn0500b3c2011-11-01 15:28:43 -070055 TextView mTestTime;
Dianne Hackborn28695e02011-11-02 21:59:51 -070056 Button mStartButton;
57 Button mStopButton;
Dianne Hackborn6b57b7e2011-11-07 14:45:49 -080058 CheckBox mLocalCheckBox;
Dianne Hackborn28695e02011-11-02 21:59:51 -070059 TextView mLog;
Dianne Hackbornd4c4b762011-10-27 12:58:16 -070060 PowerManager.WakeLock mPartialWakeLock;
61
62 long mMaxRunTime = 5000;
Christopher Tate80a682b2011-11-18 17:14:14 -080063 boolean mLimitIsIterations;
Dianne Hackbornd4c4b762011-10-27 12:58:16 -070064 boolean mStarted;
65
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -070066 final String[] mAvailOpLabels;
67 final String[] mAvailOpDescriptions;
Christopher Tate80a682b2011-11-18 17:14:14 -080068 final String[] mLimitLabels = { "Time", "Iterations" };
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -070069
Dianne Hackborn6b57b7e2011-11-07 14:45:49 -080070 int mFgTestIndex = -1;
71 int mBgTestIndex = -1;
72 TestService.Op mFgTest;
73 TestService.Op mBgTest;
Dianne Hackbornd4c4b762011-10-27 12:58:16 -070074 int mCurOpIndex = 0;
Dianne Hackborn6b57b7e2011-11-07 14:45:49 -080075 TestConnection mCurConnection;
Dianne Hackborndd137932011-11-08 10:59:28 -080076 boolean mConnectionBound;
Dianne Hackbornd4c4b762011-10-27 12:58:16 -070077
78 final ArrayList<RunResult> mResults = new ArrayList<RunResult>();
79
Guang Zhu5eefd772011-11-17 14:32:41 -080080 Object mResultNotifier = new Object();
81
Dianne Hackborndd137932011-11-08 10:59:28 -080082 class TestConnection implements ServiceConnection, IBinder.DeathRecipient {
Dianne Hackborn6b57b7e2011-11-07 14:45:49 -080083 Messenger mService;
Dianne Hackborndd137932011-11-08 10:59:28 -080084 boolean mLinked;
Dianne Hackborn6b57b7e2011-11-07 14:45:49 -080085
86 @Override public void onServiceConnected(ComponentName name, IBinder service) {
Dianne Hackborndd137932011-11-08 10:59:28 -080087 try {
88 if (!(service instanceof Binder)) {
89 // If remote, we'll be killing ye.
90 service.linkToDeath(this, 0);
91 mLinked = true;
92 }
93 mService = new Messenger(service);
94 dispatchCurOp(this);
95 } catch (RemoteException e) {
96 // Whoops, service has disappeared... try starting again.
97 Log.w(TAG, "Test service died, starting again");
98 startCurOp();
99 }
Dianne Hackborn6b57b7e2011-11-07 14:45:49 -0800100 }
101
102 @Override public void onServiceDisconnected(ComponentName name) {
103 }
Dianne Hackborndd137932011-11-08 10:59:28 -0800104
105 @Override public void binderDied() {
106 cleanup();
107 connectionDied(this);
108 }
109
110 void cleanup() {
111 if (mLinked) {
112 mLinked = false;
113 mService.getBinder().unlinkToDeath(this, 0);
114 }
115 }
Dianne Hackborn6b57b7e2011-11-07 14:45:49 -0800116 }
117
Dianne Hackborndd137932011-11-08 10:59:28 -0800118 static final int MSG_DO_NEXT_TEST = 1000;
Dianne Hackborn6b57b7e2011-11-07 14:45:49 -0800119
120 final Handler mHandler = new Handler() {
121 @Override public void handleMessage(Message msg) {
122 switch (msg.what) {
123 case TestService.RES_TEST_FINISHED: {
124 Bundle bundle = (Bundle)msg.obj;
125 bundle.setClassLoader(getClassLoader());
126 RunResult res = (RunResult)bundle.getParcelable("res");
127 completeCurOp(res);
128 } break;
Dianne Hackborndd137932011-11-08 10:59:28 -0800129 case MSG_DO_NEXT_TEST: {
Dianne Hackborn6b57b7e2011-11-07 14:45:49 -0800130 startCurOp();
131 } break;
132 }
133 }
134 };
135
136 final Messenger mMessenger = new Messenger(mHandler);
137
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700138 public FrameworkPerfActivity() {
Dianne Hackborn6b57b7e2011-11-07 14:45:49 -0800139 mAvailOpLabels = new String[TestService.mAvailOps.length];
140 mAvailOpDescriptions = new String[TestService.mAvailOps.length];
141 for (int i=0; i<TestService.mAvailOps.length; i++) {
142 TestService.Op op = TestService.mAvailOps[i];
Dianne Hackborn0500b3c2011-11-01 15:28:43 -0700143 if (op == null) {
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700144 mAvailOpLabels[i] = "All";
145 mAvailOpDescriptions[i] = "All tests";
146 } else {
147 mAvailOpLabels[i] = op.getName();
Dianne Hackborn0500b3c2011-11-01 15:28:43 -0700148 if (mAvailOpLabels[i] == null) {
149 mAvailOpLabels[i] = "Nothing";
150 }
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700151 mAvailOpDescriptions[i] = op.getLongName();
152 }
153 }
154 }
155
Dianne Hackbornd4c4b762011-10-27 12:58:16 -0700156 @Override
157 public void onCreate(Bundle savedInstanceState) {
158 super.onCreate(savedInstanceState);
159
160 // Set the layout for this activity. You can find it
161 // in res/layout/hello_activity.xml
162 setContentView(R.layout.main);
163
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700164 mFgSpinner = (Spinner) findViewById(R.id.fgspinner);
165 ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
166 android.R.layout.simple_spinner_item, mAvailOpLabels);
167 adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
168 mFgSpinner.setAdapter(adapter);
169 mFgSpinner.setOnItemSelectedListener(this);
170 mBgSpinner = (Spinner) findViewById(R.id.bgspinner);
171 adapter = new ArrayAdapter<String>(this,
172 android.R.layout.simple_spinner_item, mAvailOpLabels);
173 adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
174 mBgSpinner.setAdapter(adapter);
175 mBgSpinner.setOnItemSelectedListener(this);
Christopher Tate80a682b2011-11-18 17:14:14 -0800176 mLimitSpinner = (Spinner) findViewById(R.id.limitspinner);
177 adapter = new ArrayAdapter<String>(this,
178 android.R.layout.simple_spinner_item, mLimitLabels);
179 adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
180 mLimitSpinner.setAdapter(adapter);
181 mLimitSpinner.setOnItemSelectedListener(this);
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700182
Dianne Hackborn28695e02011-11-02 21:59:51 -0700183 mTestTime = (TextView)findViewById(R.id.testtime);
Christopher Tate80a682b2011-11-18 17:14:14 -0800184 mLimitLabel = (TextView)findViewById(R.id.limitlabel);
Dianne Hackborn28695e02011-11-02 21:59:51 -0700185
186 mStartButton = (Button)findViewById(R.id.start);
187 mStartButton.setOnClickListener(new View.OnClickListener() {
Dianne Hackbornd4c4b762011-10-27 12:58:16 -0700188 @Override public void onClick(View v) {
189 startRunning();
190 }
191 });
Dianne Hackborn28695e02011-11-02 21:59:51 -0700192 mStopButton = (Button)findViewById(R.id.stop);
193 mStopButton.setOnClickListener(new View.OnClickListener() {
Dianne Hackbornd4c4b762011-10-27 12:58:16 -0700194 @Override public void onClick(View v) {
195 stopRunning();
196 }
197 });
Dianne Hackborn28695e02011-11-02 21:59:51 -0700198 mStopButton.setEnabled(false);
Dianne Hackborn6b57b7e2011-11-07 14:45:49 -0800199 mLocalCheckBox = (CheckBox)findViewById(R.id.local);
Dianne Hackborn28695e02011-11-02 21:59:51 -0700200
Dianne Hackbornd4c4b762011-10-27 12:58:16 -0700201 mLog = (TextView)findViewById(R.id.log);
202
203 PowerManager pm = (PowerManager)getSystemService(POWER_SERVICE);
204 mPartialWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Scheduler");
205 mPartialWakeLock.setReferenceCounted(false);
206 }
207
208 @Override
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700209 public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
Christopher Tate80a682b2011-11-18 17:14:14 -0800210 if (parent == mFgSpinner || parent == mBgSpinner || parent == mLimitSpinner) {
Dianne Hackborn6b57b7e2011-11-07 14:45:49 -0800211 TestService.Op op = TestService.mAvailOps[position];
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700212 if (parent == mFgSpinner) {
Dianne Hackborn6b57b7e2011-11-07 14:45:49 -0800213 mFgTestIndex = position;
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700214 mFgTest = op;
215 ((TextView)findViewById(R.id.fgtext)).setText(mAvailOpDescriptions[position]);
Christopher Tate80a682b2011-11-18 17:14:14 -0800216 } else if (parent == mBgSpinner) {
Dianne Hackborn6b57b7e2011-11-07 14:45:49 -0800217 mBgTestIndex = position;
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700218 mBgTest = op;
219 ((TextView)findViewById(R.id.bgtext)).setText(mAvailOpDescriptions[position]);
Christopher Tate80a682b2011-11-18 17:14:14 -0800220 } else if (parent == mLimitSpinner) {
221 mLimitIsIterations = (position != 0);
222 if (mLimitIsIterations) {
223 mLimitLabel.setText("Iterations: ");
224 } else {
225 mLimitLabel.setText("Test time (ms): ");
226 }
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700227 }
228 }
229 }
230
231 @Override
232 public void onNothingSelected(AdapterView<?> parent) {
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700233 }
234
235 @Override
Dianne Hackbornd4c4b762011-10-27 12:58:16 -0700236 public void onResume() {
237 super.onResume();
238 }
239
240 @Override
241 public void onDestroy() {
242 super.onDestroy();
243 stopRunning();
244 if (mPartialWakeLock.isHeld()) {
245 mPartialWakeLock.release();
246 }
247 }
248
Dianne Hackborn6b57b7e2011-11-07 14:45:49 -0800249 void dispatchCurOp(TestConnection conn) {
250 if (mCurConnection != conn) {
251 Log.w(TAG, "Dispatching on invalid connection: " + conn);
252 return;
253 }
254 TestArgs args = new TestArgs();
Christopher Tate80a682b2011-11-18 17:14:14 -0800255 if (mLimitIsIterations) {
256 args.maxOps = mMaxRunTime;
257 } else {
258 args.maxTime = mMaxRunTime;
259 }
Dianne Hackborn6b57b7e2011-11-07 14:45:49 -0800260 if (mFgTestIndex == 0 && mBgTestIndex == 0) {
261 args.combOp = mCurOpIndex;
262 } else if (mFgTestIndex != 0 && mBgTestIndex != 0) {
263 args.fgOp = mFgTestIndex;
264 args.bgOp = mBgTestIndex;
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700265 } else {
Dianne Hackborn28695e02011-11-02 21:59:51 -0700266 // Skip null test.
267 if (mCurOpIndex == 0) {
268 mCurOpIndex = 1;
269 }
Dianne Hackborn6b57b7e2011-11-07 14:45:49 -0800270 if (mFgTestIndex != 0) {
271 args.fgOp = mFgTestIndex;
272 args.bgOp = mCurOpIndex;
273 } else {
274 args.fgOp = mCurOpIndex;
275 args.bgOp = mFgTestIndex;
Dianne Hackbornd4c4b762011-10-27 12:58:16 -0700276 }
Dianne Hackborn6b57b7e2011-11-07 14:45:49 -0800277 }
278 Bundle bundle = new Bundle();
279 bundle.putParcelable("args", args);
280 Message msg = Message.obtain(null, TestService.CMD_START_TEST, bundle);
281 msg.replyTo = mMessenger;
282 try {
283 conn.mService.send(msg);
284 } catch (RemoteException e) {
Dianne Hackborndd137932011-11-08 10:59:28 -0800285 Log.w(TAG, "Failure communicating with service", e);
Dianne Hackborn6b57b7e2011-11-07 14:45:49 -0800286 }
287 }
288
289 void completeCurOp(RunResult result) {
290 log(String.format("%s: fg=%d*%gms/op (%dms) / bg=%d*%gms/op (%dms)",
291 result.name, result.fgOps, result.getFgMsPerOp(), result.fgTime,
292 result.bgOps, result.getBgMsPerOp(), result.bgTime));
Guang Zhu5eefd772011-11-17 14:32:41 -0800293 synchronized (mResults) {
294 mResults.add(result);
295 }
Dianne Hackborn6b57b7e2011-11-07 14:45:49 -0800296 if (!mStarted) {
297 log("Stop");
298 stopRunning();
299 return;
300 }
301 if (mFgTest != null && mBgTest != null) {
302 log("Finished");
303 stopRunning();
304 return;
305 }
306 if (mFgTest == null && mBgTest == null) {
307 mCurOpIndex+=2;
308 if (mCurOpIndex >= TestService.mOpPairs.length) {
309 log("Finished");
310 stopRunning();
311 return;
312 }
313 } else {
314 mCurOpIndex++;
315 if (mCurOpIndex >= TestService.mAvailOps.length) {
316 log("Finished");
317 stopRunning();
318 return;
319 }
320 }
321 startCurOp();
322 }
323
324 void disconnect() {
Dianne Hackborndd137932011-11-08 10:59:28 -0800325 final TestConnection conn = mCurConnection;
326 if (conn != null) {
327 if (DEBUG) {
328 RuntimeException here = new RuntimeException("here");
329 here.fillInStackTrace();
330 Log.i(TAG, "Unbinding " + conn, here);
331 }
332 if (mConnectionBound) {
333 unbindService(conn);
334 mConnectionBound = false;
335 }
336 if (conn.mLinked) {
Dianne Hackborn6b57b7e2011-11-07 14:45:49 -0800337 Message msg = Message.obtain(null, TestService.CMD_TERMINATE);
Dianne Hackborn6b57b7e2011-11-07 14:45:49 -0800338 try {
Dianne Hackborndd137932011-11-08 10:59:28 -0800339 conn.mService.send(msg);
340 return;
Dianne Hackborn6b57b7e2011-11-07 14:45:49 -0800341 } catch (RemoteException e) {
Dianne Hackborndd137932011-11-08 10:59:28 -0800342 Log.w(TAG, "Test service aleady died when terminating");
Dianne Hackborn6b57b7e2011-11-07 14:45:49 -0800343 }
344 }
Dianne Hackborndd137932011-11-08 10:59:28 -0800345 conn.cleanup();
346 }
347 connectionDied(conn);
348 }
349
350 void connectionDied(TestConnection conn) {
351 if (mCurConnection == conn) {
352 // Now that we know the test process has died, we can commence
353 // the next test. Just give a little delay to allow the activity
354 // manager to know it has died as well (not a disaster if it hasn't
355 // yet, though).
356 if (mConnectionBound) {
357 unbindService(conn);
358 }
Dianne Hackborn6b57b7e2011-11-07 14:45:49 -0800359 mCurConnection = null;
Dianne Hackborndd137932011-11-08 10:59:28 -0800360 mHandler.sendMessageDelayed(Message.obtain(null, MSG_DO_NEXT_TEST), 100);
Dianne Hackborn6b57b7e2011-11-07 14:45:49 -0800361 }
362 }
363
364 void startCurOp() {
Dianne Hackborndd137932011-11-08 10:59:28 -0800365 if (DEBUG) Log.i(TAG, "startCurOp: mCurConnection=" + mCurConnection);
Dianne Hackborn6b57b7e2011-11-07 14:45:49 -0800366 if (mCurConnection != null) {
367 disconnect();
Dianne Hackborndd137932011-11-08 10:59:28 -0800368 return;
Dianne Hackborn6b57b7e2011-11-07 14:45:49 -0800369 }
370 if (mStarted) {
371 mHandler.removeMessages(TestService.RES_TEST_FINISHED);
372 mHandler.removeMessages(TestService.RES_TERMINATED);
Dianne Hackborndd137932011-11-08 10:59:28 -0800373 mHandler.removeMessages(MSG_DO_NEXT_TEST);
Dianne Hackborn6b57b7e2011-11-07 14:45:49 -0800374 mCurConnection = new TestConnection();
375 Intent intent;
376 if (mLocalCheckBox.isChecked()) {
377 intent = new Intent(this, LocalTestService.class);
378 } else {
379 intent = new Intent(this, TestService.class);
380 }
Dianne Hackborndd137932011-11-08 10:59:28 -0800381 if (DEBUG) {
382 RuntimeException here = new RuntimeException("here");
383 here.fillInStackTrace();
384 Log.i(TAG, "Binding " + mCurConnection, here);
385 }
Dianne Hackborn6b57b7e2011-11-07 14:45:49 -0800386 bindService(intent, mCurConnection, BIND_AUTO_CREATE|BIND_IMPORTANT);
Dianne Hackborndd137932011-11-08 10:59:28 -0800387 mConnectionBound = true;
Dianne Hackborn6b57b7e2011-11-07 14:45:49 -0800388 }
Dianne Hackbornd4c4b762011-10-27 12:58:16 -0700389 }
390
391 void startRunning() {
392 if (!mStarted) {
393 log("Start");
394 mStarted = true;
Dianne Hackborn28695e02011-11-02 21:59:51 -0700395 mStartButton.setEnabled(false);
396 mStopButton.setEnabled(true);
Dianne Hackborn6b57b7e2011-11-07 14:45:49 -0800397 mLocalCheckBox.setEnabled(false);
Dianne Hackborn28695e02011-11-02 21:59:51 -0700398 mTestTime.setEnabled(false);
399 mFgSpinner.setEnabled(false);
400 mBgSpinner.setEnabled(false);
Christopher Tate80a682b2011-11-18 17:14:14 -0800401 mLimitSpinner.setEnabled(false);
Dianne Hackbornd4c4b762011-10-27 12:58:16 -0700402 updateWakeLock();
403 startService(new Intent(this, SchedulerService.class));
404 mCurOpIndex = 0;
Dianne Hackborn0500b3c2011-11-01 15:28:43 -0700405 mMaxRunTime = Integer.parseInt(mTestTime.getText().toString());
Guang Zhu5eefd772011-11-17 14:32:41 -0800406 synchronized (mResults) {
407 mResults.clear();
408 }
Dianne Hackbornd4c4b762011-10-27 12:58:16 -0700409 startCurOp();
410 }
411 }
412
413 void stopRunning() {
414 if (mStarted) {
Dianne Hackborn6b57b7e2011-11-07 14:45:49 -0800415 disconnect();
Dianne Hackbornd4c4b762011-10-27 12:58:16 -0700416 mStarted = false;
Dianne Hackborn28695e02011-11-02 21:59:51 -0700417 mStartButton.setEnabled(true);
418 mStopButton.setEnabled(false);
Dianne Hackborn6b57b7e2011-11-07 14:45:49 -0800419 mLocalCheckBox.setEnabled(true);
Dianne Hackborn28695e02011-11-02 21:59:51 -0700420 mTestTime.setEnabled(true);
421 mFgSpinner.setEnabled(true);
422 mBgSpinner.setEnabled(true);
Christopher Tate80a682b2011-11-18 17:14:14 -0800423 mLimitSpinner.setEnabled(true);
Dianne Hackbornd4c4b762011-10-27 12:58:16 -0700424 updateWakeLock();
425 stopService(new Intent(this, SchedulerService.class));
Guang Zhu5eefd772011-11-17 14:32:41 -0800426 synchronized (mResults) {
427 for (int i=0; i<mResults.size(); i++) {
428 RunResult result = mResults.get(i);
429 float fgMsPerOp = result.getFgMsPerOp();
430 float bgMsPerOp = result.getBgMsPerOp();
431 String fgMsPerOpStr = fgMsPerOp != 0 ? Float.toString(fgMsPerOp) : "";
432 String bgMsPerOpStr = bgMsPerOp != 0 ? Float.toString(bgMsPerOp) : "";
433 Log.i("PerfRes", "\t" + result.name + "\t" + result.fgOps
434 + "\t" + result.getFgMsPerOp() + "\t" + result.fgTime
435 + "\t" + result.fgLongName + "\t" + result.bgOps
436 + "\t" + result.getBgMsPerOp() + "\t" + result.bgTime
437 + "\t" + result.bgLongName);
438 }
439 }
440 synchronized (mResultNotifier) {
441 mResultNotifier.notifyAll();
Dianne Hackbornd4c4b762011-10-27 12:58:16 -0700442 }
443 }
444 }
445
446 void updateWakeLock() {
447 if (mStarted) {
448 getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
449 if (!mPartialWakeLock.isHeld()) {
450 mPartialWakeLock.acquire();
451 }
452 } else {
453 getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
454 if (mPartialWakeLock.isHeld()) {
455 mPartialWakeLock.release();
456 }
457 }
458 }
459
460 void log(String s) {
461 mLog.setText(mLog.getText() + "\n" + s);
Dianne Hackborn2e9562a2011-10-28 17:12:12 -0700462 Log.i(TAG, s);
Dianne Hackbornd4c4b762011-10-27 12:58:16 -0700463 }
Dianne Hackbornd4c4b762011-10-27 12:58:16 -0700464}