sdm845-common: Import pocketmode app and SELinux rules for it
* Based off android_device_oneplus_msm8998-common pocketmode app but without fpc10xx support and using actual OnePlus pocketmode sensor. Change-Id: I73eaf7e00afd08cdad71d323b6821eb8a0160cd2
This commit is contained in:
parent
ee329ad0bb
commit
4ed29836d8
11 changed files with 259 additions and 0 deletions
|
@ -107,6 +107,10 @@ PRODUCT_PACKAGES += \
|
||||||
Tag \
|
Tag \
|
||||||
com.android.nfc_extras
|
com.android.nfc_extras
|
||||||
|
|
||||||
|
# Pocket mode
|
||||||
|
PRODUCT_PACKAGES += \
|
||||||
|
OnePlusPocketMode
|
||||||
|
|
||||||
# Power
|
# Power
|
||||||
PRODUCT_PACKAGES += \
|
PRODUCT_PACKAGES += \
|
||||||
power.qcom
|
power.qcom
|
||||||
|
|
18
pocketmode/Android.mk
Normal file
18
pocketmode/Android.mk
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
LOCAL_PATH := $(call my-dir)
|
||||||
|
|
||||||
|
include $(CLEAR_VARS)
|
||||||
|
|
||||||
|
LOCAL_MODULE_TAGS := optional
|
||||||
|
|
||||||
|
LOCAL_SRC_FILES := $(call all-java-files-under, src)
|
||||||
|
|
||||||
|
LOCAL_PACKAGE_NAME := OnePlusPocketMode
|
||||||
|
LOCAL_CERTIFICATE := platform
|
||||||
|
LOCAL_PRIVILEGED_MODULE := true
|
||||||
|
|
||||||
|
LOCAL_STATIC_JAVA_LIBRARIES := \
|
||||||
|
org.lineageos.platform.internal
|
||||||
|
|
||||||
|
LOCAL_PROGUARD_FLAG_FILES := proguard.flags
|
||||||
|
|
||||||
|
include $(BUILD_PACKAGE)
|
30
pocketmode/AndroidManifest.xml
Normal file
30
pocketmode/AndroidManifest.xml
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
<?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.0"
|
||||||
|
android:sharedUserId="android.uid.system">
|
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||||
|
|
||||||
|
<uses-sdk
|
||||||
|
android:minSdkVersion="21"
|
||||||
|
android:targetSdkVersion="21"/>
|
||||||
|
|
||||||
|
<application
|
||||||
|
android:label="OnePlusPocketMode"
|
||||||
|
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="OnePlusPocketModeService">
|
||||||
|
</service>
|
||||||
|
|
||||||
|
</application>
|
||||||
|
</manifest>
|
3
pocketmode/proguard.flags
Normal file
3
pocketmode/proguard.flags
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
-keep class org.lineageos.pocketmode.* {
|
||||||
|
*;
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2016 The CyanogenMod 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 = "OnePlusPocketMode";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReceive(final Context context, Intent intent) {
|
||||||
|
Log.d(TAG, "Starting");
|
||||||
|
context.startService(new Intent(context, PocketModeService.class));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,75 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2016 The CyanogenMod 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 PocketSensor mPocketSensor;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate() {
|
||||||
|
if (DEBUG) Log.d(TAG, "Creating service");
|
||||||
|
mPocketSensor = new PocketSensor(this);
|
||||||
|
|
||||||
|
IntentFilter screenStateFilter = new IntentFilter();
|
||||||
|
screenStateFilter.addAction(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");
|
||||||
|
this.unregisterReceiver(mScreenStateReceiver);
|
||||||
|
mPocketSensor.disable();
|
||||||
|
super.onDestroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IBinder onBind(Intent intent) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private BroadcastReceiver mScreenStateReceiver = new BroadcastReceiver() {
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)) {
|
||||||
|
if (DEBUG) Log.d(TAG, "Display on");
|
||||||
|
mPocketSensor.disable();
|
||||||
|
} else if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
|
||||||
|
if (DEBUG) Log.d(TAG, "Display off");
|
||||||
|
mPocketSensor.enable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
89
pocketmode/src/org/lineageos/pocketmode/PocketSensor.java
Normal file
89
pocketmode/src/org/lineageos/pocketmode/PocketSensor.java
Normal file
|
@ -0,0 +1,89 @@
|
||||||
|
/*
|
||||||
|
* 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.text.TextUtils;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import org.lineageos.internal.util.FileUtils;
|
||||||
|
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
|
||||||
|
public class PocketSensor implements SensorEventListener {
|
||||||
|
private static final boolean DEBUG = false;
|
||||||
|
private static final String TAG = "PocketSensor";
|
||||||
|
|
||||||
|
private static final String GOODIX_FILE =
|
||||||
|
"/sys/devices/platform/soc/soc:goodix_fp/proximity_state";
|
||||||
|
|
||||||
|
private ExecutorService mExecutorService;
|
||||||
|
private SensorManager mSensorManager;
|
||||||
|
private Sensor mSensor;
|
||||||
|
private Context mContext;
|
||||||
|
|
||||||
|
public PocketSensor(Context context) {
|
||||||
|
mContext = context;
|
||||||
|
mSensorManager = mContext.getSystemService(SensorManager.class);
|
||||||
|
mExecutorService = Executors.newSingleThreadExecutor();
|
||||||
|
|
||||||
|
for (Sensor sensor : mSensorManager.getSensorList(Sensor.TYPE_ALL)) {
|
||||||
|
if (TextUtils.equals(sensor.getStringType(), "oneplus.sensor.pocket")) {
|
||||||
|
mSensor = sensor;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSensorChanged(SensorEvent event) {
|
||||||
|
setFPProximityState(event.values[0] == 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAccuracyChanged(Sensor sensor, int accuracy) {
|
||||||
|
/* Empty */
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setFPProximityState(boolean isNear) {
|
||||||
|
if (!FileUtils.writeLine(GOODIX_FILE, isNear ? "1" : "0")) {
|
||||||
|
Log.e(TAG, "Proximity state file " + GOODIX_FILE + " is not writable!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void enable() {
|
||||||
|
if (DEBUG) Log.d(TAG, "Enabling");
|
||||||
|
mExecutorService.submit(() -> {
|
||||||
|
mSensorManager.registerListener(this, mSensor, SensorManager.SENSOR_DELAY_NORMAL);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void disable() {
|
||||||
|
if (DEBUG) Log.d(TAG, "Disabling");
|
||||||
|
mExecutorService.submit(() -> {
|
||||||
|
mSensorManager.unregisterListener(this, mSensor);
|
||||||
|
// Ensure FP is left enabled
|
||||||
|
setFPProximityState(/* isNear */ false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,6 +6,9 @@ on init
|
||||||
mount none /system/lib/modules/wlan.ko /vendor/lib/modules/qca_cld3_wlan.ko bind
|
mount none /system/lib/modules/wlan.ko /vendor/lib/modules/qca_cld3_wlan.ko bind
|
||||||
|
|
||||||
on boot
|
on boot
|
||||||
|
# Fingerprint
|
||||||
|
chown system system /sys/devices/platform/soc/soc:goodix_fp/proximity_state
|
||||||
|
|
||||||
# Touchpanel
|
# Touchpanel
|
||||||
chmod 0660 /proc/touchpanel/double_swipe_enable
|
chmod 0660 /proc/touchpanel/double_swipe_enable
|
||||||
chmod 0660 /proc/touchpanel/down_arrow_enable
|
chmod 0660 /proc/touchpanel/down_arrow_enable
|
||||||
|
|
|
@ -5,3 +5,4 @@ type op1_file, file_type;
|
||||||
type op2_file, file_type;
|
type op2_file, file_type;
|
||||||
type persist_file, file_type;
|
type persist_file, file_type;
|
||||||
type proc_touchpanel, fs_type;
|
type proc_touchpanel, fs_type;
|
||||||
|
type sysfs_fpc_proximity, sysfs_type, fs_type;
|
||||||
|
|
|
@ -6,6 +6,9 @@
|
||||||
/op2(/.*)? u:object_r:op2_file:s0
|
/op2(/.*)? u:object_r:op2_file:s0
|
||||||
/persist(/.*)? u:object_r:persist_file:s0
|
/persist(/.*)? u:object_r:persist_file:s0
|
||||||
|
|
||||||
|
# Files in sysfs
|
||||||
|
/sys/devices/platform/soc/soc:goodix_fp/proximity_state u:object_r:sysfs_fpc_proximity:s0
|
||||||
|
|
||||||
# Lights
|
# Lights
|
||||||
/system/bin/hw/android\.hardware\.light@2\.0-service\.oneplus_sdm845 u:object_r:hal_light_sdm845_exec:s0
|
/system/bin/hw/android\.hardware\.light@2\.0-service\.oneplus_sdm845 u:object_r:hal_light_sdm845_exec:s0
|
||||||
|
|
||||||
|
|
1
sepolicy/private/system_app.te
Normal file
1
sepolicy/private/system_app.te
Normal file
|
@ -0,0 +1 @@
|
||||||
|
allow system_app sysfs_fpc_proximity:file w_file_perms;
|
Loading…
Reference in a new issue