blob: 65f39639f379d31a47a22724fa58dadf9cdd29ea (
plain)
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
|
package com.android.systemui.statusbar.powerwidget;
import com.android.systemui.R;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.provider.Settings;
import android.os.PowerManager;
import android.os.SystemClock;
public class SleepButton extends PowerButton {
public SleepButton() { mType = BUTTON_SLEEP; }
@Override
protected void updateState(Context context) {
mIcon = R.drawable.stat_sleep;
mState = STATE_DISABLED;
}
@Override
protected void toggleState(Context context) {
PowerManager pm = (PowerManager)
context.getSystemService(Context.POWER_SERVICE);
pm.goToSleep(SystemClock.uptimeMillis() + 1);
}
@Override
protected boolean handleLongClick(Context context) {
Intent intent = new Intent("android.settings.DISPLAY_SETTINGS");
intent.addCategory(Intent.CATEGORY_DEFAULT);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
return true;
}
}
|