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

Privacy Sandbox on Android / DroidKaigi 2024

7pairs
September 12, 2024

Privacy Sandbox on Android / DroidKaigi 2024

7pairs

September 12, 2024
Tweet

More Decks by 7pairs

Other Decks in Technology

Transcript

  1. ࣗݾ঺հ val speaker = Person( name = "長谷場 潤也 (HASEBA

    Junya)" sns = "7pairs" icon = AppCompatResources.getDrawable(context, R.drawable.tkg) company = "株式会社アイモバイル" job = "広告SDK (Android / iOS)" languages = setOf("Python", "Clojure") favorites = setOf("U-NEXT Pirates", "埼玉西武ライオンズ") )
  2. 1SJWBDZ4BOECPYͷ໨ඪ  Ϣʔβʔ の​ ϓϥΠόγʔอޢ を​ ڧԽ͠ た​ ৽ͨ な​

    ٕज़ の​ ߏங  ύϒϦογϟʔ や​ ։ൃऀ に​ Α る​ ແྉΦϯϥΠϯίϯςϯπఏڙ の​ ܧଓ  ۀք の​ օ༷ と​ ڞʹ ΠϯλʔωοτϢʔβʔ の​ ϓϥΠόγʔ を​ อޢ͢ る​ ৽ͨ な​ ج४ を​ ߏங ˞IUUQTQSJWBDZTBOECPYDPNJOUMKB@KQΑΓ
  3. 1SJWBDZ4BOECPYͷ໨ඪ  Ϣʔβʔ の​ ϓϥΠόγʔอޢ を​ ڧԽ͠ た​ ৽ͨ な​

    ٕज़ の​ ߏங  ύϒϦογϟʔ や​ ։ൃऀ に​ ΑΔແྉΦϯϥΠϯίϯςϯπఏڙ の​ ܧଓ  ۀք の​ օ༷ と​ ڞʹ ΠϯλʔωοτϢʔβʔ の​ ϓϥΠόγʔ を​ อޢ͢ る​ ৽ͨ な​ ج४ を​ ߏங ˞IUUQTQSJWBDZTBOECPYDPNJOUMKB@KQΑΓ
  4.  ແྉΦϯϥΠϯίϯςϯπఏڙͷܧଓ ‣ ίϯςϯπΛແྉͰఏڙ͢Δʹ͋ͨΓ޿ࠂ͸ॏཁͳ໾ׂΛՌͨ͢ ‣ ϢʔβʔͷϓϥΠόγʔΛอޢ͠ͳ͕Β ͜Ε·Ͱͱಉ౳ Ҏ্ ͷޮՌΛ্͛Δ޿ࠂ഑৴ͷ࢓૊ΈΛఏڙ͢Δ ‣

    8FC޿ࠂಛ༗ͷػೳ ޮՌͷଌఆ ύʔιφϥΠζͳͲ ͷͨΊʹ ϢʔβʔͷϓϥΠόγʔ͕ڴ͔͞Ε͔Ͷͳ͍ͷ͕ݱঢ় ‣ ୯ʹ޿ࠂ*%΍αʔυύʔςΟ$PPLJFΛഇࢭ͚ͨͩ͠Ͱ͸ ޮՌ͕Լ͕ͬͯίϯςϯπఏڙऀ΁ؐݩͰ͖Δརӹ͕ݮগ͢Δ
  5.  ۀքͷօ༷ͱڞʹ ‣ ఏҊஈ֊ͷ࢓༷Λެ։͍ͯ͠Δ ‣ ͦΕͧΕͷཱ৔͔ΒͷϑΟʔυόοΫΛ޿͘ื͍ͬͯΔ ‣ ΞϓϦσϕϩούʔ ޿ࠂΛදࣔͤͯ͞རӹΛಘΔཱ৔ 

    ‣ ޿ࠂ഑৴ࣄۀऀ ޿ࠂΛ഑৴͢Δཱ৔  ‣ ܭଌπʔϧࣄۀऀ ޿ࠂͷޮՌΛଌఆ͢Δཱ৔  ‣ ޿ࠂओ ޿ࠂΛग़ߘ͢Δཱ৔
  6. ొ৔ਓ෺঺հ ‣ ޿ࠂωοτϫʔΫ ‣ 8FC޿ࠂΛ഑৴͢Δࣄۀऀ ‣ ΞϓϦܭଌπʔϧ ‣ ޿ࠂओͷͨΊʹ޿ࠂؔ࿈ͷσʔλΛܭଌ ूܭ͢Δࣄۀऀ

    ‣ ૬ੑͷྑ͍޿ࠂΛબͿ࢓૊Έ ‣ ࢦఆ͞Εͨ৚݅ͷϢʔβʔͱ૬ੑͷྑ͍޿ࠂΛબͿγεςϜ ܈
  7. ޿ࠂ*%ͷऔಘᶃ ґଘؔ܎ͷ௥Ճ // dependenciesにGoogle Play Servicesの参照を追加する implementation "com.google.android.gms:play-services:+" // AD_IDのパーミッションを追加する

    <uses-permission android:name= "com.google.android.gms.permission.AD_ID" /> // 広告IDを取得する Thread(Runnable { val info = AdvertisingIdClient .getAdvertisingIdInfo(context) if (info != null && !info.isLimitAdTrackingEnabled) { val id = info.getId() // 広告IDを使った処理 } }).start() ‣ (PPHMF͕ఏڙ͍ͯ͠Δ (PPHMF1MBZ4FSWJDFTͷ ϥΠϒϥϦΛར༻͢Δ
  8. ޿ࠂ*%ͷऔಘᶄ ݖݶͷ௥Ճ // dependenciesにGoogle Play Servicesの参照を追加する implementation "com.google.android.gms:play-services:+" // AD_IDのパーミッションを追加する

    <uses-permission android:name= "com.google.android.gms.permission.AD_ID" /> // 広告IDを取得する Thread(Runnable { val info = AdvertisingIdClient .getAdvertisingIdInfo(context) if (info != null && !info.isLimitAdTrackingEnabled) { val id = info.getId() // 広告IDを使った処理 } }).start() ‣ "OESPJEҎ߱Ͱ͸ "OESPJE.BOJGFTUYNMʹ "%@*%ͷݖݶ͕ඞཁ ‣ ϢʔβʔʹΑΔ ࣮ߦ࣌ͷڐ୚͸ෆཁ
  9. ޿ࠂ*%ͷऔಘᶅ *%ͷऔಘॲཧ // dependenciesにGoogle Play Servicesの参照を追加する implementation "com.google.android.gms:play-services:+" // AD_IDのパーミッションを追加する

    <uses-permission android:name= "com.google.android.gms.permission.AD_ID" /> // 広告IDを取得する Thread(Runnable { val info = AdvertisingIdClient .getAdvertisingIdInfo(context) if (info != null && !info.isLimitAdTrackingEnabled) { val id = info.getId() // 広告IDを使った処理 } }).start() ‣ (PPHMF1MBZ4FSWJDFTͷ "EWFSUJTJOH*E$MJFOUΛ ར༻͢Δ
  10. 5PQJDT ‣ Ϣʔβʔͷڵຯʹ΋ͱ͍ͮͨ޿ࠂΛදࣔ͢ΔͨΊͷ࢓૊Έ ‣ ˞ ޿ࠂͷ஌͕ࣝ͋Δํ޲͚ͷઆ໌  ɹ޿ࠂ*%Λ࢖ΘͣʹΦʔσΟΤϯελʔήςΟϯάΛ࣮ݱ͢Δ ‣ σόΠε্ͰͷΞϓϦͷར༻ঢ়گʹ΋ͱ͍ͮͯ

    γεςϜʹΑͬͯʮτϐοΫʯ͕σόΠεʹׂΓ౰ͯΒΕΔ ‣ ޿ࠂͷϦΫΤετʹτϐοΫͷ৘ใΛ௥Ճ͢Δ͜ͱͰ ౰֘τϐοΫͱؔ࿈ੑͷߴ͍޿ࠂΛ഑৴͢Δ
  11. τϐοΫͱ͸ʁ ‣ Ϣʔβʔ͕ڵຯΛ͍࣋ͬͯΔର৅Λ͋ΒΘ͢ΧςΰϦ ‣ ෼ྨ͸ެ։͞Ε͓ͯΓશछྨ ೥݄ݱࡏ  ‣ IUUQTHJUIVCDPNQSJWBDZTBOECPYUPQJDTBOESPJE ‣

    ਓछ΍ੑผͳͲͷσϦέʔτͳ෼ྨ͸ଘࡏ͠ͳ͍ ‣ γεςϜʹΑͬͯσόΠε಺෦ͰׂΓ౰ͯΒΕఆظతʹߋ৽͞ΕΔ ‣ ϢʔβʔʹΑΔ֬ೝ ࡟আ͕Մೳ
  12. 1SPUFDUFE"VEJFODF"1*ͷߏ੒ཁૉ ‣ $VTUPN"VEJFODF"1* ‣ ΧελϜΦʔσΟΤϯεΛఆٛ͢ΔͨΊͷ"1* ‣ ར༻͢Δͷ͸޿ࠂओ ͷΞϓϦ  ‣

    "E4FMFDUJPO"1* ‣ ΧελϜΦʔσΟΤϯεͱ૬ੑͷྑ͍޿ࠂΛબఆ͢ΔͨΊͷ"1* ‣ ར༻͢Δͷ͸޿ࠂ4%,
  13. "UUSJCVUJPO3FQPSUJOH ‣ ޿ࠂͷޮՌΛଌఆ͢ΔͨΊͷ࢓૊Έ ‣ ΫϦοΫ΍ίϯόʔδϣϯ ॳճىಈ ߪೖ ՝ۚͳͲ ͷ ൃੜ࣌ʹ౰֘ΠϕϯτΛσόΠε্Ͱه࿥͢Δ

    ‣ ΫϦοΫͱίϯόʔδϣϯͷ৘ใ͸σόΠεͷ಺෦Ͱ݁ͼ͚ͭΒΕΔ ‣ ूܭ͢Δ୯Ґ΍ཻ౓ͷҟͳΔ &WFOUMFWFMSFQPSUTͱ"HHSFHBUBCMFSFQPSUTͷ छྨͷϨϙʔτ͕͋Δ
  14. Կ͕໰୊ͳͷ͔ʁ ‣ ηΩϡϦςΟ໘ͷ໰୊ ‣ 4%,͸ݺͼग़͠ݩͷΞϓϦ ͷҰ෦ ͱͯ͠ ৼΔ෣͏͜ͱ͕Ͱ͖ͯ͠·͏ ‣ ҆ఆੑͷ໰୊

    ‣ ΞϓϦͱ4%,͕ಉҰϓϩηε্Ͱಈ࡞͍ͯ͠ΔͨΊ 4%,ͷڍಈ͕ΞϓϦʹӨڹΛٴ΅͢͜ͱ͕͋Δ ͋Δ͍͸ͦͷٯ
  15. MPBE4EL  ࣮૷αϯϓϧᶃ // SdkSandboxManagerを取得する val manager = applicationContext.getSystemService( SdkSandboxManager::class.java

    ) // SDKの読み込みを要求する manager.loadSdk( "com.example.adnetwork", Bundle(), { obj: Runnable -> obj.run() }, object : OutcomeReceiver<SandboxedSdk, LoadSdkException> { override fun onResult(sandboxedSdk: SandboxedSdk) { mSandboxedSdk = sandboxedSdk } override fun onError(error: LoadSdkException) {} } ) // SDKを呼び出す // (※IAdNetworkSdkがAIDLで定義されているものとする) val binder: IBinder? = mSandboxedSdk.getInterface() val adNetworkSdk = IAdNetworkSdk.Stub.asInterface(binder) adNetworkSdk.showAd() ‣ HFU4ZTUFN4FSWJDF Ͱ 4EL4BOECPY.BOBHFSΛ औಘ͢Δ
  16. MPBE4EL  ࣮૷αϯϓϧᶄ // SdkSandboxManagerを取得する val manager = applicationContext.getSystemService( SdkSandboxManager::class.java

    ) // SDKの読み込みを要求する manager.loadSdk( "com.example.adnetwork", Bundle(), { obj: Runnable -> obj.run() }, object : OutcomeReceiver<SandboxedSdk, LoadSdkException> { override fun onResult(sandboxedSdk: SandboxedSdk) { mSandboxedSdk = sandboxedSdk } override fun onError(error: LoadSdkException) {} } ) // SDKを呼び出す // (※IAdNetworkSdkがAIDLで定義されているものとする) val binder: IBinder? = mSandboxedSdk.getInterface() val adNetworkSdk = IAdNetworkSdk.Stub.asInterface(binder) adNetworkSdk.showAd() ‣ MPBE4EL Λݺͼग़͢ ‣ Ҿ਺ͷίʔϧόοΫͰ 4BOECPYFE4ELΛ ड͚औΔ͜ͱ͕Ͱ͖Δ
  17. MPBE4EL  ࣮૷αϯϓϧᶅ // SdkSandboxManagerを取得する val manager = applicationContext.getSystemService( SdkSandboxManager::class.java

    ) // SDKの読み込みを要求する manager.loadSdk( "com.example.adnetwork", Bundle(), { obj: Runnable -> obj.run() }, object : OutcomeReceiver<SandboxedSdk, LoadSdkException> { override fun onResult(sandboxedSdk: SandboxedSdk) { mSandboxedSdk = sandboxedSdk } override fun onError(error: LoadSdkException) {} } ) // SDKを呼び出す // (※IAdNetworkSdkがAIDLで定義されているものとする) val binder: IBinder? = mSandboxedSdk.getInterface() val adNetworkSdk = IAdNetworkSdk.Stub.asInterface(binder) adNetworkSdk.showAd() ‣ 4BOECPYFE4EL͔Β *#JOEFSΛऔಘ͢Δ ‣ औಘͨ͠*#JOEFSΛ 4%,ͷΠϯλʔϑΣΠεʹ ม׵͔ͯ͠Βૢ࡞͢Δ
  18. 4VSGBDF1BDLBHF ࣮૷αϯϓϧᶃ // SdkSandboxManagerを取得する val manager = applicationContext.getSystemService( SdkSandboxManager::class.java )

    // SurfacePackageを要求する Handler(Looper.getMainLooper()).post { val params = Bundle() params.putInt(EXTRA_WIDTH_IN_PIXELS, mClientView.getWidth()) params.putInt(EXTRA_HEIGHT_IN_PIXELS, mClientView.getHeight()) params.putInt(EXTRA_DISPLAY_ID, getDisplay()?.getDisplayId()!!) params.putBinder(EXTRA_HOST_TOKEN, mClientView.getHostToken()) manager.requestSurfacePackage( "com.example.adnetwork", params, { obj: Runnable -> obj.run() }, object : OutcomeReceiver<Bundle?, RequestSurfacePackageException?> { override fun onResult(response: Bundle) { Handler(Looper.getMainLooper()).post { val surfacePackage: SurfacePackage? = response.getParcelable( EXTRA_SURFACE_PACKAGE, SurfacePackage::class.java) mClientView.setChildSurfacePackage(surfacePackage!!) mClientView.setVisibility(View.VISIBLE) } } override fun onError(error: RequestSurfacePackageException) {} } ) } ‣ HFU4ZTUFN4FSWJDF Ͱ 4EL4BOECPY.BOBHFSΛ औಘ͢Δ
  19. 4VSGBDF1BDLBHF ࣮૷αϯϓϧᶄ // SdkSandboxManagerを取得する val manager = applicationContext.getSystemService( SdkSandboxManager::class.java )

    // SurfacePackageを要求する Handler(Looper.getMainLooper()).post { val params = Bundle() params.putInt(EXTRA_WIDTH_IN_PIXELS, mClientView.getWidth()) params.putInt(EXTRA_HEIGHT_IN_PIXELS, mClientView.getHeight()) params.putInt(EXTRA_DISPLAY_ID, getDisplay()?.getDisplayId()!!) params.putBinder(EXTRA_HOST_TOKEN, mClientView.getHostToken()) manager.requestSurfacePackage( "com.example.adnetwork", params, { obj: Runnable -> obj.run() }, object : OutcomeReceiver<Bundle?, RequestSurfacePackageException?> { override fun onResult(response: Bundle) { Handler(Looper.getMainLooper()).post { val surfacePackage: SurfacePackage? = response.getParcelable( EXTRA_SURFACE_PACKAGE, SurfacePackage::class.java) mClientView.setChildSurfacePackage(surfacePackage!!) mClientView.setVisibility(View.VISIBLE) } } override fun onError(error: RequestSurfacePackageException) {} } ) } ‣ SFRVFTU4VSGBDF1BDLBHF ʹ 4VSGBDF7JFXͷαΠζ *%  )PTU5PLFOΛ౉͢
  20. 4VSGBDF1BDLBHF ࣮૷αϯϓϧᶅ // SdkSandboxManagerを取得する val manager = applicationContext.getSystemService( SdkSandboxManager::class.java )

    // SurfacePackageを要求する Handler(Looper.getMainLooper()).post { val params = Bundle() params.putInt(EXTRA_WIDTH_IN_PIXELS, mClientView.getWidth()) params.putInt(EXTRA_HEIGHT_IN_PIXELS, mClientView.getHeight()) params.putInt(EXTRA_DISPLAY_ID, getDisplay()?.getDisplayId()!!) params.putBinder(EXTRA_HOST_TOKEN, mClientView.getHostToken()) manager.requestSurfacePackage( "com.example.adnetwork", params, { obj: Runnable -> obj.run() }, object : OutcomeReceiver<Bundle?, RequestSurfacePackageException?> { override fun onResult(response: Bundle) { Handler(Looper.getMainLooper()).post { val surfacePackage: SurfacePackage? = response.getParcelable( EXTRA_SURFACE_PACKAGE, SurfacePackage::class.java) mClientView.setChildSurfacePackage(surfacePackage!!) mClientView.setVisibility(View.VISIBLE) } } override fun onError(error: RequestSurfacePackageException) {} } ) } ‣ SFRVFTU4VSGBDF1BDLBHF ͷ ίʔϧόοΫͰ 4VSGBDF1BDLBHFΛड͚औΓ ΞϓϦ಺ͷ4VSGBDF7JFXͷ DIJMEͱͯ͠ઃఆ͢Δ
  21. ͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ ‣ ࢀߟࢿྉ ‣ "OESPJE޲͚ の​ ϓϥΠόγʔαϯυϘοΫε ‣ IUUQTQSJWBDZTBOECPYDPNJOUMKB@KQBOESPJE ‣

    ϓϥΠόγʔαϯυϘοΫεͷಈըϥΠϒϥϦ ‣ IUUQTEFWFMPQFSTHPPHMFDPNQSJWBDZTBOECPYSFTPVSDFTWJEFPT IMKB ‣ 4%,3VOUJNFBOE1SJWBDZ1SFTFSWJOH"1*T3FQPTJUPSZ ‣ IUUQTHJUIVCDPNBOESPJEQSJWBDZTBOECPYTBNQMFT