1 /* 2 * Copyright (C) 2015 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 17 package com.android.benchmark.synthetic; 18 19 import android.app.Activity; 20 import android.content.Intent; 21 import android.os.Bundle; 22 import android.view.Menu; 23 import android.view.MenuItem; 24 import android.view.View; 25 import android.view.WindowManager; 26 import android.widget.TextView; 27 28 import com.android.benchmark.R; 29 import com.android.benchmark.app.PerfTimeline; 30 31 import junit.framework.Test; 32 33 34 public class MemoryActivity extends Activity { 35 private TextView mTextStatus; 36 private TextView mTextMin; 37 private TextView mTextMax; 38 private TextView mTextTypical; 39 private PerfTimeline mTimeline; 40 41 TestInterface mTI; 42 int mActiveTest; 43 44 private class SyntheticTestCallback extends TestInterface.TestResultCallback { 45 @Override 46 void onTestResult(int command, float result) { 47 Intent resultIntent = new Intent(); 48 resultIntent.putExtra("com.android.benchmark.synthetic.TEST_RESULT", result); 49 setResult(RESULT_OK, resultIntent); 50 finish(); 51 } 52 } 53 54 @Override 55 protected void onCreate(Bundle savedInstanceState) { 56 super.onCreate(savedInstanceState); 57 setContentView(R.layout.activity_memory); 58 59 mTextStatus = (TextView) findViewById(R.id.textView_status); 60 mTextMin = (TextView) findViewById(R.id.textView_min); 61 mTextMax = (TextView) findViewById(R.id.textView_max); 62 mTextTypical = (TextView) findViewById(R.id.textView_typical); 63 64 mTimeline = (PerfTimeline) findViewById(R.id.mem_timeline); 65 66 mTI = new TestInterface(mTimeline, 2, new SyntheticTestCallback()); 67 mTI.mTextMax = mTextMax; 68 mTI.mTextMin = mTextMin; 69 mTI.mTextStatus = mTextStatus; 70 mTI.mTextTypical = mTextTypical; 71 72 mTimeline.mLinesLow = mTI.mLinesLow; 73 mTimeline.mLinesHigh = mTI.mLinesHigh; 74 mTimeline.mLinesValue = mTI.mLinesValue; 75 76 getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); 77 } 78 79 @Override 80 protected void onResume() { 81 super.onResume(); 82 Intent i = getIntent(); 83 mActiveTest = i.getIntExtra("test", 0); 84 85 switch (mActiveTest) { 86 case 0: 87 mTI.runMemoryBandwidth(); 88 break; 89 case 1: 90 mTI.runMemoryLatency(); 91 break; 92 case 2: 93 mTI.runPowerManagement(); 94 break; 95 case 3: 96 mTI.runCPUHeatSoak(); 97 break; 98 case 4: 99 mTI.runCPUGFlops(); 100 break; 101 default: 102 break; 103 104 } 105 } 106 107 @Override 108 public boolean onCreateOptionsMenu(Menu menu) { 109 // Inflate the menu; this adds items to the action bar if it is present. 110 getMenuInflater().inflate(R.menu.menu_memory, menu); 111 return true; 112 } 113 114 @Override 115 public boolean onOptionsItemSelected(MenuItem item) { 116 // Handle action bar item clicks here. The action bar will 117 // automatically handle clicks on the Home/Up button, so long 118 // as you specify a parent activity in AndroidManifest.xml. 119 int id = item.getItemId(); 120 121 //noinspection SimplifiableIfStatement 122 if (id == R.id.action_settings) { 123 return true; 124 } 125 126 return super.onOptionsItemSelected(item); 127 } 128 129 public void onCpuBandwidth(View v) { 130 131 132 } 133 134 135 136 137 } 138