sm8250-common: Add FODService

Change-Id: I34af976ce5c6cbaaa2a45c96374664119d6ac5c8
This commit is contained in:
TheScarastic 2019-11-01 22:48:20 +01:00 committed by Sebastiano Barezzi
parent 2a540b832e
commit 06f816fd6b
No known key found for this signature in database
GPG Key ID: 47760583F393BC44
8 changed files with 210 additions and 1 deletions

19
FODService/Android.bp Normal file
View File

@ -0,0 +1,19 @@
//
// Copyright (C) 2017-2021 The LineageOS Project
//
// SPDX-License-Identifier: Apache-2.0
//
android_app {
name: "FODService",
srcs: ["src/**/*.java"],
certificate: "platform",
platform_apis: true,
privileged: true,
static_libs: [
//"org.lineageos.settings.resources",
"//hardware/xiaomi:vendor.xiaomi.hardware.displayfeature-V1.0-java",
],
}

View File

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015-2016 The CyanogenMod Project
2017-2021 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.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.lineageos.fodservice"
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="24"
android:targetSdkVersion="24"/>
<application>
<receiver android:name=".BootCompletedReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
<service android:name=".fod.FodService"
android:permission="FodService">
</service>
</application>
</manifest>

View File

@ -0,0 +1,37 @@
/*
* Copyright (C) 2015 The CyanogenMod Project
* 2017-2020 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.fodservice;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import org.lineageos.fodservice.fod.FodUtils;
public class BootCompletedReceiver extends BroadcastReceiver {
private static final boolean DEBUG = false;
private static final String TAG = "FODService";
@Override
public void onReceive(final Context context, Intent intent) {
if (DEBUG) Log.d(TAG, "Received boot completed intent");
FodUtils.startService(context);
}
}

View File

@ -0,0 +1,77 @@
/*
* Copyright (C) 2019 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.fodservice.fod;
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;
import vendor.xiaomi.hardware.displayfeature.V1_0.IDisplayFeature;
public class FodService extends Service {
private static final String TAG = "FodService";
private static final boolean DEBUG = false;
private BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
final String action = intent.getAction();
if (Intent.ACTION_SCREEN_ON.equals(action)) {
try {
IDisplayFeature mDisplayFeature = IDisplayFeature.getService();
mDisplayFeature.setFeature(0, 0, 2, 255);
mDisplayFeature.setFeature(0, 3, 0, 255);
} catch (Exception e) {
// Do nothing
}
}
}
};
@Override
public void onCreate() {
registerReceiver();
}
@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(mIntentReceiver);
super.onDestroy();
}
@Override
public IBinder onBind(Intent intent) {
return null;
}
private void registerReceiver() {
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_SCREEN_ON);
this.registerReceiver(mIntentReceiver, filter);
}
}

View File

@ -0,0 +1,28 @@
/*
* Copyright (C) 2019 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.fodservice.fod;
import android.content.Context;
import android.content.Intent;
import android.os.UserHandle;
public class FodUtils {
public static void startService(Context context) {
context.startServiceAsUser(new Intent(context, FodService.class),
UserHandle.CURRENT);
}
}

View File

@ -195,7 +195,8 @@ PRODUCT_PACKAGES += \
# Fingerprint
ifeq ($(TARGET_HAS_FOD),true)
PRODUCT_PACKAGES += \
vendor.lineage.biometrics.fingerprint.inscreen@1.0-service.xiaomi_kona
vendor.lineage.biometrics.fingerprint.inscreen@1.0-service.xiaomi_kona \
FODService
PRODUCT_PACKAGES += \
vendor.goodix.hardware.biometrics.fingerprint@2.1.vendor

View File

@ -11,6 +11,7 @@ allow devicesettings_app {
mediaserver_service
}:service_manager find;
hal_client_domain(devicesettings_app, hal_displayfeature)
hal_client_domain(devicesettings_app, hal_motor)
hal_client_domain(devicesettings_app, hal_touchfeature)
@ -20,6 +21,7 @@ allow devicesettings_app system_app_data_file:{ file lnk_file } create_file_perm
# Allow binder communication with gpuservice
binder_call(devicesettings_app, gpuservice)
binder_call(devicesettings_app, hal_displayfeature)
binder_call(devicesettings_app, hal_motor)
binder_call(devicesettings_app, hal_touchfeature)

View File

@ -1,2 +1,3 @@
user=system seinfo=platform name=org.lineageos.devicesettings domain=devicesettings_app type=system_app_data_file
user=system seinfo=platform name=org.lineageos.fodservice domain=devicesettings_app type=system_app_data_file
user=system seinfo=platform name=org.lineageos.settings domain=devicesettings_app type=system_app_data_file