diff --git a/src/initialization.py b/src/initialization.py index 7d8431ee..5c52b87f 100644 --- a/src/initialization.py +++ b/src/initialization.py @@ -3,6 +3,8 @@ import re import sys +from jnius import autoclass +from android_utils import get_activity script_dir = os.path.dirname(os.path.abspath(__file__)) sys.path.append(script_dir) @@ -10,7 +12,17 @@ sys.path.append(os.path.join(script_dir, "extra-packages")) os.environ["DJANGO_SETTINGS_MODULE"] = "kolibri_app_settings" +Secure = autoclass('android.provider.Settings$Secure') +node_id = Secure.getString( + get_activity().getContentResolver(), + Secure.ANDROID_ID +) + +# Don't set this if the retrieved id is falsy, too short, or a specific +# id that is known to be hardcoded in many devices. +if node_id and len(node_id) >= 16 and node_id != "9774d56d682e549c": + os.environ["MORANGO_NODE_ID"] = node_id if pew.ui.platform == "android": # initialize some system environment variables needed to run smoothly on Android