Skip to content

Commit

Permalink
2024 Update to TB 15
Browse files Browse the repository at this point in the history
  • Loading branch information
qbalsdon committed Nov 17, 2024
1 parent 26a27dc commit cdf6b79
Show file tree
Hide file tree
Showing 58 changed files with 2,485 additions and 114 deletions.
79 changes: 79 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Android CI

on:
push:
branches:
- main
- feature/**
pull_request:
branches:
- main
- feature/**

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- name: set up JDK 1.11
uses: actions/setup-java@v1
with:
java-version: 1.11

- name: Setup Android SDK
uses: android-actions/setup-android@v2

- name: Run Build Script
run: |
echo "Staring build"
echo "Android sdk location: [${ANDROID_SDK_ROOT}]"
export ANDROID_SDK=${ANDROID_SDK_ROOT}
echo "SDK Check: ANDROID_SDK=${ANDROID_SDK}"
echo "-----------------------------------------------------"
echo "JAVA HOME: [${JAVA_HOME}]"
echo "-----------------------------------------------------"
echo "BUILD START"
./build.sh -p
echo "BUILD COMPLETE"
echo "ARTIFACT INFORMATION"
ls -ln ./build/outputs/apk/phone/release/talkback-phone-release-unsigned.apk
ls -ln ./build/outputs/apk/wear/release/talkback-wear-release-unsigned.apk
- name: Sign Phone and Wear Artifacts
run: |
echo "Available build tools"
ls ${ANDROID_SDK_ROOT}/build-tools/
echo "--------------------------------------"
SIGNING_KEY=${{ secrets.SIGNING_KEY }}
SIGNING_PASSWORD=${{ secrets.KEY_STORE_PASSWORD }}
BUILD_TOOLS=33.0.0
BUILD_TOOLS_PATH=${ANDROID_SDK_ROOT}/build-tools/${BUILD_TOOLS}
ALIAS=${{ secrets.ALIAS }}
INPUT_FILE_PHONE=./build/outputs/apk/phone/release/talkback-phone-release-unsigned.apk
INPUT_FILE_WEAR=./build/outputs/apk/wear/release/talkback-wear-release-unsigned.apk
OUTPUT_FILE_PHONE="talkback-phone-release-signed-${{ github.run_number }}.apk"
OUTPUT_FILE_WEAR="talkback-wear-release-signed-${{ github.run_number }}.apk"
echo "${SIGNING_KEY}" | base64 --decode > talkback_keystore.jks
echo "SIGNING PHONE APK"
${BUILD_TOOLS_PATH}/zipalign -p -f 4 ${INPUT_FILE_PHONE} ${OUTPUT_FILE_PHONE}
${BUILD_TOOLS_PATH}/apksigner sign -ks talkback_keystore.jks --v1-signing-enabled true --v2-signing-enabled true --ks-key-alias ${ALIAS} --ks-pass pass:${SIGNING_PASSWORD} --key-pass pass:${SIGNING_PASSWORD} ${OUTPUT_FILE_PHONE}
${BUILD_TOOLS_PATH}/apksigner verify ${OUTPUT_FILE_PHONE}
echo "SIGNED_PHONE_ARTIFACT=${OUTPUT_FILE_PHONE}" >> $GITHUB_ENV
echo "---------------------------------------------"
echo "SIGNING WEAR APK"
${BUILD_TOOLS_PATH}/zipalign -p -f 4 ${INPUT_FILE_WEAR} ${OUTPUT_FILE_WEAR}
${BUILD_TOOLS_PATH}/apksigner sign -ks talkback_keystore.jks --v1-signing-enabled true --v2-signing-enabled true --ks-key-alias ${ALIAS} --ks-pass pass:${SIGNING_PASSWORD} --key-pass pass:${SIGNING_PASSWORD} ${OUTPUT_FILE_WEAR}
${BUILD_TOOLS_PATH}/apksigner verify ${OUTPUT_FILE_WEAR}
echo "SIGNED_WEAR_ARTIFACT=${OUTPUT_FILE_WEAR}" >> $GITHUB_ENV
echo "---------------------------------------------"
- name: Upload Mobile App Artifact
uses: actions/upload-artifact@v2
with:
name: app-phone-signed-${{ github.run_number }}.apk
path: ${{ env.SIGNED_PHONE_ARTIFACT }}

- name: Upload Wear App Artifact
uses: actions/upload-artifact@v2
with:
name: app-wear-signed-${{ github.run_number }}.apk
path: ${{ env.SIGNED_WEAR_ARTIFACT }}
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,9 @@ build/
proguard/build/
talkback/build/
utils/build/
.idea/
.cxx/
braille/translate/src/phone/res/
gradle/
gradlew
gradlew.bat
78 changes: 75 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
# Introduction

This repository contains source code for Google's TalkBack, which is a screen
![TalkBack For Developers Logo][100]

This repository contains forked source code for Google's TalkBack, which is a screen
reader for blind and visually-impaired users of Android. For usage instructions,
see
read
[TalkBack User Guide](https://support.google.com/accessibility/android/answer/6283677?hl=en).

### How to Build

To build TalkBack, run ./build.sh, which will produce an apk file.
To build TalkBack, run `./build.sh`, which will produce an apk file. You can also specify a serial number by running `./build.sh -s [SERIAL]` to automatically install to your device.

Ensure that:
- jenv local 1.8
- NDK 24.0.8215888 is installed

Try:
- Settings > Build, Execution, Deployment > Build Tools > Gradle > Gradle JDK
- corretto-11 is the java version

### How to Install

Expand All @@ -18,3 +28,65 @@ Install the apk onto your Android device in the usual manner using adb.
With the apk now installed on the device, the TalkBack service should now be
present under Settings -> Accessibility, and will be off by default. To turn it
on, toggle the switch preference to the on position.

### How to use with ADB

```shell
# Activate
adb shell settings put secure enabled_accessibility_services com.android.talkback4d/com.developer.talkback.TalkBackDevService

# Deactivate
adb shell settings put secure enabled_accessibility_services null

# General format
# All commands take the format of a broadcast
adb shell am broadcast -a com.a11y.adb.[ACTION] [OPTIONS]

BROADCAST () { adb shell am broadcast "$@"; }

# Perform actions
BROADCAST -a com.a11y.adb.previous # default granularity
BROADCAST -a com.a11y.adb.next # default granularity

BROADCAST -a com.a11y.adb.previous -e mode headings # move tp previous heading
BROADCAST -a com.a11y.adb.next -e mode headings # move to next heading

# Toggle settings
BROADCAST -a com.a11y.adb.toggle_speech_output # show special toasts for spoken text
BROADCAST -a com.a11y.adb.perform_click_action
BROADCAST -a com.a11y.adb.volume_toggle # special case that toggles between 5% and 50%
BROADCAST -a com.a11y.adb.debug_log_overlay # special case that toggles between 5% and 50%

# Custom settings
BROADCAST -a com.a11y.adb.block_out # toggle blocking out everything except the focused element
```

## All parameters
- [Action list][0]
- [Action parameter list in the SelectorController enum][1]
- [Developer settings][2]
- [Volume specific controls][3]

## TODO
- Add curtain
- Activate via ADB
- Dev tools:
- Colour contrast check
- Touch target size check
- Developer-friendly details on curtain (add to announcements)
- [NAF control checker][4]
- [x] Hide all screen except highlighted node
- Show labels

## FIXED
- Menus lacking dark mode / styling
- Back button in menus
- Colour focus preference crash
- Colour focus preference not applying

[0]: https://github.com/qbalsdon/talkback/blob/main/talkback/src/main/java/com/google/android/accessibility/talkback/adb/A11yAction.java
[1]: https://github.com/qbalsdon/talkback/blob/main/talkback/src/main/java/com/google/android/accessibility/talkback/selector/SelectorController.java#L116
[2]: https://github.com/qbalsdon/talkback/blob/main/talkback/src/main/java/com/google/android/accessibility/talkback/adb/ToggleDeveloperSetting.java
[3]: https://github.com/qbalsdon/talkback/blob/main/talkback/src/main/java/com/google/android/accessibility/talkback/adb/VolumeSetting.java
[4]: https://android.googlesource.com/platform/frameworks/uiautomator/+/android-support-test/src/main/java/android/support/test/uiautomator/AccessibilityNodeInfoDumper.java#125
[100]: ./talkback/src/main/res/drawable-xxxhdpi/icon_tb4d_round.png "TalkBack for developers"
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ allprojects {
android {
defaultConfig {
applicationId talkbackApplicationId
versionName talkbackVersionName + "-" + BUILD_TIMESTAMP
versionName talkbackVersionName + "-" + BUILD_TIMESTAMP + "-" + talkback4DevVersionName
minSdkVersion 26
targetSdkVersion 30
testInstrumentationRunner 'android.test.InstrumentationTestRunner'
Expand Down
134 changes: 100 additions & 34 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,11 @@
### ANDROID_SDK # path to local copy of Android SDK
### JAVA_HOME # path to local copy of Java SDK.

### Environment variables:
# ANDROID_SDK=~/Android/Sdk
# ANDROID_NDK=~/Android/Sdk/ndk
# The latest JDK,
# JAVA_HOME=/usr/local/buildtools/java/jdk
# JDK 17, work for current build,
# JAVA_HOME=/google/data/ro/projects/java-platform/linux-amd64/jdk-17-latest/bin

# For help in getting the correct version numbers of gradle, the gradle plugin,
# and Java, see the following:
# https://developer.android.com/build/releases/gradle-plugin#updating-gradle
# https://docs.gradle.org/current/userguide/compatibility.html
GRADLE_DOWNLOAD_VERSION=7.6.4
GRADLE_TRACE=false # change to true to enable verbose logging of gradle

#-----------------------------------------------------------------------------
DEVICE=""
PIPELINE=false
USAGE="./build.sh [-j | --java ] [JAVA_VERSION] [-s | --device] [SERIAL_NUMBER] [-w | --wear]"
JAVA_VERSION="11.0.21"

function log {
if [[ -n $1 ]]; then
Expand All @@ -27,6 +17,31 @@ function log {
fi
}

if [[ -z $TALKBACK_JAVA_VERSION ]]; then
log "the environment variable TALKBACK_JAVA_VERSION is not set"
else
log "TALKBACK_JAVA_VERSION: ${TALKBACK_JAVA_VERSION}"
JAVA_VERSION=$TALKBACK_JAVA_VERSION
fi

log "Using JAVA $JAVA_VERSION to build"

while [[ "$#" -gt 0 ]]; do
case $1 in
-s|--device) DEVICE="$2"; shift ;;
-w|--wear) WEAR=true; shift ;;
-j|--java) JAVA_VERSION="$2"; shift ;;
-p) PIPELINE=true; shift ;;
-h|--help) echo $USAGE; exit 0 ;;
*) echo "Unknown parameter passed: $1"; exit 1 ;;
esac
shift
done
#-----------------------------------------------------------------------------

GRADLE_DOWNLOAD_VERSION=7.6.4
GRADLE_TRACE=false # change to true to enable verbose logging of gradlew

function fail_with_message {
echo
echo "Error: ${1}"
Expand All @@ -36,6 +51,7 @@ function fail_with_message {
function require_environment_variable() {
if [[ -z ${!1+set} ]]; then
fail_with_message "the environment variable $1 is not set"
exit 1
else
log "${1}: ${!1}"
fi
Expand All @@ -44,16 +60,28 @@ function require_environment_variable() {
function require_folder_exists() {
if [[ ! -d "${1}" ]]; then
fail_with_message "the folder at ${1} does not exist"
exit 1
else
log "ls ${1}"; ls "${1}"
fi
}


log "pwd: $(pwd)"
log "ls"; ls
log

#-----------------------------------------------------------------------------
TEMP_DIR=~/tmp
if [[ "$PIPELINE" = false ]]; then
log "!! CURRENT JAVA_HOME: [$JAVA_HOME] !!"
unset JAVA_HOME;
export JAVA_HOME=$(/usr/libexec/java_home -v"${JAVA_VERSION}");
log "!! NEW JAVA_HOME: [$JAVA_HOME] !!"
else
TEMP_DIR=$(mktemp -d)
fi
mkdir -p $TEMP_DIR/opt
#-----------------------------------------------------------------------------

require_environment_variable ANDROID_SDK
require_folder_exists "${ANDROID_SDK}"
Expand All @@ -67,23 +95,51 @@ echo "sdk.dir=${ANDROID_SDK}" > local.properties
log "cat local.properties"; cat local.properties
log

log "\${JAVA_HOME}: ${JAVA_HOME}"
log "ls \${JAVA_HOME}:"; ls "${JAVA_HOME}"
log "java -version:"; java -version
log "javac -version:"; javac -version
log

# Download the gradle binary at the version set atop this file
GRADLE_ZIP_REMOTE_FILE=gradle-${GRADLE_DOWNLOAD_VERSION}-bin.zip
GRADLE_ZIP_DEST_PATH=~/${GRADLE_DOWNLOAD_VERSION}.zip
log "Download gradle binary from the web ${GRADLE_ZIP_REMOTE_FILE} to ${GRADLE_ZIP_DEST_PATH} using wget"
time wget -O ${GRADLE_ZIP_DEST_PATH} https://services.gradle.org/distributions/${GRADLE_ZIP_REMOTE_FILE}
log
GRADLE_ZIP_DEST_PATH=${TEMP_DIR}/gradle-${GRADLE_DOWNLOAD_VERSION}.zip
GRADLE_UNZIP_HOSTING_FOLDER=${TEMP_DIR}/opt/gradle-${GRADLE_DOWNLOAD_VERSION}

if [[ ! -f "$GRADLE_ZIP_DEST_PATH" ]]; then
log "--> Downloading GRADLE"
log "Download gradle binary from the web ${GRADLE_ZIP_REMOTE_FILE} to ${GRADLE_ZIP_DEST_PATH} using curl"
sudo curl -L -o ${GRADLE_ZIP_DEST_PATH} https://services.gradle.org/distributions/${GRADLE_ZIP_REMOTE_FILE}
else
log "--> Using downloaded file: [$GRADLE_ZIP_DEST_PATH]"
fi


# Unzip the gradle binary
GRADLE_UNZIP_HOSTING_FOLDER=/opt/gradle-${GRADLE_DOWNLOAD_VERSION}
log "Unzip gradle zipfile ${GRADLE_ZIP_DEST_PATH} to ${GRADLE_UNZIP_HOSTING_FOLDER}"
sudo unzip -n -d ${GRADLE_UNZIP_HOSTING_FOLDER} ${GRADLE_ZIP_DEST_PATH}
unzip -n -d ${GRADLE_UNZIP_HOSTING_FOLDER} ${GRADLE_ZIP_DEST_PATH}
if [ $? -eq 0 ]; then
log "unzip succeeded"
else
log "!! UNZIP FAILED !!"
log "unzip -n -d ${GRADLE_UNZIP_HOSTING_FOLDER} ${GRADLE_ZIP_DEST_PATH}"
if [ ! -f ${GRADLE_UNZIP_HOSTING_FOLDER} ]; then
log "[${GRADLE_UNZIP_HOSTING_FOLDER}] not found!"
log "Contents of [${TEMP_DIR}]:"
log $(ls ${TEMP_DIR})
fi

log
exit 1
fi
log


GRADLE_BINARY=${GRADLE_UNZIP_HOSTING_FOLDER}/gradle-${GRADLE_DOWNLOAD_VERSION}/bin/gradle
log "\${GRADLE_BINARY} = ${GRADLE_BINARY}"
log "\${GRADLE_BINARY} -version"
log "${GRADLE_BINARY} -version"
${GRADLE_BINARY} -version
log "Obtain gradle wrapper"
log "$GRADLE_BINARY wrapper --gradle-version ${GRADLE_DOWNLOAD_VERSION}"
${GRADLE_BINARY} wrapper --gradle-version ${GRADLE_DOWNLOAD_VERSION}
log


Expand All @@ -94,23 +150,33 @@ if [[ "$GRADLE_TRACE" = true ]]; then
fi


GRADLE_DEBUG=
GRADLE_STACKTRACE=
GRADLEW_DEBUG=
GRADLEW_STACKTRACE=
if [[ "$GRADLE_TRACE" = true ]]; then
GRADLE_DEBUG=--debug
GRADLE_STACKTRACE=--stacktrace
GRADLEW_DEBUG=--debug
GRADLEW_STACKTRACE=--stacktrace
fi
log "${GRADLE_BINARY} assembleDebug"
${GRADLE_BINARY} ${GRADLE_DEBUG} ${GRADLE_STACKTRACE} assembleDebug
log "./${GRADLE_BINARY} assemble"
${GRADLE_BINARY} ${GRADLEW_DEBUG} ${GRADLEW_STACKTRACE} assemble
BUILD_EXIT_CODE=$?
log


if [[ $BUILD_EXIT_CODE -eq 0 ]]; then
log "find . -name *.apk"
find . -name "*.apk"
log
fi

if [[ ! -z $DEVICE ]]; then
log "precaution: uninstalling from $DEVICE"
adb -s "$DEVICE" uninstall com.android.talkback4d
if [[ -z $WEAR ]]; then
log "[device=PHONE] installing on $DEVICE"
adb -s "$DEVICE" install ./build/outputs/apk/phone/debug/talkback-phone-debug.apk
else
log "[device=WEAR] installing on $DEVICE"
adb -s "$DEVICE" install ./build/outputs/apk/wear/debug/talkback-wear-debug.apk
fi
fi
fi

exit $BUILD_EXIT_CODE ### This should be the last line in this file
exit $BUILD_EXIT_CODE ### This should be the last line in this file
Loading

0 comments on commit cdf6b79

Please sign in to comment.