From 05e717bbda117b9fe82208fb88ffbd3c94f4c8f4 Mon Sep 17 00:00:00 2001 From: Richard Tibbles Date: Tue, 28 Sep 2021 09:34:32 -0700 Subject: [PATCH 1/2] Use ANDROID_ID for MORANGO_NODE_ID. --- src/initialization.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/initialization.py b/src/initialization.py index 7d8431ee..80c2ccec 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,6 +12,12 @@ sys.path.append(os.path.join(script_dir, "extra-packages")) os.environ["DJANGO_SETTINGS_MODULE"] = "kolibri_app_settings" +Secure = autoclass('android.provider.Settings$Secure') + +os.environ["MORANGO_NODE_ID"] = Secure.getString( + get_activity().getContentResolver(), + Secure.ANDROID_ID +) if pew.ui.platform == "android": From 1e414c1825bea72073462935505011db3ee2a120 Mon Sep 17 00:00:00 2001 From: Richard Tibbles Date: Fri, 19 Nov 2021 06:30:00 -0800 Subject: [PATCH 2/2] Update node_id to exclude edge cases. --- src/initialization.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/initialization.py b/src/initialization.py index 80c2ccec..5c52b87f 100644 --- a/src/initialization.py +++ b/src/initialization.py @@ -14,11 +14,15 @@ os.environ["DJANGO_SETTINGS_MODULE"] = "kolibri_app_settings" Secure = autoclass('android.provider.Settings$Secure') -os.environ["MORANGO_NODE_ID"] = Secure.getString( +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