[Android Software/Hacking General [Developers Only]] gokussjx:
STEP 2: Adding device support to PA, & Building ROM:

STEP 2: Adding device support to PA, & Building ROM:​

I've tried to provide you a basic guideline. You might need to make some changes according to the files/device you have.

If your device already has the support, skip to Instruction to compile the ROM.

NOTE: Throughout this guide, I'll be using the device name as '<device>', & in red. So, if the device is 'pa_i9100', I'm using a generic name: 'pa_<device>'. This means, replace the red <device> with your device name, as per your JellyBean Device Tree

After you've the complete source, you need some prebuilts & additional props, & the script needs to know of the existence of the device (<device>) you want to compile for.

For additional prebuilts & props extraction, look for a extraction script.

In some devices, we have 'extract-files.sh', in others we have 'proprietary-files.sh'. There might be other names for the script as well. Just go through make sure you know which one it is.

For example, in case of Galaxy S3 i9300:

You get to the device source, by navigating to android/system/device/samsung/i9300/, & using the script: "proprietary-files.sh"

Here's what you do:

1) Connect your device, running working CM10/AOSP JB, with Android Debugging ACTIVATED.

2) Make the script executable, after cd to device/samsung/i9300:

$ cd android/system/device/[COLOR="red"]samsung[/COLOR]/[COLOR="red"]i9300[/COLOR]
$ chmod +x [COLOR="Red"]proprietary-files.sh[/COLOR]

3) Execute the script, in terminal:

$ ./[COLOR="red"]proprietary-files.sh[/COLOR]

----------------------------------------------------

DEVICE SPECIFIC CHANGES

----------------------------------------------------​

Next, here's an overview of what PA needs you to do to allow compilation for your device:

(Everything here is to be done under /vendor/pa)

* Create /manifest/<device>.adds

* Create /manifest/<device>.removes

* Create /prebuilt/pa_<device>.conf

* Create /products/pa_<device>.mk

* Add device makefile entry to /products/AndroidProducts.mk

* Create /vendorprops/<device>.proprietaries

* Add device lunch menu entry to /vendorsetup.sh

Again, lets start:

# Create /manifest/<device>.adds:

I'll give you two examples of .adds, to show the general extent of variation between devices:

For i9300:

[
{
"remote": "github",
"account": "CyanogenMod",
"repository": "android_frameworks_av",
"target_path": "frameworks/av",
"revision": "cm-10.1"
},
{
"remote": "github",
"account": "CyanogenMod",
"repository": "android_frameworks_native",
"target_path": "frameworks/native",
"revision": "cm-10.1"
},
{
"remote": "github",
"account": "CyanogenMod",
"repository": "android_hardware_libhardware",
"target_path": "hardware/libhardware",
"revision": "cm-10.1"
},
{
"remote": "github",
"account": "CyanogenMod",
"repository": "android_hardware_libhardware_legacy",
"target_path": "hardware/libhardware_legacy",
"revision": "cm-10.1"
},
{
"remote": "github",
"account": "CyanogenMod",
"repository": "android_frameworks_opt_telephony",
"target_path": "frameworks/opt/telephony",
"revision": "cm-10.1"
},
{
"remote": "github",
"account": "CyanogenMod",
"repository": "android_device_common",
"target_path": "device/common",
"revision": "cm-10.1"
},
{
"remote": "github",
"account": "CyanogenMod",
"repository": "android_device_generic_armv7-a-neon",
"target_path": "device/generic/armv7-a-neon",
"revision": "cm-10.1"
},
{
"remote": "github",
"account": "CyanogenMod",
"repository": "android_device_generic_common",
"target_path": "device/generic/common",
"revision": "cm-10.1"
}
]

For bravo:

