summaryrefslogtreecommitdiffstats
path: root/light
diff options
context:
space:
mode:
authorSteven Moreland2018-01-22 14:43:34 -0600
committerandroid-build-merger2018-01-22 14:43:34 -0600
commit35535bdd39196f73b3d9913b5219795fd7f97371 (patch)
treed9e396de07ea848a0b7e115912949a0424aa9df7 /light
parent4f3be2e3e9486b90f9e26f0b149b7331194d657f (diff)
parenta2dc32bd294ba9062881d2d2a1dff6c70107a175 (diff)
downloadplatform-hardware-interfaces-35535bdd39196f73b3d9913b5219795fd7f97371.tar.gz
platform-hardware-interfaces-35535bdd39196f73b3d9913b5219795fd7f97371.tar.xz
platform-hardware-interfaces-35535bdd39196f73b3d9913b5219795fd7f97371.zip
Add 'blank_screen' util. am: 64a7afb07e am: 30cb8c1b79
am: a2dc32bd29 Change-Id: I4bf96f1c14cea91a504e2f425aa7281afb08b7f1
Diffstat (limited to 'light')
-rw-r--r--light/utils/Android.bp30
-rw-r--r--light/utils/blank_screen.rc5
-rw-r--r--light/utils/main.cpp52
3 files changed, 87 insertions, 0 deletions
diff --git a/light/utils/Android.bp b/light/utils/Android.bp
new file mode 100644
index 00000000..ebcbfa27
--- /dev/null
+++ b/light/utils/Android.bp
@@ -0,0 +1,30 @@
1//
2// Copyright (C) 2017 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// Turns off the screen.
18// Canonical usage is for init (which can't talk to hals directly).
19cc_binary {
20 name: "blank_screen",
21 init_rc: ["blank_screen.rc"],
22 srcs: ["main.cpp"],
23 shared_libs: [
24 "android.hardware.light@2.0",
25 "libbase",
26 "libhidlbase",
27 "libhidltransport",
28 "libutils",
29 ],
30}
diff --git a/light/utils/blank_screen.rc b/light/utils/blank_screen.rc
new file mode 100644
index 00000000..735551cc
--- /dev/null
+++ b/light/utils/blank_screen.rc
@@ -0,0 +1,5 @@
1service blank_screen /system/bin/blank_screen
2 user system
3 oneshot
4 group system readproc
5 shutdown critical
diff --git a/light/utils/main.cpp b/light/utils/main.cpp
new file mode 100644
index 00000000..1f9cb9ce
--- /dev/null
+++ b/light/utils/main.cpp
@@ -0,0 +1,52 @@
1/*
2 * Copyright (C) 2017 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#include <iostream>
18#include <string>
19
20#include <android-base/logging.h>
21#include <android/hardware/light/2.0/ILight.h>
22
23void error(const std::string& msg) {
24 LOG(ERROR) << msg;
25 std::cerr << msg << std::endl;
26}
27
28int main() {
29 using ::android::hardware::light::V2_0::Brightness;
30 using ::android::hardware::light::V2_0::Flash;
31 using ::android::hardware::light::V2_0::ILight;
32 using ::android::hardware::light::V2_0::LightState;
33 using ::android::hardware::light::V2_0::Status;
34 using ::android::hardware::light::V2_0::Type;
35 using ::android::sp;
36
37 sp<ILight> service = ILight::getService();
38 if (service == nullptr) {
39 error("Could not retrieve light service.");
40 return -1;
41 }
42
43 const static LightState off = {
44 .color = 0u, .flashMode = Flash::NONE, .brightnessMode = Brightness::USER,
45 };
46
47 Status ret = service->setLight(Type::BACKLIGHT, off).withDefault(Status::UNKNOWN);
48 if (ret != Status::SUCCESS) {
49 error("Failed to shut off screen");
50 }
51 return 0;
52}