[Nexus 7 (2013) LTE Android Development] linuxthinker:
Hi, I migrated to T-Mobile awhile back so I haven't been making patches (T-Mobile allows tethering out-of-the-box). I made these images on Linux since it's using bash/perl, but it should work on OS X with minimal changes. Windows might work if you have Cygwin.

Before you start, you need framework-res.apk from the target version that you're trying to patch. You can either "adb pull" it from your device after you've accepted the update or you can fetch it from the factory image. If you're fetching it from the factory image, unpack system.img from the .tgz, convert it from a sparse image into a regular image (https://github.com/mcrosson/android...629b6ecab55bdb80ec9c8738c5c83882e/simg2img.py), mount it (mount -o loop system-converter.img /mnt/tmp), and copy framework-res.apk into a temp directory.

Tools you'll need:

apktool: https://ibotpeaches.github.io/Apktool/

android sdk: https://dl.google.com/android/android-sdk_r24.4.1-linux.tgz (or some other version from https://developer.android.com/studio/index.html)

xsltproc: optional - you can skip this tool and remove the entries by hand in step 2. http://xmlsoft.org/XSLT/xsltproc2.html

bsdiff: included in most Linux installs

1. unpack framework-res.apk:

rm -rf framework-res
apktool d framework-res.apk

2. remove the config_tether_*_regexs entries from all AT&T arrays.xml files.

for i in `find . -name strings.xml | xargs grep -l buyasession.att.com`; do
DIR=`dirname $i`
if [ ! -e "$DIR/arrays.xml" ]; then
echo "Skipping $DIR; no arrays.xml"
continue
fi
echo $DIR
#cat $DIR/arrays.xml
rm -f $DIR/arrays.xml.new
xsltproc ../remove-tether-entries.xslt $DIR/arrays.xml > $DIR/arrays.xml.new
diff -wu $DIR/arrays.xml.new ../empty_arrays.xml > /dev/null
if [ $? -eq 0 ]; then
echo "No remaining arrays; removing arrays.xml"
rm -f $DIR/arrays.xml $DIR/arrays.xml.new
else
diff -wu $DIR/arrays.xml $DIR/arrays.xml.new
mv $DIR/arrays.xml $DIR/arrays.xml~
mv $DIR/arrays.xml.new $DIR/arrays.xml
fi
done

Here is remove-tether-entries.xslt:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output omit-xml-declaration="no" indent="yes" encoding="utf-8"/>
<xsl:strip-space elements="*"/>

<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>

<xsl:template match="array[@name='config_tether_usb_regexs']" />
<xsl:template match="array[@name='config_tether_wifi_regexs']" />
<xsl:template match="array[@name='config_tether_bluetooth_regexs']" />
<xsl:template match="array[@name='config_tether_upstream_types']" />

</xsl:stylesheet>

3. Download a recent .zip from my original post and unpack it into pkg/. Recommend using the MOB30M package. This loads all of the tools/scripts that the device itself needs to apply the patch. You should end up with a directory structure like this:

pkg/META-INF/com/google/android/update-binary
pkg/META-INF/com/google/android/updater-script
pkg/patch/system/framework/framework-res.apk.p
pkg/system/priv-app/CellBroadcastReceiver/CellBroadcastReceiver.apk

4. Create the zip patch package:

#!/bin/sh -x

export ANDROID_HOME=$HOME/android-sdk-linux

export VERSION=`pwd | xargs basename`
echo "\033[41m$VERSION\033[0m"

# Set this to 1 if you also want to enable SMS at the same time.
DO_SMS=1

if [ $DO_SMS -ne 0 ]; then
perl -pi -e's!<bool name="config_voice_capable">(true|false)</bool>!<bool name="config_voice_capable">true</bool>!' framework-res/res/values/bools.xml
perl -pi -e's!<string name="default_sms_application">.*?</string>!<string name="default_sms_application">com.google.android.talk</string>!' framework-res/res/values/strings.xml
else
perl -pi -e's!<bool name="config_voice_capable">(true|false)</bool>!<bool name="config_voice_capable">false</bool>!' framework-res/res/values/bools.xml
perl -pi -e's!<string name="default_sms_application">.*?</string>!<string name="default_sms_application">com.android.mms</string>!' framework-res/res/values/strings.xml
fi

rm -f framework-res.new.apk resources.arsc
../apktool/apktool b framework-res -o framework-res.new.apk
unzip framework-res.new.apk resources.arsc
rm -f framework-res.new.apk

rm -f patched-framework-res.apk
cp -a framework-res.apk patched-framework-res.apk
zip -f patched-framework-res.apk resources.arsc

