use of android.os.PowerManager in project android_frameworks_base by DirtyUnicorns.
the class FrameworkPerfActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Set the layout for this activity. You can find it
// in res/layout/hello_activity.xml
setContentView(R.layout.main);
mFgSpinner = (Spinner) findViewById(R.id.fgspinner);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, mAvailOpLabels);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
mFgSpinner.setAdapter(adapter);
mFgSpinner.setOnItemSelectedListener(this);
mBgSpinner = (Spinner) findViewById(R.id.bgspinner);
adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, mAvailOpLabels);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
mBgSpinner.setAdapter(adapter);
mBgSpinner.setOnItemSelectedListener(this);
mLimitSpinner = (Spinner) findViewById(R.id.limitspinner);
adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, mLimitLabels);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
mLimitSpinner.setAdapter(adapter);
mLimitSpinner.setOnItemSelectedListener(this);
mTestTime = (TextView) findViewById(R.id.testtime);
mLimitLabel = (TextView) findViewById(R.id.limitlabel);
mStartButton = (Button) findViewById(R.id.start);
mStartButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startRunning();
}
});
mStopButton = (Button) findViewById(R.id.stop);
mStopButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
stopRunning();
}
});
mStopButton.setEnabled(false);
mLocalCheckBox = (CheckBox) findViewById(R.id.local);
mLog = (TextView) findViewById(R.id.log);
mLog.setTextColor(Color.RED);
PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE);
mPartialWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Scheduler");
mPartialWakeLock.setReferenceCounted(false);
}
use of android.os.PowerManager in project android_frameworks_base by DirtyUnicorns.
the class NetworkStatsServiceTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
mServiceContext = new BroadcastInterceptingContext(getContext());
mStatsDir = getContext().getFilesDir();
if (mStatsDir.exists()) {
IoUtils.deleteContents(mStatsDir);
}
mNetManager = createMock(INetworkManagementService.class);
// TODO: Mock AlarmManager when migrating this test to Mockito.
AlarmManager alarmManager = (AlarmManager) mServiceContext.getSystemService(Context.ALARM_SERVICE);
mTime = createMock(TrustedTime.class);
mSettings = createMock(NetworkStatsSettings.class);
mConnManager = createMock(IConnectivityManager.class);
PowerManager powerManager = (PowerManager) mServiceContext.getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG);
mService = new NetworkStatsService(mServiceContext, mNetManager, alarmManager, wakeLock, mTime, TelephonyManager.getDefault(), mSettings, new NetworkStatsObservers(), mStatsDir, getBaseDir(mStatsDir));
mHandlerThread = new IdleableHandlerThread("HandlerThread");
mHandlerThread.start();
Handler.Callback callback = new NetworkStatsService.HandlerCallback(mService);
mHandler = new Handler(mHandlerThread.getLooper(), callback);
mService.setHandler(mHandler, callback);
mService.bindConnectivityManager(mConnManager);
mElapsedRealtime = 0L;
expectCurrentTime();
expectDefaultSettings();
expectNetworkStatsUidDetail(buildEmptyStats());
expectSystemReady();
// catch INetworkManagementEventObserver during systemReady()
final Capture<INetworkManagementEventObserver> networkObserver = new Capture<INetworkManagementEventObserver>();
mNetManager.registerObserver(capture(networkObserver));
expectLastCall().atLeastOnce();
replay();
mService.systemReady();
mSession = mService.openSession();
verifyAndReset();
mNetworkObserver = networkObserver.getValue();
}
use of android.os.PowerManager in project android_frameworks_base by DirtyUnicorns.
the class SoundTriggerTestActivity method screenWakeup.
private void screenWakeup() {
if (mScreenWakelock == null) {
PowerManager pm = ((PowerManager) getSystemService(POWER_SERVICE));
mScreenWakelock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, TAG);
}
mScreenWakelock.acquire();
}
use of android.os.PowerManager in project android_frameworks_base by DirtyUnicorns.
the class RebootTile method handleLongClick.
@Override
protected void handleLongClick() {
mHost.collapsePanels();
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
public void run() {
PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
pm.reboot(mRebootToRecovery ? "recovery" : "");
}
}, 500);
}
use of android.os.PowerManager in project android_frameworks_base by DirtyUnicorns.
the class FingerprintManager method addLockoutResetCallback.
/**
* @hide
*/
public void addLockoutResetCallback(final LockoutResetCallback callback) {
if (mService != null) {
try {
final PowerManager powerManager = mContext.getSystemService(PowerManager.class);
mService.addLockoutResetCallback(new IFingerprintServiceLockoutResetCallback.Stub() {
@Override
public void onLockoutReset(long deviceId) throws RemoteException {
final PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "lockoutResetCallback");
wakeLock.acquire();
mHandler.post(new Runnable() {
@Override
public void run() {
try {
callback.onLockoutReset();
} finally {
wakeLock.release();
}
}
});
}
});
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
} else {
Log.w(TAG, "addLockoutResetCallback(): Service not connected!");
}
}
Aggregations