From 9d0b4a0f0eed60322b3b48d67c56567c547a92c6 Mon Sep 17 00:00:00 2001 From: Jim Tan Date: Wed, 21 Dec 2016 11:37:09 -0800 Subject: Move PMC from Master to AOSP All the files of PMC are exactly the same as the files of PMC in Master branch Test: None Bug: 33809986 Change-Id: Icf2c00908ab9ff147c6c06aecfa414f324cef4da --- PMC/Android.mk | 24 ++ PMC/AndroidManifest.xml | 46 +++ PMC/build_pmc.sh | 113 ++++++ PMC/res/drawable-xhdpi/ic_launcher.png | Bin 0 -> 12516 bytes PMC/res/layout/activity_linear.xml | 96 ++++++ PMC/res/layout/activity_setting.xml | 110 ++++++ PMC/res/menu/main.xml | 10 + PMC/res/values/dimens.xml | 7 + PMC/res/values/strings.xml | 27 ++ PMC/res/values/styles.xml | 18 + PMC/src/com/android/pmc/BleScanReceiver.java | 276 +++++++++++++++ PMC/src/com/android/pmc/IperfClient.java | 113 ++++++ PMC/src/com/android/pmc/PMCMainActivity.java | 400 ++++++++++++++++++++++ PMC/src/com/android/pmc/SettingActivity.java | 47 +++ PMC/src/com/android/pmc/WifiConnScanReceiver.java | 149 ++++++++ PMC/src/com/android/pmc/WifiDownloadReceiver.java | 185 ++++++++++ PMC/src/com/android/pmc/WifiGScanReceiver.java | 175 ++++++++++ 17 files changed, 1796 insertions(+) create mode 100644 PMC/Android.mk create mode 100644 PMC/AndroidManifest.xml create mode 100755 PMC/build_pmc.sh create mode 100644 PMC/res/drawable-xhdpi/ic_launcher.png create mode 100644 PMC/res/layout/activity_linear.xml create mode 100644 PMC/res/layout/activity_setting.xml create mode 100644 PMC/res/menu/main.xml create mode 100644 PMC/res/values/dimens.xml create mode 100644 PMC/res/values/strings.xml create mode 100644 PMC/res/values/styles.xml create mode 100644 PMC/src/com/android/pmc/BleScanReceiver.java create mode 100644 PMC/src/com/android/pmc/IperfClient.java create mode 100644 PMC/src/com/android/pmc/PMCMainActivity.java create mode 100644 PMC/src/com/android/pmc/SettingActivity.java create mode 100644 PMC/src/com/android/pmc/WifiConnScanReceiver.java create mode 100644 PMC/src/com/android/pmc/WifiDownloadReceiver.java create mode 100644 PMC/src/com/android/pmc/WifiGScanReceiver.java diff --git a/PMC/Android.mk b/PMC/Android.mk new file mode 100644 index 0000000..fcd25bd --- /dev/null +++ b/PMC/Android.mk @@ -0,0 +1,24 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_JAVA_LIBRARIES := bouncycastle conscrypt +LOCAL_STATIC_JAVA_LIBRARIES := android-support-v4 android-support-v13 jsr305 + +LOCAL_PACKAGE_NAME := PMC +LOCAL_CERTIFICATE := platform +LOCAL_DEX_PREOPT := false + +LOCAL_SRC_FILES := $(call all-java-files-under, src) +LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res + +LOCAL_PRIVILEGED_MODULE := true +LOCAL_PROGUARD_ENABLED := disabled + +include $(BUILD_PACKAGE) + + +# only include rules to build other stuff for the original package, not the derived package. +#ifeq ($(strip $(LOCAL_PACKAGE_OVERRIDES)),) +# additionally, build unit tests in a separate .apk +include $(call all-makefiles-under,$(LOCAL_PATH)) +#endif diff --git a/PMC/AndroidManifest.xml b/PMC/AndroidManifest.xml new file mode 100644 index 0000000..127e11d --- /dev/null +++ b/PMC/AndroidManifest.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/PMC/build_pmc.sh b/PMC/build_pmc.sh new file mode 100755 index 0000000..4f57274 --- /dev/null +++ b/PMC/build_pmc.sh @@ -0,0 +1,113 @@ +#! /bin/bash +#This script does a clean build of PMC and install it to your device through adb +#Requires envsetup.sh in the branch + +#function to change jdk version +function setup_jdk() { + # Remove the current JDK from PATH + if [ -n "$JAVA_HOME" ] ; then + PATH=${PATH/$JAVA_HOME\/bin:/} + fi + export JAVA_HOME=$1 + export PATH=$JAVA_HOME/bin:$PATH +} + +#Color code for echo +r='\e[0;31m' +brn='\e[0;33m' +y='\e[1;33m' +g='\e[0;32m' +cy='\e[0;36m' +lb='\e[1;34m' +p='\e[0;35m' +lg='\e[0;37m' +NC='\e[0m' # No Color + +echo -e "Welcome to ${r}U${brn}N${y}I${g}C${lb}O${cy}R${p}N${NC} build system for ${g}PMC${NC}" + +IFS='_' read -a array <<< "$TARGET_PRODUCT" +export TP=${array[0]} +if [[ ${#array[@]} -eq 2 ]]; then + export TP=${array[1]} +fi + +APP_NAME=PMC +APP_PACKAGE_NAME=com.android.pmc + +BRANCH_ROOT=$PWD/../../../../.. +PMC_PROJ=$BRANCH_ROOT/vendor/google_testing/comms/Tools/PMC +SHARED_LIB_JAR_ROOT=$BRANCH_ROOT/out/target/common/obj/JAVA_LIBRARIES +APP_JAR_ROOT=$BRANCH_ROOT/out/target/common/obj/APPS +APK_ROOT=$BRANCH_ROOT/out/target/product/$TP/system/priv-app/PMC + +function pmc_build { + +echo -e "${y}Removing intermeidates of the app${NC}" +rm -r $APP_JAR_ROOT/"$APP_NAME"_intermediates +#Remove the apk file +rm $APK_ROOT/"$APP_NAME".apk + +#Build all the dependency libs +. $BRANCH_ROOT/build/envsetup.sh + +exec () { + ${@:1:($#-1)} + if [ $? -ne 0 ]; then + echo -e "${r}Encountered error when ${@:$#}${NC}" + echo -e "${lg}UNICORN ${r}DIED${NC}!" + exit 1 + fi +} + +echo -e "${lb}+++++++ Building $APP_NAME.apk +++++++${NC}" +cd $PMC_PROJ +exec mm -B "building $APP_NAME.apk" +echo + +} + +function pmc_flash { + +echo -e "${y}Switching to root${NC}" +adb root +adb wait-for-device remount + +echo -e "${y}Uninstalling old apk from device${NC}" +adb uninstall $APP_PACKAGE_NAME +adb shell rm -r /system/priv-app/$APP_NAME.apk + +echo -e "${lb}Installing apk to device${NC}" +cd $APK_ROOT +#exec adb install $APP_NAME.apk "installing apk to device" +#exec adb push $APP_NAME.apk /system/priv-app "installing apk to previliged dir" +exec adb install -r $APP_NAME.apk "installing apk to previliged dir" + +} + +DO_BUILD=1 +DO_FLASH=1 + +if [ $# -ne 0 ] ; then + DO_BUILD=0 + DO_FLASH=0 + while getopts "bf" ARG + do + case $ARG in + b) DO_BUILD=1 && echo "Build it we will.";; + f) DO_FLASH=1 && echo "Flash it we must.";; + ?) echo "Invalid Argument ${ARG}" && exit 1;; + esac + done +fi + +if [ ${DO_BUILD} -eq "1" ] ; then + pmc_build +fi + +if [ ${DO_FLASH} -eq "1" ] ; then + pmc_flash +fi + +echo "All clear!" +echo -e " ${r}U${brn}N${y}I${g}C${cy}O${lb}R${p}N ${r}P${brn}O${y}W${g}E${cy}R${lb}!${p}!${NC}" + diff --git a/PMC/res/drawable-xhdpi/ic_launcher.png b/PMC/res/drawable-xhdpi/ic_launcher.png new file mode 100644 index 0000000..d4fb7cd Binary files /dev/null and b/PMC/res/drawable-xhdpi/ic_launcher.png differ diff --git a/PMC/res/layout/activity_linear.xml b/PMC/res/layout/activity_linear.xml new file mode 100644 index 0000000..6461b4d --- /dev/null +++ b/PMC/res/layout/activity_linear.xml @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + +