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

Systemアプリ開発入門

Df866cf39671a846639b2d2011b1dca8?s=47 kobashin
March 10, 2017

 Systemアプリ開発入門

DroidKaigi 2017 Day2 14:20 - 14 : 50 のセッションです

Df866cf39671a846639b2d2011b1dca8?s=128

kobashin

March 10, 2017
Tweet

Transcript

  1. SystemΞϓϦ։ൃೖ໳ DroidKaigi 2017 Day 2 14:20 - 14:50 kobashin

  2. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 2 ͜ͷεϥΠυʹ͍ͭͯ https://goo.gl/cj9AXW ∠ Լʹஔ͍ͯ·͢ ݟ͑ʹ͍͘ͱ͜Ζ΋͋Δͱࢥ͏ͷͰ ݟͳ͕ΒͲ͏ͧ

  3. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 3 ࣗݾ঺հ Shinji Kobayashi (@kobashinG) Androidͱ͸2009ೖࣾҎདྷͷ෇͖߹͍
 ΞϓϦΑΓFramework૚ͷ࢓ࣄ͕ଟΊ

  4. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 4 ࠓ೔͓࿩͢Δ͜ͱ 1. SystemΞϓϦͱύʔϛογϣϯ 2. SystemΞϓϦͱϚϧνϢʔβʔ 3.

    SystemΞϓϦͱ։ൃ؀ڥ ͓·͚ʹ͍ۙ
  5. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 5 λʔήοτ • SystemΞϓϦΛ։ൃͨ͜͠ͱ͕ແ͍ • platformॺ໊ͷཁෆཁʹ໎ͬͨ͜ͱ͕͋Δ
 ͱΓ͋͑ͣॺ໊͚ͭͱ͚

    • SystemΞϓϦͰϚϧνϢʔβʔαϙʔτ
 Λ͍ͨ͠
  6. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 6 ஫ҙࣄ߲ • ຊ೔͓࿩͢Δ͜ͱ͸ɺandroid-7.1.1_r13
 Λϕʔεʹ͍ͯ͠·͢ • ಈ࡞֬ೝʹ͸Nexus6Λར༻


    Tablet-UI, Restricted profileͷ֬ೝ༻ʹ
 গ͠ROMΛ࿔ͬͯ·͢
  7. 1 SystemΞϓϦͱύʔϛογϣϯ ∠

  8. SystemΞϓϦͱ͸ʁ

  9. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 9 AndroidʹΠϯετʔϧ͞Ε͍ͯΔΞϓϦ # # # # GooglePlay

    ౳͔Β SystemΞϓϦʹ୺຤ʹϓϦΠϯ
  10. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 10 AndroidʹΠϯετʔϧ͞Ε͍ͯΔΞϓϦ • System.imgʹؚ·Εͳ͍௨ৗͷΞϓϦ • System.imgʹؚ·ΕΔΞϓϦ •

    PrivilegedΞϓϦ • sharedUserId=“android.uid.xxxx” • ಛఆͷॺ໊෇͖ΞϓϦ • etc… SystemΞϓϦ
  11. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 11 ௨ৗͷΞϓϦͱSystemΞϓϦͱͷҧ͍ • ύʔϛογϣϯϞσϧʹΑΓ੍ݶ͞Εͨ
 APIͷར༻ • @hide

    API, @systemApiͷར༻ • ಉuid͔ΒͷΈͷΞΫηεՄAPIͷར༻ $ Πϯετʔϧख๏ʹΑΓݖݶ͕ҟͳΔ ∠
  12. ύʔϛογϣϯϞσϧ

  13. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 13 ύʔϛογϣϯϞσϧ • ΞϓϦ͕อ࣋͢ΔύʔϛογϣϯͷΈ
 ΞϓϦαϯυϘοΫε֎ͷϦιʔε΁ͷ
 ΞΫηε΁ڐՄΛ༩͑Δ MyApp

    INTERNET # % & device API INTERNET CAMERA CAMERA
  14. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 14 protectionLevel = BasicProtection | AdditionalFlag ex.

    signatureOrSystem = signature | privileged ϓϩςΫγϣϯϨϕϧ + permission: a.p.WRITE_MEDIA_STORAGE package: android label: null description: null protectionLevel: signature|privileged
  15. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 15 Basic Protection Type ֓ཁɺڐՄ৚݅ normal ௿ϦεΫ

    dangerous Ϣʔβͷݸਓ৘ใ΍อଘσʔλ΁ ͷΞΫηε͕ൃੜ͢Δ signature ύʔϛογϣϯͷఆٛऀͱಉ͡ॺ ໊Λ࣋ͭΞϓϦ signatureOrSystem signatureݖݶɺSystemΞϓϦ
  16. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 16 Additional Flag ֓ཁɺڐՄ৚݅ privileged(system) /system/priv-app ҎԼʹΠϯετʔϧ

    ͞ΕͨΞϓϦ development ༧ΊڐՄ͍ͯ͠ͳ͍ͱڐՄͰ͖ͳ͍ installer Intent.ACTION_INSTALL_PACKAGEʹ ൓Ԡ͢ΔActivityΛ࣋ͭΞϓϦ appop AppOpsͰ؅ཧ͞Ε͍ͯΔύʔϛογ ϣϯ
  17. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 17 Additional Flag ֓ཁɺڐՄ৚݅ pre23 targetSdkVersion <

    23 verifier Intent.ACTION_PACKAGE_NEEDS_VER IFICATIONʹ൓ԠͰ͖ΔActivityΛ࣋ͭ setup Intent.CATEGORY_SETUP_WIZARDʹ ൓ԠͰ͖ΔActivityΛ࣋ͭ preinstalled γεςϜΠϝʔδʹؚ·ΕΔશͯͷΞ ϓϦ
  18. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 18 ͨͱ͑͹ • FactoryResetػೳΛ࣋ͭ • ୺຤ΛεϦʔϓঢ়ଶʹ͢ΔػೳΛ࣋ͭ

  19. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 19 APIΛ୳͢ • ྨࣅΞϓϦ͔ΒAPIΛ୳͢ • SettingsΞϓϦ͕࣋ͬͯΔ •

    ֘౰Օॴͷιʔε͔ΒAPIΛݟ͚ͭΔ private void doMasterClear() {
 Intent intent = new Intent(Intent.ACTION_MASTER_CLEAR);
 intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
 intent.putExtra(Intent.EXTRA_REASON, "MasterClearConfirm");
 intent.putExtra(Intent.EXTRA_WIPE_EXTERNAL_STORAGE, mEraseSdCard);
 getActivity().sendBroadcast(intent);
 // Intent handling is asynchronous -- assume it will happen soon.
 }
 MasterClearConfirm.java
  20. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 20 APIຖͷύʔϛογϣϯΛ֬ೝ <receiver android:name="com.android.server.MasterClearReceiver"
 android:permission="android.permission.MASTER_CLEAR">
 <intent-filter
 android:priority="100"

    >
 <!-- For Checkin, Settings, etc.: action=MASTER_CLEAR -->
 <action android:name="android.intent.action.MASTER_CLEAR" />
 AndroidManifest.xml ୺຤ΛFactoryReset͢ΔAPI͸ ʮMASTER_CLEARʯ͕ඞཁ
  21. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 21 permissionͷprotectionLevelΛ֬ೝ $ adb shell pm list

    permissions -f + permission:android.permission.MASTER_CLEAR package:android label:null description:null protectionLevel:signature|privileged ʮMASTER_CLEARʯ-> signature | privileged ॺ໊ or /system/priv-app ΁Πϯετʔϧඞཁ
  22. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 22 ͨͱ͑͹ • FactoryResetػೳΛ࣋ͭ • ୺຤ΛεϦʔϓঢ়ଶʹ͢ΔػೳΛ࣋ͭ

  23. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 23 APIΛ୳͢ • XXManager͔ΒAPIΛ୳͢ • ֘౰Օॴͷιʔε͔ΒAPIΛݟ͚ͭΔ /**


    * Forces the device to go to sleep.
 * 
 * Requires the {@link android.Manifest.permission#DEVICE_POWER} * permission.
 * 
 * @hide Requires signature permission.
 */
 public void goToSleep(long time, int reason, int flags) {
 PowerManager.java
  24. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 24 APIຖͷύʔϛογϣϯΛ֬ೝ /**
 * Forces the device

    to go to sleep.
 * 
 * Requires the {@link android.Manifest.permission#DEVICE_POWER} * permission.
 * 
 * @hide Requires signature permission.
 */
 public void goToSleep(long time, int reason, int flags) {
 PowerManager.java ୺຤ΛSleepঢ়ଶ΁Ҡߦ͢ΔAPI͸ ʮDEVICE_POWERʯ͕ඞཁ
  25. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 25 permissionͷprotectionLevelΛ֬ೝ $ adb shell pm list

    permissions -f + permission:android.permission.DEVICE_POWER package:android label:null description:null protectionLevel:signature ʮDEVICE_POWERʯ-> signature͕ඞཁ
 platformॺ໊͕ඞཁ
  26. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 26 SystemΞϓϦͱύʔϛογϣϯ • ඞཁͳػೳʹ߹Θͤύʔϛογϣϯͷ
 protectionLevelΛ֬ೝ㱺ඞཁͳݖݶΛ෇༩ • AdditionalFlagͷৄࡉ͸ɺԼهॲཧ෦͕


    Θ͔Γ΍͍͢ • PackageManagerService.grantSignaturePermission()
  27. signature + android.uid.system

  28. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 28 sharedUserId=“android.uid.system” • uidΛݻఆԽʢuid = 1000ʣ •

    uid.system͕࣋ͭϦιʔε΁ͷΞΫηε • Ұ෦੍ݶAPIΛར༻Մೳʹ • platformॺ໊ඞཁ • ҰํɺWebView͕ར༻ෆՄೳʹ
  29. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 29 uidʹΑ੍ͬͯݶ͞ΕΔAPI /**
 * Validate a user-supplied

    password string with cryptfs
 */
 @Override
 public int verifyEncryptionPassword(String password) throws RemoteException {
 // Only the system process is permitted to validate passwords
 if (Binder.getCallingUid() != android.os.Process.SYSTEM_UID) {
 throw new SecurityException("no permission to access the crypt keeper");
 } MountService.java ҉߸ԽFSͷύεϫʔυνΣοΫAPI
  30. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 30 uidʹΑ੍ͬͯݶ͞ΕΔAPI final int uid = android.os.Process.myUid();


    if (uid == android.os.Process.ROOT_UID || uid == android.os.Process.SYSTEM_UID) {
 throw new UnsupportedOperationException(
 "For security reasons, WebView is not allowed in privileged processes");
 } WebViewFactory.java ٯʹandroid.uid.systemͱ͢Δ͜ͱͰWebview ͸ར༻Ͱ͖ͳ͘ͳΔ
  31. ·ͱΊ

  32. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 32 privileged? APIݕ౼ ҰൠAPP signature? uid? priv-app

    signature sharedUid SystemΞϓϦͱύʔϛογϣϯ YES NO NO YES YES NO
  33. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 33 SystemΞϓϦͱύʔϛογϣϯ • API͸ྨࣅΞϓϦ or XXManager͔Β୳͢ •

    Platformॺ໊͕ඞཁ͔Ͳ͏͔ • ԿͰ΋͚ͭΕ͹ྑ͍ͬͯ΋ͷͰ΋ແ͍ • uid.system͸੍ݶ΋͋Δ͜ͱʹ஫ҙ Point
  34. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 34 SystemΞϓϦͱύʔϛογϣϯ • Platformॺ໊Ҏ֎ʹ΋UICCอଘॺ໊ͱ
 Ұக͠ͳ͚Ε͹ར༻ෆՄAPI΋ଘࡏ͢Δ
 TelephonyManager.*ͱ͔ •

    ΞοϓσʔτͷΞϯΠϯετʔϧ͕Մೳ • /system/appͷΞϓϦ΁μ΢ϯάϨʔυ • migrationରԠΘ͢Εͣʹ
  35. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 35 SystemΞϓϦͱΞοϓσʔτ • ΞοϓσʔτࡁΈͷSystemΞϓϦ͔Ͳ͏͔
 ͸্هAPIͰ֬ೝՄೳ /**
 *

    @hide
 */
 public boolean isUpdatedSystemApp() {
 return (flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0;
 } ApplicationInfo.java
  36. 2 SystemΞϓϦͱϚϧνϢʔβʔ ∠

  37. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 37 ϚϧνϢʔβʔ͓͞Β͍ Tablet • from 4.2 •

    Restricted Profile Hand Set ※ݫີʹ͸Voice capableʹର Ԡ͍ͯ͠Δ͔Ͳ͏͔ • from 5.0
  38. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 38 ΞϓϦͷΠϯετʔϧͷ͞Εํ /data/user/ 0 10 11 •

    Owner User • /data/data/ ΁ͷSymbolic Link • New User • New Profile $ ΞϓϦέʔγϣϯσʔλ͸Ϣʔβʔຖʹಠཱ
  39. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 39 ϢʔβʔؒͰσʔλڞ༗͍ͨ͠ • ΞϓϦσʔλ/EXTERNAL STORAGE σʔλڞʹϢʔβʔຖʹഉଞ •

    ઃఆҾ͖ܧ͗ • ϢʔβʔຖʹৼΔ෣͍Λมߋ͍ͨ͠ service, receiverΛʮSingleton Componentʯʹ ∠
  40. Singleton Component

  41. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 41 MyApp uid=0 MyApp uid=10 Activity Service

    singleUser Activity Singleton Component service, receiver΁singleUse=“true”Λઃఆ uid=0 ͷcomponentΛSingletonͱͯ͠ར༻
  42. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 42 ϚϧνϢʔβʔૢ࡞ʹඞཁͳॺ໊ • INTERACT_ACROSS_USER • signature |

    privilege • Ϣʔβʔૢ࡞Ұൠʹඞཁ • INTERACT_ACROSS_USER_FULL • signature • ଞϢʔβʔͷActivityىಈ
 ଞϢʔβʔͷContentObserverొ࿥ͳͲ
  43. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 43 Singleton Component <service
 android:name=".MultiUserSingletonService"
 android:enabled="true"
 android:exported="true"


    android:singleUser="true" /> <receiver
 android:name=".MyReceiver"
 android:enabled="true"
 android:exported="true"
 android:singleUser="true">
 
 AndroidManifest.xml
  44. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 44 Singleton Component @Override
 public int sampleAidlApi()

    throws RemoteException {
 File file = getFilesDir(); // ͲͷϢʔβ͔ΒͰ΋ /data/user/0/xxx.xxx.xxx/files
 Log.i(TAG, "filesDir: " + file.getAbsolutePath());
 
 SampleService.java
  45. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 45 Singleton Component಺ͰϢʔβʔνΣοΫ • UserHandle.getCallingUserId() • Binderܦ༝ͷAPIΞΫηεݩUIDΛऔಘ

    • UserManager.getUserInfo() • ֤Ϣʔβʔͷৄࡉ৘ใΛऔಘ
  46. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 46 Singleton Component @Override
 public int sampleAidlApi()

    throws RemoteException {
 if( UserHandle.USER_SYSTEM == getCallingUserId()){
 // USER_SYSTEM (uid == 0)
 } else {
 // other user (uid != 0)
 UserManager userManager = (UserManager) getSystemService(USER_SERVICE);
 UserInfo userInfo = ɹuserManager.getUserInfo(getCallingUserId());
 // ֤ϢʔβຖͷInfo UserInfo{10:New user:10} Log.i(TAG, "UserInfo " + userInfo.toString());
 }
 SampleService.java
  47. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 47 ϢʔβʔຖͷComponentΛىಈ͢Δ • startActivityAsUser(Intent, UserHandle) • UserΛࢦఆ͠ActivityΛىಈ

    • ֤ίϯϙʔωϯτ༻ʹAsUser API͕ଘࡏ • ޡͬͨActivityΛىಈ͠Α͏ͱͨ͠৔߹
 SecurityException͕ൃੜ͢Δ
  48. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 48 Singleton Component @Override
 public int sampleAidlApi()

    throws RemoteException {
 // loginதϢʔβʔͷActivityىಈ Intent intent = new Intent();
 intent.setClass(MultiUserSingletonService.this, MainActivity.class);
 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
 startActivityAsUser(intent, UserHandle.CURRENT); // uid=0ϢʔβʔͷServiceىಈ(SYSTEM=OWNER) startServiceAsUser(intent, UserHandle.SYSTEM);
 
 
 SampleService.java
  49. SystemΞϓϦ ͱ Restricted Profile

  50. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 50 Restricted Profile • ੍ݶϢʔβʔʹ͸ɺΞϓ ϦέʔγϣϯͷڐՄঢ় ଶΛઃఆͰ͖Δ

    • Intent.ACTION_GET_RES TRICTION_ENTRIESʹΑ Γ੍ݶ಺༰Λݸผʹઃ ఆͰ͖Δ
  51. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 51 SystemΞϓϦͱRestricted Profile • SystemΞϓϦͷදࣔ৚݅ • ॺ໊༗Γ͸ඇදࣔ

    • platformॺ໊ແ͠͸දࣔ • platformॺ໊༗Γʴɹ Intent.ACTION_GET_REST RICTION_ENTRIESΛड৴ ͢ΔReceiver࣮૷
  52. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 52 ະॺ໊ platformॺ໊ platformॺ໊ has receiver දࣔঢ়ଶ

    දࣔ ඇදࣔ දࣔ + ' SystemΞϓϦͱRestricted Profile • platformॺ໊࣋ͪͷ৔߹͸ON/OFFઃఆͰ͖ͳ͍
 ৄࡉઃఆΛߦ͏ͨΊʹ Intent.ACTION_GET_RESTRICTION_ENTRIESΛϋϯυϧ͢Δ
  53. ·ͱΊ

  54. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 54 SystemΞϓϦͱϚϧνϢʔβʔ • جຊҰൠΞϓϦͱมΘΒͳ͍ • ϢʔβʔؒͰσʔλڞ༗ɺϢʔβʔຖͷڍಈมߋ
 ɹ㱺singleUserͷservice,

    receiverΛར༻͢Δ • Restricted Profile͸ॺ໊༗ແͰڍಈมߋ͋Γ
 ඞཁʹԠ͡ACTION_GET_RESTRICTION_ENTRIESͷ
 ࣮૷ݕ౼Λʢ࣮૷಺༰͸ҰൠΞϓϦͱಉ౳ʣ
  55. 3 SystemΞϓϦͱ։ൃ؀ڥ ∠

  56. SystemΞϓϦ ʴ Android Studio

  57. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 57 AndroidSDKͷ࣋ͨͳ͍APIΛར༻͢Δ • AndroidSDKͷ࣋ͨͳ͍APIΛར༻
 ɹ㱺௨ৗͷ؀ڥͩͱࢀরΤϥʔൃੜ • AOSPϏϧυ؀ڥͰϏϧυඞཁ


    㱺IDE͕ར༻Ͱ͖ͳ͍໰୊
 ʢEclipse༻ͷαϙʔτϖʔδ͸͕͋ͬͨɺ
 ɹAndroid Studio༻͸ແ͍ΑͶʁʣ
  58. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 58 AndroidSDKͷ࣋ͨͳ͍APIΛར༻͢Δ 1. AOSPͷϏϧυʢframework.jarੜ੒ʣ 2. framework.jarΛϥΠϒϥϦͱͯ͠ొ࿥ 3.

    ϏϧυΤϥʔճආͷͨΊbuild.gradleมߋ 4. ॺ໊͕ඞཁͰ͋Ε͹෇༩͢Δ
  59. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 59 2. framework.jarΛϥΠϒϥϦͱͯ͠ొ࿥ 1. out/target/common/obj/JAVA_LIBRARIES/ framework_intermediates/classes.jar 


    Λίϐʔˍϖʔετ
  60. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 60 2. framework.jarΛϥΠϒϥϦͱͯ͠ొ࿥ 2. apkʹؚΊͳ͍Α͏ʹprovidedͰಡΈࠐΉ dependencies {


    // build pathʹframework.jarΛؚΊΔɻAPKʹ͸ؚΊͳ͍
 provided fileTree(dir: 'framework', include: ['*.jar']) }
  61. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 61 3. ϏϧυΤϥʔճආͷͨΊbuild.gradleมߋ • Editor͸app.imlͷϥΠϒϥϦΛ্͔Βϩʔυ
 ͠ࢀরΛղܾ͢Δ •

    framework.jarΛSDKΑΓ΋্ʹมߋ • build.gradleʹtaskॻ͍͓ͯ͘ͱศར
  62. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 62 import groovy.xml.*
 task changeOrderEntry {
 def

    iml = file("app.iml")
 def doc = (new XmlParser()).parse(iml);
 def deleteNode = doc.component[1].orderEntry.find { it.@type == "jdk" }
 
 def _type = deleteNode.@type
 def _jdkName = deleteNode.@jdkName
 def _jdkType = deleteNode.@jdkType
 
 doc.component[1].remove(deleteNode)
 new Node(doc.component[1], 'orderEntry', ['type': _type, 'jdkName': _jdkName, 'jdkType': _jdkType])
 
 iml.text = XmlUtil.serialize(doc)
 }
 preBuild.dependsOn(changeOrderEntry) 3. ϏϧυΤϥʔճආͷͨΊbuild.gradleมߋ
  63. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 63 tasks.withType(JavaCompile) {
 options.compilerArgs.add('-Xbootclasspath/p:app/framework/ framework.jar')
 }
 3.

    ϏϧυΤϥʔճආͷͨΊbuild.gradleมߋ • packageੜ੒࣌ʹBuildPathʹׂΓࠐΉʹ͸
 -Xbootclasspath/p: Λར༻͢Δ
  64. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 64 4. ॺ໊͕ඞཁͳΒ෇༩͢Δ • debugॺ໊͸ build/target/product/security •

    keytool-importkeypair • https://github.com/getfatday/keytool-importkeypair signingConfigs {
 debug {
 storeFile file(“/path/to/debug.keystore")
 storePassword "android"
 keyAlias "platform"
 keyPassword "android"
 }
 }

  65. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 65 AndroidSDKͷ࣋ͨͳ͍APIΛར༻͢Δ • priv-app΁ͷΠϯετʔϧ͸ผ్ඞཁ • ࠷ۙͷfirm͸dm-verity͕̤̣ͳͷͰ
 `adb

    disable-verity; adb reboot;` Λ๨Εͣʹ • SDKͷjarΛฤू͢Δํ๏ͩͱɺ
 :app:mockableAndroidJar TaskͰΤϥʔൃੜ
  66. debugging framework

  67. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 67 Debugging AOSP Source 1. user-debugͷ࣮ػΛ༻ҙ 2.

    AOSPͷϏϧυ 3. ./development/tools/idegen/intellij-gen.sh
 ͰϓϩδΣΫτͷiprΛ࡞੒ 4. DDMSىಈ 5. studioͰಡΈࠐΈ & debug࣮ߦ
  68. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 68 
 $ ./development/tools/idegen/intellij-gen.sh \ packages/apps/Settings $

    monitor
 iprͷ࡞੒ͱDDMSͷىಈ • intellij-gen.shΛར༻͠iprΛ࡞੒ • idegen.shͰ΋ߏΘͳ͍͕AOSPશମ͸ϝϞϦෛՙ • DDMS͕port:8700ͰσόΠεͱ௨৴
 ಉportͰAndroid StudioͰremote઀ଓ͢Δ
  69. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 69 DDMSͰΞλον͢ΔϓϩηεΛબ୒

  70. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 70 Edit ConfigurationͰRemote DebugΛ௥Ճ Port:8700Λࢦఆ

  71. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 71 SettingsΞϓϦͷσόοά

  72. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 72 Debugging AOSP Source • Step࣮ߦ౳΋ࣗ༝ʹͰ͖ΔͷͰɺAOSPͷ
 ιʔεΛಡΉͱ͖ͷखॿ͚ʹ

    • DDMSͷىಈॱʹΑͬͯ͸8700Ͱ઀ଓ
 Ͱ͖ͳ͍ͱ͖΋͋ΔͷͰ஫ҙ
  73. ·ͱΊ

  74. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 74 ·ͱΊ • Ϗϧυ͸ίϚϯυϥΠϯͰӡ༻͸ਏ͍ • AOSPͷιʔεΛಡΉ؀ڥͱͯ͠1ͭ༻ҙ
 ͓ͯ͘͠ͱίʔυϦʔσΟϯάḿΔ


    ʢIntellijͷBookmarkػೳͱ͔௒ศར͡Όͳ͍Ͱ͔͢ʣ
  75. SystemΞϓϦ։ൃೖ໳ ! @kobashinG 75 ͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