resolved conflicts for merge of 16e6db4c to jb-mr1-dev-plus-aosp

Change-Id: I33f870d3ce6d7855073526d9910ec15de197fd78
diff --git a/clear-factory-images-variables.sh b/clear-factory-images-variables.sh
index df9c251..2c625a7 100644
--- a/clear-factory-images-variables.sh
+++ b/clear-factory-images-variables.sh
@@ -12,19 +12,21 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-unset XLOADER
-unset XLOADERSRC
 unset BOOTLOADER
 unset BOOTLOADERFILE
 unset BOOTLOADERSRC
-unset TWINBOOTLOADERS
 unset BUILD
 unset CDMARADIO
 unset DEVICE
 unset ERASE
 unset PRODUCT
 unset RADIO
+unset RADIOFILE
 unset RADIOSRC
 unset SLEEPDURATION
 unset SRCPREFIX
+unset UNLOCKBOOTLOADER
 unset VERSION
+unset TWINBOOTLOADERS
+unset XLOADER
+unset XLOADERSRC
diff --git a/generate-blob-lists.sh b/generate-blob-lists.sh
index a560526..8360da8 100755
--- a/generate-blob-lists.sh
+++ b/generate-blob-lists.sh
@@ -42,7 +42,7 @@
 fi
 shift
 
-DEVICES="phantasm"
+DEVICES="maguro toro toroplus grouper tilapia manta phantasm"
 export LC_ALL=C
 
 repo sync -j32 -n
@@ -66,7 +66,10 @@
       cut -b 15- |
       sort -f > $ARCHIVEDIR/$DEVICENAME-with.txt
   done
