Upgrade to Pro — share decks privately, control downloads, hide ads and more …

できる!Android Framework Code Reading

operandoOS
October 21, 2021

できる!Android Framework Code Reading

operandoOS

October 21, 2021
Tweet

More Decks by operandoOS

Other Decks in Technology

Transcript

  1. • Shinobu Okano • @operandoOS / shinobu.dart • 10X, Inc.

    / Software Engineer • Flutter / Dart / Android / Automation ࣗݾ঺հ
  2. Android software stack • ͬ͘͟ΓݴͬͯAndroid OSΛߏ੒͍ͯ͠Δ΋ͷ • ͍͔ͭ͘ͷLayerͰ෼͔Ε͍ͯΔ • Android

    system architectureͱදݱ͞ΕΔ͜ͱ΋͋Δ • ͱʹ͔͘޿͍ɾͰ͔͍ɾਂ͍ɾ΍͹͍
  3. • શLayerͷιʔείʔυ͕΄΅OSSͱͯ͠ެ։͞Ε͍ͯΔͷͰಡΊΔ • Kotlin/JavaͰΞϓϦ։ൃ͍ͯ͠Δਓ͕ؾܰʹಡΊΔͷ͸ Android Framework Layer • Android Framework

    Layer͸͓͓͔ͨJavaͰॻ͔Ε͍ͯΔ • ͦΕΑΓԼͷLayer͸C/C++ɺRustͳͲͰॻ͔Ε͍ͯΔ Android software stack
  4. ຊࢿྉʹ͓͚ΔAndroid Framework • Android Framework = Android software stack ͱ͍͏

    
 Ґஔ͚ͮͰॻ͍͍ͯ·͢ • ͨͩ͠ຊࢿྉͰ঺հ͢Δ͜ͱ͸্ҐϨΠϠʔ޲͚ͷ 
 Code ReadingΛϝΠϯλʔήοτͱ͍ͯ͠·͢
  5. Android Code Search “Code Search with Cross References for the

    Android Open Source Project” https://android-developers.googleblog.com/2019/12/code- search-with-cross-references-for-aosp.html
  6. Android Code Searchͷ͍͢͝ͱ͜Ζ • ݕࡧͷϑΟϧλʔ͕๛෋ • ߦ਺͕ଟ͍ίʔυͰ΋αΫαΫදࣔ͞ΕΔ • ϒϥϯνͷ੾Γସ͕͑Ͱ͖Δ •

    ૬ޓࢀরͷϦϯΫ͕షΒΕ͍ͯΔ • ϝιουͷ֊૚ݺͼग़͠ɺࢀর͕Θ͔Δ • Ξ΢τϥΠϯΊͪΌศརʂ
  7. AOSP WebαΠτ • AOSP(Android Open Source Project) • https://source.android.com/index.html •

    Androidͷ৭Μͳ͜ͱ͕υΩϡϝϯτͰ·ͱ·ͬͯΔ • ڵຯ͋ΔςʔϚΛݟ͚ͭͯಡΜͰΈΔͷ͕͓͢͢Ί
  8. UninstallerActivity(19960):Uninstallingextras=Bundle[{com.an droid.packageinstaller.extra.APP_LABEL=DroidKaigi2021,com. android.packageinstaller.applicationInfo=ApplicationInfo{5f5c cecio.github.droidkaigi.feeder.debug},android.intent.extra.UN INSTALL_ALL_USERS=false, com.android.packageinstaller.extra.UNINSTALL_ID=-2147483 643}] 
 I/ActivityManager( 1424):

    Force stopping io.github.droidkaigi.feeder.debug appid=10666 user=0: deletePackageX I/ActivityManager( 1424): Killing 23256:io.github.droidkaigi.feeder.debug/u0a666 (adj 940): stop io.github.droidkaigi.feeder.debug due to deletePackageX • ԫ৭෦෼͸ݻఆจࣈྻͬΆ͍ งғؾ • tagʢUninstallerActivityͷ ෦෼ʣ͸ݻఆจࣈྻͰίʔυ ্ʹఆٛ͞Ε͍ͯΔ͜ͱ͕ଟ ͍ͷͰݕࡧʹ࢖͍΍͍͢ 3. ݟ͚ͭͨϩά͔ΒݻఆจࣈྻΛ୳͢
  9. Code Readingͷ݁ՌΛͲ͏·ͱΊΔ͔ • Code Readingͨ͠ର৅ͷ֓ཁΛهࡌ͢Δ • Code Readingͨ͠ཧ༝ͱΘ͔ͬͨ͜ͱͷཁ໿Λهࡌ͢Δ • ॏཁͳ࣮૷෦෼͸ίʔυ෇͖ͰϝϞΔ

    + ίʔυͷϦϯΫΛ͚ͭΔ • ࢀߟʹͳΔυΩϡϝϯτͷϦϯΫΛషΔ • Code Reading࠷தϝϞΛ࢒͠ɺͦΕ΋ͬ͟ͱهࡌ͢Δ
  10. • Code Reading͢Δ্Ͱ 
 ϝϞ͸େࣄ • ͪΐͬͱͨ͠ϝϞͰ΋ফͣ͞ ʹ࢒͓ͯ͘͠ • ·ͱΊͷ࠷ޙͷํʹϝϞΛ

    
 ͦͷ··ࡶʹॻ͍͓͚ͯͩ͘ Ͱ΋Ձ஋͸͋Δ ϝϞΛ࢒͠ɺͦΕ΋ͬ͟ͱهࡌ͢Δ https://github.com/operando/JobScheduler-Code-Reading
  11. Session Buddy • Chrome Extension • https://sessionbuddy.com/ • ։͍ͯΔλϒΛλϒɾ΢Οϯυ΢ͷঢ়ଶΛอଘͰ͖Δ •

    Code Readingͯ͠ΔͱΊͬͪΌλϒ։͖·͘Δ • ಡΜͰΔঢ়ଶΛҰ୴อଘ͓͖͍ͯͨ͠৔߹ʹศར
  12. πϦʔܕλϒ • Firefox Add-ons • https://addons.mozilla.org/ja/ fi refox/addon/tree- style-tab/ •

    ಡΜͰ͍Δίʔυͷϝιουݺͼग़͠ͷ֊૚ͱ͔ΛπϦʔ ܕͷλϒͰ؅ཧ͢Δͷʹศར
  13. ·ͬͨΓAndroid Framework Code Reading • AndroidͷιʔείʔυΛಡΜͰɺ։ൃ౳ʹ໾ཱͯΔษڧձΛ 
 ਺೥લ ࢲ͕ओ࠵ऀͰ΍͍ͬͯͨ •

    ࢀՃऀͷΈͳ͞Μ͕ಡΜͩίʔυΛ·ͱΊͨͷ͕GitHubʹ·ͱ·ͬͯΔ • Կ͔ͷࢀߟʹͳΕ͹ͱʂ • https://github.com/AndroidFrameworkCodeReading/ CodeReadingHistory