GNSS সময় সনাক্তকরণ

অ্যান্ড্রয়েড 12 থেকে, অ্যান্ড্রয়েড ঐচ্ছিকভাবে একটি গ্লোবাল নেভিগেশন স্যাটেলাইট সিস্টেম (জিএনএসএস) ব্যবহার করতে পারে যাতে সময়_ডিটেক্টর পরিষেবাতে ইউনিক্স যুগের সময় প্রস্তাব করা যায়। এটি AOSP-এ ডিফল্টরূপে সক্ষম নয়।

যখন GNSS সময় সনাক্তকরণ সক্ষম করা হয়, gnss_time_update_service নিষ্ক্রিয়ভাবে GNSS উত্স থেকে অবস্থানের আপডেটগুলি শোনে এবং time_detector পরিষেবাতে GNSS পরামর্শ জমা দেয়৷ time_detector পরিষেবা তারপর নির্ধারণ করে যে পরামর্শের সাথে মেলে সিস্টেম ঘড়ি আপডেট করা হবে কিনা।

শক্তি ব্যবহারের উপর প্রভাব

AOSP gnss_time_update_service নিষ্ক্রিয়ভাবে অবস্থানের আপডেট শোনে। এর মানে হল যে এটি সক্রিয়ভাবে GPS চালু করে না বা অতিরিক্ত শক্তি খরচ করে না। এর মানে হল যে যতক্ষণ না সিস্টেমে অন্য অ্যাপ বা পরিষেবা সক্রিয়ভাবে অবস্থান আপডেটের অনুরোধ করছে, gnss_time_update_service একটি অবস্থান আপডেট পাবে না এবং একটি GNSS সময় প্রস্তাব করবে।

বাস্তবায়ন

GNSS সময় সনাক্তকরণ সক্ষম করতে, ডিভাইস নির্মাতাদের অবশ্যই সিস্টেম সার্ভারে স্পষ্টভাবে gnss_time_update_service সক্ষম করতে হবে।

এই বৈশিষ্ট্যটি সক্ষম করতে core/res/res/values/config.xml ফাইলের config_enableGnssTimeUpdateService এবং config_autoTimeSourcesPriority মান উভয়ই আপডেট করতে হবে। config_enableGnssTimeUpdateService এর মান true সেট করুন এবং config_autoTimeSourcesPriority এর জন্য আইটেম তালিকায় gnss যোগ করুন। অগ্রাধিকার তালিকায় gnss এর অবস্থান অন্যান্য উত্স থেকে GNSS পরামর্শের ক্ষেত্রে অগ্রাধিকার নির্ধারণ করে।

নীচের একটি উদাহরণ core/res/res/values/config.xml ফাইল যেখানে GNSS সময় সনাক্তকরণ সক্ষম করা হয়েছে এবং gnss network এবং telephony পরে অগ্রাধিকার তালিকায় তৃতীয়।

<!-- Specifies priority of automatic time sources. Suggestions from higher entries in the list
         take precedence over lower ones.
         See com.android.server.timedetector.TimeDetectorStrategy for available sources. -->
    <string-array name="config_autoTimeSourcesPriority">
        <item>network</item>
        <item>telephony</item>
        <item>gnss</item>
    </string-array>

    <!-- Enables the GnssTimeUpdate service. This is the global switch for enabling Gnss time based
         suggestions to TimeDetector service. See also config_autoTimeSourcesPriority. -->
    <bool name="config_enableGnssTimeUpdateService">true</bool>

ডিবাগিং এবং টেস্টিং

GNSS সময় সনাক্তকরণ পরীক্ষা করতে, আপনি adb shell cmd location কমান্ড ব্যবহার করতে পারেন। পরীক্ষা অবস্থান প্রদানকারী যোগ করতে এই কমান্ডগুলি ব্যবহার করুন যেখানে আপনি একটি অবস্থান এবং সংশ্লিষ্ট GNSS সময় নির্দিষ্ট করতে পারেন। gnss_time_update_service এই অবস্থানের আপডেটগুলি শোনে এবং পর্যায়ক্রমে পরামর্শ দেয়৷

নিম্নলিখিত adb shell cmd location কমান্ডের উদাহরণ দেখায়:

# Enable Master Location Switch in the foreground user (usually user 10 on automotive). If you just flashed, this can be done through setup wizard.
adb shell cmd location set-location-enabled true --user 10

# Add GPS test provider (This usually fails the first time. Will throw a SecurityException with "android from <SOME_UID> not allowed to perform MOCK_LOCATION".)
adb shell cmd location providers add-test-provider gps

# Enable mock location permissions for previous UID
adb shell appops set UID_PRINTED_IN_PREVIOUS_ERROR android:mock_location allow

# Add GPS test provider (Should work with no errors.)
adb shell cmd location providers add-test-provider gps

# Enable GPS test provider
adb shell cmd location providers set-test-provider-enabled gps true

# Set location with time (Time can't be lower than the limit set by the lower bound.)
adb shell cmd location providers set-test-provider-location gps --location LATITUDE,LONGITUDE --time TIME