27 মার্চ, 2025 থেকে, আমরা AOSP তৈরি করতে এবং অবদান রাখতে aosp-main
এর পরিবর্তে android-latest-release
ব্যবহার করার পরামর্শ দিচ্ছি। আরও তথ্যের জন্য, AOSP-তে পরিবর্তনগুলি দেখুন।
USB HAL প্রয়োগ করুন
সেভ করা পৃষ্ঠা গুছিয়ে রাখতে 'সংগ্রহ' ব্যবহার করুন
আপনার পছন্দ অনুযায়ী কন্টেন্ট সেভ করুন ও সঠিক বিভাগে রাখুন।
অ্যান্ড্রয়েড 8.0 রিলিজ ভাল কনফিগারেশন এবং কোড নির্ভরযোগ্যতার জন্য USB কমান্ডগুলির পরিচালনাকে init
স্ক্রিপ্টের বাইরে এবং একটি নেটিভ USB ডেমনে নিয়ে যায়। গ্যাজেট ফাংশন কনফিগারেশনের জন্য, init
স্ক্রিপ্ট (সম্পত্তি ট্রিগার) ডিভাইস-নির্দিষ্ট গ্যাজেট ক্রিয়াকলাপ সম্পাদন করতে ব্যবহৃত হয়।
পূর্ববর্তী রিলিজে, এই ডিভাইস-নির্দিষ্ট কনফিগারেশনগুলি ডিভাইস-নির্দিষ্ট init
স্ক্রিপ্ট (প্রপার্টি ট্রিগার ব্যবহার করে) মাধ্যমে অর্জন করা হয়েছিল। একটি হার্ডওয়্যার অ্যাবস্ট্রাকশন লেয়ার (HAL) ডিজাইনে যাওয়ার ফলে অনেক ক্লিনার বাস্তবায়ন হয় যা এই সমস্যার সমাধান করে:
- কার্নেল sysfs নোডগুলিতে লেখার মতো অপারেশনগুলি ব্যর্থ হতে পারে কিন্তু প্রপার্টি ট্রিগার সেট করে এমন ফ্রেমওয়ার্ক কোডে প্রচার করা যাবে না। ফলস্বরূপ, ফ্রেমওয়ার্কগুলি ভুলভাবে অনুমান করে যে অপারেশনগুলি সফল হয়েছে যদিও তারা নীরবে ব্যর্থ হয়েছে।
-
init
স্ক্রিপ্টগুলিতে সীমিত সংখ্যক অপারেশন রয়েছে যা চালানো যেতে পারে।
Android 12 রিলিজ নেটওয়ার্ক কন্ট্রোল মডেল (NCM) এবং API কলগুলির জন্য USB গ্যাজেট HAL সমর্থন যোগ করে যা HAL সংস্করণ নম্বর এবং USB গতি উভয়ই ফেরত দেয়। USB HAL-এর মাধ্যমে উপলব্ধ API কলগুলি সম্পর্কে আরও তথ্যের জন্য, android.hardware.usb
প্যাকেজ সারাংশ দেখুন।
HAL এবং Treble
ডিভাইস-নির্দিষ্ট init
স্ক্রিপ্টগুলি ডিভাইস-নির্দিষ্ট USB অপারেশন সম্পাদনের জন্য HAL স্তরগুলির প্রতিস্থাপন হিসাবে ব্যবহৃত হয়েছিল। USB (ADB-এর মাধ্যমে) ডিবাগিং সিস্টেম সমস্যাগুলির জন্য একটি প্রাথমিক ইন্টারফেস। ইউএসবি কনফিগারেশন করার জন্য একটি নেটিভ ডেমন থাকা ফ্রেমওয়ার্ক কোডের উপর নির্ভরতা দূর করে তাই ফ্রেমওয়ার্ক ক্র্যাশ করলেও ইউএসবি চালু হওয়া উচিত।
অ্যান্ড্রয়েড 8.0-এ প্রবর্তিত ট্রেবল মডেলের অধীনে, সমস্ত এইচএএল সিস্টেম পরিষেবাগুলি থেকে বিচ্ছিন্ন এবং তাদের নিজস্ব স্থানীয় ডেমনগুলিতে চালানো প্রয়োজন। এটি একটি এক্সক্লুসিভ USB ডেমনের প্রয়োজনীয়তা দূর করে কারণ HAL স্তরটি একটি USB ডেমনের মতো সুন্দরভাবে দ্বিগুণ হয়।
ডিফল্ট HAL বাস্তবায়ন সমস্ত প্রাক-Android 8.0 ডিভাইসের যত্ন নেয়। অতএব, প্রি-অ্যান্ড্রয়েড 8.0 ডিভাইসগুলির জন্য কোনও ডিভাইস-নির্দিষ্ট কাজ হবে না। Android 8.0 HAL ইন্টারফেস ব্যবহার করে USB পোর্টের অবস্থা জানতে এবং ডেটা রোল এবং পাওয়ার রোল সোয়াপ করতে।
বাস্তবায়ন
Android 8.0-এ লঞ্চ হওয়া প্রতিটি ডিভাইসে নতুন USB HAL ইন্টারফেস প্রয়োগ করা প্রয়োজন। ডিফল্ট বাস্তবায়ন প্রি-Android 8.0 ডিভাইসের যত্ন নেওয়া উচিত। টাইপ-সি পোর্ট স্ট্যাটাস রিপোর্ট করতে ডিভাইসটি dual_role_usb
ক্লাস ব্যবহার করলে ডিফল্ট বাস্তবায়ন যথেষ্ট। সিস্টেমে typc-c নোডগুলির মালিকানা স্থানান্তর করতে ডিভাইস-নির্দিষ্ট USB স্ক্রিপ্টগুলিতে তুচ্ছ পরিবর্তনের প্রয়োজন হতে পারে।
এই পৃষ্ঠার কন্টেন্ট ও কোডের নমুনাগুলি Content License-এ বর্ণিত লাইসেন্সের অধীনস্থ। Java এবং OpenJDK হল Oracle এবং/অথবা তার অ্যাফিলিয়েট সংস্থার রেজিস্টার্ড ট্রেডমার্ক।
2025-07-29 UTC-তে শেষবার আপডেট করা হয়েছে।
[[["সহজে বোঝা যায়","easyToUnderstand","thumb-up"],["আমার সমস্যার সমাধান হয়েছে","solvedMyProblem","thumb-up"],["অন্যান্য","otherUp","thumb-up"]],[["এতে আমার প্রয়োজনীয় তথ্য নেই","missingTheInformationINeed","thumb-down"],["খুব জটিল / অনেক ধাপ","tooComplicatedTooManySteps","thumb-down"],["পুরনো","outOfDate","thumb-down"],["অনুবাদ সংক্রান্ত সমস্যা","translationIssue","thumb-down"],["নমুনা / কোড সংক্রান্ত সমস্যা","samplesCodeIssue","thumb-down"],["অন্যান্য","otherDown","thumb-down"]],["2025-07-29 UTC-তে শেষবার আপডেট করা হয়েছে।"],[],[],null,["# Implement USB HAL\n\nThe Android 8.0 release moves handling of USB commands out of `init`\nscripts and into a native USB daemon for better configuration and code\nreliability. For the Gadget function configuration, `init` scripts\n(property triggers) are used to perform device-specific gadget operations.\n\nIn previous releases, these device-specific configurations were achieved through\ndevice-specific `init` scripts (using property triggers). Moving to a\nHardware Abstraction Layer (HAL) design results in a much cleaner implementation\nthat solves these problems:\n\n1. Operations such as writes to the kernel sysfs nodes could fail but not be propagated back to the frameworks code that sets the property trigger. As a result, frameworks incorrectly assumes the operations have succeeded even though they have silently failed.\n2. `init` scripts have a limited number of operations that could be executed.\n\nThe Android 12 release adds USB Gadget HAL support for Network Control\nModels (NCM) and API calls that return both the HAL version number and USB speed. For more\ninformation on the API calls available through the USB HAL, see\n[the `android.hardware.usb` package summary](https://developer.android.com/reference/android/hardware/usb/package-summary).\n\nHAL and Treble\n--------------\n\n\nThe device-specific `init` scripts were used as a substitution for\nHAL layers to perform device-specific USB operations. USB (through ADB) is a\nprimary interface for debugging system issues. Having a native daemon to perform\nUSB configuration eliminates the dependency on the framework code so even if the\nframework crashes USB should be running.\n\n\nUnder the\n[Treble](https://android-developers.googleblog.com/2017/05/here-comes-treble-modular-base-for.html)\nmodel also introduced in Android 8.0, all of the HALs are isolated from System\nservices and are required to run in their own native daemons. This eliminates\nthe requirement to have an exclusive USB daemon as the HAL layer nicely doubles\nas a USB daemon.\n\n\nThe default HAL implementation takes care of all pre-Android 8.0 devices. Therefore, there\nwouldn't be any device-specific work for the pre-Android 8.0 devices. Android 8.0 uses the HAL\ninterface to query the status of USB ports and to perform data role and power\nrole swaps.\n\nImplementation\n--------------\n\n\nNew USB HAL interface needs to be implemented on every device launching on Android 8.0.\nThe default implementation should take care of pre-Android 8.0 devices. The default\nimplementation is sufficient if the device uses the `dual_role_usb` class to report\ntype-c port status. Trivial changes might be required in device-specific USB scripts\nto transfer ownership of the typc-c nodes to system."]]