+  rm -rf device/lge/*
   rm -rf hardware/broadcom/nfc
+  rm -rf hardware/msm7k
+  rm -rf hardware/qcom/*
   rm -rf packages/apps/UnifiedEmail
   rm -rf vendor
   for DEVICENAME in $DEVICES
diff --git a/generate-factory-images-common.sh b/generate-factory-images-common.sh
index 0ff6868..b7c959f 100644
--- a/generate-factory-images-common.sh
+++ b/generate-factory-images-common.sh
@@ -43,7 +43,7 @@
 then
   unzip -d tmp ${SRCPREFIX}$PRODUCT-target_files-$BUILD.zip RADIO/$BOOTLOADERSRC
 fi
-if test "$RADIO" != ""
+if test "$RADIO" != "" -a "$RADIOFILE" = ""
 then
   unzip -d tmp ${SRCPREFIX}$PRODUCT-target_files-$BUILD.zip RADIO/$RADIOSRC
 fi
@@ -54,7 +54,10 @@
 
 # Copy the various images in their staging location
 cp ${SRCPREFIX}$PRODUCT-img-$BUILD.zip tmp/$PRODUCT-$VERSION/image-$PRODUCT-$VERSION.zip
-cp tmp/RADIO/$XLOADERSRC tmp/$PRODUCT-$VERSION/xloader-$DEVICE-$XLOADER.img
+if test "$XLOADER" != ""
+then
+  cp tmp/RADIO/$XLOADERSRC tmp/$PRODUCT-$VERSION/xloader-$DEVICE-$XLOADER.img
+fi
 if test "$BOOTLOADERFILE" = ""
 then
   cp tmp/RADIO/$BOOTLOADERSRC tmp/$PRODUCT-$VERSION/bootloader-$DEVICE-$BOOTLOADER.img
@@ -63,7 +66,12 @@
 fi
 if test "$RADIO" != ""
 then
-  cp tmp/RADIO/$RADIOSRC tmp/$PRODUCT-$VERSION/radio-$DEVICE-$RADIO.img
+  if test "$RADIOFILE" = ""
+  then
+    cp tmp/RADIO/$RADIOSRC tmp/$PRODUCT-$VERSION/radio-$DEVICE-$RADIO.img
+  else
+    cp $RADIOFILE tmp/$PRODUCT-$VERSION/radio-$DEVICE-$RADIO.img
+  fi
 fi
 if test "$CDMARADIO" != ""
 then
@@ -89,6 +97,12 @@
 # limitations under the License.
 
 EOF
+if test "$UNLOCKBOOTLOADER" = "true"
+then
+cat >> tmp/$PRODUCT-$VERSION/flash-all.sh << EOF
+fastboot oem unlock
+EOF
+fi
 if test "$ERASEALL" = "true"
 then
 cat >> tmp/$PRODUCT-$VERSION/flash-all.sh << EOF
@@ -158,6 +172,12 @@
 
 PATH=%PATH%;"%SYSTEMROOT%\System32"
 EOF
+if test "$UNLOCKBOOTLOADER" = "true"
+then
+cat >> tmp/$PRODUCT-$VERSION/flash-all.bat << EOF
+fastboot oem unlock
+EOF
+fi
 if test "$ERASEALL" = "true"
 then
 cat >> tmp/$PRODUCT-$VERSION/flash-all.bat << EOF
diff --git a/populate-new-device.sh b/populate-new-device.sh
new file mode 100755
index 0000000..90ab783
--- /dev/null
+++ b/populate-new-device.sh
@@ -0,0 +1,186 @@
+#!/usr/bin/env bash
+
+# Copyright 2013 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+if test "$1" = "" -o "$2" = ""
+then
+  echo "Need a manufacturer name and a device name"
+  exit 1
+fi
+
+mkdir -p device/$1/$2
+mkdir -p device/$1/$2-kernel
+mkdir -p vendor/$1/$2
+
+cat > device/$1/$2/vendorsetup.sh << EOF
+#
+# Copyright 2013 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+add_lunch_combo full_$2-userdebug
+EOF
+
+cat > device/$1/$2/AndroidProducts.mk << EOF
+#
+# Copyright 2013 The Android Open-Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+PRODUCT_MAKEFILES := \$(LOCAL_DIR)/full_$2.mk
+EOF
+
+cat > device/$1/$2/full_$2.mk << EOF
+#
+# Copyright 2013 The Android Open-Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+\$(call inherit-product, \$(SRC_TARGET_DIR)/product/full_base.mk)
+\$(call inherit-product, device/$1/$2/device.mk)
+
+PRODUCT_NAME := full_$2
+PRODUCT_DEVICE := $2
+PRODUCT_BRAND := Android
+PRODUCT_MODEL := $2
+PRODUCT_MANUFACTURER := $1
+EOF
+
+cat > device/$1/$2/device.mk << EOF
+#
+# Copyright 2013 The Android Open-Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+ifeq (\$(TARGET_PREBUILT_KERNEL),)
+LOCAL_KERNEL := device/$1/$2-kernel/kernel
+else
+LOCAL_KERNEL := \$(TARGET_PREBUILT_KERNEL)
+endif
+
+PRODUCT_COPY_FILES := \\
+	\$(LOCAL_KERNEL):kernel
+
+\$(call inherit-product-if-exists, vendor/$1/$2/device-vendor.mk)
+EOF
+
+cat > device/$1/$2/BoardConfig.mk << EOF
+#
+# Copyright 2013 The Android Open-Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# Use the non-open-source parts, if they're present
+-include vendor/$1/$2/BoardConfigVendor.mk
+
+TARGET_ARCH := arm
+TARGET_ARCH_VARIANT := armv7-a-neon
+TARGET_CPU_ABI := armeabi-v7a
+TARGET_CPU_ABI2 := armeabi
+EOF
+
+touch device/$1/$2-kernel/kernel
+touch device/$1/$2-kernel/MODULE_LICENSE_GPL
+
+cat > vendor/$1/$2/device-vendor.mk << EOF
+#
+# Copyright 2013 The Android Open-Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+EOF
+
+cat > vendor/$1/$2/BoardConfigVendor.mk << EOF
+#
+# Copyright 2013 The Android Open-Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+EOF
+