Skip to content

Commit

Permalink
ForegroundService; move Conversation state to MobileViewModel
Browse files Browse the repository at this point in the history
  • Loading branch information
paulpv committed Jan 29, 2025
1 parent 77ac231 commit 09261f3
Show file tree
Hide file tree
Showing 10 changed files with 940 additions and 388 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ OpenAI Realtime API over WebRTC Push-To-Talk Android Phone[/Mobile] + Watch[/Wea

## TODOs
(Not necessarily in any order)
1. Background service (easy to do wrong; I want to get the UX right)
2. Localize strings (I committed the sin of hard coding strings)
3. Tests (another sin I committed)
4. Get `Stop` working better
5. **Standalone** `Wear` version (lower priority; requires adding tiles for settings, conversation, etc)
6. Add `text` input/output feature
7. Learn Tool/Function integration
8. Find way to integrate with Gmail/Tasks/Keep/etc
9. Find way to save conversations to https://chatgpt.com/ history
1. Localize strings (I committed the sin of hard coding strings)
2. Tests (another sin I committed)
3. Get `Stop` working better
4. **Standalone** `Wear` version (lower priority; requires adding tiles for settings, conversation, etc)
5. Add `text` input/output feature
6. Learn Tool/Function integration
7. Find way to integrate with Gmail/Tasks/Keep/etc
8. Find way to save conversations to https://chatgpt.com/ history
9. Implement a `VoiceInteractionService`? https://developer.android.com/reference/android/service/voice/VoiceInteractionService

## Development
* If Mobile or Wear physical device wireless debugging does not connect in Android Studio:
Expand Down
28 changes: 28 additions & 0 deletions mobile/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@

<uses-permission android:name="android.permission.VIBRATE" />

<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<!--
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_REMOTE_MESSAGING" />
-->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />

<application
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
Expand All @@ -36,6 +44,26 @@
</intent-filter>
</activity>

<service
android:name=".MobileForegroundService"
android:exported="false"
android:foregroundServiceType="specialUse"
>
<!--
https://developer.android.com/develop/background-work/services/fgs/service-types#microphone
https://developer.android.com/develop/background-work/services/fgs/service-types#remote-messaging
https://developer.android.com/develop/background-work/services/fgs/service-types#special-use
-->
<property
android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"
android:value="OpenAI Realtime WebRTC Voice Assistant Session (VoIP Call)"
/>
<intent-filter>
<action android:name="com.swooby.alfredai.action.START" />
<action android:name="com.swooby.alfredai.action.STOP" />
</intent-filter>
</service>

</application>

</manifest>
6 changes: 4 additions & 2 deletions mobile/src/main/java/com/swooby/alfredai/AlfredAiApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.ViewModelStore
import androidx.lifecycle.ViewModelStoreOwner

/*
@MainThread
inline fun <reified VM : ViewModel> ComponentActivity.appViewModels(): Lazy<VM> {
return ViewModelLazy(
Expand All @@ -18,15 +19,16 @@ inline fun <reified VM : ViewModel> ComponentActivity.appViewModels(): Lazy<VM>
{ defaultViewModelCreationExtras }
)
}
*/

class AlfredAiApp : Application(), ViewModelStoreOwner
{
override val viewModelStore = ViewModelStore()

val mobileViewModel by lazy {
ViewModelProvider(
this,
ViewModelProvider.AndroidViewModelFactory.getInstance(this)
owner = this,
factory = ViewModelProvider.AndroidViewModelFactory.getInstance(this)
)[MobileViewModel::class.java]
}

Expand Down
Loading

0 comments on commit 09261f3

Please sign in to comment.