File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import json
22import os
33import re
4+ from uuid import uuid4
45from functools import cache
56
67from cryptography import x509
@@ -228,6 +229,19 @@ def get_dummy_user_name():
228229 value_cache .set (cache_key , value )
229230 return value
230231
232+ def get_os_user_auth_token ():
233+ cache_key = "OS_USER_AUTH_TOKEN"
234+ value = value_cache .get (cache_key )
235+ if value is None :
236+ value = uuid4 ().hex
237+ value_cache .set (cache_key , value )
238+ return value
239+
240+ def os_user (auth_token ):
241+ if auth_token == get_os_user_auth_token ():
242+ return (get_dummy_user_name (), True )
243+ return None , False
244+
231245
232246def is_active_network_metered ():
233247 ConnectivityManager = autoclass ("android.net.ConnectivityManager" )
Original file line number Diff line number Diff line change 22from uuid import uuid4
33
44import initialization # noqa: F401 keep this first, to ensure we're set up for other imports
5- from android_utils import get_dummy_user_name
5+ from android_utils import os_user
6+ from android_utils import get_os_user_auth_token
67from android_utils import is_active_network_metered
78from android_utils import share_by_intent
89from jnius import autoclass
2526
2627loadUrl = Runnable (PythonActivity .mWebView .loadUrl )
2728
28- auth_token_value = uuid4 ().hex
29-
30-
31- def os_user (auth_token ):
32- if auth_token == auth_token_value :
33- return (get_dummy_user_name (), True )
34- return None , False
35-
29+ auth_token_value = get_os_user_auth_token ()
3630
3731class AppPlugin (SimplePlugin ):
3832 def __init__ (self , bus ):
Original file line number Diff line number Diff line change 11import logging
22
33import initialization # noqa: F401 keep this first, to ensure we're set up for other imports
4+ from android_utils import os_user
45from kolibri .main import initialize
5-
6+ from kolibri . plugins . app . utils import interface
67
78initialize (skip_update = True )
9+ interface .register (get_os_user = os_user )
810
911logger = logging .getLogger (__name__ )
1012
You can’t perform that action at this time.
0 commit comments