sm8250-common: Nuke pocketmode app
This commit is contained in:
parent
46e2b99062
commit
cdff2c5447
8 changed files with 0 additions and 261 deletions
|
@ -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)
|
|
@ -1,30 +0,0 @@
|
|||
<?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>
|
|
@ -1,3 +0,0 @@
|
|||
-keep class org.lineageos.pocketmode.* {
|
||||
*;
|
||||
}
|
|
@ -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));
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
|
@ -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);
|
||||
});
|
||||
}
|
||||
}
|
|
@ -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 };
|
|
@ -1 +0,0 @@
|
|||
user=system seinfo=platform name=org.lineageos.pocketmode domain=pocketmode_app type=system_app_data_file
|
Loading…
Reference in a new issue