ParanoidGlyph: Implement ThirdParty service

An instance of IGlyphService class receive data about LED updates and then send it to the AnimationManager

Change-Id: I682aa0d17db6d796483eee5e1aa6374442cefe3e
This commit is contained in:
BrainKub
2025-02-24 02:14:28 +03:00
committed by Wiktor
parent c348fcb7b4
commit c59c1d5a2c
5 changed files with 63 additions and 1 deletions

View File

@@ -37,6 +37,7 @@ android_library {
"androidx.preference_preference",
"com.google.android.material_material",
"SettingsLib",
"IGlyphService-java",
],
}

View File

@@ -101,6 +101,14 @@
<action android:name="android.service.quicksettings.action.QS_TILE" />
</intent-filter>
</service>
<service
android:name=".Services.ThirdPartyService"
android:exported="true"
android:permission="android.permission.BIND_SERVICE">
<intent-filter>
<action android:name="co.aospa.glyph.Services.ThirdPartyService" />
</intent-filter>
</service>
<activity
android:name=".Tiles.TileActivity"
android:exported="true"

View File

@@ -378,7 +378,7 @@ public final class AnimationManager {
.toArray());
}
private static void updateLedFrame(int[] pattern) {
public static void updateLedFrame(int[] pattern) {
float[] floatPattern = new float[pattern.length];
for (int i = 0; i < pattern.length; i++) {
floatPattern[i] = (float) pattern[i];

View File

@@ -0,0 +1,38 @@
/*
* SPDX-FileCopyrightText: 2023 The LineageOS Project
* SPDX-License-Identifier: Apache-2.0
*/
package co.aospa.glyph.Services
import android.app.Service
import android.content.Intent
import android.os.IBinder
import android.util.Log
import co.aospa.glyph.Manager.AnimationManager
import com.nothing.thirdparty.IGlyphService
class ThirdPartyService : Service() {
private val binder = object : IGlyphService.Stub() {
override fun setFrameColors(iArray: IntArray?) {
Log.d("ThirdPartyService", "received data: ${iArray.contentToString()}")
AnimationManager.updateLedFrame(iArray)
}
override fun openSession() {
Log.d("IGlyphServiceImpl", "openSession")
}
override fun closeSession() {
Log.d("IGlyphServiceImpl", "closeSession")
}
override fun register(str: String) = true
override fun registerSDK(str1: String, str2: String) = true
}
override fun onBind(intent: Intent?): IBinder {
return binder
}
}

View File

@@ -30,6 +30,7 @@ import co.aospa.glyph.Services.ChargingService;
import co.aospa.glyph.Services.FlipToGlyphService;
import co.aospa.glyph.Services.MusicVisualizerService;
import co.aospa.glyph.Services.PowershareService;
import co.aospa.glyph.Services.ThirdPartyService;
import co.aospa.glyph.Services.VolumeLevelService;
public final class ServiceUtils {
@@ -111,9 +112,22 @@ public final class ServiceUtils {
UserHandle.CURRENT);
}
public static void startThirdPartyService() {
if (DEBUG) Log.d(TAG, "Starting ThirdParty service");
context.startServiceAsUser(new Intent(context, ThirdPartyService.class),
UserHandle.CURRENT);
}
protected static void stopThirdPartyService() {
if (DEBUG) Log.d(TAG, "Stopping ThirdParty service");
context.stopServiceAsUser(new Intent(context, ThirdPartyService.class),
UserHandle.CURRENT);
}
public static void checkGlyphService() {
if (SettingsManager.isGlyphEnabled()) {
Constants.setBrightness(SettingsManager.getGlyphBrightness());
startThirdPartyService();
if (SettingsManager.isGlyphChargingEnabled()) {
startChargingService();
} else {
@@ -151,6 +165,7 @@ public final class ServiceUtils {
stopFlipToGlyphService();
stopMusicVisualizerService();
stopVolumeLevelService();
stopThirdPartyService();
}
}
}