[
{
"remote": "github",
"account": "WoH",
"repository": "android_bionic",
"target_path": "bionic",
"revision": "jellybean"
},
{
"remote": "github",
"account": "Evervolv",
"repository": "android_external_wpa_supplicant_8",
"target_path": "external/wpa_supplicant_8",
"revision": "jellybean"
},
{
"remote": "github",
"account": "Evervolv",
"repository": "android_frameworks_av",
"target_path": "frameworks/av",
"revision": "jellybean"
},
{
"remote": "github",
"account": "WoH",
"repository": "android_frameworks_base",
"target_path": "frameworks/base",
"revision": "jellybean"
},
{
"remote": "github",
"account": "Evervolv",
"repository": "android_frameworks_native",
"target_path": "frameworks/native",
"revision": "jellybean"
},
{
"remote": "github",
"account": "Evervolv",
"repository": "android_hardware_atheros",
"target_path": "hardware/atheros",
"revision": "jellybean"
},
{
"remote": "github",
"account": "Evervolv",
"repository": "android_hardware_gpsshim",
"target_path": "hardware/gpsshim",
"revision": "jellybean"
},
{
"remote": "github",
"account": "Evervolv",
"repository": "android_hardware_libhardware",
"target_path": "hardware/libhardware",
"revision": "jellybean"
},
{
"remote": "github",
"account": "Evervolv",
"repository": "android_hardware_libhardware_legacy",
"target_path": "hardware/libhardware_legacy",
"revision": "jellybean"
},
{
"remote": "github",
"account": "Evervolv",
"repository": "android_hardware_ril",
"target_path": "hardware/ril",
"revision": "jellybean"
},
{
"remote": "github",
"account": "Evervolv",
"repository": "android_hardware_qcom_audio",
"target_path": "hardware/qcom/audio",
"revision": "jellybean"
},
{
"remote": "github",
"account": "Evervolv",
"repository": "android_hardware_qcom_audio-legacy",
"target_path": "hardware/qcom/audio-legacy",
"revision": "jellybean"
},
{
"remote": "github",
"account": "Evervolv",
"repository": "android_hardware_qcom_bt",
"target_path": "hardware/qcom/bt",
"revision": "jellybean"
},
{
"remote": "github",
"account": "Evervolv",
"repository": "android_hardware_qcom_camera",
"target_path": "hardware/qcom/camera",
"revision": "jellybean"
},
{
"remote": "github",
"account": "Evervolv",
"repository": "android_hardware_qcom_display",
"target_path": "hardware/qcom/display",
"revision": "jellybean"
},
{
"remote": "github",
"account": "Evervolv",
"repository": "android_hardware_qcom_display-caf",
"target_path": "hardware/qcom/display-caf",
"revision": "jellybean"
},
{
"remote": "github",
"account": "Evervolv",
"repository": "android_hardware_qcom_display-legacy",
"target_path": "hardware/qcom/display-legacy",
"revision": "jellybean"
},
{
"remote": "github",
"account": "Evervolv",
"repository": "android_hardware_qcom_gps",
"target_path": "hardware/qcom/gps",
"revision": "jellybean"
},
{
"remote": "github",
"account": "Evervolv",
"repository": "android_hardware_qcom_gps-legacy",
"target_path": "hardware/qcom/gps-legacy",
"revision": "jellybean"
},
{
"remote": "github",
"account": "Evervolv",
"repository": "android_hardware_qcom_keymaster",
"target_path": "hardware/qcom/keymaster",
"revision": "jellybean"
},
{
"remote": "github",
"account": "Evervolv",
"repository": "android_hardware_qcom_media",
"target_path": "hardware/qcom/media",
"revision": "jellybean"
},
{
"remote": "github",
"account": "Evervolv",
"repository": "android_hardware_qcom_media-legacy",
"target_path": "hardware/qcom/media-legacy",
"revision": "jellybean"
},
{
"remote": "github",
"account": "Evervolv",
"repository": "android_hardware_qcom_power",
"target_path": "hardware/qcom/power",
"revision": "jellybean"
},
{
"remote": "github",
"account": "Evervolv",
"repository": "android_hardware_qcom_sensors",
"target_path": "hardware/qcom/sensors",
"revision": "jellybean"
},
{
"remote": "github",
"account": "Evervolv",
"repository": "android_hardware_qcom_wlan",
"target_path": "hardware/qcom/wlan",
"revision": "jellybean"
},
{
"remote": "github",
"account": "Evervolv",
"repository": "android_system_bluetooth",
"target_path": "system/bluetooth",
"revision": "jellybean"
},
{
"remote": "github",
"account": "WoH",
"repository": "android_system_core",
"target_path": "system/core",
"revision": "jellybean"
},
{
"remote": "github",
"account": "Evervolv",
"repository": "android_system_extras",
"target_path": "system/extras",
"revision": "jellybean"
},
{
"remote": "github",
"account": "Evervolv",
"repository": "android_system_security",
"target_path": "system/security",
"revision": "jellybean"
},
{
"remote": "github",
"account": "Evervolv",
"repository": "android_system_vold",
"target_path": "system/vold",
"revision": "jellybean"
},
{
"remote": "github",
"account": "WoH",
"repository": "android_frameworks_opt_telephony",
"target_path": "frameworks/opt/telephony",
"revision": "jellybean"
},
{
"remote": "github",
"account": "Evervolv",
"repository": "android_device_common",
"target_path": "device/common",
"revision": "jellybean"
},
{
"remote": "github",
"account": "CyanogenMod",
"repository": "android_device_generic_armv7-a-neon",
"target_path": "device/generic/armv7-a-neon",
"revision": "cm-10.1"
},
{
"remote": "github",
"account": "CyanogenMod",
"repository": "android_device_generic_common",
"target_path": "device/generic/common",
"revision": "cm-10.1"
},
{
"remote": "github",
"account": "Evervolv",
"repository": "android_device_generic_goldfish",
"target_path": "device/generic/goldfish",
"revision": "jellybean"
}
]

