This commit is contained in:
2025-12-28 10:54:06 +01:00
commit de82e50bd5
48 changed files with 2511 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<application
android:icon="@mipmap/ic_launcher"
android:label="MosisOS Service"
android:theme="@style/Theme.AppCompat.Light">
<service
android:name=".NativeService"
android:enabled="true"
android:exported="true"
android:process=":service"
android:foregroundServiceType="dataSync">
<intent-filter>
<action android:name="com.omixlab.mosis.SERVICE" />
</intent-filter>
</service>
</application>
</manifest>

View File

@@ -0,0 +1,5 @@
package com.omixlab.mosis;
interface IMosisService {
int getNumber();
}

View File

@@ -0,0 +1,13 @@
cmake_minimum_required(VERSION 3.22.1)
project("mosis-service")
set(ANDROID_SDK "/Users/omar/Library/Android/sdk")
set(BINDER_DIR "${ANDROID_SDK}/platforms/android-36/optional/libbinder_ndk_cpp")
add_library(${CMAKE_PROJECT_NAME} SHARED
mosis-service.cpp
com/omixlab/mosis/IMosisService.cpp)
target_include_directories(${CMAKE_PROJECT_NAME} PUBLIC
${CMAKE_CURRENT_LIST_DIR} ${BINDER_DIR})
target_link_libraries(${CMAKE_PROJECT_NAME}
android log binder_ndk)

View File

@@ -0,0 +1,50 @@
/*
* This file is auto-generated. DO NOT MODIFY.
* Using: /Users/omar/Library/Android/sdk/build-tools/36.1.0/aidl --lang=ndk --min_sdk_version=36 -o src/main/cpp -h src/main/cpp -I src/main/aidl src/main/aidl/com/omixlab/mosis/IMosisService.aidl
*
* DO NOT CHECK THIS FILE INTO A CODE TREE (e.g. git, etc..).
* ALWAYS GENERATE THIS FILE FROM UPDATED AIDL COMPILER
* AS A BUILD INTERMEDIATE ONLY. THIS IS NOT SOURCE CODE.
*/
#pragma once
#include "aidl/com/omixlab/mosis/IMosisService.h"
#include <android/binder_ibinder.h>
#include <cassert>
#ifndef __BIONIC__
#ifndef __assert2
#define __assert2(a,b,c,d) ((void)0)
#endif
#endif
namespace aidl {
namespace com {
namespace omixlab {
namespace mosis {
class BnMosisService : public ::ndk::BnCInterface<IMosisService> {
public:
BnMosisService();
virtual ~BnMosisService();
protected:
::ndk::SpAIBinder createBinder() override;
private:
};
class IMosisServiceDelegator : public BnMosisService {
public:
explicit IMosisServiceDelegator(const std::shared_ptr<IMosisService> &impl) : _impl(impl) {
}
::ndk::ScopedAStatus getNumber(int32_t* _aidl_return) override {
return _impl->getNumber(_aidl_return);
}
protected:
private:
std::shared_ptr<IMosisService> _impl;
};
} // namespace mosis
} // namespace omixlab
} // namespace com
} // namespace aidl

View File

@@ -0,0 +1,29 @@
/*
* This file is auto-generated. DO NOT MODIFY.
* Using: /Users/omar/Library/Android/sdk/build-tools/36.1.0/aidl --lang=ndk --min_sdk_version=36 -o src/main/cpp -h src/main/cpp -I src/main/aidl src/main/aidl/com/omixlab/mosis/IMosisService.aidl
*
* DO NOT CHECK THIS FILE INTO A CODE TREE (e.g. git, etc..).
* ALWAYS GENERATE THIS FILE FROM UPDATED AIDL COMPILER
* AS A BUILD INTERMEDIATE ONLY. THIS IS NOT SOURCE CODE.
*/
#pragma once
#include "aidl/com/omixlab/mosis/IMosisService.h"
#include <android/binder_ibinder.h>
namespace aidl {
namespace com {
namespace omixlab {
namespace mosis {
class BpMosisService : public ::ndk::BpCInterface<IMosisService> {
public:
explicit BpMosisService(const ::ndk::SpAIBinder& binder);
virtual ~BpMosisService();
::ndk::ScopedAStatus getNumber(int32_t* _aidl_return) override;
};
} // namespace mosis
} // namespace omixlab
} // namespace com
} // namespace aidl

