Merge "Add experimental flag to support OpenJDK builds."
diff --git a/core/Makefile b/core/Makefile
index fca06fa..2fbd39a 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -623,6 +623,11 @@
# -----------------------------------------------------------------
# Recovery image
+# Recovery is disabled in PDK builds
+ifeq ($(TARGET_BUILD_PDK),true)
+TARGET_NO_RECOVERY := true
+endif
+
# If neither TARGET_NO_KERNEL nor TARGET_NO_RECOVERY are true
ifeq (,$(filter true, $(TARGET_NO_KERNEL) $(TARGET_NO_RECOVERY)))
diff --git a/core/base_rules.mk b/core/base_rules.mk
index 36f36c1..96d7f39 100644
--- a/core/base_rules.mk
+++ b/core/base_rules.mk
@@ -75,7 +75,7 @@
# Only the tags mentioned in this test are expected to be set by module
# makefiles. Anything else is either a typo or a source of unexpected
# behaviors.
-ifneq ($(filter-out debug eng tests optional samples shell_ash shell_mksh,$(LOCAL_MODULE_TAGS)),)
+ifneq ($(filter-out debug eng tests optional samples shell_mksh,$(LOCAL_MODULE_TAGS)),)
$(warning unusual tags $(LOCAL_MODULE_TAGS) on $(LOCAL_MODULE) at $(LOCAL_PATH))
endif
diff --git a/core/combo/TARGET_linux-aarch64.mk b/core/combo/TARGET_linux-aarch64.mk
index 56dd157..49cf9c0 100644
--- a/core/combo/TARGET_linux-aarch64.mk
+++ b/core/combo/TARGET_linux-aarch64.mk
@@ -45,6 +45,9 @@
$(error Unknown ARM architecture version: $(TARGET_ARCH_VARIANT))
endif
+# TODO: Enable Clang when aarch64 prebuilt is added
+WITHOUT_CLANG := true
+
include $(TARGET_ARCH_SPECIFIC_MAKEFILE)
# You can set TARGET_TOOLS_PREFIX to get gcc from somewhere else
@@ -101,10 +104,10 @@
#
TARGET_GLOBAL_CFLAGS += -Wno-psabi
+# TODO - temporarily remove "-Wl,-z,relro -Wl,-z,now" as they cause segmentation fault on the
+# v8 foundation model.
TARGET_GLOBAL_LDFLAGS += \
-Wl,-z,noexecstack \
- -Wl,-z,relro \
- -Wl,-z,now \
-Wl,--warn-shared-textrel \
-Wl,--fatal-warnings \
$(arch_variant_ldflags)
@@ -125,6 +128,8 @@
libstdc++_root := bionic/libstdc++
libthread_db_root := bionic/libthread_db
+TARGET_LIBGCC := $(shell $(TARGET_CC) $(TARGET_GLOBAL_CFLAGS) \
+ -print-libgcc-file-name)
# unless CUSTOM_KERNEL_HEADERS is defined, we're going to use
# symlinks located in out/ to point to the appropriate kernel
@@ -133,11 +138,13 @@
ifneq ($(CUSTOM_KERNEL_HEADERS),)
KERNEL_HEADERS_COMMON := $(CUSTOM_KERNEL_HEADERS)
KERNEL_HEADERS_ARCH := $(CUSTOM_KERNEL_HEADERS)
+ KERNEL_HEADERS_AUX := $(CUSTOM_KERNEL_HEADERS)
else
KERNEL_HEADERS_COMMON := $(libc_root)/kernel/uapi
- KERNEL_HEADERS_ARCH := $(libc_root)/kernel/uapi/arch-$(TARGET_ARCH)
+ KERNEL_HEADERS_ARCH := $(libc_root)/kernel/uapi/asm-$(TARGET_ARCH)
+ KERNEL_HEADERS_AUX := $(libc_root)/kernel/common
endif
-KERNEL_HEADERS := $(KERNEL_HEADERS_COMMON) $(KERNEL_HEADERS_ARCH)
+KERNEL_HEADERS := $(KERNEL_HEADERS_COMMON) $(KERNEL_HEADERS_ARCH) $(KERNEL_HEADERS_AUX)
TARGET_C_INCLUDES := \
$(libc_root)/arch-aarch64/include \
@@ -148,14 +155,12 @@
$(libm_root)/include/aarch64 \
$(libthread_db_root)/include
-# FIXME
-# CRT* objects to be added later
-TARGET_CRTBEGIN_STATIC_O :=
-TARGET_CRTBEGIN_DYNAMIC_O :=
-TARGET_CRTEND_O :=
+TARGET_CRTBEGIN_STATIC_O := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_static.o
+TARGET_CRTBEGIN_DYNAMIC_O := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_dynamic.o
+TARGET_CRTEND_O := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_android.o
-TARGET_CRTBEGIN_SO_O :=
-TARGET_CRTEND_SO_O :=
+TARGET_CRTBEGIN_SO_O := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_so.o
+TARGET_CRTEND_SO_O := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_so.o
TARGET_STRIP_MODULE:=true
@@ -211,7 +216,7 @@
endef
define transform-o-to-static-executable-inner
-$(hide) $(PRIVATE_CXX) -Bstatic \
+$(hide) $(PRIVATE_CXX) -nostdlib -Bstatic \
-o $@ \
$(PRIVATE_TARGET_GLOBAL_LD_DIRS) \
$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTBEGIN_STATIC_O)) \
diff --git a/core/combo/TARGET_linux-x86.mk b/core/combo/TARGET_linux-x86.mk
index 113957b..7b25a8e 100755
--- a/core/combo/TARGET_linux-x86.mk
+++ b/core/combo/TARGET_linux-x86.mk
@@ -185,6 +185,7 @@
TARGET_GLOBAL_LDFLAGS += -Wl,-z,noexecstack
TARGET_GLOBAL_LDFLAGS += -Wl,-z,relro -Wl,-z,now
TARGET_GLOBAL_LDFLAGS += -Wl,--warn-shared-textrel
+TARGET_GLOBAL_LDFLAGS += -Wl,--fatal-warnings
TARGET_GLOBAL_LDFLAGS += -Wl,--gc-sections
TARGET_C_INCLUDES := \
diff --git a/core/copy_headers.mk b/core/copy_headers.mk
index dac07d5..e16560f 100644
--- a/core/copy_headers.mk
+++ b/core/copy_headers.mk
@@ -15,7 +15,9 @@
$(foreach header,$(LOCAL_COPY_HEADERS), \
$(eval _chFrom := $(LOCAL_PATH)/$(header)) \
$(eval _chTo := \
- $($(my_prefix)OUT_HEADERS)/$(LOCAL_COPY_HEADERS_TO)/$(notdir $(header))) \
+ $(if $(LOCAL_COPY_HEADERS_TO),\
+ $($(my_prefix)OUT_HEADERS)/$(LOCAL_COPY_HEADERS_TO)/$(notdir $(header)),\
+ $($(my_prefix)OUT_HEADERS)/$(notdir $(header)))) \
$(eval $(call copy-one-header,$(_chFrom),$(_chTo))) \
$(eval all_copied_headers: $(_chTo)) \
)
diff --git a/core/droiddoc.mk b/core/droiddoc.mk
index 0d3094d..fedf14a 100644
--- a/core/droiddoc.mk
+++ b/core/droiddoc.mk
@@ -52,12 +52,7 @@
endif
-$(full_target): PRIVATE_BOOTCLASSPATH :=
-ifeq ($(BUILD_OS),linux)
-# You have to set bootclasspath for javadoc manually on linux since Java 6.
-host_jdk_rt_jar := $(dir $(HOST_JDK_TOOLS_JAR))../jre/lib/rt.jar
-$(full_target): PRIVATE_BOOTCLASSPATH := $(host_jdk_rt_jar)
-endif
+$(full_target): PRIVATE_BOOTCLASSPATH := $(call java-lib-files, core)
ifneq ($(LOCAL_IS_HOST_MODULE),true)
@@ -200,6 +195,7 @@
-J-Xmx1024m \
$(PRIVATE_PROFILING_OPTIONS) \
$(addprefix -classpath ,$(PRIVATE_CLASSPATH)) \
+ $(addprefix -bootclasspath ,$(PRIVATE_BOOTCLASSPATH)) \
-sourcepath $(PRIVATE_SOURCE_PATH)$(addprefix :,$(PRIVATE_CLASSPATH)) \
-d $(PRIVATE_OUT_DIR) \
-quiet \
diff --git a/target/board/generic/BoardConfig.mk b/target/board/generic/BoardConfig.mk
index 60decfb..8f698ec 100644
--- a/target/board/generic/BoardConfig.mk
+++ b/target/board/generic/BoardConfig.mk
@@ -74,3 +74,6 @@
BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE := ext4
BOARD_FLASH_BLOCK_SIZE := 512
TARGET_USERIMAGES_SPARSE_EXT_DISABLED := true
+
+BOARD_SEPOLICY_DIRS += build/target/board/generic/sepolicy
+BOARD_SEPOLICY_UNION += domain.te surfaceflinger.te
diff --git a/target/board/generic/sepolicy/domain.te b/target/board/generic/sepolicy/domain.te
new file mode 100644
index 0000000..f026100
--- /dev/null
+++ b/target/board/generic/sepolicy/domain.te
@@ -0,0 +1,2 @@
+# For /sys/qemu_trace files in the emulator.
+allow domain sysfs_writable:file rw_file_perms;
diff --git a/target/board/generic/sepolicy/surfaceflinger.te b/target/board/generic/sepolicy/surfaceflinger.te
new file mode 100644
index 0000000..9523630
--- /dev/null
+++ b/target/board/generic/sepolicy/surfaceflinger.te
@@ -0,0 +1 @@
+allow surfaceflinger self:process execmem;
diff --git a/tools/droiddoc/templates-sdk/assets/css/default.css b/tools/droiddoc/templates-sdk/assets/css/default.css
index fa9dee3..ba1cbac 100644
--- a/tools/droiddoc/templates-sdk/assets/css/default.css
+++ b/tools/droiddoc/templates-sdk/assets/css/default.css
@@ -393,6 +393,17 @@
#nav li ul.tree-list-children ul {
display:block; }
+#nav.samples-nav li li li {
+ font-size:13px;
+}
+#nav.samples-nav li li li a {
+ padding-top:3px;
+ padding-bottom:3px;
+}
+#nav.samples-nav li li ul > li:last-child {
+ padding-bottom:3px;
+}
+
.new,
.new-child {
font-size: .78em;
@@ -860,7 +871,40 @@
.framed-nexus4-port-216 img {
width: 216px;
height: 360px; }
+
+.framed-nexus5-port-span-5 {
+ background: transparent url(../images/styles/device_nexus5_blank_port_span5.png) no-repeat
+ scroll top left;
+ padding: 52px 33px 69px 31px;
+ overflow: hidden;
+}
+.framed-nexus5-port-span-5,
+.framed-nexus5-port-span-5 video,
+.framed-nexus5-port-span-5 img {
+ width: 216px;
+ height: 384px;
+}
+
+.framed-nexus5-land-span-13 {
+ background: transparent url(../images/styles/device_nexus5_blank_land_span13.png) no-repeat scroll top left;
+ padding: 36px 119px 54px 108px;
+ overflow: hidden;
+}
+
+.framed-nexus5-land-span-13,
+.framed-nexus5-land-span-13 video,
+.framed-nexus5-land-span-13 img {
+ width: 533px;
+ height: 300px;
+}
+
+.framed-nexus5-port-span-5,
+.framed-nexus5-port-span-5 video,
+.framed-nexus5-port-span-5 img {
+ width: 216px;
+ height: 384px;
+}
/* landing page disclosures */
.landing-page-link {
@@ -2105,16 +2149,15 @@
border: solid 1px #ddd;
background: #f7f7f7;
}
-.str { color: #080; }
+.str { color: #800; } /* Code string */
.kwd { color: #008; }
-.com { color: #800; }
.typ { color: #606; }
.lit { color: #066; }
.pun { color: #660; }
.pln { color: #000; }
.tag { color: #008; }
.atn { color: #828; }
-.atv { color: #080; }
+.atv { color: #800; } /* XML string */
.dec { color: #606; }
/* --------------------------------------------------------------------------
@@ -2450,13 +2493,12 @@
background-position: -10px 0;
}
-
/* --------------------------------------------------------------------------
Styles for samples project trees and code browsing in resources tab
*/
#codesample-wrapper {
- width:1000px;
+ width:100000px; /* super wide to contain floats, but doesn't cause scroll */
overflow:visible;
}
pre#codesample-block {
@@ -2465,6 +2507,9 @@
background:transparent;
border:none;
}
+pre#codesample-block a.number {
+ display:none;
+}
pre#codesample-block .code-line:hover {
background:#e7e7e7;
}
diff --git a/tools/droiddoc/templates-sdk/assets/images/styles/device_nexus5_blank_land_span13.png b/tools/droiddoc/templates-sdk/assets/images/styles/device_nexus5_blank_land_span13.png
new file mode 100644
index 0000000..5d37121
--- /dev/null
+++ b/tools/droiddoc/templates-sdk/assets/images/styles/device_nexus5_blank_land_span13.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/styles/device_nexus5_blank_port_span5.png b/tools/droiddoc/templates-sdk/assets/images/styles/device_nexus5_blank_port_span5.png
new file mode 100644
index 0000000..df35117
--- /dev/null
+++ b/tools/droiddoc/templates-sdk/assets/images/styles/device_nexus5_blank_port_span5.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/js/docs.js b/tools/droiddoc/templates-sdk/assets/js/docs.js
index 1659cc6..8c00da7 100644
--- a/tools/droiddoc/templates-sdk/assets/js/docs.js
+++ b/tools/droiddoc/templates-sdk/assets/js/docs.js
@@ -241,7 +241,7 @@
var training = $(".next-class-link").length; // decides whether to provide "next class" link
var isCrossingBoundary = false;
- if ($selListItem.hasClass('nav-section')) {
+ if ($selListItem.hasClass('nav-section') && $selListItem.children('div.empty').length == 0) {
// we're on an index page, jump to the first topic
$nextLink = $selListItem.find('ul:eq(0)').find('a:eq(0)');
@@ -262,12 +262,17 @@
} else {
// jump to the next topic in this section (if it exists)
$nextLink = $selListItem.next('li').find('a:eq(0)');
- if (!$nextLink.length) {
+ if ($nextLink.length == 0) {
isCrossingBoundary = true;
// no more topics in this section, jump to the first topic in the next section
$nextLink = $selListItem.parents('li:eq(0)').next('li.nav-section').find('a:eq(0)');
if (!$nextLink.length) { // Go up another layer to look for next page (lesson > class > course)
$nextLink = $selListItem.parents('li:eq(1)').next('li.nav-section').find('a:eq(0)');
+ if ($nextLink.length == 0) {
+ // if that doesn't work, we're at the end of the list, so disable NEXT link
+ $('.next-page-link').attr('href','').addClass("disabled")
+ .click(function() { return false; });
+ }
}
}
}
@@ -285,10 +290,11 @@
$('.next-page-link').attr('href','')
.removeClass("hide").addClass("disabled")
.click(function() { return false; });
-
- $('.next-class-link').attr('href',$nextLink.attr('href'))
- .removeClass("hide").append($nextLink.html());
- $('.next-class-link').find('.new').empty();
+ if ($nextLink.length) {
+ $('.next-class-link').attr('href',$nextLink.attr('href'))
+ .removeClass("hide").append($nextLink.html());
+ $('.next-class-link').find('.new').empty();
+ }
} else {
$('.next-page-link').attr('href', $nextLink.attr('href')).removeClass("hide");
}
@@ -567,7 +573,7 @@
} else {
/* show me */
// first hide all other siblings
- var $others = $('li.nav-section.expanded', $(this).closest('ul'));
+ var $others = $('li.nav-section.expanded', $(this).closest('ul')).not('.sticky');
$others.removeClass('expanded').children('ul').slideUp(250);
// now expand me
@@ -2156,12 +2162,6 @@
// when an event on the browser history occurs (back, forward, load) requery hash and do search
$(window).hashchange( function(){
- // Handle hash changes in the samples browser
- if ($("body").hasClass("samples") && location.href.indexOf("/samples/index.html") != -1) {
- showSamples();
- highlightSidenav();
- resizeNav();
- }
// Exit if the hash isn't a search query or there's an error in the query
if ((location.hash.indexOf("q=") == -1) || (query == "undefined")) {
// If the results pane is open, close it.
@@ -2710,6 +2710,9 @@
$containerUl.append(new_google_node2(node_data));
}
+ // Make all third-generation list items 'sticky' to prevent them from collapsing
+ $containerUl.find('li li li.nav-section').addClass('sticky');
+
initExpandableNavItems("#"+navtree_id);
}
@@ -2722,9 +2725,11 @@
var $li = $('<li>');
var $a;
if (node_data[NODE_HREF] != null) {
- $a = $('<a href="' + toRoot + node_data[NODE_HREF] + '">' + linkText + '</a>');
+ $a = $('<a href="' + toRoot + node_data[NODE_HREF] + '" title="' + linkText + '" >'
+ + linkText + '</a>');
} else {
- $a = $('<a href="#" onclick="return false;">' + linkText + '/</a>');
+ $a = $('<a href="#" onclick="return false;" title="' + linkText + '" >'
+ + linkText + '/</a>');
}
var $childUl = $('<ul>');
if (node_data[NODE_CHILDREN] != null) {
@@ -2791,9 +2796,18 @@
$.getScript(toRoot + 'samples_navtree_data.js', function(data, textStatus, jqxhr) {
// when the file is loaded, initialize the tree
if(jqxhr.status === 200) {
+ // hack to remove the "about the samples" link then put it back in
+ // after we nuke the list to remove the dummy static list of samples
+ var $firstLi = $("#nav.samples-nav > li:first-child").clone();
+ $("#nav.samples-nav").empty();
+ $("#nav.samples-nav").append($firstLi);
+
init_google_navtree2("nav.samples-nav", SAMPLES_NAVTREE_DATA);
highlightSidenav();
resizeNav();
+ if ($("#jd-content #samples").length) {
+ showSamples();
+ }
}
});
}
@@ -2943,10 +2957,31 @@
range.moveToElementText(element);
range.select();
} else if (window.getSelection) { //all others
- selection = window.getSelection();
+ selection = window.getSelection();
range = doc.createRange();
range.selectNodeContents(element);
selection.removeAllRanges();
selection.addRange(range);
}
}
+
+
+
+
+/** Display links and other information about samples that match the
+ group specified by the URL */
+function showSamples() {
+ var group = $("#samples").attr('class');
+ $("#samples").html("<p>Here are some samples for <b>" + group + "</b> apps:</p>");
+
+ var $ul = $("<ul>");
+ $selectedLi = $("#nav li.selected");
+
+ $selectedLi.children("ul").children("li").each(function() {
+ var $li = $("<li>").append($(this).find("a").first().clone());
+ $ul.append($li);
+ });
+
+ $("#samples").append($ul);
+
+}
diff --git a/tools/droiddoc/templates-sdk/sample.cs b/tools/droiddoc/templates-sdk/sample.cs
index a8eaf8c..3fed799 100644
--- a/tools/droiddoc/templates-sdk/sample.cs
+++ b/tools/droiddoc/templates-sdk/sample.cs
@@ -19,11 +19,9 @@
| <a href="<?cs var:toroot ?>samples/<?cs var:projectDir ?>/project.html">Project</a>
| <a href="<?cs var:toroot ?>downloads/samples/<?cs var:projectDir ?>.zip">Download</a>
- </div><!-- end sum-details-links -->
- <div class="api-level">
- Other info
- </div>
-</div> <!-- end api-info-block -->
+</div><!-- end sum-details-links -->
+
+</div><!-- end breadcurmb block -->
<div id="jd-header" style="border:0;">
@@ -57,11 +55,6 @@
<pre id="codesample-block"><?cs var:fileContents ?></pre>
</div>
-<h3 id="file-location" style="clear:left">Source file location</h3>
-<p>The file containing the source code shown below is located in the corresponding directory in
-<code><sdk>/samples/android-<version>/...</code></p>
-
-
<!-- end file contents -->
<script type="text/javascript">
initCodeLineNumbers();
@@ -74,11 +67,6 @@
# else, this means it's offline docs,
so don't show src links (we dont have the pages!) ?>
-<p>You can find the source code for this sample in your SDK at:</p>
-<p style="margin-left:2em">
-<code><em><sdk></em>/samples/android-<em><version></em>/</code>
-</p>
-
<?cs /if ?><?cs # end if/else online docs ?>
</div> <!-- end jd-content -->
diff --git a/tools/droiddoc/templates-sdk/sampleindex.cs b/tools/droiddoc/templates-sdk/sampleindex.cs
index 077b3d5..8db15c4 100644
--- a/tools/droiddoc/templates-sdk/sampleindex.cs
+++ b/tools/droiddoc/templates-sdk/sampleindex.cs
@@ -23,9 +23,7 @@
| <a href="<?cs var:toroot ?>downloads/samples/<?cs var:projectDir ?>.zip">Download</a>
</div><!-- end sum-details-links -->
-<div class="api-level">
- Other info
-</div>
+
</div><!-- end breadcurmb block -->
<h1 itemprop="name"><?cs var:projectDir ?></h1>
@@ -79,11 +77,6 @@
# else, this means it's offline docs,
so don't show src links (we dont have the pages!) ?>
-<p>You can find the source code for this sample in your SDK at:</p>
-<p style="margin-left:2em">
-<code><em><sdk></em>/samples/android-<em><version></em>/</code>
-</p>
-
<?cs /if ?><?cs # end if/else online docs ?>
</div> <!-- end jd-content -->
diff --git a/tools/releasetools/check_target_files_signatures b/tools/releasetools/check_target_files_signatures
index 45d30a6..ae372ba 100755
--- a/tools/releasetools/check_target_files_signatures
+++ b/tools/releasetools/check_target_files_signatures
@@ -135,7 +135,7 @@
for i in to_load:
f = open(i)
- cert = common.ParseCertificate(f.read())
+ cert = ParseCertificate(f.read())
f.close()
name, _ = os.path.splitext(i)
name, _ = os.path.splitext(name)
@@ -144,6 +144,21 @@
ALL_CERTS = CertDB()
+def ParseCertificate(data):
+ """Parse a PEM-format certificate."""
+ cert = []
+ save = False
+ for line in data.split("\n"):
+ if "--END CERTIFICATE--" in line:
+ break
+ if save:
+ cert.append(line)
+ if "--BEGIN CERTIFICATE--" in line:
+ save = True
+ cert = "".join(cert).decode('base64')
+ return cert
+
+
def CertFromPKCS7(data, filename):
"""Read the cert out of a PKCS#7-format file (which is what is
stored in a signed .apk)."""
@@ -160,7 +175,7 @@
AddProblem("error reading cert:\n" + err)
return None
- cert = common.ParseCertificate(out)
+ cert = ParseCertificate(out)
if not cert:
AddProblem("error parsing cert output")
return None
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py
index f179717..95d01e0 100644
--- a/tools/releasetools/common.py
+++ b/tools/releasetools/common.py
@@ -957,18 +957,3 @@
return PARTITION_TYPES[fstab[mount_point].fs_type], fstab[mount_point].device
else:
return None
-
-
-def ParseCertificate(data):
- """Parse a PEM-format certificate."""
- cert = []
- save = False
- for line in data.split("\n"):
- if "--END CERTIFICATE--" in line:
- break
- if save:
- cert.append(line)
- if "--BEGIN CERTIFICATE--" in line:
- save = True
- cert = "".join(cert).decode('base64')
- return cert
diff --git a/tools/releasetools/sign_target_files_apks b/tools/releasetools/sign_target_files_apks
index 6ed21de..120c955 100755
--- a/tools/releasetools/sign_target_files_apks
+++ b/tools/releasetools/sign_target_files_apks
@@ -71,10 +71,8 @@
print >> sys.stderr, "Python 2.4 or newer is required."
sys.exit(1)
-import base64
import cStringIO
import copy
-import errno
import os
import re
import subprocess
@@ -163,45 +161,11 @@
print "rewriting %s:" % (info.filename,)
new_data = RewriteProps(data)
output_tf_zip.writestr(out_info, new_data)
- elif info.filename.endswith("mac_permissions.xml"):
- print "rewriting %s with new keys." % (info.filename,)
- new_data = ReplaceCerts(data)
- output_tf_zip.writestr(out_info, new_data)
else:
# a non-APK file; copy it verbatim
output_tf_zip.writestr(out_info, data)
-def ReplaceCerts(data):
- """Given a string of data, replace all occurences of a set
- of X509 certs with a newer set of X509 certs and return
- the updated data string."""
- for old, new in OPTIONS.key_map.iteritems():
- try:
- if OPTIONS.verbose:
- print " Replacing %s.x509.pem with %s.x509.pem" % (old, new)
- f = open(old + ".x509.pem")
- old_cert16 = base64.b16encode(common.ParseCertificate(f.read())).lower()
- f.close()
- f = open(new + ".x509.pem")
- new_cert16 = base64.b16encode(common.ParseCertificate(f.read())).lower()
- f.close()
- # Only match entire certs.
- pattern = "\\b"+old_cert16+"\\b"
- (data, num) = re.subn(pattern, new_cert16, data, flags=re.IGNORECASE)
- if OPTIONS.verbose:
- print " Replaced %d occurence(s) of %s.x509.pem with " \
- "%s.x509.pem" % (num, old, new)
- except IOError, e:
- if (e.errno == errno.ENOENT and not OPTIONS.verbose):
- continue
-
- print " Error accessing %s. %s. Skip replacing %s.x509.pem " \
- "with %s.x509.pem." % (e.filename, e.strerror, old, new)
-
- return data
-
-
def EditTags(tags):
"""Given a string containing comma-separated tags, apply the edits
specified in OPTIONS.tag_changes and return the updated string."""