rm -f pkg/patch/system/framework/framework-res.apk.p
mkdir -p pkg/patch/system/framework
echo -n "\033[41m"
time bsdiff framework-res.apk patched-framework-res.apk pkg/patch/system/framework/framework-res.apk.p
echo -n "\033[0m"

EXISTING_SHA1=`sha1sum framework-res.apk | cut -d" " -f 1`
NEW_SHA1=`sha1sum patched-framework-res.apk | cut -d" " -f 1`
NEW_SIZE=`stat --printf="%s" patched-framework-res.apk`

cat > pkg/META-INF/com/google/android/updater-script << END
ui_print("--------------------------------------------------");
ui_print("Installing new AT&T tethering enabled framework...");
ui_print("--------------------------------------------------");
mount("ext4", "EMMC", "/dev/block/platform/msm_sdcc.1/by-name/system", "/system", "max_batch_time=0,commit=1,data=ordered,barrier=1,errors=panic,nodelalloc");
assert(file_getprop("/system/build.prop", "ro.build.id") == "$VERSION");
ui_print("Making sure that system is stock...");
apply_patch_check("/system/framework/framework-res.apk", "$EXISTING_SHA1") || abort("framework-res.apk is not stock. It's not safe to continue.");
assert(run_program("/sbin/cp", "-a", "/system/framework/framework-res.apk", "/system/framework/framework-res.apk.stock"));
apply_patch("/system/framework/framework-res.apk", "-",
$NEW_SHA1, $NEW_SIZE,
$EXISTING_SHA1, package_extract_file("patch/system/framework/framework-res.apk.p"));
set_metadata("/system/framework/framework-res.apk", "uid", 0, "gid", 0, "mode", 0644, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
unmount("/system");
mount("ext4", "EMMC", "/dev/block/platform/msm_sdcc.1/by-name/system", "/system", "");
assert(sha1_check(read_file("/system/framework/framework-res.apk"), "$NEW_SHA1"));
unmount("/system");
ui_print("Done!");
ui_print("Backup of original is saved at:");
ui_print(" /system/framework/framework-res.apk.stock");
END

echo "\033[41m`grep ro.build.id pkg/META-INF/com/google/android/updater-script`\033[0m"

cd pkg
find . -name \*~ | xargs rm -f
if [ $DO_SMS -ne 0 ]; then
rm -f ../update-att-tether-sms-${VERSION}-0.1.zip
zip -X -9 -r ../update-att-tether-sms-${VERSION}-0.1.zip *
else
rm -f ../update-att-tether-${VERSION}-0.1.zip
ls | grep -v system | xargs zip -X -9 -r ../update-att-tether-${VERSION}-0.1.zip
fi

5. You should end up with an update-att-tether-sms-XXXXX-0.1.zip file that you can flash

Bonus: if you want to create the revert.zip package, here's the script for that. You'll need a recent -revert.zip package from the OP. Recommend using the MOB30M one.

#!/bin/sh -x

export ANDROID_HOME=$HOME/android-sdk-linux

export VERSION=`pwd | xargs basename`
echo "\033[41m$VERSION\033[0m"

EXISTING_SHA1=`sha1sum framework-res.apk | cut -d" " -f 1`

cat > pkg-revert/META-INF/com/google/android/updater-script << END
ui_print("--------------------------------------------------");
ui_print("Reverting to stock framework...");
ui_print("--------------------------------------------------");
mount("ext4", "EMMC", "/dev/block/platform/msm_sdcc.1/by-name/system", "/system", "max_batch_time=0,commit=1,data=ordered,barrier=1,errors=panic,nodelalloc");
assert(file_getprop("/system/build.prop", "ro.build.id") == "$VERSION");
apply_patch_check("/system/framework/framework-res.apk.stock", "$EXISTING_SHA1") || abort("framework-res.apk.stock is not stock - can't restore.");
assert(run_program("/sbin/cp", "-a", "/system/framework/framework-res.apk.stock", "/system/framework/framework-res.apk"));
set_metadata("/system/framework/framework-res.apk", "uid", 0, "gid", 0, "mode", 0644, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
unmount("/system");
mount("ext4", "EMMC", "/dev/block/platform/msm_sdcc.1/by-name/system", "/system", "");
assert(sha1_check(read_file("/system/framework/framework-res.apk"), "$EXISTING_SHA1"));
unmount("/system");
ui_print("Done!");
END

rm -f update-att-tether-${VERSION}-revert.zip
cd pkg-revert
find . -name \*~ | xargs rm -f
zip -X -9 -r ../update-att-tether-${VERSION}-revert.zip *