You may use the i9300 as the base .adds, & make changes, add/remove/modify as per your device requirements.

# Create /manifest/<device>.removes:

Another example based explanation:

For i9300:

[
{
"name": "platform/frameworks/av",
"path": "frameworks/av"
},
{
"name": "ParanoidAndroid/android_frameworks_native",
"path": "frameworks/native"
},
{
"name": "platform/hardware/libhardware",
"path": "hardware/libhardware"
},
{
"name": "platform/hardware/libhardware_legacy",
"path": "hardware/libhardware_legacy"
},
{
"name": "device/common",
"path": "device/common"
},
{
"name": "ParanoidAndroid/android_frameworks_opt_telephony",
"path": "frameworks/opt/telephony"
}
]

For bravo:

[
{
"name": "ParanoidAndroid/android_bionic",
"path": "bionic"
},
{
"name": "platform/external/wpa_supplicant_8",
"path": "external/wpa_supplicant_8"
},
{
"name": "platform/frameworks/av",
"path": "frameworks/av"
},
{
"name": "ParanoidAndroid/android_frameworks_base",
"path": "frameworks/base"
},
{
"name": "ParanoidAndroid/android_frameworks_native",
"path": "frameworks/native"
},
{
"name": "platform/hardware/ril",
"path": "hardware/ril"
},
{
"name": "platform/hardware/libhardware",
"path": "hardware/libhardware"
},
{
"name": "platform/hardware/libhardware_legacy",
"path": "hardware/libhardware_legacy"
},
{
"name": "platform/system/bluetooth",
"path": "system/bluetooth"
},
{
"name": "ParanoidAndroid/android_system_core",
"path": "system/core"
},
{
"name": "platform/system/extras",
"path": "system/extras"
},
{
"name": "platform/system/security",
"path": "system/security"
},
{
"name": "platform/system/vold",
"path": "system/vold"
},
{
"name": "device/common",
"path": "device/common"
},
{
"name": "ParanoidAndroid/android_frameworks_opt_telephony",
"path": "frameworks/opt/telephony"
}
]

Basically, you need to remove the official manifest bits that you replaced/overlayed using the <device>.adds, for your device

# Create /prebuilt/pa_<device>.conf:

-> For an HDPI device, use the pa_hdpi.conf

-> For an XHDPI device WITH Hardware buttons, use pa_i9300.conf

-> For an XHDPI device WITHOUT Hardware buttons, use the pa_xhdpi.conf

# Create /products/pa_<device>.mk:

Open, & paste the following: (Read the instruction after this code)(All RED LETTERED parts vary from device to device. Use your own values)

# Copyright (C) 2012 ParanoidAndroid 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.

# Check for target product
ifeq (pa_[COLOR="Red"]<device>[/COLOR],$(TARGET_PRODUCT))

# Define PA bootanimation size
PARANOID_BOOTANIMATION_NAME := [COLOR="red"]XHDPI[/COLOR] [B]OR[/B] [COLOR="red"]HDPI[/COLOR]

# OVERLAY_TARGET adds overlay asset source
OVERLAY_TARGET := pa_[COLOR="red"]xhdpi[/COLOR] [B]OR[/B] pa_[COLOR="red"]i9300[/COLOR] [B]OR[/B] pa_[COLOR="red"]hdpi[/COLOR]

# Build paprefs from sources
PREFS_FROM_SOURCE ?= false

# Include ParanoidAndroid common configuration
include vendor/pa/config/pa_common.mk

# Inherit AOSP device configuration
$(call inherit-product, device/[COLOR="red"]<device-manufacturer>[/COLOR]/[COLOR="Red"]<device>[/COLOR]/full_[COLOR="Red"]<device>[/COLOR].mk)

# Product Package Extras - Repos can be added manually or via addprojects.py
-include vendor/pa/packages/[COLOR="Red"]<device>[/COLOR].mk

# CM Package Extras
-include vendor/pa/packages/cm.mk

# Override AOSP build properties
PRODUCT_NAME := pa_[COLOR="Red"]<device>[/COLOR]
PRODUCT_BRAND := [COLOR="red"]<device-manufacturer>[/COLOR]
PRODUCT_MODEL := [COLOR="red"]<Official Device Name, Eg: [COLOR="RoyalBlue"]GT-I9300[/COLOR]>[/COLOR]
PRODUCT_MANUFACTURER := [COLOR="Red"]<device-manufacturer>[/COLOR]
PRODUCT_BUILD_PROP_OVERRIDES += PRODUCT_NAME=[COLOR="red"]<product-name as per CyanogenMod>[/COLOR] TARGET_DEVICE=[COLOR="red"]<target-device as per CyanogenMod>[/COLOR] BUILD_FINGERPRINT="[COLOR="red"]<As per CM>[/COLOR]" PRIVATE_BUILD_DESC="[COLOR="red"]<As per CM>[/COLOR]"

# Update local_manifest.xml
GET_VENDOR_PROPS := $(shell vendor/pa/tools/getvendorprops.py $(PRODUCT_NAME))
GET_PROJECT_RMS := $(shell vendor/pa/tools/removeprojects.py $(PRODUCT_NAME))
GET_PROJECT_ADDS := $(shell vendor/pa/tools/addprojects.py $(PRODUCT_NAME))
GET_CM_PROJECT_ADDS := $(shell vendor/pa/tools/addprojects.py cm.adds)

endif

-> Change the inherit device config directory to device/.... (wherever you've kept your device tree)(could change as per manufact: Samsung, Sony, Motorola etc)

-> Change OVERLAY_TARGET value as per your device pixel density

-> Save & Exit

# Add device makefile entry to /products/AndroidProducts.mk:

Append this at the end:

ifeq (pa_[COLOR="Red"]<device>[/COLOR],$(TARGET_PRODUCT))
PRODUCT_MAKEFILES += $(LOCAL_DIR)/pa_[COLOR="red"]<device>[/COLOR].mk
endif

-> Use your device name in place of <device>

-> Save & Exit.

# Create /vendorprops/<device>.proprietaries:

1) Now, navigate to your_workspace/vendor/pa/vendorprops

2) Make a new file, & name it '<device>.proprietaries'

