Update to latest release
diff --git a/patches/platform_build/0001-Add-PRODUCT_SYSTEM_DEFAULT_PROPERTIES.patch b/patches/platform_build/0001-Add-PRODUCT_SYSTEM_DEFAULT_PROPERTIES.patch
index 893c807..acf8134 100644
--- a/patches/platform_build/0001-Add-PRODUCT_SYSTEM_DEFAULT_PROPERTIES.patch
+++ b/patches/platform_build/0001-Add-PRODUCT_SYSTEM_DEFAULT_PROPERTIES.patch
@@ -1,7 +1,7 @@
-From cd16437f867940eeeea039e40e4cb926b493a48e Mon Sep 17 00:00:00 2001
+From e0717a868052ab839ad0b589ca7cb869df5ad43f Mon Sep 17 00:00:00 2001
 From: Jaekyun Seok <jaekyun@google.com>
 Date: Fri, 3 Nov 2017 15:18:55 +0900
-Subject: [PATCH 1/3] Add PRODUCT_SYSTEM_DEFAULT_PROPERTIES
+Subject: [PATCH 1/4] Add PRODUCT_SYSTEM_DEFAULT_PROPERTIES
 
 PRODUCT_SYSTEM_DEFAULT_PROPERTIES will be used to define system default
 properties which should be installed in system partition.
@@ -20,7 +20,7 @@
  4 files changed, 11 insertions(+), 1 deletion(-)
 
 diff --git a/core/Makefile b/core/Makefile
-index 618e98317..77a817cd5 100644
+index 618e983..77a817c 100644
 --- a/core/Makefile
 +++ b/core/Makefile
 @@ -90,7 +90,8 @@ INSTALLED_DEFAULT_PROP_TARGET := $(TARGET_ROOT_OUT)/default.prop
@@ -34,7 +34,7 @@
    FINAL_DEFAULT_PROPERTIES += \
        $(call collapse-pairs, $(PRODUCT_DEFAULT_PROPERTY_OVERRIDES))
 diff --git a/core/product-graph.mk b/core/product-graph.mk
-index 36e903723..dc9a29646 100644
+index 36e9037..dc9a296 100644
 --- a/core/product-graph.mk
 +++ b/core/product-graph.mk
 @@ -103,6 +103,7 @@ $(OUT_DIR)/products/$(strip $(1)).txt: $(this_makefile)
@@ -46,7 +46,7 @@
  	$(hide) echo 'PRODUCT_COPY_FILES=$$(PRODUCTS.$(strip $(1)).PRODUCT_COPY_FILES)' >> $$@
  	$(hide) echo 'PRODUCT_OTA_PUBLIC_KEYS=$$(PRODUCTS.$(strip $(1)).PRODUCT_OTA_PUBLIC_KEYS)' >> $$@
 diff --git a/core/product.mk b/core/product.mk
-index 4682dac99..ea6cd30fa 100644
+index 4682dac..ea6cd30 100644
 --- a/core/product.mk
 +++ b/core/product.mk
 @@ -112,6 +112,7 @@ _product_var_list := \
@@ -58,7 +58,7 @@
      PRODUCT_SYSTEM_SERVER_APPS \
      PRODUCT_SYSTEM_SERVER_JARS \
 diff --git a/core/product_config.mk b/core/product_config.mk
-index f7ae834fb..330497f5b 100644
+index f7ae834..330497f 100644
 --- a/core/product_config.mk
 +++ b/core/product_config.mk
 @@ -359,6 +359,13 @@ PRODUCT_DEFAULT_PROPERTY_OVERRIDES := \
@@ -76,5 +76,5 @@
  PRODUCT_PACKAGE_OVERLAYS := \
      $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGE_OVERLAYS))
 -- 
-2.15.1
+2.7.4
 
diff --git a/patches/platform_build/0002-Move-ART-default-properties-into-system-partition.patch b/patches/platform_build/0002-Move-ART-default-properties-into-system-partition.patch
index 5695ad4..ec8d0da 100644
--- a/patches/platform_build/0002-Move-ART-default-properties-into-system-partition.patch
+++ b/patches/platform_build/0002-Move-ART-default-properties-into-system-partition.patch
@@ -1,7 +1,7 @@
-From 84e5d0e45c211c4e5e22acfea523ede244d34911 Mon Sep 17 00:00:00 2001
+From edcb0cb74c66637f34746dbcc7f35d6c268dc56e Mon Sep 17 00:00:00 2001
 From: Jaekyun Seok <jaekyun@google.com>
 Date: Fri, 3 Nov 2017 15:33:10 +0900
-Subject: [PATCH 2/3] Move ART default properties into system partition
+Subject: [PATCH 2/4] Move ART default properties into system partition
 
 Bug: 64661857
 Bug: 68755013
@@ -15,7 +15,7 @@
  2 files changed, 7 insertions(+), 5 deletions(-)
 
 diff --git a/core/dex_preopt_libart.mk b/core/dex_preopt_libart.mk
