From cdff2c54472018989989220c16bbe00e50e0764c Mon Sep 17 00:00:00 2001 From: LuK1337 Date: Tue, 23 Jun 2020 13:04:47 +0200 Subject: [PATCH] sm8250-common: Nuke pocketmode app --- pocketmode/Android.mk | 16 ---- pocketmode/AndroidManifest.xml | 30 ------ pocketmode/proguard.flags | 3 - .../pocketmode/BootCompletedReceiver.java | 32 ------- .../pocketmode/PocketModeService.java | 75 --------------- .../lineageos/pocketmode/PocketSensor.java | 91 ------------------- sepolicy/private/pocketmode_app.te | 13 --- sepolicy/private/seapp_contexts | 1 - 8 files changed, 261 deletions(-) delete mode 100644 pocketmode/Android.mk delete mode 100644 pocketmode/AndroidManifest.xml delete mode 100644 pocketmode/proguard.flags delete mode 100644 pocketmode/src/org/lineageos/pocketmode/BootCompletedReceiver.java delete mode 100644 pocketmode/src/org/lineageos/pocketmode/PocketModeService.java delete mode 100644 pocketmode/src/org/lineageos/pocketmode/PocketSensor.java delete mode 100644 sepolicy/private/pocketmode_app.te delete mode 100644 sepolicy/private/seapp_contexts diff --git a/pocketmode/Android.mk b/pocketmode/Android.mk deleted file mode 100644 index 61bf601..0000000 --- a/pocketmode/Android.mk +++ /dev/null @@ -1,16 +0,0 @@ -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_PRIVATE_PLATFORM_APIS := true -LOCAL_PRIVILEGED_MODULE := true - -LOCAL_PROGUARD_FLAG_FILES := proguard.flags - -include $(BUILD_PACKAGE) diff --git a/pocketmode/AndroidManifest.xml b/pocketmode/AndroidManifest.xml deleted file mode 100644 index 9fdf751..0000000 --- a/pocketmode/AndroidManifest.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/pocketmode/proguard.flags b/pocketmode/proguard.flags deleted file mode 100644 index 2087239..0000000 --- a/pocketmode/proguard.flags +++ /dev/null @@ -1,3 +0,0 @@ --keep class org.lineageos.pocketmode.* { - *; -} diff --git a/pocketmode/src/org/lineageos/pocketmode/BootCompletedReceiver.java b/pocketmode/src/org/lineageos/pocketmode/BootCompletedReceiver.java deleted file mode 100644 index 2ce11b9..0000000 --- a/pocketmode/src/org/lineageos/pocketmode/BootCompletedReceiver.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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)); - } -} diff --git a/pocketmode/src/org/lineageos/pocketmode/PocketModeService.java b/pocketmode/src/org/lineageos/pocketmode/PocketModeService.java deleted file mode 100644 index 2b8002a..0000000 --- a/pocketmode/src/org/lineageos/pocketmode/PocketModeService.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * 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(); - } - } - }; -} diff --git a/pocketmode/src/org/lineageos/pocketmode/PocketSensor.java b/pocketmode/src/org/lineageos/pocketmode/PocketSensor.java deleted file mode 100644 index 1905767..0000000 --- a/pocketmode/src/org/lineageos/pocketmode/PocketSensor.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * 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.os.FileUtils; -import android.text.TextUtils; -import android.util.Log; - -import java.io.IOException; -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) { - try { - FileUtils.stringToFile(GOODIX_FILE, isNear ? "1" : "0"); - } catch (IOException e) { - Log.e(TAG, "Failed to write to " + GOODIX_FILE, e); - } - } - - 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); - }); - } -} diff --git a/sepolicy/private/pocketmode_app.te b/sepolicy/private/pocketmode_app.te deleted file mode 100644 index cf6aa80..0000000 --- a/sepolicy/private/pocketmode_app.te +++ /dev/null @@ -1,13 +0,0 @@ -type pocketmode_app, domain; - -app_domain(pocketmode_app) - -# Allow pocketmode_app to find app_api_service -allow pocketmode_app app_api_service:service_manager find; - -# Allow pocketmode_app read and write /data/data subdirectory -allow pocketmode_app system_app_data_file:dir create_dir_perms; -allow pocketmode_app system_app_data_file:{ file lnk_file } create_file_perms; - -# Allow pocketmode_app to write to sysfs_fpc_proximity -allow pocketmode_app sysfs_fpc_proximity:file { w_file_perms getattr }; diff --git a/sepolicy/private/seapp_contexts b/sepolicy/private/seapp_contexts deleted file mode 100644 index d91b70e..0000000 --- a/sepolicy/private/seapp_contexts +++ /dev/null @@ -1 +0,0 @@ -user=system seinfo=platform name=org.lineageos.pocketmode domain=pocketmode_app type=system_app_data_file