3) You need to point the script towards your device's proprietary vendor files from your manufacturer.

Example of what Samsung's looks like.

(Do some research on google, github, forums etc, & find out your required tree/configs.)

Here's i9300.proprietaries code: (Same for all Samsung devices)

[
{
"remote": "github",
"account": "TheMuppets",
"repository": "proprietary_vendor_samsung",
"target_path": "vendor/samsung",
"revision": "cm-10.1"
},
{
"remote": "github",
"account": "CyanogenMod",
"repository": "android_packages_apps_SamsungServiceMode",
"target_path": "packages/apps/SamsungServiceMode",
"revision": "cm-10.1"
},
{
"remote": "github",
"account": "CyanogenMod",
"repository": "android_hardware_samsung",
"target_path": "hardware/samsung",
"revision": "cm-10.1"
},
{
"remote": "github",
"account": "ParanoidAndroid",
"repository": "android_device_samsung_smdk4412-common",
"target_path": "device/samsung/smdk4412-common",
"revision": "cm-10.1"
}
]

These are your device specific props that'll get added to local manifest.

If you've added all such prop sources in <device>.adds, no need to add duplicate entries to <device>.proprietaries

Just create the file & paste the following in the proprietaries file:

[
]

-> Make your changes

-> Save & Exit.

# Add device lunch menu entry to /vendorsetup.sh:

1) Navigate to android/system/vendor/pa, & open 'vendorsetup.sh' (Just right click, open in Text Editor)

2) Append this line :

add_lunch_combo pa_[COLOR="Red"]<device>[/COLOR]-userdebug

That's it!

Make sure you also have all the hardware, kernel, device specific files, blobs, prebuilts, extracts etc before hand, & set the addresses accordingly.

You've come so far, & here's the final punch.

Build the ROM:

# Build the ROM:

-> For building ParanoidAndroid you must cd to the working directory. Make sure you have your device tree sources, located on:

$ cd ~/android/system/device/[COLOR="Red"]-manufacturer-[/COLOR]/[COLOR="red"]-device-[/COLOR]

-> Now you can run the build script:

$ cd ~/android/system
$ ./rom-build.sh [COLOR="red"]-device-[/COLOR]

-> You can also use a second parameter for syncing sources before building

# ./rom-build.sh [COLOR="red"]-device-[/COLOR] [B]true[/B]

-> There are also a few parameters that you can use together with before mentioned:

threads: Allows to choose a number of threads for syncing operation

clean: Removes intermediates and output files

The usage is the same

$ ./rom-build.sh [COLOR="red"]-device-[/COLOR] [B]-parameters-[/B] [B]-sync-[/B]

(Parameters will be considered false unless you set them to true)

This will generate a signed zip located at ~/android/system/out/target/product/-device-

(This'll take a while, depending on your processor speed, & memory. On 3GHz Quad Core Processor, with 4GB RAM, it takes me 71-75 minutes to get the final ZIP. If your configs are higher, it'll take you less)

Congratulations! You've successfully compiled ParanoidAndroid for your device!

-> That's it. You're done! You can test your build by flashing the output zip via CWM. :good: :laugh:

Disclaimer:

It shouldn't be necessary to mention but well, Paranoid-Settings is meant for Official Paranoid Android only, or ports that stay true to our vision. It is not meant to be included in other ROMs or Kangs - unless we give permission. This is our good name that people pull through the mud when they mix it with conflicting source like aokp. Hybrid engine and dpi changer will only result in a crappy user experience for the end-user. Hybrid relies on a clean system and does not change its DPI, thats the whole point of it. Furthermore hybrid engine is huge and complicated to kang because it grew over half a year and hundreds of commits, resets, reverts, rewrites. The only real hybrid engine is the result of a clean repo init and .rom-build.sh devicename.

Kangs and ROMs that don't have our permission can either write their own implementation (its really just a text file reader/writer), or adopt on the old paprefs version in the ICS branch, which is 100% opensource. Hybrid engine is 100% open source as well, of course. :cool: