From 5b16c748ba55c4cfdeb64d2c37ef19e2f8185f30 Mon Sep 17 00:00:00 2001 From: Jasmine Cha Date: Thu, 4 Jul 2024 12:40:45 +0000 Subject: [PATCH 01/12] audio: support spatial audio on speaker-safe Flag: EXEMPT bugfix Bug: 349953895 Test: manual test Change-Id: I8fea55fc023ce6ee6ca1d5641695d0b6b0d34fda Signed-off-by: Jasmine Cha --- audio/tangorpro/config/audio_policy_configuration.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/audio/tangorpro/config/audio_policy_configuration.xml b/audio/tangorpro/config/audio_policy_configuration.xml index 2d1b259..695e2c6 100644 --- a/audio/tangorpro/config/audio_policy_configuration.xml +++ b/audio/tangorpro/config/audio_policy_configuration.xml @@ -187,7 +187,7 @@ + sources="primary output,deep buffer,raw,compressed_offload,mmap_no_irq_out,voip_rx,ultrasound output,immersive_out"/> Date: Thu, 25 Jul 2024 20:28:54 +0000 Subject: [PATCH 02/12] Adpf:tangorpro: switch to multitier heuristic boost. Bug: 344685639 Test: Checked the trace file running on the device. Flag: NONE powerhal doesn't have a flag yet Change-Id: I934a7763c480a6cd46e98ba6020c5ac29cb7587c --- powerhint.json | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/powerhint.json b/powerhint.json index 79e1c35..c503010 100644 --- a/powerhint.json +++ b/powerhint.json @@ -1894,11 +1894,12 @@ "TargetTimeFactor": 1.0, "StaleTimeFactor": 15.0, "HeuristicBoost_On": true, - "HBoostOnMissedCycles": 8, - "HBoostOffMaxAvgRatio": 4.0, - "HBoostOffMissedCycles": 5, - "HBoostPidPuFactor": 0.5, - "HBoostUclampMin": 722, + "HBoostModerateJankThreshold": 2, + "HBoostOffMaxAvgDurRatio": 4.0, + "HBoostSevereJankPidPu": 0.5, + "HBoostSevereJankThreshold": 8, + "HBoostUclampMinCeilingRange": [480, 722], + "HBoostUclampMinFloorRange": [230, 410], "JankCheckTimeFactor": 1.2, "LowFrameRateThreshold": 25, "MaxRecordsNum": 300 From 3ff00c0207fa5c57e9b5cbc0d0e47903bfd5a121 Mon Sep 17 00:00:00 2001 From: Lokesh Kumar Goel Date: Fri, 19 Apr 2024 20:55:22 +0000 Subject: [PATCH 03/12] tangorpro: Add build_flags based properties for SMR/EMR build Flag: build.RELEASE_IS_SMR Flag: build.RELEASE_IS_EMR Flag: build.RELEASE_BASE_OS_TANGORPRO Bug: 155105803 Change-Id: If08bf526b8929a47a964486e45220c725b03e506 --- device-tangorpro.mk | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/device-tangorpro.mk b/device-tangorpro.mk index 2dcc4bc..23e5e13 100644 --- a/device-tangorpro.mk +++ b/device-tangorpro.mk @@ -282,6 +282,25 @@ PRODUCT_PROPERTY_OVERRIDES += \ PRODUCT_VENDOR_PROPERTIES += \ persist.vendor.camera.exif_reveal_make_model=true +# Set device family property for SMR +PRODUCT_PROPERTY_OVERRIDES += \ + ro.build.device_family=T6P + +# Set build properties for SMR builds +ifeq ($(RELEASE_IS_SMR), true) + ifneq (,$(RELEASE_BASE_OS_TANGORPRO)) + PRODUCT_BASE_OS := $(RELEASE_BASE_OS_TANGORPRO) + endif +endif + +# Set build properties for EMR builds +ifeq ($(RELEASE_IS_EMR), true) + ifneq (,$(RELEASE_BASE_OS_TANGORPRO)) + PRODUCT_PROPERTY_OVERRIDES += \ + ro.build.version.emergency_base_os=$(RELEASE_BASE_OS_TANGORPRO) + endif +endif + # Audio PRODUCT_PROPERTY_OVERRIDES += \ ro.audio.multi_usb_mode=true From 89ece9eddec18a05648473c7727d48f7c077dc60 Mon Sep 17 00:00:00 2001 From: samou Date: Tue, 16 Jul 2024 07:47:39 +0000 Subject: [PATCH 04/12] thermal: Remove bcl related tzones Flag: EXEMPT tuning changes Bug: 349935208 Test: Confirm boot Change-Id: I7aacd517cdd0543e9e4f2010615059b03bf10695 Signed-off-by: samou --- powerhint.json | 12 -- thermal_info_config_tangorpro.json | 287 ----------------------------- 2 files changed, 299 deletions(-) diff --git a/powerhint.json b/powerhint.json index 79e1c35..e7e6043 100644 --- a/powerhint.json +++ b/powerhint.json @@ -1632,18 +1632,6 @@ "Duration": 50, "Value": "1" }, - { - "PowerHint": "THERMAL_FLASH_LED_REDUCE_CRITICAL", - "Node": "LimitFlashCurrent", - "Duration": 0, - "Value": "100" - }, - { - "PowerHint": "THERMAL_FLASH_LED_REDUCE_NONE", - "Node": "LimitFlashCurrent", - "Duration": 0, - "Value": "1500" - }, { "PowerHint": "EXPENSIVE_RENDERING", "Node": "PowerHALRenderingState", diff --git a/thermal_info_config_tangorpro.json b/thermal_info_config_tangorpro.json index 5260a34..d65c5f1 100644 --- a/thermal_info_config_tangorpro.json +++ b/thermal_info_config_tangorpro.json @@ -343,293 +343,6 @@ "Name":"ISP", "Type":"NPU", "Multiplier":0.001 - }, - { - "Name":"battery_cycle", - "Type":"BCL_VOLTAGE", - "Multiplier":1 - }, - { - "Name":"critical-battery-cell", - "Type":"BCL_VOLTAGE", - "VirtualSensor":true, - "Formula":"COUNT_THRESHOLD", - "TriggerSensor": "vdroop1", - "Combination":["battery", "battery_cycle", "vdroop1"], - "Coefficient":[-10000, 400, 1000], - "HotThreshold":["NAN", "NAN", "NAN", "NAN", "NAN", 3.00, "NAN"], - "Multiplier":1, - "Monitor":true - }, - { - "Name":"FLASH_LED_REDUCE", - "Type":"UNKNOWN", - "VirtualSensor":true, - "Formula":"COUNT_THRESHOLD", - "TriggerSensor": "vdroop1", - "Combination":["battery", "battery_cycle", "vdroop1"], - "Coefficient":[-10000, 400, 1000], - "HotThreshold":["NAN", "NAN", "NAN", "NAN", 3.00, "NAN", "NAN"], - "Multiplier":1, - "Monitor":true, - "SendPowerHint":true - }, - { - "Name":"soc", - "Type":"BCL_PERCENTAGE", - "HotThreshold":["NAN", "NAN", 70, "NAN", "NAN", "NAN", "NAN"], - "Multiplier":1 - }, - { - "Name":"BCL_TPU_LOW_TEMP", - "Type":"BCL_CURRENT", - "VirtualSensor":true, - "Formula":"WEIGHTED_AVG", - "TriggerSensor": "ocp_tpu", - "Combination":["ocp_tpu", "battery"], - "Coefficient":[1, -10], - "HotThreshold":["NAN", "NAN", "NAN", "NAN", 13000, "NAN", "NAN"], - "Multiplier":1, - "Monitor":true, - "BindedCdevInfo": [ - { - "CdevRequest": "tpu_cooling", - "LimitInfo": [0, 0, 0, 0, 7, 7, 7] - } - ] - }, - { - "Name":"BCL_GPU_LOW_TEMP", - "Type":"BCL_CURRENT", - "VirtualSensor":true, - "Formula":"WEIGHTED_AVG", - "TriggerSensor": "ocp_gpu", - "Combination":["ocp_gpu", "battery"], - "Coefficient":[1, -10], - "HotThreshold":["NAN", "NAN", "NAN", "NAN", 13000, "NAN", "NAN"], - "Multiplier":1, - "Monitor":true, - "BindedCdevInfo": [ - { - "CdevRequest": "thermal-gpufreq-0", - "LimitInfo": [0, 0, 0, 0, 11, 11, 11] - } - ] - }, - { - "Name":"BCL_BATOILO_GPU_LOW_TEMP", - "Type":"BCL_CURRENT", - "VirtualSensor":true, - "Formula":"COUNT_THRESHOLD", - "TriggerSensor": "batoilo", - "Combination":["batoilo", "ocp_gpu", "battery"], - "Coefficient":[5000, 12000, -1000 ], - "HotThreshold":["NAN", "NAN", "NAN", "NAN", 3.0, "NAN", "NAN"], - "Multiplier":1, - "Monitor":true, - "BindedCdevInfo": [ - { - "CdevRequest": "thermal-gpufreq-0", - "LimitInfo": [0, 0, 0, 0, 11, 11, 11] - } - ] - }, - { - "Name":"BCL_BATOILO_TPU_LOW_TEMP", - "Type":"BCL_CURRENT", - "VirtualSensor":true, - "Formula":"COUNT_THRESHOLD", - "TriggerSensor": "batoilo", - "Combination":["batoilo", "ocp_tpu", "battery"], - "Coefficient":[5000, 12000, -1000], - "HotThreshold":["NAN", "NAN", "NAN", "NAN", 3.0, "NAN", "NAN"], - "Multiplier":1, - "Monitor":true, - "BindedCdevInfo": [ - { - "CdevRequest": "tpu_cooling", - "LimitInfo": [0, 0, 0, 0, 7, 7, 7] - } - ] - }, - { - "Name":"BCL_BATOILO_GPU", - "Type":"BCL_CURRENT", - "VirtualSensor":true, - "Formula":"COUNT_THRESHOLD", - "TriggerSensor": "batoilo", - "Combination":["batoilo", "ocp_gpu"], - "Coefficient":[5000, 12000], - "HotThreshold":["NAN", "NAN", "NAN", "NAN", 2.0, "NAN", "NAN"], - "Multiplier":1, - "Monitor":true, - "BindedCdevInfo": [ - { - "CdevRequest": "thermal-gpufreq-0", - "LimitInfo": [0, 0, 0, 0, 5, 5, 5] - } - ] - }, - { - "Name":"BCL_BATOILO_TPU", - "Type":"BCL_CURRENT", - "VirtualSensor":true, - "Formula":"COUNT_THRESHOLD", - "TriggerSensor": "batoilo", - "Combination":[ - "batoilo", - "ocp_tpu" - ], - "Coefficient":[5000, 12000], - "HotThreshold":["NAN", "NAN", "NAN", "NAN", 2.0, "NAN", "NAN"], - "Multiplier":1, - "Monitor":true, - "BindedCdevInfo": [ - { - "CdevRequest": "tpu_cooling", - "LimitInfo": [0, 0, 0, 0, 6, 6, 6] - } - ] - }, - { - "Name":"batoilo", - "Type":"BCL_CURRENT", - "HotThreshold":["NAN", "NAN", "NAN", "NAN", 5000, "NAN", "NAN"], - "HotHysteresis":[0.0, 0.0, 0.0, 0.0, 100, 0.0, 0.0], - "Multiplier":1, - "Monitor":true, - "PollingDelay":0, - "PassiveDelay":60000, - "BindedCdevInfo": [ - { - "CdevRequest": "thermal-cpufreq-2", - "LimitInfo": [0, 0, 0, 0, 7, 7, 7] - }, - { - "CdevRequest": "thermal-gpufreq-0", - "LimitInfo": [0, 0, 0, 0, 4, 4, 4] - }, - { - "CdevRequest": "tpu_cooling", - "LimitInfo": [0, 0, 0, 0, 5, 5, 5] - } - ] - }, - { - "Name":"BCL_AUDIO_BAACL", - "Type":"BCL_VOLTAGE", - "VirtualSensor":true, - "Formula":"COUNT_THRESHOLD", - "TriggerSensor": "soc", - "Combination":["battery", "soc"], - "Coefficient":[-45000, 70], - "HotThreshold":["NAN", "NAN", "NAN", "NAN", 2.0, "NAN", "NAN"], - "Multiplier":1, - "Monitor":true - }, - { - "Name":"vdroop1", - "Type":"BCL_VOLTAGE", - "HotThreshold":["NAN", "NAN", "NAN", "NAN", 1000, "NAN", "NAN"], - "HotHysteresis":[0.0, 0.0, 0.0, 0.0, 100, 0.0, 0.0], - "Multiplier":1, - "Monitor":true, - "PollingDelay":0, - "PassiveDelay":60000, - "BindedCdevInfo": [ - { - "CdevRequest": "thermal-cpufreq-2", - "LimitInfo": [0, 0, 0, 0, 7, 7, 7] - }, - { - "CdevRequest": "thermal-gpufreq-0", - "LimitInfo": [0, 0, 0, 0, 3, 3, 3] - }, - { - "CdevRequest": "tpu_cooling", - "LimitInfo": [0, 0, 0, 0, 3, 3, 3] - } - ] - }, - { - "Name":"vdroop2", - "Type":"BCL_VOLTAGE", - "HotThreshold":["NAN", "NAN", "NAN", "NAN", 1200, "NAN", "NAN"], - "HotHysteresis":[0.0, 0.0, 0.0, 0.0, 100, 0.0, 0.0], - "Multiplier":1, - "Monitor":true, - "PollingDelay":0, - "PassiveDelay":60000, - "BindedCdevInfo": [ - { - "CdevRequest": "thermal-cpufreq-2", - "LimitInfo": [0, 0, 0, 0, 7, 7, 7] - }, - { - "CdevRequest": "thermal-gpufreq-0", - "LimitInfo": [0, 0, 0, 0, 5, 5, 5] - }, - { - "CdevRequest": "tpu_cooling", - "LimitInfo": [0, 0, 0, 0, 3, 3, 3] - } - ] - }, - { - "Name":"smpl_gm", - "Type":"BCL_VOLTAGE", - "HotThreshold":["NAN", "NAN", "NAN", "NAN", 1100, "NAN", "NAN"], - "HotHysteresis":[0.0, 0.0, 0.0, 0.0, 100, 0.0, 0.0], - "Multiplier":1, - "Monitor":true, - "PollingDelay":0, - "PassiveDelay":60000, - "BindedCdevInfo": [ - { - "CdevRequest": "thermal-cpufreq-2", - "LimitInfo": [0, 0, 0, 0, 7, 7, 7] - }, - { - "CdevRequest": "thermal-gpufreq-0", - "LimitInfo": [0, 0, 0, 0, 4, 4, 4] - }, - { - "CdevRequest": "tpu_cooling", - "LimitInfo": [0, 0, 0, 0, 3, 3, 3] - } - ] - }, - { - "Name":"ocp_cpu1", - "Type":"BCL_CURRENT", - "HotThreshold":["NAN", "NAN", "NAN", "NAN", 8000, "NAN", "NAN"], - "HotHysteresis":[0.0, 0.0, 0.0, 0.0, 100, 0.0, 0.0], - "Multiplier":1, - "Hidden":true - }, - { - "Name":"ocp_cpu2", - "Type":"BCL_CURRENT", - "HotThreshold":["NAN", "NAN", "NAN", "NAN", 12000, "NAN", "NAN"], - "HotHysteresis":[0.0, 0.0, 0.0, 0.0, 100, 0.0, 0.0], - "Multiplier":1, - "Hidden":true - }, - { - "Name":"ocp_tpu", - "Type":"BCL_CURRENT", - "HotThreshold":["NAN", "NAN", "NAN", "NAN", 12000, "NAN", "NAN"], - "HotHysteresis":[0.0, 0.0, 0.0, 0.0, 100, 0.0, 0.0], - "Multiplier":1, - "Hidden":true - }, - { - "Name":"ocp_gpu", - "Type":"BCL_CURRENT", - "HotThreshold":["NAN", "NAN", "NAN", "NAN", 12000, "NAN", "NAN"], - "HotHysteresis":[0.0, 0.0, 0.0, 0.0, 100, 0.0, 0.0], - "Multiplier":1, - "Hidden":true } ], "CoolingDevices":[ From 258f90a96789652ed1e6df25873b707fbaaed42a Mon Sep 17 00:00:00 2001 From: Cyan_Hsieh Date: Fri, 9 Aug 2024 08:34:24 +0000 Subject: [PATCH 05/12] update OWNERS to include Android.bp Flag: EXEMPT only changing OWNERS Bug: 357036384 (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:21fe5059b81ac22b2a22f07606d3a5f019e14e28) Merged-In: I14accc21c396a63d492736a235a37cc104683128 Change-Id: I14accc21c396a63d492736a235a37cc104683128 --- OWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OWNERS b/OWNERS index 5524a1f..b511997 100644 --- a/OWNERS +++ b/OWNERS @@ -1,4 +1,4 @@ per-file powerhint.json = jychen@google.com,jenhaochen@google.com,wvw@google.com,joaodias@google.com # per-file for Pixel device makefiles, see go/pixel-device-mk-owner-checklist for details. -per-file *.mk,*/BoardConfig.mk=file:device/google/gs-common:main:/MK_OWNERS +per-file *.mk,*/BoardConfig.mk,{**/,}Android.bp=file:device/google/gs-common:main:/MK_OWNERS From 8c72a7406d8daa90453b464576d13f0826c853d9 Mon Sep 17 00:00:00 2001 From: "Peter (YM)" Date: Wed, 14 Aug 2024 08:59:58 +0000 Subject: [PATCH 06/12] thermal:remove unused state2power value Bug: 355566259 Test: Build test Flag: EXEMPT NDK Change-Id: I7575597cf934c18fd31228a4641bef5e80f4e0a2 Signed-off-by: Peter (YM) --- thermal_info_config_tangorpro.json | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/thermal_info_config_tangorpro.json b/thermal_info_config_tangorpro.json index 5260a34..f9e4c8c 100644 --- a/thermal_info_config_tangorpro.json +++ b/thermal_info_config_tangorpro.json @@ -636,26 +636,22 @@ { "Name":"thermal-cpufreq-0", "Type":"CPU", - "WritePath":"/dev/thermal/cdev-by-name/thermal-cpufreq-0/user_vote", - "State2Power":[1100, 1050, 1000, 950, 900, 850, 800, 750, 700, 650, 600] + "WritePath":"/dev/thermal/cdev-by-name/thermal-cpufreq-0/user_vote" }, { "Name":"thermal-cpufreq-1", "Type":"CPU", - "WritePath":"/dev/thermal/cdev-by-name/thermal-cpufreq-1/user_vote", - "State2Power":[1400, 1350, 1300, 1250, 1200, 1150, 1100, 1050, 1000, 950, 900, 850, 800, 750] + "WritePath":"/dev/thermal/cdev-by-name/thermal-cpufreq-1/user_vote" }, { "Name":"thermal-cpufreq-2", "Type":"CPU", - "WritePath":"/dev/thermal/cdev-by-name/thermal-cpufreq-2/user_vote", - "State2Power":[1450, 1400, 1350, 1300, 1250, 1200, 1150, 1100, 1050, 1000, 950, 900, 850, 800, 750] + "WritePath":"/dev/thermal/cdev-by-name/thermal-cpufreq-2/user_vote" }, { "Name":"thermal-gpufreq-0", "Type":"GPU", - "WritePath":"/dev/thermal/cdev-by-name/thermal-gpufreq-0/user_vote", - "State2Power":[4371, 3543, 3085, 2293, 1927, 1707, 1394, 1171, 967, 768, 592, 433] + "WritePath":"/dev/thermal/cdev-by-name/thermal-gpufreq-0/user_vote" }, { "Name":"tpu_cooling", From 760188730b0bd6f24f14933403a53306000f87ae Mon Sep 17 00:00:00 2001 From: "Peter (YM)" Date: Fri, 16 Aug 2024 06:27:38 +0000 Subject: [PATCH 07/12] thermal: read thermistor temp from sysfs - avoid wrong sensor value reading for thermalHAL Bug: 327327502 Test: Build to boot to home Flag: EXEMPT (bug 337358613) Change-Id: Id3f90b16dcbb1f485915de9877ff2906d99901c6 Signed-off-by: Peter (YM) --- thermal_info_config_charge_tangorpro.json | 6 ------ thermal_info_config_tangorpro.json | 6 ------ 2 files changed, 12 deletions(-) diff --git a/thermal_info_config_charge_tangorpro.json b/thermal_info_config_charge_tangorpro.json index f167181..d359a88 100644 --- a/thermal_info_config_charge_tangorpro.json +++ b/thermal_info_config_charge_tangorpro.json @@ -8,21 +8,18 @@ { "Name":"neutral_therm", "Type":"UNKNOWN", - "TempPath":"/dev/thermal/tz-by-name/neutral_therm/tz_temp", "Multiplier":0.001 }, { "Name":"quiet_therm", "Type":"UNKNOWN", "HotThreshold":["NAN", "35.0", "NAN", "NAN", "NAN", "NAN", "NAN"], - "TempPath":"/dev/thermal/tz-by-name/quiet_therm/tz_temp", "Multiplier":0.001 }, { "Name":"charger_skin_therm", "Type":"UNKNOWN", "HotThreshold":["NAN", "39.0", "NAN", "NAN", "NAN", "NAN", "NAN"], - "TempPath":"/dev/thermal/tz-by-name/charger_skin_therm/tz_temp", "Multiplier":0.001, "PollingDelay":60000, "PassiveDelay":7000 @@ -30,14 +27,12 @@ { "Name":"disp_therm", "Type":"UNKNOWN", - "TempPath":"/dev/thermal/tz-by-name/disp_therm/tz_temp", "Multiplier":0.001 }, { "Name":"usb_pwr_therm", "Type":"UNKNOWN", "HotThreshold":["NAN", "37.0", "NAN", "NAN", "NAN", "NAN", "NAN"], - "TempPath":"/dev/thermal/tz-by-name/usb_pwr_therm/tz_temp", "Multiplier":0.001, "PollingDelay":300000, "PassiveDelay":7000 @@ -45,7 +40,6 @@ { "Name":"usb_pwr_therm2", "Type":"UNKNOWN", - "TempPath":"/dev/thermal/tz-by-name/usb_pwr_therm2/tz_temp", "Multiplier":0.001 }, { diff --git a/thermal_info_config_tangorpro.json b/thermal_info_config_tangorpro.json index 5260a34..a49515e 100644 --- a/thermal_info_config_tangorpro.json +++ b/thermal_info_config_tangorpro.json @@ -4,7 +4,6 @@ "Name":"neutral_therm", "Type":"UNKNOWN", "HotThreshold":["NAN", "50.0", "NAN", "NAN", "NAN", "NAN", "NAN"], - "TempPath":"/dev/thermal/tz-by-name/neutral_therm/tz_temp", "Multiplier":0.001, "PollingDelay":60000, "PassiveDelay":7000 @@ -12,14 +11,12 @@ { "Name":"quiet_therm", "Type":"UNKNOWN", - "TempPath":"/dev/thermal/tz-by-name/quiet_therm/tz_temp", "Multiplier":0.001 }, { "Name":"charger_skin_therm", "Type":"UNKNOWN", "HotThreshold":["NAN", "39.0", "NAN", "NAN", "NAN", "NAN", "NAN"], - "TempPath":"/dev/thermal/tz-by-name/charger_skin_therm/tz_temp", "Multiplier":0.001, "PollingDelay":60000, "PassiveDelay":7000 @@ -28,7 +25,6 @@ "Name":"disp_therm", "Type":"UNKNOWN", "HotThreshold":["NAN", "37.0", "NAN", "NAN", "NAN", "NAN", "NAN"], - "TempPath":"/dev/thermal/tz-by-name/disp_therm/tz_temp", "Multiplier":0.001, "PollingDelay":60000, "PassiveDelay":7000 @@ -42,7 +38,6 @@ "Name":"usb_pwr_therm", "Type":"UNKNOWN", "HotThreshold":["NAN", "37.0", "NAN", "NAN", "NAN", "NAN", "NAN"], - "TempPath":"/dev/thermal/tz-by-name/usb_pwr_therm/tz_temp", "Multiplier":0.001, "PollingDelay":300000, "PassiveDelay":7000 @@ -50,7 +45,6 @@ { "Name":"usb_pwr_therm2", "Type":"UNKNOWN", - "TempPath":"/dev/thermal/tz-by-name/usb_pwr_therm2/tz_temp", "Multiplier":0.001 }, { From 2dba660f5a28f0d6aae266a7b02def5a8490df48 Mon Sep 17 00:00:00 2001 From: Ankit Goyal Date: Wed, 28 Aug 2024 22:55:49 -0700 Subject: [PATCH 08/12] Delete mapper4 manifest Bug: 362183626 Flag: EXEMPT manifest update Test: Boot to home on shiba Change-Id: Ie43abdb59c2c5a7c07670f187229314c0cf9539f --- manifest.xml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/manifest.xml b/manifest.xml index a427ac0..a31c2c0 100644 --- a/manifest.xml +++ b/manifest.xml @@ -48,15 +48,6 @@ default - - android.hardware.graphics.mapper - passthrough - 4.0 - - IMapper - default - - android.hardware.graphics.composer hwbinder From 3dedd0cfa0ed81f5a4cf8e037197a744f7d69348 Mon Sep 17 00:00:00 2001 From: Robin Peng Date: Fri, 6 Sep 2024 07:35:42 +0000 Subject: [PATCH 09/12] Symlink current prebuilt folder to android root The Android are now based on Trunk Stable world and Pixel prebuilts CLs also needs to reply with this which controlled by the flag which results: - the flag value might be different on each branches - the flag value are mostly different on each release configuration - for local builds, ENGs' needs to figure out the correct location of current prebuilts by checking through entire prebuilt textproto files To alleviate this problem, create an symlink file under android root indicates current prebuilt path after invoke the android lunch cmd. Bug: 364831620 Flag: EXEMPT export current prebuilt path Change-Id: Ieb2d6f517d62bf9a5270fe7ed5fc7643572ea3fe Signed-off-by: Robin Peng --- tangorpro/BoardConfig.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/tangorpro/BoardConfig.mk b/tangorpro/BoardConfig.mk index 0a83b85..382f609 100644 --- a/tangorpro/BoardConfig.mk +++ b/tangorpro/BoardConfig.mk @@ -38,6 +38,7 @@ BOARD_KERNEL_CMDLINE += swiotlb=noforce include device/google/gs201/BoardConfig-common.mk -include vendor/google_devices/gs201/prebuilts/BoardConfigVendor.mk +include device/google/gs-common/check_current_prebuilt/check_current_prebuilt.mk -include vendor/google_devices/tangorpro/proprietary/BoardConfigVendor.mk include device/google/tangorpro-sepolicy/tangorpro-sepolicy.mk include device/google/tangorpro/wifi/BoardConfig-wifi.mk From 70a2a32350bde595b0ca8f703be8ab37b20dedf0 Mon Sep 17 00:00:00 2001 From: Rock Huang Date: Fri, 13 Sep 2024 22:01:59 +0800 Subject: [PATCH 10/12] Add SOONG_NAMESPACES for mediaDrm plugin * Without this CL, the following gs-common ag/29381547 will hit a duplicated name issue. Bug: 364190751 Bug: 229298787 Bug: 366426322 Flag: EXEMPT castauth enabled Test: ab/P80927970 Change-Id: I6bf2fe4ce933f70179cb83fa597caaf98806ffdc --- cast_auth/mediadrm/Android.bp | 11 +++++++++-- device-tangorpro.mk | 3 +++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/cast_auth/mediadrm/Android.bp b/cast_auth/mediadrm/Android.bp index 1dc4e32..e113d24 100644 --- a/cast_auth/mediadrm/Android.bp +++ b/cast_auth/mediadrm/Android.bp @@ -1,7 +1,11 @@ - // ---------------------------------------------------------------------------- // Builds android.hardware.drm-service.castkey // +// TODO(b/366426322): Merge these targets into `device/google/gs-common`. + +soong_namespace { +} + package { // See: http://go/android-license-faq // A large-scale-change added 'default_applicable_licenses' to import @@ -32,7 +36,10 @@ cc_defaults { relative_install_path: "hw", - cflags: ["-Wall", "-Werror"], + cflags: [ + "-Wall", + "-Werror", + ], include_dirs: [ "device/google/tangorpro/cast_auth/mediadrm/include", diff --git a/device-tangorpro.mk b/device-tangorpro.mk index 23e5e13..d1d1ada 100644 --- a/device-tangorpro.mk +++ b/device-tangorpro.mk @@ -258,7 +258,10 @@ PRODUCT_VENDOR_PROPERTIES += \ PRODUCT_SOONG_NAMESPACES += \ vendor/lib64 +# TODO(b/366426322): Merge CastKey Drm plugin into `device/google/gs-common`. # CastKey Drm plugin modules +PRODUCT_SOONG_NAMESPACES += \ + device/google/tangorpro/cast_auth/mediadrm PRODUCT_PACKAGES += \ android.hardware.drm-service.castkey From 25046bedc2101726a99c6eab10d04378977938e4 Mon Sep 17 00:00:00 2001 From: Rock Huang Date: Thu, 19 Sep 2024 16:14:29 +0800 Subject: [PATCH 11/12] Use mediadrm from private instead of tangorpro * Private mediadrm: ag/29478046, ag/29489024 Bug: 367906184 Bug: 366426322 Flag: EXEMPT castauth enabled Test: b/367906184#comment5 Change-Id: I8dc459ca757de0efd0e989adf92dcb0f4bf5519d --- cast_auth/mediadrm/Android.bp | 55 --- cast_auth/mediadrm/CreatePluginFactories.cpp | 17 - cast_auth/mediadrm/DrmFactory.cpp | 82 ---- cast_auth/mediadrm/DrmPlugin.cpp | 419 ------------------ cast_auth/mediadrm/Service.cpp | 23 - cast_auth/mediadrm/SessionLibrary.cpp | 39 -- .../android.hardware.drm-service.castkey.rc | 6 - cast_auth/mediadrm/include/CastKeyTypes.h | 48 -- .../mediadrm/include/CreatePluginFactories.h | 20 - cast_auth/mediadrm/include/DrmFactory.h | 50 --- cast_auth/mediadrm/include/DrmPlugin.h | 143 ------ cast_auth/mediadrm/include/SessionLibrary.h | 28 -- cast_auth/mediadrm/include/Utils.h | 44 -- ...t_android.hardware.drm-service.castkey.xml | 7 - device-tangorpro.mk | 7 - 15 files changed, 988 deletions(-) delete mode 100644 cast_auth/mediadrm/Android.bp delete mode 100644 cast_auth/mediadrm/CreatePluginFactories.cpp delete mode 100644 cast_auth/mediadrm/DrmFactory.cpp delete mode 100644 cast_auth/mediadrm/DrmPlugin.cpp delete mode 100644 cast_auth/mediadrm/Service.cpp delete mode 100644 cast_auth/mediadrm/SessionLibrary.cpp delete mode 100644 cast_auth/mediadrm/android.hardware.drm-service.castkey.rc delete mode 100644 cast_auth/mediadrm/include/CastKeyTypes.h delete mode 100644 cast_auth/mediadrm/include/CreatePluginFactories.h delete mode 100644 cast_auth/mediadrm/include/DrmFactory.h delete mode 100644 cast_auth/mediadrm/include/DrmPlugin.h delete mode 100644 cast_auth/mediadrm/include/SessionLibrary.h delete mode 100644 cast_auth/mediadrm/include/Utils.h delete mode 100644 cast_auth/mediadrm/manifest_android.hardware.drm-service.castkey.xml diff --git a/cast_auth/mediadrm/Android.bp b/cast_auth/mediadrm/Android.bp deleted file mode 100644 index e113d24..0000000 --- a/cast_auth/mediadrm/Android.bp +++ /dev/null @@ -1,55 +0,0 @@ -// ---------------------------------------------------------------------------- -// Builds android.hardware.drm-service.castkey -// -// TODO(b/366426322): Merge these targets into `device/google/gs-common`. - -soong_namespace { -} - -package { - // See: http://go/android-license-faq - // A large-scale-change added 'default_applicable_licenses' to import - // all of the 'license_kinds' from "device_google_tangorpro_license" - // to get the below license kinds: - // SPDX-license-identifier-Apache-2.0 - default_applicable_licenses: ["device_google_tangorpro_license"], -} - -cc_binary { - name: "android.hardware.drm-service.castkey", - defaults: ["castkey_service_defaults"], - srcs: ["Service.cpp"], - init_rc: ["android.hardware.drm-service.castkey.rc"], - vintf_fragments: ["manifest_android.hardware.drm-service.castkey.xml"], -} - -cc_defaults { - name: "castkey_service_defaults", - vendor: true, - proprietary: true, - srcs: [ - "CreatePluginFactories.cpp", - "DrmFactory.cpp", - "DrmPlugin.cpp", - "SessionLibrary.cpp", - ], - - relative_install_path: "hw", - - cflags: [ - "-Wall", - "-Werror", - ], - - include_dirs: [ - "device/google/tangorpro/cast_auth/mediadrm/include", - ], - - shared_libs: [ - "android.hardware.drm-V1-ndk", - "libbase", - "libbinder_ndk", - "liblog", - "libutils", - ], -} diff --git a/cast_auth/mediadrm/CreatePluginFactories.cpp b/cast_auth/mediadrm/CreatePluginFactories.cpp deleted file mode 100644 index 23dee4e..0000000 --- a/cast_auth/mediadrm/CreatePluginFactories.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include "CreatePluginFactories.h" - -namespace aidl { -namespace android { -namespace hardware { -namespace drm { -namespace castkey { - -std::shared_ptr createDrmFactory() { - return ::ndk::SharedRefBase::make(); -} - -} // namespace castkey -} // namespace drm -} // namespace hardware -} // namespace android -} // namespace aidl \ No newline at end of file diff --git a/cast_auth/mediadrm/DrmFactory.cpp b/cast_auth/mediadrm/DrmFactory.cpp deleted file mode 100644 index e127186..0000000 --- a/cast_auth/mediadrm/DrmFactory.cpp +++ /dev/null @@ -1,82 +0,0 @@ -#define LOG_TAG "castkey-DrmFactory" - -#include - -#include "DrmFactory.h" - -#include "DrmPlugin.h" -#include "Utils.h" - -namespace aidl { -namespace android { -namespace hardware { -namespace drm { -namespace castkey { - -namespace { - -const std::array kCastKeyUUID{ - 0xBC, 0xB4, 0x81, 0xCB, 0xA1, 0xD5, 0x42, 0xAF, - 0xB1, 0xE3, 0x7B, 0xFF, 0x14, 0x73, 0xEB, 0x85 -}; - -bool isCastKeyUUID(const uint8_t uuid[16]) { - return !memcmp(uuid, kCastKeyUUID.data(), 16); -} - -} - -using std::string; -using std::vector; - -using ::aidl::android::hardware::drm::Status; -using ::aidl::android::hardware::drm::Uuid; -using namespace castkeydrm; - -::ndk::ScopedAStatus DrmFactory::createDrmPlugin( - const Uuid& in_uuid, const string& in_appPackageName, - std::shared_ptr<::aidl::android::hardware::drm::IDrmPlugin>* _aidl_return) { - UNUSED(in_appPackageName); - if (!isCastKeyUUID(in_uuid.uuid.data())) { - ALOGE("Castkey Drm HAL: failed to create drm plugin, " - "invalid crypto scheme"); - *_aidl_return = nullptr; - return toNdkScopedAStatus(Status::BAD_VALUE); - } - std::shared_ptr plugin = - ::ndk::SharedRefBase::make(); - *_aidl_return = plugin; - return toNdkScopedAStatus(Status::OK); -} - -::ndk::ScopedAStatus DrmFactory::createCryptoPlugin( - const Uuid& in_uuid, const std::vector& in_initData, - std::shared_ptr<::aidl::android::hardware::drm::ICryptoPlugin>* _aidl_return) { - UNUSED(in_uuid); - UNUSED(in_initData); - UNUSED(_aidl_return); - return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); -} - -::ndk::ScopedAStatus DrmFactory::getSupportedCryptoSchemes(CryptoSchemes* _aidl_return) { - CryptoSchemes schemes{}; - schemes.uuids.push_back({kCastKeyUUID}); - *_aidl_return = schemes; - return toNdkScopedAStatus(Status::OK); -} - -binder_status_t DrmFactory::dump(int fd, const char** args, uint32_t numArgs) { - UNUSED(args); - UNUSED(numArgs); - if (fd < 0) { - ALOGE("%s: negative fd", __FUNCTION__); - return STATUS_BAD_VALUE; - } - return STATUS_OK; -} - -} // namespace castkey -} // namespace drm -} // namespace hardware -} // namespace android -} // namespace aidl diff --git a/cast_auth/mediadrm/DrmPlugin.cpp b/cast_auth/mediadrm/DrmPlugin.cpp deleted file mode 100644 index 00b7956..0000000 --- a/cast_auth/mediadrm/DrmPlugin.cpp +++ /dev/null @@ -1,419 +0,0 @@ -#define LOG_TAG "castkey-DrmPlugin" - -#include -#include -#include -#include -#include - -#include "Utils.h" -#include "DrmPlugin.h" -#include "SessionLibrary.h" - -namespace aidl { -namespace android { -namespace hardware { -namespace drm { -namespace castkey { - -using namespace castkeydrm; - -DrmPlugin::DrmPlugin() {}; -DrmPlugin::~DrmPlugin() {}; - -constexpr char CAST_CRT_FILE[] = "/mnt/vendor/persist/nest/cast_auth.crt"; -constexpr char CAST_ICA_FILE[] = "/vendor/etc/cert-chain.crt"; -constexpr unsigned char kSha1Prefix[] = {0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, - 0x03, 0x02, 0x1a, 0x05, 0x00, 0x04, 0x14}; -constexpr unsigned char kSha256Prefix[] = {0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, - 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, - 0x01, 0x05, 0x00, 0x04, 0x20}; -constexpr int kSHA1Length = 20; -constexpr int kSHA256Length = 32; -constexpr int DigestInfoPrefixesSize = 2; - -struct DigestInfoPrefix { - const unsigned char* bytes; - size_t size; - size_t hash_size; -}; - -// Array of DigestInfoPrefixes that are currently supported (SHA1 and SHA256). -const DigestInfoPrefix kDigestInfoPrefixes[] = { - {kSha1Prefix, sizeof(kSha1Prefix), kSHA1Length}, - {kSha256Prefix, sizeof(kSha256Prefix), kSHA256Length}, -}; - -// If we find a raw hash, prepend the appropriate DER prefix. -std::vector adjustHash(const std::vector& hash) { - std::vector adjusted_hash(hash); - for (size_t i = 0; i < DigestInfoPrefixesSize; i++) { - const DigestInfoPrefix& prefix = kDigestInfoPrefixes[i]; - if (hash.size() == prefix.hash_size) { - adjusted_hash.insert(adjusted_hash.begin(), prefix.bytes, - &prefix.bytes[prefix.size]); - break; - } - } - return adjusted_hash; -} - -std::vector readBinaryFile(const std::string& file_path) { - std::ifstream fin(file_path, std::ios::in | std::ios::binary); - fin >> std::noskipws; - std::vector buffer((std::istream_iterator(fin)), - std::istream_iterator()); - return buffer; -} - -::ndk::ScopedAStatus DrmPlugin::openSession( - ::aidl::android::hardware::drm::SecurityLevel in_securityLevel, - std::vector* _aidl_return) { - UNUSED(in_securityLevel); - std::vector sessionId = SessionLibrary::get()->createSession(); - *_aidl_return = sessionId; - return toNdkScopedAStatus(Status::OK); -} - -::ndk::ScopedAStatus DrmPlugin::closeSession(const std::vector& in_sessionId) { - if (in_sessionId.size() == 0) { - return toNdkScopedAStatus(Status::BAD_VALUE); - } - SessionLibrary::get()->closeSession(in_sessionId); - return toNdkScopedAStatus(Status::OK); -} - -::ndk::ScopedAStatus DrmPlugin::getPropertyByteArray(const std::string& in_propertyName, - std::vector* _aidl_return) { - Status status = Status::OK; - std::string name(in_propertyName.c_str()); - std::vector value; - if (name == "castcert") { - std::vector device_cert = readBinaryFile(CAST_CRT_FILE); - std::vector ica = readBinaryFile(CAST_ICA_FILE); - value = std::move(device_cert); - value.insert(value.end(), ica.begin(), ica.end()); - } else { - status = Status::ERROR_DRM_CANNOT_HANDLE; - ALOGE("Unsupported Property: %s", in_propertyName.c_str()); - } - *_aidl_return = value; - return toNdkScopedAStatus(status); -} - -::ndk::ScopedAStatus DrmPlugin::signRSA(const std::vector& in_sessionId, - const std::string& in_algorithm, - const std::vector& in_message, - const std::vector& in_wrappedkey, - std::vector* _aidl_return) { - if (in_sessionId.size() == 0 || in_message.size() == 0) { - return toNdkScopedAStatus(Status::BAD_VALUE); - } - UNUSED(in_algorithm); - UNUSED(in_wrappedkey); - Status status = Status::ERROR_DRM_CANNOT_HANDLE; - std::vector signature; - *_aidl_return = std::vector(); - void* cast_auth_handle = ::dlopen("libcast_auth.so", RTLD_LAZY); - if (!cast_auth_handle) { - ALOGE("Fail to get TA for signing"); - return toNdkScopedAStatus(status); - } - typedef bool (*func_type)(const std::vector&, - std::vector*); - func_type sign_hash_func = - reinterpret_cast(::dlsym(cast_auth_handle, "SignHash")); - if (!sign_hash_func) { - ALOGE("Fail to apply signing method"); - dlclose(cast_auth_handle); - return toNdkScopedAStatus(status); - } - const std::vector msg = adjustHash(in_message); - int res = sign_hash_func(msg, &signature); - dlclose(cast_auth_handle); - if (res == 0) { - *_aidl_return = signature; - return toNdkScopedAStatus(Status::OK); - } - ALOGE("Get empty result from TA"); - return toNdkScopedAStatus(status); -} - -::ndk::ScopedAStatus DrmPlugin::decrypt(const std::vector& in_sessionId, - const std::vector& in_keyId, - const std::vector& in_input, - const std::vector& in_iv, - std::vector* _aidl_return) { - UNUSED(in_sessionId); - UNUSED(in_keyId); - UNUSED(in_input); - UNUSED(in_iv); - UNUSED(_aidl_return); - return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); -} - -::ndk::ScopedAStatus DrmPlugin::encrypt(const std::vector& in_sessionId, - const std::vector& in_keyId, - const std::vector& in_input, - const std::vector& in_iv, - std::vector* _aidl_return) { - UNUSED(in_sessionId); - UNUSED(in_keyId); - UNUSED(in_input); - UNUSED(in_iv); - UNUSED(_aidl_return); - return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); -} - -::ndk::ScopedAStatus DrmPlugin::getHdcpLevels( - ::aidl::android::hardware::drm::HdcpLevels* _aidl_return) { - UNUSED(_aidl_return); - return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); -} - -::ndk::ScopedAStatus DrmPlugin::getKeyRequest( - const std::vector& in_scope, - const std::vector& in_initData, - const std::string& in_mimeType, - ::aidl::android::hardware::drm::KeyType in_keyType, - const std::vector<::aidl::android::hardware::drm::KeyValue>& in_optionalParameters, - ::aidl::android::hardware::drm::KeyRequest* _aidl_return) { - UNUSED(in_scope); - UNUSED(in_initData); - UNUSED(in_mimeType); - UNUSED(in_keyType); - UNUSED(in_optionalParameters); - UNUSED(_aidl_return); - return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); -} - -::ndk::ScopedAStatus DrmPlugin::getLogMessages( - std::vector<::aidl::android::hardware::drm::LogMessage>* _aidl_return) { - UNUSED(_aidl_return); - return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); -} - -::ndk::ScopedAStatus DrmPlugin::getMetrics( - std::vector<::aidl::android::hardware::drm::DrmMetricGroup>* _aidl_return) { - UNUSED(_aidl_return); - return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); -} - -::ndk::ScopedAStatus DrmPlugin::getNumberOfSessions( - ::aidl::android::hardware::drm::NumberOfSessions* _aidl_return) { - UNUSED(_aidl_return); - return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); -} - -::ndk::ScopedAStatus DrmPlugin::getOfflineLicenseKeySetIds( - std::vector<::aidl::android::hardware::drm::KeySetId>* _aidl_return) { - UNUSED(_aidl_return); - return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); -} - -::ndk::ScopedAStatus DrmPlugin::getOfflineLicenseState( - const ::aidl::android::hardware::drm::KeySetId& in_keySetId, - ::aidl::android::hardware::drm::OfflineLicenseState* _aidl_return) { - UNUSED(in_keySetId); - UNUSED(_aidl_return); - return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); -} - -::ndk::ScopedAStatus DrmPlugin::getPropertyString(const std::string& in_propertyName, - std::string* _aidl_return) { - UNUSED(in_propertyName); - UNUSED(_aidl_return); - return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); -} - -::ndk::ScopedAStatus DrmPlugin::getProvisionRequest( - const std::string& in_certificateType, - const std::string& in_certificateAuthority, - ::aidl::android::hardware::drm::ProvisionRequest* _aidl_return) { - UNUSED(in_certificateType); - UNUSED(in_certificateAuthority); - UNUSED(_aidl_return); - return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); -} - -::ndk::ScopedAStatus DrmPlugin::getSecureStop( - const ::aidl::android::hardware::drm::SecureStopId& in_secureStopId, - ::aidl::android::hardware::drm::SecureStop* _aidl_return) { - UNUSED(in_secureStopId); - UNUSED(_aidl_return); - return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); -} - -::ndk::ScopedAStatus DrmPlugin::getSecureStopIds( - std::vector<::aidl::android::hardware::drm::SecureStopId>* _aidl_return) { - UNUSED(_aidl_return); - return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); -} - -::ndk::ScopedAStatus DrmPlugin::getSecureStops( - std::vector<::aidl::android::hardware::drm::SecureStop>* _aidl_return) { - UNUSED(_aidl_return); - return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); -} - -::ndk::ScopedAStatus DrmPlugin::getSecurityLevel( - const std::vector& in_sessionId, - ::aidl::android::hardware::drm::SecurityLevel* _aidl_return) { - UNUSED(in_sessionId); - UNUSED(_aidl_return); - return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); -} - -::ndk::ScopedAStatus DrmPlugin::provideKeyResponse( - const std::vector& in_scope, - const std::vector& in_response, - ::aidl::android::hardware::drm::KeySetId* _aidl_return) { - UNUSED(in_scope); - UNUSED(in_response); - UNUSED(_aidl_return); - return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); -} - -::ndk::ScopedAStatus DrmPlugin::provideProvisionResponse( - const std::vector& in_response, - ::aidl::android::hardware::drm::ProvideProvisionResponseResult* _aidl_return) { - UNUSED(in_response); - UNUSED(_aidl_return); - return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); -} - -::ndk::ScopedAStatus DrmPlugin::queryKeyStatus( - const std::vector& in_sessionId, - std::vector<::aidl::android::hardware::drm::KeyValue>* _aidl_return) { - UNUSED(in_sessionId); - UNUSED(_aidl_return); - return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); -} - -::ndk::ScopedAStatus DrmPlugin::releaseAllSecureStops() { - return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); -} - -::ndk::ScopedAStatus DrmPlugin::releaseSecureStop( - const ::aidl::android::hardware::drm::SecureStopId& in_secureStopId) { - UNUSED(in_secureStopId); - return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); -} - -::ndk::ScopedAStatus DrmPlugin::releaseSecureStops( - const ::aidl::android::hardware::drm::OpaqueData& in_ssRelease) { - UNUSED(in_ssRelease); - return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); -} - -::ndk::ScopedAStatus DrmPlugin::removeAllSecureStops() { - return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); -} - -::ndk::ScopedAStatus DrmPlugin::removeKeys(const std::vector& in_sessionId) { - UNUSED(in_sessionId); - return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); -} - -::ndk::ScopedAStatus DrmPlugin::removeOfflineLicense( - const ::aidl::android::hardware::drm::KeySetId& in_keySetId) { - UNUSED(in_keySetId); - return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); -} - -::ndk::ScopedAStatus DrmPlugin::removeSecureStop( - const ::aidl::android::hardware::drm::SecureStopId& in_secureStopId) { - UNUSED(in_secureStopId); - return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); -} - -::ndk::ScopedAStatus DrmPlugin::requiresSecureDecoder( - const std::string& in_mime, - ::aidl::android::hardware::drm::SecurityLevel in_level, - bool* _aidl_return) { - UNUSED(in_mime); - UNUSED(in_level); - UNUSED(_aidl_return); - return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); -} - -::ndk::ScopedAStatus DrmPlugin::restoreKeys( - const std::vector& in_sessionId, - const ::aidl::android::hardware::drm::KeySetId& in_keySetId) { - UNUSED(in_sessionId); - UNUSED(in_keySetId); - return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); -} - -::ndk::ScopedAStatus DrmPlugin::setCipherAlgorithm(const std::vector& in_sessionId, - const std::string& in_algorithm) { - UNUSED(in_sessionId); - UNUSED(in_algorithm); - return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); -} - -::ndk::ScopedAStatus DrmPlugin::setListener( - const std::shared_ptr<::aidl::android::hardware::drm::IDrmPluginListener>& - in_listener) { - UNUSED(in_listener); - return toNdkScopedAStatus(Status::OK); -} - -::ndk::ScopedAStatus DrmPlugin::setMacAlgorithm(const std::vector& in_sessionId, - const std::string& in_algorithm) { - UNUSED(in_sessionId); - UNUSED(in_algorithm); - return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); -} - -::ndk::ScopedAStatus DrmPlugin::setPlaybackId(const std::vector& in_sessionId, - const std::string& in_playbackId) { - UNUSED(in_sessionId); - UNUSED(in_playbackId); - return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); -} - -::ndk::ScopedAStatus DrmPlugin::setPropertyByteArray(const std::string& in_propertyName, - const std::vector& in_value) { - UNUSED(in_propertyName); - UNUSED(in_value); - return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); -} - -::ndk::ScopedAStatus DrmPlugin::setPropertyString(const std::string& in_propertyName, - const std::string& in_value) { - UNUSED(in_propertyName); - UNUSED(in_value); - return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); -} - -::ndk::ScopedAStatus DrmPlugin::sign(const std::vector& in_sessionId, - const std::vector& in_keyId, - const std::vector& in_message, - std::vector* _aidl_return) { - UNUSED(in_sessionId); - UNUSED(in_keyId); - UNUSED(in_message); - UNUSED(_aidl_return); - return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); -} - -::ndk::ScopedAStatus DrmPlugin::verify(const std::vector& in_sessionId, - const std::vector& in_keyId, - const std::vector& in_message, - const std::vector& in_signature, - bool* _aidl_return) { - UNUSED(in_sessionId); - UNUSED(in_keyId); - UNUSED(in_message); - UNUSED(in_signature); - UNUSED(_aidl_return); - return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); -} - - -} // namespace castkey -} // namespace drm -} // namespace hardware -} // namespace android -} // namespace aidl diff --git a/cast_auth/mediadrm/Service.cpp b/cast_auth/mediadrm/Service.cpp deleted file mode 100644 index 53b50e2..0000000 --- a/cast_auth/mediadrm/Service.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#define LOG_TAG "castkey-main" - -#include -#include -#include -#include "CreatePluginFactories.h" - -using ::android::base::InitLogging; -using ::android::base::LogdLogger; -using ::aidl::android::hardware::drm::castkey::createDrmFactory; -using ::aidl::android::hardware::drm::castkey::DrmFactory; - -int main(int /*argc*/, char* argv[]) { - InitLogging(argv, LogdLogger()); - ABinderProcess_setThreadPoolMaxThreadCount(8); - std::shared_ptr drmFactory = createDrmFactory(); - const std::string drmInstance = std::string() + DrmFactory::descriptor + "/castkey"; - binder_status_t status = - AServiceManager_addService(drmFactory->asBinder().get(), drmInstance.c_str()); - CHECK(status == STATUS_OK); - ABinderProcess_joinThreadPool(); - return EXIT_FAILURE; -} \ No newline at end of file diff --git a/cast_auth/mediadrm/SessionLibrary.cpp b/cast_auth/mediadrm/SessionLibrary.cpp deleted file mode 100644 index 8d56660..0000000 --- a/cast_auth/mediadrm/SessionLibrary.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include "SessionLibrary.h" - -#include -#include - -namespace castkeydrm { - -std::mutex SessionLibrary::singleton_lock_; -SessionLibrary* SessionLibrary::singleton_ = NULL; - -SessionLibrary* SessionLibrary::get() { - std::lock_guard guard(singleton_lock_); - - if (singleton_ == NULL) { - singleton_ = new SessionLibrary(); - } - - return singleton_; -} - -std::vector SessionLibrary::createSession() { - std::lock_guard guard(session_lock_); - - std::string session_string = std::to_string(next_session_id_); - next_session_id_ += 1; - sessions_.emplace_back(session_string.begin(), session_string.end()); - return sessions_.back(); -} - -void SessionLibrary::closeSession(const std::vector& session) { - std::lock_guard guard(session_lock_); - sessions_.erase(std::remove_if(sessions_.begin(), sessions_.end(), - [&session](const std::vector& e) { - return std::equal(e.begin(), e.end(), session.begin()); - }), - sessions_.end()); -} - -} // namespace castkeydrm \ No newline at end of file diff --git a/cast_auth/mediadrm/android.hardware.drm-service.castkey.rc b/cast_auth/mediadrm/android.hardware.drm-service.castkey.rc deleted file mode 100644 index 73106a9..0000000 --- a/cast_auth/mediadrm/android.hardware.drm-service.castkey.rc +++ /dev/null @@ -1,6 +0,0 @@ -service vendor.drm-castkey-service /vendor/bin/hw/android.hardware.drm-service.castkey - class hal - user media - group mediadrm drmrpc - ioprio rt 4 - interface aidl android.hardware.drm.IDrmFactory/castkey diff --git a/cast_auth/mediadrm/include/CastKeyTypes.h b/cast_auth/mediadrm/include/CastKeyTypes.h deleted file mode 100644 index 5eb17f7..0000000 --- a/cast_auth/mediadrm/include/CastKeyTypes.h +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef CASTKEY_TYPES_H_ -#define CASTKEY_TYPES_H_ - -#include -#include -#include - -namespace castkeydrm { - -const uint8_t kBlockSize = 16; // AES_BLOCK_SIZE; -typedef uint8_t KeyId[kBlockSize]; -typedef uint8_t Iv[kBlockSize]; - -typedef std::map, std::vector> KeyMap; - -#define CASTKEY_DISALLOW_COPY_AND_ASSIGN(TypeName) \ - TypeName(const TypeName&) = delete; \ - void operator=(const TypeName&) = delete; - -#define CASTKEY_DISALLOW_COPY_AND_ASSIGN_AND_NEW(TypeName) \ - TypeName() = delete; \ - TypeName(const TypeName&) = delete; \ - void operator=(const TypeName&) = delete; - -enum CdmResponseType : int32_t { - OK = 0, - ERROR_NO_LICENSE = 1, - ERROR_SESSION_NOT_OPENED = 3, - ERROR_CANNOT_HANDLE = 4, - ERROR_INVALID_STATE = 5, - BAD_VALUE = 6, - ERROR_DECRYPT = 11, - ERROR_UNKNOWN = 12, - ERROR_INSUFFICIENT_SECURITY = 13, - ERROR_FRAME_TOO_LARGE = 14, - ERROR_SESSION_LOST_STATE = 15, - ERROR_RESOURCE_CONTENTION = 16, -}; - -enum CdmKeyType : int32_t { - KEY_TYPE_OFFLINE = 0, - KEY_TYPE_STREAMING = 1, - KEY_TYPE_RELEASE = 2, -}; - -} // namespace castkeydrm - -#endif // CASTKEY_TYPES_H_ \ No newline at end of file diff --git a/cast_auth/mediadrm/include/CreatePluginFactories.h b/cast_auth/mediadrm/include/CreatePluginFactories.h deleted file mode 100644 index acf9545..0000000 --- a/cast_auth/mediadrm/include/CreatePluginFactories.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef CREATE_PLUGIN_FACTORIES_H_ -#define CREATE_PLUGIN_FACTORIES_H_ - -#include "DrmFactory.h" - -namespace aidl { -namespace android { -namespace hardware { -namespace drm { -namespace castkey { - -std::shared_ptr createDrmFactory(); - -} // namespace castkey -} // namespace drm -} // namespace hardware -} // namespace android -} // namespace aidl - -#endif // CREATE_PLUGIN_FACTORIES_H_ \ No newline at end of file diff --git a/cast_auth/mediadrm/include/DrmFactory.h b/cast_auth/mediadrm/include/DrmFactory.h deleted file mode 100644 index eb0816d..0000000 --- a/cast_auth/mediadrm/include/DrmFactory.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef DRM_FACTORY_H_ -#define DRM_FACTORY_H_ - -#include -#include -#include -#include - -#include -#include - -#include "CastKeyTypes.h" - -namespace aidl { -namespace android { -namespace hardware { -namespace drm { -namespace castkey { - -struct DrmFactory : public BnDrmFactory { - DrmFactory() {}; - virtual ~DrmFactory() {}; - - ::ndk::ScopedAStatus createDrmPlugin( - const ::aidl::android::hardware::drm::Uuid& in_uuid, - const std::string& in_appPackageName, - std::shared_ptr<::aidl::android::hardware::drm::IDrmPlugin>* _aidl_return) override; - - ::ndk::ScopedAStatus createCryptoPlugin( - const ::aidl::android::hardware::drm::Uuid& in_uuid, - const std::vector& in_initData, - std::shared_ptr<::aidl::android::hardware::drm::ICryptoPlugin>* _aidl_return) override; - - ::ndk::ScopedAStatus getSupportedCryptoSchemes( - ::aidl::android::hardware::drm::CryptoSchemes* _aidl_return) override; - - binder_status_t dump(int fd, const char** args, uint32_t numArgs) override; - - - private: - CASTKEY_DISALLOW_COPY_AND_ASSIGN(DrmFactory); -}; - -} // namespace castkey -} // namespace drm -} // namespace hardware -} // namespace android -} // namespace aidl - -#endif // DRM_FACTORIES_H_ diff --git a/cast_auth/mediadrm/include/DrmPlugin.h b/cast_auth/mediadrm/include/DrmPlugin.h deleted file mode 100644 index f6a3f6f..0000000 --- a/cast_auth/mediadrm/include/DrmPlugin.h +++ /dev/null @@ -1,143 +0,0 @@ -#ifndef DRM_PLUGIN_H_ -#define DRM_PLUGIN_H_ - -#include -#include -#include - -#include -#include - -#include - -namespace aidl { -namespace android { -namespace hardware { -namespace drm { -namespace castkey { - -using namespace castkeydrm; -using ::aidl::android::hardware::drm::KeyType; -using ::aidl::android::hardware::drm::Status; - -struct DrmPlugin : public BnDrmPlugin { -public: - explicit DrmPlugin(); - virtual ~DrmPlugin(); - - ::ndk::ScopedAStatus closeSession(const std::vector& in_sessionId) override; - ::ndk::ScopedAStatus decrypt(const std::vector& in_sessionId, - const std::vector& in_keyId, - const std::vector& in_input, - const std::vector& in_iv, - std::vector* _aidl_return) override; - ::ndk::ScopedAStatus encrypt(const std::vector& in_sessionId, - const std::vector& in_keyId, - const std::vector& in_input, - const std::vector& in_iv, - std::vector* _aidl_return) override; - ::ndk::ScopedAStatus getHdcpLevels( - ::aidl::android::hardware::drm::HdcpLevels* _aidl_return) override; - ::ndk::ScopedAStatus getKeyRequest( - const std::vector& in_scope, - const std::vector& in_initData, - const std::string& in_mimeType, - ::aidl::android::hardware::drm::KeyType in_keyType, - const std::vector<::aidl::android::hardware::drm::KeyValue>& in_optionalParameters, - ::aidl::android::hardware::drm::KeyRequest* _aidl_return) override; - ::ndk::ScopedAStatus getLogMessages( - std::vector<::aidl::android::hardware::drm::LogMessage>* _aidl_return) override; - - ::ndk::ScopedAStatus getMetrics( - std::vector<::aidl::android::hardware::drm::DrmMetricGroup>* _aidl_return) override; - ::ndk::ScopedAStatus getNumberOfSessions( - ::aidl::android::hardware::drm::NumberOfSessions* _aidl_return) override; - ::ndk::ScopedAStatus getOfflineLicenseKeySetIds( - std::vector<::aidl::android::hardware::drm::KeySetId>* _aidl_return) override; - ::ndk::ScopedAStatus getOfflineLicenseState( - const ::aidl::android::hardware::drm::KeySetId& in_keySetId, - ::aidl::android::hardware::drm::OfflineLicenseState* _aidl_return) override; - ::ndk::ScopedAStatus getPropertyByteArray(const std::string& in_propertyName, - std::vector* _aidl_return) override; - ::ndk::ScopedAStatus getPropertyString(const std::string& in_propertyName, - std::string* _aidl_return) override; - ::ndk::ScopedAStatus getProvisionRequest( - const std::string& in_certificateType, - const std::string& in_certificateAuthority, - ::aidl::android::hardware::drm::ProvisionRequest* _aidl_return) override; - ::ndk::ScopedAStatus getSecureStop( - const ::aidl::android::hardware::drm::SecureStopId& in_secureStopId, - ::aidl::android::hardware::drm::SecureStop* _aidl_return) override; - ::ndk::ScopedAStatus getSecureStopIds( - std::vector<::aidl::android::hardware::drm::SecureStopId>* _aidl_return) override; - ::ndk::ScopedAStatus getSecureStops( - std::vector<::aidl::android::hardware::drm::SecureStop>* _aidl_return) override; - ::ndk::ScopedAStatus getSecurityLevel( - const std::vector& in_sessionId, - ::aidl::android::hardware::drm::SecurityLevel* _aidl_return) override; - ::ndk::ScopedAStatus openSession(::aidl::android::hardware::drm::SecurityLevel in_securityLevel, - std::vector* _aidl_return) override; - ::ndk::ScopedAStatus provideKeyResponse( - const std::vector& in_scope, - const std::vector& in_response, - ::aidl::android::hardware::drm::KeySetId* _aidl_return) override; - ::ndk::ScopedAStatus provideProvisionResponse( - const std::vector& in_response, - ::aidl::android::hardware::drm::ProvideProvisionResponseResult* _aidl_return) override; - ::ndk::ScopedAStatus queryKeyStatus( - const std::vector& in_sessionId, - std::vector<::aidl::android::hardware::drm::KeyValue>* _aidl_return) override; - ::ndk::ScopedAStatus releaseAllSecureStops() override; - ::ndk::ScopedAStatus releaseSecureStop( - const ::aidl::android::hardware::drm::SecureStopId& in_secureStopId) override; - ::ndk::ScopedAStatus releaseSecureStops( - const ::aidl::android::hardware::drm::OpaqueData& in_ssRelease) override; - ::ndk::ScopedAStatus removeAllSecureStops() override; - ::ndk::ScopedAStatus removeKeys(const std::vector& in_sessionId) override; - ::ndk::ScopedAStatus removeOfflineLicense( - const ::aidl::android::hardware::drm::KeySetId& in_keySetId) override; - ::ndk::ScopedAStatus removeSecureStop( - const ::aidl::android::hardware::drm::SecureStopId& in_secureStopId) override; - ::ndk::ScopedAStatus requiresSecureDecoder( - const std::string& in_mime, - ::aidl::android::hardware::drm::SecurityLevel in_level, - bool* _aidl_return) override; - ::ndk::ScopedAStatus restoreKeys( - const std::vector& in_sessionId, - const ::aidl::android::hardware::drm::KeySetId& in_keySetId) override; - ::ndk::ScopedAStatus setCipherAlgorithm(const std::vector& in_sessionId, - const std::string& in_algorithm) override; - ::ndk::ScopedAStatus setListener( - const std::shared_ptr<::aidl::android::hardware::drm::IDrmPluginListener>& - in_listener) override; - ::ndk::ScopedAStatus setMacAlgorithm(const std::vector& in_sessionId, - const std::string& in_algorithm) override; - ::ndk::ScopedAStatus setPlaybackId(const std::vector& in_sessionId, - const std::string& in_playbackId) override; - ::ndk::ScopedAStatus setPropertyByteArray(const std::string& in_propertyName, - const std::vector& in_value) override; - ::ndk::ScopedAStatus setPropertyString(const std::string& in_propertyName, - const std::string& in_value) override; - ::ndk::ScopedAStatus sign(const std::vector& in_sessionId, - const std::vector& in_keyId, - const std::vector& in_message, - std::vector* _aidl_return) override; - ::ndk::ScopedAStatus signRSA(const std::vector& in_sessionId, - const std::string& in_algorithm, - const std::vector& in_message, - const std::vector& in_wrappedkey, - std::vector* _aidl_return) override; - ::ndk::ScopedAStatus verify(const std::vector& in_sessionId, - const std::vector& in_keyId, - const std::vector& in_message, - const std::vector& in_signature, - bool* _aidl_return) override; -}; - -} // namespace castkey -} // namespace drm -} // namespace hardware -} // namespace android -} // namespace aidl - -#endif // DRM_PLUGIN_H_ \ No newline at end of file diff --git a/cast_auth/mediadrm/include/SessionLibrary.h b/cast_auth/mediadrm/include/SessionLibrary.h deleted file mode 100644 index d2d0e49..0000000 --- a/cast_auth/mediadrm/include/SessionLibrary.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef SESSION_LIBRARY_H_ -#define SESSION_LIBRARY_H_ - -#include -#include - -namespace castkeydrm { - -class SessionLibrary { -public: - static SessionLibrary* get(); - std::vector createSession(); - void closeSession(const std::vector& session); - -private: - SessionLibrary() : next_session_id_(1) {} - - static std::mutex singleton_lock_; - static SessionLibrary* singleton_; - - std::mutex session_lock_; - uint32_t next_session_id_; - std::vector> sessions_; -}; - -} // namespace castkeydrm - -#endif // SESSION_LIBRARY_H_ \ No newline at end of file diff --git a/cast_auth/mediadrm/include/Utils.h b/cast_auth/mediadrm/include/Utils.h deleted file mode 100644 index 98821f4..0000000 --- a/cast_auth/mediadrm/include/Utils.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef UTILS_H_ -#define UTILS_H_ - -#include - -#include "SessionLibrary.h" - -#include -#include "aidl/android/hardware/drm/Status.h" -#include "CastKeyTypes.h" - -namespace aidl { -namespace android { -namespace hardware { -namespace drm { -namespace castkey { - -inline ::ndk::ScopedAStatus toNdkScopedAStatus(::aidl::android::hardware::drm::Status status, - const char* msg = nullptr) { - if (Status::OK == status) { - return ::ndk::ScopedAStatus::ok(); - } else { - auto err = static_cast(status); - if (msg) { - return ::ndk::ScopedAStatus::fromServiceSpecificErrorWithMessage(err, msg); - } else { - return ::ndk::ScopedAStatus::fromServiceSpecificError(err); - } - } -} - -inline ::ndk::ScopedAStatus toNdkScopedAStatus(castkeydrm::CdmResponseType res) { - return toNdkScopedAStatus(static_cast<::aidl::android::hardware::drm::Status>(res)); -} - -#define UNUSED(x) (void)(x); - -} // namespace castkey -} // namespace drm -} // namespace hardware -} // namespace android -} // namespace aidl - -#endif // UTILS_H_ diff --git a/cast_auth/mediadrm/manifest_android.hardware.drm-service.castkey.xml b/cast_auth/mediadrm/manifest_android.hardware.drm-service.castkey.xml deleted file mode 100644 index 412a10b..0000000 --- a/cast_auth/mediadrm/manifest_android.hardware.drm-service.castkey.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - android.hardware.drm - 1 - IDrmFactory/castkey - - \ No newline at end of file diff --git a/device-tangorpro.mk b/device-tangorpro.mk index d1d1ada..3c6a790 100644 --- a/device-tangorpro.mk +++ b/device-tangorpro.mk @@ -258,13 +258,6 @@ PRODUCT_VENDOR_PROPERTIES += \ PRODUCT_SOONG_NAMESPACES += \ vendor/lib64 -# TODO(b/366426322): Merge CastKey Drm plugin into `device/google/gs-common`. -# CastKey Drm plugin modules -PRODUCT_SOONG_NAMESPACES += \ - device/google/tangorpro/cast_auth/mediadrm -PRODUCT_PACKAGES += \ - android.hardware.drm-service.castkey - # MIPI Coex Configs PRODUCT_COPY_FILES += \ device/google/tangorpro/radio/tangor_camera_front_mipi_coex_table.csv:$(TARGET_COPY_OUT_VENDOR)/etc/modem/camera_front_mipi_coex_table.csv \ From 32c2f95b109ba2e90615782de61b5f087b72dcb1 Mon Sep 17 00:00:00 2001 From: "Liana Kazanova (xWF)" Date: Mon, 23 Sep 2024 21:03:33 +0000 Subject: [PATCH 12/12] Revert "Use mediadrm from private instead of tangorpro" Revert submission 29489024-pixel_tablet_mediadrm Reason for revert: DroidMonitor: Potential culprit for http://b/369192150 - Verifying through ABTD before submission. Reverted changes: /q/submissionid:29489024-pixel_tablet_mediadrm Change-Id: I3c1c31b871275bf2b5ceb93120918f749f828cd1 --- cast_auth/mediadrm/Android.bp | 55 +++ cast_auth/mediadrm/CreatePluginFactories.cpp | 17 + cast_auth/mediadrm/DrmFactory.cpp | 82 ++++ cast_auth/mediadrm/DrmPlugin.cpp | 419 ++++++++++++++++++ cast_auth/mediadrm/Service.cpp | 23 + cast_auth/mediadrm/SessionLibrary.cpp | 39 ++ .../android.hardware.drm-service.castkey.rc | 6 + cast_auth/mediadrm/include/CastKeyTypes.h | 48 ++ .../mediadrm/include/CreatePluginFactories.h | 20 + cast_auth/mediadrm/include/DrmFactory.h | 50 +++ cast_auth/mediadrm/include/DrmPlugin.h | 143 ++++++ cast_auth/mediadrm/include/SessionLibrary.h | 28 ++ cast_auth/mediadrm/include/Utils.h | 44 ++ ...t_android.hardware.drm-service.castkey.xml | 7 + device-tangorpro.mk | 7 + 15 files changed, 988 insertions(+) create mode 100644 cast_auth/mediadrm/Android.bp create mode 100644 cast_auth/mediadrm/CreatePluginFactories.cpp create mode 100644 cast_auth/mediadrm/DrmFactory.cpp create mode 100644 cast_auth/mediadrm/DrmPlugin.cpp create mode 100644 cast_auth/mediadrm/Service.cpp create mode 100644 cast_auth/mediadrm/SessionLibrary.cpp create mode 100644 cast_auth/mediadrm/android.hardware.drm-service.castkey.rc create mode 100644 cast_auth/mediadrm/include/CastKeyTypes.h create mode 100644 cast_auth/mediadrm/include/CreatePluginFactories.h create mode 100644 cast_auth/mediadrm/include/DrmFactory.h create mode 100644 cast_auth/mediadrm/include/DrmPlugin.h create mode 100644 cast_auth/mediadrm/include/SessionLibrary.h create mode 100644 cast_auth/mediadrm/include/Utils.h create mode 100644 cast_auth/mediadrm/manifest_android.hardware.drm-service.castkey.xml diff --git a/cast_auth/mediadrm/Android.bp b/cast_auth/mediadrm/Android.bp new file mode 100644 index 0000000..e113d24 --- /dev/null +++ b/cast_auth/mediadrm/Android.bp @@ -0,0 +1,55 @@ +// ---------------------------------------------------------------------------- +// Builds android.hardware.drm-service.castkey +// +// TODO(b/366426322): Merge these targets into `device/google/gs-common`. + +soong_namespace { +} + +package { + // See: http://go/android-license-faq + // A large-scale-change added 'default_applicable_licenses' to import + // all of the 'license_kinds' from "device_google_tangorpro_license" + // to get the below license kinds: + // SPDX-license-identifier-Apache-2.0 + default_applicable_licenses: ["device_google_tangorpro_license"], +} + +cc_binary { + name: "android.hardware.drm-service.castkey", + defaults: ["castkey_service_defaults"], + srcs: ["Service.cpp"], + init_rc: ["android.hardware.drm-service.castkey.rc"], + vintf_fragments: ["manifest_android.hardware.drm-service.castkey.xml"], +} + +cc_defaults { + name: "castkey_service_defaults", + vendor: true, + proprietary: true, + srcs: [ + "CreatePluginFactories.cpp", + "DrmFactory.cpp", + "DrmPlugin.cpp", + "SessionLibrary.cpp", + ], + + relative_install_path: "hw", + + cflags: [ + "-Wall", + "-Werror", + ], + + include_dirs: [ + "device/google/tangorpro/cast_auth/mediadrm/include", + ], + + shared_libs: [ + "android.hardware.drm-V1-ndk", + "libbase", + "libbinder_ndk", + "liblog", + "libutils", + ], +} diff --git a/cast_auth/mediadrm/CreatePluginFactories.cpp b/cast_auth/mediadrm/CreatePluginFactories.cpp new file mode 100644 index 0000000..23dee4e --- /dev/null +++ b/cast_auth/mediadrm/CreatePluginFactories.cpp @@ -0,0 +1,17 @@ +#include "CreatePluginFactories.h" + +namespace aidl { +namespace android { +namespace hardware { +namespace drm { +namespace castkey { + +std::shared_ptr createDrmFactory() { + return ::ndk::SharedRefBase::make(); +} + +} // namespace castkey +} // namespace drm +} // namespace hardware +} // namespace android +} // namespace aidl \ No newline at end of file diff --git a/cast_auth/mediadrm/DrmFactory.cpp b/cast_auth/mediadrm/DrmFactory.cpp new file mode 100644 index 0000000..e127186 --- /dev/null +++ b/cast_auth/mediadrm/DrmFactory.cpp @@ -0,0 +1,82 @@ +#define LOG_TAG "castkey-DrmFactory" + +#include + +#include "DrmFactory.h" + +#include "DrmPlugin.h" +#include "Utils.h" + +namespace aidl { +namespace android { +namespace hardware { +namespace drm { +namespace castkey { + +namespace { + +const std::array kCastKeyUUID{ + 0xBC, 0xB4, 0x81, 0xCB, 0xA1, 0xD5, 0x42, 0xAF, + 0xB1, 0xE3, 0x7B, 0xFF, 0x14, 0x73, 0xEB, 0x85 +}; + +bool isCastKeyUUID(const uint8_t uuid[16]) { + return !memcmp(uuid, kCastKeyUUID.data(), 16); +} + +} + +using std::string; +using std::vector; + +using ::aidl::android::hardware::drm::Status; +using ::aidl::android::hardware::drm::Uuid; +using namespace castkeydrm; + +::ndk::ScopedAStatus DrmFactory::createDrmPlugin( + const Uuid& in_uuid, const string& in_appPackageName, + std::shared_ptr<::aidl::android::hardware::drm::IDrmPlugin>* _aidl_return) { + UNUSED(in_appPackageName); + if (!isCastKeyUUID(in_uuid.uuid.data())) { + ALOGE("Castkey Drm HAL: failed to create drm plugin, " + "invalid crypto scheme"); + *_aidl_return = nullptr; + return toNdkScopedAStatus(Status::BAD_VALUE); + } + std::shared_ptr plugin = + ::ndk::SharedRefBase::make(); + *_aidl_return = plugin; + return toNdkScopedAStatus(Status::OK); +} + +::ndk::ScopedAStatus DrmFactory::createCryptoPlugin( + const Uuid& in_uuid, const std::vector& in_initData, + std::shared_ptr<::aidl::android::hardware::drm::ICryptoPlugin>* _aidl_return) { + UNUSED(in_uuid); + UNUSED(in_initData); + UNUSED(_aidl_return); + return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); +} + +::ndk::ScopedAStatus DrmFactory::getSupportedCryptoSchemes(CryptoSchemes* _aidl_return) { + CryptoSchemes schemes{}; + schemes.uuids.push_back({kCastKeyUUID}); + *_aidl_return = schemes; + return toNdkScopedAStatus(Status::OK); +} + +binder_status_t DrmFactory::dump(int fd, const char** args, uint32_t numArgs) { + UNUSED(args); + UNUSED(numArgs); + if (fd < 0) { + ALOGE("%s: negative fd", __FUNCTION__); + return STATUS_BAD_VALUE; + } + return STATUS_OK; +} + +} // namespace castkey +} // namespace drm +} // namespace hardware +} // namespace android +} // namespace aidl diff --git a/cast_auth/mediadrm/DrmPlugin.cpp b/cast_auth/mediadrm/DrmPlugin.cpp new file mode 100644 index 0000000..00b7956 --- /dev/null +++ b/cast_auth/mediadrm/DrmPlugin.cpp @@ -0,0 +1,419 @@ +#define LOG_TAG "castkey-DrmPlugin" + +#include +#include +#include +#include +#include + +#include "Utils.h" +#include "DrmPlugin.h" +#include "SessionLibrary.h" + +namespace aidl { +namespace android { +namespace hardware { +namespace drm { +namespace castkey { + +using namespace castkeydrm; + +DrmPlugin::DrmPlugin() {}; +DrmPlugin::~DrmPlugin() {}; + +constexpr char CAST_CRT_FILE[] = "/mnt/vendor/persist/nest/cast_auth.crt"; +constexpr char CAST_ICA_FILE[] = "/vendor/etc/cert-chain.crt"; +constexpr unsigned char kSha1Prefix[] = {0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, + 0x03, 0x02, 0x1a, 0x05, 0x00, 0x04, 0x14}; +constexpr unsigned char kSha256Prefix[] = {0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, + 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, + 0x01, 0x05, 0x00, 0x04, 0x20}; +constexpr int kSHA1Length = 20; +constexpr int kSHA256Length = 32; +constexpr int DigestInfoPrefixesSize = 2; + +struct DigestInfoPrefix { + const unsigned char* bytes; + size_t size; + size_t hash_size; +}; + +// Array of DigestInfoPrefixes that are currently supported (SHA1 and SHA256). +const DigestInfoPrefix kDigestInfoPrefixes[] = { + {kSha1Prefix, sizeof(kSha1Prefix), kSHA1Length}, + {kSha256Prefix, sizeof(kSha256Prefix), kSHA256Length}, +}; + +// If we find a raw hash, prepend the appropriate DER prefix. +std::vector adjustHash(const std::vector& hash) { + std::vector adjusted_hash(hash); + for (size_t i = 0; i < DigestInfoPrefixesSize; i++) { + const DigestInfoPrefix& prefix = kDigestInfoPrefixes[i]; + if (hash.size() == prefix.hash_size) { + adjusted_hash.insert(adjusted_hash.begin(), prefix.bytes, + &prefix.bytes[prefix.size]); + break; + } + } + return adjusted_hash; +} + +std::vector readBinaryFile(const std::string& file_path) { + std::ifstream fin(file_path, std::ios::in | std::ios::binary); + fin >> std::noskipws; + std::vector buffer((std::istream_iterator(fin)), + std::istream_iterator()); + return buffer; +} + +::ndk::ScopedAStatus DrmPlugin::openSession( + ::aidl::android::hardware::drm::SecurityLevel in_securityLevel, + std::vector* _aidl_return) { + UNUSED(in_securityLevel); + std::vector sessionId = SessionLibrary::get()->createSession(); + *_aidl_return = sessionId; + return toNdkScopedAStatus(Status::OK); +} + +::ndk::ScopedAStatus DrmPlugin::closeSession(const std::vector& in_sessionId) { + if (in_sessionId.size() == 0) { + return toNdkScopedAStatus(Status::BAD_VALUE); + } + SessionLibrary::get()->closeSession(in_sessionId); + return toNdkScopedAStatus(Status::OK); +} + +::ndk::ScopedAStatus DrmPlugin::getPropertyByteArray(const std::string& in_propertyName, + std::vector* _aidl_return) { + Status status = Status::OK; + std::string name(in_propertyName.c_str()); + std::vector value; + if (name == "castcert") { + std::vector device_cert = readBinaryFile(CAST_CRT_FILE); + std::vector ica = readBinaryFile(CAST_ICA_FILE); + value = std::move(device_cert); + value.insert(value.end(), ica.begin(), ica.end()); + } else { + status = Status::ERROR_DRM_CANNOT_HANDLE; + ALOGE("Unsupported Property: %s", in_propertyName.c_str()); + } + *_aidl_return = value; + return toNdkScopedAStatus(status); +} + +::ndk::ScopedAStatus DrmPlugin::signRSA(const std::vector& in_sessionId, + const std::string& in_algorithm, + const std::vector& in_message, + const std::vector& in_wrappedkey, + std::vector* _aidl_return) { + if (in_sessionId.size() == 0 || in_message.size() == 0) { + return toNdkScopedAStatus(Status::BAD_VALUE); + } + UNUSED(in_algorithm); + UNUSED(in_wrappedkey); + Status status = Status::ERROR_DRM_CANNOT_HANDLE; + std::vector signature; + *_aidl_return = std::vector(); + void* cast_auth_handle = ::dlopen("libcast_auth.so", RTLD_LAZY); + if (!cast_auth_handle) { + ALOGE("Fail to get TA for signing"); + return toNdkScopedAStatus(status); + } + typedef bool (*func_type)(const std::vector&, + std::vector*); + func_type sign_hash_func = + reinterpret_cast(::dlsym(cast_auth_handle, "SignHash")); + if (!sign_hash_func) { + ALOGE("Fail to apply signing method"); + dlclose(cast_auth_handle); + return toNdkScopedAStatus(status); + } + const std::vector msg = adjustHash(in_message); + int res = sign_hash_func(msg, &signature); + dlclose(cast_auth_handle); + if (res == 0) { + *_aidl_return = signature; + return toNdkScopedAStatus(Status::OK); + } + ALOGE("Get empty result from TA"); + return toNdkScopedAStatus(status); +} + +::ndk::ScopedAStatus DrmPlugin::decrypt(const std::vector& in_sessionId, + const std::vector& in_keyId, + const std::vector& in_input, + const std::vector& in_iv, + std::vector* _aidl_return) { + UNUSED(in_sessionId); + UNUSED(in_keyId); + UNUSED(in_input); + UNUSED(in_iv); + UNUSED(_aidl_return); + return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); +} + +::ndk::ScopedAStatus DrmPlugin::encrypt(const std::vector& in_sessionId, + const std::vector& in_keyId, + const std::vector& in_input, + const std::vector& in_iv, + std::vector* _aidl_return) { + UNUSED(in_sessionId); + UNUSED(in_keyId); + UNUSED(in_input); + UNUSED(in_iv); + UNUSED(_aidl_return); + return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); +} + +::ndk::ScopedAStatus DrmPlugin::getHdcpLevels( + ::aidl::android::hardware::drm::HdcpLevels* _aidl_return) { + UNUSED(_aidl_return); + return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); +} + +::ndk::ScopedAStatus DrmPlugin::getKeyRequest( + const std::vector& in_scope, + const std::vector& in_initData, + const std::string& in_mimeType, + ::aidl::android::hardware::drm::KeyType in_keyType, + const std::vector<::aidl::android::hardware::drm::KeyValue>& in_optionalParameters, + ::aidl::android::hardware::drm::KeyRequest* _aidl_return) { + UNUSED(in_scope); + UNUSED(in_initData); + UNUSED(in_mimeType); + UNUSED(in_keyType); + UNUSED(in_optionalParameters); + UNUSED(_aidl_return); + return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); +} + +::ndk::ScopedAStatus DrmPlugin::getLogMessages( + std::vector<::aidl::android::hardware::drm::LogMessage>* _aidl_return) { + UNUSED(_aidl_return); + return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); +} + +::ndk::ScopedAStatus DrmPlugin::getMetrics( + std::vector<::aidl::android::hardware::drm::DrmMetricGroup>* _aidl_return) { + UNUSED(_aidl_return); + return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); +} + +::ndk::ScopedAStatus DrmPlugin::getNumberOfSessions( + ::aidl::android::hardware::drm::NumberOfSessions* _aidl_return) { + UNUSED(_aidl_return); + return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); +} + +::ndk::ScopedAStatus DrmPlugin::getOfflineLicenseKeySetIds( + std::vector<::aidl::android::hardware::drm::KeySetId>* _aidl_return) { + UNUSED(_aidl_return); + return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); +} + +::ndk::ScopedAStatus DrmPlugin::getOfflineLicenseState( + const ::aidl::android::hardware::drm::KeySetId& in_keySetId, + ::aidl::android::hardware::drm::OfflineLicenseState* _aidl_return) { + UNUSED(in_keySetId); + UNUSED(_aidl_return); + return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); +} + +::ndk::ScopedAStatus DrmPlugin::getPropertyString(const std::string& in_propertyName, + std::string* _aidl_return) { + UNUSED(in_propertyName); + UNUSED(_aidl_return); + return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); +} + +::ndk::ScopedAStatus DrmPlugin::getProvisionRequest( + const std::string& in_certificateType, + const std::string& in_certificateAuthority, + ::aidl::android::hardware::drm::ProvisionRequest* _aidl_return) { + UNUSED(in_certificateType); + UNUSED(in_certificateAuthority); + UNUSED(_aidl_return); + return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); +} + +::ndk::ScopedAStatus DrmPlugin::getSecureStop( + const ::aidl::android::hardware::drm::SecureStopId& in_secureStopId, + ::aidl::android::hardware::drm::SecureStop* _aidl_return) { + UNUSED(in_secureStopId); + UNUSED(_aidl_return); + return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); +} + +::ndk::ScopedAStatus DrmPlugin::getSecureStopIds( + std::vector<::aidl::android::hardware::drm::SecureStopId>* _aidl_return) { + UNUSED(_aidl_return); + return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); +} + +::ndk::ScopedAStatus DrmPlugin::getSecureStops( + std::vector<::aidl::android::hardware::drm::SecureStop>* _aidl_return) { + UNUSED(_aidl_return); + return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); +} + +::ndk::ScopedAStatus DrmPlugin::getSecurityLevel( + const std::vector& in_sessionId, + ::aidl::android::hardware::drm::SecurityLevel* _aidl_return) { + UNUSED(in_sessionId); + UNUSED(_aidl_return); + return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); +} + +::ndk::ScopedAStatus DrmPlugin::provideKeyResponse( + const std::vector& in_scope, + const std::vector& in_response, + ::aidl::android::hardware::drm::KeySetId* _aidl_return) { + UNUSED(in_scope); + UNUSED(in_response); + UNUSED(_aidl_return); + return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); +} + +::ndk::ScopedAStatus DrmPlugin::provideProvisionResponse( + const std::vector& in_response, + ::aidl::android::hardware::drm::ProvideProvisionResponseResult* _aidl_return) { + UNUSED(in_response); + UNUSED(_aidl_return); + return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); +} + +::ndk::ScopedAStatus DrmPlugin::queryKeyStatus( + const std::vector& in_sessionId, + std::vector<::aidl::android::hardware::drm::KeyValue>* _aidl_return) { + UNUSED(in_sessionId); + UNUSED(_aidl_return); + return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); +} + +::ndk::ScopedAStatus DrmPlugin::releaseAllSecureStops() { + return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); +} + +::ndk::ScopedAStatus DrmPlugin::releaseSecureStop( + const ::aidl::android::hardware::drm::SecureStopId& in_secureStopId) { + UNUSED(in_secureStopId); + return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); +} + +::ndk::ScopedAStatus DrmPlugin::releaseSecureStops( + const ::aidl::android::hardware::drm::OpaqueData& in_ssRelease) { + UNUSED(in_ssRelease); + return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); +} + +::ndk::ScopedAStatus DrmPlugin::removeAllSecureStops() { + return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); +} + +::ndk::ScopedAStatus DrmPlugin::removeKeys(const std::vector& in_sessionId) { + UNUSED(in_sessionId); + return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); +} + +::ndk::ScopedAStatus DrmPlugin::removeOfflineLicense( + const ::aidl::android::hardware::drm::KeySetId& in_keySetId) { + UNUSED(in_keySetId); + return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); +} + +::ndk::ScopedAStatus DrmPlugin::removeSecureStop( + const ::aidl::android::hardware::drm::SecureStopId& in_secureStopId) { + UNUSED(in_secureStopId); + return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); +} + +::ndk::ScopedAStatus DrmPlugin::requiresSecureDecoder( + const std::string& in_mime, + ::aidl::android::hardware::drm::SecurityLevel in_level, + bool* _aidl_return) { + UNUSED(in_mime); + UNUSED(in_level); + UNUSED(_aidl_return); + return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); +} + +::ndk::ScopedAStatus DrmPlugin::restoreKeys( + const std::vector& in_sessionId, + const ::aidl::android::hardware::drm::KeySetId& in_keySetId) { + UNUSED(in_sessionId); + UNUSED(in_keySetId); + return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); +} + +::ndk::ScopedAStatus DrmPlugin::setCipherAlgorithm(const std::vector& in_sessionId, + const std::string& in_algorithm) { + UNUSED(in_sessionId); + UNUSED(in_algorithm); + return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); +} + +::ndk::ScopedAStatus DrmPlugin::setListener( + const std::shared_ptr<::aidl::android::hardware::drm::IDrmPluginListener>& + in_listener) { + UNUSED(in_listener); + return toNdkScopedAStatus(Status::OK); +} + +::ndk::ScopedAStatus DrmPlugin::setMacAlgorithm(const std::vector& in_sessionId, + const std::string& in_algorithm) { + UNUSED(in_sessionId); + UNUSED(in_algorithm); + return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); +} + +::ndk::ScopedAStatus DrmPlugin::setPlaybackId(const std::vector& in_sessionId, + const std::string& in_playbackId) { + UNUSED(in_sessionId); + UNUSED(in_playbackId); + return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); +} + +::ndk::ScopedAStatus DrmPlugin::setPropertyByteArray(const std::string& in_propertyName, + const std::vector& in_value) { + UNUSED(in_propertyName); + UNUSED(in_value); + return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); +} + +::ndk::ScopedAStatus DrmPlugin::setPropertyString(const std::string& in_propertyName, + const std::string& in_value) { + UNUSED(in_propertyName); + UNUSED(in_value); + return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); +} + +::ndk::ScopedAStatus DrmPlugin::sign(const std::vector& in_sessionId, + const std::vector& in_keyId, + const std::vector& in_message, + std::vector* _aidl_return) { + UNUSED(in_sessionId); + UNUSED(in_keyId); + UNUSED(in_message); + UNUSED(_aidl_return); + return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); +} + +::ndk::ScopedAStatus DrmPlugin::verify(const std::vector& in_sessionId, + const std::vector& in_keyId, + const std::vector& in_message, + const std::vector& in_signature, + bool* _aidl_return) { + UNUSED(in_sessionId); + UNUSED(in_keyId); + UNUSED(in_message); + UNUSED(in_signature); + UNUSED(_aidl_return); + return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE); +} + + +} // namespace castkey +} // namespace drm +} // namespace hardware +} // namespace android +} // namespace aidl diff --git a/cast_auth/mediadrm/Service.cpp b/cast_auth/mediadrm/Service.cpp new file mode 100644 index 0000000..53b50e2 --- /dev/null +++ b/cast_auth/mediadrm/Service.cpp @@ -0,0 +1,23 @@ +#define LOG_TAG "castkey-main" + +#include +#include +#include +#include "CreatePluginFactories.h" + +using ::android::base::InitLogging; +using ::android::base::LogdLogger; +using ::aidl::android::hardware::drm::castkey::createDrmFactory; +using ::aidl::android::hardware::drm::castkey::DrmFactory; + +int main(int /*argc*/, char* argv[]) { + InitLogging(argv, LogdLogger()); + ABinderProcess_setThreadPoolMaxThreadCount(8); + std::shared_ptr drmFactory = createDrmFactory(); + const std::string drmInstance = std::string() + DrmFactory::descriptor + "/castkey"; + binder_status_t status = + AServiceManager_addService(drmFactory->asBinder().get(), drmInstance.c_str()); + CHECK(status == STATUS_OK); + ABinderProcess_joinThreadPool(); + return EXIT_FAILURE; +} \ No newline at end of file diff --git a/cast_auth/mediadrm/SessionLibrary.cpp b/cast_auth/mediadrm/SessionLibrary.cpp new file mode 100644 index 0000000..8d56660 --- /dev/null +++ b/cast_auth/mediadrm/SessionLibrary.cpp @@ -0,0 +1,39 @@ +#include "SessionLibrary.h" + +#include +#include + +namespace castkeydrm { + +std::mutex SessionLibrary::singleton_lock_; +SessionLibrary* SessionLibrary::singleton_ = NULL; + +SessionLibrary* SessionLibrary::get() { + std::lock_guard guard(singleton_lock_); + + if (singleton_ == NULL) { + singleton_ = new SessionLibrary(); + } + + return singleton_; +} + +std::vector SessionLibrary::createSession() { + std::lock_guard guard(session_lock_); + + std::string session_string = std::to_string(next_session_id_); + next_session_id_ += 1; + sessions_.emplace_back(session_string.begin(), session_string.end()); + return sessions_.back(); +} + +void SessionLibrary::closeSession(const std::vector& session) { + std::lock_guard guard(session_lock_); + sessions_.erase(std::remove_if(sessions_.begin(), sessions_.end(), + [&session](const std::vector& e) { + return std::equal(e.begin(), e.end(), session.begin()); + }), + sessions_.end()); +} + +} // namespace castkeydrm \ No newline at end of file diff --git a/cast_auth/mediadrm/android.hardware.drm-service.castkey.rc b/cast_auth/mediadrm/android.hardware.drm-service.castkey.rc new file mode 100644 index 0000000..73106a9 --- /dev/null +++ b/cast_auth/mediadrm/android.hardware.drm-service.castkey.rc @@ -0,0 +1,6 @@ +service vendor.drm-castkey-service /vendor/bin/hw/android.hardware.drm-service.castkey + class hal + user media + group mediadrm drmrpc + ioprio rt 4 + interface aidl android.hardware.drm.IDrmFactory/castkey diff --git a/cast_auth/mediadrm/include/CastKeyTypes.h b/cast_auth/mediadrm/include/CastKeyTypes.h new file mode 100644 index 0000000..5eb17f7 --- /dev/null +++ b/cast_auth/mediadrm/include/CastKeyTypes.h @@ -0,0 +1,48 @@ +#ifndef CASTKEY_TYPES_H_ +#define CASTKEY_TYPES_H_ + +#include +#include +#include + +namespace castkeydrm { + +const uint8_t kBlockSize = 16; // AES_BLOCK_SIZE; +typedef uint8_t KeyId[kBlockSize]; +typedef uint8_t Iv[kBlockSize]; + +typedef std::map, std::vector> KeyMap; + +#define CASTKEY_DISALLOW_COPY_AND_ASSIGN(TypeName) \ + TypeName(const TypeName&) = delete; \ + void operator=(const TypeName&) = delete; + +#define CASTKEY_DISALLOW_COPY_AND_ASSIGN_AND_NEW(TypeName) \ + TypeName() = delete; \ + TypeName(const TypeName&) = delete; \ + void operator=(const TypeName&) = delete; + +enum CdmResponseType : int32_t { + OK = 0, + ERROR_NO_LICENSE = 1, + ERROR_SESSION_NOT_OPENED = 3, + ERROR_CANNOT_HANDLE = 4, + ERROR_INVALID_STATE = 5, + BAD_VALUE = 6, + ERROR_DECRYPT = 11, + ERROR_UNKNOWN = 12, + ERROR_INSUFFICIENT_SECURITY = 13, + ERROR_FRAME_TOO_LARGE = 14, + ERROR_SESSION_LOST_STATE = 15, + ERROR_RESOURCE_CONTENTION = 16, +}; + +enum CdmKeyType : int32_t { + KEY_TYPE_OFFLINE = 0, + KEY_TYPE_STREAMING = 1, + KEY_TYPE_RELEASE = 2, +}; + +} // namespace castkeydrm + +#endif // CASTKEY_TYPES_H_ \ No newline at end of file diff --git a/cast_auth/mediadrm/include/CreatePluginFactories.h b/cast_auth/mediadrm/include/CreatePluginFactories.h new file mode 100644 index 0000000..acf9545 --- /dev/null +++ b/cast_auth/mediadrm/include/CreatePluginFactories.h @@ -0,0 +1,20 @@ +#ifndef CREATE_PLUGIN_FACTORIES_H_ +#define CREATE_PLUGIN_FACTORIES_H_ + +#include "DrmFactory.h" + +namespace aidl { +namespace android { +namespace hardware { +namespace drm { +namespace castkey { + +std::shared_ptr createDrmFactory(); + +} // namespace castkey +} // namespace drm +} // namespace hardware +} // namespace android +} // namespace aidl + +#endif // CREATE_PLUGIN_FACTORIES_H_ \ No newline at end of file diff --git a/cast_auth/mediadrm/include/DrmFactory.h b/cast_auth/mediadrm/include/DrmFactory.h new file mode 100644 index 0000000..eb0816d --- /dev/null +++ b/cast_auth/mediadrm/include/DrmFactory.h @@ -0,0 +1,50 @@ +#ifndef DRM_FACTORY_H_ +#define DRM_FACTORY_H_ + +#include +#include +#include +#include + +#include +#include + +#include "CastKeyTypes.h" + +namespace aidl { +namespace android { +namespace hardware { +namespace drm { +namespace castkey { + +struct DrmFactory : public BnDrmFactory { + DrmFactory() {}; + virtual ~DrmFactory() {}; + + ::ndk::ScopedAStatus createDrmPlugin( + const ::aidl::android::hardware::drm::Uuid& in_uuid, + const std::string& in_appPackageName, + std::shared_ptr<::aidl::android::hardware::drm::IDrmPlugin>* _aidl_return) override; + + ::ndk::ScopedAStatus createCryptoPlugin( + const ::aidl::android::hardware::drm::Uuid& in_uuid, + const std::vector& in_initData, + std::shared_ptr<::aidl::android::hardware::drm::ICryptoPlugin>* _aidl_return) override; + + ::ndk::ScopedAStatus getSupportedCryptoSchemes( + ::aidl::android::hardware::drm::CryptoSchemes* _aidl_return) override; + + binder_status_t dump(int fd, const char** args, uint32_t numArgs) override; + + + private: + CASTKEY_DISALLOW_COPY_AND_ASSIGN(DrmFactory); +}; + +} // namespace castkey +} // namespace drm +} // namespace hardware +} // namespace android +} // namespace aidl + +#endif // DRM_FACTORIES_H_ diff --git a/cast_auth/mediadrm/include/DrmPlugin.h b/cast_auth/mediadrm/include/DrmPlugin.h new file mode 100644 index 0000000..f6a3f6f --- /dev/null +++ b/cast_auth/mediadrm/include/DrmPlugin.h @@ -0,0 +1,143 @@ +#ifndef DRM_PLUGIN_H_ +#define DRM_PLUGIN_H_ + +#include +#include +#include + +#include +#include + +#include + +namespace aidl { +namespace android { +namespace hardware { +namespace drm { +namespace castkey { + +using namespace castkeydrm; +using ::aidl::android::hardware::drm::KeyType; +using ::aidl::android::hardware::drm::Status; + +struct DrmPlugin : public BnDrmPlugin { +public: + explicit DrmPlugin(); + virtual ~DrmPlugin(); + + ::ndk::ScopedAStatus closeSession(const std::vector& in_sessionId) override; + ::ndk::ScopedAStatus decrypt(const std::vector& in_sessionId, + const std::vector& in_keyId, + const std::vector& in_input, + const std::vector& in_iv, + std::vector* _aidl_return) override; + ::ndk::ScopedAStatus encrypt(const std::vector& in_sessionId, + const std::vector& in_keyId, + const std::vector& in_input, + const std::vector& in_iv, + std::vector* _aidl_return) override; + ::ndk::ScopedAStatus getHdcpLevels( + ::aidl::android::hardware::drm::HdcpLevels* _aidl_return) override; + ::ndk::ScopedAStatus getKeyRequest( + const std::vector& in_scope, + const std::vector& in_initData, + const std::string& in_mimeType, + ::aidl::android::hardware::drm::KeyType in_keyType, + const std::vector<::aidl::android::hardware::drm::KeyValue>& in_optionalParameters, + ::aidl::android::hardware::drm::KeyRequest* _aidl_return) override; + ::ndk::ScopedAStatus getLogMessages( + std::vector<::aidl::android::hardware::drm::LogMessage>* _aidl_return) override; + + ::ndk::ScopedAStatus getMetrics( + std::vector<::aidl::android::hardware::drm::DrmMetricGroup>* _aidl_return) override; + ::ndk::ScopedAStatus getNumberOfSessions( + ::aidl::android::hardware::drm::NumberOfSessions* _aidl_return) override; + ::ndk::ScopedAStatus getOfflineLicenseKeySetIds( + std::vector<::aidl::android::hardware::drm::KeySetId>* _aidl_return) override; + ::ndk::ScopedAStatus getOfflineLicenseState( + const ::aidl::android::hardware::drm::KeySetId& in_keySetId, + ::aidl::android::hardware::drm::OfflineLicenseState* _aidl_return) override; + ::ndk::ScopedAStatus getPropertyByteArray(const std::string& in_propertyName, + std::vector* _aidl_return) override; + ::ndk::ScopedAStatus getPropertyString(const std::string& in_propertyName, + std::string* _aidl_return) override; + ::ndk::ScopedAStatus getProvisionRequest( + const std::string& in_certificateType, + const std::string& in_certificateAuthority, + ::aidl::android::hardware::drm::ProvisionRequest* _aidl_return) override; + ::ndk::ScopedAStatus getSecureStop( + const ::aidl::android::hardware::drm::SecureStopId& in_secureStopId, + ::aidl::android::hardware::drm::SecureStop* _aidl_return) override; + ::ndk::ScopedAStatus getSecureStopIds( + std::vector<::aidl::android::hardware::drm::SecureStopId>* _aidl_return) override; + ::ndk::ScopedAStatus getSecureStops( + std::vector<::aidl::android::hardware::drm::SecureStop>* _aidl_return) override; + ::ndk::ScopedAStatus getSecurityLevel( + const std::vector& in_sessionId, + ::aidl::android::hardware::drm::SecurityLevel* _aidl_return) override; + ::ndk::ScopedAStatus openSession(::aidl::android::hardware::drm::SecurityLevel in_securityLevel, + std::vector* _aidl_return) override; + ::ndk::ScopedAStatus provideKeyResponse( + const std::vector& in_scope, + const std::vector& in_response, + ::aidl::android::hardware::drm::KeySetId* _aidl_return) override; + ::ndk::ScopedAStatus provideProvisionResponse( + const std::vector& in_response, + ::aidl::android::hardware::drm::ProvideProvisionResponseResult* _aidl_return) override; + ::ndk::ScopedAStatus queryKeyStatus( + const std::vector& in_sessionId, + std::vector<::aidl::android::hardware::drm::KeyValue>* _aidl_return) override; + ::ndk::ScopedAStatus releaseAllSecureStops() override; + ::ndk::ScopedAStatus releaseSecureStop( + const ::aidl::android::hardware::drm::SecureStopId& in_secureStopId) override; + ::ndk::ScopedAStatus releaseSecureStops( + const ::aidl::android::hardware::drm::OpaqueData& in_ssRelease) override; + ::ndk::ScopedAStatus removeAllSecureStops() override; + ::ndk::ScopedAStatus removeKeys(const std::vector& in_sessionId) override; + ::ndk::ScopedAStatus removeOfflineLicense( + const ::aidl::android::hardware::drm::KeySetId& in_keySetId) override; + ::ndk::ScopedAStatus removeSecureStop( + const ::aidl::android::hardware::drm::SecureStopId& in_secureStopId) override; + ::ndk::ScopedAStatus requiresSecureDecoder( + const std::string& in_mime, + ::aidl::android::hardware::drm::SecurityLevel in_level, + bool* _aidl_return) override; + ::ndk::ScopedAStatus restoreKeys( + const std::vector& in_sessionId, + const ::aidl::android::hardware::drm::KeySetId& in_keySetId) override; + ::ndk::ScopedAStatus setCipherAlgorithm(const std::vector& in_sessionId, + const std::string& in_algorithm) override; + ::ndk::ScopedAStatus setListener( + const std::shared_ptr<::aidl::android::hardware::drm::IDrmPluginListener>& + in_listener) override; + ::ndk::ScopedAStatus setMacAlgorithm(const std::vector& in_sessionId, + const std::string& in_algorithm) override; + ::ndk::ScopedAStatus setPlaybackId(const std::vector& in_sessionId, + const std::string& in_playbackId) override; + ::ndk::ScopedAStatus setPropertyByteArray(const std::string& in_propertyName, + const std::vector& in_value) override; + ::ndk::ScopedAStatus setPropertyString(const std::string& in_propertyName, + const std::string& in_value) override; + ::ndk::ScopedAStatus sign(const std::vector& in_sessionId, + const std::vector& in_keyId, + const std::vector& in_message, + std::vector* _aidl_return) override; + ::ndk::ScopedAStatus signRSA(const std::vector& in_sessionId, + const std::string& in_algorithm, + const std::vector& in_message, + const std::vector& in_wrappedkey, + std::vector* _aidl_return) override; + ::ndk::ScopedAStatus verify(const std::vector& in_sessionId, + const std::vector& in_keyId, + const std::vector& in_message, + const std::vector& in_signature, + bool* _aidl_return) override; +}; + +} // namespace castkey +} // namespace drm +} // namespace hardware +} // namespace android +} // namespace aidl + +#endif // DRM_PLUGIN_H_ \ No newline at end of file diff --git a/cast_auth/mediadrm/include/SessionLibrary.h b/cast_auth/mediadrm/include/SessionLibrary.h new file mode 100644 index 0000000..d2d0e49 --- /dev/null +++ b/cast_auth/mediadrm/include/SessionLibrary.h @@ -0,0 +1,28 @@ +#ifndef SESSION_LIBRARY_H_ +#define SESSION_LIBRARY_H_ + +#include +#include + +namespace castkeydrm { + +class SessionLibrary { +public: + static SessionLibrary* get(); + std::vector createSession(); + void closeSession(const std::vector& session); + +private: + SessionLibrary() : next_session_id_(1) {} + + static std::mutex singleton_lock_; + static SessionLibrary* singleton_; + + std::mutex session_lock_; + uint32_t next_session_id_; + std::vector> sessions_; +}; + +} // namespace castkeydrm + +#endif // SESSION_LIBRARY_H_ \ No newline at end of file diff --git a/cast_auth/mediadrm/include/Utils.h b/cast_auth/mediadrm/include/Utils.h new file mode 100644 index 0000000..98821f4 --- /dev/null +++ b/cast_auth/mediadrm/include/Utils.h @@ -0,0 +1,44 @@ +#ifndef UTILS_H_ +#define UTILS_H_ + +#include + +#include "SessionLibrary.h" + +#include +#include "aidl/android/hardware/drm/Status.h" +#include "CastKeyTypes.h" + +namespace aidl { +namespace android { +namespace hardware { +namespace drm { +namespace castkey { + +inline ::ndk::ScopedAStatus toNdkScopedAStatus(::aidl::android::hardware::drm::Status status, + const char* msg = nullptr) { + if (Status::OK == status) { + return ::ndk::ScopedAStatus::ok(); + } else { + auto err = static_cast(status); + if (msg) { + return ::ndk::ScopedAStatus::fromServiceSpecificErrorWithMessage(err, msg); + } else { + return ::ndk::ScopedAStatus::fromServiceSpecificError(err); + } + } +} + +inline ::ndk::ScopedAStatus toNdkScopedAStatus(castkeydrm::CdmResponseType res) { + return toNdkScopedAStatus(static_cast<::aidl::android::hardware::drm::Status>(res)); +} + +#define UNUSED(x) (void)(x); + +} // namespace castkey +} // namespace drm +} // namespace hardware +} // namespace android +} // namespace aidl + +#endif // UTILS_H_ diff --git a/cast_auth/mediadrm/manifest_android.hardware.drm-service.castkey.xml b/cast_auth/mediadrm/manifest_android.hardware.drm-service.castkey.xml new file mode 100644 index 0000000..412a10b --- /dev/null +++ b/cast_auth/mediadrm/manifest_android.hardware.drm-service.castkey.xml @@ -0,0 +1,7 @@ + + + android.hardware.drm + 1 + IDrmFactory/castkey + + \ No newline at end of file diff --git a/device-tangorpro.mk b/device-tangorpro.mk index 3c6a790..d1d1ada 100644 --- a/device-tangorpro.mk +++ b/device-tangorpro.mk @@ -258,6 +258,13 @@ PRODUCT_VENDOR_PROPERTIES += \ PRODUCT_SOONG_NAMESPACES += \ vendor/lib64 +# TODO(b/366426322): Merge CastKey Drm plugin into `device/google/gs-common`. +# CastKey Drm plugin modules +PRODUCT_SOONG_NAMESPACES += \ + device/google/tangorpro/cast_auth/mediadrm +PRODUCT_PACKAGES += \ + android.hardware.drm-service.castkey + # MIPI Coex Configs PRODUCT_COPY_FILES += \ device/google/tangorpro/radio/tangor_camera_front_mipi_coex_table.csv:$(TARGET_COPY_OUT_VENDOR)/etc/modem/camera_front_mipi_coex_table.csv \