View File

@@ -0,0 +1,54 @@
/*
* This file is auto-generated. DO NOT MODIFY.
* Using: /Users/omar/Library/Android/sdk/build-tools/36.1.0/aidl --lang=ndk --min_sdk_version=36 -o src/main/cpp -h src/main/cpp -I src/main/aidl src/main/aidl/com/omixlab/mosis/IMosisService.aidl
*
* DO NOT CHECK THIS FILE INTO A CODE TREE (e.g. git, etc..).
* ALWAYS GENERATE THIS FILE FROM UPDATED AIDL COMPILER
* AS A BUILD INTERMEDIATE ONLY. THIS IS NOT SOURCE CODE.
*/
#pragma once
#include <cstdint>
#include <memory>
#include <optional>
#include <string>
#include <vector>
#include <android/binder_interface_utils.h>
#ifdef BINDER_STABILITY_SUPPORT
#include <android/binder_stability.h>
#endif // BINDER_STABILITY_SUPPORT
namespace aidl {
namespace com {
namespace omixlab {
namespace mosis {
class IMosisServiceDelegator;
class IMosisService : public ::ndk::ICInterface {
public:
typedef IMosisServiceDelegator DefaultDelegator;
static const char* descriptor;
IMosisService();
virtual ~IMosisService();
static constexpr uint32_t TRANSACTION_getNumber = FIRST_CALL_TRANSACTION + 0;
static std::shared_ptr<IMosisService> fromBinder(const ::ndk::SpAIBinder& binder);
static binder_status_t writeToParcel(AParcel* parcel, const std::shared_ptr<IMosisService>& instance);
static binder_status_t readFromParcel(const AParcel* parcel, std::shared_ptr<IMosisService>* instance);
static bool setDefaultImpl(const std::shared_ptr<IMosisService>& impl);
static const std::shared_ptr<IMosisService>& getDefaultImpl();
virtual ::ndk::ScopedAStatus getNumber(int32_t* _aidl_return) = 0;
private:
static std::shared_ptr<IMosisService> default_impl;
};
class IMosisServiceDefault : public IMosisService {
public:
::ndk::ScopedAStatus getNumber(int32_t* _aidl_return) override;
::ndk::SpAIBinder asBinder() override;
bool isRemote() override;
};
} // namespace mosis
} // namespace omixlab
} // namespace com
} // namespace aidl

View File