-index 96160367b..15cb221b6 100644
+index 9616036..15cb221 100644
 --- a/core/dex_preopt_libart.mk
 +++ b/core/dex_preopt_libart.mk
 @@ -30,7 +30,9 @@ DIRTY_IMAGE_OBJECTS := $(call word-colon,1,$(firstword \
@@ -30,7 +30,7 @@
  
  DEX2OAT_IMAGE_XMS := $(call get-product-default-property,dalvik.vm.image-dex2oat-Xms)
 diff --git a/target/product/runtime_libart.mk b/target/product/runtime_libart.mk
-index 8aedee79c..f1b8f4596 100644
+index 8aedee7..f1b8f45 100644
 --- a/target/product/runtime_libart.mk
 +++ b/target/product/runtime_libart.mk
 @@ -56,7 +56,7 @@ PRODUCT_PACKAGES += art-tools
@@ -63,5 +63,5 @@
      pm.dexopt.bg-dexopt=speed-profile \
      pm.dexopt.ab-ota=speed-profile \
 -- 
-2.15.1
+2.7.4
 
diff --git a/patches/platform_build/0003-Set-ro.build.fingerprint-in-system-etc-prop.default.patch b/patches/platform_build/0003-Set-ro.build.fingerprint-in-system-etc-prop.default.patch
index 090ac53..a780cf8 100644
--- a/patches/platform_build/0003-Set-ro.build.fingerprint-in-system-etc-prop.default.patch
+++ b/patches/platform_build/0003-Set-ro.build.fingerprint-in-system-etc-prop.default.patch
@@ -1,14 +1,14 @@
-From 98a31a76008d682563273b8196668b57c1b6ff14 Mon Sep 17 00:00:00 2001
+From ed63e5f22b143b683b0d96393d4758f61bfec9ef Mon Sep 17 00:00:00 2001
 From: Pierre-Hugues Husson <phh@phh.me>
 Date: Mon, 5 Mar 2018 22:27:50 +0100
-Subject: [PATCH 3/3] Set ro.build.fingerprint in system/etc/prop.default
+Subject: [PATCH 3/4] Set ro.build.fingerprint in system/etc/prop.default
 
 ---
  core/Makefile | 1 +
  1 file changed, 1 insertion(+)
 
 diff --git a/core/Makefile b/core/Makefile
-index 77a817cd5..e0f0e9145 100644
+index 77a817c..e0f0e91 100644
 --- a/core/Makefile
 +++ b/core/Makefile
 @@ -116,6 +116,7 @@ $(INSTALLED_DEFAULT_PROP_TARGET): $(intermediate_system_build_prop)
@@ -20,5 +20,5 @@
  ifdef property_overrides_split_enabled
  	$(hide) mkdir -p $(TARGET_ROOT_OUT)
 -- 
-2.15.1
+2.7.4
 
diff --git a/patches/platform_build/0004-Revert-Remove-root-folder-bt_firmware-in-GSI.patch b/patches/platform_build/0004-Revert-Remove-root-folder-bt_firmware-in-GSI.patch
new file mode 100644
index 0000000..79dd57e
--- /dev/null
+++ b/patches/platform_build/0004-Revert-Remove-root-folder-bt_firmware-in-GSI.patch
@@ -0,0 +1,53 @@
+From b1fd47b99f06d78d728ace3c57d5c9bade5e4831 Mon Sep 17 00:00:00 2001
+From: Pierre-Hugues Husson <phh@phh.me>
+Date: Tue, 27 Mar 2018 23:26:49 +0200
+Subject: [PATCH 4/4] Revert "Remove root folder bt_firmware in GSI"
+
+This reverts commit 292b8433cb48ef4ceb2330e57e11b8f644d9d1ee.
+
+Essential 8.1 firmware requires this
+---
+ target/board/generic_arm64_ab/BoardConfig.mk         | 2 +-
+ target/board/generic_arm64_ab/sepolicy/file.te       | 1 +
+ target/board/generic_arm64_ab/sepolicy/file_contexts | 1 +
+ 3 files changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/target/board/generic_arm64_ab/BoardConfig.mk b/target/board/generic_arm64_ab/BoardConfig.mk
+index 6744289..d7b9979 100644
+--- a/target/board/generic_arm64_ab/BoardConfig.mk
++++ b/target/board/generic_arm64_ab/BoardConfig.mk
+@@ -33,7 +33,7 @@ TARGET_NO_RECOVERY := true
+ BOARD_BUILD_SYSTEM_ROOT_IMAGE := true
+ 
+ # TODO(jiyong) These might be SoC specific.
+-BOARD_ROOT_EXTRA_FOLDERS += firmware firmware/radio persist
++BOARD_ROOT_EXTRA_FOLDERS += bt_firmware firmware firmware/radio persist
+ BOARD_ROOT_EXTRA_SYMLINKS := /vendor/lib/dsp:/dsp
+ 
+ # TODO(b/36764215): remove this setting when the generic system image
+diff --git a/target/board/generic_arm64_ab/sepolicy/file.te b/target/board/generic_arm64_ab/sepolicy/file.te
+index 7adfdfa..4645533 100644
+--- a/target/board/generic_arm64_ab/sepolicy/file.te
++++ b/target/board/generic_arm64_ab/sepolicy/file.te
+@@ -1,5 +1,6 @@
+ # TODO(b/36764215): remove this file when the generic system image
+ # no longer has these directories
++type bt_firmware_file, file_type;
+ type persist_file, file_type;
+ 
+ # Default type for anything under /firmware.
+diff --git a/target/board/generic_arm64_ab/sepolicy/file_contexts b/target/board/generic_arm64_ab/sepolicy/file_contexts
+index 0a80559..92a4ff8 100644
+--- a/target/board/generic_arm64_ab/sepolicy/file_contexts
++++ b/target/board/generic_arm64_ab/sepolicy/file_contexts
+@@ -2,6 +2,7 @@
+ # no longer has these directories. They are specific to QCOM.
+ 
+ # /
++/bt_firmware(/.*)?      u:object_r:bt_firmware_file:s0
+ /tombstones             u:object_r:rootfs:s0
+ /dsp                    u:object_r:rootfs:s0
+ 
+-- 
+2.7.4
+
diff --git a/patches/platform_external_selinux/0001-libsepol-cil-Add-ability-to-redeclare-types-attribut.patch b/patches/platform_external_selinux/0001-libsepol-cil-Add-ability-to-redeclare-types-attribut.patch
index d38aec2..d25a8da 100644
--- a/patches/platform_external_selinux/0001-libsepol-cil-Add-ability-to-redeclare-types-attribut.patch
+++ b/patches/platform_external_selinux/0001-libsepol-cil-Add-ability-to-redeclare-types-attribut.patch
@@ -25,7 +25,7 @@
  6 files changed, 57 insertions(+), 8 deletions(-)
 
 diff --git a/libsepol/cil/include/cil/cil.h b/libsepol/cil/include/cil/cil.h
-index 4507892c..4df646a0 100644
+index 4507892..4df646a 100644
 --- a/libsepol/cil/include/cil/cil.h
 +++ b/libsepol/cil/include/cil/cil.h
 @@ -46,6 +46,7 @@ extern int cil_userprefixes_to_string(cil_db_t *db, char **out, size_t *size);
@@ -37,7 +37,7 @@
  extern void cil_set_preserve_tunables(cil_db_t *db, int preserve_tunables);
  extern int cil_set_handle_unknown(cil_db_t *db, int handle_unknown);
 diff --git a/libsepol/cil/src/cil.c b/libsepol/cil/src/cil.c
-index 9b9ccc36..e8bbbfdf 100644
+index 9b9ccc3..e8bbbfd 100644
 --- a/libsepol/cil/src/cil.c
 +++ b/libsepol/cil/src/cil.c
 @@ -1675,6 +1675,11 @@ void cil_set_mls(struct cil_db *db, int mls)
@@ -53,7 +53,7 @@
  {
  	db->target_platform = target_platform;
 diff --git a/libsepol/cil/src/cil_build_ast.c b/libsepol/cil/src/cil_build_ast.c
-index 36cc6735..9a10e7ab 100644
+index 36cc673..9a10e7a 100644
 --- a/libsepol/cil/src/cil_build_ast.c
 +++ b/libsepol/cil/src/cil_build_ast.c
 @@ -82,10 +82,33 @@ exit:
@@ -125,7 +125,7 @@
  	}
  
 diff --git a/libsepol/cil/src/cil_internal.h b/libsepol/cil/src/cil_internal.h
-index aee3f00c..abfacd8d 100644
+index aee3f00..abfacd8 100644
 --- a/libsepol/cil/src/cil_internal.h
 +++ b/libsepol/cil/src/cil_internal.h
 @@ -312,6 +312,7 @@ struct cil_db {
@@ -137,7 +137,7 @@
  	int policy_version;
  };
 diff --git a/libsepol/src/libsepol.map.in b/libsepol/src/libsepol.map.in
-index 40426408..edd98d5a 100644
+index 4042640..edd98d5 100644
 --- a/libsepol/src/libsepol.map.in
 +++ b/libsepol/src/libsepol.map.in
 @@ -47,6 +47,7 @@ LIBSEPOL_1.1 {
@@ -149,7 +149,7 @@
  	sepol_ppfile_to_module_package;
  	sepol_module_package_to_cil;
 diff --git a/secilc/secilc.c b/secilc/secilc.c
-index f2232e72..0be6975b 100644
+index f2232e7..0be6975 100644
 --- a/secilc/secilc.c
 +++ b/secilc/secilc.c
 @@ -63,6 +63,7 @@ static __attribute__((__noreturn__)) void usage(const char *prog)
@@ -204,5 +204,5 @@
  	cil_set_preserve_tunables(db, preserve_tunables);
  	if (handle_unknown != -1) {
 -- 
-2.15.1
+2.7.4
 
diff --git a/patches/platform_external_selinux/0002-libsepol-cil-Keep-type-attribute-declarations-when-a.patch b/patches/platform_external_selinux/0002-libsepol-cil-Keep-type-attribute-declarations-when-a.patch
index f88b855..77dc2cf 100644
--- a/patches/platform_external_selinux/0002-libsepol-cil-Keep-type-attribute-declarations-when-a.patch
+++ b/patches/platform_external_selinux/0002-libsepol-cil-Keep-type-attribute-declarations-when-a.patch
@@ -24,7 +24,7 @@
  2 files changed, 10 insertions(+), 9 deletions(-)
 
 diff --git a/libsepol/cil/include/cil/android.h b/libsepol/cil/include/cil/android.h
-index 082d7fd2..5aceda62 100644
+index 082d7fd..5aceda6 100644
 --- a/libsepol/cil/include/cil/android.h
 +++ b/libsepol/cil/include/cil/android.h
 @@ -21,6 +21,8 @@ int cil_android_attrib_mapping(struct cil_db **mdb, struct cil_db *srcdb, const
@@ -37,7 +37,7 @@
   *   srcdb - initialized and parsed cil_db reference to source public policy
   *           from which to extract attributizable elements.
 diff --git a/libsepol/cil/src/android.c b/libsepol/cil/src/android.c
-index 1d80046b..53df4187 100644
+index 1d80046..53df418 100644
 --- a/libsepol/cil/src/android.c
 +++ b/libsepol/cil/src/android.c
 @@ -200,23 +200,27 @@ static char *__cil_attrib_get_versname(char *old, const char *vers)
@@ -85,5 +85,5 @@
  
  	return SEPOL_OK;
 -- 
-2.15.1
+2.7.4
 
diff --git a/patches/platform_external_selinux/0003-libsepol-cil-Create-new-keep-field-for-type-attribut.patch b/patches/platform_external_selinux/0003-libsepol-cil-Create-new-keep-field-for-type-attribut.patch
index 86f94f1..875fef9 100644
--- a/patches/platform_external_selinux/0003-libsepol-cil-Create-new-keep-field-for-type-attribut.patch
+++ b/patches/platform_external_selinux/0003-libsepol-cil-Create-new-keep-field-for-type-attribut.patch
@@ -32,7 +32,7 @@
  6 files changed, 9 insertions(+), 6 deletions(-)
 
 diff --git a/libsepol/cil/src/cil.c b/libsepol/cil/src/cil.c
-index e8bbbfdf..a5a3e263 100644
+index e8bbbfd..a5a3e26 100644
 --- a/libsepol/cil/src/cil.c
 +++ b/libsepol/cil/src/cil.c
 @@ -2038,6 +2038,7 @@ void cil_typeattribute_init(struct cil_typeattribute **attr)
@@ -44,7 +44,7 @@
  
  void cil_typeattributeset_init(struct cil_typeattributeset **attrset)
 diff --git a/libsepol/cil/src/cil_binary.c b/libsepol/cil/src/cil_binary.c
-index e1481a43..1818ffa9 100644
+index e1481a4..1818ffa 100644
 --- a/libsepol/cil/src/cil_binary.c
 +++ b/libsepol/cil/src/cil_binary.c
 @@ -567,7 +567,7 @@ int cil_typeattribute_to_policydb(policydb_t *pdb, struct cil_typeattribute *cil
@@ -84,7 +84,7 @@
  					}
  				}
 diff --git a/libsepol/cil/src/cil_internal.h b/libsepol/cil/src/cil_internal.h
-index abfacd8d..942b28f0 100644
+index abfacd8..942b28f 100644
 --- a/libsepol/cil/src/cil_internal.h
 +++ b/libsepol/cil/src/cil_internal.h
 @@ -527,6 +527,7 @@ struct cil_typeattribute {
@@ -96,7 +96,7 @@
  
  struct cil_typeattributeset {
 diff --git a/libsepol/cil/src/cil_policy.c b/libsepol/cil/src/cil_policy.c
-index 77179e63..3e511330 100644
+index 77179e6..3e51133 100644
 --- a/libsepol/cil/src/cil_policy.c
 +++ b/libsepol/cil/src/cil_policy.c
 @@ -1085,7 +1085,7 @@ static void cil_typeattributes_to_policy(FILE *out, struct cil_list *types, stru
@@ -109,7 +109,7 @@
  			if (ebitmap_get_bit(attribute->types, type->value)) {
  				if (first) {
 diff --git a/libsepol/cil/src/cil_post.c b/libsepol/cil/src/cil_post.c
-index 1941fab3..a30de0e1 100644
+index 1941fab..a30de0e 100644
 --- a/libsepol/cil/src/cil_post.c
 +++ b/libsepol/cil/src/cil_post.c
 @@ -1250,7 +1250,7 @@ static int __cil_post_db_attr_helper(struct cil_tree_node *node, uint32_t *finis
@@ -122,7 +122,7 @@
  	}
  	case CIL_ROLEATTRIBUTE: {
 diff --git a/libsepol/cil/src/cil_reset_ast.c b/libsepol/cil/src/cil_reset_ast.c
-index 676e156e..142179ee 100644
+index 676e156..142179e 100644
 --- a/libsepol/cil/src/cil_reset_ast.c
 +++ b/libsepol/cil/src/cil_reset_ast.c
 @@ -186,6 +186,7 @@ static void cil_reset_typeattr(struct cil_typeattribute *attr)
@@ -134,5 +134,5 @@
  
  static void cil_reset_typeattributeset(struct cil_typeattributeset *tas)
 -- 
-2.15.1
+2.7.4
 
diff --git a/patches/platform_external_selinux/0004-Enable-multipl_decls-by-default.-This-is-needed-beca.patch b/patches/platform_external_selinux/0004-Enable-multipl_decls-by-default.-This-is-needed-beca.patch
index edf02fa..ab6521f 100644
--- a/patches/platform_external_selinux/0004-Enable-multipl_decls-by-default.-This-is-needed-beca.patch
+++ b/patches/platform_external_selinux/0004-Enable-multipl_decls-by-default.-This-is-needed-beca.patch
@@ -10,7 +10,7 @@
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/secilc/secilc.c b/secilc/secilc.c
-index 0be6975b..e30572e5 100644
+index 0be6975..e30572e 100644
 --- a/secilc/secilc.c
 +++ b/secilc/secilc.c
 @@ -90,7 +90,7 @@ int main(int argc, char *argv[])
@@ -23,5 +23,5 @@
  	int preserve_tunables = 0;
  	int handle_unknown = -1;
 -- 
-2.15.1
+2.7.4
 
diff --git a/patches/platform_external_selinux/0005-Delete-identical-genfscon-s.patch b/patches/platform_external_selinux/0005-Delete-identical-genfscon-s.patch
deleted file mode 100644
index bf664e1..0000000
--- a/patches/platform_external_selinux/0005-Delete-identical-genfscon-s.patch
+++ /dev/null
@@ -1,42 +0,0 @@
-From c334f823d0eccac2656ceceb707367680cca32f2 Mon Sep 17 00:00:00 2001
-From: Pierre-Hugues Husson <phh@phh.me>
-Date: Sat, 3 Mar 2018 19:02:29 +0100
-Subject: [PATCH 5/5] Delete identical genfscon-s
-
-Change-Id: I9775187b9da3568390ab66ebd59cb774b1283ad1
----
- libsepol/cil/src/cil_post.c | 11 +++++++++++
- 1 file changed, 11 insertions(+)
-
-diff --git a/libsepol/cil/src/cil_post.c b/libsepol/cil/src/cil_post.c
-index a30de0e1..605847d1 100644
---- a/libsepol/cil/src/cil_post.c
-+++ b/libsepol/cil/src/cil_post.c
-@@ -53,6 +53,16 @@
- static int __cil_expr_to_bitmap(struct cil_list *expr, ebitmap_t *out, int max, struct cil_db *db);
- static int __cil_expr_list_to_bitmap(struct cil_list *expr_list, ebitmap_t *out, int max, struct cil_db *db);
- 
-+static int compact(void* array, int count, int len, int (*compar)(const void *, const void *)) {
-+	char *a = (char*)array;
-+	int j = 0;
-+	for(int i=1; i<count; i++) {
-+		if(compar(a+i*len, a+j*len) != 0) j++;
-+		if(i != j) memcpy(a+j*len, a+i*len, len);
-+	}
-+	return j;
-+}
-+
- static int cil_verify_is_list(struct cil_list *list, enum cil_flavor flavor)
- {
- 	struct cil_list_item *curr;
-@@ -1977,6 +1987,7 @@ static int cil_post_db(struct cil_db *db)
- 
- 	qsort(db->netifcon->array, db->netifcon->count, sizeof(db->netifcon->array), cil_post_netifcon_compare);
- 	qsort(db->genfscon->array, db->genfscon->count, sizeof(db->genfscon->array), cil_post_genfscon_compare);
-+	db->genfscon->count = compact(db->genfscon->array, db->genfscon->count, sizeof(db->genfscon->array), cil_post_genfscon_compare);
- 	qsort(db->portcon->array, db->portcon->count, sizeof(db->portcon->array), cil_post_portcon_compare);
- 	qsort(db->nodecon->array, db->nodecon->count, sizeof(db->nodecon->array), cil_post_nodecon_compare);
- 	qsort(db->fsuse->array, db->fsuse->count, sizeof(db->fsuse->array), cil_post_fsuse_compare);
--- 
-2.15.1
-
diff --git a/patches/platform_external_selinux/0005-libsepol-cil-Improve-processing-of-context-rules.patch b/patches/platform_external_selinux/0005-libsepol-cil-Improve-processing-of-context-rules.patch
new file mode 100644
index 0000000..c5241e0
--- /dev/null
+++ b/patches/platform_external_selinux/0005-libsepol-cil-Improve-processing-of-context-rules.patch
@@ -0,0 +1,377 @@
+From 9b009c3354946ec04c60b87d344ed2abbe63c4ba Mon Sep 17 00:00:00 2001
+From: James Carter <jwcart2@tycho.nsa.gov>
+Date: Thu, 29 Mar 2018 16:06:49 -0400
+Subject: [PATCH 5/5] libsepol/cil: Improve processing of context rules
+
+Improve the processing of netifcon, genfscon, ibpkeycon, ibendportcon,
+portcon, nodecon, fsuse, filecon, iomemcon, ioportcon, pcidevicecon,
+and devicetreecon rules.
+
+If the multiple-decls option is not used then report errors if duplicate
+context rules are found. If it is used then remove duplicate context rules
+and report errors when two rules are identical except for the context.
+
+This also changes the ordering of portcon and filecon rules. The protocol
+of portcon rules will be compared if the port numbers are the same and the
+path strings of filecon rules will be compared if the number of meta
+characters, the stem length, string length and file types are the same.
+
+Based on an initial patch by Pierre-Hugues Husson (phh@phh.me)
+
+Signed-off-by: James Carter <jwcart2@tycho.nsa.gov>
+---
+ libsepol/cil/src/cil_post.c | 303 ++++++++++++++++++++++++++++++++++++++++++--
+ 1 file changed, 292 insertions(+), 11 deletions(-)
+
+diff --git a/libsepol/cil/src/cil_post.c b/libsepol/cil/src/cil_post.c
+index a30de0e..3799350 100644
+--- a/libsepol/cil/src/cil_post.c
++++ b/libsepol/cil/src/cil_post.c
+@@ -53,6 +53,83 @@
+ static int __cil_expr_to_bitmap(struct cil_list *expr, ebitmap_t *out, int max, struct cil_db *db);
+ static int __cil_expr_list_to_bitmap(struct cil_list *expr_list, ebitmap_t *out, int max, struct cil_db *db);
+ 
++static int cats_compare(struct cil_cats *a, struct cil_cats *b)
++{
++	struct cil_list_item *i, *j;
++	int rc;
++
++	if (a == b) return 0;
++	if (!a) return -1;
++	if (!b) return 1;
++
++	/* Expects cat expression to have been evaluated */
++	cil_list_for_each(i, a->datum_expr) {
++		cil_list_for_each(j, b->datum_expr) {
++			rc = strcmp(DATUM(i->data)->fqn, DATUM(j->data)->fqn);
++			if (!rc) return rc;
++		}
++	}
++	return 0;
++}
++
++static int level_compare(struct cil_level *a, struct cil_level *b)
++{
++	int rc;
++
++	if (a == b) return 0;
++	if (!a) return -1;
++	if (!b) return 1;
++
++	if (a->sens != b->sens) {
++		rc = strcmp(DATUM(a->sens)->fqn, DATUM(b->sens)->fqn);
++		if (rc != 0) return rc;
++	}
++	if (a->cats != b->cats) {
++		return cats_compare(a->cats, b->cats);
++	}
++	return 0;
++}
++
++static int range_compare(struct cil_levelrange *a, struct cil_levelrange *b)
++{
++	int rc;
++
++	if (a == b) return 0;
++	if (!a) return -1;
++	if (!b) return 1;
++
++	if (a->low != b->low) {
++		rc = level_compare(a->low, b->low);
++		if (rc != 0) return rc;
++	}
++	if (a->high != b->high) {
++		return level_compare(a->high, b->high);
++	}
++	return 0;
++}
++
++static int context_compare(struct cil_context *a, struct cil_context *b)
++{
++	int rc;
++
++	if (a->user != b->user) {
++		rc = strcmp(DATUM(a->user)->fqn, DATUM(b->user)->fqn);
++		if (rc != 0) return rc;
++	}
++	if (a->role != b->role) {
++		rc = strcmp(DATUM(a->role)->fqn, DATUM(b->role)->fqn);
++		if (rc != 0) return rc;
++	}
++	if (a->type != b->type) {
++		rc = strcmp(DATUM(a->type)->fqn, DATUM(b->type)->fqn);
++		if (rc != 0) return rc;
++	}
++	if (a->range != b->range) {
++		return range_compare(a->range, b->range);
++	}
++	return 0;
++}
++
+ static int cil_verify_is_list(struct cil_list *list, enum cil_flavor flavor)
+ {
+ 	struct cil_list_item *curr;
+@@ -144,6 +221,8 @@ int cil_post_filecon_compare(const void *a, const void *b)
+ 		rc = -1;
+ 	} else if (b_filecon->type < a_filecon->type) {
+ 		rc = 1;
++	} else {
++		rc = strcmp(a_filecon->path_str, b_filecon->path_str);
+ 	}
+ 
+ 	free(a_path);
+@@ -167,6 +246,10 @@ int cil_post_portcon_compare(const void *a, const void *b)
+ 			rc = -1;
+ 		} else if (bportcon->port_low < aportcon->port_low) {
+ 			rc = 1;
++		} else if (aportcon->proto < bportcon->proto) {
++			rc = -1;
++		} else if (aportcon->proto > bportcon->proto) {
++			rc = 1;
+ 		}
+ 	}
+ 
+@@ -327,6 +410,88 @@ int cil_post_fsuse_compare(const void *a, const void *b)
+ 	return rc;
+ }
+ 
++int cil_post_filecon_context_compare(const void *a, const void *b)
++{
++	struct cil_filecon *a_filecon = *(struct cil_filecon**)a;
++	struct cil_filecon *b_filecon = *(struct cil_filecon**)b;
++	return context_compare(a_filecon->context, b_filecon->context);
++}
++
++int cil_post_portcon_context_compare(const void *a, const void *b)
++{
++	struct cil_portcon *a_portcon = *(struct cil_portcon**)a;
++	struct cil_portcon *b_portcon = *(struct cil_portcon**)b;
++	return context_compare(a_portcon->context, b_portcon->context);
++}
++
++int cil_post_genfscon_context_compare(const void *a, const void *b)
++{
++	struct cil_genfscon *a_genfscon = *(struct cil_genfscon**)a;
++	struct cil_genfscon *b_genfscon = *(struct cil_genfscon**)b;
++	return context_compare(a_genfscon->context, b_genfscon->context);
++}
++
++int cil_post_netifcon_context_compare(const void *a, const void *b)
++{
++	int rc;
++	struct cil_netifcon *a_netifcon = *(struct cil_netifcon**)a;
++	struct cil_netifcon *b_netifcon = *(struct cil_netifcon**)b;
++	rc = context_compare(a_netifcon->if_context, b_netifcon->if_context);
++	if (rc != 0) {
++		return rc;
++	}
++	return context_compare(a_netifcon->packet_context, b_netifcon->packet_context);
++}
++
++int cil_post_nodecon_context_compare(const void *a, const void *b)
++{
++	struct cil_nodecon *a_nodecon = *(struct cil_nodecon **)a;
++	struct cil_nodecon *b_nodecon = *(struct cil_nodecon **)b;
++	return context_compare(a_nodecon->context, b_nodecon->context);
++}
++
++int cil_post_pirqcon_context_compare(const void *a, const void *b)
++{
++	struct cil_pirqcon *a_pirqcon = *(struct cil_pirqcon**)a;
++	struct cil_pirqcon *b_pirqcon = *(struct cil_pirqcon**)b;
++	return context_compare(a_pirqcon->context, b_pirqcon->context);
++}
++
++int cil_post_iomemcon_context_compare(const void *a, const void *b)
++{
++	struct cil_iomemcon *a_iomemcon = *(struct cil_iomemcon**)a;
++	struct cil_iomemcon *b_iomemcon = *(struct cil_iomemcon**)b;
++	return context_compare(a_iomemcon->context, b_iomemcon->context);
++}
++
++int cil_post_ioportcon_context_compare(const void *a, const void *b)
++{
++	struct cil_ioportcon *a_ioportcon = *(struct cil_ioportcon**)a;
++	struct cil_ioportcon *b_ioportcon = *(struct cil_ioportcon**)b;
++	return context_compare(a_ioportcon->context, b_ioportcon->context);
++}
++
++int cil_post_pcidevicecon_context_compare(const void *a, const void *b)
++{
++	struct cil_pcidevicecon *a_pcidevicecon = *(struct cil_pcidevicecon**)a;
++	struct cil_pcidevicecon *b_pcidevicecon = *(struct cil_pcidevicecon**)b;
++	return context_compare(a_pcidevicecon->context, b_pcidevicecon->context);
++}
++
++int cil_post_devicetreecon_context_compare(const void *a, const void *b)
++{
++	struct cil_devicetreecon *a_devicetreecon = *(struct cil_devicetreecon**)a;
++	struct cil_devicetreecon *b_devicetreecon = *(struct cil_devicetreecon**)b;
++	return context_compare(a_devicetreecon->context, b_devicetreecon->context);
++}
++
++int cil_post_fsuse_context_compare(const void *a, const void *b)
++{
++	struct cil_fsuse *a_fsuse = *(struct cil_fsuse**)a;
++	struct cil_fsuse *b_fsuse = *(struct cil_fsuse**)b;
++	return context_compare(a_fsuse->context, b_fsuse->context);
++}
++
+ static int __cil_post_db_count_helper(struct cil_tree_node *node, uint32_t *finished, void *extra_args)
+ {
+ 	struct cil_db *db = extra_args;
+@@ -1929,6 +2094,74 @@ exit:
+ 	return rc;
+ }
+ 
++static int __cil_post_report_conflict(struct cil_tree_node *node, uint32_t *finished, void *extra_args)
++{
++	struct cil_list_item *li = extra_args;
++
++	if (node->flavor == CIL_BLOCK) {
++		struct cil_block *blk = node->data;
++		if (blk->is_abstract == CIL_TRUE) {
++			*finished = CIL_TREE_SKIP_HEAD;
++		}
++	} else if (node->flavor == CIL_MACRO) {
++		*finished = CIL_TREE_SKIP_HEAD;
++	} else if (node->flavor == li->flavor) {
++		if (node->data == li->data) {
++			char *path = cil_tree_get_cil_path(node);
++			cil_log(CIL_WARN, "  at %s:%d\n", path, node->line);
++		}
++	}
++	return SEPOL_OK;
++}
++
++static int __cil_post_process_context_rules(struct cil_sort *sort, int (*compar)(const void *, const void *), int (*concompar)(const void *, const void *), struct cil_db *db, enum cil_flavor flavor, const char *flavor_str)
++{
++	uint32_t count = sort->count;
++	uint32_t i, j = 0, removed = 0;
++	int rc = SEPOL_OK;
++
++	if (count < 2) {
++		return SEPOL_OK;
++	}
++
++	qsort(sort->array, sort->count, sizeof(sort->array), compar);
++
++	for (i=1; i<count; i++) {
++		if (compar(&sort->array[i], &sort->array[j]) != 0) {
++			j++;
++		} else {
++			removed++;
++			if (!db->multiple_decls ||
++			   concompar(&sort->array[i], &sort->array[j]) != 0) {
++				struct cil_list_item li;
++				int rc2;
++				cil_log(CIL_WARN, "Found conflicting %s rules\n",
++					flavor_str);
++				rc = SEPOL_ERR;
++				li.flavor = flavor;
++				li.data = sort->array[i];
++				rc2 = cil_tree_walk(db->ast->root,
++						    __cil_post_report_conflict,
++						    NULL, NULL, &li);
++				if (rc2 != SEPOL_OK) goto exit;
++				li.data = sort->array[j];
++				rc2 = cil_tree_walk(db->ast->root,
++						    __cil_post_report_conflict,
++						    NULL, NULL, &li);
++				if (rc2 != SEPOL_OK) goto exit;
++			}
++		}
++		if (i != j) {
++			sort->array[j] = sort->array[i];
++		}
++	}
++
++	sort->count = count - removed;
++
++exit:
++	return rc;
++}
++
+ static int cil_post_db(struct cil_db *db)
+ {
+ 	int rc = SEPOL_ERR;
+@@ -1975,17 +2208,65 @@ static int cil_post_db(struct cil_db *db)
+ 		goto exit;
+ 	}
+ 
+-	qsort(db->netifcon->array, db->netifcon->count, sizeof(db->netifcon->array), cil_post_netifcon_compare);
+-	qsort(db->genfscon->array, db->genfscon->count, sizeof(db->genfscon->array), cil_post_genfscon_compare);
+-	qsort(db->portcon->array, db->portcon->count, sizeof(db->portcon->array), cil_post_portcon_compare);
+-	qsort(db->nodecon->array, db->nodecon->count, sizeof(db->nodecon->array), cil_post_nodecon_compare);
+-	qsort(db->fsuse->array, db->fsuse->count, sizeof(db->fsuse->array), cil_post_fsuse_compare);
+-	qsort(db->filecon->array, db->filecon->count, sizeof(db->filecon->array), cil_post_filecon_compare);
+-	qsort(db->pirqcon->array, db->pirqcon->count, sizeof(db->pirqcon->array), cil_post_pirqcon_compare);
+-	qsort(db->iomemcon->array, db->iomemcon->count, sizeof(db->iomemcon->array), cil_post_iomemcon_compare);
+-	qsort(db->ioportcon->array, db->ioportcon->count, sizeof(db->ioportcon->array), cil_post_ioportcon_compare);
+-	qsort(db->pcidevicecon->array, db->pcidevicecon->count, sizeof(db->pcidevicecon->array), cil_post_pcidevicecon_compare);
+-	qsort(db->devicetreecon->array, db->devicetreecon->count, sizeof(db->devicetreecon->array), cil_post_devicetreecon_compare);
++	rc = __cil_post_process_context_rules(db->netifcon, cil_post_netifcon_compare, cil_post_netifcon_context_compare, db, CIL_NETIFCON, CIL_KEY_NETIFCON);
++	if (rc != SEPOL_OK) {
++		cil_log(CIL_ERR, "Problems processing netifcon rules\n");
++		goto exit;
++	}
++
++	rc = __cil_post_process_context_rules(db->genfscon, cil_post_genfscon_compare, cil_post_genfscon_context_compare, db, CIL_GENFSCON, CIL_KEY_GENFSCON);
++	if (rc != SEPOL_OK) {
++		cil_log(CIL_ERR, "Problems processing genfscon rules\n");
++		goto exit;
++	}
++
++	rc = __cil_post_process_context_rules(db->portcon, cil_post_portcon_compare, cil_post_portcon_context_compare, db, CIL_PORTCON, CIL_KEY_PORTCON);
++	if (rc != SEPOL_OK) {
++		cil_log(CIL_ERR, "Problems processing portcon rules\n");
++		goto exit;
++	}
++
++	rc = __cil_post_process_context_rules(db->nodecon, cil_post_nodecon_compare, cil_post_nodecon_context_compare, db, CIL_NODECON, CIL_KEY_NODECON);
++	if (rc != SEPOL_OK) {
++		cil_log(CIL_ERR, "Problems processing nodecon rules\n");
++		goto exit;
++	}
++
++	rc = __cil_post_process_context_rules(db->fsuse, cil_post_fsuse_compare, cil_post_fsuse_context_compare, db, CIL_FSUSE, CIL_KEY_FSUSE);
++	if (rc != SEPOL_OK) {
++		cil_log(CIL_ERR, "Problems processing fsuse rules\n");
++		goto exit;
++	}
++
++	rc = __cil_post_process_context_rules(db->filecon, cil_post_filecon_compare, cil_post_filecon_context_compare, db, CIL_FILECON, CIL_KEY_FILECON);
++	if (rc != SEPOL_OK) {
++		cil_log(CIL_ERR, "Problems processing filecon rules\n");
++		goto exit;
++	}
++
++	rc = __cil_post_process_context_rules(db->iomemcon, cil_post_iomemcon_compare, cil_post_iomemcon_context_compare, db, CIL_IOMEMCON, CIL_KEY_IOMEMCON);
++	if (rc != SEPOL_OK) {
++		cil_log(CIL_ERR, "Problems processing iomemcon rules\n");
++		goto exit;
++	}
++
++	rc = __cil_post_process_context_rules(db->ioportcon, cil_post_ioportcon_compare, cil_post_ioportcon_context_compare, db, CIL_IOPORTCON, CIL_KEY_IOPORTCON);
++	if (rc != SEPOL_OK) {
++		cil_log(CIL_ERR, "Problems processing ioportcon rules\n");
++		goto exit;
++	}
++
++	rc = __cil_post_process_context_rules(db->pcidevicecon, cil_post_pcidevicecon_compare, cil_post_pcidevicecon_context_compare, db, CIL_PCIDEVICECON, CIL_KEY_PCIDEVICECON);
++	if (rc != SEPOL_OK) {
++		cil_log(CIL_ERR, "Problems processing pcidevicecon rules\n");
++		goto exit;
++	}
++
++	rc = __cil_post_process_context_rules(db->devicetreecon, cil_post_devicetreecon_compare, cil_post_devicetreecon_context_compare, db, CIL_DEVICETREECON, CIL_KEY_DEVICETREECON);
++	if (rc != SEPOL_OK) {
++		cil_log(CIL_ERR, "Problems processing devicetreecon rules\n");
++		goto exit;
++	}
+ 
+ exit:
+ 	return rc;
+-- 
+2.7.4
+
diff --git a/patches/platform_frameworks_base/0001-renderthread-relax-error-handling-for-wide-gamut-EGL.patch b/patches/platform_frameworks_base/0001-renderthread-relax-error-handling-for-wide-gamut-EGL.patch
index 73d2590..81c8692 100644
--- a/patches/platform_frameworks_base/0001-renderthread-relax-error-handling-for-wide-gamut-EGL.patch
+++ b/patches/platform_frameworks_base/0001-renderthread-relax-error-handling-for-wide-gamut-EGL.patch
@@ -1,7 +1,7 @@
-From 8aff32ec3106530d1ea81ba536cd548760bd4ded Mon Sep 17 00:00:00 2001
+From 5063cdf366ef61b1151f5376ca106f77719404ee Mon Sep 17 00:00:00 2001
 From: Rob Herring <robh@kernel.org>
 Date: Wed, 29 Nov 2017 09:26:31 -0600
-Subject: [PATCH 1/3] renderthread: relax error handling for wide gamut EGL
+Subject: [PATCH 1/6] renderthread: relax error handling for wide gamut EGL
  configs
 
 It is valid to advertise EGL_EXT_pixel_format_float, but not have a
@@ -16,7 +16,7 @@
  1 file changed, 2 insertions(+), 2 deletions(-)
 
 diff --git a/libs/hwui/renderthread/EglManager.cpp b/libs/hwui/renderthread/EglManager.cpp
-index 16d77364942..bd4708da562 100644
+index 16d7736..bd4708d 100644
 --- a/libs/hwui/renderthread/EglManager.cpp
 +++ b/libs/hwui/renderthread/EglManager.cpp
 @@ -223,9 +223,9 @@ void EglManager::loadConfigs() {
@@ -32,5 +32,5 @@
      }
  }
 -- 
-2.15.1
+2.7.4
 
diff --git a/patches/platform_frameworks_base/0002-Reintroduce-button-backlight-and-respective-inactivi.patch b/patches/platform_frameworks_base/0002-Reintroduce-button-backlight-and-respective-inactivi.patch
index e4afc1d..5321082 100644
--- a/patches/platform_frameworks_base/0002-Reintroduce-button-backlight-and-respective-inactivi.patch
+++ b/patches/platform_frameworks_base/0002-Reintroduce-button-backlight-and-respective-inactivi.patch
@@ -1,7 +1,7 @@
-From d1cd1dbf69b4cb6c0046255c8015c58b10a90165 Mon Sep 17 00:00:00 2001
+From d7116d97f5a71b125be642494d897aed4ef31c60 Mon Sep 17 00:00:00 2001
 From: Ricardo Cerqueira <cyanogenmod@cerqueira.org>
 Date: Fri, 23 Nov 2012 14:23:16 +0000
-Subject: [PATCH 2/3] Reintroduce button-backlight (and respective inactivity
+Subject: [PATCH 2/6] Reintroduce button-backlight (and respective inactivity
  timeout)
 
 The power manager rewrite from Change I1d7a52e98f0449f76d70bf421f6a7f245957d1d7
@@ -19,7 +19,7 @@
  2 files changed, 21 insertions(+)
 
 diff --git a/services/core/java/com/android/server/display/DisplayPowerController.java b/services/core/java/com/android/server/display/DisplayPowerController.java
-index f8e58362e7a..80bdf1ffade 100644
+index f8e5836..80bdf1f 100644
 --- a/services/core/java/com/android/server/display/DisplayPowerController.java
 +++ b/services/core/java/com/android/server/display/DisplayPowerController.java
 @@ -20,6 +20,7 @@ import android.app.ActivityManager;
@@ -62,7 +62,7 @@
  
          // Configure auto-brightness.
 diff --git a/services/core/java/com/android/server/power/PowerManagerService.java b/services/core/java/com/android/server/power/PowerManagerService.java
-index f84b20c0570..1ced53fe840 100644
+index f84b20c..1ced53f 100644
 --- a/services/core/java/com/android/server/power/PowerManagerService.java
 +++ b/services/core/java/com/android/server/power/PowerManagerService.java
 @@ -220,6 +220,8 @@ public final class PowerManagerService extends SystemService
@@ -104,5 +104,5 @@
                      } else {
                          nextTimeout = mLastUserActivityTime + screenOffTimeout;
 -- 
-2.15.1
+2.7.4
 
diff --git a/patches/platform_frameworks_base/0003-power-Disable-keyboard-button-lights-while-dozing-dr.patch b/patches/platform_frameworks_base/0003-power-Disable-keyboard-button-lights-while-dozing-dr.patch
index 1c6606c..2f72489 100644
--- a/patches/platform_frameworks_base/0003-power-Disable-keyboard-button-lights-while-dozing-dr.patch
+++ b/patches/platform_frameworks_base/0003-power-Disable-keyboard-button-lights-while-dozing-dr.patch
@@ -1,7 +1,7 @@
-From 55bd603882486a351210d29ac7767d92f12000f2 Mon Sep 17 00:00:00 2001
+From 0ac1c80ec58bee78a6240a197c68975b284e984c Mon Sep 17 00:00:00 2001
 From: Steve Kondik <steve@cyngn.com>
 Date: Sat, 3 Jan 2015 05:13:26 -0800
-Subject: [PATCH 3/3] power: Disable keyboard/button lights while
+Subject: [PATCH 3/6] power: Disable keyboard/button lights while
  dozing/dreaming
 
  * With hardkeys and doze mode enabled, entering suspend results in
@@ -14,7 +14,7 @@
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/services/core/java/com/android/server/power/PowerManagerService.java b/services/core/java/com/android/server/power/PowerManagerService.java
-index 1ced53fe840..9edf6fcae1e 100644
+index 1ced53f..9edf6fc 100644
 --- a/services/core/java/com/android/server/power/PowerManagerService.java
 +++ b/services/core/java/com/android/server/power/PowerManagerService.java
 @@ -1947,7 +1947,7 @@ public final class PowerManagerService extends SystemService
@@ -27,5 +27,5 @@
                              + screenOffTimeout - screenDimDuration;
                      if (now < nextTimeout) {
 -- 
-2.15.1
+2.7.4
 
diff --git a/patches/platform_frameworks_base/0004-Fix-backlight-control-on-Galaxy-S9.patch b/patches/platform_frameworks_base/0004-Fix-backlight-control-on-Galaxy-S9.patch
index 1c59cbd..60c03f1 100644
--- a/patches/platform_frameworks_base/0004-Fix-backlight-control-on-Galaxy-S9.patch
+++ b/patches/platform_frameworks_base/0004-Fix-backlight-control-on-Galaxy-S9.patch
@@ -1,7 +1,7 @@
-From 2e1d738a01ff82c46e9e78ca9dcb042fe68d290a Mon Sep 17 00:00:00 2001
+From ec221199a674603080ab183c912bf5a48cbf2f28 Mon Sep 17 00:00:00 2001
 From: Pierre-Hugues Husson <phh@phh.me>
 Date: Sat, 24 Mar 2018 08:01:48 +0100
-Subject: [PATCH 4/4] Fix backlight control on Galaxy S9(+)
+Subject: [PATCH 4/6] Fix backlight control on Galaxy S9(+)
 
 ---
  services/core/java/com/android/server/lights/LightsService.java | 7 +++++++
diff --git a/patches/platform_frameworks_base/0005-Relax-requirement-for-visible-flag-to-sdcards.patch b/patches/platform_frameworks_base/0005-Relax-requirement-for-visible-flag-to-sdcards.patch
new file mode 100644
index 0000000..645a1b3
--- /dev/null
+++ b/patches/platform_frameworks_base/0005-Relax-requirement-for-visible-flag-to-sdcards.patch
@@ -0,0 +1,31 @@
+From 284d851a55d31127dfe140197968d6daaa2d92e9 Mon Sep 17 00:00:00 2001
+From: Pierre-Hugues Husson <phh@phh.me>
+Date: Tue, 28 Nov 2017 18:28:04 +0100
+Subject: [PATCH 5/6] Relax requirement for visible flag to sdcards
+
+The vast majority of sdcard readers are stable enough to be declared by
+the API. (I see no counter-example)
+FBE broke adoptable storage with SDCard, hence this need.
+
+Change-Id: Ia616671c03562d1eadaff5531a5c708a62d7ad3a
+---
+ services/core/java/com/android/server/StorageManagerService.java | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/services/core/java/com/android/server/StorageManagerService.java b/services/core/java/com/android/server/StorageManagerService.java
+index 1ca0112..4014cab 100644
+--- a/services/core/java/com/android/server/StorageManagerService.java
++++ b/services/core/java/com/android/server/StorageManagerService.java
+@@ -1316,7 +1316,8 @@ class StorageManagerService extends IStorageManager.Stub
+ 
+             // Adoptable public disks are visible to apps, since they meet
+             // public API requirement of being in a stable location.
+-            if (vol.disk.isAdoptable()) {
++	    // Assume all SDs match this as well
++            if (vol.disk.isAdoptable() || vol.disk.isSd()) {
+                 vol.mountFlags |= VolumeInfo.MOUNT_FLAG_VISIBLE;
+             }
+ 
+-- 
+2.7.4
+
diff --git a/patches/platform_frameworks_base/0006-Include-gapps-modifications-for-webview.patch b/patches/platform_frameworks_base/0006-Include-gapps-modifications-for-webview.patch
new file mode 100644
index 0000000..4fcdb08
--- /dev/null
+++ b/patches/platform_frameworks_base/0006-Include-gapps-modifications-for-webview.patch
@@ -0,0 +1,102 @@
+From 3ed5a82453bbe5f6d58324ea14a4b8c5583ab7a8 Mon Sep 17 00:00:00 2001
+From: Pierre-Hugues Husson <phh@phh.me>
+Date: Mon, 26 Sep 2016 13:17:56 +0200
+Subject: [PATCH 6/6] Include gapps modifications for webview
+
+webview_packages: prefer the more powerful webview packages
+
+If Gapps are installed, better webview providers
+become avaliable.
+
+This commit adds support for those and makes the system
+choose the best provider: Chrome Stable>Google Webview>AOSP Webview
+
+It also allows the user to choose between additional
+providers from Play Store: Chrome Beta, Chrome Dev and Chrome Canary.
+
+AOSP WebView is used as Fallback in case no Gapps were installed.
+If Gapps were detected, AOSP WebView will be blocked and cannot be
+chosen any more.
+
+This patch is a collobarative work of:
+
+mfonville <maarten.fonville@gmail.com> @mfonville
+rapperskull <rapper.skull@hotmail.it> @rapperskull
+Arne-Christian Blystad <arne.christian.blystad@bartec-pixavi.com> @Blystad
+Alex Naidis <alex.naidis@linux.com> @TheCrazyLex
+
+You can find more information on this topic here: opengapps/aosp_build#76
+
+Change-Id: I3beecf38c75600ec05c9018259dfe3b539b73614
+Signed-off-by: Alex Naidis <alex.naidis@linux.com>
+
+webview_packages: correct signature definition for Chrome Stable
+
+This is an incremental fix onto this patch:
+https://github.com/AOSPA/android_frameworks_base/commit/d36582165d4694da101cc65755af0841d443c80e
+
+Previously the definition of the signature for Chrome Stable
+was ignored since it wasn't inside the definition of Chrome
+Stable as webviewprovider.
+
+Thanks goes to @AKPWebDesign for initially noticing this.
+
+Change-Id: Id5c051859e7e51e11304874ec2defaa11aede1bf
+Signed-off-by: Alex Naidis <alex.naidis@linux.com>
+
+webview_packages: fix incorrect signatures
+
+Chrome Stable and Google Webview had incorrect
+signatures. That was due to an incorrect method
+of determining the right signature.
+
+That mistake wasn't noticed because Android
+disables the signature check on "userdebug" and
+"eng" builds. It is only enabled on "user" builds.
+
+So this commit replaces the wrong signatures
+of Chrome Stable and Google Webview by the
+correct ones and thus makes them avaliable
+webview providers on "user" builds.
+
+Main credits go to @KreAch3R for his
+extensive research on the issue.
+
+Change-Id: I081783b59254bfed0b2e3568ba8ae2801d86efea
+Signed-off-by: Alex Naidis <alex.naidis@linux.com>
+---
+ core/res/res/xml/config_webview_packages.xml | 19 +++++++++++++++++--
+ 1 file changed, 17 insertions(+), 2 deletions(-)
+
+diff --git a/core/res/res/xml/config_webview_packages.xml b/core/res/res/xml/config_webview_packages.xml
+index f062b59..574f7c1 100644
+--- a/core/res/res/xml/config_webview_packages.xml
++++ b/core/res/res/xml/config_webview_packages.xml
+@@ -15,7 +15,22 @@
+ -->
+ 
+ <webviewproviders>
+-    <!-- The default WebView implementation -->
+-    <webviewprovider description="Android WebView" packageName="com.android.webview" availableByDefault="true">
++
++    <webviewprovider description="Chrome Stable" packageName="com.android.chrome" availableByDefault="true">
++        <signature>MIIEQzCCAyugAwIBAgIJAMLgh0ZkSjCNMA0GCSqGSIb3DQEBBAUAMHQxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtHb29nbGUgSW5jLjEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDAeFw0wODA4MjEyMzEzMzRaFw0zNjAxMDcyMzEzMzRaMHQxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtHb29nbGUgSW5jLjEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDCCASAwDQYJKoZIhvcNAQEBBQADggENADCCAQgCggEBAKtWLgDYO6IIrgqWbxJOKdoR8qtW0I9Y4sypEwPpt1TTcvZApxsdyxMJZ2JORland2qSGT2y5b+3JKkedxiLDmpHpDsz2WCbdxgxRczfey5YZnTJ4VZbH0xqWVW/8lGmPav5xVwnIiJS6HXk+BVKZF+JcWjAsb/GEuq/eFdpuzSqeYTcfi6idkyugwfYwXFU1+5fZKUaRKYCwkkFQVfcAs1fXA5V+++FGfvjJ/CxURaSxaBvGdGDhfXE28LWuT9ozCl5xw4Yq5OGazvV24mZVSoOO0yZ31j7kYvtwYK6NeADwbSxDdJEqO4k//0zOHKrUiGYXtqw/A0LFFtqoZKFjnkCAQOjgdkwgdYwHQYDVR0OBBYEFMd9jMIhF1Ylmn/Tgt9r45jk14alMIGmBgNVHSMEgZ4wgZuAFMd9jMIhF1Ylmn/Tgt9r45jk14aloXikdjB0MQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEUMBIGA1UEChMLR29vZ2xlIEluYy4xEDAOBgNVBAsTB0FuZHJvaWQxEDAOBgNVBAMTB0FuZHJvaWSCCQDC4IdGZEowjTAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBAUAA4IBAQBt0lLO74UwLDYKqs6Tm8/yzKkEu116FmH4rkaymUIE0P9KaMftGlMexFlaYjzmB2OxZyl6euNXEsQH8gjwyxCUKRJNexBiGcCEyj6z+a1fuHHvkiaai+KL8W1EyNmgjmyy8AW7P+LLlkR+ho5zEHatRbM/YAnqGcFh5iZBqpknHf1SKMXFh4dd239FJ1jWYfbMDMy3NS5CTMQ2XFI1MvcyUTdZPErjQfTbQe3aDQsQcafEQPD+nqActifKZ0Np0IS9L9kR/wbNvyz6ENwPiTrjV2KRkEjH78ZMcUQXg0L3BYHJ3lc69Vs5Ddf9uUGGMYldX3WfMBEmh/9iFBDAaTCK</signature>
++    </webviewprovider>
++    <webviewprovider description="Chrome Beta" packageName="com.chrome.beta">
++        <signature>MIIDwzCCAqugAwIBAgIJAOoj9MXoVhH6MA0GCSqGSIb3DQEBBQUAMHgxCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRYwFAYDVQQHDA1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKDAtHb29nbGUgSW5jLjEQMA4GA1UECwwHQW5kcm9pZDEUMBIGA1UEAwwLY2hyb21lX2JldGEwHhcNMTYwMjI5MTUxNTIzWhcNNDMwNzE3MTUxNTIzWjB4MQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEUMBIGA1UECgwLR29vZ2xlIEluYy4xEDAOBgNVBAsMB0FuZHJvaWQxFDASBgNVBAMMC2Nocm9tZV9iZXRhMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAo/wW27nRxVqGbFOyXr8jtv2pc2Ke8XMr6Sfs+3JK2licVaAljGFpLtWH4wUdb50w/QQSPALNLSSyuK/94rtp5Jjs4RSJI+whuewV/R6El+mFXBO3Ek5/op4UrOsR91IM4emvS67Ji2u8gp5EmttVgJtllFZCbtZLPmKuTaOkOB+EdWIxrYiHVEEaAcQpEHa9UgWUZ0bMfPj8j3F0w+Ak2ttmTjoFGLaZjuBAYwfdctN1b0sdLT9Lif45kMCb8QwPp0F9/ozs0rrTc+I6vnTS8kfFQfk7GIE4Hgm+cYQEHkIA6gLJxUVWvPZGdulAZw7wPt/neOkazHNZPcV4pYuNLQIDAQABo1AwTjAdBgNVHQ4EFgQU5t7dhcZfOSixRsiJ1E46JhzPlwowHwYDVR0jBBgwFoAU5t7dhcZfOSixRsiJ1E46JhzPlwowDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOCAQEAZO2jB8P1d8ki3KZILvp27a2VM3DInlp8I8UgG3gh7nBQfTrnZr5M1PL8eFHqX7MEvAiGCMTcrPklEhjtcHK/c7BcdeCWq6oL56UK3JTl33RxJcjmjrz3e3VI6ehRSm1feNAkMD0Nr2RWr2LCYheAEmwTPtluLOJS+i7WhnXJzBtg5UpUFEbdFYenqUbDzya+cUVp0197k7hUTs8/Hxs0wf79o/TZXzTBq9eYQkiITonRN8+5QCBl1XmZKV0IHkzGFES1RP+fTiZpIjZT+W4tasHgs9QTTks4CCpyHBAy+uy7tApe1AxCzihgecCfUN1hWIltKwGZS6EE0bu0OXPzaQ==</signature>
++    </webviewprovider>
++    <webviewprovider description="Chrome Dev" packageName="com.chrome.dev">
++        <signature>MIIDwTCCAqmgAwIBAgIJAOSN+O0cdii5MA0GCSqGSIb3DQEBBQUAMHcxCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRYwFAYDVQQHDA1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKDAtHb29nbGUgSW5jLjEQMA4GA1UECwwHQW5kcm9pZDETMBEGA1UEAwwKY2hyb21lX2RldjAeFw0xNjAyMjkxNzUwMDdaFw00MzA3MTcxNzUwMDdaMHcxCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRYwFAYDVQQHDA1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKDAtHb29nbGUgSW5jLjEQMA4GA1UECwwHQW5kcm9pZDETMBEGA1UEAwwKY2hyb21lX2RldjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANOYPj6Y9rVt8xizSHDYjDEkDfFZAgSiZ9T6tevkQXsFyfaq3Gk3h2qssi29G6cTPJ2VXFKlVB71wSXv5p9/LEcDQPWQiO3Q2cLmgUXxyhJWXI3g96tPAhZQX2q6SC37ZQdiBR/raMO70DAkvCyBGtNplsvutzSE3oZ7LYfzB8vTbe7zCh3fDYSS/7xb3ZVvFqydHS40uVq1qqg1S80Pge7tW3pDGsPMZN7yA4yfmsvA1rbHm9N8t3Rc9hqzh6OxNAAgRB535YcsWL7iF+mpdFILXk3jLYT0nMvMnB83rsdgnRREjlGQYHl2mh8+6CqujsW/eICDq/LR6BYDyqHhk0ECAwEAAaNQME4wHQYDVR0OBBYEFKzsl07JglgpbeYDYGqsgqRDo+01MB8GA1UdIwQYMBaAFKzsl07JglgpbeYDYGqsgqRDo+01MAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBACka6SFF6xAcj8L8O6R36++E09DTiGZEjvKT8eIycgcQQ+p1WUmPb6M2EJpN6zvvSE62ussmXdzf8rIyc0JXA8jbViZt62Y39epNENFxPTLN9QzXlT+w8AW73Ka3cnbOuL5EgoDl8fM79WVlARY3X+wB/jGNrkiGIdRm2IZIeAodWgC2mtXMiferyYBKz2/F2bhnU6DwgCbegS8trFjEWviijWdJ+lBdobn7LRc3orZCtHl8UyvRDi7cye3sK9y3BM39k0g20F21wTNHAonnvL6zbuNgpd+UEsVxDpOeWrEdBFN7Md0CI2wnu8eA8ljJD45v0WWMEoxsIi131g5piNM=</signature>
++    </webviewprovider>
++    <webviewprovider description="Chrome Canary" packageName="com.chrome.canary">
++        <signature>MIIDxzCCAq+gAwIBAgIJAML7APITsgV7MA0GCSqGSIb3DQEBBQUAMHoxCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRYwFAYDVQQHDA1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKDAtHb29nbGUgSW5jLjEQMA4GA1UECwwHQW5kcm9pZDEWMBQGA1UEAwwNY2hyb21lX2NhbmFyeTAeFw0xNjAyMjkxOTA5MDdaFw00MzA3MTcxOTA5MDdaMHoxCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRYwFAYDVQQHDA1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKDAtHb29nbGUgSW5jLjEQMA4GA1UECwwHQW5kcm9pZDEWMBQGA1UEAwwNY2hyb21lX2NhbmFyeTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANXfeAoZlr0ya1HBzIfAz/nLLjpPJeAPvuX5dueaxmiQgv2hNG22acriFuiiJI6TU0t8AIVJD5Ifbc4OOuA0zeFhdzWWGnmTRH6x27WI7bzOKnAqOvv21ZBmE9i8Vo++K13xWdTs3qVn1bn9oUONxFu0wKDzXYZhoj1Jom0RZGjXm16xuPlEuOzMcjiNBDoYuxPAXkMcK/G1gP4P4nAV8Rd/GGIjKRS/SUtcShhoAMOQhs4WIEkUrvEVRwhBDIbpM87oFbCVdBH38r0XS6F6CdhPJsKFhoEfq4c01HZqNmDpCPA8AAcCuSWqmXoTIqs7OqkWgduE2bInbWU7WMaTl+kCAwEAAaNQME4wHQYDVR0OBBYEFB/AsC4iPAqaLoNytNSx29qByI7+MB8GA1UdIwQYMBaAFB/AsC4iPAqaLoNytNSx29qByI7+MAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBAMb2Td3ro/+MGVnCPAbwBSOZMVLUKGqt6zr8CShW9mtFHnmy29EaWSYYAj1M4+6Vpkq85NsgBEck7rnUjV8A3Q0NKdTys1KRKJqVvQRBN6SwqQenSf/abxQCa8Z+69rh+3BkIU1HLtu5lrMDZwon5H91L5mpORn6vItd20uW132lwSDeUEW2CHslTrodoFuTUcSUlRiq/URfUH3baO1QHXkxpQwrBPKL5deJfcZnxh5MAtAGSQL7gHvayEFlDppETXdDO7vgGTH2dEK2TjKWALbGiKkxSqjRyTNt4/FOj10TqNRdUamj+ydVJgzGQ8bki4Vc6NnKm/r4asusxapkVR4=</signature>
+     </webviewprovider>
++    <webviewprovider description="Google WebView" packageName="com.google.android.webview" availableByDefault="true">
++<signature>MIIDuzCCAqOgAwIBAgIJANi6DgBQG4ZTMA0GCSqGSIb3DQEBBQUAMHQxCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRYwFAYDVQQHDA1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKDAtHb29nbGUgSW5jLjEQMA4GA1UECwwHQW5kcm9pZDEQMA4GA1UEAwwHd2VidmlldzAeFw0xNDA4MDgyMzIwMjBaFw00MTEyMjQyMzIwMjBaMHQxCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRYwFAYDVQQHDA1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKDAtHb29nbGUgSW5jLjEQMA4GA1UECwwHQW5kcm9pZDEQMA4GA1UEAwwHd2VidmlldzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMbtaFX0r5aZJMAbPVMAgK1ZZ29dTn91VsGxXv2hqrQo7IpqEy2JmPvPnoMsSiuTAe+UcQy8oKDQ2aYVSAd1DGIy+nSRyFTt3LSIAdwSBkB1qT4a+OqkpsR6bSNXQXQ18lCQu9gREY3h3QlYBQAyzRxw4hRGlrXAzuSz1Ec4W+6x4nLG5DG61MAMR8ClF9XSqbmGB3kyZ70A0X9OPYYxiMWP1ExaYvpaVqjyZZcrPwr+vtW8oCuGBUtHpBUH3OoG+9s2YMcgLG7vCK9awKDqlPcJSpIAAj6uGs4gORmkqxZRMskLSTWbhP4p+3Ap8jYzTVB6Y1/DMVmYTWRMcPW0macCAwEAAaNQME4wHQYDVR0OBBYEFJ6bAR6/QVm4w9LRSGQiaR5Rhp3TMB8GA1UdIwQYMBaAFJ6bAR6/QVm4w9LRSGQiaR5Rhp3TMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBAEQu8QiVxax7/diEiJrgKE1LwdXsIygJK/KnaKdnYEkAQpeu/QmrLiycm+OFbL1qHJIB7OuI/PQBUtcaNSiJSCVgtwtEbZWWIdsynqG/Nf4aGOndXegSQNRH54M05sRHLoeRycPrY7xQlEwGikNFR76+5UdwFBQI3Gn22g6puJnVukQm/wXQ+ajoiS4QclrNlixoDQsZ4STLH4+Wju2wIWKFFArIhVEIlbamq+p6BghuzH3aIz/Fy0YTQKi7SA+0fuNeCaqlSm5pYSt6p5CH89y1Fr+wFc5r3iLRnUwRcy08ESC7bZJnxV3d/YQ5valTxBbzku/dQbXVj/xg69H8l8M</signature>
++</webviewprovider>
++  <!-- The default WebView implementation -->
++    <webviewprovider description="AOSP WebView" packageName="com.android.webview" availableByDefault="true" isFallback="true" />
+ </webviewproviders>
+-- 
+2.7.4
+
diff --git a/patches/platform_frameworks_native/0001-device-Huawei-HWC-doesn-t-understand-0-0-0-0-fullscr.patch b/patches/platform_frameworks_native/0001-device-Huawei-HWC-doesn-t-understand-0-0-0-0-fullscr.patch
index eccd95a..0c711ba 100644
--- a/patches/platform_frameworks_native/0001-device-Huawei-HWC-doesn-t-understand-0-0-0-0-fullscr.patch
+++ b/patches/platform_frameworks_native/0001-device-Huawei-HWC-doesn-t-understand-0-0-0-0-fullscr.patch
@@ -18,7 +18,7 @@
  3 files changed, 44 insertions(+), 1 deletion(-)
 
 diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
-index 038ece2e0..8099f1d3c 100755
+index 038ece2..8099f1d 100755
 --- a/services/surfaceflinger/Layer.cpp
 +++ b/services/surfaceflinger/Layer.cpp
 @@ -871,7 +871,40 @@ void Layer::setPerFrameData(const sp<const DisplayDevice>& displayDevice) {
@@ -64,7 +64,7 @@
          ALOGE("[%s] Failed to set surface damage: %s (%d)", mName.string(),
                  to_string(error).c_str(), static_cast<int32_t>(error));
 diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
-index 4055693e4..3f806b71c 100644
+index 4055693..3f806b7 100644
 --- a/services/surfaceflinger/SurfaceFlinger.cpp
 +++ b/services/surfaceflinger/SurfaceFlinger.cpp
 @@ -247,6 +247,13 @@ SurfaceFlinger::SurfaceFlinger()
@@ -82,7 +82,7 @@
  
  void SurfaceFlinger::onFirstRef()
 diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
-index 99d4a1a63..c888b1dcd 100644
+index 99d4a1a..c888b1d 100644
 --- a/services/surfaceflinger/SurfaceFlinger.h
 +++ b/services/surfaceflinger/SurfaceFlinger.h
 @@ -727,6 +727,9 @@ private:
@@ -96,5 +96,5 @@
      mutable MessageQueue mEventQueue;
      FrameTracker mAnimFrameTracker;
 -- 
-2.15.1
+2.7.4
 
diff --git a/patches/platform_system_bt/0001-Make-BTM_BYPASS_EXTRA_ACL_SETUP-dynamic.patch b/patches/platform_system_bt/0001-Make-BTM_BYPASS_EXTRA_ACL_SETUP-dynamic.patch
index f83d9f9..f626f9f 100644
--- a/patches/platform_system_bt/0001-Make-BTM_BYPASS_EXTRA_ACL_SETUP-dynamic.patch
+++ b/patches/platform_system_bt/0001-Make-BTM_BYPASS_EXTRA_ACL_SETUP-dynamic.patch
@@ -1,4 +1,4 @@
-From e9af4318791727d9e47006aa56f243950a41ba8c Mon Sep 17 00:00:00 2001
+From d246922d298906f22a3dc64607b421ed7219e5c4 Mon Sep 17 00:00:00 2001
 From: Pierre-Hugues Husson <phh@phh.me>
 Date: Tue, 20 Feb 2018 23:04:50 +0100
 Subject: [PATCH] Make BTM_BYPASS_EXTRA_ACL_SETUP dynamic
@@ -12,7 +12,7 @@
  4 files changed, 25 insertions(+), 19 deletions(-)
 
 diff --git a/hci/include/bt_hci_bdroid.h b/hci/include/bt_hci_bdroid.h
-index aa193d058..6c82f19ad 100644
+index aa193d0..6c82f19 100644
 --- a/hci/include/bt_hci_bdroid.h
 +++ b/hci/include/bt_hci_bdroid.h
 @@ -32,6 +32,9 @@
@@ -26,7 +26,7 @@
  /******************************************************************************
   *  Constants & Macros
 diff --git a/include/bt_target.h b/include/bt_target.h
-index eadfc920f..bf1f95dae 100644
+index eadfc92..bf1f95d 100644
 --- a/include/bt_target.h
 +++ b/include/bt_target.h
 @@ -32,6 +32,9 @@
@@ -40,7 +40,7 @@
  #include "bt_types.h" /* This must be defined AFTER buildcfg.h */
  
 diff --git a/stack/btm/btm_acl.cc b/stack/btm/btm_acl.cc
-index 8df6acb81..7eba37d3e 100644
+index 8df6acb..7eba37d 100644
 --- a/stack/btm/btm_acl.cc
 +++ b/stack/btm/btm_acl.cc
 @@ -1164,17 +1164,17 @@ void btm_read_remote_ext_features_failed(uint8_t status, uint16_t handle) {
@@ -72,7 +72,7 @@
  
    /* If anyone cares, tell him database changed */
 diff --git a/stack/btm/btm_sec.cc b/stack/btm/btm_sec.cc
-index 60a3a17ef..5d36ef903 100644
+index 60a3a17..5d36ef9 100644
 --- a/stack/btm/btm_sec.cc
 +++ b/stack/btm/btm_sec.cc
 @@ -4490,15 +4490,15 @@ void btm_sec_connected(const RawAddress& bda, uint16_t handle, uint8_t status,
@@ -101,5 +101,5 @@
    btm_acl_created(bda, p_dev_rec->dev_class, p_dev_rec->sec_bd_name, handle,
                    HCI_ROLE_SLAVE, BT_TRANSPORT_BR_EDR);
 -- 
-2.15.1
+2.7.4
 
diff --git a/patches/platform_system_core/0001-Revert-logd-add-passcred-for-logdw-socket.patch b/patches/platform_system_core/0001-Revert-logd-add-passcred-for-logdw-socket.patch
index 5e386ce..69b57c0 100644
--- a/patches/platform_system_core/0001-Revert-logd-add-passcred-for-logdw-socket.patch
+++ b/patches/platform_system_core/0001-Revert-logd-add-passcred-for-logdw-socket.patch
@@ -12,7 +12,7 @@
  2 files changed, 6 insertions(+), 6 deletions(-)
 
 diff --git a/logd/LogListener.cpp b/logd/LogListener.cpp
-index d2df68eef..e4d2dea92 100644
+index d2df68e..e4d2dea 100644
 --- a/logd/LogListener.cpp
 +++ b/logd/LogListener.cpp
 @@ -145,14 +145,14 @@ int LogListener::getLogSocket() {
@@ -36,7 +36,7 @@
      return sock;
  }
 diff --git a/logd/logd.rc b/logd/logd.rc
-index 88042466b..7494d8fb3 100644
+index 8804246..7494d8f 100644
 --- a/logd/logd.rc
 +++ b/logd/logd.rc
 @@ -1,7 +1,7 @@
@@ -49,5 +49,5 @@
      file /dev/kmsg w
      user logd
 -- 
-2.15.1
+2.7.4
 
diff --git a/patches/platform_system_vold/0001-Allow-deletion-of-symlink.patch b/patches/platform_system_vold/0001-Allow-deletion-of-symlink.patch
index b9afea8..9344b35 100644
--- a/patches/platform_system_vold/0001-Allow-deletion-of-symlink.patch
+++ b/patches/platform_system_vold/0001-Allow-deletion-of-symlink.patch
@@ -21,5 +21,5 @@
          return false;
      }
 -- 
-2.15.1
+2.7.4
 
diff --git a/patches/platform_system_vold/0002-Workaround-perdev_minors-path-change-in-Linux.patch b/patches/platform_system_vold/0002-Workaround-perdev_minors-path-change-in-Linux.patch
index 73edc04..87db5f0 100644
--- a/patches/platform_system_vold/0002-Workaround-perdev_minors-path-change-in-Linux.patch
+++ b/patches/platform_system_vold/0002-Workaround-perdev_minors-path-change-in-Linux.patch
@@ -38,5 +38,5 @@
              return -errno;
          }
 -- 
-2.15.1
+2.7.4