blob: 61fecc9b4c7e19eb0e702f55a2e8b9738d6f675d (
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() {
mIcon = R.drawable.stat_sleep;
mState = STATE_DISABLED;
}
@Override
protected void toggleState() {
PowerManager pm = (PowerManager)mView.getContext()
.getSystemService(Context.POWER_SERVICE);
pm.goToSleep(SystemClock.uptimeMillis() + 1);
}
@Override
protected boolean handleLongClick() {
Intent intent = new Intent("android.settings.DISPLAY_SETTINGS");
intent.addCategory(Intent.CATEGORY_DEFAULT);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mView.getContext().startActivity(intent);
return true;
}
}
|