@@ -0,0 +1,161 @@
/*
* This file is auto-generated. DO NOT MODIFY.
* Using: /Users/omar/Library/Android/sdk/build-tools/36.1.0/aidl --lang=ndk --min_sdk_version=36 -o src/main/cpp -h src/main/cpp -I src/main/aidl src/main/aidl/com/omixlab/mosis/IMosisService.aidl
*
* DO NOT CHECK THIS FILE INTO A CODE TREE (e.g. git, etc..).
* ALWAYS GENERATE THIS FILE FROM UPDATED AIDL COMPILER
* AS A BUILD INTERMEDIATE ONLY. THIS IS NOT SOURCE CODE.
*/
#include "aidl/com/omixlab/mosis/IMosisService.h"
#include <cstdint>
#include <android/binder_parcel.h>
#include <android/binder_parcel_utils.h>
#include <android/binder_status.h>
#include <aidl/com/omixlab/mosis/BnMosisService.h>
#include <aidl/com/omixlab/mosis/BpMosisService.h>
namespace aidl {
namespace com {
namespace omixlab {
namespace mosis {
static binder_status_t _aidl_com_omixlab_mosis_IMosisService_onTransact(AIBinder* _aidl_binder, transaction_code_t _aidl_code, const AParcel* _aidl_in, AParcel* _aidl_out) {
(void)_aidl_in;
(void)_aidl_out;
binder_status_t _aidl_ret_status = STATUS_UNKNOWN_TRANSACTION;
std::shared_ptr<BnMosisService> _aidl_impl = std::static_pointer_cast<BnMosisService>(::ndk::ICInterface::asInterface(_aidl_binder));
switch (_aidl_code) {
case (FIRST_CALL_TRANSACTION + 0 /*getNumber*/): {
int32_t _aidl_return;
::ndk::ScopedAStatus _aidl_status = _aidl_impl->getNumber(&_aidl_return);
_aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
if (_aidl_ret_status != STATUS_OK) break;
if (!AStatus_isOk(_aidl_status.get())) break;
_aidl_ret_status = ::ndk::AParcel_writeData(_aidl_out, _aidl_return);
if (_aidl_ret_status != STATUS_OK) break;
break;
}
}
return _aidl_ret_status;
}
static AIBinder_Class* _g_aidl_com_omixlab_mosis_IMosisService_clazz = ::ndk::ICInterface::defineClass(IMosisService::descriptor, _aidl_com_omixlab_mosis_IMosisService_onTransact, nullptr, 0);
BpMosisService::BpMosisService(const ::ndk::SpAIBinder& binder) : BpCInterface(binder) {}
BpMosisService::~BpMosisService() {}
::ndk::ScopedAStatus BpMosisService::getNumber(int32_t* _aidl_return) {
binder_status_t _aidl_ret_status = STATUS_OK;
::ndk::ScopedAStatus _aidl_status;
::ndk::ScopedAParcel _aidl_in;
::ndk::ScopedAParcel _aidl_out;
_aidl_ret_status = AIBinder_prepareTransaction(asBinderReference().get(), _aidl_in.getR());
if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
_aidl_ret_status = AIBinder_transact(
asBinderReference().get(),
(FIRST_CALL_TRANSACTION + 0 /*getNumber*/),
_aidl_in.getR(),
_aidl_out.getR(),
0
#ifdef BINDER_STABILITY_SUPPORT
| static_cast<int>(FLAG_PRIVATE_LOCAL)
#endif // BINDER_STABILITY_SUPPORT
);
if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && IMosisService::getDefaultImpl()) {
_aidl_status = IMosisService::getDefaultImpl()->getNumber(_aidl_return);
goto _aidl_status_return;
}
if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
_aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
_aidl_ret_status = ::ndk::AParcel_readData(_aidl_out.get(), _aidl_return);
if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
_aidl_error:
_aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
_aidl_status_return:
return _aidl_status;
}
// Source for BnMosisService
BnMosisService::BnMosisService() {}
BnMosisService::~BnMosisService() {}
::ndk::SpAIBinder BnMosisService::createBinder() {
AIBinder* binder = AIBinder_new(_g_aidl_com_omixlab_mosis_IMosisService_clazz, static_cast<void*>(this));
#ifdef BINDER_STABILITY_SUPPORT
AIBinder_markCompilationUnitStability(binder);
#endif // BINDER_STABILITY_SUPPORT
return ::ndk::SpAIBinder(binder);
}
// Source for IMosisService
const char* IMosisService::descriptor = "com.omixlab.mosis.IMosisService";
IMosisService::IMosisService() {}
IMosisService::~IMosisService() {}
std::shared_ptr<IMosisService> IMosisService::fromBinder(const ::ndk::SpAIBinder& binder) {
if (!AIBinder_associateClass(binder.get(), _g_aidl_com_omixlab_mosis_IMosisService_clazz)) {
#if __ANDROID_API__ >= 31
const AIBinder_Class* originalClass = AIBinder_getClass(binder.get());
if (originalClass == nullptr) return nullptr;
if (0 == strcmp(AIBinder_Class_getDescriptor(originalClass), descriptor)) {
return ::ndk::SharedRefBase::make<BpMosisService>(binder);
}
#endif
return nullptr;
}
std::shared_ptr<::ndk::ICInterface> interface = ::ndk::ICInterface::asInterface(binder.get());
if (interface) {
return std::static_pointer_cast<IMosisService>(interface);
}
return ::ndk::SharedRefBase::make<BpMosisService>(binder);
}
binder_status_t IMosisService::writeToParcel(AParcel* parcel, const std::shared_ptr<IMosisService>& instance) {
return AParcel_writeStrongBinder(parcel, instance ? instance->asBinder().get() : nullptr);
}
binder_status_t IMosisService::readFromParcel(const AParcel* parcel, std::shared_ptr<IMosisService>* instance) {
::ndk::SpAIBinder binder;
binder_status_t status = AParcel_readStrongBinder(parcel, binder.getR());
if (status != STATUS_OK) return status;
*instance = IMosisService::fromBinder(binder);
return STATUS_OK;
}
bool IMosisService::setDefaultImpl(const std::shared_ptr<IMosisService>& impl) {
// Only one user of this interface can use this function
// at a time. This is a heuristic to detect if two different
// users in the same process use this function.
assert(!IMosisService::default_impl);
if (impl) {
IMosisService::default_impl = impl;
return true;
}
return false;
}
const std::shared_ptr<IMosisService>& IMosisService::getDefaultImpl() {
return IMosisService::default_impl;
}
std::shared_ptr<IMosisService> IMosisService::default_impl = nullptr;
::ndk::ScopedAStatus IMosisServiceDefault::getNumber(int32_t* /*_aidl_return*/) {
::ndk::ScopedAStatus _aidl_status;
_aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
return _aidl_status;
}
::ndk::SpAIBinder IMosisServiceDefault::asBinder() {
return ::ndk::SpAIBinder();
}
bool IMosisServiceDefault::isRemote() {
return false;
}
} // namespace mosis
} // namespace omixlab
} // namespace com
} // namespace aidl

