aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfluxi <linflux@arcor.de>2016-10-29 21:45:27 +0100
committerDavide Garberi <dade.garberi@gmail.com>2018-10-07 15:22:49 +0200
commit0945b3d5e10dfc4ac20ef9d677316e458ec1bdca (patch)
treed91a5bab99fe98781ef57a368342483ce44a90ab
parent49ccf360945d119b2dd5595a8280f0667551ad71 (diff)
msm8996-common: Add pocketmode app
Change-Id: I71e47d5f203adb7e28d37447e19a8041a1d02840 msm8996-common: PocketMode: Apply LineageOS rebrand Change-Id: I1de627062f56bd125f430033e8bb7aad8fe48f69 msm8996-common: pocketmode: Bump sdk version Change-Id: Ic521e380868bdc886e15c6a8a472564a98dbc094 msm8996-common: PocketMode: Explicitly include Android support libs * Fixes non-jack build Change-Id: I9d8346193577c7be218e12efb20f52ca9946eb14 msm8996-common: PocketMode: Properly depend on Lineage SDK * This is actually the proper library to include (only spotted while buidling with Jack disabled, because app compilation was failing). Change-Id: Ib61f93704c6411a4cb1f91d9e8693a1775934037 msm8996-common: PocketMode: Remove useless cast Change-Id: I655b0b80ccafdaae422a2464d2b8409f70be0e8c msm8996-common: Adapt to Zuk Change-Id: I9050faac37de0a8392b31fed5c3562d4553c546f msm8996-common: Set LOCAL_SDK_VERSION where possible. This change sets LOCAL_SDK_VERSION for all packages where this is possible without breaking the build, and LOCAL_PRIVATE_PLATFORM_APIS := true otherwise. Setting one of these two will be made required soon, and this is a change in preparation for that. Not setting LOCAL_SDK_VERSION makes the app implicitly depend on the bootclasspath, which is often not required. This change effectively makes depending on private apis opt-in rather than opt-out. Test: make relevant packages Bug: 73535841 Change-Id: Ic906adbd670c4dbfe2cdf0b71cdbeaf9ac08a27e msm8996-common: sepolicy: Address a fingerprint denial Change-Id: I07c75d58357f7eea2dcc68ed80dacbab76bb30f5 Signed-off-by: Davide Garberi <dade.garberi@gmail.com>
-rwxr-xr-xmsm8996.mk3
-rw-r--r--pocketmode/Android.mk27
-rw-r--r--pocketmode/AndroidManifest.xml41
-rw-r--r--pocketmode/proguard.flags3
-rw-r--r--pocketmode/src/org/lineageos/pocketmode/BootCompletedReceiver.java34
-rw-r--r--pocketmode/src/org/lineageos/pocketmode/PocketModeService.java83
-rw-r--r--pocketmode/src/org/lineageos/pocketmode/ProximitySensor.java69
-rw-r--r--rootdir/etc/init.qcom.rc2
-rw-r--r--sepolicy/file.te1
-rw-r--r--sepolicy/file_contexts1
-rw-r--r--sepolicy/system_app.te3
11 files changed, 265 insertions, 2 deletions
diff --git a/msm8996.mk b/msm8996.mk
index 2041532..94c7763 100755
--- a/msm8996.mk
+++ b/msm8996.mk
@@ -391,7 +391,8 @@ PRODUCT_COPY_FILES += \
# Fingerprint
PRODUCT_PACKAGES += \
- android.hardware.biometrics.fingerprint@2.1-service
+ android.hardware.biometrics.fingerprint@2.1-service \
+ ZukPocketMode
# Thermal
PRODUCT_PACKAGES += \
diff --git a/pocketmode/Android.mk b/pocketmode/Android.mk
new file mode 100644
index 0000000..4919ad4
--- /dev/null
+++ b/pocketmode/Android.mk
@@ -0,0 +1,27 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_PACKAGE_NAME := ZukPocketMode
+LOCAL_CERTIFICATE := platform
+LOCAL_PRIVATE_PLATFORM_APIS := true
+LOCAL_PRIVILEGED_MODULE := true
+
+LOCAL_STATIC_ANDROID_LIBRARIES := \
+ android-support-v4 \
+ android-support-v7-appcompat \
+ android-support-v7-preference \
+ android-support-v7-recyclerview \
+ android-support-v14-preference
+
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ org.lineageos.platform.internal
+
+LOCAL_PROGUARD_FLAG_FILES := proguard.flags
+
+include $(BUILD_PACKAGE)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/pocketmode/AndroidManifest.xml b/pocketmode/AndroidManifest.xml
new file mode 100644
index 0000000..e462eb2
--- /dev/null
+++ b/pocketmode/AndroidManifest.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="org.lineageos.pocketmode"
+ android:versionCode="1"
+ android:versionName="1.1"
+ android:sharedUserId="android.uid.system">
+
+ <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
+
+ <uses-sdk
+ android:minSdkVersion="27"
+ android:targetSdkVersion="27"/>
+
+ <application
+ android:label="ZukPocketMode"
+ android:persistent="true">
+
+ <receiver android:name="org.lineageos.pocketmode.BootCompletedReceiver">
+ <intent-filter>
+ <action android:name="android.intent.action.BOOT_COMPLETED" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ </receiver>
+
+ <service android:name="org.lineageos.pocketmode.PocketModeService"
+ android:permission="ZukPocketModeService">
+ </service>
+
+ <activity android:name="PocketMode"
+ android:label="PocketMode"
+ android:excludeFromRecents="true"
+ android:launchMode="singleInstance"
+ android:screenOrientation="portrait"
+ android:windowAnimationStyle="@null">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ </intent-filter>
+ </activity>
+
+ </application>
+</manifest>
diff --git a/pocketmode/proguard.flags b/pocketmode/proguard.flags
new file mode 100644
index 0000000..2087239
--- /dev/null
+++ b/pocketmode/proguard.flags
@@ -0,0 +1,3 @@
+-keep class org.lineageos.pocketmode.* {
+ *;
+}
diff --git a/pocketmode/src/org/lineageos/pocketmode/BootCompletedReceiver.java b/pocketmode/src/org/lineageos/pocketmode/BootCompletedReceiver.java
new file mode 100644
index 0000000..b967946
--- /dev/null
+++ b/pocketmode/src/org/lineageos/pocketmode/BootCompletedReceiver.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2016 The CyanogenMod Project
+ * Copyright (c) 2018 The LineageOS Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.lineageos.pocketmode;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.util.Log;
+
+public class BootCompletedReceiver extends BroadcastReceiver {
+
+ private static final String TAG = "ZukPocketMode";
+
+ @Override
+ public void onReceive(final Context context, Intent intent) {
+ Log.d(TAG, "Starting");
+ context.startService(new Intent(context, PocketModeService.class));
+ }
+}
diff --git a/pocketmode/src/org/lineageos/pocketmode/PocketModeService.java b/pocketmode/src/org/lineageos/pocketmode/PocketModeService.java
new file mode 100644
index 0000000..42658b9
--- /dev/null
+++ b/pocketmode/src/org/lineageos/pocketmode/PocketModeService.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2016 The CyanogenMod Project
+ * Copyright (c) 2018 The LineageOS Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.lineageos.pocketmode;
+
+import android.app.Service;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.os.IBinder;
+import android.util.Log;
+
+public class PocketModeService extends Service {
+ private static final String TAG = "PocketModeService";
+ private static final boolean DEBUG = false;
+
+ private ProximitySensor mProximitySensor;
+
+ @Override
+ public void onCreate() {
+ if (DEBUG) Log.d(TAG, "Creating service");
+ mProximitySensor = new ProximitySensor(this);
+
+ IntentFilter screenStateFilter = new IntentFilter(Intent.ACTION_SCREEN_ON);
+ screenStateFilter.addAction(Intent.ACTION_SCREEN_OFF);
+ registerReceiver(mScreenStateReceiver, screenStateFilter);
+ }
+
+ @Override
+ public int onStartCommand(Intent intent, int flags, int startId) {
+ if (DEBUG) Log.d(TAG, "Starting service");
+ return START_STICKY;
+ }
+
+ @Override
+ public void onDestroy() {
+ if (DEBUG) Log.d(TAG, "Destroying service");
+ super.onDestroy();
+ this.unregisterReceiver(mScreenStateReceiver);
+ mProximitySensor.disable();
+ }
+
+ @Override
+ public IBinder onBind(Intent intent) {
+ return null;
+ }
+
+ private void onDisplayOn() {
+ if (DEBUG) Log.d(TAG, "Display on");
+ mProximitySensor.disable();
+ }
+
+ private void onDisplayOff() {
+ if (DEBUG) Log.d(TAG, "Display off");
+ mProximitySensor.enable();
+ }
+
+ private BroadcastReceiver mScreenStateReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)) {
+ onDisplayOn();
+ } else if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
+ onDisplayOff();
+ }
+ }
+ };
+}
diff --git a/pocketmode/src/org/lineageos/pocketmode/ProximitySensor.java b/pocketmode/src/org/lineageos/pocketmode/ProximitySensor.java
new file mode 100644
index 0000000..c1af4e8
--- /dev/null
+++ b/pocketmode/src/org/lineageos/pocketmode/ProximitySensor.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2016 The CyanogenMod Project
+ * Copyright (c) 2018 The LineageOS Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.lineageos.pocketmode;
+
+import android.content.Context;
+import android.hardware.Sensor;
+import android.hardware.SensorEvent;
+import android.hardware.SensorEventListener;
+import android.hardware.SensorManager;
+import android.util.Log;
+
+import org.lineageos.internal.util.FileUtils;
+
+public class ProximitySensor implements SensorEventListener {
+
+ private static final boolean DEBUG = false;
+ private static final String TAG = "PocketModeProximity";
+
+ private static final String FPC_FILE = "/sys/devices/soc/soc:fpc1020/proximity_state";
+
+ private SensorManager mSensorManager;
+ private Sensor mSensor;
+ private Context mContext;
+
+ public ProximitySensor(Context context) {
+ mContext = context;
+ mSensorManager = mContext.getSystemService(SensorManager.class);
+ mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
+ }
+
+ @Override
+ public void onSensorChanged(SensorEvent event) {
+ boolean isNear = event.values[0] < mSensor.getMaximumRange();
+ if (FileUtils.isFileWritable(FPC_FILE)) {
+ FileUtils.writeLine(FPC_FILE, isNear ? "1" : "0");
+ }
+ }
+
+ @Override
+ public void onAccuracyChanged(Sensor sensor, int accuracy) {
+ /* Empty */
+ }
+
+ protected void enable() {
+ if (DEBUG) Log.d(TAG, "Enabling");
+ mSensorManager.registerListener(this, mSensor,
+ SensorManager.SENSOR_DELAY_NORMAL);
+ }
+
+ protected void disable() {
+ if (DEBUG) Log.d(TAG, "Disabling");
+ mSensorManager.unregisterListener(this, mSensor);
+ }
+}
diff --git a/rootdir/etc/init.qcom.rc b/rootdir/etc/init.qcom.rc
index f19416a..4d27f96 100644
--- a/rootdir/etc/init.qcom.rc
+++ b/rootdir/etc/init.qcom.rc
@@ -247,6 +247,8 @@ on boot
chmod 0660 /sys/devices/soc/soc:fpc1020/wl
chown system system /sys/devices/soc/soc:fpc1020/screen
chmod 0660 /sys/devices/soc/soc:fpc1020/screen
+ chmod 0660 /sys/devices/soc/soc:fpc1020/proximity_state
+ chown system system /sys/devices/soc/soc:fpc1020/proximity_state
# Access permission for secure touch
chmod 0660 /sys/devices/soc/75ba000.i2c/i2c-12/12-0020/secure_touch_enable
diff --git a/sepolicy/file.te b/sepolicy/file.te
index ee394dd..3fc793f 100644
--- a/sepolicy/file.te
+++ b/sepolicy/file.te
@@ -5,6 +5,7 @@ type thermal_data_file, core_data_file_type, data_file_type, file_type;
type sysfs_camera, sysfs_type, fs_type;
type sysfs_enable_ps_sensor, sysfs_type, fs_type;
type sysfs_fingerprint, sysfs_type, fs_type;
+type sysfs_fpc_proximity, sysfs_type, fs_type;
type sysfs_mdss_mdp_caps, sysfs_type, fs_type;
type sysfs_msm_subsys, sysfs_type, fs_type;
type sysfs_msm_subsys_restart, sysfs_type, fs_type;
diff --git a/sepolicy/file_contexts b/sepolicy/file_contexts
index 90bc67d..3d7167d 100644
--- a/sepolicy/file_contexts
+++ b/sepolicy/file_contexts
@@ -7,6 +7,7 @@
# Devices
/dev/fpc1020 u:object_r:fpc1020_device:s0
/dev/tfa9890 u:object_r:audio_device:s0
+/sys/devices/soc/soc:fpc_fpc1020/proximity_state u:object_r:sysfs_fpc_proximity:s0
# Data files
/data/fpc(/.*)? u:object_r:fpc_data_file:s0
diff --git a/sepolicy/system_app.te b/sepolicy/system_app.te
index 0137c7a..bff7565 100644
--- a/sepolicy/system_app.te
+++ b/sepolicy/system_app.te
@@ -1,4 +1,5 @@
-allow system_app sysfs_fingerprint:file rw_file_perms;
+allow system_app { sysfs_fpc_proximity sysfs_fingerprint }:file rw_file_perms;
+allow system_app sysfs_fingerprint:dir search;
allow system_app shell_prop:property_service set;
binder_call(system_app, wificond);