Skip to content

Commit

Permalink
Merge pull request #179 from learningequality/task-reconcile
Browse files Browse the repository at this point in the history
Access kolibri's job storage database to reconcile tasks
  • Loading branch information
rtibbles authored Jan 18, 2024
2 parents 3340ce1 + 8a73999 commit 28c9e0a
Show file tree
Hide file tree
Showing 37 changed files with 2,505 additions and 438 deletions.
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.9.13
1 change: 1 addition & 0 deletions python-for-android/dists/kolibri/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,5 @@ dependencies {
implementation 'androidx.concurrent:concurrent-futures:1.1.0'
implementation 'androidx.work:work-runtime:2.7.1'
implementation 'androidx.work:work-multiprocess:2.7.1'
implementation 'net.sourceforge.streamsupport:java9-concurrent-backport:2.0.5'
}
137 changes: 94 additions & 43 deletions python-for-android/dists/kolibri/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,72 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.learningequality.Kolibri"
android:installLocation="auto">
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="org.learningequality.Kolibri"
android:installLocation="auto"
>

<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:anyDensity="true"
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:anyDensity="true"
android:xlargeScreens="true"
/>

android:xlargeScreens="true"

/>

<!-- Allow writing to external storage -->
<uses-permission android:name="android.permission.INTERNET" />

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

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

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

<application android:label="@string/app_name"
android:icon="@mipmap/icon"
android:allowBackup="true"
android:name=".App"
android:theme="@android:style/Theme.NoTitleBar"
android:hardwareAccelerated="true"
android:usesCleartextTraffic="true"
android:extractNativeLibs="true"
>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />

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

<meta-data android:name="wakelock" android:value="0"/>

<activity android:name="org.kivy.android.PythonActivity"
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|fontScale|uiMode|uiMode|screenSize|smallestScreenSize|layoutDirection"
android:screenOrientation="unspecified"
android:exported="true"
<application
android:label="@string/app_name"
android:icon="@mipmap/icon"
android:allowBackup="true"
android:name=".App"
android:theme="@android:style/Theme.NoTitleBar"
android:hardwareAccelerated="true"
android:usesCleartextTraffic="true"
android:extractNativeLibs="true"
>

android:launchMode="singleTask"

android:windowSoftInputMode="adjustResize"
>
<meta-data android:name="wakelock" android:value="0"/>

<activity
android:name="org.kivy.android.PythonActivity"
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|fontScale|uiMode|uiMode|screenSize|smallestScreenSize|layoutDirection"
android:screenOrientation="unspecified"
android:exported="true"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>


<service
android:name="org.learningequality.Kolibri.ServiceRemoteshell"
android:permission=""
android:exported="true"
android:process=":service_remoteshell"
>
<intent-filter>
<action android:name="org.learningequality.Kolibri.START_REMOTESHELL" />

<service android:name="org.learningequality.Kolibri.ServiceRemoteshell"
android:permission=""
android:exported="true"
android:process=":service_remoteshell" >
<intent-filter>
<action android:name="org.learningequality.Kolibri.START_REMOTESHELL" />

</intent-filter>
</intent-filter>
</service>


<service android:name="org.learningequality.Kolibri.TaskworkerWorkerService"
android:process="@string/task_worker_process"
android:exported="false" />


<service
android:name=".WorkControllerService"
android:process="@string/task_worker_process"
android:exported="false"
/>

<!-- Use android:exported="true" so JobScheduler or Android Work can start these services -->
<service
android:name="androidx.work.multiprocess.RemoteWorkManagerService"
android:process="@string/task_worker_process"
android:exported="true"
tools:replace="android:process, android:exported"
/>

<service
android:name="androidx.work.impl.background.systemjob.SystemJobService"
android:process="@string/task_worker_process"
android:exported="true"
tools:replace="android:process, android:exported"
/>

<service
android:name="androidx.work.impl.foreground.SystemForegroundService"
android:foregroundServiceType="dataSync|connectedDevice"
tools:node="merge"
/>

<service
android:name=".WorkerService"
android:foregroundServiceType="dataSync|connectedDevice"
android:process="@string/task_worker_process"
android:exported="true"
android:permission="android.permission.FOREGROUND_SERVICE_CONNECTED_DEVICE, android.permission.FOREGROUND_SERVICE_DATA_SYNC"
/>

<provider
android:name="androidx.startup.InitializationProvider"
android:authorities="${applicationId}.androidx-startup"
android:exported="false"
tools:node="merge"
>
<!-- If you are using androidx.startup to initialize other components -->
<meta-data
android:name="androidx.work.WorkManagerInitializer"
android:value="androidx.startup"
tools:node="remove"
/>
</provider>

</application>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package org.kivy.android;

import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.os.Build;
import android.os.SystemClock;

import java.io.InputStream;
Expand Down Expand Up @@ -42,11 +39,10 @@
import android.webkit.CookieManager;
import android.net.Uri;

import androidx.core.app.NotificationManagerCompat;

import org.learningequality.Kolibri.R;
import org.renpy.android.ResourceManager;


public class PythonActivity extends Activity {
// This activity is modified from a mixture of the SDLActivity and
// PythonActivity in the SDL2 bootstrap, but removing all the SDL2
Expand Down Expand Up @@ -248,8 +244,7 @@ public void onDestroy() {
}

public void loadLibraries() {
PythonUtil.loadLibraries(
new File(getApplicationInfo().nativeLibraryDir));
PythonLoader.doLoad(this);
}

public static void loadUrl(String url) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package org.kivy.android;

import android.content.Context;

public class PythonContext {
public static PythonContext mInstance;

private final Context context;

private PythonContext(Context context) {
this.context = context;
}

public static PythonContext getInstance(Context context) {
if (mInstance == null) {
synchronized (PythonContext.class) {
if (mInstance == null) {
mInstance = new PythonContext(
context.getApplicationContext()
);
}
}
}
return PythonContext.mInstance;
}

public static Context get() {
if (PythonContext.mInstance == null) {
return null;
}
return PythonContext.mInstance.context;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package org.kivy.android;

import android.content.Context;

import java.io.File;
import java.util.concurrent.atomic.AtomicBoolean;

public class PythonLoader {
protected static PythonLoader mInstance;

private final File src;
private final AtomicBoolean isLoaded = new AtomicBoolean(false);

private PythonLoader(File src) {
this.src = src;
}

public void load() {
synchronized (isLoaded) {
if (isLoaded.get()) {
return;
}
PythonUtil.loadLibraries(src);
isLoaded.set(true);
}
}

public static PythonLoader getInstance(Context context) {
if (mInstance == null) {
synchronized (PythonLoader.class) {
if (mInstance == null) {
mInstance = new PythonLoader(
new File(context.getApplicationInfo().nativeLibraryDir)
);
}
}
}
return PythonLoader.mInstance;
}

public static void doLoad(Context context) {
PythonLoader.getInstance(context).load();
}
}
Loading

0 comments on commit 28c9e0a

Please sign in to comment.