Files
android/libwvdrmengine/tools/ota_keybox/set_debug_count.sh
Alex Dale a402066b37 ADB script for OTA keybox testing
Added a test script for developers to run while testing OTA keybox
provisioning.  Writes to a special file on a device which alters how
the CDM treats L1's keybox.

Bug: 187646550
Test: Ran set_debug_count.sh
Change-Id: Ie9e2121565cda64cca392144c415e6bcfc024ef4
2021-12-09 21:20:58 -08:00

124 lines
3.0 KiB
Bash
Executable File

#!/usr/bin/bash
# Copyright 2021 Google LLC. All Rights Reserved. This file and proprietary
# source code may only be used and distributed under the Widevine License
# Agreement.
# Setup
adb_path=$(which adb)
if [ -z "$adb_path" ] || [ ! -f "$adb_path" ]; then
echo "Cannot find ADB" 1>&2
exit 1
fi
# Determine data path. On some devices, when the tests run as root,
# they use a different directory for the MediaDRM files.
while [ ! -z "$1" ]; do
case $1 in
-h | --help )
echo "Usage: [-s DEVICE_ID] [-r] [--wipe-l3]"
echo " Configures devices files for testing OTA Keybox Provisioning."
echo
echo "Optional arguments:"
echo " -h, --help Show this help message and exit"
echo " -s DEVICE_ID Specify device ID to use"
echo " -r, --root Use data directory for root user"
echo " (unittests only)"
echo " --wipe-l3 Wipe L3 data along with L1. Useful for"
echo " testing app robustness."
echo " --no-reboot Do not reboot the device after setup."
echo " Normally required if the CDM is in use."
exit
;;
-s | --id )
if [ -z "$2" ]; then
echo "Missing device ID for option $1" 1>&2
exit 2
fi
device_id="$2"
shift
shift
;;
-r | --root )
root_path="yes"
shift
;;
--wipe-l3 )
wipe_l3="yes"
shift
;;
--no-reboot )
reboot="no"
shift
;;
* )
echo "Unexpected argument: $1" 1>&2
exit 2
;;
esac
done
if [ ! -z "$device_id" ]; then
echo "Using device: $device_id"
export ANDROID_SERIAL="$device_id"
fi
# Must run as root to write to directory.
adb_user=$(adb shell whoami)
if [ "$adb_user" != "root" ]; then
echo "Changing ADB to run as root"
adb root
fi
# Select path for MediaDRM data.
if [ "$root_path" = "yes" ]; then
echo "Using root path: IDM0"
data_path="/data/vendor/mediadrm/IDM0"
else
echo "Using prod path: IDM1013"
data_path="/data/vendor/mediadrm/IDM1013"
fi
# Clear existing DRM data
if adb shell test -d "$data_path" ; then
echo "Deleting MediaDRM files..."
if adb shell test -d "$data_path/L1" ; then
echo "Deleting L1..."
adb shell rm -rf "$data_path/L1/*"
fi
if [ "$wipe_l3" = "yes" ] && adb shell test -d "$data_path/L3" ; then
echo "Deleting L3..."
adb shell rm -rf "$data_path/L3/*"
fi
fi
if ! adb shell test -d "$data_path/L1" ; then
if ! adb shell mkdir -p "$data_path/L1"; then
echo "Failed to create MediaDRM data directory" 1>&2
exit 1
fi
fi
# Set debug_ignore_keybox_count.txt
if [ "$root_path" = "yes" ]; then
adb shell <<'ALT_EOF'
echo 1 >> /data/vendor/mediadrm/IDM0/L1/debug_ignore_keybox_count.txt
exit
ALT_EOF
else
adb shell <<'EOF'
echo 1 >> /data/vendor/mediadrm/IDM1013/L1/debug_ignore_keybox_count.txt
exit
EOF
fi
if [ "$reboot" != "no" ]; then
adb reboot
echo "Waiting for device to boot..."
adb wait-for-device root
fi
adb logcat -G 8M