View File

@@ -0,0 +1,26 @@
#include <jni.h>
#include <android/binder_ibinder_jni.h>
#include <aidl/com/omixlab/mosis/BnMosisService.h>
using namespace aidl::com::omixlab::mosis;
class NativeService : public BnMosisService {
public:
ndk::ScopedAStatus getNumber(int32_t *_aidl_return) override {
*_aidl_return = 100;
return ndk::ScopedAStatus::ok();
}
};
static std::shared_ptr<NativeService> g_service;
extern "C"
JNIEXPORT jobject JNICALL
Java_com_omixlab_mosis_NativeService_getBinderNative(JNIEnv *env, jobject thiz) {
if (!g_service)
{
g_service = ndk::SharedRefBase::make<NativeService>();
}
return AIBinder_toJavaBinder(env, g_service->asBinder().get());
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

View File

@@ -0,0 +1,48 @@
package com.omixlab.mosis
import android.app.Notification
import android.app.NotificationChannel
import android.app.NotificationManager
import android.app.Service
import android.content.Intent
import android.os.Build
import android.os.IBinder
import androidx.core.app.NotificationCompat
class NativeService : Service() {
companion object {
const val NOTIFICATION_ID = 1
const val CHANNEL_ID = "MosisServiceChannel"
init {
System.loadLibrary("mosis-service")
}
}
private external fun getBinderNative(): IBinder
override fun onBind(intent: Intent): IBinder {
return getBinderNative()
}
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
createNotificationChannel()
// Create the notification required for the foreground service
val notification: Notification = NotificationCompat.Builder(this, CHANNEL_ID)
.setContentTitle("Mosis Service")
.setContentText("Service is running in the background")
.setSmallIcon(android.R.drawable.ic_dialog_info) // Replace with your app's icon
.setPriority(NotificationCompat.PRIORITY_LOW)
.build()
// Promotes the service to a foreground service
startForeground(NOTIFICATION_ID, notification)
// START_STICKY ensures the service restarts if the system kills it
return START_STICKY
}
private fun createNotificationChannel() {
val serviceChannel = NotificationChannel(
CHANNEL_ID,
"Mosis Service Channel",
NotificationManager.IMPORTANCE_LOW
)
val manager = getSystemService(NotificationManager::class.java)
manager.createNotificationChannel(serviceChannel)
}
}

View File

@@ -0,0 +1,15 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="#000000">
<group android:scaleX="0.58"
android:scaleY="0.58"
android:translateX="5.04"
android:translateY="5.04">
<path
android:fillColor="@android:color/white"
android:pathData="M16,1L8,1C6.34,1 5,2.34 5,4v16c0,1.66 1.34,3 3,3h8c1.66,0 3,-1.34 3,-3L19,4c0,-1.66 -1.34,-3 -3,-3zM14,21h-4v-1h4v1zM17.25,18L6.75,18L6.75,4h10.5v14z"/>
</group>
</vector>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
</adaptive-icon>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
</adaptive-icon>

Binary file not shown.

After

Width:  |  Height:  |  Size: 556 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 428 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 702 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#FFFFFF</color>
</resources>