Merge "Add additional languages to be accepted by the NumberPicker input filter"
diff --git a/api/current.txt b/api/current.txt
index 2bd9c05..a98fcfb 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -17651,6 +17651,7 @@
method public static void startMethodTracing(java.lang.String);
method public static void startMethodTracing(java.lang.String, int);
method public static void startMethodTracing(java.lang.String, int, int);
+ method public static void startMethodTracingSampling(java.lang.String, int, int);
method public static void startNativeTracing();
method public static deprecated void stopAllocCounting();
method public static void stopMethodTracing();
@@ -21793,7 +21794,7 @@
}
public class BaseObj {
- method public synchronized void destroy();
+ method public void destroy();
method public java.lang.String getName();
method public void setName(java.lang.String);
}
@@ -42719,11 +42720,11 @@
}
public class ConcurrentHashMap extends java.util.AbstractMap implements java.util.concurrent.ConcurrentMap java.io.Serializable {
- ctor public ConcurrentHashMap(int, float, int);
- ctor public ConcurrentHashMap(int, float);
- ctor public ConcurrentHashMap(int);
ctor public ConcurrentHashMap();
+ ctor public ConcurrentHashMap(int);
ctor public ConcurrentHashMap(java.util.Map<? extends K, ? extends V>);
+ ctor public ConcurrentHashMap(int, float);
+ ctor public ConcurrentHashMap(int, float, int);
method public boolean contains(java.lang.Object);
method public java.util.Enumeration<V> elements();
method public java.util.Set<java.util.Map.Entry<K, V>> entrySet();
@@ -44163,12 +44164,12 @@
public final class Matcher implements java.util.regex.MatchResult {
method public java.util.regex.Matcher appendReplacement(java.lang.StringBuffer, java.lang.String);
method public java.lang.StringBuffer appendTail(java.lang.StringBuffer);
- method public int end(int);
method public int end();
+ method public int end(int);
method public boolean find(int);
method public boolean find();
- method public java.lang.String group(int);
method public java.lang.String group();
+ method public java.lang.String group(int);
method public int groupCount();
method public boolean hasAnchoringBounds();
method public boolean hasTransparentBounds();
@@ -44185,8 +44186,8 @@
method public boolean requireEnd();
method public java.util.regex.Matcher reset();
method public java.util.regex.Matcher reset(java.lang.CharSequence);
- method public int start(int) throws java.lang.IllegalStateException;
method public int start();
+ method public int start(int) throws java.lang.IllegalStateException;
method public java.util.regex.MatchResult toMatchResult();
method public java.util.regex.Matcher useAnchoringBounds(boolean);
method public java.util.regex.Matcher usePattern(java.util.regex.Pattern);
@@ -50927,7 +50928,7 @@
method public java.lang.String getString(java.lang.String) throws org.json.JSONException;
method public boolean has(java.lang.String);
method public boolean isNull(java.lang.String);
- method public java.util.Iterator keys();
+ method public java.util.Iterator<java.lang.String> keys();
method public int length();
method public org.json.JSONArray names();
method public static java.lang.String numberToString(java.lang.Number) throws org.json.JSONException;
diff --git a/cmds/app_process/Android.mk b/cmds/app_process/Android.mk
index b9afe40..7c25354 100644
--- a/cmds/app_process/Android.mk
+++ b/cmds/app_process/Android.mk
@@ -1,4 +1,6 @@
LOCAL_PATH:= $(call my-dir)
+
+# 32-bit app_process
include $(CLEAR_VARS)
LOCAL_SRC_FILES:= \
@@ -12,10 +14,11 @@
libandroid_runtime
LOCAL_MODULE:= app_process
-
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := app_process
+LOCAL_MODULE_STEM_64 := app_process64
include $(BUILD_EXECUTABLE)
-
# Build a variant of app_process binary linked with ASan runtime.
# ARM-only at the moment.
ifeq ($(TARGET_ARCH),arm)
diff --git a/cmds/app_process/app_main.cpp b/cmds/app_process/app_main.cpp
index 8d2b739..c520b58 100644
--- a/cmds/app_process/app_main.cpp
+++ b/cmds/app_process/app_main.cpp
@@ -10,8 +10,9 @@
#include <binder/IPCThreadState.h>
#include <binder/ProcessState.h>
#include <utils/Log.h>
-#include <cutils/process_name.h>
#include <cutils/memory.h>
+#include <cutils/process_name.h>
+#include <cutils/properties.h>
#include <cutils/trace.h>
#include <android_runtime/AndroidRuntime.h>
@@ -30,31 +31,22 @@
class AppRuntime : public AndroidRuntime
{
public:
- AppRuntime()
- : mParentDir(NULL)
- , mClassName(NULL)
+ AppRuntime(char* argBlockStart, const size_t argBlockLength)
+ : AndroidRuntime(argBlockStart, argBlockLength)
, mClass(NULL)
- , mArgC(0)
- , mArgV(NULL)
{
}
-#if 0
- // this appears to be unused
- const char* getParentDir() const
- {
- return mParentDir;
- }
-#endif
-
- const char* getClassName() const
- {
- return mClassName;
+ void setClassNameAndArgs(const String8& className, int argc, char * const *argv) {
+ mClassName = className;
+ for (int i = 0; i < argc; ++i) {
+ mArgs.add(String8(argv[i]));
+ }
}
virtual void onVmCreated(JNIEnv* env)
{
- if (mClassName == NULL) {
+ if (mClassName.isEmpty()) {
return; // Zygote. Nothing to do here.
}
@@ -71,10 +63,10 @@
* executing boot class Java code and thereby deny ourselves access to
* non-boot classes.
*/
- char* slashClassName = toSlashClassName(mClassName);
+ char* slashClassName = toSlashClassName(mClassName.string());
mClass = env->FindClass(slashClassName);
if (mClass == NULL) {
- ALOGE("ERROR: could not find class '%s'\n", mClassName);
+ ALOGE("ERROR: could not find class '%s'\n", mClassName.string());
}
free(slashClassName);
@@ -88,7 +80,7 @@
proc->startThreadPool();
AndroidRuntime* ar = AndroidRuntime::getRuntime();
- ar->callMain(mClassName, mClass, mArgC, mArgV);
+ ar->callMain(mClassName, mClass, mArgs);
IPCThreadState::self()->stopProcess();
}
@@ -114,46 +106,72 @@
}
- const char* mParentDir;
- const char* mClassName;
+ String8 mClassName;
+ Vector<String8> mArgs;
jclass mClass;
- int mArgC;
- const char* const* mArgV;
};
}
using namespace android;
-/*
- * sets argv0 to as much of newArgv0 as will fit
- */
-static void setArgv0(const char *argv0, const char *newArgv0)
-{
- strlcpy(const_cast<char *>(argv0), newArgv0, strlen(argv0));
+static size_t computeArgBlockSize(int argc, char* const argv[]) {
+ // TODO: This assumes that all arguments are allocated in
+ // contiguous memory. There isn't any documented guarantee
+ // that this is the case, but this is how the kernel does it
+ // (see fs/exec.c).
+ //
+ // Also note that this is a constant for "normal" android apps.
+ // Since they're forked from zygote, the size of their command line
+ // is the size of the zygote command line.
+ //
+ // We change the process name of the process by over-writing
+ // the start of the argument block (argv[0]) with the new name of
+ // the process, so we'd mysteriously start getting truncated process
+ // names if the zygote command line decreases in size.
+ uintptr_t start = reinterpret_cast<uintptr_t>(argv[0]);
+ uintptr_t end = reinterpret_cast<uintptr_t>(argv[argc - 1]);
+ end += strlen(argv[argc - 1]);
+
+ return (end - start);
}
+#if defined(__LP64__)
+static const char ABI_LIST_PROPERTY[] = "ro.product.cpu.abilist64";
+static const char ZYGOTE_NICE_NAME[] = "zygote64";
+#else
+static const char ABI_LIST_PROPERTY[] = "ro.product.cpu.abilist32";
+static const char ZYGOTE_NICE_NAME[] = "zygote";
+#endif
+
int main(int argc, char* const argv[])
{
- // These are global variables in ProcessState.cpp
- mArgC = argc;
- mArgV = argv;
-
- mArgLen = 0;
- for (int i=0; i<argc; i++) {
- mArgLen += strlen(argv[i]) + 1;
- }
- mArgLen--;
-
- AppRuntime runtime;
- const char* argv0 = argv[0];
-
+ AppRuntime runtime(argv[0], computeArgBlockSize(argc, argv));
// Process command line arguments
// ignore argv[0]
argc--;
argv++;
- // Everything up to '--' or first non '-' arg goes to the vm
+ // Everything up to '--' or first non '-' arg goes to the vm.
+ //
+ // The first argument after the VM args is the "parent dir", which
+ // is currently unused.
+ //
+ // After the parent dir, we expect one or more the following internal
+ // arguments :
+ //
+ // --zygote : Start in zygote mode
+ // --start-system-server : Start the system server.
+ // --application : Start in application (stand alone, non zygote) mode.
+ // --nice-name : The nice name for this process.
+ //
+ // For non zygote starts, these arguments will be followed by
+ // the main class name. All remaining arguments are passed to
+ // the main method of this class.
+ //
+ // For zygote starts, all remaining arguments are passed to the zygote.
+ // main function.
+
int i = runtime.addVmArguments(argc, argv);
@@ -161,45 +179,71 @@
bool zygote = false;
bool startSystemServer = false;
bool application = false;
- const char* parentDir = NULL;
const char* niceName = NULL;
- const char* className = NULL;
+ String8 className;
+
+ ++i; // Skip unused "parent dir" argument.
while (i < argc) {
const char* arg = argv[i++];
- if (!parentDir) {
- parentDir = arg;
- } else if (strcmp(arg, "--zygote") == 0) {
+ if (strcmp(arg, "--zygote") == 0) {
zygote = true;
- niceName = "zygote";
+ niceName = ZYGOTE_NICE_NAME;
} else if (strcmp(arg, "--start-system-server") == 0) {
startSystemServer = true;
} else if (strcmp(arg, "--application") == 0) {
application = true;
} else if (strncmp(arg, "--nice-name=", 12) == 0) {
niceName = arg + 12;
+ } else if (strncmp(arg, "--", 2) != 0) {
+ className.setTo(arg);
+ break;
} else {
- className = arg;
+ --i;
break;
}
}
+ Vector<String8> args;
+ if (!className.isEmpty()) {
+ // We're not in zygote mode, the only argument we need to pass
+ // to RuntimeInit is the application argument.
+ //
+ // The Remainder of args get passed to startup class main(). Make
+ // copies of them before we overwrite them with the process name.
+ args.add(application ? String8("application") : String8("tool"));
+ runtime.setClassNameAndArgs(className, argc - i, argv + i);
+ } else {
+ if (startSystemServer) {
+ args.add(String8("start-system-server"));
+ }
+
+ char prop[PROP_VALUE_MAX];
+ if (property_get(ABI_LIST_PROPERTY, prop, NULL) == 0) {
+ LOG_ALWAYS_FATAL("app_process: Unable to deterimine ABI list from property %s.",
+ ABI_LIST_PROPERTY);
+ return 11;
+ }
+
+ String8 abiFlag("--abi-list=");
+ abiFlag.append(prop);
+ args.add(abiFlag);
+
+ // In zygote mode, pass all remaining arguments to the zygote
+ // main() method.
+ for (; i < argc; ++i) {
+ args.add(String8(argv[i]));
+ }
+ }
+
if (niceName && *niceName) {
- setArgv0(argv0, niceName);
+ runtime.setArgv0(niceName);
set_process_name(niceName);
}
- runtime.mParentDir = parentDir;
-
if (zygote) {
- runtime.start("com.android.internal.os.ZygoteInit",
- startSystemServer ? "start-system-server" : "");
+ runtime.start("com.android.internal.os.ZygoteInit", args);
} else if (className) {
- // Remainder of args get passed to startup class main()
- runtime.mClassName = className;
- runtime.mArgC = argc - i;
- runtime.mArgV = argv + i;
- runtime.start("com.android.internal.os.RuntimeInit",
- application ? "application" : "tool");
+ runtime.start("com.android.internal.os.RuntimeInit", args);
} else {
fprintf(stderr, "Error: no class name or --zygote supplied.\n");
app_usage();
diff --git a/cmds/bootanimation/Android.mk b/cmds/bootanimation/Android.mk
index d5ff84e..dd987e0 100644
--- a/cmds/bootanimation/Android.mk
+++ b/cmds/bootanimation/Android.mk
@@ -24,5 +24,8 @@
LOCAL_MODULE:= bootanimation
+ifdef TARGET_32_BIT_SURFACEFLINGER
+LOCAL_32_BIT_ONLY := true
+endif
include $(BUILD_EXECUTABLE)
diff --git a/cmds/idmap/Android.mk b/cmds/idmap/Android.mk
new file mode 100644
index 0000000..ffa83f2
--- /dev/null
+++ b/cmds/idmap/Android.mk
@@ -0,0 +1,28 @@
+# Copyright (C) 2012 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := idmap.cpp create.cpp scan.cpp inspect.cpp
+
+LOCAL_SHARED_LIBRARIES := liblog libutils libandroidfw
+
+LOCAL_MODULE := idmap
+
+LOCAL_C_INCLUDES := external/zlib
+
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_EXECUTABLE)
diff --git a/cmds/idmap/create.cpp b/cmds/idmap/create.cpp
new file mode 100644
index 0000000..ae35f7b
--- /dev/null
+++ b/cmds/idmap/create.cpp
@@ -0,0 +1,222 @@
+#include "idmap.h"
+
+#include <UniquePtr.h>
+#include <androidfw/AssetManager.h>
+#include <androidfw/ResourceTypes.h>
+#include <androidfw/ZipFileRO.h>
+#include <utils/String8.h>
+
+#include <fcntl.h>
+#include <sys/stat.h>
+
+using namespace android;
+
+namespace {
+ int get_zip_entry_crc(const char *zip_path, const char *entry_name, uint32_t *crc)
+ {
+ UniquePtr<ZipFileRO> zip(ZipFileRO::open(zip_path));
+ if (zip.get() == NULL) {
+ return -1;
+ }
+ ZipEntryRO entry = zip->findEntryByName(entry_name);
+ if (entry == NULL) {
+ return -1;
+ }
+ if (!zip->getEntryInfo(entry, NULL, NULL, NULL, NULL, NULL, (long*)crc)) {
+ return -1;
+ }
+ zip->releaseEntry(entry);
+ return 0;
+ }
+
+ int open_idmap(const char *path)
+ {
+ int fd = TEMP_FAILURE_RETRY(open(path, O_WRONLY | O_CREAT | O_TRUNC, 0644));
+ if (fd == -1) {
+ ALOGD("error: open %s: %s\n", path, strerror(errno));
+ goto fail;
+ }
+ if (fchmod(fd, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) < 0) {
+ ALOGD("error: fchmod %s: %s\n", path, strerror(errno));
+ goto fail;
+ }
+ if (TEMP_FAILURE_RETRY(flock(fd, LOCK_EX | LOCK_NB)) != 0) {
+ ALOGD("error: flock %s: %s\n", path, strerror(errno));
+ goto fail;
+ }
+
+ return fd;
+fail:
+ if (fd != -1) {
+ close(fd);
+ unlink(path);
+ }
+ return -1;
+ }
+
+ int write_idmap(int fd, const uint32_t *data, size_t size)
+ {
+ if (lseek(fd, SEEK_SET, 0) < 0) {
+ return -1;
+ }
+ size_t bytesLeft = size;
+ while (bytesLeft > 0) {
+ ssize_t w = TEMP_FAILURE_RETRY(write(fd, data + size - bytesLeft, bytesLeft));
+ if (w < 0) {
+ fprintf(stderr, "error: write: %s\n", strerror(errno));
+ return -1;
+ }
+ bytesLeft -= w;
+ }
+ return 0;
+ }
+
+ bool is_idmap_stale_fd(const char *target_apk_path, const char *overlay_apk_path, int idmap_fd)
+ {
+ static const size_t N = ResTable::IDMAP_HEADER_SIZE_BYTES;
+ struct stat st;
+ if (fstat(idmap_fd, &st) == -1) {
+ return true;
+ }
+ if (st.st_size < N) {
+ // file is empty or corrupt
+ return true;
+ }
+
+ char buf[N];
+ ssize_t bytesLeft = N;
+ if (lseek(idmap_fd, SEEK_SET, 0) < 0) {
+ return true;
+ }
+ for (;;) {
+ ssize_t r = TEMP_FAILURE_RETRY(read(idmap_fd, buf + N - bytesLeft, bytesLeft));
+ if (r < 0) {
+ return true;
+ }
+ bytesLeft -= r;
+ if (bytesLeft == 0) {
+ break;
+ }
+ if (r == 0) {
+ // "shouldn't happen"
+ return true;
+ }
+ }
+
+ uint32_t cached_target_crc, cached_overlay_crc;
+ String8 cached_target_path, cached_overlay_path;
+ if (!ResTable::getIdmapInfo(buf, N, &cached_target_crc, &cached_overlay_crc,
+ &cached_target_path, &cached_overlay_path)) {
+ return true;
+ }
+
+ if (cached_target_path != target_apk_path) {
+ return true;
+ }
+ if (cached_overlay_path != overlay_apk_path) {
+ return true;
+ }
+
+ uint32_t actual_target_crc, actual_overlay_crc;
+ if (get_zip_entry_crc(target_apk_path, AssetManager::RESOURCES_FILENAME,
+ &actual_target_crc) == -1) {
+ return true;
+ }
+ if (get_zip_entry_crc(overlay_apk_path, AssetManager::RESOURCES_FILENAME,
+ &actual_overlay_crc) == -1) {
+ return true;
+ }
+
+ return cached_target_crc != actual_target_crc || cached_overlay_crc != actual_overlay_crc;
+ }
+
+ bool is_idmap_stale_path(const char *target_apk_path, const char *overlay_apk_path,
+ const char *idmap_path)
+ {
+ struct stat st;
+ if (stat(idmap_path, &st) == -1) {
+ // non-existing idmap is always stale; on other errors, abort idmap generation
+ return errno == ENOENT;
+ }
+
+ int idmap_fd = TEMP_FAILURE_RETRY(open(idmap_path, O_RDONLY));
+ if (idmap_fd == -1) {
+ return false;
+ }
+ bool is_stale = is_idmap_stale_fd(target_apk_path, overlay_apk_path, idmap_fd);
+ close(idmap_fd);
+ return is_stale;
+ }
+
+ int create_idmap(const char *target_apk_path, const char *overlay_apk_path,
+ uint32_t **data, size_t *size)
+ {
+ uint32_t target_crc, overlay_crc;
+ if (get_zip_entry_crc(target_apk_path, AssetManager::RESOURCES_FILENAME,
+ &target_crc) == -1) {
+ return -1;
+ }
+ if (get_zip_entry_crc(overlay_apk_path, AssetManager::RESOURCES_FILENAME,
+ &overlay_crc) == -1) {
+ return -1;
+ }
+
+ AssetManager am;
+ bool b = am.createIdmap(target_apk_path, overlay_apk_path, target_crc, overlay_crc,
+ data, size);
+ return b ? 0 : -1;
+ }
+
+ int create_and_write_idmap(const char *target_apk_path, const char *overlay_apk_path,
+ int fd, bool check_if_stale)
+ {
+ if (check_if_stale) {
+ if (!is_idmap_stale_fd(target_apk_path, overlay_apk_path, fd)) {
+ // already up to date -- nothing to do
+ return 0;
+ }
+ }
+
+ uint32_t *data = NULL;
+ size_t size;
+
+ if (create_idmap(target_apk_path, overlay_apk_path, &data, &size) == -1) {
+ return -1;
+ }
+
+ if (write_idmap(fd, data, size) == -1) {
+ free(data);
+ return -1;
+ }
+
+ free(data);
+ return 0;
+ }
+}
+
+int idmap_create_path(const char *target_apk_path, const char *overlay_apk_path,
+ const char *idmap_path)
+{
+ if (!is_idmap_stale_path(target_apk_path, overlay_apk_path, idmap_path)) {
+ // already up to date -- nothing to do
+ return EXIT_SUCCESS;
+ }
+
+ int fd = open_idmap(idmap_path);
+ if (fd == -1) {
+ return EXIT_FAILURE;
+ }
+
+ int r = create_and_write_idmap(target_apk_path, overlay_apk_path, fd, false);
+ close(fd);
+ if (r != 0) {
+ unlink(idmap_path);
+ }
+ return r == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
+}
+
+int idmap_create_fd(const char *target_apk_path, const char *overlay_apk_path, int fd)
+{
+ return create_and_write_idmap(target_apk_path, overlay_apk_path, fd, true) == 0 ?
+ EXIT_SUCCESS : EXIT_FAILURE;
+}
diff --git a/cmds/idmap/idmap.cpp b/cmds/idmap/idmap.cpp
new file mode 100644
index 0000000..46c0edc
--- /dev/null
+++ b/cmds/idmap/idmap.cpp
@@ -0,0 +1,237 @@
+#include "idmap.h"
+
+#include <private/android_filesystem_config.h> // for AID_SYSTEM
+
+#include <stdlib.h>
+#include <string.h>
+
+namespace {
+ const char *usage = "NAME\n\
+ idmap - create or display idmap files\n\
+\n\
+SYNOPSIS \n\
+ idmap --help \n\
+ idmap --fd target overlay fd \n\
+ idmap --path target overlay idmap \n\
+ idmap --scan dir-to-scan target-to-look-for target dir-to-hold-idmaps \n\
+ idmap --inspect idmap \n\
+\n\
+DESCRIPTION \n\
+ Idmap files play an integral part in the runtime resource overlay framework. An idmap \n\
+ file contains a mapping of resource identifiers between overlay package and its target \n\
+ package; this mapping is used during resource lookup. Idmap files also act as control \n\
+ files by their existence: if not present, the corresponding overlay package is ignored \n\
+ when the resource context is created. \n\
+\n\
+ Idmap files are stored in /data/resource-cache. For each pair (target package, overlay \n\
+ package), there exists exactly one idmap file, or none if the overlay should not be used. \n\
+\n\
+NOMENCLATURE \n\
+ target: the original, non-overlay, package. Each target package may be associated with \n\
+ any number of overlay packages. \n\
+\n\
+ overlay: an overlay package. Each overlay package is associated with exactly one target \n\
+ package, specified in the overlay's manifest using the <overlay target=\"...\"/> \n\
+ tag. \n\
+\n\
+OPTIONS \n\
+ --help: display this help \n\
+\n\
+ --fd: create idmap for target package 'target' (path to apk) and overlay package 'overlay' \n\
+ (path to apk); write results to file descriptor 'fd' (integer). This invocation \n\
+ version is intended to be used by a parent process with higher privileges to call \n\
+ idmap in a controlled way: the parent will open a suitable file descriptor, fork, \n\
+ drop its privileges and exec. This tool will continue execution without the extra \n\
+ privileges, but still have write access to a file it could not have opened on its \n\
+ own. \n\
+\n\
+ --path: create idmap for target package 'target' (path to apk) and overlay package \n\
+ 'overlay' (path to apk); write results to 'idmap' (path). \n\
+\n\
+ --scan: non-recursively search directory 'dir-to-scan' (path) for overlay packages with \n\
+ target package 'target-to-look-for' (package name) present at 'target' (path to \n\
+ apk). For each overlay package found, create an idmap file in 'dir-to-hold-idmaps' \n\
+ (path). \n\
+\n\
+ --inspect: decode the binary format of 'idmap' (path) and display the contents in a \n\
+ debug-friendly format. \n\
+\n\
+EXAMPLES \n\
+ Create an idmap file: \n\
+\n\
+ $ adb shell idmap --path /system/app/target.apk \\ \n\
+ /vendor/overlay/overlay.apk \\ \n\
+ /data/resource-cache/vendor@overlay@overlay.apk@idmap \n\
+\n\
+ Display an idmap file: \n\
+\n\
+ $ adb shell idmap --inspect /data/resource-cache/vendor@overlay@overlay.apk@idmap \n\
+ SECTION ENTRY VALUE OFFSET COMMENT \n\
+ IDMAP HEADER magic 0x706d6469 0x0 \n\
+ base crc 0x484aa77f 0x1 \n\
+ overlay crc 0x03c66fa5 0x2 \n\
+ base path .......... 0x03-0x42 /system/app/target.apk \n\
+ overlay path .......... 0x43-0x82 /vendor/overlay/overlay.apk \n\
+ DATA HEADER types count 0x00000003 0x83 \n\
+ padding 0x00000000 0x84 \n\
+ type offset 0x00000004 0x85 absolute offset 0x87, xml \n\
+ type offset 0x00000007 0x86 absolute offset 0x8a, string \n\
+ DATA BLOCK entry count 0x00000001 0x87 \n\
+ entry offset 0x00000000 0x88 \n\
+ entry 0x7f020000 0x89 xml/integer \n\
+ DATA BLOCK entry count 0x00000002 0x8a \n\
+ entry offset 0x00000000 0x8b \n\
+ entry 0x7f030000 0x8c string/str \n\
+ entry 0x7f030001 0x8d string/str2 \n\
+\n\
+ In this example, the overlay package provides three alternative resource values:\n\
+ xml/integer, string/str and string/str2.\n\
+\n\
+NOTES \n\
+ This tool and its expected invocation from installd is modelled on dexopt.";
+
+ bool verify_directory_readable(const char *path)
+ {
+ return access(path, R_OK | X_OK) == 0;
+ }
+
+ bool verify_directory_writable(const char *path)
+ {
+ return access(path, W_OK) == 0;
+ }
+
+ bool verify_file_readable(const char *path)
+ {
+ return access(path, R_OK) == 0;
+ }
+
+ bool verify_root_or_system()
+ {
+ uid_t uid = getuid();
+ gid_t gid = getgid();
+
+ return (uid == 0 && gid == 0) || (uid == AID_SYSTEM && gid == AID_SYSTEM);
+ }
+
+ int maybe_create_fd(const char *target_apk_path, const char *overlay_apk_path,
+ const char *idmap_str)
+ {
+ // anyone (not just root or system) may do --fd -- the file has
+ // already been opened by someone else on our behalf
+
+ char *endptr;
+ int idmap_fd = strtol(idmap_str, &endptr, 10);
+ if (*endptr != '\0') {
+ fprintf(stderr, "error: failed to parse file descriptor argument %s\n", idmap_str);
+ return -1;
+ }
+
+ if (!verify_file_readable(target_apk_path)) {
+ ALOGD("error: failed to read apk %s: %s\n", target_apk_path, strerror(errno));
+ return -1;
+ }
+
+ if (!verify_file_readable(overlay_apk_path)) {
+ ALOGD("error: failed to read apk %s: %s\n", overlay_apk_path, strerror(errno));
+ return -1;
+ }
+
+ return idmap_create_fd(target_apk_path, overlay_apk_path, idmap_fd);
+ }
+
+ int maybe_create_path(const char *target_apk_path, const char *overlay_apk_path,
+ const char *idmap_path)
+ {
+ if (!verify_root_or_system()) {
+ fprintf(stderr, "error: permission denied: not user root or user system\n");
+ return -1;
+ }
+
+ if (!verify_file_readable(target_apk_path)) {
+ ALOGD("error: failed to read apk %s: %s\n", target_apk_path, strerror(errno));
+ return -1;
+ }
+
+ if (!verify_file_readable(overlay_apk_path)) {
+ ALOGD("error: failed to read apk %s: %s\n", overlay_apk_path, strerror(errno));
+ return -1;
+ }
+
+ return idmap_create_path(target_apk_path, overlay_apk_path, idmap_path);
+ }
+
+ int maybe_scan(const char *overlay_dir, const char *target_package_name,
+ const char *target_apk_path, const char *idmap_dir)
+ {
+ if (!verify_root_or_system()) {
+ fprintf(stderr, "error: permission denied: not user root or user system\n");
+ return -1;
+ }
+
+ if (!verify_directory_readable(overlay_dir)) {
+ ALOGD("error: no read access to %s: %s\n", overlay_dir, strerror(errno));
+ return -1;
+ }
+
+ if (!verify_file_readable(target_apk_path)) {
+ ALOGD("error: failed to read apk %s: %s\n", target_apk_path, strerror(errno));
+ return -1;
+ }
+
+ if (!verify_directory_writable(idmap_dir)) {
+ ALOGD("error: no write access to %s: %s\n", idmap_dir, strerror(errno));
+ return -1;
+ }
+
+ return idmap_scan(overlay_dir, target_package_name, target_apk_path, idmap_dir);
+ }
+
+ int maybe_inspect(const char *idmap_path)
+ {
+ // anyone (not just root or system) may do --inspect
+ if (!verify_file_readable(idmap_path)) {
+ ALOGD("error: failed to read idmap %s: %s\n", idmap_path, strerror(errno));
+ return -1;
+ }
+ return idmap_inspect(idmap_path);
+ }
+}
+
+int main(int argc, char **argv)
+{
+#if 0
+ {
+ char buf[1024];
+ buf[0] = '\0';
+ for (int i = 0; i < argc; ++i) {
+ strncat(buf, argv[i], sizeof(buf) - 1);
+ strncat(buf, " ", sizeof(buf) - 1);
+ }
+ ALOGD("%s:%d: uid=%d gid=%d argv=%s\n", __FILE__, __LINE__, getuid(), getgid(), buf);
+ }
+#endif
+
+ if (argc == 2 && !strcmp(argv[1], "--help")) {
+ printf("%s\n", usage);
+ return 0;
+ }
+
+ if (argc == 5 && !strcmp(argv[1], "--fd")) {
+ return maybe_create_fd(argv[2], argv[3], argv[4]);
+ }
+
+ if (argc == 5 && !strcmp(argv[1], "--path")) {
+ return maybe_create_path(argv[2], argv[3], argv[4]);
+ }
+
+ if (argc == 6 && !strcmp(argv[1], "--scan")) {
+ return maybe_scan(argv[2], argv[3], argv[4], argv[5]);
+ }
+
+ if (argc == 3 && !strcmp(argv[1], "--inspect")) {
+ return maybe_inspect(argv[2]);
+ }
+
+ fprintf(stderr, "Usage: don't use this (cf dexopt usage).\n");
+ return EXIT_FAILURE;
+}
diff --git a/cmds/idmap/idmap.h b/cmds/idmap/idmap.h
new file mode 100644
index 0000000..f507dd8
--- /dev/null
+++ b/cmds/idmap/idmap.h
@@ -0,0 +1,34 @@
+#ifndef _IDMAP_H_
+#define _IDMAP_H_
+
+#define LOG_TAG "idmap"
+
+#include <utils/Log.h>
+
+#include <errno.h>
+#include <stdio.h>
+
+#ifndef TEMP_FAILURE_RETRY
+// Used to retry syscalls that can return EINTR.
+#define TEMP_FAILURE_RETRY(exp) ({ \
+ typeof (exp) _rc; \
+ do { \
+ _rc = (exp); \
+ } while (_rc == -1 && errno == EINTR); \
+ _rc; })
+#endif
+
+int idmap_create_path(const char *target_apk_path, const char *overlay_apk_path,
+ const char *idmap_path);
+
+int idmap_create_fd(const char *target_apk_path, const char *overlay_apk_path, int fd);
+
+// Regarding target_package_name: the idmap_scan implementation should
+// be able to extract this from the manifest in target_apk_path,
+// simplifying the external API.
+int idmap_scan(const char *overlay_dir, const char *target_package_name,
+ const char *target_apk_path, const char *idmap_dir);
+
+int idmap_inspect(const char *idmap_path);
+
+#endif // _IDMAP_H_
diff --git a/cmds/idmap/inspect.cpp b/cmds/idmap/inspect.cpp
new file mode 100644
index 0000000..a59f5d3
--- /dev/null
+++ b/cmds/idmap/inspect.cpp
@@ -0,0 +1,291 @@
+#include "idmap.h"
+
+#include <androidfw/AssetManager.h>
+#include <androidfw/ResourceTypes.h>
+#include <utils/String8.h>
+
+#include <fcntl.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+
+using namespace android;
+
+#define NEXT(b, i, o) do { if (buf.next(&i, &o) < 0) { return -1; } } while (0)
+
+namespace {
+ static const uint32_t IDMAP_MAGIC = 0x706d6469;
+ static const size_t PATH_LENGTH = 256;
+ static const uint32_t IDMAP_HEADER_SIZE = (3 + 2 * (PATH_LENGTH / sizeof(uint32_t)));
+
+ void printe(const char *fmt, ...);
+
+ class IdmapBuffer {
+ private:
+ char *buf_;
+ size_t len_;
+ mutable size_t pos_;
+ public:
+ IdmapBuffer() : buf_((char *)MAP_FAILED), len_(0), pos_(0) {}
+
+ ~IdmapBuffer() {
+ if (buf_ != MAP_FAILED) {
+ munmap(buf_, len_);
+ }
+ }
+
+ int init(const char *idmap_path)
+ {
+ struct stat st;
+ int fd;
+
+ if (stat(idmap_path, &st) < 0) {
+ printe("failed to stat idmap '%s': %s\n", idmap_path, strerror(errno));
+ return -1;
+ }
+ len_ = st.st_size;
+ if ((fd = TEMP_FAILURE_RETRY(open(idmap_path, O_RDONLY))) < 0) {
+ printe("failed to open idmap '%s': %s\n", idmap_path, strerror(errno));
+ return -1;
+ }
+ if ((buf_ = (char*)mmap(NULL, len_, PROT_READ, MAP_PRIVATE, fd, 0)) == MAP_FAILED) {
+ close(fd);
+ printe("failed to mmap idmap: %s\n", strerror(errno));
+ return -1;
+ }
+ close(fd);
+ return 0;
+ }
+
+ int next(uint32_t *i, uint32_t *offset) const
+ {
+ if (!buf_) {
+ printe("failed to read next uint32_t: buffer not initialized\n");
+ return -1;
+ }
+ if (pos_ + 4 > len_) {
+ printe("failed to read next uint32_t: end of buffer reached at pos=0x%08x\n",
+ pos_);
+ return -1;
+ }
+ *offset = pos_ / sizeof(uint32_t);
+ char a = buf_[pos_++];
+ char b = buf_[pos_++];
+ char c = buf_[pos_++];
+ char d = buf_[pos_++];
+ *i = (d << 24) | (c << 16) | (b << 8) | a;
+ return 0;
+ }
+
+ int nextPath(char *b, uint32_t *offset_start, uint32_t *offset_end) const
+ {
+ if (!buf_) {
+ printe("failed to read next path: buffer not initialized\n");
+ return -1;
+ }
+ if (pos_ + PATH_LENGTH > len_) {
+ printe("failed to read next path: end of buffer reached at pos=0x%08x\n", pos_);
+ return -1;
+ }
+ memcpy(b, buf_ + pos_, PATH_LENGTH);
+ *offset_start = pos_ / sizeof(uint32_t);
+ pos_ += PATH_LENGTH;
+ *offset_end = pos_ / sizeof(uint32_t) - 1;
+ return 0;
+ }
+ };
+
+ void printe(const char *fmt, ...)
+ {
+ va_list ap;
+
+ va_start(ap, fmt);
+ fprintf(stderr, "error: ");
+ vfprintf(stderr, fmt, ap);
+ va_end(ap);
+ }
+
+ void print_header()
+ {
+ printf("SECTION ENTRY VALUE OFFSET COMMENT\n");
+ }
+
+ void print(const char *section, const char *subsection, uint32_t value, uint32_t offset,
+ const char *fmt, ...)
+ {
+ va_list ap;
+
+ va_start(ap, fmt);
+ printf("%-12s %-12s 0x%08x 0x%-4x ", section, subsection, value, offset);
+ vprintf(fmt, ap);
+ printf("\n");
+ va_end(ap);
+ }
+
+ void print_path(const char *section, const char *subsection, uint32_t offset_start,
+ uint32_t offset_end, const char *fmt, ...)
+ {
+ va_list ap;
+
+ va_start(ap, fmt);
+ printf("%-12s %-12s .......... 0x%02x-0x%02x ", section, subsection, offset_start,
+ offset_end);
+ vprintf(fmt, ap);
+ printf("\n");
+ va_end(ap);
+ }
+
+ int resource_metadata(const AssetManager& am, uint32_t res_id,
+ String8 *package, String8 *type, String8 *name)
+ {
+ const ResTable& rt = am.getResources();
+ struct ResTable::resource_name data;
+ if (!rt.getResourceName(res_id, false, &data)) {
+ printe("failed to get resource name id=0x%08x\n", res_id);
+ return -1;
+ }
+ if (package) {
+ *package = String8(String16(data.package, data.packageLen));
+ }
+ if (type) {
+ *type = String8(String16(data.type, data.typeLen));
+ }
+ if (name) {
+ *name = String8(String16(data.name, data.nameLen));
+ }
+ return 0;
+ }
+
+ int package_id(const AssetManager& am)
+ {
+ return (am.getResources().getBasePackageId(0)) << 24;
+ }
+
+ int parse_idmap_header(const IdmapBuffer& buf, AssetManager& am)
+ {
+ uint32_t i, o, e;
+ char path[PATH_LENGTH];
+
+ NEXT(buf, i, o);
+ if (i != IDMAP_MAGIC) {
+ printe("not an idmap file: actual magic constant 0x%08x does not match expected magic "
+ "constant 0x%08x\n", i, IDMAP_MAGIC);
+ return -1;
+ }
+ print_header();
+ print("IDMAP HEADER", "magic", i, o, "");
+
+ NEXT(buf, i, o);
+ print("", "base crc", i, o, "");
+
+ NEXT(buf, i, o);
+ print("", "overlay crc", i, o, "");
+
+ if (buf.nextPath(path, &o, &e) < 0) {
+ // printe done from IdmapBuffer::nextPath
+ return -1;
+ }
+ print_path("", "base path", o, e, "%s", path);
+ if (!am.addAssetPath(String8(path), NULL)) {
+ printe("failed to add '%s' as asset path\n", path);
+ return -1;
+ }
+
+ if (buf.nextPath(path, &o, &e) < 0) {
+ // printe done from IdmapBuffer::nextPath
+ return -1;
+ }
+ print_path("", "overlay path", o, e, "%s", path);
+
+ return 0;
+ }
+
+ int parse_data_header(const IdmapBuffer& buf, const AssetManager& am, Vector<uint32_t>& types)
+ {
+ uint32_t i, o;
+ const uint32_t numeric_package = package_id(am);
+
+ NEXT(buf, i, o);
+ print("DATA HEADER", "types count", i, o, "");
+ const uint32_t N = i;
+
+ for (uint32_t j = 0; j < N; ++j) {
+ NEXT(buf, i, o);
+ if (i == 0) {
+ print("", "padding", i, o, "");
+ } else {
+ String8 type;
+ const uint32_t numeric_type = (j + 1) << 16;
+ const uint32_t res_id = numeric_package | numeric_type;
+ if (resource_metadata(am, res_id, NULL, &type, NULL) < 0) {
+ // printe done from resource_metadata
+ return -1;
+ }
+ print("", "type offset", i, o, "absolute offset 0x%02x, %s",
+ i + IDMAP_HEADER_SIZE, type.string());
+ types.add(numeric_type);
+ }
+ }
+
+ return 0;
+ }
+
+ int parse_data_block(const IdmapBuffer& buf, const AssetManager& am, size_t numeric_type)
+ {
+ uint32_t i, o, n, id_offset;
+ const uint32_t numeric_package = package_id(am);
+
+ NEXT(buf, i, o);
+ print("DATA BLOCK", "entry count", i, o, "");
+ n = i;
+
+ NEXT(buf, i, o);
+ print("", "entry offset", i, o, "");
+ id_offset = i;
+
+ for ( ; n > 0; --n) {
+ String8 type, name;
+
+ NEXT(buf, i, o);
+ if (i == 0) {
+ print("", "padding", i, o, "");
+ } else {
+ uint32_t res_id = numeric_package | numeric_type | id_offset;
+ if (resource_metadata(am, res_id, NULL, &type, &name) < 0) {
+ // printe done from resource_metadata
+ return -1;
+ }
+ print("", "entry", i, o, "%s/%s", type.string(), name.string());
+ }
+ ++id_offset;
+ }
+
+ return 0;
+ }
+}
+
+int idmap_inspect(const char *idmap_path)
+{
+ IdmapBuffer buf;
+ if (buf.init(idmap_path) < 0) {
+ // printe done from IdmapBuffer::init
+ return EXIT_FAILURE;
+ }
+ AssetManager am;
+ if (parse_idmap_header(buf, am) < 0) {
+ // printe done from parse_idmap_header
+ return EXIT_FAILURE;
+ }
+ Vector<uint32_t> types;
+ if (parse_data_header(buf, am, types) < 0) {
+ // printe done from parse_data_header
+ return EXIT_FAILURE;
+ }
+ const size_t N = types.size();
+ for (size_t i = 0; i < N; ++i) {
+ if (parse_data_block(buf, am, types.itemAt(i)) < 0) {
+ // printe done from parse_data_block
+ return EXIT_FAILURE;
+ }
+ }
+ return EXIT_SUCCESS;
+}
diff --git a/cmds/idmap/scan.cpp b/cmds/idmap/scan.cpp
new file mode 100644
index 0000000..c5fc941
--- /dev/null
+++ b/cmds/idmap/scan.cpp
@@ -0,0 +1,244 @@
+#include "idmap.h"
+
+#include <UniquePtr.h>
+#include <androidfw/ResourceTypes.h>
+#include <androidfw/StreamingZipInflater.h>
+#include <androidfw/ZipFileRO.h>
+#include <private/android_filesystem_config.h> // for AID_SYSTEM
+#include <utils/SortedVector.h>
+#include <utils/String16.h>
+#include <utils/String8.h>
+
+#include <dirent.h>
+
+#define NO_OVERLAY_TAG (-1000)
+
+using namespace android;
+
+namespace {
+ struct Overlay {
+ Overlay() {}
+ Overlay(const String8& a, const String8& i, int p) :
+ apk_path(a), idmap_path(i), priority(p) {}
+
+ bool operator<(Overlay const& rhs) const
+ {
+ // Note: order is reversed by design
+ return rhs.priority < priority;
+ }
+
+ String8 apk_path;
+ String8 idmap_path;
+ int priority;
+ };
+
+ bool writePackagesList(const char *filename, const SortedVector<Overlay>& overlayVector)
+ {
+ FILE* fout = fopen(filename, "w");
+ if (fout == NULL) {
+ return false;
+ }
+
+ for (size_t i = 0; i < overlayVector.size(); ++i) {
+ const Overlay& overlay = overlayVector[i];
+ fprintf(fout, "%s %s\n", overlay.apk_path.string(), overlay.idmap_path.string());
+ }
+
+ fclose(fout);
+
+ // Make file world readable since Zygote (running as root) will read
+ // it when creating the initial AssetManger object
+ const mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH; // 0644
+ if (chmod(filename, mode) == -1) {
+ unlink(filename);
+ return false;
+ }
+
+ return true;
+ }
+
+ String8 flatten_path(const char *path)
+ {
+ String16 tmp(path);
+ tmp.replaceAll('/', '@');
+ return String8(tmp);
+ }
+
+ int mkdir_p(const String8& path, uid_t uid, gid_t gid)
+ {
+ static const mode_t mode =
+ S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IXOTH;
+ struct stat st;
+
+ if (stat(path.string(), &st) == 0) {
+ return 0;
+ }
+ if (mkdir_p(path.getPathDir(), uid, gid) < 0) {
+ return -1;
+ }
+ if (mkdir(path.string(), 0755) != 0) {
+ return -1;
+ }
+ if (chown(path.string(), uid, gid) == -1) {
+ return -1;
+ }
+ if (chmod(path.string(), mode) == -1) {
+ return -1;
+ }
+ return 0;
+ }
+
+ int parse_overlay_tag(const ResXMLTree& parser, const char *target_package_name)
+ {
+ const size_t N = parser.getAttributeCount();
+ String16 target;
+ int priority = -1;
+ for (size_t i = 0; i < N; ++i) {
+ size_t len;
+ String16 key(parser.getAttributeName(i, &len));
+ if (key == String16("targetPackage")) {
+ const uint16_t *p = parser.getAttributeStringValue(i, &len);
+ if (p) {
+ target = String16(p, len);
+ }
+ } else if (key == String16("priority")) {
+ Res_value v;
+ if (parser.getAttributeValue(i, &v) == sizeof(Res_value)) {
+ priority = v.data;
+ if (priority < 0 || priority > 9999) {
+ return -1;
+ }
+ }
+ }
+ }
+ if (target == String16(target_package_name)) {
+ return priority;
+ }
+ return NO_OVERLAY_TAG;
+ }
+
+ int parse_manifest(const void *data, size_t size, const char *target_package_name)
+ {
+ ResXMLTree parser(data, size);
+ if (parser.getError() != NO_ERROR) {
+ ALOGD("%s failed to init xml parser, error=0x%08x\n", __FUNCTION__, parser.getError());
+ return -1;
+ }
+
+ ResXMLParser::event_code_t type;
+ do {
+ type = parser.next();
+ if (type == ResXMLParser::START_TAG) {
+ size_t len;
+ String16 tag(parser.getElementName(&len));
+ if (tag == String16("overlay")) {
+ return parse_overlay_tag(parser, target_package_name);
+ }
+ }
+ } while (type != ResXMLParser::BAD_DOCUMENT && type != ResXMLParser::END_DOCUMENT);
+
+ return NO_OVERLAY_TAG;
+ }
+
+ int parse_apk(const char *path, const char *target_package_name)
+ {
+ UniquePtr<ZipFileRO> zip(ZipFileRO::open(path));
+ if (zip.get() == NULL) {
+ ALOGW("%s: failed to open zip %s\n", __FUNCTION__, path);
+ return -1;
+ }
+ ZipEntryRO entry;
+ if ((entry = zip->findEntryByName("AndroidManifest.xml")) == NULL) {
+ ALOGW("%s: failed to find entry AndroidManifest.xml\n", __FUNCTION__);
+ return -1;
+ }
+ size_t uncompLen = 0;
+ int method;
+ if (!zip->getEntryInfo(entry, &method, &uncompLen, NULL, NULL, NULL, NULL)) {
+ ALOGW("%s: failed to read entry info\n", __FUNCTION__);
+ return -1;
+ }
+ if (method != ZipFileRO::kCompressDeflated) {
+ ALOGW("%s: cannot handle zip compression method %d\n", __FUNCTION__, method);
+ return -1;
+ }
+ FileMap *dataMap = zip->createEntryFileMap(entry);
+ if (!dataMap) {
+ ALOGW("%s: failed to create FileMap\n", __FUNCTION__);
+ return -1;
+ }
+ char *buf = new char[uncompLen];
+ if (NULL == buf) {
+ ALOGW("%s: failed to allocate %d byte\n", __FUNCTION__, uncompLen);
+ dataMap->release();
+ return -1;
+ }
+ StreamingZipInflater inflater(dataMap, uncompLen);
+ if (inflater.read(buf, uncompLen) < 0) {
+ ALOGW("%s: failed to inflate %d byte\n", __FUNCTION__, uncompLen);
+ delete[] buf;
+ dataMap->release();
+ return -1;
+ }
+
+ int priority = parse_manifest(buf, uncompLen, target_package_name);
+ delete[] buf;
+ dataMap->release();
+ return priority;
+ }
+}
+
+int idmap_scan(const char *overlay_dir, const char *target_package_name,
+ const char *target_apk_path, const char *idmap_dir)
+{
+ String8 filename = String8(idmap_dir);
+ filename.appendPath("overlays.list");
+ if (unlink(filename.string()) != 0 && errno != ENOENT) {
+ return EXIT_FAILURE;
+ }
+
+ DIR *dir = opendir(overlay_dir);
+ if (dir == NULL) {
+ return EXIT_FAILURE;
+ }
+
+ SortedVector<Overlay> overlayVector;
+ struct dirent *dirent;
+ while ((dirent = readdir(dir)) != NULL) {
+ struct stat st;
+ char overlay_apk_path[PATH_MAX + 1];
+ snprintf(overlay_apk_path, PATH_MAX, "%s/%s", overlay_dir, dirent->d_name);
+ if (stat(overlay_apk_path, &st) < 0) {
+ continue;
+ }
+ if (!S_ISREG(st.st_mode)) {
+ continue;
+ }
+
+ int priority = parse_apk(overlay_apk_path, target_package_name);
+ if (priority < 0) {
+ continue;
+ }
+
+ String8 idmap_path(idmap_dir);
+ idmap_path.appendPath(flatten_path(overlay_apk_path + 1));
+ idmap_path.append("@idmap");
+
+ if (idmap_create_path(target_apk_path, overlay_apk_path, idmap_path.string()) != 0) {
+ ALOGE("error: failed to create idmap for target=%s overlay=%s idmap=%s\n",
+ target_apk_path, overlay_apk_path, idmap_path.string());
+ continue;
+ }
+
+ Overlay overlay(String8(overlay_apk_path), idmap_path, priority);
+ overlayVector.add(overlay);
+ }
+
+ closedir(dir);
+
+ if (!writePackagesList(filename.string(), overlayVector)) {
+ return EXIT_FAILURE;
+ }
+
+ return EXIT_SUCCESS;
+}
diff --git a/core/java/android/animation/PropertyValuesHolder.java b/core/java/android/animation/PropertyValuesHolder.java
index 43014ad..21f6eda 100644
--- a/core/java/android/animation/PropertyValuesHolder.java
+++ b/core/java/android/animation/PropertyValuesHolder.java
@@ -743,9 +743,9 @@
static class IntPropertyValuesHolder extends PropertyValuesHolder {
// Cache JNI functions to avoid looking them up twice
- private static final HashMap<Class, HashMap<String, Integer>> sJNISetterPropertyMap =
- new HashMap<Class, HashMap<String, Integer>>();
- int mJniSetter;
+ private static final HashMap<Class, HashMap<String, Long>> sJNISetterPropertyMap =
+ new HashMap<Class, HashMap<String, Long>>();
+ long mJniSetter;
private IntProperty mIntProperty;
IntKeyframeSet mIntKeyframeSet;
@@ -845,11 +845,11 @@
// Check new static hashmap<propName, int> for setter method
try {
mPropertyMapLock.writeLock().lock();
- HashMap<String, Integer> propertyMap = sJNISetterPropertyMap.get(targetClass);
+ HashMap<String, Long> propertyMap = sJNISetterPropertyMap.get(targetClass);
if (propertyMap != null) {
- Integer mJniSetterInteger = propertyMap.get(mPropertyName);
- if (mJniSetterInteger != null) {
- mJniSetter = mJniSetterInteger;
+ Long jniSetter = propertyMap.get(mPropertyName);
+ if (jniSetter != null) {
+ mJniSetter = jniSetter;
}
}
if (mJniSetter == 0) {
@@ -857,7 +857,7 @@
mJniSetter = nGetIntMethod(targetClass, methodName);
if (mJniSetter != 0) {
if (propertyMap == null) {
- propertyMap = new HashMap<String, Integer>();
+ propertyMap = new HashMap<String, Long>();
sJNISetterPropertyMap.put(targetClass, propertyMap);
}
propertyMap.put(mPropertyName, mJniSetter);
@@ -880,9 +880,9 @@
static class FloatPropertyValuesHolder extends PropertyValuesHolder {
// Cache JNI functions to avoid looking them up twice
- private static final HashMap<Class, HashMap<String, Integer>> sJNISetterPropertyMap =
- new HashMap<Class, HashMap<String, Integer>>();
- int mJniSetter;
+ private static final HashMap<Class, HashMap<String, Long>> sJNISetterPropertyMap =
+ new HashMap<Class, HashMap<String, Long>>();
+ long mJniSetter;
private FloatProperty mFloatProperty;
FloatKeyframeSet mFloatKeyframeSet;
@@ -982,11 +982,11 @@
// Check new static hashmap<propName, int> for setter method
try {
mPropertyMapLock.writeLock().lock();
- HashMap<String, Integer> propertyMap = sJNISetterPropertyMap.get(targetClass);
+ HashMap<String, Long> propertyMap = sJNISetterPropertyMap.get(targetClass);
if (propertyMap != null) {
- Integer mJniSetterInteger = propertyMap.get(mPropertyName);
- if (mJniSetterInteger != null) {
- mJniSetter = mJniSetterInteger;
+ Long jniSetter = propertyMap.get(mPropertyName);
+ if (jniSetter != null) {
+ mJniSetter = jniSetter;
}
}
if (mJniSetter == 0) {
@@ -994,7 +994,7 @@
mJniSetter = nGetFloatMethod(targetClass, methodName);
if (mJniSetter != 0) {
if (propertyMap == null) {
- propertyMap = new HashMap<String, Integer>();
+ propertyMap = new HashMap<String, Long>();
sJNISetterPropertyMap.put(targetClass, propertyMap);
}
propertyMap.put(mPropertyName, mJniSetter);
@@ -1015,8 +1015,8 @@
}
- native static private int nGetIntMethod(Class targetClass, String methodName);
- native static private int nGetFloatMethod(Class targetClass, String methodName);
- native static private void nCallIntMethod(Object target, int methodID, int arg);
- native static private void nCallFloatMethod(Object target, int methodID, float arg);
-}
\ No newline at end of file
+ native static private long nGetIntMethod(Class targetClass, String methodName);
+ native static private long nGetFloatMethod(Class targetClass, String methodName);
+ native static private void nCallIntMethod(Object target, long methodID, int arg);
+ native static private void nCallFloatMethod(Object target, long methodID, float arg);
+}
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index d6db8c2..10ef535 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -816,7 +816,7 @@
}
/**
- * Return the LoaderManager for this fragment, creating it if needed.
+ * Return the LoaderManager for this activity, creating it if needed.
*/
public LoaderManager getLoaderManager() {
if (mLoaderManager != null) {
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index 97baf9a..b103e71 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -68,6 +68,7 @@
import android.os.SystemProperties;
import android.os.Trace;
import android.os.UserHandle;
+import android.provider.Settings;
import android.util.AndroidRuntimeException;
import android.util.ArrayMap;
import android.util.DisplayMetrics;
@@ -106,6 +107,7 @@
import java.lang.ref.WeakReference;
import java.net.InetAddress;
import java.security.Security;
+import java.text.DateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
@@ -742,8 +744,42 @@
setCoreSettings(coreSettings);
- // Tell the VMRuntime about the application.
- VMRuntime.registerAppInfo(appInfo.dataDir, appInfo.processName);
+ /*
+ * Two possible indications that this package could be
+ * sharing its runtime with other packages:
+ *
+ * 1.) the sharedUserId attribute is set in the manifest,
+ * indicating a request to share a VM with other
+ * packages with the same sharedUserId.
+ *
+ * 2.) the application element of the manifest has an
+ * attribute specifying a non-default process name,
+ * indicating the desire to run in another packages VM.
+ *
+ * If sharing is enabled we do not have a unique application
+ * in a process and therefore cannot rely on the package
+ * name inside the runtime.
+ */
+ IPackageManager pm = getPackageManager();
+ android.content.pm.PackageInfo pi = null;
+ try {
+ pi = pm.getPackageInfo(appInfo.packageName, 0, UserHandle.myUserId());
+ } catch (RemoteException e) {
+ }
+ if (pi != null) {
+ boolean sharedUserIdSet = (pi.sharedUserId != null);
+ boolean processNameNotDefault =
+ (pi.applicationInfo != null &&
+ !appInfo.packageName.equals(pi.applicationInfo.processName));
+ boolean sharable = (sharedUserIdSet || processNameNotDefault);
+
+ // Tell the VMRuntime about the application, unless it is shared
+ // inside a process.
+ if (!sharable) {
+ VMRuntime.registerAppInfo(appInfo.packageName, appInfo.dataDir,
+ appInfo.processName);
+ }
+ }
AppBindData data = new AppBindData();
data.processName = processName;
@@ -1095,6 +1131,11 @@
public void scheduleInstallProvider(ProviderInfo provider) {
sendMessage(H.INSTALL_PROVIDER, provider);
}
+
+ @Override
+ public final void updateTimePrefs(boolean is24Hour) {
+ DateFormat.set24HourTimePref(is24Hour);
+ }
}
private class H extends Handler {
@@ -1144,6 +1185,7 @@
public static final int REQUEST_ASSIST_CONTEXT_EXTRAS = 143;
public static final int TRANSLUCENT_CONVERSION_COMPLETE = 144;
public static final int INSTALL_PROVIDER = 145;
+
String codeToString(int code) {
if (DEBUG_MESSAGES) {
switch (code) {
@@ -1541,11 +1583,11 @@
/**
* Creates the top level resources for the given package.
*/
- Resources getTopLevelResources(String resDir,
+ Resources getTopLevelResources(String resDir, String[] overlayDirs,
int displayId, Configuration overrideConfiguration,
LoadedApk pkgInfo) {
- return mResourcesManager.getTopLevelResources(resDir, displayId, overrideConfiguration,
- pkgInfo.getCompatibilityInfo(), null);
+ return mResourcesManager.getTopLevelResources(resDir, overlayDirs, displayId,
+ overrideConfiguration, pkgInfo.getCompatibilityInfo(), null);
}
final Handler getHandler() {
@@ -4189,6 +4231,11 @@
Log.e(TAG, "Unable to setupGraphicsSupport due to missing cache directory");
}
}
+
+
+ final boolean is24Hr = "24".equals(mCoreSettings.getString(Settings.System.TIME_12_24));
+ DateFormat.set24HourTimePref(is24Hr);
+
/**
* For system applications on userdebug/eng builds, log stack
* traces of disk and network access to dropbox for analysis.
diff --git a/core/java/android/app/ApplicationPackageManager.java b/core/java/android/app/ApplicationPackageManager.java
index b505d4f..a280448 100644
--- a/core/java/android/app/ApplicationPackageManager.java
+++ b/core/java/android/app/ApplicationPackageManager.java
@@ -774,7 +774,7 @@
}
Resources r = mContext.mMainThread.getTopLevelResources(
app.uid == Process.myUid() ? app.sourceDir : app.publicSourceDir,
- Display.DEFAULT_DISPLAY, null, mContext.mPackageInfo);
+ app.resourceDirs, Display.DEFAULT_DISPLAY, null, mContext.mPackageInfo);
if (r != null) {
return r;
}
diff --git a/core/java/android/app/ApplicationThreadNative.java b/core/java/android/app/ApplicationThreadNative.java
index 347d43f..cb453e2 100644
--- a/core/java/android/app/ApplicationThreadNative.java
+++ b/core/java/android/app/ApplicationThreadNative.java
@@ -627,6 +627,15 @@
reply.writeNoException();
return true;
}
+
+ case UPDATE_TIME_PREFS_TRANSACTION:
+ {
+ data.enforceInterface(IApplicationThread.descriptor);
+ byte is24Hour = data.readByte();
+ updateTimePrefs(is24Hour == (byte) 1);
+ reply.writeNoException();
+ return true;
+ }
}
return super.onTransact(code, data, reply, flags);
@@ -1266,4 +1275,13 @@
mRemote.transact(SCHEDULE_INSTALL_PROVIDER_TRANSACTION, data, null, IBinder.FLAG_ONEWAY);
data.recycle();
}
+
+ @Override
+ public void updateTimePrefs(boolean is24Hour) throws RemoteException {
+ Parcel data = Parcel.obtain();
+ data.writeInterfaceToken(IApplicationThread.descriptor);
+ data.writeByte(is24Hour ? (byte) 1 : (byte) 0);
+ mRemote.transact(UPDATE_TIME_PREFS_TRANSACTION, data, null, IBinder.FLAG_ONEWAY);
+ data.recycle();
+ }
}
diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java
index 190ddb4..8d127c6 100644
--- a/core/java/android/app/ContextImpl.java
+++ b/core/java/android/app/ContextImpl.java
@@ -1911,8 +1911,8 @@
ContextImpl c = new ContextImpl();
c.init(mPackageInfo, null, mMainThread);
c.mResources = mResourcesManager.getTopLevelResources(mPackageInfo.getResDir(),
- getDisplayId(), overrideConfiguration, mResources.getCompatibilityInfo(),
- mActivityToken);
+ mPackageInfo.getOverlayDirs(), getDisplayId(), overrideConfiguration,
+ mResources.getCompatibilityInfo(), mActivityToken);
return c;
}
@@ -1929,7 +1929,7 @@
context.mDisplay = display;
DisplayAdjustments daj = getDisplayAdjustments(displayId);
context.mResources = mResourcesManager.getTopLevelResources(mPackageInfo.getResDir(),
- displayId, null, daj.getCompatibilityInfo(), null);
+ mPackageInfo.getOverlayDirs(), displayId, null, daj.getCompatibilityInfo(), null);
return context;
}
@@ -2041,7 +2041,8 @@
mDisplayAdjustments.setCompatibilityInfo(compatInfo);
mDisplayAdjustments.setActivityToken(activityToken);
mResources = mResourcesManager.getTopLevelResources(mPackageInfo.getResDir(),
- Display.DEFAULT_DISPLAY, null, compatInfo, activityToken);
+ mPackageInfo.getOverlayDirs(), Display.DEFAULT_DISPLAY, null, compatInfo,
+ activityToken);
} else {
mDisplayAdjustments.setCompatibilityInfo(packageInfo.getCompatibilityInfo());
mDisplayAdjustments.setActivityToken(activityToken);
diff --git a/core/java/android/app/IAlarmManager.aidl b/core/java/android/app/IAlarmManager.aidl
index 8476609..ef9f26e 100644
--- a/core/java/android/app/IAlarmManager.aidl
+++ b/core/java/android/app/IAlarmManager.aidl
@@ -28,7 +28,7 @@
/** windowLength == 0 means exact; windowLength < 0 means the let the OS decide */
void set(int type, long triggerAtTime, long windowLength,
long interval, in PendingIntent operation, in WorkSource workSource);
- void setTime(long millis);
+ boolean setTime(long millis);
void setTimeZone(String zone);
void remove(in PendingIntent operation);
}
diff --git a/core/java/android/app/IApplicationThread.java b/core/java/android/app/IApplicationThread.java
index d0cc1bb..3aceff9 100644
--- a/core/java/android/app/IApplicationThread.java
+++ b/core/java/android/app/IApplicationThread.java
@@ -138,6 +138,7 @@
throws RemoteException;
void setProcessState(int state) throws RemoteException;
void scheduleInstallProvider(ProviderInfo provider) throws RemoteException;
+ void updateTimePrefs(boolean is24Hour) throws RemoteException;
String descriptor = "android.app.IApplicationThread";
@@ -191,4 +192,5 @@
int SCHEDULE_TRANSLUCENT_CONVERSION_COMPLETE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+48;
int SET_PROCESS_STATE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+49;
int SCHEDULE_INSTALL_PROVIDER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+50;
+ int UPDATE_TIME_PREFS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+51;
}
diff --git a/core/java/android/app/LoadedApk.java b/core/java/android/app/LoadedApk.java
index 4239a5d..0115d1b 100644
--- a/core/java/android/app/LoadedApk.java
+++ b/core/java/android/app/LoadedApk.java
@@ -76,6 +76,7 @@
final String mPackageName;
private final String mAppDir;
private final String mResDir;
+ private final String[] mOverlayDirs;
private final String[] mSharedLibraries;
private final String mDataDir;
private final String mLibDir;
@@ -120,6 +121,7 @@
final int myUid = Process.myUid();
mResDir = aInfo.uid == myUid ? aInfo.sourceDir
: aInfo.publicSourceDir;
+ mOverlayDirs = aInfo.resourceDirs;
if (!UserHandle.isSameUser(aInfo.uid, myUid) && !Process.isIsolated()) {
aInfo.dataDir = PackageManager.getDataDirForUser(UserHandle.getUserId(myUid),
mPackageName);
@@ -159,6 +161,7 @@
mPackageName = name;
mAppDir = null;
mResDir = null;
+ mOverlayDirs = null;
mSharedLibraries = null;
mDataDir = null;
mDataDirFile = null;
@@ -471,6 +474,10 @@
return mResDir;
}
+ public String[] getOverlayDirs() {
+ return mOverlayDirs;
+ }
+
public String getDataDir() {
return mDataDir;
}
@@ -485,7 +492,7 @@
public Resources getResources(ActivityThread mainThread) {
if (mResources == null) {
- mResources = mainThread.getTopLevelResources(mResDir,
+ mResources = mainThread.getTopLevelResources(mResDir, mOverlayDirs,
Display.DEFAULT_DISPLAY, null, this);
}
return mResources;
diff --git a/core/java/android/app/ResourcesManager.java b/core/java/android/app/ResourcesManager.java
index f55dba4..728f372 100644
--- a/core/java/android/app/ResourcesManager.java
+++ b/core/java/android/app/ResourcesManager.java
@@ -147,7 +147,7 @@
* @param compatInfo the compability info. Must not be null.
* @param token the application token for determining stack bounds.
*/
- public Resources getTopLevelResources(String resDir, int displayId,
+ public Resources getTopLevelResources(String resDir, String[] overlayDirs, int displayId,
Configuration overrideConfiguration, CompatibilityInfo compatInfo, IBinder token) {
final float scale = compatInfo.applicationScale;
ResourcesKey key = new ResourcesKey(resDir, displayId, overrideConfiguration, scale,
@@ -180,6 +180,12 @@
return null;
}
+ if (overlayDirs != null) {
+ for (String idmapPath : overlayDirs) {
+ assets.addOverlayPath(idmapPath);
+ }
+ }
+
//Slog.i(TAG, "Resource: key=" + key + ", display metrics=" + metrics);
DisplayMetrics dm = getDisplayMetricsLocked(displayId);
Configuration config;
diff --git a/core/java/android/app/SharedPreferencesImpl.java b/core/java/android/app/SharedPreferencesImpl.java
index 86fd7b9..a292ecb 100644
--- a/core/java/android/app/SharedPreferencesImpl.java
+++ b/core/java/android/app/SharedPreferencesImpl.java
@@ -421,13 +421,15 @@
for (Map.Entry<String, Object> e : mModified.entrySet()) {
String k = e.getKey();
Object v = e.getValue();
- if (v == this) { // magic value for a removal mutation
+ // "this" is the magic value for a removal mutation. In addition,
+ // setting a value to "null" for a given key is specified to be
+ // equivalent to calling remove on that key.
+ if (v == this || v == null) {
if (!mMap.containsKey(k)) {
continue;
}
mMap.remove(k);
} else {
- boolean isSame = false;
if (mMap.containsKey(k)) {
Object existingValue = mMap.get(k);
if (existingValue != null && existingValue.equals(v)) {
diff --git a/core/java/android/content/ContentProvider.java b/core/java/android/content/ContentProvider.java
index ddde3fb..44831fc 100644
--- a/core/java/android/content/ContentProvider.java
+++ b/core/java/android/content/ContentProvider.java
@@ -987,7 +987,7 @@
* Implement this to handle requests to delete one or more rows.
* The implementation should apply the selection clause when performing
* deletion, allowing the operation to affect multiple rows in a directory.
- * As a courtesy, call {@link ContentResolver#notifyChange(android.net.Uri ,android.database.ContentObserver) notifyDelete()}
+ * As a courtesy, call {@link ContentResolver#notifyChange(android.net.Uri ,android.database.ContentObserver) notifyChange()}
* after deleting.
* This method can be called from multiple threads, as described in
* <a href="{@docRoot}guide/topics/fundamentals/processes-and-threads.html#Threads">Processes
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java
index a289649..2e2d4b8 100644
--- a/core/java/android/content/Intent.java
+++ b/core/java/android/content/Intent.java
@@ -3331,6 +3331,15 @@
public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
= "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
+ /**
+ * Optional boolean extra for {@link #ACTION_TIME_CHANGED} that indicates the
+ * user has set their time format preferences to the 24 hour format.
+ *
+ * @hide for internal use only.
+ */
+ public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
+ "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
+
// ---------------------------------------------------------------------
// ---------------------------------------------------------------------
// Intent flags (see mFlags variable).
diff --git a/core/java/android/content/Loader.java b/core/java/android/content/Loader.java
index 911e49c..a045b3a 100644
--- a/core/java/android/content/Loader.java
+++ b/core/java/android/content/Loader.java
@@ -24,7 +24,7 @@
import java.io.PrintWriter;
/**
- * An abstract class that performs asynchronous loading of data. While Loaders are active
+ * A class that performs asynchronous loading of data. While Loaders are active
* they should monitor the source of their data and deliver new results when the contents
* change. See {@link android.app.LoaderManager} for more detail.
*
diff --git a/core/java/android/content/pm/ApplicationInfo.java b/core/java/android/content/pm/ApplicationInfo.java
index 9c46d96..1a1610d 100644
--- a/core/java/android/content/pm/ApplicationInfo.java
+++ b/core/java/android/content/pm/ApplicationInfo.java
@@ -441,6 +441,15 @@
public String nativeLibraryDir;
/**
+ * The ABI that this application requires, This is inferred from the ABIs
+ * of the native JNI libraries the application bundles. Will be {@code null}
+ * if this application does not require any particular ABI.
+ *
+ * {@hide}
+ */
+ public String requiredCpuAbi;
+
+ /**
* The kernel user-ID that has been assigned to this application;
* currently this is not a unique ID (multiple applications can have
* the same uid).
@@ -570,6 +579,7 @@
sourceDir = orig.sourceDir;
publicSourceDir = orig.publicSourceDir;
nativeLibraryDir = orig.nativeLibraryDir;
+ requiredCpuAbi = orig.requiredCpuAbi;
resourceDirs = orig.resourceDirs;
seinfo = orig.seinfo;
sharedLibraryFiles = orig.sharedLibraryFiles;
@@ -610,6 +620,7 @@
dest.writeString(sourceDir);
dest.writeString(publicSourceDir);
dest.writeString(nativeLibraryDir);
+ dest.writeString(requiredCpuAbi);
dest.writeStringArray(resourceDirs);
dest.writeString(seinfo);
dest.writeStringArray(sharedLibraryFiles);
@@ -649,6 +660,7 @@
sourceDir = source.readString();
publicSourceDir = source.readString();
nativeLibraryDir = source.readString();
+ requiredCpuAbi = source.readString();
resourceDirs = source.readStringArray();
seinfo = source.readString();
sharedLibraryFiles = source.readStringArray();
diff --git a/core/java/android/content/pm/PackageInfo.java b/core/java/android/content/pm/PackageInfo.java
index af1a6d5..785f2b4 100644
--- a/core/java/android/content/pm/PackageInfo.java
+++ b/core/java/android/content/pm/PackageInfo.java
@@ -227,6 +227,14 @@
/** @hide */
public String requiredAccountType;
+ /**
+ * What package, if any, this package will overlay.
+ *
+ * Package name of target package, or null.
+ * @hide
+ */
+ public String overlayTarget;
+
public PackageInfo() {
}
@@ -270,6 +278,7 @@
dest.writeInt(requiredForAllUsers ? 1 : 0);
dest.writeString(restrictedAccountType);
dest.writeString(requiredAccountType);
+ dest.writeString(overlayTarget);
}
public static final Parcelable.Creator<PackageInfo> CREATOR
@@ -311,5 +320,6 @@
requiredForAllUsers = source.readInt() != 0;
restrictedAccountType = source.readString();
requiredAccountType = source.readString();
+ overlayTarget = source.readString();
}
}
diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java
index c97c2b8..8ce7e97 100644
--- a/core/java/android/content/pm/PackageManager.java
+++ b/core/java/android/content/pm/PackageManager.java
@@ -675,6 +675,25 @@
public static final int INSTALL_FAILED_USER_RESTRICTED = -111;
/**
+ * Installation failed return code: this is passed to the {@link IPackageInstallObserver} by
+ * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
+ * if the system failed to install the package because its packaged native code did not
+ * match any of the ABIs supported by the system.
+ *
+ * @hide
+ */
+ public static final int INSTALL_FAILED_NO_MATCHING_ABIS = -112;
+
+ /**
+ * Internal return code for NativeLibraryHelper methods to indicate that the package
+ * being processed did not contain any native code. This is placed here only so that
+ * it can belong to the same value space as the other install failure codes.
+ *
+ * @hide
+ */
+ public static final int NO_NATIVE_LIBRARIES = -113;
+
+ /**
* Flag parameter for {@link #deletePackage} to indicate that you don't want to delete the
* package's data directory.
*
diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java
index 4607902..52564eb 100644
--- a/core/java/android/content/pm/PackageParser.java
+++ b/core/java/android/content/pm/PackageParser.java
@@ -307,6 +307,7 @@
}
pi.restrictedAccountType = p.mRestrictedAccountType;
pi.requiredAccountType = p.mRequiredAccountType;
+ pi.overlayTarget = p.mOverlayTarget;
pi.firstInstallTime = firstInstallTime;
pi.lastUpdateTime = lastUpdateTime;
if ((flags&PackageManager.GET_GIDS) != 0) {
@@ -490,6 +491,11 @@
public Package parsePackage(File sourceFile, String destCodePath,
DisplayMetrics metrics, int flags) {
+ return parsePackage(sourceFile, destCodePath, metrics, flags, false);
+ }
+
+ public Package parsePackage(File sourceFile, String destCodePath,
+ DisplayMetrics metrics, int flags, boolean trustedOverlay) {
mParseError = PackageManager.INSTALL_SUCCEEDED;
mArchiveSourcePath = sourceFile.getPath();
@@ -542,7 +548,7 @@
Exception errorException = null;
try {
// XXXX todo: need to figure out correct configuration.
- pkg = parsePackage(res, parser, flags, errorText);
+ pkg = parsePackage(res, parser, flags, trustedOverlay, errorText);
} catch (Exception e) {
errorException = e;
mParseError = PackageManager.INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION;
@@ -951,8 +957,8 @@
}
private Package parsePackage(
- Resources res, XmlResourceParser parser, int flags, String[] outError)
- throws XmlPullParserException, IOException {
+ Resources res, XmlResourceParser parser, int flags, boolean trustedOverlay,
+ String[] outError) throws XmlPullParserException, IOException {
AttributeSet attrs = parser;
mParseInstrumentationArgs = null;
@@ -1051,6 +1057,31 @@
if (!parseApplication(pkg, res, parser, attrs, flags, outError)) {
return null;
}
+ } else if (tagName.equals("overlay")) {
+ pkg.mTrustedOverlay = trustedOverlay;
+
+ sa = res.obtainAttributes(attrs,
+ com.android.internal.R.styleable.AndroidManifestResourceOverlay);
+ pkg.mOverlayTarget = sa.getString(
+ com.android.internal.R.styleable.AndroidManifestResourceOverlay_targetPackage);
+ pkg.mOverlayPriority = sa.getInt(
+ com.android.internal.R.styleable.AndroidManifestResourceOverlay_priority,
+ -1);
+ sa.recycle();
+
+ if (pkg.mOverlayTarget == null) {
+ outError[0] = "<overlay> does not specify a target package";
+ mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
+ return null;
+ }
+ if (pkg.mOverlayPriority < 0 || pkg.mOverlayPriority > 9999) {
+ outError[0] = "<overlay> priority must be between 0 and 9999";
+ mParseError =
+ PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
+ return null;
+ }
+ XmlUtils.skipCurrentTag(parser);
+
} else if (tagName.equals("keys")) {
if (!parseKeys(pkg, res, parser, attrs, outError)) {
return null;
@@ -3546,6 +3577,10 @@
*/
public ManifestDigest manifestDigest;
+ public String mOverlayTarget;
+ public int mOverlayPriority;
+ public boolean mTrustedOverlay;
+
/**
* Data used to feed the KeySetManager
*/
diff --git a/core/java/android/content/res/AssetManager.java b/core/java/android/content/res/AssetManager.java
index fc9e486..9ce17e4 100644
--- a/core/java/android/content/res/AssetManager.java
+++ b/core/java/android/content/res/AssetManager.java
@@ -69,14 +69,13 @@
private final long[] mOffsets = new long[2];
// For communication with native code.
- private int mObject;
- private int mNObject; // used by the NDK
+ private long mObject;
private StringBlock mStringBlocks[] = null;
private int mNumRefs = 1;
private boolean mOpen = true;
- private HashMap<Integer, RuntimeException> mRefStacks;
+ private HashMap<Long, RuntimeException> mRefStacks;
/**
* Create a new AssetManager containing only the basic system assets.
@@ -91,7 +90,7 @@
mNumRefs = 0;
incRefsLocked(this.hashCode());
}
- init();
+ init(false);
if (localLOGV) Log.v(TAG, "New asset manager: " + this);
ensureSystemAssets();
}
@@ -114,7 +113,7 @@
incRefsLocked(this.hashCode());
}
}
- init();
+ init(true);
if (localLOGV) Log.v(TAG, "New asset manager: " + this);
}
@@ -225,7 +224,7 @@
return retArray;
}
- /*package*/ final boolean getThemeValue(int theme, int ident,
+ /*package*/ final boolean getThemeValue(long theme, int ident,
TypedValue outValue, boolean resolveRefs) {
int block = loadThemeAttributeValue(theme, ident, outValue, resolveRefs);
if (block >= 0) {
@@ -313,7 +312,7 @@
if (!mOpen) {
throw new RuntimeException("Assetmanager has been closed");
}
- int asset = openAsset(fileName, accessMode);
+ long asset = openAsset(fileName, accessMode);
if (asset != 0) {
AssetInputStream res = new AssetInputStream(asset);
incRefsLocked(res.hashCode());
@@ -405,7 +404,7 @@
if (!mOpen) {
throw new RuntimeException("Assetmanager has been closed");
}
- int asset = openNonAssetNative(cookie, fileName, accessMode);
+ long asset = openNonAssetNative(cookie, fileName, accessMode);
if (asset != 0) {
AssetInputStream res = new AssetInputStream(asset);
incRefsLocked(res.hashCode());
@@ -485,7 +484,7 @@
if (!mOpen) {
throw new RuntimeException("Assetmanager has been closed");
}
- int xmlBlock = openXmlAssetNative(cookie, fileName);
+ long xmlBlock = openXmlAssetNative(cookie, fileName);
if (xmlBlock != 0) {
XmlBlock res = new XmlBlock(this, xmlBlock);
incRefsLocked(res.hashCode());
@@ -501,18 +500,18 @@
}
}
- /*package*/ final int createTheme() {
+ /*package*/ final long createTheme() {
synchronized (this) {
if (!mOpen) {
throw new RuntimeException("Assetmanager has been closed");
}
- int res = newTheme();
+ long res = newTheme();
incRefsLocked(res);
return res;
}
}
- /*package*/ final void releaseTheme(int theme) {
+ /*package*/ final void releaseTheme(long theme) {
synchronized (this) {
deleteTheme(theme);
decRefsLocked(theme);
@@ -538,9 +537,15 @@
public final class AssetInputStream extends InputStream {
public final int getAssetInt() {
+ throw new UnsupportedOperationException();
+ }
+ /**
+ * @hide
+ */
+ public final long getNativeAsset() {
return mAsset;
}
- private AssetInputStream(int asset)
+ private AssetInputStream(long asset)
{
mAsset = asset;
mLength = getAssetLength(asset);
@@ -592,7 +597,7 @@
close();
}
- private int mAsset;
+ private long mAsset;
private long mLength;
private long mMarkPos;
}
@@ -610,6 +615,16 @@
private native final int addAssetPathNative(String path);
+ /**
+ * Add a set of assets to overlay an already added set of assets.
+ *
+ * This is only intended for application resources. System wide resources
+ * are handled before any Java code is executed.
+ *
+ * {@hide}
+ */
+ public native final int addOverlayPath(String idmapPath);
+
/**
* Add multiple sets of assets to the asset manager at once. See
* {@link #addAssetPath(String)} for more information. Returns array of
@@ -673,19 +688,19 @@
/*package*/ native final String getResourceTypeName(int resid);
/*package*/ native final String getResourceEntryName(int resid);
- private native final int openAsset(String fileName, int accessMode);
+ private native final long openAsset(String fileName, int accessMode);
private final native ParcelFileDescriptor openAssetFd(String fileName,
long[] outOffsets) throws IOException;
- private native final int openNonAssetNative(int cookie, String fileName,
+ private native final long openNonAssetNative(int cookie, String fileName,
int accessMode);
private native ParcelFileDescriptor openNonAssetFdNative(int cookie,
String fileName, long[] outOffsets) throws IOException;
- private native final void destroyAsset(int asset);
- private native final int readAssetChar(int asset);
- private native final int readAsset(int asset, byte[] b, int off, int len);
- private native final long seekAsset(int asset, long offset, int whence);
- private native final long getAssetLength(int asset);
- private native final long getAssetRemainingLength(int asset);
+ private native final void destroyAsset(long asset);
+ private native final int readAssetChar(long asset);
+ private native final int readAsset(long asset, byte[] b, int off, int len);
+ private native final long seekAsset(long asset, long offset, int whence);
+ private native final long getAssetLength(long asset);
+ private native final long getAssetRemainingLength(long asset);
/** Returns true if the resource was found, filling in mRetStringBlock and
* mRetData. */
@@ -702,15 +717,15 @@
/*package*/ static final int STYLE_RESOURCE_ID = 3;
/*package*/ static final int STYLE_CHANGING_CONFIGURATIONS = 4;
/*package*/ static final int STYLE_DENSITY = 5;
- /*package*/ native static final boolean applyStyle(int theme,
- int defStyleAttr, int defStyleRes, int xmlParser,
+ /*package*/ native static final boolean applyStyle(long theme,
+ int defStyleAttr, int defStyleRes, long xmlParser,
int[] inAttrs, int[] outValues, int[] outIndices);
/*package*/ native final boolean retrieveAttributes(
- int xmlParser, int[] inAttrs, int[] outValues, int[] outIndices);
+ long xmlParser, int[] inAttrs, int[] outValues, int[] outIndices);
/*package*/ native final int getArraySize(int resource);
/*package*/ native final int retrieveArray(int resource, int[] outValues);
private native final int getStringBlockCount();
- private native final int getNativeStringBlock(int block);
+ private native final long getNativeStringBlock(int block);
/**
* {@hide}
@@ -732,37 +747,37 @@
*/
public native static final int getGlobalAssetManagerCount();
- private native final int newTheme();
- private native final void deleteTheme(int theme);
- /*package*/ native static final void applyThemeStyle(int theme, int styleRes, boolean force);
- /*package*/ native static final void copyTheme(int dest, int source);
- /*package*/ native static final int loadThemeAttributeValue(int theme, int ident,
+ private native final long newTheme();
+ private native final void deleteTheme(long theme);
+ /*package*/ native static final void applyThemeStyle(long theme, int styleRes, boolean force);
+ /*package*/ native static final void copyTheme(long dest, long source);
+ /*package*/ native static final int loadThemeAttributeValue(long theme, int ident,
TypedValue outValue,
boolean resolve);
- /*package*/ native static final void dumpTheme(int theme, int priority, String tag, String prefix);
+ /*package*/ native static final void dumpTheme(long theme, int priority, String tag, String prefix);
- private native final int openXmlAssetNative(int cookie, String fileName);
+ private native final long openXmlAssetNative(int cookie, String fileName);
private native final String[] getArrayStringResource(int arrayRes);
private native final int[] getArrayStringInfo(int arrayRes);
/*package*/ native final int[] getArrayIntResource(int arrayRes);
- private native final void init();
+ private native final void init(boolean isSystem);
private native final void destroy();
- private final void incRefsLocked(int id) {
+ private final void incRefsLocked(long id) {
if (DEBUG_REFS) {
if (mRefStacks == null) {
- mRefStacks = new HashMap<Integer, RuntimeException>();
- RuntimeException ex = new RuntimeException();
- ex.fillInStackTrace();
- mRefStacks.put(this.hashCode(), ex);
+ mRefStacks = new HashMap<Long, RuntimeException>();
}
+ RuntimeException ex = new RuntimeException();
+ ex.fillInStackTrace();
+ mRefStacks.put(id, ex);
}
mNumRefs++;
}
- private final void decRefsLocked(int id) {
+ private final void decRefsLocked(long id) {
if (DEBUG_REFS && mRefStacks != null) {
mRefStacks.remove(id);
}
diff --git a/core/java/android/content/res/Resources.java b/core/java/android/content/res/Resources.java
index cd5b5d2f..3d9daca 100644
--- a/core/java/android/content/res/Resources.java
+++ b/core/java/android/content/res/Resources.java
@@ -1460,7 +1460,7 @@
}
private final AssetManager mAssets;
- private final int mTheme;
+ private final long mTheme;
}
/**
@@ -1569,10 +1569,7 @@
String locale = null;
if (mConfiguration.locale != null) {
- locale = mConfiguration.locale.getLanguage();
- if (mConfiguration.locale.getCountry() != null) {
- locale += "-" + mConfiguration.locale.getCountry();
- }
+ locale = mConfiguration.locale.toLanguageTag();
}
int width, height;
if (mMetrics.widthPixels >= mMetrics.heightPixels) {
diff --git a/core/java/android/content/res/StringBlock.java b/core/java/android/content/res/StringBlock.java
index 78180b1..77b8a33 100644
--- a/core/java/android/content/res/StringBlock.java
+++ b/core/java/android/content/res/StringBlock.java
@@ -36,7 +36,7 @@
private static final String TAG = "AssetManager";
private static final boolean localLOGV = false;
- private final int mNative;
+ private final long mNative;
private final boolean mUseSparse;
private final boolean mOwnsNative;
private CharSequence[] mStrings;
@@ -474,7 +474,7 @@
* are doing! The given native object must exist for the entire lifetime
* of this newly creating StringBlock.
*/
- StringBlock(int obj, boolean useSparse) {
+ StringBlock(long obj, boolean useSparse) {
mNative = obj;
mUseSparse = useSparse;
mOwnsNative = false;
@@ -482,11 +482,11 @@
+ ": " + nativeGetSize(mNative));
}
- private static native int nativeCreate(byte[] data,
+ private static native long nativeCreate(byte[] data,
int offset,
int size);
- private static native int nativeGetSize(int obj);
- private static native String nativeGetString(int obj, int idx);
- private static native int[] nativeGetStyle(int obj, int idx);
- private static native void nativeDestroy(int obj);
+ private static native int nativeGetSize(long obj);
+ private static native String nativeGetString(long obj, int idx);
+ private static native int[] nativeGetStyle(long obj, int idx);
+ private static native void nativeDestroy(long obj);
}
diff --git a/core/java/android/content/res/XmlBlock.java b/core/java/android/content/res/XmlBlock.java
index bea6529..3ad357f2 100644
--- a/core/java/android/content/res/XmlBlock.java
+++ b/core/java/android/content/res/XmlBlock.java
@@ -75,7 +75,7 @@
}
/*package*/ final class Parser implements XmlResourceParser {
- Parser(int parseState, XmlBlock block) {
+ Parser(long parseState, XmlBlock block) {
mParseState = parseState;
mBlock = block;
block.mOpenCount++;
@@ -458,7 +458,7 @@
return mStrings.get(id);
}
- /*package*/ int mParseState;
+ /*package*/ long mParseState;
private final XmlBlock mBlock;
private boolean mStarted = false;
private boolean mDecNextDepth = false;
@@ -476,41 +476,41 @@
* are doing! The given native object must exist for the entire lifetime
* of this newly creating XmlBlock.
*/
- XmlBlock(AssetManager assets, int xmlBlock) {
+ XmlBlock(AssetManager assets, long xmlBlock) {
mAssets = assets;
mNative = xmlBlock;
mStrings = new StringBlock(nativeGetStringBlock(xmlBlock), false);
}
private final AssetManager mAssets;
- private final int mNative;
+ private final long mNative;
/*package*/ final StringBlock mStrings;
private boolean mOpen = true;
private int mOpenCount = 1;
- private static final native int nativeCreate(byte[] data,
+ private static final native long nativeCreate(byte[] data,
int offset,
int size);
- private static final native int nativeGetStringBlock(int obj);
+ private static final native long nativeGetStringBlock(long obj);
- private static final native int nativeCreateParseState(int obj);
- /*package*/ static final native int nativeNext(int state);
- private static final native int nativeGetNamespace(int state);
- /*package*/ static final native int nativeGetName(int state);
- private static final native int nativeGetText(int state);
- private static final native int nativeGetLineNumber(int state);
- private static final native int nativeGetAttributeCount(int state);
- private static final native int nativeGetAttributeNamespace(int state, int idx);
- private static final native int nativeGetAttributeName(int state, int idx);
- private static final native int nativeGetAttributeResource(int state, int idx);
- private static final native int nativeGetAttributeDataType(int state, int idx);
- private static final native int nativeGetAttributeData(int state, int idx);
- private static final native int nativeGetAttributeStringValue(int state, int idx);
- private static final native int nativeGetIdAttribute(int state);
- private static final native int nativeGetClassAttribute(int state);
- private static final native int nativeGetStyleAttribute(int state);
- private static final native int nativeGetAttributeIndex(int state, String namespace, String name);
- private static final native void nativeDestroyParseState(int state);
+ private static final native long nativeCreateParseState(long obj);
+ /*package*/ static final native int nativeNext(long state);
+ private static final native int nativeGetNamespace(long state);
+ /*package*/ static final native int nativeGetName(long state);
+ private static final native int nativeGetText(long state);
+ private static final native int nativeGetLineNumber(long state);
+ private static final native int nativeGetAttributeCount(long state);
+ private static final native int nativeGetAttributeNamespace(long state, int idx);
+ private static final native int nativeGetAttributeName(long state, int idx);
+ private static final native int nativeGetAttributeResource(long state, int idx);
+ private static final native int nativeGetAttributeDataType(long state, int idx);
+ private static final native int nativeGetAttributeData(long state, int idx);
+ private static final native int nativeGetAttributeStringValue(long state, int idx);
+ private static final native int nativeGetIdAttribute(long state);
+ private static final native int nativeGetClassAttribute(long state);
+ private static final native int nativeGetStyleAttribute(long state);
+ private static final native int nativeGetAttributeIndex(long state, String namespace, String name);
+ private static final native void nativeDestroyParseState(long state);
- private static final native void nativeDestroy(int obj);
+ private static final native void nativeDestroy(long obj);
}
diff --git a/core/java/android/debug/JNITest.java b/core/java/android/debug/JNITest.java
deleted file mode 100644
index 2ce374a..0000000
--- a/core/java/android/debug/JNITest.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.debug;
-
-/**
- * Simple JNI verification test.
- */
-public class JNITest {
-
- public JNITest() {
- }
-
- public int test(int intArg, double doubleArg, String stringArg) {
- int[] intArray = { 42, 53, 65, 127 };
-
- return part1(intArg, doubleArg, stringArg, intArray);
- }
-
- private native int part1(int intArg, double doubleArg, String stringArg,
- int[] arrayArg);
-
- private int part2(double doubleArg, int fromArray, String stringArg) {
- int result;
-
- System.out.println(stringArg + " : " + (float) doubleArg + " : " +
- fromArray);
- result = part3(stringArg);
-
- return result + 6;
- }
-
- private static native int part3(String stringArg);
-}
-
diff --git a/core/java/android/emoji/EmojiFactory.java b/core/java/android/emoji/EmojiFactory.java
index 8fd8695..aba990d 100644
--- a/core/java/android/emoji/EmojiFactory.java
+++ b/core/java/android/emoji/EmojiFactory.java
@@ -54,7 +54,7 @@
}
// A pointer to native EmojiFactory object.
- private int mNativeEmojiFactory;
+ private long mNativeEmojiFactory;
private String mName;
// Cache.
private Map<Integer, WeakReference<Bitmap>> mCache;
@@ -68,7 +68,7 @@
*
* This can be called from JNI code.
*/
- private EmojiFactory(int nativeEmojiFactory, String name) {
+ private EmojiFactory(long nativeEmojiFactory, String name) {
mNativeEmojiFactory = nativeEmojiFactory;
mName = name;
mCache = new CustomLinkedHashMap<Integer, WeakReference<Bitmap>>();
@@ -272,18 +272,18 @@
// native methods
- private native void nativeDestructor(int factory);
- private native Bitmap nativeGetBitmapFromAndroidPua(int nativeEmojiFactory, int AndroidPua);
- private native int nativeGetAndroidPuaFromVendorSpecificSjis(int nativeEmojiFactory,
+ private native void nativeDestructor(long nativeEmojiFactory);
+ private native Bitmap nativeGetBitmapFromAndroidPua(long nativeEmojiFactory, int AndroidPua);
+ private native int nativeGetAndroidPuaFromVendorSpecificSjis(long nativeEmojiFactory,
char sjis);
- private native int nativeGetVendorSpecificSjisFromAndroidPua(int nativeEmojiFactory,
+ private native int nativeGetVendorSpecificSjisFromAndroidPua(long nativeEmojiFactory,
int pua);
- private native int nativeGetAndroidPuaFromVendorSpecificPua(int nativeEmojiFactory,
+ private native int nativeGetAndroidPuaFromVendorSpecificPua(long nativeEmojiFactory,
int vsp);
- private native int nativeGetVendorSpecificPuaFromAndroidPua(int nativeEmojiFactory,
+ private native int nativeGetVendorSpecificPuaFromAndroidPua(long nativeEmojiFactory,
int pua);
- private native int nativeGetMaximumVendorSpecificPua(int nativeEmojiFactory);
- private native int nativeGetMinimumVendorSpecificPua(int nativeEmojiFactory);
- private native int nativeGetMaximumAndroidPua(int nativeEmojiFactory);
- private native int nativeGetMinimumAndroidPua(int nativeEmojiFactory);
+ private native int nativeGetMaximumVendorSpecificPua(long nativeEmojiFactory);
+ private native int nativeGetMinimumVendorSpecificPua(long nativeEmojiFactory);
+ private native int nativeGetMaximumAndroidPua(long nativeEmojiFactory);
+ private native int nativeGetMinimumAndroidPua(long nativeEmojiFactory);
}
diff --git a/core/java/android/hardware/SensorManager.java b/core/java/android/hardware/SensorManager.java
index b931313..ac9189d 100644
--- a/core/java/android/hardware/SensorManager.java
+++ b/core/java/android/hardware/SensorManager.java
@@ -1359,7 +1359,7 @@
float q2 = rotationVector[1];
float q3 = rotationVector[2];
- if (rotationVector.length == 4) {
+ if (rotationVector.length >= 4) {
q0 = rotationVector[3];
} else {
q0 = 1 - q1*q1 - q2*q2 - q3*q3;
@@ -1416,7 +1416,7 @@
* @param Q an array of floats in which to store the computed quaternion
*/
public static void getQuaternionFromVector(float[] Q, float[] rv) {
- if (rv.length == 4) {
+ if (rv.length >= 4) {
Q[0] = rv[3];
} else {
Q[0] = 1 - rv[0]*rv[0] - rv[1]*rv[1] - rv[2]*rv[2];
diff --git a/core/java/android/net/LocalSocketImpl.java b/core/java/android/net/LocalSocketImpl.java
index b2ee50a..119e533 100644
--- a/core/java/android/net/LocalSocketImpl.java
+++ b/core/java/android/net/LocalSocketImpl.java
@@ -326,6 +326,7 @@
}
s.fd = accept(fd, s);
+ s.mFdCreatedInternally = true;
}
/**
@@ -536,4 +537,3 @@
close();
}
}
-
diff --git a/core/java/android/net/http/CertificateChainValidator.java b/core/java/android/net/http/CertificateChainValidator.java
index 3652a4c..d06355d 100644
--- a/core/java/android/net/http/CertificateChainValidator.java
+++ b/core/java/android/net/http/CertificateChainValidator.java
@@ -16,22 +16,28 @@
package android.net.http;
-import com.android.org.conscrypt.SSLParametersImpl;
-import com.android.org.conscrypt.TrustManagerImpl;
+import android.util.Slog;
import java.io.ByteArrayInputStream;
import java.io.IOException;
+import java.lang.reflect.Method;
import java.security.GeneralSecurityException;
-import java.security.KeyManagementException;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
import java.security.cert.Certificate;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
-import javax.net.ssl.DefaultHostnameVerifier;
+
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLHandshakeException;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSocket;
-import javax.net.ssl.X509TrustManager;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.TrustManagerFactory;
+import javax.net.ssl.X509ExtendedTrustManager;
/**
* Class responsible for all server certificate validation functionality
@@ -39,28 +45,54 @@
* {@hide}
*/
public class CertificateChainValidator {
+ private static final String TAG = "CertificateChainValidator";
- /**
- * The singleton instance of the certificate chain validator
- */
- private static final CertificateChainValidator sInstance
- = new CertificateChainValidator();
+ private static class NoPreloadHolder {
+ /**
+ * The singleton instance of the certificate chain validator.
+ */
+ private static final CertificateChainValidator sInstance = new CertificateChainValidator();
- private static final DefaultHostnameVerifier sVerifier
- = new DefaultHostnameVerifier();
+ /**
+ * The singleton instance of the hostname verifier.
+ */
+ private static final HostnameVerifier sVerifier = HttpsURLConnection
+ .getDefaultHostnameVerifier();
+ }
+
+ private X509ExtendedTrustManager mTrustManager;
/**
* @return The singleton instance of the certificates chain validator
*/
public static CertificateChainValidator getInstance() {
- return sInstance;
+ return NoPreloadHolder.sInstance;
}
/**
* Creates a new certificate chain validator. This is a private constructor.
* If you need a Certificate chain validator, call getInstance().
*/
- private CertificateChainValidator() {}
+ private CertificateChainValidator() {
+ try {
+ TrustManagerFactory tmf = TrustManagerFactory.getInstance("X.509");
+ tmf.init((KeyStore) null);
+ for (TrustManager tm : tmf.getTrustManagers()) {
+ if (tm instanceof X509ExtendedTrustManager) {
+ mTrustManager = (X509ExtendedTrustManager) tm;
+ }
+ }
+ } catch (NoSuchAlgorithmException e) {
+ throw new RuntimeException("X.509 TrustManagerFactory must be available", e);
+ } catch (KeyStoreException e) {
+ throw new RuntimeException("X.509 TrustManagerFactory cannot be initialized", e);
+ }
+
+ if (mTrustManager == null) {
+ throw new RuntimeException(
+ "None of the X.509 TrustManagers are X509ExtendedTrustManager");
+ }
+ }
/**
* Performs the handshake and server certificates validation
@@ -136,14 +168,31 @@
* Handles updates to credential storage.
*/
public static void handleTrustStorageUpdate() {
-
+ TrustManagerFactory tmf;
try {
- X509TrustManager x509TrustManager = SSLParametersImpl.getDefaultTrustManager();
- if( x509TrustManager instanceof TrustManagerImpl ) {
- TrustManagerImpl trustManager = (TrustManagerImpl) x509TrustManager;
- trustManager.handleTrustStorageUpdate();
+ tmf = TrustManagerFactory.getInstance("X.509");
+ tmf.init((KeyStore) null);
+ } catch (NoSuchAlgorithmException e) {
+ Slog.w(TAG, "Couldn't find default X.509 TrustManagerFactory");
+ return;
+ } catch (KeyStoreException e) {
+ Slog.w(TAG, "Couldn't initialize default X.509 TrustManagerFactory", e);
+ return;
+ }
+
+ TrustManager[] tms = tmf.getTrustManagers();
+ boolean sentUpdate = false;
+ for (TrustManager tm : tms) {
+ try {
+ Method updateMethod = tm.getClass().getDeclaredMethod("handleTrustStorageUpdate");
+ updateMethod.setAccessible(true);
+ updateMethod.invoke(tm);
+ sentUpdate = true;
+ } catch (Exception e) {
}
- } catch (KeyManagementException ignored) {
+ }
+ if (!sentUpdate) {
+ Slog.w(TAG, "Didn't find a TrustManager to handle CA list update");
}
}
@@ -166,7 +215,8 @@
boolean valid = domain != null
&& !domain.isEmpty()
- && sVerifier.verify(domain, currCertificate);
+ && NoPreloadHolder.sVerifier.verify(domain,
+ new DelegatingSSLSession.CertificateWrap(currCertificate));
if (!valid) {
if (HttpLog.LOGV) {
HttpLog.v("certificate not for this host: " + domain);
@@ -175,13 +225,8 @@
}
try {
- X509TrustManager x509TrustManager = SSLParametersImpl.getDefaultTrustManager();
- if (x509TrustManager instanceof TrustManagerImpl) {
- TrustManagerImpl trustManager = (TrustManagerImpl) x509TrustManager;
- trustManager.checkServerTrusted(chain, authType, domain);
- } else {
- x509TrustManager.checkServerTrusted(chain, authType);
- }
+ getInstance().getTrustManager().checkServerTrusted(chain, authType,
+ new DelegatingSocketWrapper(domain));
return null; // No errors.
} catch (GeneralSecurityException e) {
if (HttpLog.LOGV) {
@@ -192,6 +237,12 @@
}
}
+ /**
+ * Returns the platform default {@link X509ExtendedTrustManager}.
+ */
+ private X509ExtendedTrustManager getTrustManager() {
+ return mTrustManager;
+ }
private void closeSocketThrowException(
SSLSocket socket, String errorMessage, String defaultErrorMessage)
@@ -217,4 +268,4 @@
throw new SSLHandshakeException(errorMessage);
}
-}
+}
\ No newline at end of file
diff --git a/core/java/android/net/http/DelegatingSSLSession.java b/core/java/android/net/http/DelegatingSSLSession.java
new file mode 100644
index 0000000..ff75b24
--- /dev/null
+++ b/core/java/android/net/http/DelegatingSSLSession.java
@@ -0,0 +1,172 @@
+/*
+ * Copyright 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.net.http;
+
+import java.security.Principal;
+import java.security.cert.Certificate;
+import java.security.cert.X509Certificate;
+
+import javax.net.ssl.SSLPeerUnverifiedException;
+import javax.net.ssl.SSLSession;
+import javax.net.ssl.SSLSessionContext;
+import javax.net.ssl.SSLSocket;
+import javax.net.ssl.X509ExtendedTrustManager;
+
+/**
+ * This is used when only a {@code hostname} is available but usage of the new API
+ * {@link X509ExtendedTrustManager#checkServerTrusted(X509Certificate[], String, Socket)}
+ * requires a {@link SSLSocket}.
+ *
+ * @hide
+ */
+public class DelegatingSSLSession implements SSLSession {
+ protected DelegatingSSLSession() {
+ }
+
+ public static class HostnameWrap extends DelegatingSSLSession {
+ private final String mHostname;
+
+ public HostnameWrap(String hostname) {
+ mHostname = hostname;
+ }
+
+ @Override
+ public String getPeerHost() {
+ return mHostname;
+ }
+ }
+
+ public static class CertificateWrap extends DelegatingSSLSession {
+ private final Certificate mCertificate;
+
+ public CertificateWrap(Certificate certificate) {
+ mCertificate = certificate;
+ }
+
+ @Override
+ public Certificate[] getPeerCertificates() throws SSLPeerUnverifiedException {
+ return new Certificate[] { mCertificate };
+ }
+ }
+
+
+ @Override
+ public int getApplicationBufferSize() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public String getCipherSuite() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public long getCreationTime() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public byte[] getId() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public long getLastAccessedTime() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Certificate[] getLocalCertificates() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Principal getLocalPrincipal() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public int getPacketBufferSize() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public javax.security.cert.X509Certificate[] getPeerCertificateChain()
+ throws SSLPeerUnverifiedException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Certificate[] getPeerCertificates() throws SSLPeerUnverifiedException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public String getPeerHost() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public int getPeerPort() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Principal getPeerPrincipal() throws SSLPeerUnverifiedException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public String getProtocol() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public SSLSessionContext getSessionContext() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Object getValue(String name) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public String[] getValueNames() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void invalidate() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean isValid() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void putValue(String name, Object value) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void removeValue(String name) {
+ throw new UnsupportedOperationException();
+ }
+}
\ No newline at end of file
diff --git a/core/java/android/net/http/DelegatingSocketWrapper.java b/core/java/android/net/http/DelegatingSocketWrapper.java
new file mode 100644
index 0000000..230d017
--- /dev/null
+++ b/core/java/android/net/http/DelegatingSocketWrapper.java
@@ -0,0 +1,127 @@
+/*
+ * Copyright 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.net.http;
+
+import java.io.IOException;
+
+import javax.net.ssl.HandshakeCompletedListener;
+import javax.net.ssl.SSLSession;
+import javax.net.ssl.SSLSocket;
+import javax.net.ssl.X509ExtendedTrustManager;
+
+/**
+ * This is used when only a {@code hostname} is available for
+ * {@link X509ExtendedTrustManager#checkServerTrusted(java.security.cert.X509Certificate[], String, Socket)}
+ * but we want to use the new API that requires a {@link SSLSocket}.
+ */
+class DelegatingSocketWrapper extends SSLSocket {
+ private String hostname;
+
+ public DelegatingSocketWrapper(String hostname) {
+ this.hostname = hostname;
+ }
+
+ @Override
+ public String[] getSupportedCipherSuites() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public String[] getEnabledCipherSuites() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void setEnabledCipherSuites(String[] suites) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public String[] getSupportedProtocols() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public String[] getEnabledProtocols() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void setEnabledProtocols(String[] protocols) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public SSLSession getSession() {
+ return new DelegatingSSLSession.HostnameWrap(hostname);
+ }
+
+ @Override
+ public void addHandshakeCompletedListener(HandshakeCompletedListener listener) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void removeHandshakeCompletedListener(HandshakeCompletedListener listener) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void startHandshake() throws IOException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void setUseClientMode(boolean mode) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean getUseClientMode() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void setNeedClientAuth(boolean need) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void setWantClientAuth(boolean want) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean getNeedClientAuth() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean getWantClientAuth() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void setEnableSessionCreation(boolean flag) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean getEnableSessionCreation() {
+ throw new UnsupportedOperationException();
+ }
+}
\ No newline at end of file
diff --git a/core/java/android/net/http/X509TrustManagerExtensions.java b/core/java/android/net/http/X509TrustManagerExtensions.java
index cfe5f27..d730a7b 100644
--- a/core/java/android/net/http/X509TrustManagerExtensions.java
+++ b/core/java/android/net/http/X509TrustManagerExtensions.java
@@ -22,14 +22,25 @@
import java.security.cert.X509Certificate;
import java.util.List;
+import javax.net.ssl.SSLParameters;
+import javax.net.ssl.SSLSocket;
+import javax.net.ssl.X509ExtendedTrustManager;
import javax.net.ssl.X509TrustManager;
/**
* X509TrustManager wrapper exposing Android-added features.
- *
- * <p> The checkServerTrusted method allows callers to perform additional
- * verification of certificate chains after they have been successfully
- * verified by the platform.</p>
+ * <p>
+ * The checkServerTrusted method allows callers to perform additional
+ * verification of certificate chains after they have been successfully verified
+ * by the platform.
+ * </p>
+ * <p>
+ * If the returned certificate list is not needed, see also
+ * {@code X509ExtendedTrustManager#checkServerTrusted(X509Certificate[], String, java.net.Socket)}
+ * where an {@link SSLSocket} can be used to verify the given hostname during
+ * handshake using
+ * {@code SSLParameters#setEndpointIdentificationAlgorithm(String)}.
+ * </p>
*/
public class X509TrustManagerExtensions {
@@ -45,7 +56,8 @@
if (tm instanceof TrustManagerImpl) {
mDelegate = (TrustManagerImpl) tm;
} else {
- throw new IllegalArgumentException("tm is not a supported type of X509TrustManager");
+ throw new IllegalArgumentException("tm is an instance of " + tm.getClass().getName() +
+ " which is not a supported type of X509TrustManager");
}
}
@@ -61,6 +73,7 @@
*/
public List<X509Certificate> checkServerTrusted(X509Certificate[] chain, String authType,
String host) throws CertificateException {
- return mDelegate.checkServerTrusted(chain, authType, host);
+ return mDelegate.checkServerTrusted(chain, authType,
+ new DelegatingSSLSession.HostnameWrap(host));
}
}
diff --git a/core/java/android/net/nsd/NsdManager.java b/core/java/android/net/nsd/NsdManager.java
index 9c3e405..7b2c623 100644
--- a/core/java/android/net/nsd/NsdManager.java
+++ b/core/java/android/net/nsd/NsdManager.java
@@ -301,27 +301,36 @@
@Override
public void handleMessage(Message message) {
- Object listener = getListener(message.arg2);
- boolean listenerRemove = true;
switch (message.what) {
case AsyncChannel.CMD_CHANNEL_HALF_CONNECTED:
mAsyncChannel.sendMessage(AsyncChannel.CMD_CHANNEL_FULL_CONNECTION);
- break;
+ return;
case AsyncChannel.CMD_CHANNEL_FULLY_CONNECTED:
mConnected.countDown();
- break;
+ return;
case AsyncChannel.CMD_CHANNEL_DISCONNECTED:
Log.e(TAG, "Channel lost");
+ return;
+ default:
break;
+ }
+ Object listener = getListener(message.arg2);
+ if (listener == null) {
+ Log.d(TAG, "Stale key " + message.arg2);
+ return;
+ }
+ boolean listenerRemove = true;
+ NsdServiceInfo ns = getNsdService(message.arg2);
+ switch (message.what) {
case DISCOVER_SERVICES_STARTED:
- String s = ((NsdServiceInfo) message.obj).getServiceType();
+ String s = getNsdServiceInfoType((NsdServiceInfo) message.obj);
((DiscoveryListener) listener).onDiscoveryStarted(s);
// Keep listener until stop discovery
listenerRemove = false;
break;
case DISCOVER_SERVICES_FAILED:
- ((DiscoveryListener) listener).onStartDiscoveryFailed(
- getNsdService(message.arg2).getServiceType(), message.arg1);
+ ((DiscoveryListener) listener).onStartDiscoveryFailed(getNsdServiceInfoType(ns),
+ message.arg1);
break;
case SERVICE_FOUND:
((DiscoveryListener) listener).onServiceFound((NsdServiceInfo) message.obj);
@@ -334,16 +343,14 @@
listenerRemove = false;
break;
case STOP_DISCOVERY_FAILED:
- ((DiscoveryListener) listener).onStopDiscoveryFailed(
- getNsdService(message.arg2).getServiceType(), message.arg1);
+ ((DiscoveryListener) listener).onStopDiscoveryFailed(getNsdServiceInfoType(ns),
+ message.arg1);
break;
case STOP_DISCOVERY_SUCCEEDED:
- ((DiscoveryListener) listener).onDiscoveryStopped(
- getNsdService(message.arg2).getServiceType());
+ ((DiscoveryListener) listener).onDiscoveryStopped(getNsdServiceInfoType(ns));
break;
case REGISTER_SERVICE_FAILED:
- ((RegistrationListener) listener).onRegistrationFailed(
- getNsdService(message.arg2), message.arg1);
+ ((RegistrationListener) listener).onRegistrationFailed(ns, message.arg1);
break;
case REGISTER_SERVICE_SUCCEEDED:
((RegistrationListener) listener).onServiceRegistered(
@@ -352,16 +359,13 @@
listenerRemove = false;
break;
case UNREGISTER_SERVICE_FAILED:
- ((RegistrationListener) listener).onUnregistrationFailed(
- getNsdService(message.arg2), message.arg1);
+ ((RegistrationListener) listener).onUnregistrationFailed(ns, message.arg1);
break;
case UNREGISTER_SERVICE_SUCCEEDED:
- ((RegistrationListener) listener).onServiceUnregistered(
- getNsdService(message.arg2));
+ ((RegistrationListener) listener).onServiceUnregistered(ns);
break;
case RESOLVE_SERVICE_FAILED:
- ((ResolveListener) listener).onResolveFailed(
- getNsdService(message.arg2), message.arg1);
+ ((ResolveListener) listener).onResolveFailed(ns, message.arg1);
break;
case RESOLVE_SERVICE_SUCCEEDED:
((ResolveListener) listener).onServiceResolved((NsdServiceInfo) message.obj);
@@ -421,6 +425,11 @@
}
+ private String getNsdServiceInfoType(NsdServiceInfo s) {
+ if (s == null) return "?";
+ return s.getServiceType();
+ }
+
/**
* Initialize AsyncChannel
*/
diff --git a/core/java/android/nfc/tech/Ndef.java b/core/java/android/nfc/tech/Ndef.java
index 64aa2996..f16dc3b 100644
--- a/core/java/android/nfc/tech/Ndef.java
+++ b/core/java/android/nfc/tech/Ndef.java
@@ -278,6 +278,8 @@
throw new TagLostException();
}
return msg;
+ } else if (!tagService.isPresent(serviceHandle)) {
+ throw new TagLostException();
} else {
return null;
}
diff --git a/core/java/android/os/Binder.java b/core/java/android/os/Binder.java
index f4a8391..ba71605 100644
--- a/core/java/android/os/Binder.java
+++ b/core/java/android/os/Binder.java
@@ -56,7 +56,7 @@
private static String sDumpDisabled = null;
/* mObject is used by native code, do not remove or rename */
- private int mObject;
+ private long mObject;
private IInterface mOwner;
private String mDescriptor;
@@ -390,7 +390,7 @@
private native final void destroy();
// Entry point from android_util_Binder.cpp's onTransact
- private boolean execTransact(int code, int dataObj, int replyObj,
+ private boolean execTransact(int code, long dataObj, long replyObj,
int flags) {
Parcel data = Parcel.obtain(dataObj);
Parcel reply = Parcel.obtain(replyObj);
@@ -499,6 +499,6 @@
}
final private WeakReference mSelf;
- private int mObject;
- private int mOrgue;
+ private long mObject;
+ private long mOrgue;
}
diff --git a/core/java/android/os/Build.java b/core/java/android/os/Build.java
index bc51a60..c3313c5 100644
--- a/core/java/android/os/Build.java
+++ b/core/java/android/os/Build.java
@@ -74,7 +74,14 @@
/** A hardware serial number, if available. Alphanumeric only, case-insensitive. */
public static final String SERIAL = getString("ro.serialno");
-
+
+ /**
+ * A list of ABIs (in priority) order supported by this device.
+ *
+ * @hide
+ */
+ public static final String[] SUPPORTED_ABIS = getString("ro.product.cpu.abilist").split(",");
+
/** Various version strings. */
public static class VERSION {
/**
diff --git a/core/java/android/os/CountDownTimer.java b/core/java/android/os/CountDownTimer.java
index 15e6405..58acbcf 100644
--- a/core/java/android/os/CountDownTimer.java
+++ b/core/java/android/os/CountDownTimer.java
@@ -16,8 +16,6 @@
package android.os;
-import android.util.Log;
-
/**
* Schedule a countdown until a time in the future, with
* regular notifications on intervals along the way.
@@ -56,6 +54,11 @@
private final long mCountdownInterval;
private long mStopTimeInFuture;
+
+ /**
+ * boolean representing if the timer was cancelled
+ */
+ private boolean mCancelled = false;
/**
* @param millisInFuture The number of millis in the future from the call
@@ -72,7 +75,8 @@
/**
* Cancel the countdown.
*/
- public final void cancel() {
+ public synchronized final void cancel() {
+ mCancelled = true;
mHandler.removeMessages(MSG);
}
@@ -80,6 +84,7 @@
* Start the countdown.
*/
public synchronized final CountDownTimer start() {
+ mCancelled = false;
if (mMillisInFuture <= 0) {
onFinish();
return this;
@@ -112,6 +117,10 @@
public void handleMessage(Message msg) {
synchronized (CountDownTimer.this) {
+ if (mCancelled) {
+ return;
+ }
+
final long millisLeft = mStopTimeInFuture - SystemClock.elapsedRealtime();
if (millisLeft <= 0) {
diff --git a/core/java/android/os/Debug.java b/core/java/android/os/Debug.java
index 974bf8d..2de1204 100644
--- a/core/java/android/os/Debug.java
+++ b/core/java/android/os/Debug.java
@@ -578,7 +578,7 @@
* tracing.
*/
public static void startMethodTracing() {
- VMDebug.startMethodTracing(DEFAULT_TRACE_FILE_PATH, 0, 0);
+ VMDebug.startMethodTracing(DEFAULT_TRACE_FILE_PATH, 0, 0, false, 0);
}
/**
@@ -589,7 +589,7 @@
* information about reading trace files.
*
* @param traceName Name for the trace log file to create.
- * If no name argument is given, this value defaults to "/sdcard/dmtrace.trace".
+ * If {@code traceName} is null, this value defaults to "/sdcard/dmtrace.trace".
* If the files already exist, they will be truncated.
* If the trace file given does not end in ".trace", it will be appended for you.
*/
@@ -604,7 +604,7 @@
href="{@docRoot}guide/developing/tools/traceview.html">Traceview: A Graphical Log Viewer</a> for
* information about reading trace files.
* @param traceName Name for the trace log file to create.
- * If no name argument is given, this value defaults to "/sdcard/dmtrace.trace".
+ * If {@code traceName} is null, this value defaults to "/sdcard/dmtrace.trace".
* If the files already exist, they will be truncated.
* If the trace file given does not end in ".trace", it will be appended for you.
*
@@ -627,26 +627,54 @@
* in relative terms (e.g. was run #1 faster than run #2). The times
* for native methods will not change, so don't try to use this to
* compare the performance of interpreted and native implementations of the
- * same method. As an alternative, consider using "native" tracing
- * in the emulator via {@link #startNativeTracing()}.
+ * same method. As an alternative, consider using sampling-based method
+ * tracing via {@link #startMethodTracingSampling(String, int, int)} or
+ * "native" tracing in the emulator via {@link #startNativeTracing()}.
* </p>
*
* @param traceName Name for the trace log file to create.
- * If no name argument is given, this value defaults to "/sdcard/dmtrace.trace".
+ * If {@code traceName} is null, this value defaults to "/sdcard/dmtrace.trace".
* If the files already exist, they will be truncated.
* If the trace file given does not end in ".trace", it will be appended for you.
* @param bufferSize The maximum amount of trace data we gather. If not given, it defaults to 8MB.
+ * @param flags Flags to control method tracing. The only one that is currently defined is {@link #TRACE_COUNT_ALLOCS}.
*/
public static void startMethodTracing(String traceName, int bufferSize,
int flags) {
+ VMDebug.startMethodTracing(fixTraceName(traceName), bufferSize, flags, false, 0);
+ }
- String pathName = traceName;
- if (pathName.charAt(0) != '/')
- pathName = DEFAULT_TRACE_PATH_PREFIX + pathName;
- if (!pathName.endsWith(DEFAULT_TRACE_EXTENSION))
- pathName = pathName + DEFAULT_TRACE_EXTENSION;
+ /**
+ * Start sampling-based method tracing, specifying the trace log file name,
+ * the buffer size, and the sampling interval. The trace files will be put
+ * under "/sdcard" unless an absolute path is given. See <a
+ href="{@docRoot}guide/developing/tools/traceview.html">Traceview: A Graphical Log Viewer</a>
+ * for information about reading trace files.
+ *
+ * @param traceName Name for the trace log file to create.
+ * If {@code traceName} is null, this value defaults to "/sdcard/dmtrace.trace".
+ * If the files already exist, they will be truncated.
+ * If the trace file given does not end in ".trace", it will be appended for you.
+ * @param bufferSize The maximum amount of trace data we gather. If not given, it defaults to 8MB.
+ * @param intervalUs The amount of time between each sample in microseconds.
+ */
+ public static void startMethodTracingSampling(String traceName,
+ int bufferSize, int intervalUs) {
+ VMDebug.startMethodTracing(fixTraceName(traceName), bufferSize, 0, true, intervalUs);
+ }
- VMDebug.startMethodTracing(pathName, bufferSize, flags);
+ /**
+ * Formats name of trace log file for method tracing.
+ */
+ private static String fixTraceName(String traceName) {
+ if (traceName == null)
+ traceName = DEFAULT_TRACE_FILE_PATH;
+ if (traceName.charAt(0) != '/')
+ traceName = DEFAULT_TRACE_PATH_PREFIX + traceName;
+ if (!traceName.endsWith(DEFAULT_TRACE_EXTENSION))
+ traceName = traceName + DEFAULT_TRACE_EXTENSION;
+
+ return traceName;
}
/**
@@ -660,7 +688,7 @@
*/
public static void startMethodTracing(String traceName, FileDescriptor fd,
int bufferSize, int flags) {
- VMDebug.startMethodTracing(traceName, fd, bufferSize, flags);
+ VMDebug.startMethodTracing(traceName, fd, bufferSize, flags, false, 0);
}
/**
diff --git a/core/java/android/os/MemoryFile.java b/core/java/android/os/MemoryFile.java
index e8148f7..6cec55a 100644
--- a/core/java/android/os/MemoryFile.java
+++ b/core/java/android/os/MemoryFile.java
@@ -43,19 +43,19 @@
private static native FileDescriptor native_open(String name, int length) throws IOException;
// returns memory address for ashmem region
- private static native int native_mmap(FileDescriptor fd, int length, int mode)
+ private static native long native_mmap(FileDescriptor fd, int length, int mode)
throws IOException;
- private static native void native_munmap(int addr, int length) throws IOException;
+ private static native void native_munmap(long addr, int length) throws IOException;
private static native void native_close(FileDescriptor fd);
- private static native int native_read(FileDescriptor fd, int address, byte[] buffer,
+ private static native int native_read(FileDescriptor fd, long address, byte[] buffer,
int srcOffset, int destOffset, int count, boolean isUnpinned) throws IOException;
- private static native void native_write(FileDescriptor fd, int address, byte[] buffer,
+ private static native void native_write(FileDescriptor fd, long address, byte[] buffer,
int srcOffset, int destOffset, int count, boolean isUnpinned) throws IOException;
private static native void native_pin(FileDescriptor fd, boolean pin) throws IOException;
private static native int native_get_size(FileDescriptor fd) throws IOException;
private FileDescriptor mFD; // ashmem file descriptor
- private int mAddress; // address of ashmem memory
+ private long mAddress; // address of ashmem memory
private int mLength; // total length of our ashmem region
private boolean mAllowPurging = false; // true if our ashmem region is unpinned
@@ -63,12 +63,17 @@
* Allocates a new ashmem region. The region is initially not purgable.
*
* @param name optional name for the file (can be null).
- * @param length of the memory file in bytes.
+ * @param length of the memory file in bytes, must be non-negative.
* @throws IOException if the memory file could not be created.
*/
public MemoryFile(String name, int length) throws IOException {
mLength = length;
- mFD = native_open(name, length);
+ if (length >= 0) {
+ mFD = native_open(name, length);
+ } else {
+ throw new IOException("Invalid length: " + length);
+ }
+
if (length > 0) {
mAddress = native_mmap(mFD, length, PROT_READ | PROT_WRITE);
} else {
diff --git a/core/java/android/os/MessageQueue.java b/core/java/android/os/MessageQueue.java
index 799de5c..75f9813 100644
--- a/core/java/android/os/MessageQueue.java
+++ b/core/java/android/os/MessageQueue.java
@@ -35,7 +35,7 @@
private final boolean mQuitAllowed;
@SuppressWarnings("unused")
- private int mPtr; // used by native code
+ private long mPtr; // used by native code
Message mMessages;
private final ArrayList<IdleHandler> mIdleHandlers = new ArrayList<IdleHandler>();
@@ -49,11 +49,11 @@
// Barriers are indicated by messages with a null target whose arg1 field carries the token.
private int mNextBarrierToken;
- private native static int nativeInit();
- private native static void nativeDestroy(int ptr);
- private native static void nativePollOnce(int ptr, int timeoutMillis);
- private native static void nativeWake(int ptr);
- private native static boolean nativeIsIdling(int ptr);
+ private native static long nativeInit();
+ private native static void nativeDestroy(long ptr);
+ private native static void nativePollOnce(long ptr, int timeoutMillis);
+ private native static void nativeWake(long ptr);
+ private native static boolean nativeIsIdling(long ptr);
/**
* Callback interface for discovering when a thread is going to block
diff --git a/core/java/android/os/Parcel.java b/core/java/android/os/Parcel.java
index 94b9617..7425f67 100644
--- a/core/java/android/os/Parcel.java
+++ b/core/java/android/os/Parcel.java
@@ -182,7 +182,7 @@
private static final String TAG = "Parcel";
@SuppressWarnings({"UnusedDeclaration"})
- private int mNativePtr; // used by native code
+ private long mNativePtr; // used by native code
/**
* Flag indicating if {@link #mNativePtr} was allocated by this object,
@@ -232,47 +232,47 @@
private static final int EX_NETWORK_MAIN_THREAD = -6;
private static final int EX_HAS_REPLY_HEADER = -128; // special; see below
- private static native int nativeDataSize(int nativePtr);
- private static native int nativeDataAvail(int nativePtr);
- private static native int nativeDataPosition(int nativePtr);
- private static native int nativeDataCapacity(int nativePtr);
- private static native void nativeSetDataSize(int nativePtr, int size);
- private static native void nativeSetDataPosition(int nativePtr, int pos);
- private static native void nativeSetDataCapacity(int nativePtr, int size);
+ private static native int nativeDataSize(long nativePtr);
+ private static native int nativeDataAvail(long nativePtr);
+ private static native int nativeDataPosition(long nativePtr);
+ private static native int nativeDataCapacity(long nativePtr);
+ private static native void nativeSetDataSize(long nativePtr, int size);
+ private static native void nativeSetDataPosition(long nativePtr, int pos);
+ private static native void nativeSetDataCapacity(long nativePtr, int size);
- private static native boolean nativePushAllowFds(int nativePtr, boolean allowFds);
- private static native void nativeRestoreAllowFds(int nativePtr, boolean lastValue);
+ private static native boolean nativePushAllowFds(long nativePtr, boolean allowFds);
+ private static native void nativeRestoreAllowFds(long nativePtr, boolean lastValue);
- private static native void nativeWriteByteArray(int nativePtr, byte[] b, int offset, int len);
- private static native void nativeWriteInt(int nativePtr, int val);
- private static native void nativeWriteLong(int nativePtr, long val);
- private static native void nativeWriteFloat(int nativePtr, float val);
- private static native void nativeWriteDouble(int nativePtr, double val);
- private static native void nativeWriteString(int nativePtr, String val);
- private static native void nativeWriteStrongBinder(int nativePtr, IBinder val);
- private static native void nativeWriteFileDescriptor(int nativePtr, FileDescriptor val);
+ private static native void nativeWriteByteArray(long nativePtr, byte[] b, int offset, int len);
+ private static native void nativeWriteInt(long nativePtr, int val);
+ private static native void nativeWriteLong(long nativePtr, long val);
+ private static native void nativeWriteFloat(long nativePtr, float val);
+ private static native void nativeWriteDouble(long nativePtr, double val);
+ private static native void nativeWriteString(long nativePtr, String val);
+ private static native void nativeWriteStrongBinder(long nativePtr, IBinder val);
+ private static native void nativeWriteFileDescriptor(long nativePtr, FileDescriptor val);
- private static native byte[] nativeCreateByteArray(int nativePtr);
- private static native int nativeReadInt(int nativePtr);
- private static native long nativeReadLong(int nativePtr);
- private static native float nativeReadFloat(int nativePtr);
- private static native double nativeReadDouble(int nativePtr);
- private static native String nativeReadString(int nativePtr);
- private static native IBinder nativeReadStrongBinder(int nativePtr);
- private static native FileDescriptor nativeReadFileDescriptor(int nativePtr);
+ private static native byte[] nativeCreateByteArray(long nativePtr);
+ private static native int nativeReadInt(long nativePtr);
+ private static native long nativeReadLong(long nativePtr);
+ private static native float nativeReadFloat(long nativePtr);
+ private static native double nativeReadDouble(long nativePtr);
+ private static native String nativeReadString(long nativePtr);
+ private static native IBinder nativeReadStrongBinder(long nativePtr);
+ private static native FileDescriptor nativeReadFileDescriptor(long nativePtr);
- private static native int nativeCreate();
- private static native void nativeFreeBuffer(int nativePtr);
- private static native void nativeDestroy(int nativePtr);
+ private static native long nativeCreate();
+ private static native void nativeFreeBuffer(long nativePtr);
+ private static native void nativeDestroy(long nativePtr);
- private static native byte[] nativeMarshall(int nativePtr);
+ private static native byte[] nativeMarshall(long nativePtr);
private static native void nativeUnmarshall(
- int nativePtr, byte[] data, int offest, int length);
+ long nativePtr, byte[] data, int offest, int length);
private static native void nativeAppendFrom(
- int thisNativePtr, int otherNativePtr, int offset, int length);
- private static native boolean nativeHasFileDescriptors(int nativePtr);
- private static native void nativeWriteInterfaceToken(int nativePtr, String interfaceName);
- private static native void nativeEnforceInterface(int nativePtr, String interfaceName);
+ long thisNativePtr, long otherNativePtr, int offset, int length);
+ private static native boolean nativeHasFileDescriptors(long nativePtr);
+ private static native void nativeWriteInterfaceToken(long nativePtr, String interfaceName);
+ private static native void nativeEnforceInterface(long nativePtr, String interfaceName);
public final static Parcelable.Creator<String> STRING_CREATOR
= new Parcelable.Creator<String>() {
@@ -1246,9 +1246,6 @@
} else if (v instanceof Parcelable[]) {
writeInt(VAL_PARCELABLEARRAY);
writeParcelableArray((Parcelable[]) v, 0);
- } else if (v instanceof Object[]) {
- writeInt(VAL_OBJECTARRAY);
- writeArray((Object[]) v);
} else if (v instanceof int[]) {
writeInt(VAL_INTARRAY);
writeIntArray((int[]) v);
@@ -1258,12 +1255,20 @@
} else if (v instanceof Byte) {
writeInt(VAL_BYTE);
writeInt((Byte) v);
- } else if (v instanceof Serializable) {
- // Must be last
- writeInt(VAL_SERIALIZABLE);
- writeSerializable((Serializable) v);
} else {
- throw new RuntimeException("Parcel: unable to marshal value " + v);
+ Class<?> clazz = v.getClass();
+ if (clazz.isArray() && clazz.getComponentType() == Object.class) {
+ // Only pure Object[] are written here, Other arrays of non-primitive types are
+ // handled by serialization as this does not record the component type.
+ writeInt(VAL_OBJECTARRAY);
+ writeArray((Object[]) v);
+ } else if (v instanceof Serializable) {
+ // Must be last
+ writeInt(VAL_SERIALIZABLE);
+ writeSerializable((Serializable) v);
+ } else {
+ throw new RuntimeException("Parcel: unable to marshal value " + v);
+ }
}
}
@@ -1454,10 +1459,11 @@
}
/**
- * Use this function for customized exception handling.
- * customized method call this method for all unknown case
- * @param code exception code
- * @param msg exception message
+ * Throw an exception with the given message. Not intended for use
+ * outside the Parcel class.
+ *
+ * @param code Used to determine which exception class to throw.
+ * @param msg The exception message.
*/
public final void readException(int code, String msg) {
switch (code) {
@@ -2229,6 +2235,11 @@
mCreators = new HashMap<ClassLoader,HashMap<String,Parcelable.Creator>>();
static protected final Parcel obtain(int obj) {
+ throw new UnsupportedOperationException();
+ }
+
+ /** @hide */
+ static protected final Parcel obtain(long obj) {
final Parcel[] pool = sHolderPool;
synchronized (pool) {
Parcel p;
@@ -2247,7 +2258,7 @@
return new Parcel(obj);
}
- private Parcel(int nativePtr) {
+ private Parcel(long nativePtr) {
if (DEBUG_RECYCLE) {
mStack = new RuntimeException();
}
@@ -2255,7 +2266,7 @@
init(nativePtr);
}
- private void init(int nativePtr) {
+ private void init(long nativePtr) {
if (nativePtr != 0) {
mNativePtr = nativePtr;
mOwnsNativeParcelObject = false;
diff --git a/core/java/android/os/Process.java b/core/java/android/os/Process.java
index 631edd6..10ff27e 100644
--- a/core/java/android/os/Process.java
+++ b/core/java/android/os/Process.java
@@ -16,17 +16,18 @@
package android.os;
-import android.net.LocalSocketAddress;
import android.net.LocalSocket;
+import android.net.LocalSocketAddress;
import android.util.Log;
-import dalvik.system.Zygote;
-
+import com.android.internal.os.Zygote;
import java.io.BufferedWriter;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
-
+import java.util.Arrays;
+import java.util.List;
import libcore.io.Libcore;
/*package*/ class ZygoteStartFailedEx extends Exception {
@@ -47,17 +48,7 @@
private static final String ZYGOTE_SOCKET = "zygote";
- /**
- * Name of a process for running the platform's media services.
- * {@hide}
- */
- public static final String ANDROID_SHARED_MEDIA = "com.android.process.media";
-
- /**
- * Name of the process that Google content providers can share.
- * {@hide}
- */
- public static final String GOOGLE_SHARED_APP_CONTENT = "com.google.process.content";
+ private static final String SECONDARY_ZYGOTE_SOCKET = "zygote_secondary";
/**
* Defines the UID/GID under which system code runs.
@@ -344,15 +335,112 @@
public static final int SIGNAL_QUIT = 3;
public static final int SIGNAL_KILL = 9;
public static final int SIGNAL_USR1 = 10;
-
- // State for communicating with zygote process
- static LocalSocket sZygoteSocket;
- static DataInputStream sZygoteInputStream;
- static BufferedWriter sZygoteWriter;
+ /**
+ * State for communicating with the zygote process.
+ */
+ static class ZygoteState {
+ final LocalSocket socket;
+ final DataInputStream inputStream;
+ final BufferedWriter writer;
+ final List<String> abiList;
- /** true if previous zygote open failed */
- static boolean sPreviousZygoteOpenFailed;
+ boolean mClosed;
+
+ private ZygoteState(LocalSocket socket, DataInputStream inputStream,
+ BufferedWriter writer, List<String> abiList) {
+ this.socket = socket;
+ this.inputStream = inputStream;
+ this.writer = writer;
+ this.abiList = abiList;
+ }
+
+ static ZygoteState connect(String socketAddress, int tries) throws ZygoteStartFailedEx {
+ LocalSocket zygoteSocket = null;
+ DataInputStream zygoteInputStream = null;
+ BufferedWriter zygoteWriter = null;
+
+ /*
+ * See bug #811181: Sometimes runtime can make it up before zygote.
+ * Really, we'd like to do something better to avoid this condition,
+ * but for now just wait a bit...
+ *
+ * TODO: This bug was filed in 2007. Get rid of this code. The zygote
+ * forks the system_server so it shouldn't be possible for the zygote
+ * socket to be brought up after the system_server is.
+ */
+ for (int i = 0; i < tries; i++) {
+ if (i > 0) {
+ try {
+ Log.i("Zygote", "Zygote not up yet, sleeping...");
+ Thread.sleep(ZYGOTE_RETRY_MILLIS);
+ } catch (InterruptedException ex) {
+ throw new ZygoteStartFailedEx(ex);
+ }
+ }
+
+ try {
+ zygoteSocket = new LocalSocket();
+ zygoteSocket.connect(new LocalSocketAddress(socketAddress,
+ LocalSocketAddress.Namespace.RESERVED));
+
+ zygoteInputStream = new DataInputStream(zygoteSocket.getInputStream());
+
+ zygoteWriter = new BufferedWriter(new OutputStreamWriter(
+ zygoteSocket.getOutputStream()), 256);
+ break;
+ } catch (IOException ex) {
+ if (zygoteSocket != null) {
+ try {
+ zygoteSocket.close();
+ } catch (IOException ex2) {
+ Log.e(LOG_TAG,"I/O exception on close after exception", ex2);
+ }
+ }
+
+ zygoteSocket = null;
+ }
+ }
+
+ if (zygoteSocket == null) {
+ throw new ZygoteStartFailedEx("connect failed");
+ }
+
+ String abiListString = getAbiList(zygoteWriter, zygoteInputStream);
+ Log.i("Zygote", "Process: zygote socket opened, supported ABIS: " + abiListString);
+
+ return new ZygoteState(zygoteSocket, zygoteInputStream, zygoteWriter,
+ Arrays.asList(abiListString.split(",")));
+ }
+
+ boolean matches(String abi) {
+ return abiList.contains(abi);
+ }
+
+ void close() {
+ try {
+ socket.close();
+ } catch (IOException ex) {
+ Log.e(LOG_TAG,"I/O exception on routine close", ex);
+ }
+
+ mClosed = true;
+ }
+
+ boolean isClosed() {
+ return mClosed;
+ }
+ }
+
+ /**
+ * The state of the connection to the primary zygote.
+ */
+ static ZygoteState primaryZygoteState;
+
+ /**
+ * The state of the connection to the secondary zygote.
+ */
+ static ZygoteState secondaryZygoteState;
/**
* Start a new process.
@@ -378,6 +466,7 @@
* @param debugFlags Additional flags.
* @param targetSdkVersion The target SDK version for the app.
* @param seInfo null-ok SELinux information for the new process.
+ * @param abi non-null the ABI this app should be started with.
* @param zygoteArgs Additional arguments to supply to the zygote process.
*
* @return An object that describes the result of the attempt to start the process.
@@ -391,10 +480,12 @@
int debugFlags, int mountExternal,
int targetSdkVersion,
String seInfo,
+ String abi,
String[] zygoteArgs) {
try {
return startViaZygote(processClass, niceName, uid, gid, gids,
- debugFlags, mountExternal, targetSdkVersion, seInfo, zygoteArgs);
+ debugFlags, mountExternal, targetSdkVersion, seInfo,
+ abi, zygoteArgs);
} catch (ZygoteStartFailedEx ex) {
Log.e(LOG_TAG,
"Starting VM process through Zygote failed");
@@ -407,78 +498,31 @@
static final int ZYGOTE_RETRY_MILLIS = 500;
/**
- * Tries to open socket to Zygote process if not already open. If
- * already open, does nothing. May block and retry.
+ * Queries the zygote for the list of ABIS it supports.
+ *
+ * @throws ZygoteStartFailedEx if the query failed.
*/
- private static void openZygoteSocketIfNeeded()
+ private static String getAbiList(BufferedWriter writer, DataInputStream inputStream)
throws ZygoteStartFailedEx {
+ try {
- int retryCount;
+ // Each query starts with the argument count (1 in this case)
+ writer.write("1");
+ // ... followed by a new-line.
+ writer.newLine();
+ // ... followed by our only argument.
+ writer.write("--query-abi-list");
+ writer.newLine();
+ writer.flush();
- if (sPreviousZygoteOpenFailed) {
- /*
- * If we've failed before, expect that we'll fail again and
- * don't pause for retries.
- */
- retryCount = 0;
- } else {
- retryCount = 10;
- }
+ // The response is a length prefixed stream of ASCII bytes.
+ int numBytes = inputStream.readInt();
+ byte[] bytes = new byte[numBytes];
+ inputStream.readFully(bytes);
- /*
- * See bug #811181: Sometimes runtime can make it up before zygote.
- * Really, we'd like to do something better to avoid this condition,
- * but for now just wait a bit...
- */
- for (int retry = 0
- ; (sZygoteSocket == null) && (retry < (retryCount + 1))
- ; retry++ ) {
-
- if (retry > 0) {
- try {
- Log.i("Zygote", "Zygote not up yet, sleeping...");
- Thread.sleep(ZYGOTE_RETRY_MILLIS);
- } catch (InterruptedException ex) {
- // should never happen
- }
- }
-
- try {
- sZygoteSocket = new LocalSocket();
-
- sZygoteSocket.connect(new LocalSocketAddress(ZYGOTE_SOCKET,
- LocalSocketAddress.Namespace.RESERVED));
-
- sZygoteInputStream
- = new DataInputStream(sZygoteSocket.getInputStream());
-
- sZygoteWriter =
- new BufferedWriter(
- new OutputStreamWriter(
- sZygoteSocket.getOutputStream()),
- 256);
-
- Log.i("Zygote", "Process: zygote socket opened");
-
- sPreviousZygoteOpenFailed = false;
- break;
- } catch (IOException ex) {
- if (sZygoteSocket != null) {
- try {
- sZygoteSocket.close();
- } catch (IOException ex2) {
- Log.e(LOG_TAG,"I/O exception on close after exception",
- ex2);
- }
- }
-
- sZygoteSocket = null;
- }
- }
-
- if (sZygoteSocket == null) {
- sPreviousZygoteOpenFailed = true;
- throw new ZygoteStartFailedEx("connect failed");
+ return new String(bytes, StandardCharsets.US_ASCII);
+ } catch (IOException ioe) {
+ throw new ZygoteStartFailedEx(ioe);
}
}
@@ -486,14 +530,12 @@
* Sends an argument list to the zygote process, which starts a new child
* and returns the child's pid. Please note: the present implementation
* replaces newlines in the argument list with spaces.
- * @param args argument list
- * @return An object that describes the result of the attempt to start the process.
+ *
* @throws ZygoteStartFailedEx if process start failed for any reason
*/
- private static ProcessStartResult zygoteSendArgsAndGetResult(ArrayList<String> args)
+ private static ProcessStartResult zygoteSendArgsAndGetResult(
+ ZygoteState zygoteState, ArrayList<String> args)
throws ZygoteStartFailedEx {
- openZygoteSocketIfNeeded();
-
try {
/**
* See com.android.internal.os.ZygoteInit.readArgumentList()
@@ -505,9 +547,11 @@
* the child or -1 on failure, followed by boolean to
* indicate whether a wrapper process was used.
*/
+ final BufferedWriter writer = zygoteState.writer;
+ final DataInputStream inputStream = zygoteState.inputStream;
- sZygoteWriter.write(Integer.toString(args.size()));
- sZygoteWriter.newLine();
+ writer.write(Integer.toString(args.size()));
+ writer.newLine();
int sz = args.size();
for (int i = 0; i < sz; i++) {
@@ -516,32 +560,22 @@
throw new ZygoteStartFailedEx(
"embedded newlines not allowed");
}
- sZygoteWriter.write(arg);
- sZygoteWriter.newLine();
+ writer.write(arg);
+ writer.newLine();
}
- sZygoteWriter.flush();
+ writer.flush();
// Should there be a timeout on this?
ProcessStartResult result = new ProcessStartResult();
- result.pid = sZygoteInputStream.readInt();
+ result.pid = inputStream.readInt();
if (result.pid < 0) {
throw new ZygoteStartFailedEx("fork() failed");
}
- result.usingWrapper = sZygoteInputStream.readBoolean();
+ result.usingWrapper = inputStream.readBoolean();
return result;
} catch (IOException ex) {
- try {
- if (sZygoteSocket != null) {
- sZygoteSocket.close();
- }
- } catch (IOException ex2) {
- // we're going to fail anyway
- Log.e(LOG_TAG,"I/O exception on routine close", ex2);
- }
-
- sZygoteSocket = null;
-
+ zygoteState.close();
throw new ZygoteStartFailedEx(ex);
}
}
@@ -558,6 +592,7 @@
* @param debugFlags Additional flags.
* @param targetSdkVersion The target SDK version for the app.
* @param seInfo null-ok SELinux information for the new process.
+ * @param abi the ABI the process should use.
* @param extraArgs Additional arguments to supply to the zygote process.
* @return An object that describes the result of the attempt to start the process.
* @throws ZygoteStartFailedEx if process start failed for any reason
@@ -569,6 +604,7 @@
int debugFlags, int mountExternal,
int targetSdkVersion,
String seInfo,
+ String abi,
String[] extraArgs)
throws ZygoteStartFailedEx {
synchronized(Process.class) {
@@ -636,10 +672,54 @@
}
}
- return zygoteSendArgsAndGetResult(argsForZygote);
+ return zygoteSendArgsAndGetResult(openZygoteSocketIfNeeded(abi), argsForZygote);
}
}
-
+
+ /**
+ * Returns the number of times we attempt a connection to the zygote. We
+ * sleep for {@link #ZYGOTE_RETRY_MILLIS} milliseconds between each try.
+ *
+ * This could probably be removed, see TODO in {@code ZygoteState#connect}.
+ */
+ private static int getNumTries(ZygoteState state) {
+ // Retry 10 times for the first connection to each zygote.
+ if (state == null) {
+ return 11;
+ }
+
+ // This means the connection has already been established, but subsequently
+ // closed, possibly due to an IOException. We retry just once if that's the
+ // case.
+ return 1;
+ }
+
+ /**
+ * Tries to open socket to Zygote process if not already open. If
+ * already open, does nothing. May block and retry.
+ */
+ private static ZygoteState openZygoteSocketIfNeeded(String abi) throws ZygoteStartFailedEx {
+ if (primaryZygoteState == null || primaryZygoteState.isClosed()) {
+ primaryZygoteState = ZygoteState.connect(ZYGOTE_SOCKET, getNumTries(primaryZygoteState));
+ }
+
+ if (primaryZygoteState.matches(abi)) {
+ return primaryZygoteState;
+ }
+
+ // The primary zygote didn't match. Try the secondary.
+ if (secondaryZygoteState == null || secondaryZygoteState.isClosed()) {
+ secondaryZygoteState = ZygoteState.connect(SECONDARY_ZYGOTE_SOCKET,
+ getNumTries(secondaryZygoteState));
+ }
+
+ if (secondaryZygoteState.matches(abi)) {
+ return secondaryZygoteState;
+ }
+
+ throw new ZygoteStartFailedEx("Unsupported zygote ABI: " + abi);
+ }
+
/**
* Returns elapsed milliseconds of the time this process has run.
* @return Returns the number of milliseconds this process has return.
diff --git a/core/java/android/os/SystemClock.java b/core/java/android/os/SystemClock.java
index 729c64b..672df6d 100644
--- a/core/java/android/os/SystemClock.java
+++ b/core/java/android/os/SystemClock.java
@@ -16,6 +16,9 @@
package android.os;
+import android.app.IAlarmManager;
+import android.content.Context;
+import android.util.Slog;
/**
* Core timekeeping facilities.
@@ -89,6 +92,8 @@
* </ul>
*/
public final class SystemClock {
+ private static final String TAG = "SystemClock";
+
/**
* This class is uninstantiable.
*/
@@ -134,7 +139,23 @@
*
* @return if the clock was successfully set to the specified time.
*/
- native public static boolean setCurrentTimeMillis(long millis);
+ public static boolean setCurrentTimeMillis(long millis) {
+ IBinder b = ServiceManager.getService(Context.ALARM_SERVICE);
+ IAlarmManager mgr = IAlarmManager.Stub.asInterface(b);
+ if (mgr == null) {
+ return false;
+ }
+
+ try {
+ return mgr.setTime(millis);
+ } catch (RemoteException e) {
+ Slog.e(TAG, "Unable to set RTC", e);
+ } catch (SecurityException e) {
+ Slog.e(TAG, "Unable to set RTC", e);
+ }
+
+ return false;
+ }
/**
* Returns milliseconds since boot, not counting time spent in deep sleep.
diff --git a/core/java/android/speech/srec/MicrophoneInputStream.java b/core/java/android/speech/srec/MicrophoneInputStream.java
index fab77a9..94db176 100644
--- a/core/java/android/speech/srec/MicrophoneInputStream.java
+++ b/core/java/android/speech/srec/MicrophoneInputStream.java
@@ -34,7 +34,7 @@
}
private final static String TAG = "MicrophoneInputStream";
- private int mAudioRecord = 0;
+ private long mAudioRecord = 0;
private byte[] mOneByte = new byte[1];
/**
@@ -102,9 +102,9 @@
//
// AudioRecord JNI interface
//
- private static native int AudioRecordNew(int sampleRate, int fifoDepth);
- private static native int AudioRecordStart(int audioRecord);
- private static native int AudioRecordRead(int audioRecord, byte[] b, int offset, int length) throws IOException;
- private static native void AudioRecordStop(int audioRecord) throws IOException;
- private static native void AudioRecordDelete(int audioRecord) throws IOException;
+ private static native long AudioRecordNew(int sampleRate, int fifoDepth);
+ private static native int AudioRecordStart(long audioRecord);
+ private static native int AudioRecordRead(long audioRecord, byte[] b, int offset, int length) throws IOException;
+ private static native void AudioRecordStop(long audioRecord) throws IOException;
+ private static native void AudioRecordDelete(long audioRecord) throws IOException;
}
diff --git a/core/java/android/speech/srec/Recognizer.java b/core/java/android/speech/srec/Recognizer.java
index db5d8fd..1396204 100644
--- a/core/java/android/speech/srec/Recognizer.java
+++ b/core/java/android/speech/srec/Recognizer.java
@@ -125,10 +125,10 @@
public static final String KEY_MEANING = "meaning";
// handle to SR_Vocabulary object
- private int mVocabulary = 0;
+ private long mVocabulary = 0;
// handle to SR_Recognizer object
- private int mRecognizer = 0;
+ private long mRecognizer = 0;
// Grammar currently associated with Recognizer via SR_GrammarSetupRecognizer
private Grammar mActiveGrammar = null;
@@ -174,7 +174,7 @@
* Represents a grammar loaded into the Recognizer.
*/
public class Grammar {
- private int mGrammar = 0;
+ private long mGrammar = 0;
/**
* Create a <code>Grammar</code> instance.
@@ -603,116 +603,116 @@
//
// SR_Recognizer methods
//
- private static native void SR_RecognizerStart(int recognizer);
- private static native void SR_RecognizerStop(int recognizer);
- private static native int SR_RecognizerCreate();
- private static native void SR_RecognizerDestroy(int recognizer);
- private static native void SR_RecognizerSetup(int recognizer);
- private static native void SR_RecognizerUnsetup(int recognizer);
- private static native boolean SR_RecognizerIsSetup(int recognizer);
- private static native String SR_RecognizerGetParameter(int recognizer, String key);
- private static native int SR_RecognizerGetSize_tParameter(int recognizer, String key);
- private static native boolean SR_RecognizerGetBoolParameter(int recognizer, String key);
- private static native void SR_RecognizerSetParameter(int recognizer, String key, String value);
- private static native void SR_RecognizerSetSize_tParameter(int recognizer,
+ private static native void SR_RecognizerStart(long recognizer);
+ private static native void SR_RecognizerStop(long recognizer);
+ private static native long SR_RecognizerCreate();
+ private static native void SR_RecognizerDestroy(long recognizer);
+ private static native void SR_RecognizerSetup(long recognizer);
+ private static native void SR_RecognizerUnsetup(long recognizer);
+ private static native boolean SR_RecognizerIsSetup(long recognizer);
+ private static native String SR_RecognizerGetParameter(long recognizer, String key);
+ private static native int SR_RecognizerGetSize_tParameter(long recognizer, String key);
+ private static native boolean SR_RecognizerGetBoolParameter(long recognizer, String key);
+ private static native void SR_RecognizerSetParameter(long recognizer, String key, String value);
+ private static native void SR_RecognizerSetSize_tParameter(long recognizer,
String key, int value);
- private static native void SR_RecognizerSetBoolParameter(int recognizer, String key,
+ private static native void SR_RecognizerSetBoolParameter(long recognizer, String key,
boolean value);
- private static native void SR_RecognizerSetupRule(int recognizer, int grammar,
+ private static native void SR_RecognizerSetupRule(long recognizer, long grammar,
String ruleName);
- private static native boolean SR_RecognizerHasSetupRules(int recognizer);
- private static native void SR_RecognizerActivateRule(int recognizer, int grammar,
+ private static native boolean SR_RecognizerHasSetupRules(long recognizer);
+ private static native void SR_RecognizerActivateRule(long recognizer, long grammar,
String ruleName, int weight);
- private static native void SR_RecognizerDeactivateRule(int recognizer, int grammar,
+ private static native void SR_RecognizerDeactivateRule(long recognizer, long grammar,
String ruleName);
- private static native void SR_RecognizerDeactivateAllRules(int recognizer);
- private static native boolean SR_RecognizerIsActiveRule(int recognizer, int grammar,
+ private static native void SR_RecognizerDeactivateAllRules(long recognizer);
+ private static native boolean SR_RecognizerIsActiveRule(long recognizer, long grammar,
String ruleName);
- private static native boolean SR_RecognizerCheckGrammarConsistency(int recognizer,
- int grammar);
- private static native int SR_RecognizerPutAudio(int recognizer, byte[] buffer, int offset,
+ private static native boolean SR_RecognizerCheckGrammarConsistency(long recognizer,
+ long grammar);
+ private static native int SR_RecognizerPutAudio(long recognizer, byte[] buffer, int offset,
int length, boolean isLast);
- private static native int SR_RecognizerAdvance(int recognizer);
- // private static native void SR_RecognizerLoadUtterance(int recognizer,
+ private static native int SR_RecognizerAdvance(long recognizer);
+ // private static native void SR_RecognizerLoadUtterance(long recognizer,
// const LCHAR* filename);
- // private static native void SR_RecognizerLoadWaveFile(int recognizer,
+ // private static native void SR_RecognizerLoadWaveFile(long recognizer,
// const LCHAR* filename);
- // private static native void SR_RecognizerSetLockFunction(int recognizer,
+ // private static native void SR_RecognizerSetLockFunction(long recognizer,
// SR_RecognizerLockFunction function, void* data);
- private static native boolean SR_RecognizerIsSignalClipping(int recognizer);
- private static native boolean SR_RecognizerIsSignalDCOffset(int recognizer);
- private static native boolean SR_RecognizerIsSignalNoisy(int recognizer);
- private static native boolean SR_RecognizerIsSignalTooQuiet(int recognizer);
- private static native boolean SR_RecognizerIsSignalTooFewSamples(int recognizer);
- private static native boolean SR_RecognizerIsSignalTooManySamples(int recognizer);
+ private static native boolean SR_RecognizerIsSignalClipping(long recognizer);
+ private static native boolean SR_RecognizerIsSignalDCOffset(long recognizer);
+ private static native boolean SR_RecognizerIsSignalNoisy(long recognizer);
+ private static native boolean SR_RecognizerIsSignalTooQuiet(long recognizer);
+ private static native boolean SR_RecognizerIsSignalTooFewSamples(long recognizer);
+ private static native boolean SR_RecognizerIsSignalTooManySamples(long recognizer);
// private static native void SR_Recognizer_Change_Sample_Rate (size_t new_sample_rate);
//
// SR_AcousticState native methods
//
- private static native void SR_AcousticStateReset(int recognizer);
- private static native void SR_AcousticStateSet(int recognizer, String state);
- private static native String SR_AcousticStateGet(int recognizer);
+ private static native void SR_AcousticStateReset(long recognizer);
+ private static native void SR_AcousticStateSet(long recognizer, String state);
+ private static native String SR_AcousticStateGet(long recognizer);
//
// SR_Grammar native methods
//
- private static native void SR_GrammarCompile(int grammar);
- private static native void SR_GrammarAddWordToSlot(int grammar, String slot,
+ private static native void SR_GrammarCompile(long grammar);
+ private static native void SR_GrammarAddWordToSlot(long grammar, String slot,
String word, String pronunciation, int weight, String tag);
- private static native void SR_GrammarResetAllSlots(int grammar);
- // private static native void SR_GrammarAddNametagToSlot(int grammar, String slot,
+ private static native void SR_GrammarResetAllSlots(long grammar);
+ // private static native void SR_GrammarAddNametagToSlot(long grammar, String slot,
// const struct SR_Nametag_t* nametag, int weight, String tag);
- private static native void SR_GrammarSetupVocabulary(int grammar, int vocabulary);
- // private static native void SR_GrammarSetupModels(int grammar, SR_AcousticModels* models);
- private static native void SR_GrammarSetupRecognizer(int grammar, int recognizer);
- private static native void SR_GrammarUnsetupRecognizer(int grammar);
- // private static native void SR_GrammarGetModels(int grammar,SR_AcousticModels** models);
- private static native int SR_GrammarCreate();
- private static native void SR_GrammarDestroy(int grammar);
- private static native int SR_GrammarLoad(String filename);
- private static native void SR_GrammarSave(int grammar, String filename);
- // private static native void SR_GrammarSetDispatchFunction(int grammar,
+ private static native void SR_GrammarSetupVocabulary(long grammar, long vocabulary);
+ // private static native void SR_GrammarSetupModels(long grammar, SR_AcousticModels* models);
+ private static native void SR_GrammarSetupRecognizer(long grammar, long recognizer);
+ private static native void SR_GrammarUnsetupRecognizer(long grammar);
+ // private static native void SR_GrammarGetModels(long grammar,SR_AcousticModels** models);
+ private static native long SR_GrammarCreate();
+ private static native void SR_GrammarDestroy(long grammar);
+ private static native long SR_GrammarLoad(String filename);
+ private static native void SR_GrammarSave(long grammar, String filename);
+ // private static native void SR_GrammarSetDispatchFunction(long grammar,
// const LCHAR* name, void* userData, SR_GrammarDispatchFunction function);
- // private static native void SR_GrammarSetParameter(int grammar, const
+ // private static native void SR_GrammarSetParameter(long grammar, const
// LCHAR* key, void* value);
- // private static native void SR_GrammarSetSize_tParameter(int grammar,
+ // private static native void SR_GrammarSetSize_tParameter(long grammar,
// const LCHAR* key, size_t value);
- // private static native void SR_GrammarGetParameter(int grammar, const
+ // private static native void SR_GrammarGetParameter(long grammar, const
// LCHAR* key, void** value);
- // private static native void SR_GrammarGetSize_tParameter(int grammar,
+ // private static native void SR_GrammarGetSize_tParameter(long grammar,
// const LCHAR* key, size_t* value);
- // private static native void SR_GrammarCheckParse(int grammar, const LCHAR*
+ // private static native void SR_GrammarCheckParse(long grammar, const LCHAR*
// transcription, SR_SemanticResult** result, size_t* resultCount);
- private static native void SR_GrammarAllowOnly(int grammar, String transcription);
- private static native void SR_GrammarAllowAll(int grammar);
+ private static native void SR_GrammarAllowOnly(long grammar, String transcription);
+ private static native void SR_GrammarAllowAll(long grammar);
//
// SR_Vocabulary native methods
//
// private static native int SR_VocabularyCreate();
- private static native int SR_VocabularyLoad();
+ private static native long SR_VocabularyLoad();
// private static native void SR_VocabularySave(SR_Vocabulary* self,
// const LCHAR* filename);
// private static native void SR_VocabularyAddWord(SR_Vocabulary* self,
// const LCHAR* word);
// private static native void SR_VocabularyGetLanguage(SR_Vocabulary* self,
// ESR_Locale* locale);
- private static native void SR_VocabularyDestroy(int vocabulary);
- private static native String SR_VocabularyGetPronunciation(int vocabulary, String word);
+ private static native void SR_VocabularyDestroy(long vocabulary);
+ private static native String SR_VocabularyGetPronunciation(long vocabulary, String word);
//
// SR_RecognizerResult native methods
//
- private static native byte[] SR_RecognizerResultGetWaveform(int recognizer);
- private static native int SR_RecognizerResultGetSize(int recognizer);
- private static native int SR_RecognizerResultGetKeyCount(int recognizer, int nbest);
- private static native String[] SR_RecognizerResultGetKeyList(int recognizer, int nbest);
- private static native String SR_RecognizerResultGetValue(int recognizer,
+ private static native byte[] SR_RecognizerResultGetWaveform(long recognizer);
+ private static native int SR_RecognizerResultGetSize(long recognizer);
+ private static native int SR_RecognizerResultGetKeyCount(long recognizer, int nbest);
+ private static native String[] SR_RecognizerResultGetKeyList(long recognizer, int nbest);
+ private static native String SR_RecognizerResultGetValue(long recognizer,
int nbest, String key);
- // private static native void SR_RecognizerResultGetLocale(int recognizer, ESR_Locale* locale);
+ // private static native void SR_RecognizerResultGetLocale(long recognizer, ESR_Locale* locale);
}
diff --git a/core/java/android/util/JsonReader.java b/core/java/android/util/JsonReader.java
index f2a86c9..7d1c6c4 100644
--- a/core/java/android/util/JsonReader.java
+++ b/core/java/android/util/JsonReader.java
@@ -546,6 +546,9 @@
public void skipValue() throws IOException {
skipping = true;
try {
+ if (!hasNext() || peek() == JsonToken.END_DOCUMENT) {
+ throw new IllegalStateException("No element left to skip");
+ }
int count = 0;
do {
JsonToken token = advance();
diff --git a/core/java/android/util/Patterns.java b/core/java/android/util/Patterns.java
index 9522112..0f8da44 100644
--- a/core/java/android/util/Patterns.java
+++ b/core/java/android/util/Patterns.java
@@ -191,8 +191,6 @@
for (int i = 1; i <= numGroups; i++) {
String s = matcher.group(i);
- System.err.println("Group(" + i + ") : " + s);
-
if (s != null) {
b.append(s);
}
diff --git a/core/java/android/view/GLES20Canvas.java b/core/java/android/view/GLES20Canvas.java
index beefc21..d533060 100644
--- a/core/java/android/view/GLES20Canvas.java
+++ b/core/java/android/view/GLES20Canvas.java
@@ -49,7 +49,7 @@
private static final int MODIFIER_COLOR_FILTER = 4;
private final boolean mOpaque;
- private int mRenderer;
+ private long mRenderer;
// The native renderer will be destroyed when this object dies.
// DO NOT overwrite this reference once it is set.
@@ -92,7 +92,7 @@
/**
* Creates a canvas to render into an FBO.
*/
- GLES20Canvas(int layer, boolean translucent) {
+ GLES20Canvas(long layer, boolean translucent) {
mOpaque = !translucent;
mRenderer = nCreateLayerRenderer(layer);
setupFinalizer();
@@ -122,16 +122,16 @@
nResetDisplayListRenderer(mRenderer);
}
- private static native int nCreateRenderer();
- private static native int nCreateLayerRenderer(int layer);
- private static native int nCreateDisplayListRenderer();
- private static native void nResetDisplayListRenderer(int renderer);
- private static native void nDestroyRenderer(int renderer);
+ private static native long nCreateRenderer();
+ private static native long nCreateLayerRenderer(long layer);
+ private static native long nCreateDisplayListRenderer();
+ private static native void nResetDisplayListRenderer(long renderer);
+ private static native void nDestroyRenderer(long renderer);
private static final class CanvasFinalizer {
- private final int mRenderer;
+ private final long mRenderer;
- public CanvasFinalizer(int renderer) {
+ public CanvasFinalizer(long renderer) {
mRenderer = renderer;
}
@@ -151,7 +151,7 @@
nSetName(mRenderer, name);
}
- private static native void nSetName(int renderer, String name);
+ private static native void nSetName(long renderer, String name);
///////////////////////////////////////////////////////////////////////////
// Hardware layers
@@ -177,26 +177,26 @@
nClearLayerUpdates(mRenderer);
}
- static native int nCreateTextureLayer(boolean opaque, int[] layerInfo);
- static native int nCreateLayer(int width, int height, boolean isOpaque, int[] layerInfo);
- static native boolean nResizeLayer(int layerId, int width, int height, int[] layerInfo);
- static native void nSetOpaqueLayer(int layerId, boolean isOpaque);
- static native void nSetLayerPaint(int layerId, int nativePaint);
- static native void nSetLayerColorFilter(int layerId, int nativeColorFilter);
- static native void nUpdateTextureLayer(int layerId, int width, int height, boolean opaque,
+ static native long nCreateTextureLayer(boolean opaque, int[] layerInfo);
+ static native long nCreateLayer(int width, int height, boolean isOpaque, int[] layerInfo);
+ static native boolean nResizeLayer(long layerId, int width, int height, int[] layerInfo);
+ static native void nSetOpaqueLayer(long layerId, boolean isOpaque);
+ static native void nSetLayerPaint(long layerId, long nativePaint);
+ static native void nSetLayerColorFilter(long layerId, long nativeColorFilter);
+ static native void nUpdateTextureLayer(long layerId, int width, int height, boolean opaque,
SurfaceTexture surface);
- static native void nClearLayerTexture(int layerId);
- static native void nSetTextureLayerTransform(int layerId, int matrix);
- static native void nDestroyLayer(int layerId);
- static native void nDestroyLayerDeferred(int layerId);
- static native void nUpdateRenderLayer(int layerId, int renderer, int displayList,
+ static native void nClearLayerTexture(long layerId);
+ static native void nSetTextureLayerTransform(long layerId, long matrix);
+ static native void nDestroyLayer(long layerId);
+ static native void nDestroyLayerDeferred(long layerId);
+ static native void nUpdateRenderLayer(long layerId, long renderer, long displayList,
int left, int top, int right, int bottom);
- static native boolean nCopyLayer(int layerId, int bitmap);
+ static native boolean nCopyLayer(long layerId, long bitmap);
- private static native void nClearLayerUpdates(int renderer);
- private static native void nFlushLayerUpdates(int renderer);
- private static native void nPushLayerUpdate(int renderer, int layer);
- private static native void nCancelLayerUpdate(int renderer, int layer);
+ private static native void nClearLayerUpdates(long renderer);
+ private static native void nFlushLayerUpdates(long renderer);
+ private static native void nPushLayerUpdate(long renderer, long layer);
+ private static native void nCancelLayerUpdate(long renderer, long layer);
///////////////////////////////////////////////////////////////////////////
// Canvas management
@@ -233,7 +233,7 @@
/**
* Returns the native OpenGLRenderer object.
*/
- int getRenderer() {
+ long getRenderer() {
return mRenderer;
}
@@ -249,7 +249,7 @@
nSetViewport(mRenderer, width, height);
}
- private static native void nSetViewport(int renderer, int width, int height);
+ private static native void nSetViewport(long renderer, int width, int height);
@Override
public int onPreDraw(Rect dirty) {
@@ -261,8 +261,8 @@
}
}
- private static native int nPrepare(int renderer, boolean opaque);
- private static native int nPrepareDirty(int renderer, int left, int top, int right, int bottom,
+ private static native int nPrepare(long renderer, boolean opaque);
+ private static native int nPrepareDirty(long renderer, int left, int top, int right, int bottom,
boolean opaque);
@Override
@@ -270,7 +270,7 @@
nFinish(mRenderer);
}
- private static native void nFinish(int renderer);
+ private static native void nFinish(long renderer);
/**
* Returns the size of the stencil buffer required by the underlying
@@ -290,45 +290,45 @@
nSetCountOverdrawEnabled(mRenderer, enabled);
}
- static native void nSetCountOverdrawEnabled(int renderer, boolean enabled);
+ static native void nSetCountOverdrawEnabled(long renderer, boolean enabled);
float getOverdraw() {
return nGetOverdraw(mRenderer);
}
- static native float nGetOverdraw(int renderer);
+ static native float nGetOverdraw(long renderer);
///////////////////////////////////////////////////////////////////////////
// Functor
///////////////////////////////////////////////////////////////////////////
@Override
- public int callDrawGLFunction(int drawGLFunction) {
+ public int callDrawGLFunction(long drawGLFunction) {
return nCallDrawGLFunction(mRenderer, drawGLFunction);
}
- private static native int nCallDrawGLFunction(int renderer, int drawGLFunction);
+ private static native int nCallDrawGLFunction(long renderer, long drawGLFunction);
@Override
public int invokeFunctors(Rect dirty) {
return nInvokeFunctors(mRenderer, dirty);
}
- private static native int nInvokeFunctors(int renderer, Rect dirty);
+ private static native int nInvokeFunctors(long renderer, Rect dirty);
@Override
- public void detachFunctor(int functor) {
+ public void detachFunctor(long functor) {
nDetachFunctor(mRenderer, functor);
}
- private static native void nDetachFunctor(int renderer, int functor);
+ private static native void nDetachFunctor(long renderer, long functor);
@Override
- public void attachFunctor(int functor) {
+ public void attachFunctor(long functor) {
nAttachFunctor(mRenderer, functor);
}
- private static native void nAttachFunctor(int renderer, int functor);
+ private static native void nAttachFunctor(long renderer, long functor);
///////////////////////////////////////////////////////////////////////////
// Memory
@@ -392,28 +392,28 @@
// Atlas
///////////////////////////////////////////////////////////////////////////
- static void initAtlas(GraphicBuffer buffer, int[] map) {
+ static void initAtlas(GraphicBuffer buffer, long[] map) {
nInitAtlas(buffer, map, map.length);
}
- private static native void nInitAtlas(GraphicBuffer buffer, int[] map, int count);
+ private static native void nInitAtlas(GraphicBuffer buffer, long[] map, int count);
///////////////////////////////////////////////////////////////////////////
// Display list
///////////////////////////////////////////////////////////////////////////
- int getDisplayList(int displayList) {
+ long getDisplayList(long displayList) {
return nGetDisplayList(mRenderer, displayList);
}
- private static native int nGetDisplayList(int renderer, int displayList);
+ private static native long nGetDisplayList(long renderer, long displayList);
@Override
void outputDisplayList(DisplayList displayList) {
nOutputDisplayList(mRenderer, ((GLES20DisplayList) displayList).getNativeDisplayList());
}
- private static native void nOutputDisplayList(int renderer, int displayList);
+ private static native void nOutputDisplayList(long renderer, long displayList);
@Override
public int drawDisplayList(DisplayList displayList, Rect dirty, int flags) {
@@ -421,7 +421,7 @@
dirty, flags);
}
- private static native int nDrawDisplayList(int renderer, int displayList,
+ private static native int nDrawDisplayList(long renderer, long displayList,
Rect dirty, int flags);
///////////////////////////////////////////////////////////////////////////
@@ -435,7 +435,7 @@
nDrawLayer(mRenderer, glLayer.getLayer(), x, y);
}
- private static native void nDrawLayer(int renderer, int layer, float x, float y);
+ private static native void nDrawLayer(long renderer, long layer, float x, float y);
void interrupt() {
nInterrupt(mRenderer);
@@ -445,8 +445,8 @@
nResume(mRenderer);
}
- private static native void nInterrupt(int renderer);
- private static native void nResume(int renderer);
+ private static native void nInterrupt(long renderer);
+ private static native void nResume(long renderer);
///////////////////////////////////////////////////////////////////////////
// Support
@@ -487,14 +487,14 @@
return nClipPath(mRenderer, path.mNativePath, op.nativeInt);
}
- private static native boolean nClipPath(int renderer, int path, int op);
+ private static native boolean nClipPath(long renderer, long path, int op);
@Override
public boolean clipRect(float left, float top, float right, float bottom) {
return nClipRect(mRenderer, left, top, right, bottom, Region.Op.INTERSECT.nativeInt);
}
- private static native boolean nClipRect(int renderer, float left, float top,
+ private static native boolean nClipRect(long renderer, float left, float top,
float right, float bottom, int op);
@Override
@@ -507,7 +507,7 @@
return nClipRect(mRenderer, left, top, right, bottom, Region.Op.INTERSECT.nativeInt);
}
- private static native boolean nClipRect(int renderer, int left, int top,
+ private static native boolean nClipRect(long renderer, int left, int top,
int right, int bottom, int op);
@Override
@@ -542,21 +542,21 @@
return nClipRegion(mRenderer, region.mNativeRegion, op.nativeInt);
}
- private static native boolean nClipRegion(int renderer, int region, int op);
+ private static native boolean nClipRegion(long renderer, long region, int op);
@Override
public boolean getClipBounds(Rect bounds) {
return nGetClipBounds(mRenderer, bounds);
}
- private static native boolean nGetClipBounds(int renderer, Rect bounds);
+ private static native boolean nGetClipBounds(long renderer, Rect bounds);
@Override
public boolean quickReject(float left, float top, float right, float bottom, EdgeType type) {
return nQuickReject(mRenderer, left, top, right, bottom);
}
- private static native boolean nQuickReject(int renderer, float left, float top,
+ private static native boolean nQuickReject(long renderer, float left, float top,
float right, float bottom);
@Override
@@ -581,35 +581,35 @@
if (dx != 0.0f || dy != 0.0f) nTranslate(mRenderer, dx, dy);
}
- private static native void nTranslate(int renderer, float dx, float dy);
+ private static native void nTranslate(long renderer, float dx, float dy);
@Override
public void skew(float sx, float sy) {
nSkew(mRenderer, sx, sy);
}
- private static native void nSkew(int renderer, float sx, float sy);
+ private static native void nSkew(long renderer, float sx, float sy);
@Override
public void rotate(float degrees) {
nRotate(mRenderer, degrees);
}
- private static native void nRotate(int renderer, float degrees);
+ private static native void nRotate(long renderer, float degrees);
@Override
public void scale(float sx, float sy) {
nScale(mRenderer, sx, sy);
}
- private static native void nScale(int renderer, float sx, float sy);
+ private static native void nScale(long renderer, float sx, float sy);
@Override
public void setMatrix(Matrix matrix) {
nSetMatrix(mRenderer, matrix == null ? 0 : matrix.native_instance);
}
- private static native void nSetMatrix(int renderer, int matrix);
+ private static native void nSetMatrix(long renderer, long matrix);
@SuppressWarnings("deprecation")
@Override
@@ -617,14 +617,14 @@
nGetMatrix(mRenderer, matrix.native_instance);
}
- private static native void nGetMatrix(int renderer, int matrix);
+ private static native void nGetMatrix(long renderer, long matrix);
@Override
public void concat(Matrix matrix) {
if (matrix != null) nConcatMatrix(mRenderer, matrix.native_instance);
}
- private static native void nConcatMatrix(int renderer, int matrix);
+ private static native void nConcatMatrix(long renderer, long matrix);
///////////////////////////////////////////////////////////////////////////
// State management
@@ -640,7 +640,7 @@
return nSave(mRenderer, saveFlags);
}
- private static native int nSave(int renderer, int flags);
+ private static native int nSave(long renderer, int flags);
@Override
public int saveLayer(RectF bounds, Paint paint, int saveFlags) {
@@ -651,7 +651,7 @@
int count;
int modifier = paint != null ? setupColorFilter(paint) : MODIFIER_NONE;
try {
- final int nativePaint = paint == null ? 0 : paint.mNativePaint;
+ final long nativePaint = paint == null ? 0 : paint.mNativePaint;
count = nSaveLayer(mRenderer, nativePaint, saveFlags);
} finally {
if (modifier != MODIFIER_NONE) nResetModifiers(mRenderer, modifier);
@@ -659,7 +659,7 @@
return count;
}
- private static native int nSaveLayer(int renderer, int paint, int saveFlags);
+ private static native int nSaveLayer(long renderer, long paint, int saveFlags);
@Override
public int saveLayer(float left, float top, float right, float bottom, Paint paint,
@@ -668,7 +668,7 @@
int count;
int modifier = paint != null ? setupColorFilter(paint) : MODIFIER_NONE;
try {
- final int nativePaint = paint == null ? 0 : paint.mNativePaint;
+ final long nativePaint = paint == null ? 0 : paint.mNativePaint;
count = nSaveLayer(mRenderer, left, top, right, bottom, nativePaint, saveFlags);
} finally {
if (modifier != MODIFIER_NONE) nResetModifiers(mRenderer, modifier);
@@ -678,8 +678,8 @@
return save(saveFlags);
}
- private static native int nSaveLayer(int renderer, float left, float top,
- float right, float bottom, int paint, int saveFlags);
+ private static native int nSaveLayer(long renderer, float left, float top,
+ float right, float bottom, long paint, int saveFlags);
@Override
public int saveLayerAlpha(RectF bounds, int alpha, int saveFlags) {
@@ -690,7 +690,7 @@
return nSaveLayerAlpha(mRenderer, alpha, saveFlags);
}
- private static native int nSaveLayerAlpha(int renderer, int alpha, int saveFlags);
+ private static native int nSaveLayerAlpha(long renderer, int alpha, int saveFlags);
@Override
public int saveLayerAlpha(float left, float top, float right, float bottom, int alpha,
@@ -701,7 +701,7 @@
return save(saveFlags);
}
- private static native int nSaveLayerAlpha(int renderer, float left, float top, float right,
+ private static native int nSaveLayerAlpha(long renderer, float left, float top, float right,
float bottom, int alpha, int saveFlags);
@Override
@@ -709,21 +709,21 @@
nRestore(mRenderer);
}
- private static native void nRestore(int renderer);
+ private static native void nRestore(long renderer);
@Override
public void restoreToCount(int saveCount) {
nRestoreToCount(mRenderer, saveCount);
}
- private static native void nRestoreToCount(int renderer, int saveCount);
+ private static native void nRestoreToCount(long renderer, int saveCount);
@Override
public int getSaveCount() {
return nGetSaveCount(mRenderer);
}
- private static native int nGetSaveCount(int renderer);
+ private static native int nGetSaveCount(long renderer);
///////////////////////////////////////////////////////////////////////////
// Filtering
@@ -740,8 +740,8 @@
}
}
- private static native void nResetPaintFilter(int renderer);
- private static native void nSetupPaintFilter(int renderer, int clearBits, int setBits);
+ private static native void nResetPaintFilter(long renderer);
+ private static native void nSetupPaintFilter(long renderer, int clearBits, int setBits);
@Override
public DrawFilter getDrawFilter() {
@@ -764,9 +764,9 @@
}
}
- private static native void nDrawArc(int renderer, float left, float top,
+ private static native void nDrawArc(long renderer, float left, float top,
float right, float bottom, float startAngle, float sweepAngle,
- boolean useCenter, int paint);
+ boolean useCenter, long paint);
@Override
public void drawARGB(int a, int r, int g, int b) {
@@ -780,7 +780,7 @@
// Shaders are ignored when drawing patches
int modifier = paint != null ? setupColorFilter(paint) : MODIFIER_NONE;
try {
- final int nativePaint = paint == null ? 0 : paint.mNativePaint;
+ final long nativePaint = paint == null ? 0 : paint.mNativePaint;
nDrawPatch(mRenderer, bitmap.mNativeBitmap, bitmap.mBuffer, patch.mNativeChunk,
dst.left, dst.top, dst.right, dst.bottom, nativePaint);
} finally {
@@ -795,7 +795,7 @@
// Shaders are ignored when drawing patches
int modifier = paint != null ? setupColorFilter(paint) : MODIFIER_NONE;
try {
- final int nativePaint = paint == null ? 0 : paint.mNativePaint;
+ final long nativePaint = paint == null ? 0 : paint.mNativePaint;
nDrawPatch(mRenderer, bitmap.mNativeBitmap, bitmap.mBuffer, patch.mNativeChunk,
dst.left, dst.top, dst.right, dst.bottom, nativePaint);
} finally {
@@ -803,8 +803,8 @@
}
}
- private static native void nDrawPatch(int renderer, int bitmap, byte[] buffer, int chunk,
- float left, float top, float right, float bottom, int paint);
+ private static native void nDrawPatch(long renderer, long bitmap, byte[] buffer, long chunk,
+ float left, float top, float right, float bottom, long paint);
@Override
public void drawBitmap(Bitmap bitmap, float left, float top, Paint paint) {
@@ -812,15 +812,15 @@
// Shaders are ignored when drawing bitmaps
int modifiers = paint != null ? setupModifiers(bitmap, paint) : MODIFIER_NONE;
try {
- final int nativePaint = paint == null ? 0 : paint.mNativePaint;
+ final long nativePaint = paint == null ? 0 : paint.mNativePaint;
nDrawBitmap(mRenderer, bitmap.mNativeBitmap, bitmap.mBuffer, left, top, nativePaint);
} finally {
if (modifiers != MODIFIER_NONE) nResetModifiers(mRenderer, modifiers);
}
}
- private static native void nDrawBitmap(int renderer, int bitmap, byte[] buffer,
- float left, float top, int paint);
+ private static native void nDrawBitmap(long renderer, long bitmap, byte[] buffer,
+ float left, float top, long paint);
@Override
public void drawBitmap(Bitmap bitmap, Matrix matrix, Paint paint) {
@@ -828,7 +828,7 @@
// Shaders are ignored when drawing bitmaps
int modifiers = paint != null ? setupModifiers(bitmap, paint) : MODIFIER_NONE;
try {
- final int nativePaint = paint == null ? 0 : paint.mNativePaint;
+ final long nativePaint = paint == null ? 0 : paint.mNativePaint;
nDrawBitmap(mRenderer, bitmap.mNativeBitmap, bitmap.mBuffer,
matrix.native_instance, nativePaint);
} finally {
@@ -836,8 +836,8 @@
}
}
- private static native void nDrawBitmap(int renderer, int bitmap, byte[] buffer,
- int matrix, int paint);
+ private static native void nDrawBitmap(long renderer, long bitmap, byte[] buffer,
+ long matrix, long paint);
@Override
public void drawBitmap(Bitmap bitmap, Rect src, Rect dst, Paint paint) {
@@ -845,7 +845,7 @@
// Shaders are ignored when drawing bitmaps
int modifiers = paint != null ? setupModifiers(bitmap, paint) : MODIFIER_NONE;
try {
- final int nativePaint = paint == null ? 0 : paint.mNativePaint;
+ final long nativePaint = paint == null ? 0 : paint.mNativePaint;
int left, top, right, bottom;
if (src == null) {
@@ -872,7 +872,7 @@
// Shaders are ignored when drawing bitmaps
int modifiers = paint != null ? setupModifiers(bitmap, paint) : MODIFIER_NONE;
try {
- final int nativePaint = paint == null ? 0 : paint.mNativePaint;
+ final long nativePaint = paint == null ? 0 : paint.mNativePaint;
float left, top, right, bottom;
if (src == null) {
@@ -893,9 +893,9 @@
}
}
- private static native void nDrawBitmap(int renderer, int bitmap, byte[] buffer,
+ private static native void nDrawBitmap(long renderer, long bitmap, byte[] buffer,
float srcLeft, float srcTop, float srcRight, float srcBottom,
- float left, float top, float right, float bottom, int paint);
+ float left, float top, float right, float bottom, long paint);
@Override
public void drawBitmap(int[] colors, int offset, int stride, float x, float y,
@@ -923,7 +923,7 @@
// Shaders are ignored when drawing bitmaps
int modifier = paint != null ? setupColorFilter(paint) : MODIFIER_NONE;
try {
- final int nativePaint = paint == null ? 0 : paint.mNativePaint;
+ final long nativePaint = paint == null ? 0 : paint.mNativePaint;
nDrawBitmap(mRenderer, colors, offset, stride, x, y,
width, height, hasAlpha, nativePaint);
} finally {
@@ -931,8 +931,8 @@
}
}
- private static native void nDrawBitmap(int renderer, int[] colors, int offset, int stride,
- float x, float y, int width, int height, boolean hasAlpha, int nativePaint);
+ private static native void nDrawBitmap(long renderer, int[] colors, int offset, int stride,
+ float x, float y, int width, int height, boolean hasAlpha, long nativePaint);
@Override
public void drawBitmap(int[] colors, int offset, int stride, int x, int y,
@@ -962,7 +962,7 @@
int modifiers = paint != null ? setupModifiers(bitmap, paint) : MODIFIER_NONE;
try {
- final int nativePaint = paint == null ? 0 : paint.mNativePaint;
+ final long nativePaint = paint == null ? 0 : paint.mNativePaint;
nDrawBitmapMesh(mRenderer, bitmap.mNativeBitmap, bitmap.mBuffer, meshWidth, meshHeight,
verts, vertOffset, colors, colorOffset, nativePaint);
} finally {
@@ -970,9 +970,9 @@
}
}
- private static native void nDrawBitmapMesh(int renderer, int bitmap, byte[] buffer,
+ private static native void nDrawBitmapMesh(long renderer, long bitmap, byte[] buffer,
int meshWidth, int meshHeight, float[] verts, int vertOffset,
- int[] colors, int colorOffset, int paint);
+ int[] colors, int colorOffset, long paint);
@Override
public void drawCircle(float cx, float cy, float radius, Paint paint) {
@@ -984,8 +984,8 @@
}
}
- private static native void nDrawCircle(int renderer, float cx, float cy,
- float radius, int paint);
+ private static native void nDrawCircle(long renderer, float cx, float cy,
+ float radius, long paint);
@Override
public void drawColor(int color) {
@@ -997,7 +997,7 @@
nDrawColor(mRenderer, color, mode.nativeInt);
}
- private static native void nDrawColor(int renderer, int color, int mode);
+ private static native void nDrawColor(long renderer, int color, int mode);
@Override
public void drawLine(float startX, float startY, float stopX, float stopY, Paint paint) {
@@ -1024,8 +1024,8 @@
}
}
- private static native void nDrawLines(int renderer, float[] points,
- int offset, int count, int paint);
+ private static native void nDrawLines(long renderer, float[] points,
+ int offset, int count, long paint);
@Override
public void drawLines(float[] pts, Paint paint) {
@@ -1042,8 +1042,8 @@
}
}
- private static native void nDrawOval(int renderer, float left, float top,
- float right, float bottom, int paint);
+ private static native void nDrawOval(long renderer, float left, float top,
+ float right, float bottom, long paint);
@Override
public void drawPaint(Paint paint) {
@@ -1068,8 +1068,8 @@
}
}
- private static native void nDrawPath(int renderer, int path, int paint);
- private static native void nDrawRects(int renderer, int region, int paint);
+ private static native void nDrawPath(long renderer, long path, long paint);
+ private static native void nDrawRects(long renderer, long region, long paint);
void drawRects(float[] rects, int count, Paint paint) {
int modifiers = setupModifiers(paint, MODIFIER_COLOR_FILTER | MODIFIER_SHADER);
@@ -1080,7 +1080,7 @@
}
}
- private static native void nDrawRects(int renderer, float[] rects, int count, int paint);
+ private static native void nDrawRects(long renderer, float[] rects, int count, long paint);
@Override
public void drawPicture(Picture picture) {
@@ -1147,8 +1147,8 @@
}
}
- private static native void nDrawPoints(int renderer, float[] points,
- int offset, int count, int paint);
+ private static native void nDrawPoints(long renderer, float[] points,
+ int offset, int count, long paint);
@SuppressWarnings("deprecation")
@Override
@@ -1165,8 +1165,8 @@
}
}
- private static native void nDrawPosText(int renderer, char[] text, int index, int count,
- float[] pos, int paint);
+ private static native void nDrawPosText(long renderer, char[] text, int index, int count,
+ float[] pos, long paint);
@SuppressWarnings("deprecation")
@Override
@@ -1183,8 +1183,8 @@
}
}
- private static native void nDrawPosText(int renderer, String text, int start, int end,
- float[] pos, int paint);
+ private static native void nDrawPosText(long renderer, String text, int start, int end,
+ float[] pos, long paint);
@Override
public void drawRect(float left, float top, float right, float bottom, Paint paint) {
@@ -1197,8 +1197,8 @@
}
}
- private static native void nDrawRect(int renderer, float left, float top,
- float right, float bottom, int paint);
+ private static native void nDrawRect(long renderer, float left, float top,
+ float right, float bottom, long paint);
@Override
public void drawRect(Rect r, Paint paint) {
@@ -1226,8 +1226,8 @@
}
}
- private static native void nDrawRoundRect(int renderer, float left, float top,
- float right, float bottom, float rx, float y, int paint);
+ private static native void nDrawRoundRect(long renderer, float left, float top,
+ float right, float bottom, float rx, float y, long paint);
@Override
public void drawText(char[] text, int index, int count, float x, float y, Paint paint) {
@@ -1243,8 +1243,8 @@
}
}
- private static native void nDrawText(int renderer, char[] text, int index, int count,
- float x, float y, int bidiFlags, int paint);
+ private static native void nDrawText(long renderer, char[] text, int index, int count,
+ float x, float y, int bidiFlags, long paint);
@Override
public void drawText(CharSequence text, int start, int end, float x, float y, Paint paint) {
@@ -1283,8 +1283,8 @@
}
}
- private static native void nDrawText(int renderer, String text, int start, int end,
- float x, float y, int bidiFlags, int paint);
+ private static native void nDrawText(long renderer, String text, int start, int end,
+ float x, float y, int bidiFlags, long paint);
@Override
public void drawText(String text, float x, float y, Paint paint) {
@@ -1313,8 +1313,8 @@
}
}
- private static native void nDrawTextOnPath(int renderer, char[] text, int index, int count,
- int path, float hOffset, float vOffset, int bidiFlags, int nativePaint);
+ private static native void nDrawTextOnPath(long renderer, char[] text, int index, int count,
+ long path, float hOffset, float vOffset, int bidiFlags, long nativePaint);
@Override
public void drawTextOnPath(String text, Path path, float hOffset, float vOffset, Paint paint) {
@@ -1329,8 +1329,8 @@
}
}
- private static native void nDrawTextOnPath(int renderer, String text, int start, int end,
- int path, float hOffset, float vOffset, int bidiFlags, int nativePaint);
+ private static native void nDrawTextOnPath(long renderer, String text, int start, int end,
+ long path, float hOffset, float vOffset, int bidiFlags, long nativePaint);
@Override
public void drawTextRun(char[] text, int index, int count, int contextIndex, int contextCount,
@@ -1351,8 +1351,8 @@
}
}
- private static native void nDrawTextRun(int renderer, char[] text, int index, int count,
- int contextIndex, int contextCount, float x, float y, int dir, int nativePaint);
+ private static native void nDrawTextRun(long renderer, char[] text, int index, int count,
+ int contextIndex, int contextCount, float x, float y, int dir, long nativePaint);
@Override
public void drawTextRun(CharSequence text, int start, int end, int contextStart, int contextEnd,
@@ -1385,8 +1385,8 @@
}
}
- private static native void nDrawTextRun(int renderer, String text, int start, int end,
- int contextStart, int contextEnd, float x, float y, int flags, int nativePaint);
+ private static native void nDrawTextRun(long renderer, String text, int start, int end,
+ int contextStart, int contextEnd, float x, float y, int flags, long nativePaint);
@Override
public void drawVertices(VertexMode mode, int vertexCount, float[] verts, int vertOffset,
@@ -1466,10 +1466,10 @@
return MODIFIER_NONE;
}
- private static native void nSetupShader(int renderer, int shader);
- private static native void nSetupColorFilter(int renderer, int colorFilter);
- private static native void nSetupShadow(int renderer, float radius,
+ private static native void nSetupShader(long renderer, long shader);
+ private static native void nSetupColorFilter(long renderer, long colorFilter);
+ private static native void nSetupShadow(long renderer, float radius,
float dx, float dy, int color);
- private static native void nResetModifiers(int renderer, int modifiers);
+ private static native void nResetModifiers(long renderer, int modifiers);
}
diff --git a/core/java/android/view/GLES20DisplayList.java b/core/java/android/view/GLES20DisplayList.java
index c652bac..7f8b3bd 100644
--- a/core/java/android/view/GLES20DisplayList.java
+++ b/core/java/android/view/GLES20DisplayList.java
@@ -44,7 +44,7 @@
return mValid && mFinalizer != null;
}
- int getNativeDisplayList() {
+ long getNativeDisplayList() {
if (!mValid || mFinalizer == null) {
throw new IllegalStateException("The display list is not valid.");
}
@@ -124,9 +124,9 @@
return nGetDisplayListSize(mFinalizer.mNativeDisplayList);
}
- private static native void nDestroyDisplayList(int displayList);
- private static native int nGetDisplayListSize(int displayList);
- private static native void nSetDisplayListName(int displayList, String name);
+ private static native void nDestroyDisplayList(long displayList);
+ private static native int nGetDisplayListSize(long displayList);
+ private static native void nSetDisplayListName(long displayList, String name);
///////////////////////////////////////////////////////////////////////////
// Native View Properties
@@ -440,62 +440,62 @@
}
}
- private static native void nReset(int displayList);
- private static native void nOffsetTopAndBottom(int displayList, float offset);
- private static native void nOffsetLeftAndRight(int displayList, float offset);
- private static native void nSetLeftTopRightBottom(int displayList, int left, int top,
+ private static native void nReset(long displayList);
+ private static native void nOffsetTopAndBottom(long displayList, float offset);
+ private static native void nOffsetLeftAndRight(long displayList, float offset);
+ private static native void nSetLeftTopRightBottom(long displayList, int left, int top,
int right, int bottom);
- private static native void nSetBottom(int displayList, int bottom);
- private static native void nSetRight(int displayList, int right);
- private static native void nSetTop(int displayList, int top);
- private static native void nSetLeft(int displayList, int left);
- private static native void nSetCameraDistance(int displayList, float distance);
- private static native void nSetPivotY(int displayList, float pivotY);
- private static native void nSetPivotX(int displayList, float pivotX);
- private static native void nSetCaching(int displayList, boolean caching);
- private static native void nSetClipToBounds(int displayList, boolean clipToBounds);
- private static native void nSetAlpha(int displayList, float alpha);
- private static native void nSetHasOverlappingRendering(int displayList,
+ private static native void nSetBottom(long displayList, int bottom);
+ private static native void nSetRight(long displayList, int right);
+ private static native void nSetTop(long displayList, int top);
+ private static native void nSetLeft(long displayList, int left);
+ private static native void nSetCameraDistance(long displayList, float distance);
+ private static native void nSetPivotY(long displayList, float pivotY);
+ private static native void nSetPivotX(long displayList, float pivotX);
+ private static native void nSetCaching(long displayList, boolean caching);
+ private static native void nSetClipToBounds(long displayList, boolean clipToBounds);
+ private static native void nSetAlpha(long displayList, float alpha);
+ private static native void nSetHasOverlappingRendering(long displayList,
boolean hasOverlappingRendering);
- private static native void nSetTranslationX(int displayList, float translationX);
- private static native void nSetTranslationY(int displayList, float translationY);
- private static native void nSetRotation(int displayList, float rotation);
- private static native void nSetRotationX(int displayList, float rotationX);
- private static native void nSetRotationY(int displayList, float rotationY);
- private static native void nSetScaleX(int displayList, float scaleX);
- private static native void nSetScaleY(int displayList, float scaleY);
- private static native void nSetTransformationInfo(int displayList, float alpha,
+ private static native void nSetTranslationX(long displayList, float translationX);
+ private static native void nSetTranslationY(long displayList, float translationY);
+ private static native void nSetRotation(long displayList, float rotation);
+ private static native void nSetRotationX(long displayList, float rotationX);
+ private static native void nSetRotationY(long displayList, float rotationY);
+ private static native void nSetScaleX(long displayList, float scaleX);
+ private static native void nSetScaleY(long displayList, float scaleY);
+ private static native void nSetTransformationInfo(long displayList, float alpha,
float translationX, float translationY, float rotation, float rotationX,
float rotationY, float scaleX, float scaleY);
- private static native void nSetStaticMatrix(int displayList, int nativeMatrix);
- private static native void nSetAnimationMatrix(int displayList, int animationMatrix);
+ private static native void nSetStaticMatrix(long displayList, long nativeMatrix);
+ private static native void nSetAnimationMatrix(long displayList, long animationMatrix);
- private static native boolean nHasOverlappingRendering(int displayList);
- private static native void nGetMatrix(int displayList, int matrix);
- private static native float nGetAlpha(int displayList);
- private static native float nGetLeft(int displayList);
- private static native float nGetTop(int displayList);
- private static native float nGetRight(int displayList);
- private static native float nGetBottom(int displayList);
- private static native float nGetCameraDistance(int displayList);
- private static native float nGetScaleX(int displayList);
- private static native float nGetScaleY(int displayList);
- private static native float nGetTranslationX(int displayList);
- private static native float nGetTranslationY(int displayList);
- private static native float nGetRotation(int displayList);
- private static native float nGetRotationX(int displayList);
- private static native float nGetRotationY(int displayList);
- private static native float nGetPivotX(int displayList);
- private static native float nGetPivotY(int displayList);
+ private static native boolean nHasOverlappingRendering(long displayList);
+ private static native void nGetMatrix(long displayList, long matrix);
+ private static native float nGetAlpha(long displayList);
+ private static native float nGetLeft(long displayList);
+ private static native float nGetTop(long displayList);
+ private static native float nGetRight(long displayList);
+ private static native float nGetBottom(long displayList);
+ private static native float nGetCameraDistance(long displayList);
+ private static native float nGetScaleX(long displayList);
+ private static native float nGetScaleY(long displayList);
+ private static native float nGetTranslationX(long displayList);
+ private static native float nGetTranslationY(long displayList);
+ private static native float nGetRotation(long displayList);
+ private static native float nGetRotationX(long displayList);
+ private static native float nGetRotationY(long displayList);
+ private static native float nGetPivotX(long displayList);
+ private static native float nGetPivotY(long displayList);
///////////////////////////////////////////////////////////////////////////
// Finalization
///////////////////////////////////////////////////////////////////////////
private static class DisplayListFinalizer {
- final int mNativeDisplayList;
+ final long mNativeDisplayList;
- public DisplayListFinalizer(int nativeDisplayList) {
+ public DisplayListFinalizer(long nativeDisplayList) {
mNativeDisplayList = nativeDisplayList;
}
diff --git a/core/java/android/view/GLES20Layer.java b/core/java/android/view/GLES20Layer.java
index 0e3311c..37154eb 100644
--- a/core/java/android/view/GLES20Layer.java
+++ b/core/java/android/view/GLES20Layer.java
@@ -24,7 +24,7 @@
* An OpenGL ES 2.0 implementation of {@link HardwareLayer}.
*/
abstract class GLES20Layer extends HardwareLayer {
- int mLayer;
+ long mLayer;
Finalizer mFinalizer;
GLES20Layer() {
@@ -39,7 +39,7 @@
*
* @return A pointer to the native layer object, or 0 if the object is NULL
*/
- public int getLayer() {
+ public long getLayer() {
return mLayer;
}
@@ -75,9 +75,9 @@
}
static class Finalizer {
- private int mLayerId;
+ private long mLayerId;
- public Finalizer(int layerId) {
+ public Finalizer(long layerId) {
mLayerId = layerId;
}
diff --git a/core/java/android/view/GLES20RecordingCanvas.java b/core/java/android/view/GLES20RecordingCanvas.java
index b6fc38d..e3e1c76 100644
--- a/core/java/android/view/GLES20RecordingCanvas.java
+++ b/core/java/android/view/GLES20RecordingCanvas.java
@@ -58,7 +58,7 @@
mDisplayList.clearReferences();
}
- int end(int nativeDisplayList) {
+ long end(long nativeDisplayList) {
return getDisplayList(nativeDisplayList);
}
diff --git a/core/java/android/view/GraphicBuffer.java b/core/java/android/view/GraphicBuffer.java
index 30c077c..5f2a9cd 100644
--- a/core/java/android/view/GraphicBuffer.java
+++ b/core/java/android/view/GraphicBuffer.java
@@ -56,7 +56,7 @@
private final int mFormat;
private final int mUsage;
// Note: do not rename, this field is used by native code
- private final int mNativeObject;
+ private final long mNativeObject;
// These two fields are only used by lock/unlockCanvas()
private Canvas mCanvas;
@@ -77,7 +77,7 @@
* @return A <code>GraphicBuffer</code> instance or null
*/
public static GraphicBuffer create(int width, int height, int format, int usage) {
- int nativeObject = nCreateGraphicBuffer(width, height, format, usage);
+ long nativeObject = nCreateGraphicBuffer(width, height, format, usage);
if (nativeObject != 0) {
return new GraphicBuffer(width, height, format, usage, nativeObject);
}
@@ -87,7 +87,7 @@
/**
* Private use only. See {@link #create(int, int, int, int)}.
*/
- private GraphicBuffer(int width, int height, int format, int usage, int nativeObject) {
+ private GraphicBuffer(int width, int height, int format, int usage, long nativeObject) {
mWidth = width;
mHeight = height;
mFormat = format;
@@ -271,7 +271,7 @@
int height = in.readInt();
int format = in.readInt();
int usage = in.readInt();
- int nativeObject = nReadGraphicBufferFromParcel(in);
+ long nativeObject = nReadGraphicBufferFromParcel(in);
if (nativeObject != 0) {
return new GraphicBuffer(width, height, format, usage, nativeObject);
}
@@ -283,10 +283,10 @@
}
};
- private static native int nCreateGraphicBuffer(int width, int height, int format, int usage);
- private static native void nDestroyGraphicBuffer(int nativeObject);
- private static native void nWriteGraphicBufferToParcel(int nativeObject, Parcel dest);
- private static native int nReadGraphicBufferFromParcel(Parcel in);
- private static native boolean nLockCanvas(int nativeObject, Canvas canvas, Rect dirty);
- private static native boolean nUnlockCanvasAndPost(int nativeObject, Canvas canvas);
+ private static native long nCreateGraphicBuffer(int width, int height, int format, int usage);
+ private static native void nDestroyGraphicBuffer(long nativeObject);
+ private static native void nWriteGraphicBufferToParcel(long nativeObject, Parcel dest);
+ private static native long nReadGraphicBufferFromParcel(Parcel in);
+ private static native boolean nLockCanvas(long nativeObject, Canvas canvas, Rect dirty);
+ private static native boolean nUnlockCanvasAndPost(long nativeObject, Canvas canvas);
}
diff --git a/core/java/android/view/HardwareCanvas.java b/core/java/android/view/HardwareCanvas.java
index 259e1cd..10f700c 100644
--- a/core/java/android/view/HardwareCanvas.java
+++ b/core/java/android/view/HardwareCanvas.java
@@ -145,7 +145,7 @@
*
* @hide
*/
- public int callDrawGLFunction(int drawGLFunction) {
+ public int callDrawGLFunction(long drawGLFunction) {
// Noop - this is done in the display list recorder subclass
return DisplayList.STATUS_DONE;
}
@@ -170,12 +170,12 @@
* @param functor The native functor to remove from the execution queue.
*
* @see #invokeFunctors(android.graphics.Rect)
- * @see #callDrawGLFunction(int)
- * @see #detachFunctor(int)
+ * @see #callDrawGLFunction(long)
+ * @see #detachFunctor(long)
*
* @hide
*/
- abstract void detachFunctor(int functor);
+ abstract void detachFunctor(long functor);
/**
* Attaches the specified functor to the current functor execution queue.
@@ -183,12 +183,12 @@
* @param functor The native functor to add to the execution queue.
*
* @see #invokeFunctors(android.graphics.Rect)
- * @see #callDrawGLFunction(int)
- * @see #detachFunctor(int)
+ * @see #callDrawGLFunction(long)
+ * @see #detachFunctor(long)
*
* @hide
*/
- abstract void attachFunctor(int functor);
+ abstract void attachFunctor(long functor);
/**
* Indicates that the specified layer must be updated as soon as possible.
diff --git a/core/java/android/view/HardwareRenderer.java b/core/java/android/view/HardwareRenderer.java
index f215189..f09a111 100644
--- a/core/java/android/view/HardwareRenderer.java
+++ b/core/java/android/view/HardwareRenderer.java
@@ -568,7 +568,7 @@
* @see HardwareCanvas#callDrawGLFunction(int)
* @see #attachFunctor(android.view.View.AttachInfo, int)
*/
- abstract void detachFunctor(int functor);
+ abstract void detachFunctor(long functor);
/**
* Schedules the specified functor in the functors execution queue.
@@ -581,7 +581,7 @@
*
* @return true if the functor was attached successfully
*/
- abstract boolean attachFunctor(View.AttachInfo attachInfo, int functor);
+ abstract boolean attachFunctor(View.AttachInfo attachInfo, long functor);
/**
* Initializes the hardware renderer for the specified surface and setup the
@@ -1712,14 +1712,14 @@
}
@Override
- void detachFunctor(int functor) {
+ void detachFunctor(long functor) {
if (mCanvas != null) {
mCanvas.detachFunctor(functor);
}
}
@Override
- boolean attachFunctor(View.AttachInfo attachInfo, int functor) {
+ boolean attachFunctor(View.AttachInfo attachInfo, long functor) {
if (mCanvas != null) {
mCanvas.attachFunctor(functor);
mFunctorsRunnable.attachInfo = attachInfo;
@@ -1981,7 +1981,7 @@
if (atlas.isCompatible(android.os.Process.myPpid())) {
GraphicBuffer buffer = atlas.getBuffer();
if (buffer != null) {
- int[] map = atlas.getMap();
+ long[] map = atlas.getMap();
if (map != null) {
GLES20Canvas.initAtlas(buffer, map);
}
diff --git a/core/java/android/view/IAssetAtlas.aidl b/core/java/android/view/IAssetAtlas.aidl
index 5f1e238..edce059 100644
--- a/core/java/android/view/IAssetAtlas.aidl
+++ b/core/java/android/view/IAssetAtlas.aidl
@@ -45,10 +45,10 @@
* if the atlas is not available yet.
*
* Each bitmap is represented by several entries in the array:
- * int0: SkBitmap*, the native bitmap object
- * int1: x position
- * int2: y position
- * int3: rotated, 1 if the bitmap must be rotated, 0 otherwise
+ * long0: SkBitmap*, the native bitmap object
+ * long1: x position
+ * long2: y position
+ * long3: rotated, 1 if the bitmap must be rotated, 0 otherwise
*/
- int[] getMap();
+ long[] getMap();
}
diff --git a/core/java/android/view/InputChannel.java b/core/java/android/view/InputChannel.java
index 40ee1ad..de195ae 100644
--- a/core/java/android/view/InputChannel.java
+++ b/core/java/android/view/InputChannel.java
@@ -46,7 +46,7 @@
};
@SuppressWarnings("unused")
- private int mPtr; // used by native code
+ private long mPtr; // used by native code
private static native InputChannel[] nativeOpenInputChannelPair(String name);
diff --git a/core/java/android/view/InputEventReceiver.java b/core/java/android/view/InputEventReceiver.java
index 25972e7..91ef50d 100644
--- a/core/java/android/view/InputEventReceiver.java
+++ b/core/java/android/view/InputEventReceiver.java
@@ -34,7 +34,7 @@
private final CloseGuard mCloseGuard = CloseGuard.get();
- private int mReceiverPtr;
+ private long mReceiverPtr;
// We keep references to the input channel and message queue objects here so that
// they are not GC'd while the native peer of the receiver is using them.
@@ -44,11 +44,11 @@
// Map from InputEvent sequence numbers to dispatcher sequence numbers.
private final SparseIntArray mSeqMap = new SparseIntArray();
- private static native int nativeInit(WeakReference<InputEventReceiver> receiver,
+ private static native long nativeInit(WeakReference<InputEventReceiver> receiver,
InputChannel inputChannel, MessageQueue messageQueue);
- private static native void nativeDispose(int receiverPtr);
- private static native void nativeFinishInputEvent(int receiverPtr, int seq, boolean handled);
- private static native boolean nativeConsumeBatchedInputEvents(int receiverPtr,
+ private static native void nativeDispose(long receiverPtr);
+ private static native void nativeFinishInputEvent(long receiverPtr, int seq, boolean handled);
+ private static native boolean nativeConsumeBatchedInputEvents(long receiverPtr,
long frameTimeNanos);
/**
diff --git a/core/java/android/view/InputEventSender.java b/core/java/android/view/InputEventSender.java
index be6a623..304ea3f 100644
--- a/core/java/android/view/InputEventSender.java
+++ b/core/java/android/view/InputEventSender.java
@@ -33,18 +33,18 @@
private final CloseGuard mCloseGuard = CloseGuard.get();
- private int mSenderPtr;
+ private long mSenderPtr;
// We keep references to the input channel and message queue objects here so that
// they are not GC'd while the native peer of the receiver is using them.
private InputChannel mInputChannel;
private MessageQueue mMessageQueue;
- private static native int nativeInit(WeakReference<InputEventSender> sender,
+ private static native long nativeInit(WeakReference<InputEventSender> sender,
InputChannel inputChannel, MessageQueue messageQueue);
- private static native void nativeDispose(int senderPtr);
- private static native boolean nativeSendKeyEvent(int senderPtr, int seq, KeyEvent event);
- private static native boolean nativeSendMotionEvent(int senderPtr, int seq, MotionEvent event);
+ private static native void nativeDispose(long senderPtr);
+ private static native boolean nativeSendKeyEvent(long senderPtr, int seq, KeyEvent event);
+ private static native boolean nativeSendMotionEvent(long senderPtr, int seq, MotionEvent event);
/**
* Creates an input event sender bound to the specified input channel.
diff --git a/core/java/android/view/InputQueue.java b/core/java/android/view/InputQueue.java
index e3de89d..d5cec49 100644
--- a/core/java/android/view/InputQueue.java
+++ b/core/java/android/view/InputQueue.java
@@ -23,7 +23,7 @@
import android.os.MessageQueue;
import android.util.Pools.Pool;
import android.util.Pools.SimplePool;
-import android.util.SparseArray;
+import android.util.LongSparseArray;
import java.lang.ref.WeakReference;
@@ -32,20 +32,20 @@
* input events. Currently only usable from native code.
*/
public final class InputQueue {
- private final SparseArray<ActiveInputEvent> mActiveEventArray =
- new SparseArray<ActiveInputEvent>(20);
+ private final LongSparseArray<ActiveInputEvent> mActiveEventArray =
+ new LongSparseArray<ActiveInputEvent>(20);
private final Pool<ActiveInputEvent> mActiveInputEventPool =
new SimplePool<ActiveInputEvent>(20);
private final CloseGuard mCloseGuard = CloseGuard.get();
- private int mPtr;
+ private long mPtr;
- private static native int nativeInit(WeakReference<InputQueue> weakQueue,
+ private static native long nativeInit(WeakReference<InputQueue> weakQueue,
MessageQueue messageQueue);
- private static native int nativeSendKeyEvent(int ptr, KeyEvent e, boolean preDispatch);
- private static native int nativeSendMotionEvent(int ptr, MotionEvent e);
- private static native void nativeDispose(int ptr);
+ private static native long nativeSendKeyEvent(long ptr, KeyEvent e, boolean preDispatch);
+ private static native long nativeSendMotionEvent(long ptr, MotionEvent e);
+ private static native void nativeDispose(long ptr);
/** @hide */
public InputQueue() {
@@ -84,7 +84,7 @@
}
/** @hide */
- public int getNativePtr() {
+ public long getNativePtr() {
return mPtr;
}
@@ -92,7 +92,7 @@
public void sendInputEvent(InputEvent e, Object token, boolean predispatch,
FinishedInputEventCallback callback) {
ActiveInputEvent event = obtainActiveInputEvent(token, callback);
- int id;
+ long id;
if (e instanceof KeyEvent) {
id = nativeSendKeyEvent(mPtr, (KeyEvent) e, predispatch);
} else {
@@ -101,7 +101,7 @@
mActiveEventArray.put(id, event);
}
- private void finishInputEvent(int id, boolean handled) {
+ private void finishInputEvent(long id, boolean handled) {
int index = mActiveEventArray.indexOfKey(id);
if (index >= 0) {
ActiveInputEvent e = mActiveEventArray.valueAt(index);
diff --git a/core/java/android/view/KeyCharacterMap.java b/core/java/android/view/KeyCharacterMap.java
index 9e5f25a..55dd6bb 100644
--- a/core/java/android/view/KeyCharacterMap.java
+++ b/core/java/android/view/KeyCharacterMap.java
@@ -282,20 +282,20 @@
}
};
- private int mPtr;
+ private long mPtr;
- private static native int nativeReadFromParcel(Parcel in);
- private static native void nativeWriteToParcel(int ptr, Parcel out);
- private static native void nativeDispose(int ptr);
+ private static native long nativeReadFromParcel(Parcel in);
+ private static native void nativeWriteToParcel(long ptr, Parcel out);
+ private static native void nativeDispose(long ptr);
- private static native char nativeGetCharacter(int ptr, int keyCode, int metaState);
- private static native boolean nativeGetFallbackAction(int ptr, int keyCode, int metaState,
+ private static native char nativeGetCharacter(long ptr, int keyCode, int metaState);
+ private static native boolean nativeGetFallbackAction(long ptr, int keyCode, int metaState,
FallbackAction outFallbackAction);
- private static native char nativeGetNumber(int ptr, int keyCode);
- private static native char nativeGetMatch(int ptr, int keyCode, char[] chars, int metaState);
- private static native char nativeGetDisplayLabel(int ptr, int keyCode);
- private static native int nativeGetKeyboardType(int ptr);
- private static native KeyEvent[] nativeGetEvents(int ptr, char[] chars);
+ private static native char nativeGetNumber(long ptr, int keyCode);
+ private static native char nativeGetMatch(long ptr, int keyCode, char[] chars, int metaState);
+ private static native char nativeGetDisplayLabel(long ptr, int keyCode);
+ private static native int nativeGetKeyboardType(long ptr);
+ private static native KeyEvent[] nativeGetEvents(long ptr, char[] chars);
private KeyCharacterMap(Parcel in) {
if (in == null) {
@@ -308,7 +308,7 @@
}
// Called from native
- private KeyCharacterMap(int ptr) {
+ private KeyCharacterMap(long ptr) {
mPtr = ptr;
}
diff --git a/core/java/android/view/LayoutInflater.java b/core/java/android/view/LayoutInflater.java
index aa43bad..cd905fa 100644
--- a/core/java/android/view/LayoutInflater.java
+++ b/core/java/android/view/LayoutInflater.java
@@ -591,6 +591,7 @@
Object[] args = mConstructorArgs;
args[1] = attrs;
+ constructor.setAccessible(true);
final View view = constructor.newInstance(args);
if (view instanceof ViewStub) {
// always use ourselves when inflating ViewStub later
diff --git a/core/java/android/view/MotionEvent.java b/core/java/android/view/MotionEvent.java
index db577f3..ddce3ce 100644
--- a/core/java/android/view/MotionEvent.java
+++ b/core/java/android/view/MotionEvent.java
@@ -1311,63 +1311,63 @@
}
// Pointer to the native MotionEvent object that contains the actual data.
- private int mNativePtr;
+ private long mNativePtr;
private MotionEvent mNext;
- private static native int nativeInitialize(int nativePtr,
+ private static native long nativeInitialize(long nativePtr,
int deviceId, int source, int action, int flags, int edgeFlags,
int metaState, int buttonState,
float xOffset, float yOffset, float xPrecision, float yPrecision,
long downTimeNanos, long eventTimeNanos,
int pointerCount, PointerProperties[] pointerIds, PointerCoords[] pointerCoords);
- private static native int nativeCopy(int destNativePtr, int sourceNativePtr,
+ private static native long nativeCopy(long destNativePtr, long sourceNativePtr,
boolean keepHistory);
- private static native void nativeDispose(int nativePtr);
- private static native void nativeAddBatch(int nativePtr, long eventTimeNanos,
+ private static native void nativeDispose(long nativePtr);
+ private static native void nativeAddBatch(long nativePtr, long eventTimeNanos,
PointerCoords[] pointerCoords, int metaState);
- private static native int nativeGetDeviceId(int nativePtr);
- private static native int nativeGetSource(int nativePtr);
- private static native int nativeSetSource(int nativePtr, int source);
- private static native int nativeGetAction(int nativePtr);
- private static native void nativeSetAction(int nativePtr, int action);
- private static native boolean nativeIsTouchEvent(int nativePtr);
- private static native int nativeGetFlags(int nativePtr);
- private static native void nativeSetFlags(int nativePtr, int flags);
- private static native int nativeGetEdgeFlags(int nativePtr);
- private static native void nativeSetEdgeFlags(int nativePtr, int action);
- private static native int nativeGetMetaState(int nativePtr);
- private static native int nativeGetButtonState(int nativePtr);
- private static native void nativeOffsetLocation(int nativePtr, float deltaX, float deltaY);
- private static native float nativeGetXOffset(int nativePtr);
- private static native float nativeGetYOffset(int nativePtr);
- private static native float nativeGetXPrecision(int nativePtr);
- private static native float nativeGetYPrecision(int nativePtr);
- private static native long nativeGetDownTimeNanos(int nativePtr);
- private static native void nativeSetDownTimeNanos(int nativePtr, long downTime);
+ private static native int nativeGetDeviceId(long nativePtr);
+ private static native int nativeGetSource(long nativePtr);
+ private static native int nativeSetSource(long nativePtr, int source);
+ private static native int nativeGetAction(long nativePtr);
+ private static native void nativeSetAction(long nativePtr, int action);
+ private static native boolean nativeIsTouchEvent(long nativePtr);
+ private static native int nativeGetFlags(long nativePtr);
+ private static native void nativeSetFlags(long nativePtr, int flags);
+ private static native int nativeGetEdgeFlags(long nativePtr);
+ private static native void nativeSetEdgeFlags(long nativePtr, int action);
+ private static native int nativeGetMetaState(long nativePtr);
+ private static native int nativeGetButtonState(long nativePtr);
+ private static native void nativeOffsetLocation(long nativePtr, float deltaX, float deltaY);
+ private static native float nativeGetXOffset(long nativePtr);
+ private static native float nativeGetYOffset(long nativePtr);
+ private static native float nativeGetXPrecision(long nativePtr);
+ private static native float nativeGetYPrecision(long nativePtr);
+ private static native long nativeGetDownTimeNanos(long nativePtr);
+ private static native void nativeSetDownTimeNanos(long nativePtr, long downTime);
- private static native int nativeGetPointerCount(int nativePtr);
- private static native int nativeGetPointerId(int nativePtr, int pointerIndex);
- private static native int nativeGetToolType(int nativePtr, int pointerIndex);
- private static native int nativeFindPointerIndex(int nativePtr, int pointerId);
+ private static native int nativeGetPointerCount(long nativePtr);
+ private static native int nativeGetPointerId(long nativePtr, int pointerIndex);
+ private static native int nativeGetToolType(long nativePtr, int pointerIndex);
+ private static native int nativeFindPointerIndex(long nativePtr, int pointerId);
- private static native int nativeGetHistorySize(int nativePtr);
- private static native long nativeGetEventTimeNanos(int nativePtr, int historyPos);
- private static native float nativeGetRawAxisValue(int nativePtr,
+ private static native int nativeGetHistorySize(long nativePtr);
+ private static native long nativeGetEventTimeNanos(long nativePtr, int historyPos);
+ private static native float nativeGetRawAxisValue(long nativePtr,
int axis, int pointerIndex, int historyPos);
- private static native float nativeGetAxisValue(int nativePtr,
+ private static native float nativeGetAxisValue(long nativePtr,
int axis, int pointerIndex, int historyPos);
- private static native void nativeGetPointerCoords(int nativePtr,
+ private static native void nativeGetPointerCoords(long nativePtr,
int pointerIndex, int historyPos, PointerCoords outPointerCoords);
- private static native void nativeGetPointerProperties(int nativePtr,
+ private static native void nativeGetPointerProperties(long nativePtr,
int pointerIndex, PointerProperties outPointerProperties);
- private static native void nativeScale(int nativePtr, float scale);
- private static native void nativeTransform(int nativePtr, Matrix matrix);
+ private static native void nativeScale(long nativePtr, float scale);
+ private static native void nativeTransform(long nativePtr, Matrix matrix);
- private static native int nativeReadFromParcel(int nativePtr, Parcel parcel);
- private static native void nativeWriteToParcel(int nativePtr, Parcel parcel);
+ private static native long nativeReadFromParcel(long nativePtr, Parcel parcel);
+ private static native void nativeWriteToParcel(long nativePtr, Parcel parcel);
private MotionEvent() {
}
diff --git a/core/java/android/view/Surface.java b/core/java/android/view/Surface.java
index 1bfda2d..91645e7 100644
--- a/core/java/android/view/Surface.java
+++ b/core/java/android/view/Surface.java
@@ -32,19 +32,19 @@
public class Surface implements Parcelable {
private static final String TAG = "Surface";
- private static native int nativeCreateFromSurfaceTexture(SurfaceTexture surfaceTexture)
+ private static native long nativeCreateFromSurfaceTexture(SurfaceTexture surfaceTexture)
throws OutOfResourcesException;
- private static native int nativeCreateFromSurfaceControl(int surfaceControlNativeObject);
+ private static native long nativeCreateFromSurfaceControl(long surfaceControlNativeObject);
- private static native int nativeLockCanvas(int nativeObject, Canvas canvas, Rect dirty)
+ private static native long nativeLockCanvas(long nativeObject, Canvas canvas, Rect dirty)
throws OutOfResourcesException;
- private static native void nativeUnlockCanvasAndPost(int nativeObject, Canvas canvas);
+ private static native void nativeUnlockCanvasAndPost(long nativeObject, Canvas canvas);
- private static native void nativeRelease(int nativeObject);
- private static native boolean nativeIsValid(int nativeObject);
- private static native boolean nativeIsConsumerRunningBehind(int nativeObject);
- private static native int nativeReadFromParcel(int nativeObject, Parcel source);
- private static native void nativeWriteToParcel(int nativeObject, Parcel dest);
+ private static native void nativeRelease(long nativeObject);
+ private static native boolean nativeIsValid(long nativeObject);
+ private static native boolean nativeIsConsumerRunningBehind(long nativeObject);
+ private static native long nativeReadFromParcel(long nativeObject, Parcel source);
+ private static native void nativeWriteToParcel(long nativeObject, Parcel dest);
public static final Parcelable.Creator<Surface> CREATOR =
new Parcelable.Creator<Surface>() {
@@ -71,8 +71,8 @@
// Guarded state.
final Object mLock = new Object(); // protects the native state
private String mName;
- int mNativeObject; // package scope only for SurfaceControl access
- private int mLockedObject;
+ long mNativeObject; // package scope only for SurfaceControl access
+ private long mLockedObject;
private int mGenerationId; // incremented each time mNativeObject changes
private final Canvas mCanvas = new CompatibleCanvas();
@@ -130,7 +130,7 @@
}
/* called from android_view_Surface_createFromIGraphicBufferProducer() */
- private Surface(int nativeObject) {
+ private Surface(long nativeObject) {
synchronized (mLock) {
setNativeObjectLocked(nativeObject);
}
@@ -261,8 +261,8 @@
checkNotReleasedLocked();
if (mNativeObject != mLockedObject) {
Log.w(TAG, "WARNING: Surface's mNativeObject (0x" +
- Integer.toHexString(mNativeObject) + ") != mLockedObject (0x" +
- Integer.toHexString(mLockedObject) +")");
+ Long.toHexString(mNativeObject) + ") != mLockedObject (0x" +
+ Long.toHexString(mLockedObject) +")");
}
if (mLockedObject == 0) {
throw new IllegalStateException("Surface was not locked");
@@ -307,12 +307,12 @@
throw new IllegalArgumentException("other must not be null");
}
- int surfaceControlPtr = other.mNativeObject;
+ long surfaceControlPtr = other.mNativeObject;
if (surfaceControlPtr == 0) {
throw new NullPointerException(
"SurfaceControl native object is null. Are you using a released SurfaceControl?");
}
- int newNativeObject = nativeCreateFromSurfaceControl(surfaceControlPtr);
+ long newNativeObject = nativeCreateFromSurfaceControl(surfaceControlPtr);
synchronized (mLock) {
if (mNativeObject != 0) {
@@ -334,7 +334,7 @@
throw new IllegalArgumentException("other must not be null");
}
if (other != this) {
- final int newPtr;
+ final long newPtr;
synchronized (other.mLock) {
newPtr = other.mNativeObject;
other.setNativeObjectLocked(0);
@@ -391,7 +391,7 @@
}
}
- private void setNativeObjectLocked(int ptr) {
+ private void setNativeObjectLocked(long ptr) {
if (mNativeObject != ptr) {
if (mNativeObject == 0 && ptr != 0) {
mCloseGuard.open("release");
diff --git a/core/java/android/view/SurfaceControl.java b/core/java/android/view/SurfaceControl.java
index b22d5cf..62afa60 100644
--- a/core/java/android/view/SurfaceControl.java
+++ b/core/java/android/view/SurfaceControl.java
@@ -33,11 +33,11 @@
public class SurfaceControl {
private static final String TAG = "SurfaceControl";
- private static native int nativeCreate(SurfaceSession session, String name,
+ private static native long nativeCreate(SurfaceSession session, String name,
int w, int h, int format, int flags)
throws OutOfResourcesException;
- private static native void nativeRelease(int nativeObject);
- private static native void nativeDestroy(int nativeObject);
+ private static native void nativeRelease(long nativeObject);
+ private static native void nativeDestroy(long nativeObject);
private static native Bitmap nativeScreenshot(IBinder displayToken,
int width, int height, int minLayer, int maxLayer, boolean allLayers);
@@ -48,21 +48,21 @@
private static native void nativeCloseTransaction();
private static native void nativeSetAnimationTransaction();
- private static native void nativeSetLayer(int nativeObject, int zorder);
- private static native void nativeSetPosition(int nativeObject, float x, float y);
- private static native void nativeSetSize(int nativeObject, int w, int h);
- private static native void nativeSetTransparentRegionHint(int nativeObject, Region region);
- private static native void nativeSetAlpha(int nativeObject, float alpha);
- private static native void nativeSetMatrix(int nativeObject, float dsdx, float dtdx, float dsdy, float dtdy);
- private static native void nativeSetFlags(int nativeObject, int flags, int mask);
- private static native void nativeSetWindowCrop(int nativeObject, int l, int t, int r, int b);
- private static native void nativeSetLayerStack(int nativeObject, int layerStack);
+ private static native void nativeSetLayer(long nativeObject, int zorder);
+ private static native void nativeSetPosition(long nativeObject, float x, float y);
+ private static native void nativeSetSize(long nativeObject, int w, int h);
+ private static native void nativeSetTransparentRegionHint(long nativeObject, Region region);
+ private static native void nativeSetAlpha(long nativeObject, float alpha);
+ private static native void nativeSetMatrix(long nativeObject, float dsdx, float dtdx, float dsdy, float dtdy);
+ private static native void nativeSetFlags(long nativeObject, int flags, int mask);
+ private static native void nativeSetWindowCrop(long nativeObject, int l, int t, int r, int b);
+ private static native void nativeSetLayerStack(long nativeObject, int layerStack);
private static native IBinder nativeGetBuiltInDisplay(int physicalDisplayId);
private static native IBinder nativeCreateDisplay(String name, boolean secure);
private static native void nativeDestroyDisplay(IBinder displayToken);
private static native void nativeSetDisplaySurface(
- IBinder displayToken, int nativeSurfaceObject);
+ IBinder displayToken, long nativeSurfaceObject);
private static native void nativeSetDisplayLayerStack(
IBinder displayToken, int layerStack);
private static native void nativeSetDisplayProjection(
@@ -77,7 +77,7 @@
private final CloseGuard mCloseGuard = CloseGuard.get();
private final String mName;
- int mNativeObject; // package visibility only for Surface.java access
+ long mNativeObject; // package visibility only for Surface.java access
private static final boolean HEADLESS = "1".equals(
SystemProperties.get("ro.config.headless", "0"));
diff --git a/core/java/android/view/SurfaceSession.java b/core/java/android/view/SurfaceSession.java
index 0dfd94a..3cf5af4 100644
--- a/core/java/android/view/SurfaceSession.java
+++ b/core/java/android/view/SurfaceSession.java
@@ -24,11 +24,11 @@
*/
public final class SurfaceSession {
// Note: This field is accessed by native code.
- private int mNativeClient; // SurfaceComposerClient*
+ private long mNativeClient; // SurfaceComposerClient*
- private static native int nativeCreate();
- private static native void nativeDestroy(int ptr);
- private static native void nativeKill(int ptr);
+ private static native long nativeCreate();
+ private static native void nativeDestroy(long ptr);
+ private static native void nativeKill(long ptr);
/** Create a new connection with the surface flinger. */
public SurfaceSession() {
diff --git a/core/java/android/view/TextureView.java b/core/java/android/view/TextureView.java
index 47f7628..b78af2e 100644
--- a/core/java/android/view/TextureView.java
+++ b/core/java/android/view/TextureView.java
@@ -127,7 +127,7 @@
private final Object[] mNativeWindowLock = new Object[0];
// Used from native code, do not write!
@SuppressWarnings({"UnusedDeclaration"})
- private int mNativeWindow;
+ private long mNativeWindow;
/**
* Creates a new TextureView.
@@ -816,6 +816,6 @@
private native void nCreateNativeWindow(SurfaceTexture surface);
private native void nDestroyNativeWindow();
- private static native boolean nLockCanvas(int nativeWindow, Canvas canvas, Rect dirty);
- private static native void nUnlockCanvasAndPost(int nativeWindow, Canvas canvas);
+ private static native boolean nLockCanvas(long nativeWindow, Canvas canvas, Rect dirty);
+ private static native void nUnlockCanvasAndPost(long nativeWindow, Canvas canvas);
}
diff --git a/core/java/android/view/VelocityTracker.java b/core/java/android/view/VelocityTracker.java
index eb81f72..22b5cca 100644
--- a/core/java/android/view/VelocityTracker.java
+++ b/core/java/android/view/VelocityTracker.java
@@ -34,17 +34,17 @@
private static final int ACTIVE_POINTER_ID = -1;
- private int mPtr;
+ private long mPtr;
private final String mStrategy;
- private static native int nativeInitialize(String strategy);
- private static native void nativeDispose(int ptr);
- private static native void nativeClear(int ptr);
- private static native void nativeAddMovement(int ptr, MotionEvent event);
- private static native void nativeComputeCurrentVelocity(int ptr, int units, float maxVelocity);
- private static native float nativeGetXVelocity(int ptr, int id);
- private static native float nativeGetYVelocity(int ptr, int id);
- private static native boolean nativeGetEstimator(int ptr, int id, Estimator outEstimator);
+ private static native long nativeInitialize(String strategy);
+ private static native void nativeDispose(long ptr);
+ private static native void nativeClear(long ptr);
+ private static native void nativeAddMovement(long ptr, MotionEvent event);
+ private static native void nativeComputeCurrentVelocity(long ptr, int units, float maxVelocity);
+ private static native float nativeGetXVelocity(long ptr, int id);
+ private static native float nativeGetYVelocity(long ptr, int id);
+ private static native boolean nativeGetEstimator(long ptr, int id, Estimator outEstimator);
/**
* Retrieve a new VelocityTracker object to watch the velocity of a
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index b0bae46..bdf4141 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -10098,7 +10098,7 @@
* by the layout system and should not generally be called otherwise, because the property
* may be changed at any time by the layout.
*
- * @param left The bottom of this view, in pixels.
+ * @param left The left of this view, in pixels.
*/
public final void setLeft(int left) {
if (left != mLeft) {
@@ -10165,7 +10165,7 @@
* by the layout system and should not generally be called otherwise, because the property
* may be changed at any time by the layout.
*
- * @param right The bottom of this view, in pixels.
+ * @param right The right of this view, in pixels.
*/
public final void setRight(int right) {
if (right != mRight) {
@@ -11838,7 +11838,7 @@
}
/**
- * <p>Compute the vertical extent of the horizontal scrollbar's thumb
+ * <p>Compute the vertical extent of the vertical scrollbar's thumb
* within the vertical range. This value is used to compute the length
* of the thumb within the scrollbar's track.</p>
*
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index bc0d7e3..3fd2aa9 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -660,7 +660,7 @@
mHandler.sendMessageAtFrontOfQueue(mHandler.obtainMessage(MSG_FLUSH_LAYER_UPDATES));
}
- public boolean attachFunctor(int functor) {
+ public boolean attachFunctor(long functor) {
//noinspection SimplifiableIfStatement
if (mAttachInfo.mHardwareRenderer != null && mAttachInfo.mHardwareRenderer.isEnabled()) {
return mAttachInfo.mHardwareRenderer.attachFunctor(mAttachInfo, functor);
@@ -668,7 +668,7 @@
return false;
}
- public void detachFunctor(int functor) {
+ public void detachFunctor(long functor) {
if (mAttachInfo.mHardwareRenderer != null) {
mAttachInfo.mHardwareRenderer.detachFunctor(functor);
}
diff --git a/core/java/android/widget/AbsSeekBar.java b/core/java/android/widget/AbsSeekBar.java
index 7674837..fe2fc96 100644
--- a/core/java/android/widget/AbsSeekBar.java
+++ b/core/java/android/widget/AbsSeekBar.java
@@ -292,7 +292,7 @@
// The extra space for the thumb to move on the track
available += mThumbOffset * 2;
- int thumbPos = (int) (scale * available);
+ int thumbPos = (int) (scale * available + 0.5f);
int topBound, bottomBound;
if (gap == Integer.MIN_VALUE) {
diff --git a/core/java/android/widget/AdapterView.java b/core/java/android/widget/AdapterView.java
index a5fad60..a06344f 100644
--- a/core/java/android/widget/AdapterView.java
+++ b/core/java/android/widget/AdapterView.java
@@ -663,7 +663,7 @@
/**
* When the current adapter is empty, the AdapterView can display a special view
- * call the empty view. The empty view is used to provide feedback to the user
+ * called the empty view. The empty view is used to provide feedback to the user
* that no data is available in this AdapterView.
*
* @return The view to show if the adapter is empty.
diff --git a/core/java/android/widget/CursorTreeAdapter.java b/core/java/android/widget/CursorTreeAdapter.java
old mode 100644
new mode 100755
index 44d1656..405e45a
--- a/core/java/android/widget/CursorTreeAdapter.java
+++ b/core/java/android/widget/CursorTreeAdapter.java
@@ -497,7 +497,7 @@
@Override
public void onChange(boolean selfChange) {
- if (mAutoRequery && mCursor != null) {
+ if (mAutoRequery && mCursor != null && !mCursor.isClosed()) {
if (false) Log.v("Cursor", "Auto requerying " + mCursor +
" due to update");
mDataValid = mCursor.requery();
diff --git a/core/java/android/widget/Spinner.java b/core/java/android/widget/Spinner.java
index b75d36f..5cbabef 100644
--- a/core/java/android/widget/Spinner.java
+++ b/core/java/android/widget/Spinner.java
@@ -952,8 +952,10 @@
private CharSequence mPrompt;
public void dismiss() {
- mPopup.dismiss();
- mPopup = null;
+ if (mPopup != null) {
+ mPopup.dismiss();
+ mPopup = null;
+ }
}
public boolean isShowing() {
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 7a9809f..3f35875 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -5147,12 +5147,12 @@
final int width = mRight - mLeft;
final int padding = getCompoundPaddingLeft() + getCompoundPaddingRight();
final float dx = mLayout.getLineRight(0) - (width - padding);
- canvas.translate(isLayoutRtl ? -dx : +dx, 0.0f);
+ canvas.translate(layout.getParagraphDirection(0) * dx, 0.0f);
}
if (mMarquee != null && mMarquee.isRunning()) {
final float dx = -mMarquee.getScroll();
- canvas.translate(isLayoutRtl ? -dx : +dx, 0.0f);
+ canvas.translate(layout.getParagraphDirection(0) * dx, 0.0f);
}
}
@@ -5166,8 +5166,8 @@
}
if (mMarquee != null && mMarquee.shouldDrawGhost()) {
- final int dx = (int) mMarquee.getGhostOffset();
- canvas.translate(isLayoutRtl ? -dx : dx, 0.0f);
+ final float dx = mMarquee.getGhostOffset();
+ canvas.translate(layout.getParagraphDirection(0) * dx, 0.0f);
layout.draw(canvas, highlight, mHighlightPaint, cursorOffsetVertical);
}
diff --git a/core/java/com/android/internal/app/ChooserActivity.java b/core/java/com/android/internal/app/ChooserActivity.java
index 70f90d3..1eda373 100644
--- a/core/java/com/android/internal/app/ChooserActivity.java
+++ b/core/java/com/android/internal/app/ChooserActivity.java
@@ -27,8 +27,9 @@
Intent intent = getIntent();
Parcelable targetParcelable = intent.getParcelableExtra(Intent.EXTRA_INTENT);
if (!(targetParcelable instanceof Intent)) {
- Log.w("ChooseActivity", "Target is not an intent: " + targetParcelable);
+ Log.w("ChooserActivity", "Target is not an intent: " + targetParcelable);
finish();
+ super.onCreate(null);
return;
}
Intent target = (Intent)targetParcelable;
@@ -42,9 +43,10 @@
initialIntents = new Intent[pa.length];
for (int i=0; i<pa.length; i++) {
if (!(pa[i] instanceof Intent)) {
- Log.w("ChooseActivity", "Initial intent #" + i
+ Log.w("ChooserActivity", "Initial intent #" + i
+ " not an Intent: " + pa[i]);
finish();
+ super.onCreate(null);
return;
}
initialIntents[i] = (Intent)pa[i];
diff --git a/core/java/com/android/internal/app/ProcessStats.java b/core/java/com/android/internal/app/ProcessStats.java
index 0cad33c..a87992a 100644
--- a/core/java/com/android/internal/app/ProcessStats.java
+++ b/core/java/com/android/internal/app/ProcessStats.java
@@ -1046,7 +1046,7 @@
public boolean evaluateSystemProperties(boolean update) {
boolean changed = false;
- String runtime = SystemProperties.get("persist.sys.dalvik.vm.lib",
+ String runtime = SystemProperties.get("persist.sys.dalvik.vm.lib.1",
VMRuntime.getRuntime().vmLibrary());
if (!Objects.equals(runtime, mRuntime)) {
changed = true;
diff --git a/core/java/com/android/internal/content/NativeLibraryHelper.java b/core/java/com/android/internal/content/NativeLibraryHelper.java
index 6d65782..ba419f9 100644
--- a/core/java/com/android/internal/content/NativeLibraryHelper.java
+++ b/core/java/com/android/internal/content/NativeLibraryHelper.java
@@ -16,7 +16,7 @@
package com.android.internal.content;
-import android.os.Build;
+import android.content.pm.PackageManager;
import android.util.Slog;
import java.io.File;
@@ -31,38 +31,76 @@
private static final boolean DEBUG_NATIVE = false;
- private static native long nativeSumNativeBinaries(String file, String cpuAbi, String cpuAbi2);
-
/**
- * Sums the size of native binaries in an APK.
+ * A handle to an opened APK. Used as input to the various NativeLibraryHelper
+ * methods. Allows us to scan and parse the APK exactly once instead of doing
+ * it multiple times.
*
- * @param apkFile APK file to scan for native libraries
- * @return size of all native binary files in bytes
+ * @hide
*/
- public static long sumNativeBinariesLI(File apkFile) {
- final String cpuAbi = Build.CPU_ABI;
- final String cpuAbi2 = Build.CPU_ABI2;
- return nativeSumNativeBinaries(apkFile.getPath(), cpuAbi, cpuAbi2);
+ public static class ApkHandle {
+ final String apkPath;
+ final long apkHandle;
+
+ public ApkHandle(String path) {
+ apkPath = path;
+ apkHandle = nativeOpenApk(apkPath);
+ }
+
+ public ApkHandle(File apkFile) {
+ apkPath = apkFile.getPath();
+ apkHandle = nativeOpenApk(apkPath);
+ }
+
+ public void close() {
+ nativeClose(apkHandle);
+ }
}
- private native static int nativeCopyNativeBinaries(String filePath, String sharedLibraryPath,
- String cpuAbi, String cpuAbi2);
+
+ private static native long nativeOpenApk(String path);
+ private static native void nativeClose(long handle);
+
+ private static native long nativeSumNativeBinaries(long handle, String cpuAbi);
+
+ /**
+ * Sums the size of native binaries in an APK for a given ABI.
+ *
+ * @return size of all native binary files in bytes
+ */
+ public static long sumNativeBinariesLI(ApkHandle handle, String abi) {
+ return nativeSumNativeBinaries(handle.apkHandle, abi);
+ }
+
+ private native static int nativeCopyNativeBinaries(long handle,
+ String sharedLibraryPath, String abiToCopy);
/**
* Copies native binaries to a shared library directory.
*
- * @param apkFile APK file to scan for native libraries
+ * @param handle APK file to scan for native libraries
* @param sharedLibraryDir directory for libraries to be copied to
* @return {@link PackageManager#INSTALL_SUCCEEDED} if successful or another
* error code from that class if not
*/
- public static int copyNativeBinariesIfNeededLI(File apkFile, File sharedLibraryDir) {
- final String cpuAbi = Build.CPU_ABI;
- final String cpuAbi2 = Build.CPU_ABI2;
- return nativeCopyNativeBinaries(apkFile.getPath(), sharedLibraryDir.getPath(), cpuAbi,
- cpuAbi2);
+ public static int copyNativeBinariesIfNeededLI(ApkHandle handle, File sharedLibraryDir,
+ String abi) {
+ return nativeCopyNativeBinaries(handle.apkHandle, sharedLibraryDir.getPath(), abi);
}
+ /**
+ * Checks if a given APK contains native code for any of the provided
+ * {@code supportedAbis}. Returns an index into {@code supportedAbis} if a matching
+ * ABI is found, {@link PackageManager#NO_NATIVE_LIBRARIES} if the
+ * APK doesn't contain any native code, and
+ * {@link PackageManager#INSTALL_FAILED_NO_MATCHING_ABIS} if none of the ABIs match.
+ */
+ public static int findSupportedAbi(ApkHandle handle, String[] supportedAbis) {
+ return nativeFindSupportedAbi(handle.apkHandle, supportedAbis);
+ }
+
+ private native static int nativeFindSupportedAbi(long handle, String[] supportedAbis);
+
// Convenience method to call removeNativeBinariesFromDirLI(File)
public static boolean removeNativeBinariesLI(String nativeLibraryPath) {
return removeNativeBinariesFromDirLI(new File(nativeLibraryPath));
diff --git a/core/java/com/android/internal/os/WrapperInit.java b/core/java/com/android/internal/os/WrapperInit.java
index c6b3e7c..3301cbe 100644
--- a/core/java/com/android/internal/os/WrapperInit.java
+++ b/core/java/com/android/internal/os/WrapperInit.java
@@ -25,9 +25,6 @@
import java.io.IOException;
import libcore.io.IoUtils;
-import libcore.io.Libcore;
-
-import dalvik.system.Zygote;
/**
* Startup class for the wrapper process.
@@ -95,7 +92,7 @@
* @param niceName The nice name for the application, or null if none.
* @param targetSdkVersion The target SDK version for the app.
* @param pipeFd The pipe to which the application's pid should be written, or null if none.
- * @param args Arguments for {@link RuntimeInit.main}.
+ * @param args Arguments for {@link RuntimeInit#main}.
*/
public static void execApplication(String invokeWith, String niceName,
int targetSdkVersion, FileDescriptor pipeFd, String[] args) {
diff --git a/core/java/com/android/internal/os/Zygote.java b/core/java/com/android/internal/os/Zygote.java
new file mode 100644
index 0000000..c5fa0a1
--- /dev/null
+++ b/core/java/com/android/internal/os/Zygote.java
@@ -0,0 +1,164 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.internal.os;
+
+
+import dalvik.system.ZygoteHooks;
+import libcore.io.ErrnoException;
+import libcore.io.Libcore;
+
+/** @hide */
+public final class Zygote {
+ /*
+ * Bit values for "debugFlags" argument. The definitions are duplicated
+ * in the native code.
+ */
+
+ /** enable debugging over JDWP */
+ public static final int DEBUG_ENABLE_DEBUGGER = 1;
+ /** enable JNI checks */
+ public static final int DEBUG_ENABLE_CHECKJNI = 1 << 1;
+ /** enable Java programming language "assert" statements */
+ public static final int DEBUG_ENABLE_ASSERT = 1 << 2;
+ /** disable the JIT compiler */
+ public static final int DEBUG_ENABLE_SAFEMODE = 1 << 3;
+ /** Enable logging of third-party JNI activity. */
+ public static final int DEBUG_ENABLE_JNI_LOGGING = 1 << 4;
+
+ /** No external storage should be mounted. */
+ public static final int MOUNT_EXTERNAL_NONE = 0;
+ /** Single-user external storage should be mounted. */
+ public static final int MOUNT_EXTERNAL_SINGLEUSER = 1;
+ /** Multi-user external storage should be mounted. */
+ public static final int MOUNT_EXTERNAL_MULTIUSER = 2;
+ /** All multi-user external storage should be mounted. */
+ public static final int MOUNT_EXTERNAL_MULTIUSER_ALL = 3;
+
+ private static final ZygoteHooks VM_HOOKS = new ZygoteHooks();
+
+ private Zygote() {}
+
+ /**
+ * Forks a new VM instance. The current VM must have been started
+ * with the -Xzygote flag. <b>NOTE: new instance keeps all
+ * root capabilities. The new process is expected to call capset()</b>.
+ *
+ * @param uid the UNIX uid that the new process should setuid() to after
+ * fork()ing and and before spawning any threads.
+ * @param gid the UNIX gid that the new process should setgid() to after
+ * fork()ing and and before spawning any threads.
+ * @param gids null-ok; a list of UNIX gids that the new process should
+ * setgroups() to after fork and before spawning any threads.
+ * @param debugFlags bit flags that enable debugging features.
+ * @param rlimits null-ok an array of rlimit tuples, with the second
+ * dimension having a length of 3 and representing
+ * (resource, rlim_cur, rlim_max). These are set via the posix
+ * setrlimit(2) call.
+ * @param seInfo null-ok a string specifying SELinux information for
+ * the new process.
+ * @param niceName null-ok a string specifying the process name.
+ * @param fdsToClose an array of ints, holding one or more POSIX
+ * file descriptor numbers that are to be closed by the child
+ * (and replaced by /dev/null) after forking. An integer value
+ * of -1 in any entry in the array means "ignore this one".
+ *
+ * @return 0 if this is the child, pid of the child
+ * if this is the parent, or -1 on error.
+ */
+ public static int forkAndSpecialize(int uid, int gid, int[] gids, int debugFlags,
+ int[][] rlimits, int mountExternal, String seInfo, String niceName, int[] fdsToClose) {
+ VM_HOOKS.preFork();
+ int pid = nativeForkAndSpecialize(
+ uid, gid, gids, debugFlags, rlimits, mountExternal, seInfo, niceName, fdsToClose);
+ VM_HOOKS.postForkCommon();
+ return pid;
+ }
+
+ native private static int nativeForkAndSpecialize(int uid, int gid, int[] gids,int debugFlags,
+ int[][] rlimits, int mountExternal, String seInfo, String niceName, int[] fdsToClose);
+
+ /**
+ * Special method to start the system server process. In addition to the
+ * common actions performed in forkAndSpecialize, the pid of the child
+ * process is recorded such that the death of the child process will cause
+ * zygote to exit.
+ *
+ * @param uid the UNIX uid that the new process should setuid() to after
+ * fork()ing and and before spawning any threads.
+ * @param gid the UNIX gid that the new process should setgid() to after
+ * fork()ing and and before spawning any threads.
+ * @param gids null-ok; a list of UNIX gids that the new process should
+ * setgroups() to after fork and before spawning any threads.
+ * @param debugFlags bit flags that enable debugging features.
+ * @param rlimits null-ok an array of rlimit tuples, with the second
+ * dimension having a length of 3 and representing
+ * (resource, rlim_cur, rlim_max). These are set via the posix
+ * setrlimit(2) call.
+ * @param permittedCapabilities argument for setcap()
+ * @param effectiveCapabilities argument for setcap()
+ *
+ * @return 0 if this is the child, pid of the child
+ * if this is the parent, or -1 on error.
+ */
+ public static int forkSystemServer(int uid, int gid, int[] gids, int debugFlags,
+ int[][] rlimits, long permittedCapabilities, long effectiveCapabilities) {
+ VM_HOOKS.preFork();
+ int pid = nativeForkSystemServer(
+ uid, gid, gids, debugFlags, rlimits, permittedCapabilities, effectiveCapabilities);
+ VM_HOOKS.postForkCommon();
+ return pid;
+ }
+
+ native private static int nativeForkSystemServer(int uid, int gid, int[] gids, int debugFlags,
+ int[][] rlimits, long permittedCapabilities, long effectiveCapabilities);
+
+ private static void callPostForkChildHooks(int debugFlags) {
+ VM_HOOKS.postForkChild(debugFlags);
+ }
+
+
+ /**
+ * Executes "/system/bin/sh -c <command>" using the exec() system call.
+ * This method throws a runtime exception if exec() failed, otherwise, this
+ * method never returns.
+ *
+ * @param command The shell command to execute.
+ */
+ public static void execShell(String command) {
+ String[] args = { "/system/bin/sh", "-c", command };
+ try {
+ Libcore.os.execv(args[0], args);
+ } catch (ErrnoException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Appends quotes shell arguments to the specified string builder.
+ * The arguments are quoted using single-quotes, escaped if necessary,
+ * prefixed with a space, and appended to the command.
+ *
+ * @param command A string builder for the shell command being constructed.
+ * @param args An array of argument strings to be quoted and appended to the command.
+ * @see #execShell(String)
+ */
+ public static void appendQuotedShellArgs(StringBuilder command, String[] args) {
+ for (String arg : args) {
+ command.append(" '").append(arg.replace("'", "'\\''")).append("'");
+ }
+ }
+}
diff --git a/core/java/com/android/internal/os/ZygoteConnection.java b/core/java/com/android/internal/os/ZygoteConnection.java
index 4f3b5b3..58a8e62 100644
--- a/core/java/com/android/internal/os/ZygoteConnection.java
+++ b/core/java/com/android/internal/os/ZygoteConnection.java
@@ -22,10 +22,7 @@
import android.os.SELinux;
import android.os.SystemProperties;
import android.util.Log;
-
import dalvik.system.PathClassLoader;
-import dalvik.system.Zygote;
-
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.DataOutputStream;
@@ -35,8 +32,8 @@
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
-
import libcore.io.ErrnoException;
import libcore.io.IoUtils;
import libcore.io.Libcore;
@@ -60,7 +57,7 @@
private static final int CONNECTION_TIMEOUT_MILLIS = 1000;
/** max number of arguments that a connection can specify */
- private static final int MAX_ZYGOTE_ARGC=1024;
+ private static final int MAX_ZYGOTE_ARGC = 1024;
/**
* The command socket.
@@ -74,15 +71,18 @@
private final BufferedReader mSocketReader;
private final Credentials peer;
private final String peerSecurityContext;
+ private final String abiList;
/**
* Constructs instance from connected socket.
*
* @param socket non-null; connected socket
+ * @param abiList non-null; a list of ABIs this zygote supports.
* @throws IOException
*/
- ZygoteConnection(LocalSocket socket) throws IOException {
+ ZygoteConnection(LocalSocket socket, String abiList) throws IOException {
mSocket = socket;
+ this.abiList = abiList;
mSocketOutStream
= new DataOutputStream(socket.getOutputStream());
@@ -112,43 +112,6 @@
}
/**
- * Reads start commands from an open command socket.
- * Start commands are presently a pair of newline-delimited lines
- * indicating a) class to invoke main() on b) nice name to set argv[0] to.
- * Continues to read commands and forkAndSpecialize children until
- * the socket is closed. This method is used in ZYGOTE_FORK_MODE
- *
- * @throws ZygoteInit.MethodAndArgsCaller trampoline to invoke main()
- * method in child process
- */
- void run() throws ZygoteInit.MethodAndArgsCaller {
-
- int loopCount = ZygoteInit.GC_LOOP_COUNT;
-
- while (true) {
- /*
- * Call gc() before we block in readArgumentList().
- * It's work that has to be done anyway, and it's better
- * to avoid making every child do it. It will also
- * madvise() any free memory as a side-effect.
- *
- * Don't call it every time, because walking the entire
- * heap is a lot of overhead to free a few hundred bytes.
- */
- if (loopCount <= 0) {
- ZygoteInit.gc();
- loopCount = ZygoteInit.GC_LOOP_COUNT;
- } else {
- loopCount--;
- }
-
- if (runOnce()) {
- break;
- }
- }
- }
-
- /**
* Reads one start command from the command socket. If successful,
* a child is forked and a {@link ZygoteInit.MethodAndArgsCaller}
* exception is thrown in that child while in the parent process,
@@ -197,6 +160,11 @@
try {
parsedArgs = new Arguments(args);
+
+ if (parsedArgs.abiListQuery) {
+ return handleAbiListQuery();
+ }
+
if (parsedArgs.permittedCapabilities != 0 || parsedArgs.effectiveCapabilities != 0) {
throw new ZygoteSecurityException("Client may not specify capabilities: " +
"permitted=0x" + Long.toHexString(parsedArgs.permittedCapabilities) +
@@ -224,9 +192,37 @@
ZygoteInit.setCloseOnExec(serverPipeFd, true);
}
+ /**
+ * In order to avoid leaking descriptors to the Zygote child,
+ * the native code must close the two Zygote socket descriptors
+ * in the child process before it switches from Zygote-root to
+ * the UID and privileges of the application being launched.
+ *
+ * In order to avoid "bad file descriptor" errors when the
+ * two LocalSocket objects are closed, the Posix file
+ * descriptors are released via a dup2() call which closes
+ * the socket and substitutes an open descriptor to /dev/null.
+ */
+
+ int [] fdsToClose = { -1, -1 };
+
+ FileDescriptor fd = mSocket.getFileDescriptor();
+
+ if (fd != null) {
+ fdsToClose[0] = fd.getInt$();
+ }
+
+ fd = ZygoteInit.getServerSocketFileDescriptor();
+
+ if (fd != null) {
+ fdsToClose[1] = fd.getInt$();
+ }
+
+ fd = null;
+
pid = Zygote.forkAndSpecialize(parsedArgs.uid, parsedArgs.gid, parsedArgs.gids,
parsedArgs.debugFlags, rlimits, parsedArgs.mountExternal, parsedArgs.seInfo,
- parsedArgs.niceName);
+ parsedArgs.niceName, fdsToClose);
} catch (IOException ex) {
logAndPrintError(newStderr, "Exception creating pipe", ex);
} catch (ErrnoException ex) {
@@ -260,6 +256,18 @@
}
}
+ private boolean handleAbiListQuery() {
+ try {
+ final byte[] abiListBytes = abiList.getBytes(StandardCharsets.US_ASCII);
+ mSocketOutStream.writeInt(abiListBytes.length);
+ mSocketOutStream.write(abiListBytes);
+ return false;
+ } catch (IOException ioe) {
+ Log.e(TAG, "Error writing to command socket", ioe);
+ return true;
+ }
+ }
+
/**
* Closes socket associated with this connection.
*/
@@ -361,6 +369,11 @@
String remainingArgs[];
/**
+ * Whether the current arguments constitute an ABI list query.
+ */
+ boolean abiListQuery;
+
+ /**
* Constructs instance and parses args
* @param args zygote command-line args
* @throws IllegalArgumentException
@@ -513,6 +526,8 @@
mountExternal = Zygote.MOUNT_EXTERNAL_MULTIUSER;
} else if (arg.equals("--mount-external-multiuser-all")) {
mountExternal = Zygote.MOUNT_EXTERNAL_MULTIUSER_ALL;
+ } else if (arg.equals("--query-abi-list")) {
+ abiListQuery = true;
} else {
break;
}
@@ -779,7 +794,7 @@
/**
* Applies invoke-with system properties to the zygote arguments.
*
- * @param parsedArgs non-null; zygote args
+ * @param args non-null; zygote args
*/
public static void applyInvokeWithSystemProperty(Arguments args) {
if (args.invokeWith == null && args.niceName != null) {
@@ -814,6 +829,12 @@
FileDescriptor[] descriptors, FileDescriptor pipeFd, PrintStream newStderr)
throws ZygoteInit.MethodAndArgsCaller {
+ /**
+ * By the time we get here, the native code has closed the two actual Zygote
+ * socket connections, and substituted /dev/null in their place. The LocalSocket
+ * objects still need to be closed properly.
+ */
+
closeSocket();
ZygoteInit.closeServerSocket();
@@ -942,7 +963,7 @@
mSocketOutStream.writeInt(pid);
mSocketOutStream.writeBoolean(usingWrapper);
} catch (IOException ex) {
- Log.e(TAG, "Error reading from command socket", ex);
+ Log.e(TAG, "Error writing to command socket", ex);
return true;
}
diff --git a/core/java/com/android/internal/os/ZygoteInit.java b/core/java/com/android/internal/os/ZygoteInit.java
index 25118e8..495cc5f 100644
--- a/core/java/com/android/internal/os/ZygoteInit.java
+++ b/core/java/com/android/internal/os/ZygoteInit.java
@@ -32,7 +32,6 @@
import android.util.Log;
import dalvik.system.VMRuntime;
-import dalvik.system.Zygote;
import libcore.io.IoUtils;
import libcore.io.Libcore;
@@ -65,7 +64,7 @@
private static final String PROPERTY_DISABLE_OPENGL_PRELOADING = "ro.zygote.disable_gl_preload";
- private static final String ANDROID_SOCKET_ENV = "ANDROID_SOCKET_zygote";
+ private static final String ANDROID_SOCKET_PREFIX = "ANDROID_SOCKET_";
private static final int LOG_BOOT_PROGRESS_PRELOAD_START = 3020;
private static final int LOG_BOOT_PROGRESS_PRELOAD_END = 3030;
@@ -73,8 +72,9 @@
/** when preloading, GC after allocating this many bytes */
private static final int PRELOAD_GC_THRESHOLD = 50000;
- public static final String USAGE_STRING =
- " <\"start-system-server\"|\"\" for startSystemServer>";
+ private static final String ABI_LIST_ARG = "--abi-list=";
+
+ private static final String SOCKET_NAME_ARG = "--socket-name=";
private static LocalServerSocket sServerSocket;
@@ -151,15 +151,15 @@
*
* @throws RuntimeException when open fails
*/
- private static void registerZygoteSocket() {
+ private static void registerZygoteSocket(String socketName) {
if (sServerSocket == null) {
int fileDesc;
+ final String fullSocketName = ANDROID_SOCKET_PREFIX + socketName;
try {
- String env = System.getenv(ANDROID_SOCKET_ENV);
+ String env = System.getenv(fullSocketName);
fileDesc = Integer.parseInt(env);
} catch (RuntimeException ex) {
- throw new RuntimeException(
- ANDROID_SOCKET_ENV + " unset or invalid", ex);
+ throw new RuntimeException(fullSocketName + " unset or invalid", ex);
}
try {
@@ -176,9 +176,9 @@
* Waits for and accepts a single command connection. Throws
* RuntimeException on failure.
*/
- private static ZygoteConnection acceptCommandPeer() {
+ private static ZygoteConnection acceptCommandPeer(String abiList) {
try {
- return new ZygoteConnection(sServerSocket.accept());
+ return new ZygoteConnection(sServerSocket.accept(), abiList);
} catch (IOException ex) {
throw new RuntimeException(
"IOException during accept()", ex);
@@ -201,6 +201,16 @@
sServerSocket = null;
}
+ /**
+ * Return the server socket's underlying file descriptor, so that
+ * ZygoteConnection can pass it to the native code for proper
+ * closure after a child process is forked off.
+ */
+
+ static FileDescriptor getServerSocketFileDescriptor() {
+ return sServerSocket.getFileDescriptor();
+ }
+
private static final int UNPRIVILEGED_UID = 9999;
private static final int UNPRIVILEGED_GID = 9999;
@@ -558,7 +568,26 @@
// Start profiling the zygote initialization.
SamplingProfilerIntegration.start();
- registerZygoteSocket();
+ boolean startSystemServer = false;
+ String socketName = "zygote";
+ String abiList = null;
+ for (int i = 1; i < argv.length; i++) {
+ if ("start-system-server".equals(argv[i])) {
+ startSystemServer = true;
+ } else if (argv[i].startsWith(ABI_LIST_ARG)) {
+ abiList = argv[i].substring(ABI_LIST_ARG.length());
+ } else if (argv[i].startsWith(SOCKET_NAME_ARG)) {
+ socketName = argv[i].substring(SOCKET_NAME_ARG.length());
+ } else {
+ throw new RuntimeException("Unknown command line argument: " + argv[i]);
+ }
+ }
+
+ if (abiList == null) {
+ throw new RuntimeException("No ABI list supplied.");
+ }
+
+ registerZygoteSocket(socketName);
EventLog.writeEvent(LOG_BOOT_PROGRESS_PRELOAD_START,
SystemClock.uptimeMillis());
preload();
@@ -575,20 +604,12 @@
// Zygote.
Trace.setTracingEnabled(false);
- // If requested, start system server directly from Zygote
- if (argv.length != 2) {
- throw new RuntimeException(argv[0] + USAGE_STRING);
- }
-
- if (argv[1].equals("start-system-server")) {
+ if (startSystemServer) {
startSystemServer();
- } else if (!argv[1].equals("")) {
- throw new RuntimeException(argv[0] + USAGE_STRING);
}
Log.i(TAG, "Accepting command socket connections");
-
- runSelectLoop();
+ runSelectLoop(abiList);
closeServerSocket();
} catch (MethodAndArgsCaller caller) {
@@ -608,7 +629,7 @@
* @throws MethodAndArgsCaller in a child process when a main() should
* be executed.
*/
- private static void runSelectLoop() throws MethodAndArgsCaller {
+ private static void runSelectLoop(String abiList) throws MethodAndArgsCaller {
ArrayList<FileDescriptor> fds = new ArrayList<FileDescriptor>();
ArrayList<ZygoteConnection> peers = new ArrayList<ZygoteConnection>();
FileDescriptor[] fdArray = new FileDescriptor[4];
@@ -647,7 +668,7 @@
if (index < 0) {
throw new RuntimeException("Error in select()");
} else if (index == 0) {
- ZygoteConnection newPeer = acceptCommandPeer();
+ ZygoteConnection newPeer = acceptCommandPeer(abiList);
peers.add(newPeer);
fds.add(newPeer.getFileDesciptor());
} else {
diff --git a/core/java/com/android/internal/util/FileRotator.java b/core/java/com/android/internal/util/FileRotator.java
index 26235f1..71550be 100644
--- a/core/java/com/android/internal/util/FileRotator.java
+++ b/core/java/com/android/internal/util/FileRotator.java
@@ -336,7 +336,12 @@
final long deleteBefore = currentTimeMillis - mDeleteAgeMillis;
final FileInfo info = new FileInfo(mPrefix);
- for (String name : mBasePath.list()) {
+ String[] baseFiles = mBasePath.list();
+ if (baseFiles == null) {
+ return;
+ }
+
+ for (String name : baseFiles) {
if (!info.parse(name)) continue;
if (info.isActive()) {
diff --git a/core/jni/Android.mk b/core/jni/Android.mk
index 2e0acb1..fda4114 100644
--- a/core/jni/Android.mk
+++ b/core/jni/Android.mk
@@ -134,7 +134,6 @@
android_hardware_UsbDevice.cpp \
android_hardware_UsbDeviceConnection.cpp \
android_hardware_UsbRequest.cpp \
- android_debug_JNITest.cpp \
android_util_FileObserver.cpp \
android/opengl/poly_clip.cpp.arm \
android/opengl/util.cpp.arm \
@@ -150,7 +149,8 @@
android_content_res_ObbScanner.cpp \
android_content_res_Configuration.cpp \
android_animation_PropertyValuesHolder.cpp \
- com_android_internal_net_NetworkStatsFactory.cpp
+ com_android_internal_net_NetworkStatsFactory.cpp \
+ com_android_internal_os_Zygote.cpp
LOCAL_C_INCLUDES += \
$(JNI_H_INCLUDE) \
diff --git a/core/jni/AndroidRuntime.cpp b/core/jni/AndroidRuntime.cpp
index 97ea5e6..362a54e 100644
--- a/core/jni/AndroidRuntime.cpp
+++ b/core/jni/AndroidRuntime.cpp
@@ -131,7 +131,6 @@
extern int register_android_database_SQLiteConnection(JNIEnv* env);
extern int register_android_database_SQLiteGlobal(JNIEnv* env);
extern int register_android_database_SQLiteDebug(JNIEnv* env);
-extern int register_android_debug_JNITest(JNIEnv* env);
extern int register_android_nio_utils(JNIEnv* env);
extern int register_android_text_format_Time(JNIEnv* env);
extern int register_android_os_Debug(JNIEnv* env);
@@ -178,6 +177,7 @@
extern int register_android_animation_PropertyValuesHolder(JNIEnv *env);
extern int register_com_android_internal_content_NativeLibraryHelper(JNIEnv *env);
extern int register_com_android_internal_net_NetworkStatsFactory(JNIEnv *env);
+extern int register_com_android_internal_os_Zygote(JNIEnv *env);
static AndroidRuntime* gCurRuntime = NULL;
@@ -228,9 +228,10 @@
/*static*/ JavaVM* AndroidRuntime::mJavaVM = NULL;
-
-AndroidRuntime::AndroidRuntime() :
- mExitWithoutCleanup(false)
+AndroidRuntime::AndroidRuntime(char* argBlockStart, const size_t argBlockLength) :
+ mExitWithoutCleanup(false),
+ mArgBlockStart(argBlockStart),
+ mArgBlockLength(argBlockLength)
{
SkGraphics::Init();
// this sets our preference for 16bit images during decode
@@ -265,13 +266,17 @@
return jniRegisterNativeMethods(env, className, gMethods, numMethods);
}
-status_t AndroidRuntime::callMain(const char* className,
- jclass clazz, int argc, const char* const argv[])
+void AndroidRuntime::setArgv0(const char* argv0) {
+ strlcpy(mArgBlockStart, argv0, mArgBlockLength);
+}
+
+status_t AndroidRuntime::callMain(const String8& className, jclass clazz,
+ const Vector<String8>& args)
{
JNIEnv* env;
jmethodID methodId;
- ALOGD("Calling main entry %s", className);
+ ALOGD("Calling main entry %s", className.string());
env = getJNIEnv();
if (clazz == NULL || env == NULL) {
@@ -280,7 +285,7 @@
methodId = env->GetStaticMethodID(clazz, "main", "([Ljava/lang/String;)V");
if (methodId == NULL) {
- ALOGE("ERROR: could not find method %s.main(String[])\n", className);
+ ALOGE("ERROR: could not find method %s.main(String[])\n", className.string());
return UNKNOWN_ERROR;
}
@@ -291,11 +296,12 @@
jclass stringClass;
jobjectArray strArray;
+ const size_t numArgs = args.size();
stringClass = env->FindClass("java/lang/String");
- strArray = env->NewObjectArray(argc, stringClass, NULL);
+ strArray = env->NewObjectArray(numArgs, stringClass, NULL);
- for (int i = 0; i < argc; i++) {
- jstring argStr = env->NewStringUTF(argv[i]);
+ for (size_t i = 0; i < numArgs; i++) {
+ jstring argStr = env->NewStringUTF(args[i].string());
env->SetObjectArrayElement(strArray, i, argStr);
}
@@ -396,16 +402,16 @@
*
* This will cut up "extraOptsBuf" as we chop it into individual options.
*
+ * If "quotingArg" is non-null, it is passed before each extra option in mOptions.
+ *
* Adds the strings, if any, to mOptions.
*/
-void AndroidRuntime::parseExtraOpts(char* extraOptsBuf)
+void AndroidRuntime::parseExtraOpts(char* extraOptsBuf, const char* quotingArg)
{
JavaVMOption opt;
- char* start;
- char* end;
-
memset(&opt, 0, sizeof(opt));
- start = extraOptsBuf;
+ char* start = extraOptsBuf;
+ char* end = NULL;
while (*start != '\0') {
while (*start == ' ') /* skip leading whitespace */
start++;
@@ -419,6 +425,11 @@
*end++ = '\0'; /* mark end, advance to indicate more */
opt.optionString = start;
+ if (quotingArg != NULL) {
+ JavaVMOption quotingOpt;
+ quotingOpt.optionString = quotingArg;
+ mOptions.add(quotingOpt);
+ }
mOptions.add(opt);
start = end;
}
@@ -430,6 +441,14 @@
* Various arguments, most determined by system properties, are passed in.
* The "mOptions" vector is updated.
*
+ * CAUTION: when adding options in here, be careful not to put the
+ * char buffer inside a nested scope. Adding the buffer to the
+ * options using mOptions.add() does not copy the buffer, so if the
+ * buffer goes out of scope the option may be overwritten. It's best
+ * to put the buffer at the top of the function so that it is more
+ * unlikely that someone will surround it in a scope at a later time
+ * and thus introduce a bug.
+ *
* Returns 0 on success.
*/
int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv)
@@ -450,6 +469,9 @@
char gctypeOptsBuf[sizeof("-Xgc:")-1 + PROPERTY_VALUE_MAX];
char heaptargetutilizationOptsBuf[sizeof("-XX:HeapTargetUtilization=")-1 + PROPERTY_VALUE_MAX];
char jitcodecachesizeOptsBuf[sizeof("-Xjitcodecachesize:")-1 + PROPERTY_VALUE_MAX];
+ char dalvikVmLibBuf[PROPERTY_VALUE_MAX];
+ char dex2oatFlagsBuf[PROPERTY_VALUE_MAX];
+ char dex2oatImageFlagsBuf[PROPERTY_VALUE_MAX];
char extraOptsBuf[PROPERTY_VALUE_MAX];
char* stackTraceFile = NULL;
bool checkJni = false;
@@ -461,7 +483,15 @@
kEMIntFast,
kEMJitCompiler,
} executionMode = kEMDefault;
-
+ char profile_period[sizeof("-Xprofile-period:") + PROPERTY_VALUE_MAX];
+ char profile_duration[sizeof("-Xprofile-duration:") + PROPERTY_VALUE_MAX];
+ char profile_interval[sizeof("-Xprofile-interval:") + PROPERTY_VALUE_MAX];
+ char profile_backoff[sizeof("-Xprofile-backoff:") + PROPERTY_VALUE_MAX];
+ char langOption[sizeof("-Duser.language=") + 3];
+ char regionOption[sizeof("-Duser.region=") + 3];
+ char lockProfThresholdBuf[sizeof("-Xlockprofthreshold:") + sizeof(propBuf)];
+ char jitOpBuf[sizeof("-Xjitop:") + PROPERTY_VALUE_MAX];
+ char jitMethodBuf[sizeof("-Xjitmethod:") + PROPERTY_VALUE_MAX];
property_get("dalvik.vm.checkjni", propBuf, "");
if (strcmp(propBuf, "true") == 0) {
@@ -662,7 +692,6 @@
//mOptions.add(opt);
}
- char lockProfThresholdBuf[sizeof("-Xlockprofthreshold:") + sizeof(propBuf)];
property_get("dalvik.vm.lockprof.threshold", propBuf, "");
if (strlen(propBuf) > 0) {
strcpy(lockProfThresholdBuf, "-Xlockprofthreshold:");
@@ -672,7 +701,6 @@
}
/* Force interpreter-only mode for selected opcodes. Eg "1-0a,3c,f1-ff" */
- char jitOpBuf[sizeof("-Xjitop:") + PROPERTY_VALUE_MAX];
property_get("dalvik.vm.jit.op", propBuf, "");
if (strlen(propBuf) > 0) {
strcpy(jitOpBuf, "-Xjitop:");
@@ -682,7 +710,6 @@
}
/* Force interpreter-only mode for selected methods */
- char jitMethodBuf[sizeof("-Xjitmethod:") + PROPERTY_VALUE_MAX];
property_get("dalvik.vm.jit.method", propBuf, "");
if (strlen(propBuf) > 0) {
strcpy(jitMethodBuf, "-Xjitmethod:");
@@ -742,14 +769,26 @@
mOptions.add(opt);
}
+ // libart tolerates libdvm flags, but not vice versa, so only pass some options if libart.
+ property_get("persist.sys.dalvik.vm.lib.1", dalvikVmLibBuf, "libdvm.so");
+ bool libart = (strncmp(dalvikVmLibBuf, "libart", 6) == 0);
+
+ if (libart) {
+ // Extra options for DexClassLoader.
+ property_get("dalvik.vm.dex2oat-flags", dex2oatFlagsBuf, "");
+ parseExtraOpts(dex2oatFlagsBuf, "-Xcompiler-option");
+
+ // Extra options for boot.art/boot.oat image generation.
+ property_get("dalvik.vm.image-dex2oat-flags", dex2oatImageFlagsBuf, "");
+ parseExtraOpts(dex2oatImageFlagsBuf, "-Ximage-compiler-option");
+ }
+
/* extra options; parse this late so it overrides others */
property_get("dalvik.vm.extra-opts", extraOptsBuf, "");
- parseExtraOpts(extraOptsBuf);
+ parseExtraOpts(extraOptsBuf, NULL);
/* Set the properties for locale */
{
- char langOption[sizeof("-Duser.language=") + 3];
- char regionOption[sizeof("-Duser.region=") + 3];
strcpy(langOption, "-Duser.language=");
strcpy(regionOption, "-Duser.region=");
readLocale(langOption, regionOption);
@@ -761,11 +800,35 @@
}
/*
- * We don't have /tmp on the device, but we often have an SD card. Apps
- * shouldn't use this, but some test suites might want to exercise it.
+ * Set profiler options
*/
- opt.optionString = "-Djava.io.tmpdir=/sdcard";
- mOptions.add(opt);
+ if (libart) {
+ // Number of seconds during profile runs.
+ strcpy(profile_period, "-Xprofile-period:");
+ property_get("dalvik.vm.profile.period_secs", profile_period+17, "10");
+ opt.optionString = profile_period;
+ mOptions.add(opt);
+
+ // Length of each profile run (seconds).
+ strcpy(profile_duration, "-Xprofile-duration:");
+ property_get("dalvik.vm.profile.duration_secs", profile_duration+19, "30");
+ opt.optionString = profile_duration;
+ mOptions.add(opt);
+
+
+ // Polling interval during profile run (microseconds).
+ strcpy(profile_interval, "-Xprofile-interval:");
+ property_get("dalvik.vm.profile.interval_us", profile_interval+19, "10000");
+ opt.optionString = profile_interval;
+ mOptions.add(opt);
+
+ // Coefficient for period backoff. The the period is multiplied
+ // by this value after each profile run.
+ strcpy(profile_backoff, "-Xprofile-backoff:");
+ property_get("dalvik.vm.profile.backoff_coeff", profile_backoff+18, "2.0");
+ opt.optionString = profile_backoff;
+ mOptions.add(opt);
+ }
initArgs.version = JNI_VERSION_1_4;
initArgs.options = mOptions.editArray();
@@ -810,20 +873,23 @@
* Passes the main function two arguments, the class name and the specified
* options string.
*/
-void AndroidRuntime::start(const char* className, const char* options)
+void AndroidRuntime::start(const char* className, const Vector<String8>& options)
{
ALOGD("\n>>>>>> AndroidRuntime START %s <<<<<<\n",
className != NULL ? className : "(unknown)");
+ static const String8 startSystemServer("start-system-server");
+
/*
* 'startSystemServer == true' means runtime is obsolete and not run from
* init.rc anymore, so we print out the boot start event here.
*/
- if (strcmp(options, "start-system-server") == 0) {
- /* track our progress through the boot sequence */
- const int LOG_BOOT_PROGRESS_START = 3000;
- LOG_EVENT_LONG(LOG_BOOT_PROGRESS_START,
- ns2ms(systemTime(SYSTEM_TIME_MONOTONIC)));
+ for (size_t i = 0; i < options.size(); ++i) {
+ if (options[i] == startSystemServer) {
+ /* track our progress through the boot sequence */
+ const int LOG_BOOT_PROGRESS_START = 3000;
+ LOG_EVENT_LONG(LOG_BOOT_PROGRESS_START, ns2ms(systemTime(SYSTEM_TIME_MONOTONIC)));
+ }
}
const char* rootDir = getenv("ANDROID_ROOT");
@@ -864,17 +930,20 @@
jclass stringClass;
jobjectArray strArray;
jstring classNameStr;
- jstring optionsStr;
stringClass = env->FindClass("java/lang/String");
assert(stringClass != NULL);
- strArray = env->NewObjectArray(2, stringClass, NULL);
+ strArray = env->NewObjectArray(options.size() + 1, stringClass, NULL);
assert(strArray != NULL);
classNameStr = env->NewStringUTF(className);
assert(classNameStr != NULL);
env->SetObjectArrayElement(strArray, 0, classNameStr);
- optionsStr = env->NewStringUTF(options);
- env->SetObjectArrayElement(strArray, 1, optionsStr);
+
+ for (size_t i = 0; i < options.size(); ++i) {
+ jstring optionsStr = env->NewStringUTF(options.itemAt(i).string());
+ assert(optionsStr != NULL);
+ env->SetObjectArrayElement(strArray, i + 1, optionsStr);
+ }
/*
* Start VM. This thread becomes the main thread of the VM, and will
@@ -1100,7 +1169,6 @@
}
static const RegJNIRec gRegJNI[] = {
- REG_JNI(register_android_debug_JNITest),
REG_JNI(register_com_android_internal_os_RuntimeInit),
REG_JNI(register_android_os_SystemClock),
REG_JNI(register_android_util_EventLog),
@@ -1186,6 +1254,7 @@
REG_JNI(register_android_net_wifi_WifiNative),
REG_JNI(register_android_os_MemoryFile),
REG_JNI(register_com_android_internal_os_ZygoteInit),
+ REG_JNI(register_com_android_internal_os_Zygote),
REG_JNI(register_android_hardware_Camera),
REG_JNI(register_android_hardware_camera2_CameraMetadata),
REG_JNI(register_android_hardware_SensorManager),
diff --git a/core/jni/android/graphics/Bitmap.cpp b/core/jni/android/graphics/Bitmap.cpp
index eea9ee1..7143a8a 100644
--- a/core/jni/android/graphics/Bitmap.cpp
+++ b/core/jni/android/graphics/Bitmap.cpp
@@ -289,8 +289,9 @@
}
static jobject Bitmap_creator(JNIEnv* env, jobject, jintArray jColors,
- int offset, int stride, int width, int height,
- SkBitmap::Config config, jboolean isMutable) {
+ jint offset, jint stride, jint width, jint height,
+ jint configHandle, jboolean isMutable) {
+ SkBitmap::Config config = static_cast<SkBitmap::Config>(configHandle);
if (NULL != jColors) {
size_t n = env->GetArrayLength(jColors);
if (n < SkAbs32(stride) * (size_t)height) {
@@ -321,8 +322,10 @@
getPremulBitmapCreateFlags(isMutable), NULL, NULL);
}
-static jobject Bitmap_copy(JNIEnv* env, jobject, const SkBitmap* src,
- SkBitmap::Config dstConfig, jboolean isMutable) {
+static jobject Bitmap_copy(JNIEnv* env, jobject, jlong srcHandle,
+ jint dstConfigHandle, jboolean isMutable) {
+ const SkBitmap* src = reinterpret_cast<SkBitmap*>(srcHandle);
+ SkBitmap::Config dstConfig = static_cast<SkBitmap::Config>(dstConfigHandle);
SkBitmap result;
JavaPixelAllocator allocator(env);
@@ -333,7 +336,8 @@
getPremulBitmapCreateFlags(isMutable), NULL, NULL);
}
-static void Bitmap_destructor(JNIEnv* env, jobject, SkBitmap* bitmap) {
+static void Bitmap_destructor(JNIEnv* env, jobject, jlong bitmapHandle) {
+ SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
#ifdef USE_OPENGL_RENDERER
if (android::uirenderer::Caches::hasInstance()) {
android::uirenderer::Caches::getInstance().resourceCache.destructor(bitmap);
@@ -343,24 +347,28 @@
delete bitmap;
}
-static jboolean Bitmap_recycle(JNIEnv* env, jobject, SkBitmap* bitmap) {
+static jboolean Bitmap_recycle(JNIEnv* env, jobject, jlong bitmapHandle) {
+ SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
#ifdef USE_OPENGL_RENDERER
if (android::uirenderer::Caches::hasInstance()) {
- return android::uirenderer::Caches::getInstance().resourceCache.recycle(bitmap);
+ bool result;
+ result = android::uirenderer::Caches::getInstance().resourceCache.recycle(bitmap);
+ return result ? JNI_TRUE : JNI_FALSE;
}
#endif // USE_OPENGL_RENDERER
bitmap->setPixels(NULL, NULL);
- return true;
+ return JNI_TRUE;
}
-static void Bitmap_reconfigure(JNIEnv* env, jobject clazz, jint bitmapInt,
- int width, int height, SkBitmap::Config config, int allocSize) {
+static void Bitmap_reconfigure(JNIEnv* env, jobject clazz, jlong bitmapHandle,
+ jint width, jint height, jint configHandle, jint allocSize) {
+ SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
+ SkBitmap::Config config = static_cast<SkBitmap::Config>(configHandle);
if (width * height * SkBitmap::ComputeBytesPerPixel(config) > allocSize) {
// done in native as there's no way to get BytesPerPixel in Java
doThrowIAE(env, "Bitmap not large enough to support new configuration");
return;
}
- SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapInt);
SkPixelRef* ref = bitmap->pixelRef();
SkSafeRef(ref);
bitmap->setConfig(config, width, height);
@@ -380,9 +388,10 @@
kWEBP_JavaEncodeFormat = 2
};
-static bool Bitmap_compress(JNIEnv* env, jobject clazz, SkBitmap* bitmap,
- int format, int quality,
- jobject jstream, jbyteArray jstorage) {
+static jboolean Bitmap_compress(JNIEnv* env, jobject clazz, jlong bitmapHandle,
+ jint format, jint quality,
+ jobject jstream, jbyteArray jstorage) {
+ SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
SkImageEncoder::Type fm;
switch (format) {
@@ -396,7 +405,7 @@
fm = SkImageEncoder::kWEBP_Type;
break;
default:
- return false;
+ return JNI_FALSE;
}
bool success = false;
@@ -404,12 +413,12 @@
SkAutoLockPixels alp(*bitmap);
if (NULL == bitmap->getPixels()) {
- return false;
+ return JNI_FALSE;
}
SkWStream* strm = CreateJavaOutputStreamAdaptor(env, jstream, jstorage);
if (NULL == strm) {
- return false;
+ return JNI_FALSE;
}
SkImageEncoder* encoder = SkImageEncoder::Create(fm);
@@ -419,40 +428,48 @@
}
delete strm;
}
- return success;
+ return success ? JNI_TRUE : JNI_FALSE;
}
-static void Bitmap_erase(JNIEnv* env, jobject, SkBitmap* bitmap, jint color) {
+static void Bitmap_erase(JNIEnv* env, jobject, jlong bitmapHandle, jint color) {
+ SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
bitmap->eraseColor(color);
}
-static int Bitmap_rowBytes(JNIEnv* env, jobject, SkBitmap* bitmap) {
- return bitmap->rowBytes();
+static jint Bitmap_rowBytes(JNIEnv* env, jobject, jlong bitmapHandle) {
+ SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
+ return static_cast<jint>(bitmap->rowBytes());
}
-static int Bitmap_config(JNIEnv* env, jobject, SkBitmap* bitmap) {
- return bitmap->config();
+static jint Bitmap_config(JNIEnv* env, jobject, jlong bitmapHandle) {
+ SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
+ return static_cast<jint>(bitmap->config());
}
-static int Bitmap_getGenerationId(JNIEnv* env, jobject, SkBitmap* bitmap) {
- return bitmap->getGenerationID();
+static jint Bitmap_getGenerationId(JNIEnv* env, jobject, jlong bitmapHandle) {
+ SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
+ return static_cast<jint>(bitmap->getGenerationID());
}
-static jboolean Bitmap_hasAlpha(JNIEnv* env, jobject, SkBitmap* bitmap) {
- return !bitmap->isOpaque();
+static jboolean Bitmap_hasAlpha(JNIEnv* env, jobject, jlong bitmapHandle) {
+ SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
+ return !bitmap->isOpaque() ? JNI_TRUE : JNI_FALSE;
}
-static void Bitmap_setHasAlpha(JNIEnv* env, jobject, SkBitmap* bitmap,
+static void Bitmap_setHasAlpha(JNIEnv* env, jobject, jlong bitmapHandle,
jboolean hasAlpha) {
+ SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
bitmap->setIsOpaque(!hasAlpha);
}
-static jboolean Bitmap_hasMipMap(JNIEnv* env, jobject, SkBitmap* bitmap) {
- return bitmap->hasHardwareMipMap();
+static jboolean Bitmap_hasMipMap(JNIEnv* env, jobject, jlong bitmapHandle) {
+ SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
+ return bitmap->hasHardwareMipMap() ? JNI_TRUE : JNI_FALSE;
}
-static void Bitmap_setHasMipMap(JNIEnv* env, jobject, SkBitmap* bitmap,
+static void Bitmap_setHasMipMap(JNIEnv* env, jobject, jlong bitmapHandle,
jboolean hasMipMap) {
+ SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
bitmap->setHasHardwareMipMap(hasMipMap);
}
@@ -526,12 +543,13 @@
}
static jboolean Bitmap_writeToParcel(JNIEnv* env, jobject,
- const SkBitmap* bitmap,
+ jlong bitmapHandle,
jboolean isMutable, jint density,
jobject parcel) {
+ const SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
if (parcel == NULL) {
SkDebugf("------- writeToParcel null parcel\n");
- return false;
+ return JNI_FALSE;
}
android::Parcel* p = android::parcelForJavaObject(env, parcel);
@@ -562,7 +580,7 @@
android::status_t status = p->writeBlob(size, &blob);
if (status) {
doThrowRE(env, "Could not write bitmap to parcel blob.");
- return false;
+ return JNI_FALSE;
}
bitmap->lockPixels();
@@ -575,12 +593,14 @@
bitmap->unlockPixels();
blob.release();
- return true;
+ return JNI_TRUE;
}
static jobject Bitmap_extractAlpha(JNIEnv* env, jobject clazz,
- const SkBitmap* src, const SkPaint* paint,
+ jlong srcHandle, jlong paintHandle,
jintArray offsetXY) {
+ const SkBitmap* src = reinterpret_cast<SkBitmap*>(srcHandle);
+ const SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
SkIPoint offset;
SkBitmap* dst = new SkBitmap;
JavaPixelAllocator allocator(env);
@@ -606,8 +626,9 @@
///////////////////////////////////////////////////////////////////////////////
-static int Bitmap_getPixel(JNIEnv* env, jobject, const SkBitmap* bitmap,
- int x, int y, bool isPremultiplied) {
+static jint Bitmap_getPixel(JNIEnv* env, jobject, jlong bitmapHandle,
+ jint x, jint y, jboolean isPremultiplied) {
+ const SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
SkAutoLockPixels alp(*bitmap);
ToColorProc proc = ChooseToColorProc(*bitmap, isPremultiplied);
@@ -621,12 +642,13 @@
SkColor dst[1];
proc(dst, src, 1, bitmap->getColorTable());
- return dst[0];
+ return static_cast<jint>(dst[0]);
}
-static void Bitmap_getPixels(JNIEnv* env, jobject, const SkBitmap* bitmap,
- jintArray pixelArray, int offset, int stride,
- int x, int y, int width, int height, bool isPremultiplied) {
+static void Bitmap_getPixels(JNIEnv* env, jobject, jlong bitmapHandle,
+ jintArray pixelArray, jint offset, jint stride,
+ jint x, jint y, jint width, jint height, jboolean isPremultiplied) {
+ const SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
SkAutoLockPixels alp(*bitmap);
ToColorProc proc = ChooseToColorProc(*bitmap, isPremultiplied);
@@ -651,8 +673,10 @@
///////////////////////////////////////////////////////////////////////////////
-static void Bitmap_setPixel(JNIEnv* env, jobject, const SkBitmap* bitmap,
- int x, int y, SkColor color, bool isPremultiplied) {
+static void Bitmap_setPixel(JNIEnv* env, jobject, jlong bitmapHandle,
+ jint x, jint y, jint colorHandle, jboolean isPremultiplied) {
+ const SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
+ SkColor color = static_cast<SkColor>(colorHandle);
SkAutoLockPixels alp(*bitmap);
if (NULL == bitmap->getPixels()) {
return;
@@ -667,15 +691,17 @@
bitmap->notifyPixelsChanged();
}
-static void Bitmap_setPixels(JNIEnv* env, jobject, const SkBitmap* bitmap,
- jintArray pixelArray, int offset, int stride,
- int x, int y, int width, int height, bool isPremultiplied) {
+static void Bitmap_setPixels(JNIEnv* env, jobject, jlong bitmapHandle,
+ jintArray pixelArray, jint offset, jint stride,
+ jint x, jint y, jint width, jint height, jboolean isPremultiplied) {
+ const SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
GraphicsJNI::SetPixels(env, pixelArray, offset, stride,
x, y, width, height, *bitmap, isPremultiplied);
}
static void Bitmap_copyPixelsToBuffer(JNIEnv* env, jobject,
- const SkBitmap* bitmap, jobject jbuffer) {
+ jlong bitmapHandle, jobject jbuffer) {
+ const SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
SkAutoLockPixels alp(*bitmap);
const void* src = bitmap->getPixels();
@@ -688,7 +714,8 @@
}
static void Bitmap_copyPixelsFromBuffer(JNIEnv* env, jobject,
- const SkBitmap* bitmap, jobject jbuffer) {
+ jlong bitmapHandle, jobject jbuffer) {
+ SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
SkAutoLockPixels alp(*bitmap);
void* dst = bitmap->getPixels();
@@ -700,12 +727,14 @@
}
}
-static bool Bitmap_sameAs(JNIEnv* env, jobject, const SkBitmap* bm0,
- const SkBitmap* bm1) {
+static jboolean Bitmap_sameAs(JNIEnv* env, jobject, jlong bm0Handle,
+ jlong bm1Handle) {
+ const SkBitmap* bm0 = reinterpret_cast<SkBitmap*>(bm0Handle);
+ const SkBitmap* bm1 = reinterpret_cast<SkBitmap*>(bm1Handle);
if (bm0->width() != bm1->width() ||
bm0->height() != bm1->height() ||
bm0->config() != bm1->config()) {
- return false;
+ return JNI_FALSE;
}
SkAutoLockPixels alp0(*bm0);
@@ -713,24 +742,24 @@
// if we can't load the pixels, return false
if (NULL == bm0->getPixels() || NULL == bm1->getPixels()) {
- return false;
+ return JNI_FALSE;
}
if (bm0->config() == SkBitmap::kIndex8_Config) {
SkColorTable* ct0 = bm0->getColorTable();
SkColorTable* ct1 = bm1->getColorTable();
if (NULL == ct0 || NULL == ct1) {
- return false;
+ return JNI_FALSE;
}
if (ct0->count() != ct1->count()) {
- return false;
+ return JNI_FALSE;
}
SkAutoLockColors alc0(ct0);
SkAutoLockColors alc1(ct1);
const size_t size = ct0->count() * sizeof(SkPMColor);
if (memcmp(alc0.colors(), alc1.colors(), size) != 0) {
- return false;
+ return JNI_FALSE;
}
}
@@ -741,13 +770,14 @@
const size_t size = bm0->width() * bm0->bytesPerPixel();
for (int y = 0; y < h; y++) {
if (memcmp(bm0->getAddr(0, y), bm1->getAddr(0, y), size) != 0) {
- return false;
+ return JNI_FALSE;
}
}
- return true;
+ return JNI_TRUE;
}
-static void Bitmap_prepareToDraw(JNIEnv* env, jobject, SkBitmap* bitmap) {
+static void Bitmap_prepareToDraw(JNIEnv* env, jobject, jlong bitmapHandle) {
+ SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
bitmap->lockPixels();
bitmap->unlockPixels();
}
@@ -759,38 +789,38 @@
static JNINativeMethod gBitmapMethods[] = {
{ "nativeCreate", "([IIIIIIZ)Landroid/graphics/Bitmap;",
(void*)Bitmap_creator },
- { "nativeCopy", "(IIZ)Landroid/graphics/Bitmap;",
+ { "nativeCopy", "(JIZ)Landroid/graphics/Bitmap;",
(void*)Bitmap_copy },
- { "nativeDestructor", "(I)V", (void*)Bitmap_destructor },
- { "nativeRecycle", "(I)Z", (void*)Bitmap_recycle },
- { "nativeReconfigure", "(IIIII)V", (void*)Bitmap_reconfigure },
- { "nativeCompress", "(IIILjava/io/OutputStream;[B)Z",
+ { "nativeDestructor", "(J)V", (void*)Bitmap_destructor },
+ { "nativeRecycle", "(J)Z", (void*)Bitmap_recycle },
+ { "nativeReconfigure", "(JIIII)V", (void*)Bitmap_reconfigure },
+ { "nativeCompress", "(JIILjava/io/OutputStream;[B)Z",
(void*)Bitmap_compress },
- { "nativeErase", "(II)V", (void*)Bitmap_erase },
- { "nativeRowBytes", "(I)I", (void*)Bitmap_rowBytes },
- { "nativeConfig", "(I)I", (void*)Bitmap_config },
- { "nativeHasAlpha", "(I)Z", (void*)Bitmap_hasAlpha },
- { "nativeSetHasAlpha", "(IZ)V", (void*)Bitmap_setHasAlpha },
- { "nativeHasMipMap", "(I)Z", (void*)Bitmap_hasMipMap },
- { "nativeSetHasMipMap", "(IZ)V", (void*)Bitmap_setHasMipMap },
+ { "nativeErase", "(JI)V", (void*)Bitmap_erase },
+ { "nativeRowBytes", "(J)I", (void*)Bitmap_rowBytes },
+ { "nativeConfig", "(J)I", (void*)Bitmap_config },
+ { "nativeHasAlpha", "(J)Z", (void*)Bitmap_hasAlpha },
+ { "nativeSetHasAlpha", "(JZ)V", (void*)Bitmap_setHasAlpha },
+ { "nativeHasMipMap", "(J)Z", (void*)Bitmap_hasMipMap },
+ { "nativeSetHasMipMap", "(JZ)V", (void*)Bitmap_setHasMipMap },
{ "nativeCreateFromParcel",
"(Landroid/os/Parcel;)Landroid/graphics/Bitmap;",
(void*)Bitmap_createFromParcel },
- { "nativeWriteToParcel", "(IZILandroid/os/Parcel;)Z",
+ { "nativeWriteToParcel", "(JZILandroid/os/Parcel;)Z",
(void*)Bitmap_writeToParcel },
- { "nativeExtractAlpha", "(II[I)Landroid/graphics/Bitmap;",
+ { "nativeExtractAlpha", "(JJ[I)Landroid/graphics/Bitmap;",
(void*)Bitmap_extractAlpha },
- { "nativeGenerationId", "(I)I", (void*)Bitmap_getGenerationId },
- { "nativeGetPixel", "(IIIZ)I", (void*)Bitmap_getPixel },
- { "nativeGetPixels", "(I[IIIIIIIZ)V", (void*)Bitmap_getPixels },
- { "nativeSetPixel", "(IIIIZ)V", (void*)Bitmap_setPixel },
- { "nativeSetPixels", "(I[IIIIIIIZ)V", (void*)Bitmap_setPixels },
- { "nativeCopyPixelsToBuffer", "(ILjava/nio/Buffer;)V",
+ { "nativeGenerationId", "(J)I", (void*)Bitmap_getGenerationId },
+ { "nativeGetPixel", "(JIIZ)I", (void*)Bitmap_getPixel },
+ { "nativeGetPixels", "(J[IIIIIIIZ)V", (void*)Bitmap_getPixels },
+ { "nativeSetPixel", "(JIIIZ)V", (void*)Bitmap_setPixel },
+ { "nativeSetPixels", "(J[IIIIIIIZ)V", (void*)Bitmap_setPixels },
+ { "nativeCopyPixelsToBuffer", "(JLjava/nio/Buffer;)V",
(void*)Bitmap_copyPixelsToBuffer },
- { "nativeCopyPixelsFromBuffer", "(ILjava/nio/Buffer;)V",
+ { "nativeCopyPixelsFromBuffer", "(JLjava/nio/Buffer;)V",
(void*)Bitmap_copyPixelsFromBuffer },
- { "nativeSameAs", "(II)Z", (void*)Bitmap_sameAs },
- { "nativePrepareToDraw", "(I)V", (void*)Bitmap_prepareToDraw },
+ { "nativeSameAs", "(JJ)Z", (void*)Bitmap_sameAs },
+ { "nativePrepareToDraw", "(J)V", (void*)Bitmap_prepareToDraw },
};
#define kClassPathName "android/graphics/Bitmap"
diff --git a/core/jni/android/graphics/BitmapFactory.cpp b/core/jni/android/graphics/BitmapFactory.cpp
index da6219f..44bf7f8 100644
--- a/core/jni/android/graphics/BitmapFactory.cpp
+++ b/core/jni/android/graphics/BitmapFactory.cpp
@@ -106,17 +106,19 @@
chunk->paddingRight = int(chunk->paddingRight * scale + 0.5f);
chunk->paddingBottom = int(chunk->paddingBottom * scale + 0.5f);
+ int32_t* xDivs = chunk->getXDivs();
for (int i = 0; i < chunk->numXDivs; i++) {
- chunk->xDivs[i] = int(chunk->xDivs[i] * scale + 0.5f);
- if (i > 0 && chunk->xDivs[i] == chunk->xDivs[i - 1]) {
- chunk->xDivs[i]++;
+ xDivs[i] = int32_t(xDivs[i] * scale + 0.5f);
+ if (i > 0 && xDivs[i] == xDivs[i - 1]) {
+ xDivs[i]++;
}
}
+ int32_t* yDivs = chunk->getYDivs();
for (int i = 0; i < chunk->numYDivs; i++) {
- chunk->yDivs[i] = int(chunk->yDivs[i] * scale + 0.5f);
- if (i > 0 && chunk->yDivs[i] == chunk->yDivs[i - 1]) {
- chunk->yDivs[i]++;
+ yDivs[i] = int32_t(yDivs[i] * scale + 0.5f);
+ if (i > 0 && yDivs[i] == yDivs[i - 1]) {
+ yDivs[i]++;
}
}
}
@@ -272,7 +274,7 @@
SkBitmap* outputBitmap = NULL;
unsigned int existingBufferSize = 0;
if (javaBitmap != NULL) {
- outputBitmap = (SkBitmap*) env->GetIntField(javaBitmap, gBitmap_nativeBitmapFieldID);
+ outputBitmap = (SkBitmap*) env->GetLongField(javaBitmap, gBitmap_nativeBitmapFieldID);
if (outputBitmap->isImmutable()) {
ALOGW("Unable to reuse an immutable bitmap as an image decoder target.");
javaBitmap = NULL;
@@ -365,7 +367,7 @@
return nullObjectReturn("primitive array == null");
}
- peeker.fPatch->serialize(array);
+ memcpy(array, peeker.fPatch, peeker.fPatchSize);
env->ReleasePrimitiveArrayCritical(ninePatchChunk, array, 0);
}
@@ -525,7 +527,7 @@
return doDecode(env, stream, padding, bitmapFactoryOptions, weOwnTheFD);
}
-static jobject nativeDecodeAsset(JNIEnv* env, jobject clazz, jint native_asset,
+static jobject nativeDecodeAsset(JNIEnv* env, jobject clazz, jlong native_asset,
jobject padding, jobject options) {
SkStreamRewindable* stream;
@@ -548,7 +550,7 @@
}
static jobject nativeDecodeByteArray(JNIEnv* env, jobject, jbyteArray byteArray,
- int offset, int length, jobject options) {
+ jint offset, jint length, jobject options) {
/* If optionsShareable() we could decide to just wrap the java array and
share it, but that means adding a globalref to the java array object
@@ -585,7 +587,7 @@
},
{ "nativeDecodeAsset",
- "(ILandroid/graphics/Rect;Landroid/graphics/BitmapFactory$Options;)Landroid/graphics/Bitmap;",
+ "(JLandroid/graphics/Rect;Landroid/graphics/BitmapFactory$Options;)Landroid/graphics/Bitmap;",
(void*)nativeDecodeAsset
},
@@ -638,7 +640,7 @@
jclass bitmap_class = env->FindClass("android/graphics/Bitmap");
SkASSERT(bitmap_class);
- gBitmap_nativeBitmapFieldID = getFieldIDCheck(env, bitmap_class, "mNativeBitmap", "I");
+ gBitmap_nativeBitmapFieldID = getFieldIDCheck(env, bitmap_class, "mNativeBitmap", "J");
gBitmap_layoutBoundsFieldID = getFieldIDCheck(env, bitmap_class, "mLayoutBounds", "[I");
int ret = AndroidRuntime::registerNativeMethods(env,
"android/graphics/BitmapFactory$Options",
diff --git a/core/jni/android/graphics/BitmapRegionDecoder.cpp b/core/jni/android/graphics/BitmapRegionDecoder.cpp
index ee47ac4..e7d2422 100644
--- a/core/jni/android/graphics/BitmapRegionDecoder.cpp
+++ b/core/jni/android/graphics/BitmapRegionDecoder.cpp
@@ -102,7 +102,7 @@
}
static jobject nativeNewInstanceFromByteArray(JNIEnv* env, jobject, jbyteArray byteArray,
- int offset, int length, jboolean isShareable) {
+ jint offset, jint length, jboolean isShareable) {
/* If isShareable we could decide to just wrap the java array and
share it, but that means adding a globalref to the java array object
For now we just always copy the array's data if isShareable.
@@ -151,7 +151,7 @@
}
static jobject nativeNewInstanceFromAsset(JNIEnv* env, jobject clazz,
- jint native_asset, // Asset
+ jlong native_asset, // Asset
jboolean isShareable) {
Asset* asset = reinterpret_cast<Asset*>(native_asset);
SkAutoTUnref<SkMemoryStream> stream(CopyAssetToStream(asset));
@@ -170,8 +170,9 @@
* purgeable not supported
* reportSizeToVM not supported
*/
-static jobject nativeDecodeRegion(JNIEnv* env, jobject, SkBitmapRegionDecoder *brd,
- int start_x, int start_y, int width, int height, jobject options) {
+static jobject nativeDecodeRegion(JNIEnv* env, jobject, jlong brdHandle,
+ jint start_x, jint start_y, jint width, jint height, jobject options) {
+ SkBitmapRegionDecoder *brd = reinterpret_cast<SkBitmapRegionDecoder*>(brdHandle);
jobject tileBitmap = NULL;
SkImageDecoder *decoder = brd->getDecoder();
int sampleSize = 1;
@@ -256,15 +257,18 @@
return GraphicsJNI::createBitmap(env, bitmap, buff, bitmapCreateFlags, NULL, NULL, -1);
}
-static int nativeGetHeight(JNIEnv* env, jobject, SkBitmapRegionDecoder *brd) {
- return brd->getHeight();
+static jint nativeGetHeight(JNIEnv* env, jobject, jlong brdHandle) {
+ SkBitmapRegionDecoder *brd = reinterpret_cast<SkBitmapRegionDecoder*>(brdHandle);
+ return static_cast<jint>(brd->getHeight());
}
-static int nativeGetWidth(JNIEnv* env, jobject, SkBitmapRegionDecoder *brd) {
- return brd->getWidth();
+static jint nativeGetWidth(JNIEnv* env, jobject, jlong brdHandle) {
+ SkBitmapRegionDecoder *brd = reinterpret_cast<SkBitmapRegionDecoder*>(brdHandle);
+ return static_cast<jint>(brd->getWidth());
}
-static void nativeClean(JNIEnv* env, jobject, SkBitmapRegionDecoder *brd) {
+static void nativeClean(JNIEnv* env, jobject, jlong brdHandle) {
+ SkBitmapRegionDecoder *brd = reinterpret_cast<SkBitmapRegionDecoder*>(brdHandle);
delete brd;
}
@@ -274,14 +278,14 @@
static JNINativeMethod gBitmapRegionDecoderMethods[] = {
{ "nativeDecodeRegion",
- "(IIIIILandroid/graphics/BitmapFactory$Options;)Landroid/graphics/Bitmap;",
+ "(JIIIILandroid/graphics/BitmapFactory$Options;)Landroid/graphics/Bitmap;",
(void*)nativeDecodeRegion},
- { "nativeGetHeight", "(I)I", (void*)nativeGetHeight},
+ { "nativeGetHeight", "(J)I", (void*)nativeGetHeight},
- { "nativeGetWidth", "(I)I", (void*)nativeGetWidth},
+ { "nativeGetWidth", "(J)I", (void*)nativeGetWidth},
- { "nativeClean", "(I)V", (void*)nativeClean},
+ { "nativeClean", "(J)V", (void*)nativeClean},
{ "nativeNewInstance",
"([BIIZ)Landroid/graphics/BitmapRegionDecoder;",
@@ -299,7 +303,7 @@
},
{ "nativeNewInstance",
- "(IZ)Landroid/graphics/BitmapRegionDecoder;",
+ "(JZ)Landroid/graphics/BitmapRegionDecoder;",
(void*)nativeNewInstanceFromAsset
},
};
diff --git a/core/jni/android/graphics/Camera.cpp b/core/jni/android/graphics/Camera.cpp
index 5176d9a..54d448e 100644
--- a/core/jni/android/graphics/Camera.cpp
+++ b/core/jni/android/graphics/Camera.cpp
@@ -7,84 +7,102 @@
static void Camera_constructor(JNIEnv* env, jobject obj) {
Sk3DView* view = new Sk3DView;
- env->SetIntField(obj, gNativeInstanceFieldID, (int)view);
+ env->SetLongField(obj, gNativeInstanceFieldID, reinterpret_cast<jlong>(view));
}
static void Camera_destructor(JNIEnv* env, jobject obj) {
- delete (Sk3DView*)env->GetIntField(obj, gNativeInstanceFieldID);
+ jlong viewHandle = env->GetLongField(obj, gNativeInstanceFieldID);
+ Sk3DView* view = reinterpret_cast<Sk3DView*>(viewHandle);
+ delete view;
}
static void Camera_save(JNIEnv* env, jobject obj) {
- Sk3DView* v = (Sk3DView*)env->GetIntField(obj, gNativeInstanceFieldID);
+ jlong viewHandle = env->GetLongField(obj, gNativeInstanceFieldID);
+ Sk3DView* v = reinterpret_cast<Sk3DView*>(viewHandle);
v->save();
}
static void Camera_restore(JNIEnv* env, jobject obj) {
- Sk3DView* v = (Sk3DView*)env->GetIntField(obj, gNativeInstanceFieldID);
+ jlong viewHandle = env->GetLongField(obj, gNativeInstanceFieldID);
+ Sk3DView* v = reinterpret_cast<Sk3DView*>(viewHandle);
v->restore();
}
static void Camera_translate(JNIEnv* env, jobject obj,
- float dx, float dy, float dz) {
- Sk3DView* v = (Sk3DView*)env->GetIntField(obj, gNativeInstanceFieldID);
+ jfloat dx, jfloat dy, jfloat dz) {
+ jlong viewHandle = env->GetLongField(obj, gNativeInstanceFieldID);
+ Sk3DView* v = reinterpret_cast<Sk3DView*>(viewHandle);
v->translate(SkFloatToScalar(dx), SkFloatToScalar(dy), SkFloatToScalar(dz));
}
-static void Camera_rotateX(JNIEnv* env, jobject obj, float degrees) {
- Sk3DView* v = (Sk3DView*)env->GetIntField(obj, gNativeInstanceFieldID);
+static void Camera_rotateX(JNIEnv* env, jobject obj, jfloat degrees) {
+ jlong viewHandle = env->GetLongField(obj, gNativeInstanceFieldID);
+ Sk3DView* v = reinterpret_cast<Sk3DView*>(viewHandle);
v->rotateX(SkFloatToScalar(degrees));
}
-static void Camera_rotateY(JNIEnv* env, jobject obj, float degrees) {
- Sk3DView* v = (Sk3DView*)env->GetIntField(obj, gNativeInstanceFieldID);
+static void Camera_rotateY(JNIEnv* env, jobject obj, jfloat degrees) {
+ jlong viewHandle = env->GetLongField(obj, gNativeInstanceFieldID);
+ Sk3DView* v = reinterpret_cast<Sk3DView*>(viewHandle);
v->rotateY(SkFloatToScalar(degrees));
}
-static void Camera_rotateZ(JNIEnv* env, jobject obj, float degrees) {
- Sk3DView* v = (Sk3DView*)env->GetIntField(obj, gNativeInstanceFieldID);
+static void Camera_rotateZ(JNIEnv* env, jobject obj, jfloat degrees) {
+ jlong viewHandle = env->GetLongField(obj, gNativeInstanceFieldID);
+ Sk3DView* v = reinterpret_cast<Sk3DView*>(viewHandle);
v->rotateZ(SkFloatToScalar(degrees));
}
static void Camera_rotate(JNIEnv* env, jobject obj, jfloat x, jfloat y, jfloat z) {
- Sk3DView* v = (Sk3DView*)env->GetIntField(obj, gNativeInstanceFieldID);
+ jlong viewHandle = env->GetLongField(obj, gNativeInstanceFieldID);
+ Sk3DView* v = reinterpret_cast<Sk3DView*>(viewHandle);
v->rotateX(SkFloatToScalar(x));
v->rotateY(SkFloatToScalar(y));
v->rotateZ(SkFloatToScalar(z));
}
static void Camera_setLocation(JNIEnv* env, jobject obj, jfloat x, jfloat y, jfloat z) {
- Sk3DView* v = (Sk3DView*)env->GetIntField(obj, gNativeInstanceFieldID);
+ jlong viewHandle = env->GetLongField(obj, gNativeInstanceFieldID);
+ Sk3DView* v = reinterpret_cast<Sk3DView*>(viewHandle);
v->setCameraLocation(SkFloatToScalar(x), SkFloatToScalar(y), SkFloatToScalar(z));
}
static jfloat Camera_getLocationX(JNIEnv* env, jobject obj) {
- Sk3DView* v = (Sk3DView*)env->GetIntField(obj, gNativeInstanceFieldID);
+ jlong viewHandle = env->GetLongField(obj, gNativeInstanceFieldID);
+ Sk3DView* v = reinterpret_cast<Sk3DView*>(viewHandle);
return SkScalarToFloat(v->getCameraLocationX());
}
static jfloat Camera_getLocationY(JNIEnv* env, jobject obj) {
- Sk3DView* v = (Sk3DView*)env->GetIntField(obj, gNativeInstanceFieldID);
+ jlong viewHandle = env->GetLongField(obj, gNativeInstanceFieldID);
+ Sk3DView* v = reinterpret_cast<Sk3DView*>(viewHandle);
return SkScalarToFloat(v->getCameraLocationY());
}
static jfloat Camera_getLocationZ(JNIEnv* env, jobject obj) {
- Sk3DView* v = (Sk3DView*)env->GetIntField(obj, gNativeInstanceFieldID);
+ jlong viewHandle = env->GetLongField(obj, gNativeInstanceFieldID);
+ Sk3DView* v = reinterpret_cast<Sk3DView*>(viewHandle);
return SkScalarToFloat(v->getCameraLocationZ());
}
-static void Camera_getMatrix(JNIEnv* env, jobject obj, int native_matrix) {
- Sk3DView* v = (Sk3DView*)env->GetIntField(obj, gNativeInstanceFieldID);
- v->getMatrix((SkMatrix*)native_matrix);
+static void Camera_getMatrix(JNIEnv* env, jobject obj, jlong matrixHandle) {
+ SkMatrix* native_matrix = reinterpret_cast<SkMatrix*>(matrixHandle);
+ jlong viewHandle = env->GetLongField(obj, gNativeInstanceFieldID);
+ Sk3DView* v = reinterpret_cast<Sk3DView*>(viewHandle);
+ v->getMatrix(native_matrix);
}
-static void Camera_applyToCanvas(JNIEnv* env, jobject obj, int native_canvas) {
- Sk3DView* v = (Sk3DView*)env->GetIntField(obj, gNativeInstanceFieldID);
+static void Camera_applyToCanvas(JNIEnv* env, jobject obj, jlong canvasHandle) {
+ SkCanvas* native_canvas = reinterpret_cast<SkCanvas*>(canvasHandle);
+ jlong viewHandle = env->GetLongField(obj, gNativeInstanceFieldID);
+ Sk3DView* v = reinterpret_cast<Sk3DView*>(viewHandle);
v->applyToCanvas((SkCanvas*)native_canvas);
}
-static float Camera_dotWithNormal(JNIEnv* env, jobject obj,
- float x, float y, float z) {
- Sk3DView* v = (Sk3DView*)env->GetIntField(obj, gNativeInstanceFieldID);
+static jfloat Camera_dotWithNormal(JNIEnv* env, jobject obj,
+ jfloat x, jfloat y, jfloat z) {
+ jlong viewHandle = env->GetLongField(obj, gNativeInstanceFieldID);
+ Sk3DView* v = reinterpret_cast<Sk3DView*>(viewHandle);
SkScalar dot = v->dotWithNormal(SkFloatToScalar(x), SkFloatToScalar(y),
SkFloatToScalar(z));
return SkScalarToFloat(dot);
@@ -111,8 +129,8 @@
{ "getLocationX", "()F", (void*)Camera_getLocationX },
{ "getLocationY", "()F", (void*)Camera_getLocationY },
{ "getLocationZ", "()F", (void*)Camera_getLocationZ },
- { "nativeGetMatrix", "(I)V", (void*)Camera_getMatrix },
- { "nativeApplyToCanvas", "(I)V", (void*)Camera_applyToCanvas },
+ { "nativeGetMatrix", "(J)V", (void*)Camera_getMatrix },
+ { "nativeApplyToCanvas", "(J)V", (void*)Camera_applyToCanvas },
{ "dotWithNormal", "(FFF)F", (void*)Camera_dotWithNormal }
};
@@ -121,7 +139,7 @@
if (clazz == 0) {
return -1;
}
- gNativeInstanceFieldID = env->GetFieldID(clazz, "native_instance", "I");
+ gNativeInstanceFieldID = env->GetFieldID(clazz, "native_instance", "J");
if (gNativeInstanceFieldID == 0) {
return -1;
}
diff --git a/core/jni/android/graphics/Canvas.cpp b/core/jni/android/graphics/Canvas.cpp
index 813dd5a..11089da 100644
--- a/core/jni/android/graphics/Canvas.cpp
+++ b/core/jni/android/graphics/Canvas.cpp
@@ -38,13 +38,13 @@
static uint32_t get_thread_msec() {
#if defined(HAVE_POSIX_CLOCKS)
struct timespec tm;
-
+
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tm);
-
+
return tm.tv_sec * 1000LL + tm.tv_nsec / 1000000;
#else
struct timeval tv;
-
+
gettimeofday(&tv, NULL);
return tv.tv_sec * 1000LL + tv.tv_usec / 1000;
#endif
@@ -70,23 +70,27 @@
class SkCanvasGlue {
public:
- static void finalizer(JNIEnv* env, jobject clazz, SkCanvas* canvas) {
+ static void finalizer(JNIEnv* env, jobject clazz, jlong canvasHandle) {
+ SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle);
canvas->unref();
}
- static SkCanvas* initRaster(JNIEnv* env, jobject, SkBitmap* bitmap) {
+ static jlong initRaster(JNIEnv* env, jobject, jlong bitmapHandle) {
+ SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
if (bitmap) {
- return new SkCanvas(*bitmap);
+ return reinterpret_cast<jlong>(new SkCanvas(*bitmap));
} else {
// Create an empty bitmap device to prevent callers from crashing
// if they attempt to draw into this canvas.
SkBitmap emptyBitmap;
- return new SkCanvas(emptyBitmap);
+ return reinterpret_cast<jlong>(new SkCanvas(emptyBitmap));
}
}
-
+
static void copyCanvasState(JNIEnv* env, jobject clazz,
- SkCanvas* srcCanvas, SkCanvas* dstCanvas) {
+ jlong srcCanvasHandle, jlong dstCanvasHandle) {
+ SkCanvas* srcCanvas = reinterpret_cast<SkCanvas*>(srcCanvasHandle);
+ SkCanvas* dstCanvas = reinterpret_cast<SkCanvas*>(dstCanvasHandle);
if (srcCanvas && dstCanvas) {
dstCanvas->setMatrix(srcCanvas->getTotalMatrix());
if (NULL != srcCanvas->getDevice() && NULL != dstCanvas->getDevice()) {
@@ -110,73 +114,89 @@
static jboolean isOpaque(JNIEnv* env, jobject jcanvas) {
NPE_CHECK_RETURN_ZERO(env, jcanvas);
SkCanvas* canvas = GraphicsJNI::getNativeCanvas(env, jcanvas);
- return canvas->getDevice()->accessBitmap(false).isOpaque();
- }
-
- static int getWidth(JNIEnv* env, jobject jcanvas) {
- NPE_CHECK_RETURN_ZERO(env, jcanvas);
- SkCanvas* canvas = GraphicsJNI::getNativeCanvas(env, jcanvas);
- return canvas->getDevice()->accessBitmap(false).width();
- }
-
- static int getHeight(JNIEnv* env, jobject jcanvas) {
- NPE_CHECK_RETURN_ZERO(env, jcanvas);
- SkCanvas* canvas = GraphicsJNI::getNativeCanvas(env, jcanvas);
- return canvas->getDevice()->accessBitmap(false).height();
+ bool result = canvas->getDevice()->accessBitmap(false).isOpaque();
+ return result ? JNI_TRUE : JNI_FALSE;
}
- static int saveAll(JNIEnv* env, jobject jcanvas) {
+ static jint getWidth(JNIEnv* env, jobject jcanvas) {
NPE_CHECK_RETURN_ZERO(env, jcanvas);
- return GraphicsJNI::getNativeCanvas(env, jcanvas)->save();
+ SkCanvas* canvas = GraphicsJNI::getNativeCanvas(env, jcanvas);
+ int width = canvas->getDevice()->accessBitmap(false).width();
+ return static_cast<jint>(width);
}
-
- static int save(JNIEnv* env, jobject jcanvas, SkCanvas::SaveFlags flags) {
+
+ static jint getHeight(JNIEnv* env, jobject jcanvas) {
NPE_CHECK_RETURN_ZERO(env, jcanvas);
- return GraphicsJNI::getNativeCanvas(env, jcanvas)->save(flags);
+ SkCanvas* canvas = GraphicsJNI::getNativeCanvas(env, jcanvas);
+ int height = canvas->getDevice()->accessBitmap(false).height();
+ return static_cast<jint>(height);
}
-
- static int saveLayer(JNIEnv* env, jobject, SkCanvas* canvas, jobject bounds,
- SkPaint* paint, int flags) {
+
+ static jint saveAll(JNIEnv* env, jobject jcanvas) {
+ NPE_CHECK_RETURN_ZERO(env, jcanvas);
+ int result = GraphicsJNI::getNativeCanvas(env, jcanvas)->save();
+ return static_cast<jint>(result);
+ }
+
+ static jint save(JNIEnv* env, jobject jcanvas, jint flagsHandle) {
+ SkCanvas::SaveFlags flags = static_cast<SkCanvas::SaveFlags>(flagsHandle);
+ NPE_CHECK_RETURN_ZERO(env, jcanvas);
+ int result = GraphicsJNI::getNativeCanvas(env, jcanvas)->save(flags);
+ return static_cast<jint>(result);
+ }
+
+ static jint saveLayer(JNIEnv* env, jobject, jlong canvasHandle, jobject bounds,
+ jlong paintHandle, jint flags) {
+ SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle);
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
SkRect* bounds_ = NULL;
SkRect storage;
if (bounds != NULL) {
GraphicsJNI::jrectf_to_rect(env, bounds, &storage);
bounds_ = &storage;
}
- return canvas->saveLayer(bounds_, paint, (SkCanvas::SaveFlags)flags);
+ return canvas->saveLayer(bounds_, paint, static_cast<SkCanvas::SaveFlags>(flags));
}
-
- static int saveLayer4F(JNIEnv* env, jobject, SkCanvas* canvas,
+
+ static jint saveLayer4F(JNIEnv* env, jobject, jlong canvasHandle,
jfloat l, jfloat t, jfloat r, jfloat b,
- SkPaint* paint, int flags) {
+ jlong paintHandle, jint flags) {
+ SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle);
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
SkRect bounds;
bounds.set(SkFloatToScalar(l), SkFloatToScalar(t), SkFloatToScalar(r),
SkFloatToScalar(b));
- return canvas->saveLayer(&bounds, paint, (SkCanvas::SaveFlags)flags);
+ int result = canvas->saveLayer(&bounds, paint,
+ static_cast<SkCanvas::SaveFlags>(flags));
+ return static_cast<jint>(result);
}
-
- static int saveLayerAlpha(JNIEnv* env, jobject, SkCanvas* canvas,
- jobject bounds, int alpha, int flags) {
+
+ static jint saveLayerAlpha(JNIEnv* env, jobject, jlong canvasHandle,
+ jobject bounds, jint alpha, jint flags) {
+ SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle);
SkRect* bounds_ = NULL;
SkRect storage;
if (bounds != NULL) {
GraphicsJNI::jrectf_to_rect(env, bounds, &storage);
bounds_ = &storage;
}
- return canvas->saveLayerAlpha(bounds_, alpha,
- (SkCanvas::SaveFlags)flags);
+ int result = canvas->saveLayerAlpha(bounds_, alpha,
+ static_cast<SkCanvas::SaveFlags>(flags));
+ return static_cast<jint>(result);
}
-
- static int saveLayerAlpha4F(JNIEnv* env, jobject, SkCanvas* canvas,
+
+ static jint saveLayerAlpha4F(JNIEnv* env, jobject, jlong canvasHandle,
jfloat l, jfloat t, jfloat r, jfloat b,
- int alpha, int flags) {
+ jint alpha, jint flags) {
+ SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle);
SkRect bounds;
bounds.set(SkFloatToScalar(l), SkFloatToScalar(t), SkFloatToScalar(r),
SkFloatToScalar(b));
- return canvas->saveLayerAlpha(&bounds, alpha,
- (SkCanvas::SaveFlags)flags);
+ int result = canvas->saveLayerAlpha(&bounds, alpha,
+ static_cast<SkCanvas::SaveFlags>(flags));
+ return static_cast<jint>(result);
}
-
+
static void restore(JNIEnv* env, jobject jcanvas) {
NPE_CHECK_RETURN_VOID(env, jcanvas);
SkCanvas* canvas = GraphicsJNI::getNativeCanvas(env, jcanvas);
@@ -186,13 +206,14 @@
}
canvas->restore();
}
-
- static int getSaveCount(JNIEnv* env, jobject jcanvas) {
+
+ static jint getSaveCount(JNIEnv* env, jobject jcanvas) {
NPE_CHECK_RETURN_ZERO(env, jcanvas);
- return GraphicsJNI::getNativeCanvas(env, jcanvas)->getSaveCount();
+ int result = GraphicsJNI::getNativeCanvas(env, jcanvas)->getSaveCount();
+ return static_cast<jint>(result);
}
-
- static void restoreToCount(JNIEnv* env, jobject jcanvas, int restoreCount) {
+
+ static void restoreToCount(JNIEnv* env, jobject jcanvas, jint restoreCount) {
NPE_CHECK_RETURN_VOID(env, jcanvas);
SkCanvas* canvas = GraphicsJNI::getNativeCanvas(env, jcanvas);
if (restoreCount < 1) {
@@ -201,48 +222,52 @@
}
canvas->restoreToCount(restoreCount);
}
-
+
static void translate(JNIEnv* env, jobject jcanvas, jfloat dx, jfloat dy) {
NPE_CHECK_RETURN_VOID(env, jcanvas);
SkScalar dx_ = SkFloatToScalar(dx);
SkScalar dy_ = SkFloatToScalar(dy);
(void)GraphicsJNI::getNativeCanvas(env, jcanvas)->translate(dx_, dy_);
}
-
+
static void scale__FF(JNIEnv* env, jobject jcanvas, jfloat sx, jfloat sy) {
NPE_CHECK_RETURN_VOID(env, jcanvas);
SkScalar sx_ = SkFloatToScalar(sx);
SkScalar sy_ = SkFloatToScalar(sy);
(void)GraphicsJNI::getNativeCanvas(env, jcanvas)->scale(sx_, sy_);
}
-
+
static void rotate__F(JNIEnv* env, jobject jcanvas, jfloat degrees) {
NPE_CHECK_RETURN_VOID(env, jcanvas);
SkScalar degrees_ = SkFloatToScalar(degrees);
(void)GraphicsJNI::getNativeCanvas(env, jcanvas)->rotate(degrees_);
}
-
+
static void skew__FF(JNIEnv* env, jobject jcanvas, jfloat sx, jfloat sy) {
NPE_CHECK_RETURN_VOID(env, jcanvas);
SkScalar sx_ = SkFloatToScalar(sx);
SkScalar sy_ = SkFloatToScalar(sy);
(void)GraphicsJNI::getNativeCanvas(env, jcanvas)->skew(sx_, sy_);
}
-
- static void concat(JNIEnv* env, jobject, SkCanvas* canvas,
- const SkMatrix* matrix) {
+
+ static void concat(JNIEnv* env, jobject, jlong canvasHandle,
+ jlong matrixHandle) {
+ SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle);
+ const SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle);
canvas->concat(*matrix);
}
-
- static void setMatrix(JNIEnv* env, jobject, SkCanvas* canvas,
- const SkMatrix* matrix) {
+
+ static void setMatrix(JNIEnv* env, jobject, jlong canvasHandle,
+ jlong matrixHandle) {
+ SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle);
+ const SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle);
if (NULL == matrix) {
canvas->resetMatrix();
} else {
canvas->setMatrix(*matrix);
}
}
-
+
static jboolean clipRect_FFFF(JNIEnv* env, jobject jcanvas, jfloat left,
jfloat top, jfloat right, jfloat bottom) {
NPE_CHECK_RETURN_ZERO(env, jcanvas);
@@ -250,122 +275,150 @@
r.set(SkFloatToScalar(left), SkFloatToScalar(top),
SkFloatToScalar(right), SkFloatToScalar(bottom));
SkCanvas* c = GraphicsJNI::getNativeCanvas(env, jcanvas);
- return c->clipRect(r);
+ bool result = c->clipRect(r);
+ return result ? JNI_TRUE : JNI_FALSE;
}
-
+
static jboolean clipRect_IIII(JNIEnv* env, jobject jcanvas, jint left,
jint top, jint right, jint bottom) {
NPE_CHECK_RETURN_ZERO(env, jcanvas);
SkRect r;
r.set(SkIntToScalar(left), SkIntToScalar(top),
SkIntToScalar(right), SkIntToScalar(bottom));
- return GraphicsJNI::getNativeCanvas(env, jcanvas)->clipRect(r);
+ bool result = GraphicsJNI::getNativeCanvas(env, jcanvas)->clipRect(r);
+ return result ? JNI_TRUE : JNI_FALSE;
}
-
+
static jboolean clipRect_RectF(JNIEnv* env, jobject jcanvas, jobject rectf) {
NPE_CHECK_RETURN_ZERO(env, jcanvas);
NPE_CHECK_RETURN_ZERO(env, rectf);
SkCanvas* c = GraphicsJNI::getNativeCanvas(env, jcanvas);
SkRect tmp;
- return c->clipRect(*GraphicsJNI::jrectf_to_rect(env, rectf, &tmp));
+ bool result = c->clipRect(*GraphicsJNI::jrectf_to_rect(env, rectf, &tmp));
+ return result ? JNI_TRUE : JNI_FALSE;
}
-
+
static jboolean clipRect_Rect(JNIEnv* env, jobject jcanvas, jobject rect) {
NPE_CHECK_RETURN_ZERO(env, jcanvas);
NPE_CHECK_RETURN_ZERO(env, rect);
SkCanvas* c = GraphicsJNI::getNativeCanvas(env, jcanvas);
SkRect tmp;
- return c->clipRect(*GraphicsJNI::jrect_to_rect(env, rect, &tmp));
+ bool result = c->clipRect(*GraphicsJNI::jrect_to_rect(env, rect, &tmp));
+ return result ? JNI_TRUE : JNI_FALSE;
+
}
-
- static jboolean clipRect(JNIEnv* env, jobject, SkCanvas* canvas,
- float left, float top, float right, float bottom,
- int op) {
+
+ static jboolean clipRect(JNIEnv* env, jobject, jlong canvasHandle,
+ jfloat left, jfloat top, jfloat right, jfloat bottom,
+ jint op) {
SkRect rect;
+ SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle);
rect.set(SkFloatToScalar(left), SkFloatToScalar(top),
SkFloatToScalar(right), SkFloatToScalar(bottom));
- return canvas->clipRect(rect, (SkRegion::Op)op);
+ bool result = canvas->clipRect(rect, static_cast<SkRegion::Op>(op));
+ return result ? JNI_TRUE : JNI_FALSE;
+
}
-
- static jboolean clipPath(JNIEnv* env, jobject, SkCanvas* canvas,
- SkPath* path, int op) {
- return canvas->clipPath(*path, (SkRegion::Op)op);
+
+ static jboolean clipPath(JNIEnv* env, jobject, jlong canvasHandle,
+ jlong pathHandle, jint op) {
+ SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle);
+ bool result = canvas->clipPath(*reinterpret_cast<SkPath*>(pathHandle),
+ static_cast<SkRegion::Op>(op));
+ return result ? JNI_TRUE : JNI_FALSE;
}
-
- static jboolean clipRegion(JNIEnv* env, jobject, SkCanvas* canvas,
- SkRegion* deviceRgn, int op) {
- return canvas->clipRegion(*deviceRgn, (SkRegion::Op)op);
+
+ static jboolean clipRegion(JNIEnv* env, jobject, jlong canvasHandle,
+ jlong deviceRgnHandle, jint op) {
+ SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle);
+ SkRegion* deviceRgn = reinterpret_cast<SkRegion*>(deviceRgnHandle);
+ bool result = canvas->clipRegion(*deviceRgn, static_cast<SkRegion::Op>(op));
+ return result ? JNI_TRUE : JNI_FALSE;
}
-
- static void setDrawFilter(JNIEnv* env, jobject, SkCanvas* canvas,
- SkDrawFilter* filter) {
- canvas->setDrawFilter(filter);
+
+ static void setDrawFilter(JNIEnv* env, jobject, jlong canvasHandle,
+ jlong filterHandle) {
+ SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle);
+ canvas->setDrawFilter(reinterpret_cast<SkDrawFilter*>(filterHandle));
}
-
- static jboolean quickReject__RectF(JNIEnv* env, jobject, SkCanvas* canvas,
+
+ static jboolean quickReject__RectF(JNIEnv* env, jobject, jlong canvasHandle,
jobject rect) {
+ SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle);
SkRect rect_;
GraphicsJNI::jrectf_to_rect(env, rect, &rect_);
return canvas->quickReject(rect_);
}
- static jboolean quickReject__Path(JNIEnv* env, jobject, SkCanvas* canvas,
- SkPath* path) {
- return canvas->quickReject(*path);
+ static jboolean quickReject__Path(JNIEnv* env, jobject, jlong canvasHandle,
+ jlong pathHandle) {
+ SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle);
+ bool result = canvas->quickReject(*reinterpret_cast<SkPath*>(pathHandle));
+ return result ? JNI_TRUE : JNI_FALSE;
}
- static jboolean quickReject__FFFF(JNIEnv* env, jobject, SkCanvas* canvas,
+ static jboolean quickReject__FFFF(JNIEnv* env, jobject, jlong canvasHandle,
jfloat left, jfloat top, jfloat right,
jfloat bottom) {
+ SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle);
SkRect r;
r.set(SkFloatToScalar(left), SkFloatToScalar(top),
SkFloatToScalar(right), SkFloatToScalar(bottom));
- return canvas->quickReject(r);
+ bool result = canvas->quickReject(r);
+ return result ? JNI_TRUE : JNI_FALSE;
}
-
- static void drawRGB(JNIEnv* env, jobject, SkCanvas* canvas,
+
+ static void drawRGB(JNIEnv* env, jobject, jlong canvasHandle,
jint r, jint g, jint b) {
+ SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle);
canvas->drawARGB(0xFF, r, g, b);
}
-
- static void drawARGB(JNIEnv* env, jobject, SkCanvas* canvas,
+
+ static void drawARGB(JNIEnv* env, jobject, jlong canvasHandle,
jint a, jint r, jint g, jint b) {
+ SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle);
canvas->drawARGB(a, r, g, b);
}
-
- static void drawColor__I(JNIEnv* env, jobject, SkCanvas* canvas,
+
+ static void drawColor__I(JNIEnv* env, jobject, jlong canvasHandle,
jint color) {
+ SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle);
canvas->drawColor(color);
}
-
- static void drawColor__II(JNIEnv* env, jobject, SkCanvas* canvas,
- jint color, SkPorterDuff::Mode mode) {
+
+ static void drawColor__II(JNIEnv* env, jobject, jlong canvasHandle,
+ jint color, jint modeHandle) {
+ SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle);
+ SkPorterDuff::Mode mode = static_cast<SkPorterDuff::Mode>(modeHandle);
canvas->drawColor(color, SkPorterDuff::ToXfermodeMode(mode));
}
-
- static void drawPaint(JNIEnv* env, jobject, SkCanvas* canvas,
- SkPaint* paint) {
+
+ static void drawPaint(JNIEnv* env, jobject, jlong canvasHandle,
+ jlong paintHandle) {
+ SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle);
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
canvas->drawPaint(*paint);
}
-
+
static void doPoints(JNIEnv* env, jobject jcanvas, jfloatArray jptsArray,
jint offset, jint count, jobject jpaint,
- SkCanvas::PointMode mode) {
+ jint modeHandle) {
NPE_CHECK_RETURN_VOID(env, jcanvas);
NPE_CHECK_RETURN_VOID(env, jptsArray);
NPE_CHECK_RETURN_VOID(env, jpaint);
+ SkCanvas::PointMode mode = static_cast<SkCanvas::PointMode>(modeHandle);
SkCanvas* canvas = GraphicsJNI::getNativeCanvas(env, jcanvas);
const SkPaint& paint = *GraphicsJNI::getNativePaint(env, jpaint);
-
+
AutoJavaFloatArray autoPts(env, jptsArray);
float* floats = autoPts.ptr();
const int length = autoPts.length();
-
+
if ((offset | count) < 0 || offset + count > length) {
doThrowAIOOBE(env);
return;
}
-
+
// now convert the floats into SkPoints
count >>= 1; // now it is the number of points
SkAutoSTMalloc<32, SkPoint> storage(count);
@@ -374,98 +427,118 @@
for (int i = 0; i < count; i++) {
pts[i].set(SkFloatToScalar(src[0]), SkFloatToScalar(src[1]));
src += 2;
- }
+ }
canvas->drawPoints(mode, count, pts, paint);
}
-
+
static void drawPoints(JNIEnv* env, jobject jcanvas, jfloatArray jptsArray,
jint offset, jint count, jobject jpaint) {
doPoints(env, jcanvas, jptsArray, offset, count, jpaint,
SkCanvas::kPoints_PointMode);
}
-
+
static void drawLines(JNIEnv* env, jobject jcanvas, jfloatArray jptsArray,
jint offset, jint count, jobject jpaint) {
doPoints(env, jcanvas, jptsArray, offset, count, jpaint,
SkCanvas::kLines_PointMode);
}
-
- static void drawPoint(JNIEnv* env, jobject jcanvas, float x, float y,
+
+ static void drawPoint(JNIEnv* env, jobject jcanvas, jfloat x, jfloat y,
jobject jpaint) {
NPE_CHECK_RETURN_VOID(env, jcanvas);
NPE_CHECK_RETURN_VOID(env, jpaint);
SkCanvas* canvas = GraphicsJNI::getNativeCanvas(env, jcanvas);
const SkPaint& paint = *GraphicsJNI::getNativePaint(env, jpaint);
-
+
canvas->drawPoint(SkFloatToScalar(x), SkFloatToScalar(y), paint);
}
-
- static void drawLine__FFFFPaint(JNIEnv* env, jobject, SkCanvas* canvas,
+
+ static void drawLine__FFFFPaint(JNIEnv* env, jobject, jlong canvasHandle,
jfloat startX, jfloat startY, jfloat stopX,
- jfloat stopY, SkPaint* paint) {
+ jfloat stopY, jlong paintHandle) {
+ SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle);
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
canvas->drawLine(SkFloatToScalar(startX), SkFloatToScalar(startY),
SkFloatToScalar(stopX), SkFloatToScalar(stopY),
*paint);
}
-
- static void drawRect__RectFPaint(JNIEnv* env, jobject, SkCanvas* canvas,
- jobject rect, SkPaint* paint) {
+
+ static void drawRect__RectFPaint(JNIEnv* env, jobject, jlong canvasHandle,
+ jobject rect, jlong paintHandle) {
+ SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle);
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
SkRect rect_;
GraphicsJNI::jrectf_to_rect(env, rect, &rect_);
canvas->drawRect(rect_, *paint);
}
-
- static void drawRect__FFFFPaint(JNIEnv* env, jobject, SkCanvas* canvas,
+
+ static void drawRect__FFFFPaint(JNIEnv* env, jobject, jlong canvasHandle,
jfloat left, jfloat top, jfloat right,
- jfloat bottom, SkPaint* paint) {
+ jfloat bottom, jlong paintHandle) {
+ SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle);
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
SkScalar left_ = SkFloatToScalar(left);
SkScalar top_ = SkFloatToScalar(top);
SkScalar right_ = SkFloatToScalar(right);
SkScalar bottom_ = SkFloatToScalar(bottom);
canvas->drawRectCoords(left_, top_, right_, bottom_, *paint);
}
-
- static void drawOval(JNIEnv* env, jobject, SkCanvas* canvas, jobject joval,
- SkPaint* paint) {
+
+ static void drawOval(JNIEnv* env, jobject, jlong canvasHandle, jobject joval,
+ jlong paintHandle) {
+ SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle);
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
SkRect oval;
GraphicsJNI::jrectf_to_rect(env, joval, &oval);
canvas->drawOval(oval, *paint);
}
-
- static void drawCircle(JNIEnv* env, jobject, SkCanvas* canvas, jfloat cx,
- jfloat cy, jfloat radius, SkPaint* paint) {
+
+ static void drawCircle(JNIEnv* env, jobject, jlong canvasHandle, jfloat cx,
+ jfloat cy, jfloat radius, jlong paintHandle) {
+ SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle);
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
canvas->drawCircle(SkFloatToScalar(cx), SkFloatToScalar(cy),
SkFloatToScalar(radius), *paint);
}
-
- static void drawArc(JNIEnv* env, jobject, SkCanvas* canvas, jobject joval,
+
+ static void drawArc(JNIEnv* env, jobject, jlong canvasHandle, jobject joval,
jfloat startAngle, jfloat sweepAngle,
- jboolean useCenter, SkPaint* paint) {
+ jboolean useCenter, jlong paintHandle) {
+ SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle);
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
SkRect oval;
GraphicsJNI::jrectf_to_rect(env, joval, &oval);
canvas->drawArc(oval, SkFloatToScalar(startAngle),
SkFloatToScalar(sweepAngle), useCenter, *paint);
}
-
- static void drawRoundRect(JNIEnv* env, jobject, SkCanvas* canvas,
+
+ static void drawRoundRect(JNIEnv* env, jobject, jlong canvasHandle,
jobject jrect, jfloat rx, jfloat ry,
- SkPaint* paint) {
+ jlong paintHandle) {
+ SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle);
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
SkRect rect;
GraphicsJNI::jrectf_to_rect(env, jrect, &rect);
canvas->drawRoundRect(rect, SkFloatToScalar(rx), SkFloatToScalar(ry),
*paint);
}
-
- static void drawPath(JNIEnv* env, jobject, SkCanvas* canvas, SkPath* path,
- SkPaint* paint) {
+
+ static void drawPath(JNIEnv* env, jobject, jlong canvasHandle, jlong pathHandle,
+ jlong paintHandle) {
+ SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle);
+ SkPath* path = reinterpret_cast<SkPath*>(pathHandle);
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
canvas->drawPath(*path, *paint);
}
-
+
static void drawBitmap__BitmapFFPaint(JNIEnv* env, jobject jcanvas,
- SkCanvas* canvas, SkBitmap* bitmap,
+ jlong canvasHandle, jlong bitmapHandle,
jfloat left, jfloat top,
- SkPaint* paint, jint canvasDensity,
+ jlong paintHandle, jint canvasDensity,
jint screenDensity, jint bitmapDensity) {
+ SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle);
+ SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
SkScalar left_ = SkFloatToScalar(left);
SkScalar top_ = SkFloatToScalar(top);
@@ -508,7 +581,7 @@
GraphicsJNI::jrect_to_irect(env, srcIRect, &src);
srcPtr = &src;
}
-
+
if (screenDensity != 0 && screenDensity != bitmapDensity) {
SkPaint filteredPaint;
if (paint) {
@@ -521,31 +594,39 @@
}
}
- static void drawBitmapRF(JNIEnv* env, jobject, SkCanvas* canvas,
- SkBitmap* bitmap, jobject srcIRect,
- jobject dstRectF, SkPaint* paint,
+ static void drawBitmapRF(JNIEnv* env, jobject, jlong canvasHandle,
+ jlong bitmapHandle, jobject srcIRect,
+ jobject dstRectF, jlong paintHandle,
jint screenDensity, jint bitmapDensity) {
+ SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle);
+ SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
SkRect dst;
GraphicsJNI::jrectf_to_rect(env, dstRectF, &dst);
doDrawBitmap(env, canvas, bitmap, srcIRect, dst, paint,
screenDensity, bitmapDensity);
}
-
- static void drawBitmapRR(JNIEnv* env, jobject, SkCanvas* canvas,
- SkBitmap* bitmap, jobject srcIRect,
- jobject dstRect, SkPaint* paint,
+
+ static void drawBitmapRR(JNIEnv* env, jobject, jlong canvasHandle,
+ jlong bitmapHandle, jobject srcIRect,
+ jobject dstRect, jlong paintHandle,
jint screenDensity, jint bitmapDensity) {
+ SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle);
+ SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
SkRect dst;
GraphicsJNI::jrect_to_rect(env, dstRect, &dst);
doDrawBitmap(env, canvas, bitmap, srcIRect, dst, paint,
screenDensity, bitmapDensity);
}
-
- static void drawBitmapArray(JNIEnv* env, jobject, SkCanvas* canvas,
- jintArray jcolors, int offset, int stride,
- jfloat x, jfloat y, int width, int height,
- jboolean hasAlpha, SkPaint* paint)
+
+ static void drawBitmapArray(JNIEnv* env, jobject, jlong canvasHandle,
+ jintArray jcolors, jint offset, jint stride,
+ jfloat x, jfloat y, jint width, jint height,
+ jboolean hasAlpha, jlong paintHandle)
{
+ SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle);
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
SkBitmap bitmap;
bitmap.setConfig(hasAlpha ? SkBitmap::kARGB_8888_Config :
SkBitmap::kRGB_565_Config, width, height);
@@ -561,24 +642,31 @@
canvas->drawBitmap(bitmap, SkFloatToScalar(x), SkFloatToScalar(y),
paint);
}
-
- static void drawBitmapMatrix(JNIEnv* env, jobject, SkCanvas* canvas,
- const SkBitmap* bitmap, const SkMatrix* matrix,
- const SkPaint* paint) {
+
+ static void drawBitmapMatrix(JNIEnv* env, jobject, jlong canvasHandle,
+ jlong bitmapHandle, jlong matrixHandle,
+ jlong paintHandle) {
+ SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle);
+ const SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
+ const SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle);
+ const SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
canvas->drawBitmapMatrix(*bitmap, *matrix, paint);
}
-
- static void drawBitmapMesh(JNIEnv* env, jobject, SkCanvas* canvas,
- const SkBitmap* bitmap, int meshWidth, int meshHeight,
- jfloatArray jverts, int vertIndex, jintArray jcolors,
- int colorIndex, const SkPaint* paint) {
+
+ static void drawBitmapMesh(JNIEnv* env, jobject, jlong canvasHandle,
+ jlong bitmapHandle, jint meshWidth, jint meshHeight,
+ jfloatArray jverts, jint vertIndex, jintArray jcolors,
+ jint colorIndex, jlong paintHandle) {
+ SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle);
+ const SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
+ const SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
const int ptCount = (meshWidth + 1) * (meshHeight + 1);
const int indexCount = meshWidth * meshHeight * 6;
AutoJavaFloatArray vertA(env, jverts, vertIndex + (ptCount << 1));
AutoJavaIntArray colorA(env, jcolors, colorIndex + ptCount);
-
+
/* Our temp storage holds 2 or 3 arrays.
texture points [ptCount * sizeof(SkPoint)]
optionally vertex points [ptCount * sizeof(SkPoint)] if we need a
@@ -617,7 +705,7 @@
const SkScalar h = SkIntToScalar(bitmap->height());
const SkScalar dx = w / meshWidth;
const SkScalar dy = h / meshHeight;
-
+
SkPoint* texsPtr = texs;
SkScalar y = 0;
for (int i = 0; i <= meshHeight; i++) {
@@ -636,7 +724,7 @@
}
SkASSERT(texsPtr - texs == ptCount);
}
-
+
// cons up indices
{
uint16_t* indexPtr = indices;
@@ -684,13 +772,16 @@
indexCount, tmpPaint);
}
- static void drawVertices(JNIEnv* env, jobject, SkCanvas* canvas,
- SkCanvas::VertexMode mode, int vertexCount,
- jfloatArray jverts, int vertIndex,
- jfloatArray jtexs, int texIndex,
- jintArray jcolors, int colorIndex,
- jshortArray jindices, int indexIndex,
- int indexCount, const SkPaint* paint) {
+ static void drawVertices(JNIEnv* env, jobject, jlong canvasHandle,
+ jint modeHandle, jint vertexCount,
+ jfloatArray jverts, jint vertIndex,
+ jfloatArray jtexs, jint texIndex,
+ jintArray jcolors, jint colorIndex,
+ jshortArray jindices, jint indexIndex,
+ jint indexCount, jlong paintHandle) {
+ SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle);
+ SkCanvas::VertexMode mode = static_cast<SkCanvas::VertexMode>(modeHandle);
+ const SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
AutoJavaFloatArray vertA(env, jverts, vertIndex + vertexCount);
AutoJavaFloatArray texA(env, jtexs, texIndex + vertexCount);
@@ -712,7 +803,7 @@
count += ptCount; // += for texs
}
SkAutoMalloc storage(count * sizeof(SkPoint));
- verts = (SkPoint*)storage.get();
+ verts = (SkPoint*)storage.get();
const float* src = vertA.ptr() + vertIndex;
for (int i = 0; i < ptCount; i++) {
verts[i].set(SkFloatToFixed(src[0]), SkFloatToFixed(src[1]));
@@ -742,18 +833,22 @@
}
- static void drawText___CIIFFIPaint(JNIEnv* env, jobject, SkCanvas* canvas,
- jcharArray text, int index, int count,
- jfloat x, jfloat y, int flags, SkPaint* paint) {
+ static void drawText___CIIFFIPaint(JNIEnv* env, jobject, jlong canvasHandle,
+ jcharArray text, jint index, jint count,
+ jfloat x, jfloat y, jint flags, jlong paintHandle) {
+ SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle);
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
jchar* textArray = env->GetCharArrayElements(text, NULL);
drawTextWithGlyphs(canvas, textArray + index, 0, count, x, y, flags, paint);
env->ReleaseCharArrayElements(text, textArray, JNI_ABORT);
}
static void drawText__StringIIFFIPaint(JNIEnv* env, jobject,
- SkCanvas* canvas, jstring text,
- int start, int end,
- jfloat x, jfloat y, int flags, SkPaint* paint) {
+ jlong canvasHandle, jstring text,
+ jint start, jint end,
+ jfloat x, jfloat y, jint flags, jlong paintHandle) {
+ SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle);
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
const jchar* textArray = env->GetStringChars(text, NULL);
drawTextWithGlyphs(canvas, textArray, start, end, x, y, flags, paint);
env->ReleaseStringChars(text, textArray);
@@ -843,9 +938,11 @@
}
static void drawTextRun___CIIIIFFIPaint(
- JNIEnv* env, jobject, SkCanvas* canvas, jcharArray text, int index,
- int count, int contextIndex, int contextCount,
- jfloat x, jfloat y, int dirFlags, SkPaint* paint) {
+ JNIEnv* env, jobject, jlong canvasHandle, jcharArray text, jint index,
+ jint count, jint contextIndex, jint contextCount,
+ jfloat x, jfloat y, jint dirFlags, jlong paintHandle) {
+ SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle);
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
jchar* chars = env->GetCharArrayElements(text, NULL);
drawTextWithGlyphs(canvas, chars + contextIndex, index - contextIndex,
@@ -854,9 +951,11 @@
}
static void drawTextRun__StringIIIIFFIPaint(
- JNIEnv* env, jobject obj, SkCanvas* canvas, jstring text, jint start,
+ JNIEnv* env, jobject obj, jlong canvasHandle, jstring text, jint start,
jint end, jint contextStart, jint contextEnd,
- jfloat x, jfloat y, jint dirFlags, SkPaint* paint) {
+ jfloat x, jfloat y, jint dirFlags, jlong paintHandle) {
+ SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle);
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
jint count = end - start;
jint contextCount = contextEnd - contextStart;
@@ -866,9 +965,11 @@
env->ReleaseStringChars(text, chars);
}
- static void drawPosText___CII_FPaint(JNIEnv* env, jobject, SkCanvas* canvas,
- jcharArray text, int index, int count,
- jfloatArray pos, SkPaint* paint) {
+ static void drawPosText___CII_FPaint(JNIEnv* env, jobject, jlong canvasHandle,
+ jcharArray text, jint index, jint count,
+ jfloatArray pos, jlong paintHandle) {
+ SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle);
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
jchar* textArray = text ? env->GetCharArrayElements(text, NULL) : NULL;
jsize textCount = text ? env->GetArrayLength(text) : NULL;
float* posArray = pos ? env->GetFloatArrayElements(pos, NULL) : NULL;
@@ -879,12 +980,12 @@
posPtr[indx].fX = SkFloatToScalar(posArray[indx << 1]);
posPtr[indx].fY = SkFloatToScalar(posArray[(indx << 1) + 1]);
}
-
+
SkPaint::TextEncoding encoding = paint->getTextEncoding();
paint->setTextEncoding(SkPaint::kUTF16_TextEncoding);
canvas->drawPosText(textArray + index, count << 1, posPtr, *paint);
paint->setTextEncoding(encoding);
-
+
if (text) {
env->ReleaseCharArrayElements(text, textArray, 0);
}
@@ -895,9 +996,11 @@
}
static void drawPosText__String_FPaint(JNIEnv* env, jobject,
- SkCanvas* canvas, jstring text,
+ jlong canvasHandle, jstring text,
jfloatArray pos,
- SkPaint* paint) {
+ jlong paintHandle) {
+ SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle);
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
const void* text_ = text ? env->GetStringChars(text, NULL) : NULL;
int byteLength = text ? env->GetStringLength(text) : 0;
float* posArray = pos ? env->GetFloatArrayElements(pos, NULL) : NULL;
@@ -924,8 +1027,11 @@
}
static void drawTextOnPath___CIIPathFFPaint(JNIEnv* env, jobject,
- SkCanvas* canvas, jcharArray text, int index, int count,
- SkPath* path, jfloat hOffset, jfloat vOffset, jint bidiFlags, SkPaint* paint) {
+ jlong canvasHandle, jcharArray text, jint index, jint count,
+ jlong pathHandle, jfloat hOffset, jfloat vOffset, jint bidiFlags, jlong paintHandle) {
+ SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle);
+ SkPath* path = reinterpret_cast<SkPath*>(pathHandle);
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
jchar* textArray = env->GetCharArrayElements(text, NULL);
TextLayout::drawTextOnPath(paint, textArray + index, count, bidiFlags, hOffset, vOffset,
@@ -934,8 +1040,11 @@
}
static void drawTextOnPath__StringPathFFPaint(JNIEnv* env, jobject,
- SkCanvas* canvas, jstring text, SkPath* path,
- jfloat hOffset, jfloat vOffset, jint bidiFlags, SkPaint* paint) {
+ jlong canvasHandle, jstring text, jlong pathHandle,
+ jfloat hOffset, jfloat vOffset, jint bidiFlags, jlong paintHandle) {
+ SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle);
+ SkPath* path = reinterpret_cast<SkPath*>(pathHandle);
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
const jchar* text_ = env->GetStringChars(text, NULL);
int count = env->GetStringLength(text);
TextLayout::drawTextOnPath(paint, text_, count, bidiFlags, hOffset, vOffset,
@@ -970,8 +1079,9 @@
return true;
}
- static bool getClipBounds(JNIEnv* env, jobject, SkCanvas* canvas,
- jobject bounds) {
+ static jboolean getClipBounds(JNIEnv* env, jobject, jlong canvasHandle,
+ jobject bounds) {
+ SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle);
SkRect r;
SkIRect ir;
bool result = getHardClipBounds(canvas, &r);
@@ -982,30 +1092,32 @@
r.round(&ir);
(void)GraphicsJNI::irect_to_jrect(ir, env, bounds);
- return result;
+ return result ? JNI_TRUE : JNI_FALSE;
}
- static void getCTM(JNIEnv* env, jobject, SkCanvas* canvas,
- SkMatrix* matrix) {
+ static void getCTM(JNIEnv* env, jobject, jlong canvasHandle,
+ jlong matrixHandle) {
+ SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle);
+ SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle);
*matrix = canvas->getTotalMatrix();
}
};
static JNINativeMethod gCanvasMethods[] = {
- {"finalizer", "(I)V", (void*) SkCanvasGlue::finalizer},
- {"initRaster","(I)I", (void*) SkCanvasGlue::initRaster},
- {"copyNativeCanvasState","(II)V", (void*) SkCanvasGlue::copyCanvasState},
+ {"finalizer", "(J)V", (void*) SkCanvasGlue::finalizer},
+ {"initRaster","(J)J", (void*) SkCanvasGlue::initRaster},
+ {"copyNativeCanvasState","(JJ)V", (void*) SkCanvasGlue::copyCanvasState},
{"isOpaque","()Z", (void*) SkCanvasGlue::isOpaque},
{"getWidth","()I", (void*) SkCanvasGlue::getWidth},
{"getHeight","()I", (void*) SkCanvasGlue::getHeight},
{"save","()I", (void*) SkCanvasGlue::saveAll},
{"save","(I)I", (void*) SkCanvasGlue::save},
- {"native_saveLayer","(ILandroid/graphics/RectF;II)I",
+ {"native_saveLayer","(JLandroid/graphics/RectF;JI)I",
(void*) SkCanvasGlue::saveLayer},
- {"native_saveLayer","(IFFFFII)I", (void*) SkCanvasGlue::saveLayer4F},
- {"native_saveLayerAlpha","(ILandroid/graphics/RectF;II)I",
+ {"native_saveLayer","(JFFFFJI)I", (void*) SkCanvasGlue::saveLayer4F},
+ {"native_saveLayerAlpha","(JLandroid/graphics/RectF;II)I",
(void*) SkCanvasGlue::saveLayerAlpha},
- {"native_saveLayerAlpha","(IFFFFII)I",
+ {"native_saveLayerAlpha","(JFFFFII)I",
(void*) SkCanvasGlue::saveLayerAlpha4F},
{"restore","()V", (void*) SkCanvasGlue::restore},
{"getSaveCount","()I", (void*) SkCanvasGlue::getSaveCount},
@@ -1014,77 +1126,77 @@
{"scale","(FF)V", (void*) SkCanvasGlue::scale__FF},
{"rotate","(F)V", (void*) SkCanvasGlue::rotate__F},
{"skew","(FF)V", (void*) SkCanvasGlue::skew__FF},
- {"native_concat","(II)V", (void*) SkCanvasGlue::concat},
- {"native_setMatrix","(II)V", (void*) SkCanvasGlue::setMatrix},
+ {"native_concat","(JJ)V", (void*) SkCanvasGlue::concat},
+ {"native_setMatrix","(JJ)V", (void*) SkCanvasGlue::setMatrix},
{"clipRect","(FFFF)Z", (void*) SkCanvasGlue::clipRect_FFFF},
{"clipRect","(IIII)Z", (void*) SkCanvasGlue::clipRect_IIII},
{"clipRect","(Landroid/graphics/RectF;)Z",
(void*) SkCanvasGlue::clipRect_RectF},
{"clipRect","(Landroid/graphics/Rect;)Z",
(void*) SkCanvasGlue::clipRect_Rect},
- {"native_clipRect","(IFFFFI)Z", (void*) SkCanvasGlue::clipRect},
- {"native_clipPath","(III)Z", (void*) SkCanvasGlue::clipPath},
- {"native_clipRegion","(III)Z", (void*) SkCanvasGlue::clipRegion},
- {"nativeSetDrawFilter", "(II)V", (void*) SkCanvasGlue::setDrawFilter},
- {"native_getClipBounds","(ILandroid/graphics/Rect;)Z",
+ {"native_clipRect","(JFFFFI)Z", (void*) SkCanvasGlue::clipRect},
+ {"native_clipPath","(JJI)Z", (void*) SkCanvasGlue::clipPath},
+ {"native_clipRegion","(JJI)Z", (void*) SkCanvasGlue::clipRegion},
+ {"nativeSetDrawFilter", "(JJ)V", (void*) SkCanvasGlue::setDrawFilter},
+ {"native_getClipBounds","(JLandroid/graphics/Rect;)Z",
(void*) SkCanvasGlue::getClipBounds},
- {"native_getCTM", "(II)V", (void*)SkCanvasGlue::getCTM},
- {"native_quickReject","(ILandroid/graphics/RectF;)Z",
+ {"native_getCTM", "(JJ)V", (void*)SkCanvasGlue::getCTM},
+ {"native_quickReject","(JLandroid/graphics/RectF;)Z",
(void*) SkCanvasGlue::quickReject__RectF},
- {"native_quickReject","(II)Z", (void*) SkCanvasGlue::quickReject__Path},
- {"native_quickReject","(IFFFF)Z", (void*)SkCanvasGlue::quickReject__FFFF},
- {"native_drawRGB","(IIII)V", (void*) SkCanvasGlue::drawRGB},
- {"native_drawARGB","(IIIII)V", (void*) SkCanvasGlue::drawARGB},
- {"native_drawColor","(II)V", (void*) SkCanvasGlue::drawColor__I},
- {"native_drawColor","(III)V", (void*) SkCanvasGlue::drawColor__II},
- {"native_drawPaint","(II)V", (void*) SkCanvasGlue::drawPaint},
+ {"native_quickReject","(JJ)Z", (void*) SkCanvasGlue::quickReject__Path},
+ {"native_quickReject","(JFFFF)Z", (void*)SkCanvasGlue::quickReject__FFFF},
+ {"native_drawRGB","(JIII)V", (void*) SkCanvasGlue::drawRGB},
+ {"native_drawARGB","(JIIII)V", (void*) SkCanvasGlue::drawARGB},
+ {"native_drawColor","(JI)V", (void*) SkCanvasGlue::drawColor__I},
+ {"native_drawColor","(JII)V", (void*) SkCanvasGlue::drawColor__II},
+ {"native_drawPaint","(JJ)V", (void*) SkCanvasGlue::drawPaint},
{"drawPoint", "(FFLandroid/graphics/Paint;)V",
(void*) SkCanvasGlue::drawPoint},
{"drawPoints", "([FIILandroid/graphics/Paint;)V",
(void*) SkCanvasGlue::drawPoints},
{"drawLines", "([FIILandroid/graphics/Paint;)V",
(void*) SkCanvasGlue::drawLines},
- {"native_drawLine","(IFFFFI)V", (void*) SkCanvasGlue::drawLine__FFFFPaint},
- {"native_drawRect","(ILandroid/graphics/RectF;I)V",
+ {"native_drawLine","(JFFFFJ)V", (void*) SkCanvasGlue::drawLine__FFFFPaint},
+ {"native_drawRect","(JLandroid/graphics/RectF;J)V",
(void*) SkCanvasGlue::drawRect__RectFPaint},
- {"native_drawRect","(IFFFFI)V", (void*) SkCanvasGlue::drawRect__FFFFPaint},
- {"native_drawOval","(ILandroid/graphics/RectF;I)V",
+ {"native_drawRect","(JFFFFJ)V", (void*) SkCanvasGlue::drawRect__FFFFPaint},
+ {"native_drawOval","(JLandroid/graphics/RectF;J)V",
(void*) SkCanvasGlue::drawOval},
- {"native_drawCircle","(IFFFI)V", (void*) SkCanvasGlue::drawCircle},
- {"native_drawArc","(ILandroid/graphics/RectF;FFZI)V",
+ {"native_drawCircle","(JFFFJ)V", (void*) SkCanvasGlue::drawCircle},
+ {"native_drawArc","(JLandroid/graphics/RectF;FFZJ)V",
(void*) SkCanvasGlue::drawArc},
- {"native_drawRoundRect","(ILandroid/graphics/RectF;FFI)V",
+ {"native_drawRoundRect","(JLandroid/graphics/RectF;FFJ)V",
(void*) SkCanvasGlue::drawRoundRect},
- {"native_drawPath","(III)V", (void*) SkCanvasGlue::drawPath},
- {"native_drawBitmap","(IIFFIIII)V",
+ {"native_drawPath","(JJJ)V", (void*) SkCanvasGlue::drawPath},
+ {"native_drawBitmap","(JJFFJIII)V",
(void*) SkCanvasGlue::drawBitmap__BitmapFFPaint},
- {"native_drawBitmap","(IILandroid/graphics/Rect;Landroid/graphics/RectF;III)V",
+ {"native_drawBitmap","(JJLandroid/graphics/Rect;Landroid/graphics/RectF;JII)V",
(void*) SkCanvasGlue::drawBitmapRF},
- {"native_drawBitmap","(IILandroid/graphics/Rect;Landroid/graphics/Rect;III)V",
+ {"native_drawBitmap","(JJLandroid/graphics/Rect;Landroid/graphics/Rect;JII)V",
(void*) SkCanvasGlue::drawBitmapRR},
- {"native_drawBitmap", "(I[IIIFFIIZI)V",
+ {"native_drawBitmap", "(J[IIIFFIIZJ)V",
(void*)SkCanvasGlue::drawBitmapArray},
- {"nativeDrawBitmapMatrix", "(IIII)V",
+ {"nativeDrawBitmapMatrix", "(JJJJ)V",
(void*)SkCanvasGlue::drawBitmapMatrix},
- {"nativeDrawBitmapMesh", "(IIII[FI[III)V",
+ {"nativeDrawBitmapMesh", "(JJII[FI[IIJ)V",
(void*)SkCanvasGlue::drawBitmapMesh},
- {"nativeDrawVertices", "(III[FI[FI[II[SIII)V",
+ {"nativeDrawVertices", "(JII[FI[FI[II[SIIJ)V",
(void*)SkCanvasGlue::drawVertices},
- {"native_drawText","(I[CIIFFII)V",
+ {"native_drawText","(J[CIIFFIJ)V",
(void*) SkCanvasGlue::drawText___CIIFFIPaint},
- {"native_drawText","(ILjava/lang/String;IIFFII)V",
+ {"native_drawText","(JLjava/lang/String;IIFFIJ)V",
(void*) SkCanvasGlue::drawText__StringIIFFIPaint},
- {"native_drawTextRun","(I[CIIIIFFII)V",
+ {"native_drawTextRun","(J[CIIIIFFIJ)V",
(void*) SkCanvasGlue::drawTextRun___CIIIIFFIPaint},
- {"native_drawTextRun","(ILjava/lang/String;IIIIFFII)V",
+ {"native_drawTextRun","(JLjava/lang/String;IIIIFFIJ)V",
(void*) SkCanvasGlue::drawTextRun__StringIIIIFFIPaint},
- {"native_drawPosText","(I[CII[FI)V",
+ {"native_drawPosText","(J[CII[FJ)V",
(void*) SkCanvasGlue::drawPosText___CII_FPaint},
- {"native_drawPosText","(ILjava/lang/String;[FI)V",
+ {"native_drawPosText","(JLjava/lang/String;[FJ)V",
(void*) SkCanvasGlue::drawPosText__String_FPaint},
- {"native_drawTextOnPath","(I[CIIIFFII)V",
+ {"native_drawTextOnPath","(J[CIIJFFIJ)V",
(void*) SkCanvasGlue::drawTextOnPath___CIIPathFFPaint},
- {"native_drawTextOnPath","(ILjava/lang/String;IFFII)V",
+ {"native_drawTextOnPath","(JLjava/lang/String;JFFIJ)V",
(void*) SkCanvasGlue::drawTextOnPath__StringPathFFPaint},
{"freeCaches", "()V", (void*) SkCanvasGlue::freeCaches},
@@ -1105,7 +1217,7 @@
int result;
REG(env, "android/graphics/Canvas", gCanvasMethods);
-
+
return result;
}
diff --git a/core/jni/android/graphics/ColorFilter.cpp b/core/jni/android/graphics/ColorFilter.cpp
index dd1177b..f9cefd6 100644
--- a/core/jni/android/graphics/ColorFilter.cpp
+++ b/core/jni/android/graphics/ColorFilter.cpp
@@ -32,7 +32,9 @@
class SkColorFilterGlue {
public:
- static void finalizer(JNIEnv* env, jobject clazz, SkColorFilter* obj, SkiaColorFilter* f) {
+ static void finalizer(JNIEnv* env, jobject clazz, jlong objHandle, jlong fHandle) {
+ SkColorFilter* obj = reinterpret_cast<SkColorFilter *>(objHandle);
+ SkiaColorFilter* f = reinterpret_cast<SkiaColorFilter *>(fHandle);
SkSafeUnref(obj);
// f == NULL when not !USE_OPENGL_RENDERER, so no need to delete outside the ifdef
#ifdef USE_OPENGL_RENDERER
@@ -44,26 +46,30 @@
#endif
}
- static SkiaColorFilter* glCreatePorterDuffFilter(JNIEnv* env, jobject, SkColorFilter *skFilter,
- jint srcColor, SkPorterDuff::Mode mode) {
+ static jlong glCreatePorterDuffFilter(JNIEnv* env, jobject, jlong skFilterHandle,
+ jint srcColor, jint modeHandle) {
+ SkColorFilter *skFilter = reinterpret_cast<SkColorFilter *>(skFilterHandle);
+ SkPorterDuff::Mode mode = static_cast<SkPorterDuff::Mode>(modeHandle);
#ifdef USE_OPENGL_RENDERER
- return new SkiaBlendFilter(skFilter, srcColor, SkPorterDuff::ToXfermodeMode(mode));
+ return reinterpret_cast<jlong>(new SkiaBlendFilter(skFilter, srcColor, SkPorterDuff::ToXfermodeMode(mode)));
#else
return NULL;
#endif
}
- static SkiaColorFilter* glCreateLightingFilter(JNIEnv* env, jobject, SkColorFilter *skFilter,
+ static jlong glCreateLightingFilter(JNIEnv* env, jobject, jlong skFilterHandle,
jint mul, jint add) {
+ SkColorFilter *skFilter = reinterpret_cast<SkColorFilter *>(skFilterHandle);
#ifdef USE_OPENGL_RENDERER
- return new SkiaLightingFilter(skFilter, mul, add);
+ return reinterpret_cast<jlong>(new SkiaLightingFilter(skFilter, mul, add));
#else
return NULL;
#endif
}
- static SkiaColorFilter* glCreateColorMatrixFilter(JNIEnv* env, jobject, SkColorFilter *skFilter,
+ static jlong glCreateColorMatrixFilter(JNIEnv* env, jobject, jlong skFilterHandle,
jfloatArray jarray) {
+ SkColorFilter *skFilter = reinterpret_cast<SkColorFilter *>(skFilterHandle);
#ifdef USE_OPENGL_RENDERER
AutoJavaFloatArray autoArray(env, jarray, 20);
const float* src = autoArray.ptr();
@@ -80,22 +86,23 @@
colorVector[2] = src[14];
colorVector[3] = src[19];
- return new SkiaColorMatrixFilter(skFilter, colorMatrix, colorVector);
+ return reinterpret_cast<jlong>(new SkiaColorMatrixFilter(skFilter, colorMatrix, colorVector));
#else
return NULL;
#endif
}
- static SkColorFilter* CreatePorterDuffFilter(JNIEnv* env, jobject, jint srcColor,
- SkPorterDuff::Mode mode) {
- return SkColorFilter::CreateModeFilter(srcColor, SkPorterDuff::ToXfermodeMode(mode));
+ static jlong CreatePorterDuffFilter(JNIEnv* env, jobject, jint srcColor,
+ jint modeHandle) {
+ SkPorterDuff::Mode mode = (SkPorterDuff::Mode) modeHandle;
+ return reinterpret_cast<jlong>(SkColorFilter::CreateModeFilter(srcColor, SkPorterDuff::ToXfermodeMode(mode)));
}
- static SkColorFilter* CreateLightingFilter(JNIEnv* env, jobject, jint mul, jint add) {
- return SkColorFilter::CreateLightingFilter(mul, add);
+ static jlong CreateLightingFilter(JNIEnv* env, jobject, jint mul, jint add) {
+ return reinterpret_cast<jlong>(SkColorFilter::CreateLightingFilter(mul, add));
}
- static SkColorFilter* CreateColorMatrixFilter(JNIEnv* env, jobject, jfloatArray jarray) {
+ static jlong CreateColorMatrixFilter(JNIEnv* env, jobject, jfloatArray jarray) {
AutoJavaFloatArray autoArray(env, jarray, 20);
const float* src = autoArray.ptr();
@@ -104,30 +111,30 @@
for (int i = 0; i < 20; i++) {
array[i] = SkFloatToScalar(src[i]);
}
- return new SkColorMatrixFilter(array);
+ return reinterpret_cast<jlong>(new SkColorMatrixFilter(array));
#else
- return new SkColorMatrixFilter(src);
+ return reinterpret_cast<jlong>(new SkColorMatrixFilter(src));
#endif
}
};
static JNINativeMethod colorfilter_methods[] = {
- {"finalizer", "(II)V", (void*) SkColorFilterGlue::finalizer}
+ {"finalizer", "(JJ)V", (void*) SkColorFilterGlue::finalizer}
};
static JNINativeMethod porterduff_methods[] = {
- { "native_CreatePorterDuffFilter", "(II)I", (void*) SkColorFilterGlue::CreatePorterDuffFilter },
- { "nCreatePorterDuffFilter", "(III)I", (void*) SkColorFilterGlue::glCreatePorterDuffFilter }
+ { "native_CreatePorterDuffFilter", "(II)J", (void*) SkColorFilterGlue::CreatePorterDuffFilter },
+ { "nCreatePorterDuffFilter", "(JII)J", (void*) SkColorFilterGlue::glCreatePorterDuffFilter }
};
static JNINativeMethod lighting_methods[] = {
- { "native_CreateLightingFilter", "(II)I", (void*) SkColorFilterGlue::CreateLightingFilter },
- { "nCreateLightingFilter", "(III)I", (void*) SkColorFilterGlue::glCreateLightingFilter },
+ { "native_CreateLightingFilter", "(II)J", (void*) SkColorFilterGlue::CreateLightingFilter },
+ { "nCreateLightingFilter", "(JII)J", (void*) SkColorFilterGlue::glCreateLightingFilter },
};
static JNINativeMethod colormatrix_methods[] = {
- { "nativeColorMatrixFilter", "([F)I", (void*) SkColorFilterGlue::CreateColorMatrixFilter },
- { "nColorMatrixFilter", "(I[F)I", (void*) SkColorFilterGlue::glCreateColorMatrixFilter }
+ { "nativeColorMatrixFilter", "([F)J", (void*) SkColorFilterGlue::CreateColorMatrixFilter },
+ { "nColorMatrixFilter", "(J[F)J", (void*) SkColorFilterGlue::glCreateColorMatrixFilter }
};
#define REG(env, name, array) \
diff --git a/core/jni/android/graphics/CreateJavaOutputStreamAdaptor.cpp b/core/jni/android/graphics/CreateJavaOutputStreamAdaptor.cpp
index da8f083..2cb1015 100644
--- a/core/jni/android/graphics/CreateJavaOutputStreamAdaptor.cpp
+++ b/core/jni/android/graphics/CreateJavaOutputStreamAdaptor.cpp
@@ -63,9 +63,14 @@
size_t bytesRead = 0;
// read the bytes
do {
- size_t requested = size;
- if (requested > fCapacity)
+ jint requested = 0;
+ if (size > static_cast<size_t>(fCapacity)) {
requested = fCapacity;
+ } else {
+ // This is safe because requested is clamped to (jint)
+ // fCapacity.
+ requested = static_cast<jint>(size);
+ }
jint n = env->CallIntMethod(fJavaInputStream,
gInputStream_readMethodID, fJavaByteArray, 0, requested);
@@ -120,7 +125,7 @@
JNIEnv* fEnv;
jobject fJavaInputStream; // the caller owns this object
jbyteArray fJavaByteArray; // the caller owns this object
- size_t fCapacity;
+ jint fCapacity;
size_t fBytesRead;
bool fIsAtEnd;
};
@@ -174,14 +179,18 @@
fCapacity = env->GetArrayLength(storage);
}
- virtual bool write(const void* buffer, size_t size) {
+ virtual bool write(const void* buffer, size_t size) {
JNIEnv* env = fEnv;
jbyteArray storage = fJavaByteArray;
while (size > 0) {
- size_t requested = size;
- if (requested > fCapacity) {
+ jint requested = 0;
+ if (size > static_cast<size_t>(fCapacity)) {
requested = fCapacity;
+ } else {
+ // This is safe because requested is clamped to (jint)
+ // fCapacity.
+ requested = static_cast<jint>(size);
}
env->SetByteArrayRegion(storage, 0, requested,
@@ -216,7 +225,7 @@
JNIEnv* fEnv;
jobject fJavaOutputStream; // the caller owns this object
jbyteArray fJavaByteArray; // the caller owns this object
- size_t fCapacity;
+ jint fCapacity;
};
SkWStream* CreateJavaOutputStreamAdaptor(JNIEnv* env, jobject stream,
diff --git a/core/jni/android/graphics/DrawFilter.cpp b/core/jni/android/graphics/DrawFilter.cpp
index 2f9fe7e..fbfa2ec 100644
--- a/core/jni/android/graphics/DrawFilter.cpp
+++ b/core/jni/android/graphics/DrawFilter.cpp
@@ -33,18 +33,20 @@
class SkDrawFilterGlue {
public:
- static void finalizer(JNIEnv* env, jobject clazz, SkDrawFilter* obj) {
+ static void finalizer(JNIEnv* env, jobject clazz, jlong objHandle) {
+ SkDrawFilter* obj = reinterpret_cast<SkDrawFilter*>(objHandle);
SkSafeUnref(obj);
}
- static SkDrawFilter* CreatePaintFlagsDF(JNIEnv* env, jobject clazz,
- int clearFlags, int setFlags) {
+ static jlong CreatePaintFlagsDF(JNIEnv* env, jobject clazz,
+ jint clearFlags, jint setFlags) {
// trim off any out-of-range bits
clearFlags &= SkPaint::kAllFlags;
setFlags &= SkPaint::kAllFlags;
if (clearFlags | setFlags) {
- return new SkPaintFlagsDrawFilter(clearFlags, setFlags);
+ SkDrawFilter* filter = new SkPaintFlagsDrawFilter(clearFlags, setFlags);
+ return reinterpret_cast<jlong>(filter);
} else {
return NULL;
}
@@ -52,11 +54,11 @@
};
static JNINativeMethod drawfilter_methods[] = {
- {"nativeDestructor", "(I)V", (void*) SkDrawFilterGlue::finalizer}
+ {"nativeDestructor", "(J)V", (void*) SkDrawFilterGlue::finalizer}
};
static JNINativeMethod paintflags_methods[] = {
- {"nativeConstructor","(II)I", (void*) SkDrawFilterGlue::CreatePaintFlagsDF}
+ {"nativeConstructor","(II)J", (void*) SkDrawFilterGlue::CreatePaintFlagsDF}
};
#define REG(env, name, array) \
diff --git a/core/jni/android/graphics/Graphics.cpp b/core/jni/android/graphics/Graphics.cpp
index 38a9ba3..2f4fd29 100644
--- a/core/jni/android/graphics/Graphics.cpp
+++ b/core/jni/android/graphics/Graphics.cpp
@@ -293,7 +293,8 @@
SkASSERT(env);
SkASSERT(bitmap);
SkASSERT(env->IsInstanceOf(bitmap, gBitmap_class));
- SkBitmap* b = (SkBitmap*)env->GetIntField(bitmap, gBitmap_nativeInstanceID);
+ jlong bitmapHandle = env->GetLongField(bitmap, gBitmap_nativeInstanceID);
+ SkBitmap* b = reinterpret_cast<SkBitmap*>(bitmapHandle);
SkASSERT(b);
return b;
}
@@ -316,7 +317,8 @@
SkASSERT(env);
SkASSERT(canvas);
SkASSERT(env->IsInstanceOf(canvas, gCanvas_class));
- SkCanvas* c = (SkCanvas*)env->GetIntField(canvas, gCanvas_nativeInstanceID);
+ jlong canvasHandle = env->GetLongField(canvas, gCanvas_nativeInstanceID);
+ SkCanvas* c = reinterpret_cast<SkCanvas*>(canvasHandle);
SkASSERT(c);
return c;
}
@@ -325,7 +327,8 @@
SkASSERT(env);
SkASSERT(paint);
SkASSERT(env->IsInstanceOf(paint, gPaint_class));
- SkPaint* p = (SkPaint*)env->GetIntField(paint, gPaint_nativeInstanceID);
+ jlong paintHandle = env->GetLongField(paint, gPaint_nativeInstanceID);
+ SkPaint* p = reinterpret_cast<SkPaint*>(paintHandle);
SkASSERT(p);
return p;
}
@@ -335,7 +338,8 @@
SkASSERT(env);
SkASSERT(picture);
SkASSERT(env->IsInstanceOf(picture, gPicture_class));
- SkPicture* p = (SkPicture*)env->GetIntField(picture, gPicture_nativeInstanceID);
+ jlong pictureHandle = env->GetLongField(picture, gPicture_nativeInstanceID);
+ SkPicture* p = reinterpret_cast<SkPicture*>(pictureHandle);
SkASSERT(p);
return p;
}
@@ -345,7 +349,8 @@
SkASSERT(env);
SkASSERT(region);
SkASSERT(env->IsInstanceOf(region, gRegion_class));
- SkRegion* r = (SkRegion*)env->GetIntField(region, gRegion_nativeInstanceID);
+ jlong regionHandle = env->GetLongField(region, gRegion_nativeInstanceID);
+ SkRegion* r = reinterpret_cast<SkRegion*>(regionHandle);
SkASSERT(r);
return r;
}
@@ -361,7 +366,7 @@
bool isPremultiplied = bitmapCreateFlags & kBitmapCreateFlag_Premultiplied;
jobject obj = env->NewObject(gBitmap_class, gBitmap_constructorMethodID,
- static_cast<jint>(reinterpret_cast<uintptr_t>(bitmap)), buffer,
+ reinterpret_cast<jlong>(bitmap), buffer,
bitmap->width(), bitmap->height(), density, isMutable, isPremultiplied,
ninepatch, layoutbounds);
hasException(env); // For the side effect of logging.
@@ -392,7 +397,7 @@
jobject obj = env->NewObject(gBitmapRegionDecoder_class,
gBitmapRegionDecoder_constructorMethodID,
- static_cast<jint>(reinterpret_cast<uintptr_t>(bitmap)));
+ reinterpret_cast<jlong>(bitmap));
hasException(env); // For the side effect of logging.
return obj;
}
@@ -401,7 +406,7 @@
{
SkASSERT(region != NULL);
jobject obj = env->NewObject(gRegion_class, gRegion_constructorMethodID,
- static_cast<jint>(reinterpret_cast<uintptr_t>(region)), 0);
+ reinterpret_cast<jlong>(region), 0);
hasException(env); // For the side effect of logging.
return obj;
}
@@ -646,30 +651,30 @@
gPointF_yFieldID = getFieldIDCheck(env, gPointF_class, "y", "F");
gBitmap_class = make_globalref(env, "android/graphics/Bitmap");
- gBitmap_nativeInstanceID = getFieldIDCheck(env, gBitmap_class, "mNativeBitmap", "I");
- gBitmap_constructorMethodID = env->GetMethodID(gBitmap_class, "<init>", "(I[BIIIZZ[B[I)V");
+ gBitmap_nativeInstanceID = getFieldIDCheck(env, gBitmap_class, "mNativeBitmap", "J");
+ gBitmap_constructorMethodID = env->GetMethodID(gBitmap_class, "<init>", "(J[BIIIZZ[B[I)V");
gBitmap_reinitMethodID = env->GetMethodID(gBitmap_class, "reinit", "(IIZ)V");
gBitmap_getAllocationByteCountMethodID = env->GetMethodID(gBitmap_class, "getAllocationByteCount", "()I");
gBitmapRegionDecoder_class = make_globalref(env, "android/graphics/BitmapRegionDecoder");
- gBitmapRegionDecoder_constructorMethodID = env->GetMethodID(gBitmapRegionDecoder_class, "<init>", "(I)V");
+ gBitmapRegionDecoder_constructorMethodID = env->GetMethodID(gBitmapRegionDecoder_class, "<init>", "(J)V");
gBitmapConfig_class = make_globalref(env, "android/graphics/Bitmap$Config");
gBitmapConfig_nativeInstanceID = getFieldIDCheck(env, gBitmapConfig_class,
"nativeInt", "I");
gCanvas_class = make_globalref(env, "android/graphics/Canvas");
- gCanvas_nativeInstanceID = getFieldIDCheck(env, gCanvas_class, "mNativeCanvas", "I");
+ gCanvas_nativeInstanceID = getFieldIDCheck(env, gCanvas_class, "mNativeCanvas", "J");
gPaint_class = make_globalref(env, "android/graphics/Paint");
- gPaint_nativeInstanceID = getFieldIDCheck(env, gPaint_class, "mNativePaint", "I");
+ gPaint_nativeInstanceID = getFieldIDCheck(env, gPaint_class, "mNativePaint", "J");
gPicture_class = make_globalref(env, "android/graphics/Picture");
- gPicture_nativeInstanceID = getFieldIDCheck(env, gPicture_class, "mNativePicture", "I");
+ gPicture_nativeInstanceID = getFieldIDCheck(env, gPicture_class, "mNativePicture", "J");
gRegion_class = make_globalref(env, "android/graphics/Region");
- gRegion_nativeInstanceID = getFieldIDCheck(env, gRegion_class, "mNativeRegion", "I");
+ gRegion_nativeInstanceID = getFieldIDCheck(env, gRegion_class, "mNativeRegion", "J");
gRegion_constructorMethodID = env->GetMethodID(gRegion_class, "<init>",
- "(II)V");
+ "(JI)V");
c = env->FindClass("java/lang/Byte");
gByte_class = (jclass) env->NewGlobalRef(
diff --git a/core/jni/android/graphics/Interpolator.cpp b/core/jni/android/graphics/Interpolator.cpp
index aa33c3d..ca04dfe 100644
--- a/core/jni/android/graphics/Interpolator.cpp
+++ b/core/jni/android/graphics/Interpolator.cpp
@@ -5,23 +5,26 @@
#include "SkInterpolator.h"
#include "SkTemplates.h"
-static SkInterpolator* Interpolator_constructor(JNIEnv* env, jobject clazz, int valueCount, int frameCount)
+static jlong Interpolator_constructor(JNIEnv* env, jobject clazz, jint valueCount, jint frameCount)
{
- return new SkInterpolator(valueCount, frameCount);
+ return reinterpret_cast<jlong>(new SkInterpolator(valueCount, frameCount));
}
-static void Interpolator_destructor(JNIEnv* env, jobject clazz, SkInterpolator* interp)
+static void Interpolator_destructor(JNIEnv* env, jobject clazz, jlong interpHandle)
{
+ SkInterpolator* interp = reinterpret_cast<SkInterpolator*>(interpHandle);
delete interp;
}
-static void Interpolator_reset(JNIEnv* env, jobject clazz, SkInterpolator* interp, int valueCount, int frameCount)
+static void Interpolator_reset(JNIEnv* env, jobject clazz, jlong interpHandle, jint valueCount, jint frameCount)
{
+ SkInterpolator* interp = reinterpret_cast<SkInterpolator*>(interpHandle);
interp->reset(valueCount, frameCount);
}
-static void Interpolator_setKeyFrame(JNIEnv* env, jobject clazz, SkInterpolator* interp, int index, int msec, jfloatArray valueArray, jfloatArray blendArray)
+static void Interpolator_setKeyFrame(JNIEnv* env, jobject clazz, jlong interpHandle, jint index, jint msec, jfloatArray valueArray, jfloatArray blendArray)
{
+ SkInterpolator* interp = reinterpret_cast<SkInterpolator*>(interpHandle);
SkScalar blendStorage[4];
SkScalar* blend = NULL;
@@ -46,8 +49,9 @@
interp->setKeyFrame(index, msec, scalars, blend);
}
-static void Interpolator_setRepeatMirror(JNIEnv* env, jobject clazz, SkInterpolator* interp, float repeatCount, jboolean mirror)
+static void Interpolator_setRepeatMirror(JNIEnv* env, jobject clazz, jlong interpHandle, jfloat repeatCount, jboolean mirror)
{
+ SkInterpolator* interp = reinterpret_cast<SkInterpolator*>(interpHandle);
if (repeatCount > 32000)
repeatCount = 32000;
@@ -55,8 +59,9 @@
interp->setMirror(mirror != 0);
}
-static int Interpolator_timeToValues(JNIEnv* env, jobject clazz, SkInterpolator* interp, int msec, jfloatArray valueArray)
+static jint Interpolator_timeToValues(JNIEnv* env, jobject clazz, jlong interpHandle, jint msec, jfloatArray valueArray)
{
+ SkInterpolator* interp = reinterpret_cast<SkInterpolator*>(interpHandle);
SkInterpolatorBase::Result result;
float* values = valueArray ? env->GetFloatArrayElements(valueArray, NULL) : NULL;
@@ -70,7 +75,7 @@
env->ReleaseFloatArrayElements(valueArray, values, 0);
}
- return result;
+ return static_cast<jint>(result);
}
// ----------------------------------------------------------------------------
@@ -79,12 +84,12 @@
* JNI registration.
*/
static JNINativeMethod gInterpolatorMethods[] = {
- { "nativeConstructor", "(II)I", (void*)Interpolator_constructor },
- { "nativeDestructor", "(I)V", (void*)Interpolator_destructor },
- { "nativeReset", "(III)V", (void*)Interpolator_reset },
- { "nativeSetKeyFrame", "(III[F[F)V", (void*)Interpolator_setKeyFrame },
- { "nativeSetRepeatMirror", "(IFZ)V", (void*)Interpolator_setRepeatMirror },
- { "nativeTimeToValues", "(II[F)I", (void*)Interpolator_timeToValues }
+ { "nativeConstructor", "(II)J", (void*)Interpolator_constructor },
+ { "nativeDestructor", "(J)V", (void*)Interpolator_destructor },
+ { "nativeReset", "(JII)V", (void*)Interpolator_reset },
+ { "nativeSetKeyFrame", "(JII[F[F)V", (void*)Interpolator_setKeyFrame },
+ { "nativeSetRepeatMirror", "(JFZ)V", (void*)Interpolator_setRepeatMirror },
+ { "nativeTimeToValues", "(JI[F)I", (void*)Interpolator_timeToValues }
};
int register_android_graphics_Interpolator(JNIEnv* env)
diff --git a/core/jni/android/graphics/LayerRasterizer.cpp b/core/jni/android/graphics/LayerRasterizer.cpp
index e5bc6f8..29e7db1 100644
--- a/core/jni/android/graphics/LayerRasterizer.cpp
+++ b/core/jni/android/graphics/LayerRasterizer.cpp
@@ -3,11 +3,13 @@
class SkLayerRasterizerGlue {
public:
- static SkRasterizer* create(JNIEnv* env, jobject) {
- return new SkLayerRasterizer();
+ static jlong create(JNIEnv* env, jobject) {
+ return reinterpret_cast<jlong>(new SkLayerRasterizer());
}
- static void addLayer(JNIEnv* env, jobject, SkLayerRasterizer* layer, const SkPaint* paint, float dx, float dy) {
+ static void addLayer(JNIEnv* env, jobject, jlong layerHandle, jlong paintHandle, jfloat dx, jfloat dy) {
+ SkLayerRasterizer* layer = reinterpret_cast<SkLayerRasterizer *>(layerHandle);
+ const SkPaint* paint = reinterpret_cast<SkPaint *>(paintHandle);
SkASSERT(layer);
SkASSERT(paint);
layer->addLayer(*paint, SkFloatToScalar(dx), SkFloatToScalar(dy));
@@ -19,8 +21,8 @@
#include <android_runtime/AndroidRuntime.h>
static JNINativeMethod gLayerRasterizerMethods[] = {
- { "nativeConstructor", "()I", (void*)SkLayerRasterizerGlue::create },
- { "nativeAddLayer", "(IIFF)V", (void*)SkLayerRasterizerGlue::addLayer }
+ { "nativeConstructor", "()J", (void*)SkLayerRasterizerGlue::create },
+ { "nativeAddLayer", "(JJFF)V", (void*)SkLayerRasterizerGlue::addLayer }
};
int register_android_graphics_LayerRasterizer(JNIEnv* env)
diff --git a/core/jni/android/graphics/MaskFilter.cpp b/core/jni/android/graphics/MaskFilter.cpp
index d954ddf..f331af7 100644
--- a/core/jni/android/graphics/MaskFilter.cpp
+++ b/core/jni/android/graphics/MaskFilter.cpp
@@ -13,18 +13,19 @@
class SkMaskFilterGlue {
public:
- static void destructor(JNIEnv* env, jobject, SkMaskFilter* filter) {
+ static void destructor(JNIEnv* env, jobject, jlong filterHandle) {
+ SkMaskFilter* filter = reinterpret_cast<SkMaskFilter *>(filterHandle);
SkSafeUnref(filter);
}
- static SkMaskFilter* createBlur(JNIEnv* env, jobject, float radius, int blurStyle) {
+ static jlong createBlur(JNIEnv* env, jobject, jfloat radius, jint blurStyle) {
SkMaskFilter* filter = SkBlurMaskFilter::Create(SkFloatToScalar(radius),
(SkBlurMaskFilter::BlurStyle)blurStyle);
ThrowIAE_IfNull(env, filter);
- return filter;
+ return reinterpret_cast<jlong>(filter);
}
- static SkMaskFilter* createEmboss(JNIEnv* env, jobject, jfloatArray dirArray, float ambient, float specular, float radius) {
+ static jlong createEmboss(JNIEnv* env, jobject, jfloatArray dirArray, jfloat ambient, jfloat specular, jfloat radius) {
SkScalar direction[3];
AutoJavaFloatArray autoDir(env, dirArray, 3);
@@ -38,39 +39,42 @@
SkFloatToScalar(specular),
SkFloatToScalar(radius));
ThrowIAE_IfNull(env, filter);
- return filter;
+ return reinterpret_cast<jlong>(filter);
}
- static SkMaskFilter* createTable(JNIEnv* env, jobject, jbyteArray jtable) {
+ static jlong createTable(JNIEnv* env, jobject, jbyteArray jtable) {
AutoJavaByteArray autoTable(env, jtable, 256);
- return new SkTableMaskFilter((const uint8_t*)autoTable.ptr());
+ SkMaskFilter* filter = new SkTableMaskFilter((const uint8_t*)autoTable.ptr());
+ return reinterpret_cast<jlong>(filter);
}
- static SkMaskFilter* createClipTable(JNIEnv* env, jobject, int min, int max) {
- return SkTableMaskFilter::CreateClip(min, max);
+ static jlong createClipTable(JNIEnv* env, jobject, jint min, jint max) {
+ SkMaskFilter* filter = SkTableMaskFilter::CreateClip(min, max);
+ return reinterpret_cast<jlong>(filter);
}
- static SkMaskFilter* createGammaTable(JNIEnv* env, jobject, float gamma) {
- return SkTableMaskFilter::CreateGamma(gamma);
+ static jlong createGammaTable(JNIEnv* env, jobject, jfloat gamma) {
+ SkMaskFilter* filter = SkTableMaskFilter::CreateGamma(gamma);
+ return reinterpret_cast<jlong>(filter);
}
};
static JNINativeMethod gMaskFilterMethods[] = {
- { "nativeDestructor", "(I)V", (void*)SkMaskFilterGlue::destructor }
+ { "nativeDestructor", "(J)V", (void*)SkMaskFilterGlue::destructor }
};
static JNINativeMethod gBlurMaskFilterMethods[] = {
- { "nativeConstructor", "(FI)I", (void*)SkMaskFilterGlue::createBlur }
+ { "nativeConstructor", "(FI)J", (void*)SkMaskFilterGlue::createBlur }
};
static JNINativeMethod gEmbossMaskFilterMethods[] = {
- { "nativeConstructor", "([FFFF)I", (void*)SkMaskFilterGlue::createEmboss }
+ { "nativeConstructor", "([FFFF)J", (void*)SkMaskFilterGlue::createEmboss }
};
static JNINativeMethod gTableMaskFilterMethods[] = {
- { "nativeNewTable", "([B)I", (void*)SkMaskFilterGlue::createTable },
- { "nativeNewClip", "(II)I", (void*)SkMaskFilterGlue::createClipTable },
- { "nativeNewGamma", "(F)I", (void*)SkMaskFilterGlue::createGammaTable }
+ { "nativeNewTable", "([B)J", (void*)SkMaskFilterGlue::createTable },
+ { "nativeNewClip", "(II)J", (void*)SkMaskFilterGlue::createClipTable },
+ { "nativeNewGamma", "(F)J", (void*)SkMaskFilterGlue::createGammaTable }
};
#include <android_runtime/AndroidRuntime.h>
diff --git a/core/jni/android/graphics/Matrix.cpp b/core/jni/android/graphics/Matrix.cpp
index d0871ac5..a667499 100644
--- a/core/jni/android/graphics/Matrix.cpp
+++ b/core/jni/android/graphics/Matrix.cpp
@@ -31,218 +31,246 @@
class SkMatrixGlue {
public:
- static void finalizer(JNIEnv* env, jobject clazz, SkMatrix* obj) {
+ static void finalizer(JNIEnv* env, jobject clazz, jlong objHandle) {
+ SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle);
delete obj;
}
- static SkMatrix* create(JNIEnv* env, jobject clazz, const SkMatrix* src) {
+ static jlong create(JNIEnv* env, jobject clazz, jlong srcHandle) {
+ const SkMatrix* src = reinterpret_cast<SkMatrix*>(srcHandle);
SkMatrix* obj = new SkMatrix();
if (src)
*obj = *src;
else
obj->reset();
- return obj;
+ return reinterpret_cast<jlong>(obj);
}
-
- static jboolean isIdentity(JNIEnv* env, jobject clazz, SkMatrix* obj) {
- return obj->isIdentity();
+
+ static jboolean isIdentity(JNIEnv* env, jobject clazz, jlong objHandle) {
+ SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle);
+ return obj->isIdentity() ? JNI_TRUE : JNI_FALSE;
}
-
- static jboolean rectStaysRect(JNIEnv* env, jobject clazz, SkMatrix* obj) {
- return obj->rectStaysRect();
+ static jboolean rectStaysRect(JNIEnv* env, jobject clazz, jlong objHandle) {
+ SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle);
+ return obj->rectStaysRect() ? JNI_TRUE : JNI_FALSE;
}
-
- static void reset(JNIEnv* env, jobject clazz, SkMatrix* obj) {
+ static void reset(JNIEnv* env, jobject clazz, jlong objHandle) {
+ SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle);
obj->reset();
}
-
- static void set(JNIEnv* env, jobject clazz, SkMatrix* obj, SkMatrix* other) {
+ static void set(JNIEnv* env, jobject clazz, jlong objHandle, jlong otherHandle) {
+ SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle);
+ SkMatrix* other = reinterpret_cast<SkMatrix*>(otherHandle);
*obj = *other;
}
-
- static void setTranslate(JNIEnv* env, jobject clazz, SkMatrix* obj, jfloat dx, jfloat dy) {
+ static void setTranslate(JNIEnv* env, jobject clazz, jlong objHandle, jfloat dx, jfloat dy) {
+ SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle);
SkScalar dx_ = SkFloatToScalar(dx);
SkScalar dy_ = SkFloatToScalar(dy);
obj->setTranslate(dx_, dy_);
}
-
- static void setScale__FFFF(JNIEnv* env, jobject clazz, SkMatrix* obj, jfloat sx, jfloat sy, jfloat px, jfloat py) {
+ static void setScale__FFFF(JNIEnv* env, jobject clazz, jlong objHandle, jfloat sx, jfloat sy, jfloat px, jfloat py) {
+ SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle);
SkScalar sx_ = SkFloatToScalar(sx);
SkScalar sy_ = SkFloatToScalar(sy);
SkScalar px_ = SkFloatToScalar(px);
SkScalar py_ = SkFloatToScalar(py);
obj->setScale(sx_, sy_, px_, py_);
}
-
- static void setScale__FF(JNIEnv* env, jobject clazz, SkMatrix* obj, jfloat sx, jfloat sy) {
+ static void setScale__FF(JNIEnv* env, jobject clazz, jlong objHandle, jfloat sx, jfloat sy) {
+ SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle);
SkScalar sx_ = SkFloatToScalar(sx);
SkScalar sy_ = SkFloatToScalar(sy);
obj->setScale(sx_, sy_);
}
-
- static void setRotate__FFF(JNIEnv* env, jobject clazz, SkMatrix* obj, jfloat degrees, jfloat px, jfloat py) {
+ static void setRotate__FFF(JNIEnv* env, jobject clazz, jlong objHandle, jfloat degrees, jfloat px, jfloat py) {
+ SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle);
SkScalar degrees_ = SkFloatToScalar(degrees);
SkScalar px_ = SkFloatToScalar(px);
SkScalar py_ = SkFloatToScalar(py);
obj->setRotate(degrees_, px_, py_);
}
-
- static void setRotate__F(JNIEnv* env, jobject clazz, SkMatrix* obj, jfloat degrees) {
+ static void setRotate__F(JNIEnv* env, jobject clazz, jlong objHandle, jfloat degrees) {
+ SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle);
SkScalar degrees_ = SkFloatToScalar(degrees);
obj->setRotate(degrees_);
}
-
- static void setSinCos__FFFF(JNIEnv* env, jobject clazz, SkMatrix* obj, jfloat sinValue, jfloat cosValue, jfloat px, jfloat py) {
+ static void setSinCos__FFFF(JNIEnv* env, jobject clazz, jlong objHandle, jfloat sinValue, jfloat cosValue, jfloat px, jfloat py) {
+ SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle);
SkScalar sinValue_ = SkFloatToScalar(sinValue);
SkScalar cosValue_ = SkFloatToScalar(cosValue);
SkScalar px_ = SkFloatToScalar(px);
SkScalar py_ = SkFloatToScalar(py);
obj->setSinCos(sinValue_, cosValue_, px_, py_);
}
-
- static void setSinCos__FF(JNIEnv* env, jobject clazz, SkMatrix* obj, jfloat sinValue, jfloat cosValue) {
+ static void setSinCos__FF(JNIEnv* env, jobject clazz, jlong objHandle, jfloat sinValue, jfloat cosValue) {
+ SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle);
SkScalar sinValue_ = SkFloatToScalar(sinValue);
SkScalar cosValue_ = SkFloatToScalar(cosValue);
obj->setSinCos(sinValue_, cosValue_);
}
-
- static void setSkew__FFFF(JNIEnv* env, jobject clazz, SkMatrix* obj, jfloat kx, jfloat ky, jfloat px, jfloat py) {
+ static void setSkew__FFFF(JNIEnv* env, jobject clazz, jlong objHandle, jfloat kx, jfloat ky, jfloat px, jfloat py) {
+ SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle);
SkScalar kx_ = SkFloatToScalar(kx);
SkScalar ky_ = SkFloatToScalar(ky);
SkScalar px_ = SkFloatToScalar(px);
SkScalar py_ = SkFloatToScalar(py);
obj->setSkew(kx_, ky_, px_, py_);
}
-
- static void setSkew__FF(JNIEnv* env, jobject clazz, SkMatrix* obj, jfloat kx, jfloat ky) {
+ static void setSkew__FF(JNIEnv* env, jobject clazz, jlong objHandle, jfloat kx, jfloat ky) {
+ SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle);
SkScalar kx_ = SkFloatToScalar(kx);
SkScalar ky_ = SkFloatToScalar(ky);
obj->setSkew(kx_, ky_);
}
-
- static jboolean setConcat(JNIEnv* env, jobject clazz, SkMatrix* obj, SkMatrix* a, SkMatrix* b) {
- return obj->setConcat(*a, *b);
+ static jboolean setConcat(JNIEnv* env, jobject clazz, jlong objHandle, jlong aHandle, jlong bHandle) {
+ SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle);
+ SkMatrix* a = reinterpret_cast<SkMatrix*>(aHandle);
+ SkMatrix* b = reinterpret_cast<SkMatrix*>(bHandle);
+ return obj->setConcat(*a, *b) ? JNI_TRUE : JNI_FALSE;
}
-
- static jboolean preTranslate(JNIEnv* env, jobject clazz, SkMatrix* obj, jfloat dx, jfloat dy) {
+
+ static jboolean preTranslate(JNIEnv* env, jobject clazz, jlong objHandle, jfloat dx, jfloat dy) {
+ SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle);
SkScalar dx_ = SkFloatToScalar(dx);
SkScalar dy_ = SkFloatToScalar(dy);
- return obj->preTranslate(dx_, dy_);
+ return obj->preTranslate(dx_, dy_) ? JNI_TRUE : JNI_FALSE;
}
-
- static jboolean preScale__FFFF(JNIEnv* env, jobject clazz, SkMatrix* obj, jfloat sx, jfloat sy, jfloat px, jfloat py) {
+
+ static jboolean preScale__FFFF(JNIEnv* env, jobject clazz, jlong objHandle, jfloat sx, jfloat sy, jfloat px, jfloat py) {
+ SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle);
SkScalar sx_ = SkFloatToScalar(sx);
SkScalar sy_ = SkFloatToScalar(sy);
SkScalar px_ = SkFloatToScalar(px);
SkScalar py_ = SkFloatToScalar(py);
- return obj->preScale(sx_, sy_, px_, py_);
+ return obj->preScale(sx_, sy_, px_, py_) ? JNI_TRUE : JNI_FALSE;
}
-
- static jboolean preScale__FF(JNIEnv* env, jobject clazz, SkMatrix* obj, jfloat sx, jfloat sy) {
+
+ static jboolean preScale__FF(JNIEnv* env, jobject clazz, jlong objHandle, jfloat sx, jfloat sy) {
+ SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle);
SkScalar sx_ = SkFloatToScalar(sx);
SkScalar sy_ = SkFloatToScalar(sy);
- return obj->preScale(sx_, sy_);
+ return obj->preScale(sx_, sy_) ? JNI_TRUE : JNI_FALSE;
}
-
- static jboolean preRotate__FFF(JNIEnv* env, jobject clazz, SkMatrix* obj, jfloat degrees, jfloat px, jfloat py) {
+
+ static jboolean preRotate__FFF(JNIEnv* env, jobject clazz, jlong objHandle, jfloat degrees, jfloat px, jfloat py) {
+ SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle);
SkScalar degrees_ = SkFloatToScalar(degrees);
SkScalar px_ = SkFloatToScalar(px);
SkScalar py_ = SkFloatToScalar(py);
- return obj->preRotate(degrees_, px_, py_);
+ return obj->preRotate(degrees_, px_, py_) ? JNI_TRUE : JNI_FALSE;
}
-
- static jboolean preRotate__F(JNIEnv* env, jobject clazz, SkMatrix* obj, jfloat degrees) {
+
+ static jboolean preRotate__F(JNIEnv* env, jobject clazz, jlong objHandle, jfloat degrees) {
+ SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle);
SkScalar degrees_ = SkFloatToScalar(degrees);
- return obj->preRotate(degrees_);
+ return obj->preRotate(degrees_) ? JNI_TRUE : JNI_FALSE;
}
-
- static jboolean preSkew__FFFF(JNIEnv* env, jobject clazz, SkMatrix* obj, jfloat kx, jfloat ky, jfloat px, jfloat py) {
+
+ static jboolean preSkew__FFFF(JNIEnv* env, jobject clazz, jlong objHandle, jfloat kx, jfloat ky, jfloat px, jfloat py) {
+ SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle);
SkScalar kx_ = SkFloatToScalar(kx);
SkScalar ky_ = SkFloatToScalar(ky);
SkScalar px_ = SkFloatToScalar(px);
SkScalar py_ = SkFloatToScalar(py);
- return obj->preSkew(kx_, ky_, px_, py_);
+ return obj->preSkew(kx_, ky_, px_, py_) ? JNI_TRUE : JNI_FALSE;
}
-
- static jboolean preSkew__FF(JNIEnv* env, jobject clazz, SkMatrix* obj, jfloat kx, jfloat ky) {
+
+ static jboolean preSkew__FF(JNIEnv* env, jobject clazz, jlong objHandle, jfloat kx, jfloat ky) {
+ SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle);
SkScalar kx_ = SkFloatToScalar(kx);
SkScalar ky_ = SkFloatToScalar(ky);
- return obj->preSkew(kx_, ky_);
+ return obj->preSkew(kx_, ky_) ? JNI_TRUE : JNI_FALSE;
}
-
- static jboolean preConcat(JNIEnv* env, jobject clazz, SkMatrix* obj, SkMatrix* other) {
- return obj->preConcat(*other);
+
+ static jboolean preConcat(JNIEnv* env, jobject clazz, jlong objHandle, jlong otherHandle) {
+ SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle);
+ SkMatrix* other = reinterpret_cast<SkMatrix*>(otherHandle);
+ return obj->preConcat(*other) ? JNI_TRUE : JNI_FALSE;
}
-
- static jboolean postTranslate(JNIEnv* env, jobject clazz, SkMatrix* obj, jfloat dx, jfloat dy) {
+
+ static jboolean postTranslate(JNIEnv* env, jobject clazz, jlong objHandle, jfloat dx, jfloat dy) {
+ SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle);
SkScalar dx_ = SkFloatToScalar(dx);
SkScalar dy_ = SkFloatToScalar(dy);
- return obj->postTranslate(dx_, dy_);
+ return obj->postTranslate(dx_, dy_) ? JNI_TRUE : JNI_FALSE;
}
-
- static jboolean postScale__FFFF(JNIEnv* env, jobject clazz, SkMatrix* obj, jfloat sx, jfloat sy, jfloat px, jfloat py) {
+
+ static jboolean postScale__FFFF(JNIEnv* env, jobject clazz, jlong objHandle, jfloat sx, jfloat sy, jfloat px, jfloat py) {
+ SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle);
SkScalar sx_ = SkFloatToScalar(sx);
SkScalar sy_ = SkFloatToScalar(sy);
SkScalar px_ = SkFloatToScalar(px);
SkScalar py_ = SkFloatToScalar(py);
- return obj->postScale(sx_, sy_, px_, py_);
+ return obj->postScale(sx_, sy_, px_, py_) ? JNI_TRUE : JNI_FALSE;
}
-
- static jboolean postScale__FF(JNIEnv* env, jobject clazz, SkMatrix* obj, jfloat sx, jfloat sy) {
+
+ static jboolean postScale__FF(JNIEnv* env, jobject clazz, jlong objHandle, jfloat sx, jfloat sy) {
+ SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle);
SkScalar sx_ = SkFloatToScalar(sx);
SkScalar sy_ = SkFloatToScalar(sy);
- return obj->postScale(sx_, sy_);
+ return obj->postScale(sx_, sy_) ? JNI_TRUE : JNI_FALSE;
}
-
- static jboolean postRotate__FFF(JNIEnv* env, jobject clazz, SkMatrix* obj, jfloat degrees, jfloat px, jfloat py) {
+
+ static jboolean postRotate__FFF(JNIEnv* env, jobject clazz, jlong objHandle, jfloat degrees, jfloat px, jfloat py) {
+ SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle);
SkScalar degrees_ = SkFloatToScalar(degrees);
SkScalar px_ = SkFloatToScalar(px);
SkScalar py_ = SkFloatToScalar(py);
- return obj->postRotate(degrees_, px_, py_);
+ return obj->postRotate(degrees_, px_, py_) ? JNI_TRUE : JNI_FALSE;
}
-
- static jboolean postRotate__F(JNIEnv* env, jobject clazz, SkMatrix* obj, jfloat degrees) {
+
+ static jboolean postRotate__F(JNIEnv* env, jobject clazz, jlong objHandle, jfloat degrees) {
+ SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle);
SkScalar degrees_ = SkFloatToScalar(degrees);
- return obj->postRotate(degrees_);
+ return obj->postRotate(degrees_) ? JNI_TRUE : JNI_FALSE;
}
-
- static jboolean postSkew__FFFF(JNIEnv* env, jobject clazz, SkMatrix* obj, jfloat kx, jfloat ky, jfloat px, jfloat py) {
+
+ static jboolean postSkew__FFFF(JNIEnv* env, jobject clazz, jlong objHandle, jfloat kx, jfloat ky, jfloat px, jfloat py) {
+ SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle);
SkScalar kx_ = SkFloatToScalar(kx);
SkScalar ky_ = SkFloatToScalar(ky);
SkScalar px_ = SkFloatToScalar(px);
SkScalar py_ = SkFloatToScalar(py);
- return obj->postSkew(kx_, ky_, px_, py_);
+ return obj->postSkew(kx_, ky_, px_, py_) ? JNI_TRUE : JNI_FALSE;
}
-
- static jboolean postSkew__FF(JNIEnv* env, jobject clazz, SkMatrix* matrix, jfloat kx, jfloat ky) {
+
+ static jboolean postSkew__FF(JNIEnv* env, jobject clazz, jlong matrixHandle, jfloat kx, jfloat ky) {
+ SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle);
SkScalar kx_ = SkFloatToScalar(kx);
SkScalar ky_ = SkFloatToScalar(ky);
- return matrix->postSkew(kx_, ky_);
+ return matrix->postSkew(kx_, ky_) ? JNI_TRUE : JNI_FALSE;
}
-
- static jboolean postConcat(JNIEnv* env, jobject clazz, SkMatrix* matrix, SkMatrix* other) {
- return matrix->postConcat(*other);
+
+ static jboolean postConcat(JNIEnv* env, jobject clazz, jlong matrixHandle, jlong otherHandle) {
+ SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle);
+ SkMatrix* other = reinterpret_cast<SkMatrix*>(otherHandle);
+ return matrix->postConcat(*other) ? JNI_TRUE : JNI_FALSE;
}
-
- static jboolean setRectToRect(JNIEnv* env, jobject clazz, SkMatrix* matrix, jobject src, jobject dst, SkMatrix::ScaleToFit stf) {
+
+ static jboolean setRectToRect(JNIEnv* env, jobject clazz, jlong matrixHandle, jobject src, jobject dst, jint stfHandle) {
+ SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle);
+ SkMatrix::ScaleToFit stf = static_cast<SkMatrix::ScaleToFit>(stfHandle);
SkRect src_;
GraphicsJNI::jrectf_to_rect(env, src, &src_);
SkRect dst_;
GraphicsJNI::jrectf_to_rect(env, dst, &dst_);
- return matrix->setRectToRect(src_, dst_, stf);
+ return matrix->setRectToRect(src_, dst_, stf) ? JNI_TRUE : JNI_FALSE;
}
-
- static jboolean setPolyToPoly(JNIEnv* env, jobject clazz, SkMatrix* matrix,
- jfloatArray jsrc, int srcIndex,
- jfloatArray jdst, int dstIndex, int ptCount) {
+
+ static jboolean setPolyToPoly(JNIEnv* env, jobject clazz, jlong matrixHandle,
+ jfloatArray jsrc, jint srcIndex,
+ jfloatArray jdst, jint dstIndex, jint ptCount) {
+ SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle);
SkASSERT(srcIndex >= 0);
SkASSERT(dstIndex >= 0);
SkASSERT((unsigned)ptCount <= 4);
- AutoJavaFloatArray autoSrc(env, jsrc, srcIndex + (ptCount << 1));
- AutoJavaFloatArray autoDst(env, jdst, dstIndex + (ptCount << 1));
+ AutoJavaFloatArray autoSrc(env, jsrc, srcIndex + (ptCount << 1), kRO_JNIAccess);
+ AutoJavaFloatArray autoDst(env, jdst, dstIndex + (ptCount << 1), kRW_JNIAccess);
float* src = autoSrc.ptr() + srcIndex;
float* dst = autoDst.ptr() + dstIndex;
+ bool result;
#ifdef SK_SCALAR_IS_FIXED
SkPoint srcPt[4], dstPt[4];
@@ -252,24 +280,28 @@
srcPt[i].set(SkFloatToScalar(src[x]), SkFloatToScalar(src[y]));
dstPt[i].set(SkFloatToScalar(dst[x]), SkFloatToScalar(dst[y]));
}
- return matrix->setPolyToPoly(srcPt, dstPt, ptCount);
+ result = matrix->setPolyToPoly(srcPt, dstPt, ptCount);
#else
- return matrix->setPolyToPoly((const SkPoint*)src, (const SkPoint*)dst,
+ result = matrix->setPolyToPoly((const SkPoint*)src, (const SkPoint*)dst,
ptCount);
#endif
+ return result ? JNI_TRUE : JNI_FALSE;
}
-
- static jboolean invert(JNIEnv* env, jobject clazz, SkMatrix* matrix, SkMatrix* inverse) {
+
+ static jboolean invert(JNIEnv* env, jobject clazz, jlong matrixHandle, jlong inverseHandle) {
+ SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle);
+ SkMatrix* inverse = reinterpret_cast<SkMatrix*>(inverseHandle);
return matrix->invert(inverse);
}
-
- static void mapPoints(JNIEnv* env, jobject clazz, SkMatrix* matrix,
- jfloatArray dst, int dstIndex,
- jfloatArray src, int srcIndex,
- int ptCount, bool isPts) {
+
+ static void mapPoints(JNIEnv* env, jobject clazz, jlong matrixHandle,
+ jfloatArray dst, jint dstIndex,
+ jfloatArray src, jint srcIndex,
+ jint ptCount, jboolean isPts) {
+ SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle);
SkASSERT(ptCount >= 0);
- AutoJavaFloatArray autoSrc(env, src, srcIndex + (ptCount << 1));
- AutoJavaFloatArray autoDst(env, dst, dstIndex + (ptCount << 1));
+ AutoJavaFloatArray autoSrc(env, src, srcIndex + (ptCount << 1), kRO_JNIAccess);
+ AutoJavaFloatArray autoDst(env, dst, dstIndex + (ptCount << 1), kRW_JNIAccess);
float* srcArray = autoSrc.ptr() + srcIndex;
float* dstArray = autoDst.ptr() + dstIndex;
@@ -304,21 +336,26 @@
ptCount);
#endif
}
-
- static jboolean mapRect__RectFRectF(JNIEnv* env, jobject clazz, SkMatrix* matrix, jobjectArray dst, jobject src) {
+
+ static jboolean mapRect__RectFRectF(JNIEnv* env, jobject clazz, jlong matrixHandle, jobjectArray dst, jobject src) {
+ SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle);
SkRect dst_, src_;
GraphicsJNI::jrectf_to_rect(env, src, &src_);
jboolean rectStaysRect = matrix->mapRect(&dst_, src_);
GraphicsJNI::rect_to_jrectf(dst_, env, dst);
- return rectStaysRect;
+ return rectStaysRect ? JNI_TRUE : JNI_FALSE;
}
-
- static jfloat mapRadius(JNIEnv* env, jobject clazz, SkMatrix* matrix, jfloat radius) {
- return SkScalarToFloat(matrix->mapRadius(SkFloatToScalar(radius)));
+
+ static jfloat mapRadius(JNIEnv* env, jobject clazz, jlong matrixHandle, jfloat radius) {
+ SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle);
+ float result;
+ result = SkScalarToFloat(matrix->mapRadius(SkFloatToScalar(radius)));
+ return static_cast<jfloat>(result);
}
-
- static void getValues(JNIEnv* env, jobject clazz, SkMatrix* matrix, jfloatArray values) {
- AutoJavaFloatArray autoValues(env, values, 9);
+
+ static void getValues(JNIEnv* env, jobject clazz, jlong matrixHandle, jfloatArray values) {
+ SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle);
+ AutoJavaFloatArray autoValues(env, values, 9, kRW_JNIAccess);
float* dst = autoValues.ptr();
#ifdef SK_SCALAR_IS_FIXED
@@ -334,9 +371,10 @@
}
#endif
}
-
- static void setValues(JNIEnv* env, jobject clazz, SkMatrix* matrix, jfloatArray values) {
- AutoJavaFloatArray autoValues(env, values, 9);
+
+ static void setValues(JNIEnv* env, jobject clazz, jlong matrixHandle, jfloatArray values) {
+ SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle);
+ AutoJavaFloatArray autoValues(env, values, 9, kRO_JNIAccess);
const float* src = autoValues.ptr();
#ifdef SK_SCALAR_IS_FIXED
@@ -353,53 +391,55 @@
#endif
}
- static jboolean equals(JNIEnv* env, jobject clazz, const SkMatrix* a, const SkMatrix* b) {
+ static jboolean equals(JNIEnv* env, jobject clazz, jlong aHandle, jlong bHandle) {
+ const SkMatrix* a = reinterpret_cast<SkMatrix*>(aHandle);
+ const SkMatrix* b = reinterpret_cast<SkMatrix*>(bHandle);
return *a == *b;
}
};
static JNINativeMethod methods[] = {
- {"finalizer", "(I)V", (void*) SkMatrixGlue::finalizer},
- {"native_create","(I)I", (void*) SkMatrixGlue::create},
- {"native_isIdentity","(I)Z", (void*) SkMatrixGlue::isIdentity},
- {"native_rectStaysRect","(I)Z", (void*) SkMatrixGlue::rectStaysRect},
- {"native_reset","(I)V", (void*) SkMatrixGlue::reset},
- {"native_set","(II)V", (void*) SkMatrixGlue::set},
- {"native_setTranslate","(IFF)V", (void*) SkMatrixGlue::setTranslate},
- {"native_setScale","(IFFFF)V", (void*) SkMatrixGlue::setScale__FFFF},
- {"native_setScale","(IFF)V", (void*) SkMatrixGlue::setScale__FF},
- {"native_setRotate","(IFFF)V", (void*) SkMatrixGlue::setRotate__FFF},
- {"native_setRotate","(IF)V", (void*) SkMatrixGlue::setRotate__F},
- {"native_setSinCos","(IFFFF)V", (void*) SkMatrixGlue::setSinCos__FFFF},
- {"native_setSinCos","(IFF)V", (void*) SkMatrixGlue::setSinCos__FF},
- {"native_setSkew","(IFFFF)V", (void*) SkMatrixGlue::setSkew__FFFF},
- {"native_setSkew","(IFF)V", (void*) SkMatrixGlue::setSkew__FF},
- {"native_setConcat","(III)Z", (void*) SkMatrixGlue::setConcat},
- {"native_preTranslate","(IFF)Z", (void*) SkMatrixGlue::preTranslate},
- {"native_preScale","(IFFFF)Z", (void*) SkMatrixGlue::preScale__FFFF},
- {"native_preScale","(IFF)Z", (void*) SkMatrixGlue::preScale__FF},
- {"native_preRotate","(IFFF)Z", (void*) SkMatrixGlue::preRotate__FFF},
- {"native_preRotate","(IF)Z", (void*) SkMatrixGlue::preRotate__F},
- {"native_preSkew","(IFFFF)Z", (void*) SkMatrixGlue::preSkew__FFFF},
- {"native_preSkew","(IFF)Z", (void*) SkMatrixGlue::preSkew__FF},
- {"native_preConcat","(II)Z", (void*) SkMatrixGlue::preConcat},
- {"native_postTranslate","(IFF)Z", (void*) SkMatrixGlue::postTranslate},
- {"native_postScale","(IFFFF)Z", (void*) SkMatrixGlue::postScale__FFFF},
- {"native_postScale","(IFF)Z", (void*) SkMatrixGlue::postScale__FF},
- {"native_postRotate","(IFFF)Z", (void*) SkMatrixGlue::postRotate__FFF},
- {"native_postRotate","(IF)Z", (void*) SkMatrixGlue::postRotate__F},
- {"native_postSkew","(IFFFF)Z", (void*) SkMatrixGlue::postSkew__FFFF},
- {"native_postSkew","(IFF)Z", (void*) SkMatrixGlue::postSkew__FF},
- {"native_postConcat","(II)Z", (void*) SkMatrixGlue::postConcat},
- {"native_setRectToRect","(ILandroid/graphics/RectF;Landroid/graphics/RectF;I)Z", (void*) SkMatrixGlue::setRectToRect},
- {"native_setPolyToPoly","(I[FI[FII)Z", (void*) SkMatrixGlue::setPolyToPoly},
- {"native_invert","(II)Z", (void*) SkMatrixGlue::invert},
- {"native_mapPoints","(I[FI[FIIZ)V", (void*) SkMatrixGlue::mapPoints},
- {"native_mapRect","(ILandroid/graphics/RectF;Landroid/graphics/RectF;)Z", (void*) SkMatrixGlue::mapRect__RectFRectF},
- {"native_mapRadius","(IF)F", (void*) SkMatrixGlue::mapRadius},
- {"native_getValues","(I[F)V", (void*) SkMatrixGlue::getValues},
- {"native_setValues","(I[F)V", (void*) SkMatrixGlue::setValues},
- {"native_equals", "(II)Z", (void*) SkMatrixGlue::equals}
+ {"finalizer", "(J)V", (void*) SkMatrixGlue::finalizer},
+ {"native_create","(J)J", (void*) SkMatrixGlue::create},
+ {"native_isIdentity","(J)Z", (void*) SkMatrixGlue::isIdentity},
+ {"native_rectStaysRect","(J)Z", (void*) SkMatrixGlue::rectStaysRect},
+ {"native_reset","(J)V", (void*) SkMatrixGlue::reset},
+ {"native_set","(JJ)V", (void*) SkMatrixGlue::set},
+ {"native_setTranslate","(JFF)V", (void*) SkMatrixGlue::setTranslate},
+ {"native_setScale","(JFFFF)V", (void*) SkMatrixGlue::setScale__FFFF},
+ {"native_setScale","(JFF)V", (void*) SkMatrixGlue::setScale__FF},
+ {"native_setRotate","(JFFF)V", (void*) SkMatrixGlue::setRotate__FFF},
+ {"native_setRotate","(JF)V", (void*) SkMatrixGlue::setRotate__F},
+ {"native_setSinCos","(JFFFF)V", (void*) SkMatrixGlue::setSinCos__FFFF},
+ {"native_setSinCos","(JFF)V", (void*) SkMatrixGlue::setSinCos__FF},
+ {"native_setSkew","(JFFFF)V", (void*) SkMatrixGlue::setSkew__FFFF},
+ {"native_setSkew","(JFF)V", (void*) SkMatrixGlue::setSkew__FF},
+ {"native_setConcat","(JJJ)Z", (void*) SkMatrixGlue::setConcat},
+ {"native_preTranslate","(JFF)Z", (void*) SkMatrixGlue::preTranslate},
+ {"native_preScale","(JFFFF)Z", (void*) SkMatrixGlue::preScale__FFFF},
+ {"native_preScale","(JFF)Z", (void*) SkMatrixGlue::preScale__FF},
+ {"native_preRotate","(JFFF)Z", (void*) SkMatrixGlue::preRotate__FFF},
+ {"native_preRotate","(JF)Z", (void*) SkMatrixGlue::preRotate__F},
+ {"native_preSkew","(JFFFF)Z", (void*) SkMatrixGlue::preSkew__FFFF},
+ {"native_preSkew","(JFF)Z", (void*) SkMatrixGlue::preSkew__FF},
+ {"native_preConcat","(JJ)Z", (void*) SkMatrixGlue::preConcat},
+ {"native_postTranslate","(JFF)Z", (void*) SkMatrixGlue::postTranslate},
+ {"native_postScale","(JFFFF)Z", (void*) SkMatrixGlue::postScale__FFFF},
+ {"native_postScale","(JFF)Z", (void*) SkMatrixGlue::postScale__FF},
+ {"native_postRotate","(JFFF)Z", (void*) SkMatrixGlue::postRotate__FFF},
+ {"native_postRotate","(JF)Z", (void*) SkMatrixGlue::postRotate__F},
+ {"native_postSkew","(JFFFF)Z", (void*) SkMatrixGlue::postSkew__FFFF},
+ {"native_postSkew","(JFF)Z", (void*) SkMatrixGlue::postSkew__FF},
+ {"native_postConcat","(JJ)Z", (void*) SkMatrixGlue::postConcat},
+ {"native_setRectToRect","(JLandroid/graphics/RectF;Landroid/graphics/RectF;I)Z", (void*) SkMatrixGlue::setRectToRect},
+ {"native_setPolyToPoly","(J[FI[FII)Z", (void*) SkMatrixGlue::setPolyToPoly},
+ {"native_invert","(JJ)Z", (void*) SkMatrixGlue::invert},
+ {"native_mapPoints","(J[FI[FIIZ)V", (void*) SkMatrixGlue::mapPoints},
+ {"native_mapRect","(JLandroid/graphics/RectF;Landroid/graphics/RectF;)Z", (void*) SkMatrixGlue::mapRect__RectFRectF},
+ {"native_mapRadius","(JF)F", (void*) SkMatrixGlue::mapRadius},
+ {"native_getValues","(J[F)V", (void*) SkMatrixGlue::getValues},
+ {"native_setValues","(J[F)V", (void*) SkMatrixGlue::setValues},
+ {"native_equals", "(JJ)Z", (void*) SkMatrixGlue::equals}
};
static jfieldID sNativeInstanceField;
@@ -409,13 +449,13 @@
sizeof(methods) / sizeof(methods[0]));
jclass clazz = env->FindClass("android/graphics/Matrix");
- sNativeInstanceField = env->GetFieldID(clazz, "native_instance", "I");
+ sNativeInstanceField = env->GetFieldID(clazz, "native_instance", "J");
return result;
}
SkMatrix* android_graphics_Matrix_getSkMatrix(JNIEnv* env, jobject matrixObj) {
- return reinterpret_cast<SkMatrix*>(env->GetIntField(matrixObj, sNativeInstanceField));
+ return reinterpret_cast<SkMatrix*>(env->GetLongField(matrixObj, sNativeInstanceField));
}
}
diff --git a/core/jni/android/graphics/Movie.cpp b/core/jni/android/graphics/Movie.cpp
index feb2dec..0040b6f 100644
--- a/core/jni/android/graphics/Movie.cpp
+++ b/core/jni/android/graphics/Movie.cpp
@@ -27,43 +27,43 @@
return NULL;
}
return env->NewObject(gMovie_class, gMovie_constructorMethodID,
- static_cast<jint>(reinterpret_cast<uintptr_t>(moov)));
+ static_cast<jlong>(reinterpret_cast<uintptr_t>(moov)));
}
static SkMovie* J2Movie(JNIEnv* env, jobject movie) {
SkASSERT(env);
SkASSERT(movie);
SkASSERT(env->IsInstanceOf(movie, gMovie_class));
- SkMovie* m = (SkMovie*)env->GetIntField(movie, gMovie_nativeInstanceID);
+ SkMovie* m = (SkMovie*)env->GetLongField(movie, gMovie_nativeInstanceID);
SkASSERT(m);
return m;
}
///////////////////////////////////////////////////////////////////////////////
-static int movie_width(JNIEnv* env, jobject movie) {
+static jint movie_width(JNIEnv* env, jobject movie) {
NPE_CHECK_RETURN_ZERO(env, movie);
- return J2Movie(env, movie)->width();
+ return static_cast<jint>(J2Movie(env, movie)->width());
}
-static int movie_height(JNIEnv* env, jobject movie) {
+static jint movie_height(JNIEnv* env, jobject movie) {
NPE_CHECK_RETURN_ZERO(env, movie);
- return J2Movie(env, movie)->height();
+ return static_cast<jint>(J2Movie(env, movie)->height());
}
static jboolean movie_isOpaque(JNIEnv* env, jobject movie) {
NPE_CHECK_RETURN_ZERO(env, movie);
- return J2Movie(env, movie)->isOpaque();
+ return J2Movie(env, movie)->isOpaque() ? JNI_TRUE : JNI_FALSE;
}
-static int movie_duration(JNIEnv* env, jobject movie) {
+static jint movie_duration(JNIEnv* env, jobject movie) {
NPE_CHECK_RETURN_ZERO(env, movie);
- return J2Movie(env, movie)->duration();
+ return static_cast<jint>(J2Movie(env, movie)->duration());
}
-static jboolean movie_setTime(JNIEnv* env, jobject movie, int ms) {
+static jboolean movie_setTime(JNIEnv* env, jobject movie, jint ms) {
NPE_CHECK_RETURN_ZERO(env, movie);
- return J2Movie(env, movie)->setTime(ms);
+ return J2Movie(env, movie)->setTime(ms) ? JNI_TRUE : JNI_FALSE;
}
static void movie_draw(JNIEnv* env, jobject movie, jobject canvas,
@@ -82,7 +82,7 @@
c->drawBitmap(b, sx, sy, p);
}
-static jobject movie_decodeAsset(JNIEnv* env, jobject clazz, jint native_asset) {
+static jobject movie_decodeAsset(JNIEnv* env, jobject clazz, jlong native_asset) {
android::Asset* asset = reinterpret_cast<android::Asset*>(native_asset);
if (asset == NULL) return NULL;
SkAutoTUnref<SkStreamRewindable> stream (new android::AssetStreamAdaptor(asset));
@@ -115,7 +115,7 @@
static jobject movie_decodeByteArray(JNIEnv* env, jobject clazz,
jbyteArray byteArray,
- int offset, int length) {
+ jint offset, jint length) {
NPE_CHECK_RETURN_ZERO(env, byteArray);
@@ -130,7 +130,8 @@
return create_jmovie(env, moov);
}
-static void movie_destructor(JNIEnv* env, jobject, SkMovie* movie) {
+static void movie_destructor(JNIEnv* env, jobject, jlong movieHandle) {
+ SkMovie* movie = (SkMovie*) movieHandle;
delete movie;
}
@@ -146,11 +147,11 @@
{ "setTime", "(I)Z", (void*)movie_setTime },
{ "draw", "(Landroid/graphics/Canvas;FFLandroid/graphics/Paint;)V",
(void*)movie_draw },
- { "nativeDecodeAsset", "(I)Landroid/graphics/Movie;",
+ { "nativeDecodeAsset", "(J)Landroid/graphics/Movie;",
(void*)movie_decodeAsset },
{ "nativeDecodeStream", "(Ljava/io/InputStream;)Landroid/graphics/Movie;",
(void*)movie_decodeStream },
- { "nativeDestructor","(I)V", (void*)movie_destructor },
+ { "nativeDestructor","(J)V", (void*)movie_destructor },
{ "decodeByteArray", "([BII)Landroid/graphics/Movie;",
(void*)movie_decodeByteArray },
};
@@ -165,10 +166,10 @@
RETURN_ERR_IF_NULL(gMovie_class);
gMovie_class = (jclass)env->NewGlobalRef(gMovie_class);
- gMovie_constructorMethodID = env->GetMethodID(gMovie_class, "<init>", "(I)V");
+ gMovie_constructorMethodID = env->GetMethodID(gMovie_class, "<init>", "(J)V");
RETURN_ERR_IF_NULL(gMovie_constructorMethodID);
- gMovie_nativeInstanceID = env->GetFieldID(gMovie_class, "mNativeMovie", "I");
+ gMovie_nativeInstanceID = env->GetFieldID(gMovie_class, "mNativeMovie", "J");
RETURN_ERR_IF_NULL(gMovie_nativeInstanceID);
return android::AndroidRuntime::registerNativeMethods(env, kClassPathName,
diff --git a/core/jni/android/graphics/NinePatch.cpp b/core/jni/android/graphics/NinePatch.cpp
index 7e6aeae..871e24d 100644
--- a/core/jni/android/graphics/NinePatch.cpp
+++ b/core/jni/android/graphics/NinePatch.cpp
@@ -46,22 +46,22 @@
public:
static jboolean isNinePatchChunk(JNIEnv* env, jobject, jbyteArray obj) {
if (NULL == obj) {
- return false;
+ return JNI_FALSE;
}
if (env->GetArrayLength(obj) < (int)sizeof(Res_png_9patch)) {
- return false;
+ return JNI_FALSE;
}
const jbyte* array = env->GetByteArrayElements(obj, 0);
if (array != NULL) {
const Res_png_9patch* chunk = reinterpret_cast<const Res_png_9patch*>(array);
int8_t wasDeserialized = chunk->wasDeserialized;
env->ReleaseByteArrayElements(obj, const_cast<jbyte*>(array), JNI_ABORT);
- return wasDeserialized != -1;
+ return (wasDeserialized != -1) ? JNI_TRUE : JNI_FALSE;
}
- return false;
+ return JNI_FALSE;
}
- static int8_t* validateNinePatchChunk(JNIEnv* env, jobject, jint, jbyteArray obj) {
+ static jlong validateNinePatchChunk(JNIEnv* env, jobject, jlong, jbyteArray obj) {
size_t chunkSize = env->GetArrayLength(obj);
if (chunkSize < (int) (sizeof(Res_png_9patch))) {
jniThrowRuntimeException(env, "Array too small for chunk.");
@@ -72,10 +72,11 @@
// This call copies the content of the jbyteArray
env->GetByteArrayRegion(obj, 0, chunkSize, reinterpret_cast<jbyte*>(storage));
// Deserialize in place, return the array we just allocated
- return (int8_t*) Res_png_9patch::deserialize(storage);
+ return reinterpret_cast<jlong>(Res_png_9patch::deserialize(storage));
}
- static void finalize(JNIEnv* env, jobject, int8_t* patch) {
+ static void finalize(JNIEnv* env, jobject, jlong patchHandle) {
+ int8_t* patch = reinterpret_cast<int8_t*>(patchHandle);
#ifdef USE_OPENGL_RENDERER
if (android::uirenderer::Caches::hasInstance()) {
Res_png_9patch* p = (Res_png_9patch*) patch;
@@ -115,9 +116,13 @@
}
}
- static void drawF(JNIEnv* env, jobject, SkCanvas* canvas, jobject boundsRectF,
- const SkBitmap* bitmap, Res_png_9patch* chunk, const SkPaint* paint,
+ static void drawF(JNIEnv* env, jobject, jlong canvasHandle, jobject boundsRectF,
+ jlong bitmapHandle, jlong chunkHandle, jlong paintHandle,
jint destDensity, jint srcDensity) {
+ SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle);
+ const SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
+ Res_png_9patch* chunk = reinterpret_cast<Res_png_9patch*>(chunkHandle);
+ const SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
SkASSERT(canvas);
SkASSERT(boundsRectF);
SkASSERT(bitmap);
@@ -130,9 +135,13 @@
draw(env, canvas, bounds, bitmap, chunk, paint, destDensity, srcDensity);
}
- static void drawI(JNIEnv* env, jobject, SkCanvas* canvas, jobject boundsRect,
- const SkBitmap* bitmap, Res_png_9patch* chunk, const SkPaint* paint,
+ static void drawI(JNIEnv* env, jobject, jlong canvasHandle, jobject boundsRect,
+ jlong bitmapHandle, jlong chunkHandle, jlong paintHandle,
jint destDensity, jint srcDensity) {
+ SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle);
+ const SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
+ Res_png_9patch* chunk = reinterpret_cast<Res_png_9patch*>(chunkHandle);
+ const SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
SkASSERT(canvas);
SkASSERT(boundsRect);
SkASSERT(bitmap);
@@ -144,8 +153,10 @@
draw(env, canvas, bounds, bitmap, chunk, paint, destDensity, srcDensity);
}
- static jint getTransparentRegion(JNIEnv* env, jobject, const SkBitmap* bitmap,
- Res_png_9patch* chunk, jobject boundsRect) {
+ static jlong getTransparentRegion(JNIEnv* env, jobject, jlong bitmapHandle,
+ jlong chunkHandle, jobject boundsRect) {
+ const SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
+ Res_png_9patch* chunk = reinterpret_cast<Res_png_9patch*>(chunkHandle);
SkASSERT(bitmap);
SkASSERT(chunk);
SkASSERT(boundsRect);
@@ -156,7 +167,7 @@
SkRegion* region = NULL;
NinePatch_Draw(NULL, bounds, *bitmap, *chunk, NULL, ®ion);
- return (jint) region;
+ return reinterpret_cast<jlong>(region);
}
};
@@ -167,11 +178,11 @@
static JNINativeMethod gNinePatchMethods[] = {
{ "isNinePatchChunk", "([B)Z", (void*) SkNinePatchGlue::isNinePatchChunk },
- { "validateNinePatchChunk", "(I[B)I", (void*) SkNinePatchGlue::validateNinePatchChunk },
- { "nativeFinalize", "(I)V", (void*) SkNinePatchGlue::finalize },
- { "nativeDraw", "(ILandroid/graphics/RectF;IIIII)V", (void*) SkNinePatchGlue::drawF },
- { "nativeDraw", "(ILandroid/graphics/Rect;IIIII)V", (void*) SkNinePatchGlue::drawI },
- { "nativeGetTransparentRegion", "(IILandroid/graphics/Rect;)I",
+ { "validateNinePatchChunk", "(J[B)J", (void*) SkNinePatchGlue::validateNinePatchChunk },
+ { "nativeFinalize", "(J)V", (void*) SkNinePatchGlue::finalize },
+ { "nativeDraw", "(JLandroid/graphics/RectF;JJJII)V", (void*) SkNinePatchGlue::drawF },
+ { "nativeDraw", "(JLandroid/graphics/Rect;JJJII)V", (void*) SkNinePatchGlue::drawI },
+ { "nativeGetTransparentRegion", "(JJLandroid/graphics/Rect;)J",
(void*) SkNinePatchGlue::getTransparentRegion }
};
diff --git a/core/jni/android/graphics/NinePatchImpl.cpp b/core/jni/android/graphics/NinePatchImpl.cpp
index 01e7e3e..86ff13c 100644
--- a/core/jni/android/graphics/NinePatchImpl.cpp
+++ b/core/jni/android/graphics/NinePatchImpl.cpp
@@ -115,13 +115,15 @@
defaultPaint.setDither(true);
paint = &defaultPaint;
}
-
+
+ const int32_t* xDivs = chunk.getXDivs();
+ const int32_t* yDivs = chunk.getYDivs();
// if our SkCanvas were back by GL we should enable this and draw this as
// a mesh, which will be faster in most cases.
if (false) {
SkNinePatch::DrawMesh(canvas, bounds, bitmap,
- chunk.xDivs, chunk.numXDivs,
- chunk.yDivs, chunk.numYDivs,
+ xDivs, chunk.numXDivs,
+ yDivs, chunk.numYDivs,
paint);
return;
}
@@ -145,8 +147,8 @@
if (gTrace) {
ALOGV("======== ninepatch bounds [%g %g]\n", SkScalarToFloat(bounds.width()), SkScalarToFloat(bounds.height()));
ALOGV("======== ninepatch paint bm [%d,%d]\n", bitmap.width(), bitmap.height());
- ALOGV("======== ninepatch xDivs [%d,%d]\n", chunk.xDivs[0], chunk.xDivs[1]);
- ALOGV("======== ninepatch yDivs [%d,%d]\n", chunk.yDivs[0], chunk.yDivs[1]);
+ ALOGV("======== ninepatch xDivs [%d,%d]\n", xDivs[0], xDivs[1]);
+ ALOGV("======== ninepatch yDivs [%d,%d]\n", yDivs[0], yDivs[1]);
}
#endif
@@ -171,8 +173,8 @@
SkRect dst;
SkIRect src;
- const int32_t x0 = chunk.xDivs[0];
- const int32_t y0 = chunk.yDivs[0];
+ const int32_t x0 = xDivs[0];
+ const int32_t y0 = yDivs[0];
const SkColor initColor = ((SkPaint*)paint)->getColor();
const uint8_t numXDivs = chunk.numXDivs;
const uint8_t numYDivs = chunk.numYDivs;
@@ -191,12 +193,12 @@
int numStretchyXPixelsRemaining = 0;
for (i = 0; i < numXDivs; i += 2) {
- numStretchyXPixelsRemaining += chunk.xDivs[i + 1] - chunk.xDivs[i];
+ numStretchyXPixelsRemaining += xDivs[i + 1] - xDivs[i];
}
int numFixedXPixelsRemaining = bitmapWidth - numStretchyXPixelsRemaining;
int numStretchyYPixelsRemaining = 0;
for (i = 0; i < numYDivs; i += 2) {
- numStretchyYPixelsRemaining += chunk.yDivs[i + 1] - chunk.yDivs[i];
+ numStretchyYPixelsRemaining += yDivs[i + 1] - yDivs[i];
}
int numFixedYPixelsRemaining = bitmapHeight - numStretchyYPixelsRemaining;
@@ -235,7 +237,7 @@
src.fBottom = bitmapHeight;
dst.fBottom = bounds.fBottom;
} else {
- src.fBottom = chunk.yDivs[j];
+ src.fBottom = yDivs[j];
const int srcYSize = src.fBottom - src.fTop;
if (yIsStretchable) {
dst.fBottom = dst.fTop + calculateStretch(bounds.fBottom, dst.fTop,
@@ -252,15 +254,16 @@
xIsStretchable = initialXIsStretchable;
// The initial xDiv and whether the first column is considered
// stretchable or not depends on whether xDiv[0] was zero or not.
+ const uint32_t* colors = chunk.getColors();
for (i = xIsStretchable ? 1 : 0;
i <= numXDivs && src.fLeft < bitmapWidth;
i++, xIsStretchable = !xIsStretchable) {
- color = chunk.colors[colorIndex++];
+ color = colors[colorIndex++];
if (i == numXDivs) {
src.fRight = bitmapWidth;
dst.fRight = bounds.fRight;
} else {
- src.fRight = chunk.xDivs[i];
+ src.fRight = xDivs[i];
if (dstRightsHaveBeenCached) {
dst.fRight = dstRights[i];
} else {
diff --git a/core/jni/android/graphics/NinePatchPeeker.cpp b/core/jni/android/graphics/NinePatchPeeker.cpp
index df996af..51392ab 100644
--- a/core/jni/android/graphics/NinePatchPeeker.cpp
+++ b/core/jni/android/graphics/NinePatchPeeker.cpp
@@ -28,11 +28,11 @@
// You have to copy the data because it is owned by the png reader
Res_png_9patch* patchNew = (Res_png_9patch*) malloc(patchSize);
memcpy(patchNew, patch, patchSize);
- // this relies on deserialization being done in place
Res_png_9patch::deserialize(patchNew);
patchNew->fileToDevice();
free(fPatch);
fPatch = patchNew;
+ fPatchSize = patchSize;
//printf("9patch: (%d,%d)-(%d,%d)\n",
// fPatch.sizeLeft, fPatch.sizeTop,
// fPatch.sizeRight, fPatch.sizeBottom);
diff --git a/core/jni/android/graphics/NinePatchPeeker.h b/core/jni/android/graphics/NinePatchPeeker.h
index 10d268a..2043862 100644
--- a/core/jni/android/graphics/NinePatchPeeker.h
+++ b/core/jni/android/graphics/NinePatchPeeker.h
@@ -29,6 +29,7 @@
// the host lives longer than we do, so a raw ptr is safe
fHost = host;
fPatch = NULL;
+ fPatchSize = 0;
fLayoutBounds = NULL;
}
@@ -38,6 +39,7 @@
}
Res_png_9patch* fPatch;
+ size_t fPatchSize;
int *fLayoutBounds;
virtual bool peek(const char tag[], const void* data, size_t length);
diff --git a/core/jni/android/graphics/Paint.cpp b/core/jni/android/graphics/Paint.cpp
index 40e0731..2523481 100644
--- a/core/jni/android/graphics/Paint.cpp
+++ b/core/jni/android/graphics/Paint.cpp
@@ -70,33 +70,40 @@
AFTER, AT_OR_AFTER, BEFORE, AT_OR_BEFORE, AT
};
- static void finalizer(JNIEnv* env, jobject clazz, SkPaint* obj) {
+ static void finalizer(JNIEnv* env, jobject clazz, jlong objHandle) {
+ SkPaint* obj = reinterpret_cast<SkPaint*>(objHandle);
delete obj;
}
- static SkPaint* init(JNIEnv* env, jobject clazz) {
+ static jlong init(JNIEnv* env, jobject clazz) {
SkPaint* obj = new SkPaint();
defaultSettingsForAndroid(obj);
- return obj;
+ return reinterpret_cast<jlong>(obj);
}
- static SkPaint* intiWithPaint(JNIEnv* env, jobject clazz, SkPaint* paint) {
+ static jlong initWithPaint(JNIEnv* env, jobject clazz, jlong paintHandle) {
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
SkPaint* obj = new SkPaint(*paint);
- return obj;
+ return reinterpret_cast<jlong>(obj);
}
- static void reset(JNIEnv* env, jobject clazz, SkPaint* obj) {
+ static void reset(JNIEnv* env, jobject clazz, jlong objHandle) {
+ SkPaint* obj = reinterpret_cast<SkPaint*>(objHandle);
obj->reset();
defaultSettingsForAndroid(obj);
}
- static void assign(JNIEnv* env, jobject clazz, SkPaint* dst, const SkPaint* src) {
+ static void assign(JNIEnv* env, jobject clazz, jlong dstPaintHandle, jlong srcPaintHandle) {
+ SkPaint* dst = reinterpret_cast<SkPaint*>(dstPaintHandle);
+ const SkPaint* src = reinterpret_cast<SkPaint*>(srcPaintHandle);
*dst = *src;
}
static jint getFlags(JNIEnv* env, jobject paint) {
NPE_CHECK_RETURN_ZERO(env, paint);
- return GraphicsJNI::getNativePaint(env, paint)->getFlags();
+ int result;
+ result = GraphicsJNI::getNativePaint(env, paint)->getFlags();
+ return static_cast<jint>(result);
}
static void setFlags(JNIEnv* env, jobject paint, jint flags) {
@@ -156,22 +163,29 @@
GraphicsJNI::getNativePaint(env, paint)->setDither(dither);
}
- static jint getStyle(JNIEnv* env, jobject clazz, SkPaint* obj) {
- return obj->getStyle();
+ static jint getStyle(JNIEnv* env, jobject clazz,jlong objHandle) {
+ SkPaint* obj = reinterpret_cast<SkPaint*>(objHandle);
+ return static_cast<jint>(obj->getStyle());
}
- static void setStyle(JNIEnv* env, jobject clazz, SkPaint* obj, SkPaint::Style style) {
+ static void setStyle(JNIEnv* env, jobject clazz, jlong objHandle, jint styleHandle) {
+ SkPaint* obj = reinterpret_cast<SkPaint*>(objHandle);
+ SkPaint::Style style = static_cast<SkPaint::Style>(styleHandle);
obj->setStyle(style);
}
static jint getColor(JNIEnv* env, jobject paint) {
NPE_CHECK_RETURN_ZERO(env, paint);
- return GraphicsJNI::getNativePaint(env, paint)->getColor();
+ int color;
+ color = GraphicsJNI::getNativePaint(env, paint)->getColor();
+ return static_cast<jint>(color);
}
static jint getAlpha(JNIEnv* env, jobject paint) {
NPE_CHECK_RETURN_ZERO(env, paint);
- return GraphicsJNI::getNativePaint(env, paint)->getAlpha();
+ int alpha;
+ alpha = GraphicsJNI::getNativePaint(env, paint)->getAlpha();
+ return static_cast<jint>(alpha);
}
static void setColor(JNIEnv* env, jobject paint, jint color) {
@@ -204,59 +218,85 @@
GraphicsJNI::getNativePaint(env, paint)->setStrokeMiter(SkFloatToScalar(miter));
}
- static jint getStrokeCap(JNIEnv* env, jobject clazz, SkPaint* obj) {
- return obj->getStrokeCap();
+ static jint getStrokeCap(JNIEnv* env, jobject clazz, jlong objHandle) {
+ SkPaint* obj = reinterpret_cast<SkPaint*>(objHandle);
+ return static_cast<jint>(obj->getStrokeCap());
}
- static void setStrokeCap(JNIEnv* env, jobject clazz, SkPaint* obj, SkPaint::Cap cap) {
+ static void setStrokeCap(JNIEnv* env, jobject clazz, jlong objHandle, jint capHandle) {
+ SkPaint* obj = reinterpret_cast<SkPaint*>(objHandle);
+ SkPaint::Cap cap = static_cast<SkPaint::Cap>(capHandle);
obj->setStrokeCap(cap);
}
- static jint getStrokeJoin(JNIEnv* env, jobject clazz, SkPaint* obj) {
- return obj->getStrokeJoin();
+ static jint getStrokeJoin(JNIEnv* env, jobject clazz, jlong objHandle) {
+ SkPaint* obj = reinterpret_cast<SkPaint*>(objHandle);
+ return static_cast<jint>(obj->getStrokeJoin());
}
- static void setStrokeJoin(JNIEnv* env, jobject clazz, SkPaint* obj, SkPaint::Join join) {
+ static void setStrokeJoin(JNIEnv* env, jobject clazz, jlong objHandle, jint joinHandle) {
+ SkPaint* obj = reinterpret_cast<SkPaint*>(objHandle);
+ SkPaint::Join join = (SkPaint::Join) joinHandle;
obj->setStrokeJoin(join);
}
- static jboolean getFillPath(JNIEnv* env, jobject clazz, SkPaint* obj, SkPath* src, SkPath* dst) {
- return obj->getFillPath(*src, dst);
+ static jboolean getFillPath(JNIEnv* env, jobject clazz, jlong objHandle, jlong srcHandle, jlong dstHandle) {
+ SkPaint* obj = reinterpret_cast<SkPaint*>(objHandle);
+ SkPath* src = reinterpret_cast<SkPath*>(srcHandle);
+ SkPath* dst = reinterpret_cast<SkPath*>(dstHandle);
+ return obj->getFillPath(*src, dst) ? JNI_TRUE : JNI_FALSE;
}
- static SkShader* setShader(JNIEnv* env, jobject clazz, SkPaint* obj, SkShader* shader) {
- return obj->setShader(shader);
+ static jlong setShader(JNIEnv* env, jobject clazz, jlong objHandle, jlong shaderHandle) {
+ SkPaint* obj = reinterpret_cast<SkPaint*>(objHandle);
+ SkShader* shader = reinterpret_cast<SkShader*>(shaderHandle);
+ return reinterpret_cast<jlong>(obj->setShader(shader));
}
- static SkColorFilter* setColorFilter(JNIEnv* env, jobject clazz, SkPaint* obj, SkColorFilter* filter) {
- return obj->setColorFilter(filter);
+ static jlong setColorFilter(JNIEnv* env, jobject clazz, jlong objHandle, jlong filterHandle) {
+ SkPaint* obj = reinterpret_cast<SkPaint *>(objHandle);
+ SkColorFilter* filter = reinterpret_cast<SkColorFilter *>(filterHandle);
+ return reinterpret_cast<jlong>(obj->setColorFilter(filter));
}
- static SkXfermode* setXfermode(JNIEnv* env, jobject clazz, SkPaint* obj, SkXfermode* xfermode) {
- return obj->setXfermode(xfermode);
+ static jlong setXfermode(JNIEnv* env, jobject clazz, jlong objHandle, jlong xfermodeHandle) {
+ SkPaint* obj = reinterpret_cast<SkPaint*>(objHandle);
+ SkXfermode* xfermode = reinterpret_cast<SkXfermode*>(xfermodeHandle);
+ return reinterpret_cast<jlong>(obj->setXfermode(xfermode));
}
- static SkPathEffect* setPathEffect(JNIEnv* env, jobject clazz, SkPaint* obj, SkPathEffect* effect) {
- return obj->setPathEffect(effect);
+ static jlong setPathEffect(JNIEnv* env, jobject clazz, jlong objHandle, jlong effectHandle) {
+ SkPaint* obj = reinterpret_cast<SkPaint*>(objHandle);
+ SkPathEffect* effect = reinterpret_cast<SkPathEffect*>(effectHandle);
+ return reinterpret_cast<jlong>(obj->setPathEffect(effect));
}
- static SkMaskFilter* setMaskFilter(JNIEnv* env, jobject clazz, SkPaint* obj, SkMaskFilter* maskfilter) {
- return obj->setMaskFilter(maskfilter);
+ static jlong setMaskFilter(JNIEnv* env, jobject clazz, jlong objHandle, jlong maskfilterHandle) {
+ SkPaint* obj = reinterpret_cast<SkPaint*>(objHandle);
+ SkMaskFilter* maskfilter = reinterpret_cast<SkMaskFilter*>(maskfilterHandle);
+ return reinterpret_cast<jlong>(obj->setMaskFilter(maskfilter));
}
- static SkTypeface* setTypeface(JNIEnv* env, jobject clazz, SkPaint* obj, SkTypeface* typeface) {
- return obj->setTypeface(typeface);
+ static jlong setTypeface(JNIEnv* env, jobject clazz, jlong objHandle, jlong typefaceHandle) {
+ SkPaint* obj = reinterpret_cast<SkPaint*>(objHandle);
+ SkTypeface* typeface = reinterpret_cast<SkTypeface*>(typefaceHandle);
+ return reinterpret_cast<jlong>(obj->setTypeface(typeface));
}
- static SkRasterizer* setRasterizer(JNIEnv* env, jobject clazz, SkPaint* obj, SkRasterizer* rasterizer) {
- return obj->setRasterizer(rasterizer);
+ static jlong setRasterizer(JNIEnv* env, jobject clazz, jlong objHandle, jlong rasterizerHandle) {
+ SkPaint* obj = reinterpret_cast<SkPaint*>(objHandle);
+ SkRasterizer* rasterizer = reinterpret_cast<SkRasterizer*>(rasterizerHandle);
+ return reinterpret_cast<jlong>(obj->setRasterizer(rasterizer));
}
- static jint getTextAlign(JNIEnv* env, jobject clazz, SkPaint* obj) {
- return obj->getTextAlign();
+ static jint getTextAlign(JNIEnv* env, jobject clazz, jlong objHandle) {
+ SkPaint* obj = reinterpret_cast<SkPaint*>(objHandle);
+ return static_cast<jint>(obj->getTextAlign());
}
- static void setTextAlign(JNIEnv* env, jobject clazz, SkPaint* obj, SkPaint::Align align) {
+ static void setTextAlign(JNIEnv* env, jobject clazz, jlong objHandle, jint alignHandle) {
+ SkPaint* obj = reinterpret_cast<SkPaint*>(objHandle);
+ SkPaint::Align align = static_cast<SkPaint::Align>(alignHandle);
obj->setTextAlign(align);
}
@@ -300,7 +340,8 @@
output[0] = '\0';
}
- static void setTextLocale(JNIEnv* env, jobject clazz, SkPaint* obj, jstring locale) {
+ static void setTextLocale(JNIEnv* env, jobject clazz, jlong objHandle, jstring locale) {
+ SkPaint* obj = reinterpret_cast<SkPaint*>(objHandle);
ScopedUtfChars localeChars(env, locale);
char langTag[ULOC_FULLNAME_CAPACITY];
toLanguageTag(langTag, ULOC_FULLNAME_CAPACITY, localeChars.c_str());
@@ -390,7 +431,7 @@
return descent - ascent + leading;
}
- static jfloat measureText_CIII(JNIEnv* env, jobject jpaint, jcharArray text, int index, int count,
+ static jfloat measureText_CIII(JNIEnv* env, jobject jpaint, jcharArray text, jint index, jint count,
jint bidiFlags) {
NPE_CHECK_RETURN_ZERO(env, jpaint);
NPE_CHECK_RETURN_ZERO(env, text);
@@ -415,7 +456,7 @@
return result;
}
- static jfloat measureText_StringIII(JNIEnv* env, jobject jpaint, jstring text, int start, int end,
+ static jfloat measureText_StringIII(JNIEnv* env, jobject jpaint, jstring text, jint start, jint end,
jint bidiFlags) {
NPE_CHECK_RETURN_ZERO(env, jpaint);
NPE_CHECK_RETURN_ZERO(env, text);
@@ -488,8 +529,9 @@
return count;
}
- static int getTextWidths___CIII_F(JNIEnv* env, jobject clazz, SkPaint* paint, jcharArray text,
- int index, int count, jint bidiFlags, jfloatArray widths) {
+ static jint getTextWidths___CIII_F(JNIEnv* env, jobject clazz, jlong paintHandle, jcharArray text,
+ jint index, jint count, jint bidiFlags, jfloatArray widths) {
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
const jchar* textArray = env->GetCharArrayElements(text, NULL);
count = dotextwidths(env, paint, textArray + index, count, widths, bidiFlags);
env->ReleaseCharArrayElements(text, const_cast<jchar*>(textArray),
@@ -497,8 +539,9 @@
return count;
}
- static int getTextWidths__StringIII_F(JNIEnv* env, jobject clazz, SkPaint* paint, jstring text,
- int start, int end, jint bidiFlags, jfloatArray widths) {
+ static jint getTextWidths__StringIII_F(JNIEnv* env, jobject clazz, jlong paintHandle, jstring text,
+ jint start, jint end, jint bidiFlags, jfloatArray widths) {
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
const jchar* textArray = env->GetStringChars(text, NULL);
int count = dotextwidths(env, paint, textArray + start, end - start, widths, bidiFlags);
env->ReleaseStringChars(text, textArray);
@@ -535,9 +578,10 @@
return glyphsCount;
}
- static int getTextGlyphs__StringIIIII_C(JNIEnv* env, jobject clazz, SkPaint* paint,
+ static jint getTextGlyphs__StringIIIII_C(JNIEnv* env, jobject clazz, jlong paintHandle,
jstring text, jint start, jint end, jint contextStart, jint contextEnd, jint flags,
jcharArray glyphs) {
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
const jchar* textArray = env->GetStringChars(text, NULL);
int count = doTextGlyphs(env, paint, textArray + contextStart, start - contextStart,
end - start, contextEnd - contextStart, flags, glyphs);
@@ -577,9 +621,10 @@
return totalAdvance;
}
- static float getTextRunAdvances___CIIIII_FI(JNIEnv* env, jobject clazz, SkPaint* paint,
+ static jfloat getTextRunAdvances___CIIIII_FI(JNIEnv* env, jobject clazz, jlong paintHandle,
jcharArray text, jint index, jint count, jint contextIndex, jint contextCount,
jint flags, jfloatArray advances, jint advancesIndex) {
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
jchar* textArray = env->GetCharArrayElements(text, NULL);
jfloat result = doTextRunAdvances(env, paint, textArray + contextIndex,
index - contextIndex, count, contextCount, flags, advances, advancesIndex);
@@ -587,9 +632,10 @@
return result;
}
- static float getTextRunAdvances__StringIIIII_FI(JNIEnv* env, jobject clazz, SkPaint* paint,
+ static jfloat getTextRunAdvances__StringIIIII_FI(JNIEnv* env, jobject clazz, jlong paintHandle,
jstring text, jint start, jint end, jint contextStart, jint contextEnd, jint flags,
jfloatArray advances, jint advancesIndex) {
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
const jchar* textArray = env->GetStringChars(text, NULL);
jfloat result = doTextRunAdvances(env, paint, textArray + contextStart,
start - contextStart, end - start, contextEnd - contextStart, flags,
@@ -642,8 +688,9 @@
return pos;
}
- static jint getTextRunCursor___C(JNIEnv* env, jobject clazz, SkPaint* paint, jcharArray text,
+ static jint getTextRunCursor___C(JNIEnv* env, jobject clazz, jlong paintHandle, jcharArray text,
jint contextStart, jint contextCount, jint flags, jint offset, jint cursorOpt) {
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
jchar* textArray = env->GetCharArrayElements(text, NULL);
jint result = doTextRunCursor(env, paint, textArray, contextStart, contextCount, flags,
offset, cursorOpt);
@@ -651,8 +698,9 @@
return result;
}
- static jint getTextRunCursor__String(JNIEnv* env, jobject clazz, SkPaint* paint, jstring text,
+ static jint getTextRunCursor__String(JNIEnv* env, jobject clazz, jlong paintHandle, jstring text,
jint contextStart, jint contextEnd, jint flags, jint offset, jint cursorOpt) {
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
const jchar* textArray = env->GetStringChars(text, NULL);
jint result = doTextRunCursor(env, paint, textArray, contextStart,
contextEnd - contextStart, flags, offset, cursorOpt);
@@ -665,22 +713,26 @@
TextLayout::getTextPath(paint, text, count, bidiFlags, x, y, path);
}
- static void getTextPath___C(JNIEnv* env, jobject clazz, SkPaint* paint, jint bidiFlags,
- jcharArray text, int index, int count, jfloat x, jfloat y, SkPath* path) {
+ static void getTextPath___C(JNIEnv* env, jobject clazz, jlong paintHandle, jint bidiFlags,
+ jcharArray text, jint index, jint count, jfloat x, jfloat y, jlong pathHandle) {
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
+ SkPath* path = reinterpret_cast<SkPath*>(pathHandle);
const jchar* textArray = env->GetCharArrayElements(text, NULL);
getTextPath(env, paint, textArray + index, count, bidiFlags, x, y, path);
env->ReleaseCharArrayElements(text, const_cast<jchar*>(textArray), JNI_ABORT);
}
- static void getTextPath__String(JNIEnv* env, jobject clazz, SkPaint* paint, jint bidiFlags,
- jstring text, int start, int end, jfloat x, jfloat y, SkPath* path) {
+ static void getTextPath__String(JNIEnv* env, jobject clazz, jlong paintHandle, jint bidiFlags,
+ jstring text, jint start, jint end, jfloat x, jfloat y, jlong pathHandle) {
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
+ SkPath* path = reinterpret_cast<SkPath*>(pathHandle);
const jchar* textArray = env->GetStringChars(text, NULL);
getTextPath(env, paint, textArray + start, end - start, bidiFlags, x, y, path);
env->ReleaseStringChars(text, textArray);
}
static void setShadowLayer(JNIEnv* env, jobject jpaint, jfloat radius,
- jfloat dx, jfloat dy, int color) {
+ jfloat dx, jfloat dy, jint color) {
NPE_CHECK_RETURN_VOID(env, jpaint);
SkPaint* paint = GraphicsJNI::getNativePaint(env, jpaint);
@@ -716,8 +768,8 @@
return bytes >> 1;
}
- static int breakTextC(JNIEnv* env, jobject jpaint, jcharArray jtext,
- int index, int count, float maxWidth, jint bidiFlags, jfloatArray jmeasuredWidth) {
+ static jint breakTextC(JNIEnv* env, jobject jpaint, jcharArray jtext,
+ jint index, jint count, jfloat maxWidth, jint bidiFlags, jfloatArray jmeasuredWidth) {
NPE_CHECK_RETURN_ZERO(env, jpaint);
NPE_CHECK_RETURN_ZERO(env, jtext);
@@ -744,8 +796,8 @@
return count;
}
- static int breakTextS(JNIEnv* env, jobject jpaint, jstring jtext,
- bool forwards, float maxWidth, jint bidiFlags, jfloatArray jmeasuredWidth) {
+ static jint breakTextS(JNIEnv* env, jobject jpaint, jstring jtext,
+ jboolean forwards, jfloat maxWidth, jint bidiFlags, jfloatArray jmeasuredWidth) {
NPE_CHECK_RETURN_ZERO(env, jpaint);
NPE_CHECK_RETURN_ZERO(env, jtext);
@@ -776,15 +828,17 @@
GraphicsJNI::irect_to_jrect(ir, env, bounds);
}
- static void getStringBounds(JNIEnv* env, jobject, const SkPaint* paint,
- jstring text, int start, int end, jint bidiFlags, jobject bounds) {
+ static void getStringBounds(JNIEnv* env, jobject, jlong paintHandle,
+ jstring text, jint start, jint end, jint bidiFlags, jobject bounds) {
+ const SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);;
const jchar* textArray = env->GetStringChars(text, NULL);
doTextBounds(env, textArray + start, end - start, bounds, *paint, bidiFlags);
env->ReleaseStringChars(text, textArray);
}
- static void getCharArrayBounds(JNIEnv* env, jobject, const SkPaint* paint,
- jcharArray text, int index, int count, jint bidiFlags, jobject bounds) {
+ static void getCharArrayBounds(JNIEnv* env, jobject, jlong paintHandle,
+ jcharArray text, jint index, jint count, jint bidiFlags, jobject bounds) {
+ const SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
const jchar* textArray = env->GetCharArrayElements(text, NULL);
doTextBounds(env, textArray + index, count, bounds, *paint, bidiFlags);
env->ReleaseCharArrayElements(text, const_cast<jchar*>(textArray),
@@ -794,11 +848,11 @@
};
static JNINativeMethod methods[] = {
- {"finalizer", "(I)V", (void*) SkPaintGlue::finalizer},
- {"native_init","()I", (void*) SkPaintGlue::init},
- {"native_initWithPaint","(I)I", (void*) SkPaintGlue::intiWithPaint},
- {"native_reset","(I)V", (void*) SkPaintGlue::reset},
- {"native_set","(II)V", (void*) SkPaintGlue::assign},
+ {"finalizer", "(J)V", (void*) SkPaintGlue::finalizer},
+ {"native_init","()J", (void*) SkPaintGlue::init},
+ {"native_initWithPaint","(J)J", (void*) SkPaintGlue::initWithPaint},
+ {"native_reset","(J)V", (void*) SkPaintGlue::reset},
+ {"native_set","(JJ)V", (void*) SkPaintGlue::assign},
{"getFlags","()I", (void*) SkPaintGlue::getFlags},
{"setFlags","(I)V", (void*) SkPaintGlue::setFlags},
{"getHinting","()I", (void*) SkPaintGlue::getHinting},
@@ -811,8 +865,8 @@
{"setFakeBoldText","(Z)V", (void*) SkPaintGlue::setFakeBoldText},
{"setFilterBitmap","(Z)V", (void*) SkPaintGlue::setFilterBitmap},
{"setDither","(Z)V", (void*) SkPaintGlue::setDither},
- {"native_getStyle","(I)I", (void*) SkPaintGlue::getStyle},
- {"native_setStyle","(II)V", (void*) SkPaintGlue::setStyle},
+ {"native_getStyle","(J)I", (void*) SkPaintGlue::getStyle},
+ {"native_setStyle","(JI)V", (void*) SkPaintGlue::setStyle},
{"getColor","()I", (void*) SkPaintGlue::getColor},
{"setColor","(I)V", (void*) SkPaintGlue::setColor},
{"getAlpha","()I", (void*) SkPaintGlue::getAlpha},
@@ -821,21 +875,21 @@
{"setStrokeWidth","(F)V", (void*) SkPaintGlue::setStrokeWidth},
{"getStrokeMiter","()F", (void*) SkPaintGlue::getStrokeMiter},
{"setStrokeMiter","(F)V", (void*) SkPaintGlue::setStrokeMiter},
- {"native_getStrokeCap","(I)I", (void*) SkPaintGlue::getStrokeCap},
- {"native_setStrokeCap","(II)V", (void*) SkPaintGlue::setStrokeCap},
- {"native_getStrokeJoin","(I)I", (void*) SkPaintGlue::getStrokeJoin},
- {"native_setStrokeJoin","(II)V", (void*) SkPaintGlue::setStrokeJoin},
- {"native_getFillPath","(III)Z", (void*) SkPaintGlue::getFillPath},
- {"native_setShader","(II)I", (void*) SkPaintGlue::setShader},
- {"native_setColorFilter","(II)I", (void*) SkPaintGlue::setColorFilter},
- {"native_setXfermode","(II)I", (void*) SkPaintGlue::setXfermode},
- {"native_setPathEffect","(II)I", (void*) SkPaintGlue::setPathEffect},
- {"native_setMaskFilter","(II)I", (void*) SkPaintGlue::setMaskFilter},
- {"native_setTypeface","(II)I", (void*) SkPaintGlue::setTypeface},
- {"native_setRasterizer","(II)I", (void*) SkPaintGlue::setRasterizer},
- {"native_getTextAlign","(I)I", (void*) SkPaintGlue::getTextAlign},
- {"native_setTextAlign","(II)V", (void*) SkPaintGlue::setTextAlign},
- {"native_setTextLocale","(ILjava/lang/String;)V", (void*) SkPaintGlue::setTextLocale},
+ {"native_getStrokeCap","(J)I", (void*) SkPaintGlue::getStrokeCap},
+ {"native_setStrokeCap","(JI)V", (void*) SkPaintGlue::setStrokeCap},
+ {"native_getStrokeJoin","(J)I", (void*) SkPaintGlue::getStrokeJoin},
+ {"native_setStrokeJoin","(JI)V", (void*) SkPaintGlue::setStrokeJoin},
+ {"native_getFillPath","(JJJ)Z", (void*) SkPaintGlue::getFillPath},
+ {"native_setShader","(JJ)J", (void*) SkPaintGlue::setShader},
+ {"native_setColorFilter","(JJ)J", (void*) SkPaintGlue::setColorFilter},
+ {"native_setXfermode","(JJ)J", (void*) SkPaintGlue::setXfermode},
+ {"native_setPathEffect","(JJ)J", (void*) SkPaintGlue::setPathEffect},
+ {"native_setMaskFilter","(JJ)J", (void*) SkPaintGlue::setMaskFilter},
+ {"native_setTypeface","(JJ)J", (void*) SkPaintGlue::setTypeface},
+ {"native_setRasterizer","(JJ)J", (void*) SkPaintGlue::setRasterizer},
+ {"native_getTextAlign","(J)I", (void*) SkPaintGlue::getTextAlign},
+ {"native_setTextAlign","(JI)V", (void*) SkPaintGlue::setTextAlign},
+ {"native_setTextLocale","(JLjava/lang/String;)V", (void*) SkPaintGlue::setTextLocale},
{"getTextSize","()F", (void*) SkPaintGlue::getTextSize},
{"setTextSize","(F)V", (void*) SkPaintGlue::setTextSize},
{"getTextScaleX","()F", (void*) SkPaintGlue::getTextScaleX},
@@ -851,24 +905,24 @@
{"native_measureText","(Ljava/lang/String;III)F", (void*) SkPaintGlue::measureText_StringIII},
{"native_breakText","([CIIFI[F)I", (void*) SkPaintGlue::breakTextC},
{"native_breakText","(Ljava/lang/String;ZFI[F)I", (void*) SkPaintGlue::breakTextS},
- {"native_getTextWidths","(I[CIII[F)I", (void*) SkPaintGlue::getTextWidths___CIII_F},
- {"native_getTextWidths","(ILjava/lang/String;III[F)I", (void*) SkPaintGlue::getTextWidths__StringIII_F},
- {"native_getTextRunAdvances","(I[CIIIII[FI)F",
+ {"native_getTextWidths","(J[CIII[F)I", (void*) SkPaintGlue::getTextWidths___CIII_F},
+ {"native_getTextWidths","(JLjava/lang/String;III[F)I", (void*) SkPaintGlue::getTextWidths__StringIII_F},
+ {"native_getTextRunAdvances","(J[CIIIII[FI)F",
(void*) SkPaintGlue::getTextRunAdvances___CIIIII_FI},
- {"native_getTextRunAdvances","(ILjava/lang/String;IIIII[FI)F",
+ {"native_getTextRunAdvances","(JLjava/lang/String;IIIII[FI)F",
(void*) SkPaintGlue::getTextRunAdvances__StringIIIII_FI},
- {"native_getTextGlyphs","(ILjava/lang/String;IIIII[C)I",
+ {"native_getTextGlyphs","(JLjava/lang/String;IIIII[C)I",
(void*) SkPaintGlue::getTextGlyphs__StringIIIII_C},
- {"native_getTextRunCursor", "(I[CIIIII)I", (void*) SkPaintGlue::getTextRunCursor___C},
- {"native_getTextRunCursor", "(ILjava/lang/String;IIIII)I",
+ {"native_getTextRunCursor", "(J[CIIIII)I", (void*) SkPaintGlue::getTextRunCursor___C},
+ {"native_getTextRunCursor", "(JLjava/lang/String;IIIII)I",
(void*) SkPaintGlue::getTextRunCursor__String},
- {"native_getTextPath","(II[CIIFFI)V", (void*) SkPaintGlue::getTextPath___C},
- {"native_getTextPath","(IILjava/lang/String;IIFFI)V", (void*) SkPaintGlue::getTextPath__String},
- {"nativeGetStringBounds", "(ILjava/lang/String;IIILandroid/graphics/Rect;)V",
+ {"native_getTextPath","(JI[CIIFFJ)V", (void*) SkPaintGlue::getTextPath___C},
+ {"native_getTextPath","(JILjava/lang/String;IIFFJ)V", (void*) SkPaintGlue::getTextPath__String},
+ {"nativeGetStringBounds", "(JLjava/lang/String;IIILandroid/graphics/Rect;)V",
(void*) SkPaintGlue::getStringBounds },
- {"nativeGetCharArrayBounds", "(I[CIIILandroid/graphics/Rect;)V",
+ {"nativeGetCharArrayBounds", "(J[CIIILandroid/graphics/Rect;)V",
(void*) SkPaintGlue::getCharArrayBounds },
{"nSetShadowLayer", "(FFFI)V", (void*)SkPaintGlue::setShadowLayer}
};
diff --git a/core/jni/android/graphics/Path.cpp b/core/jni/android/graphics/Path.cpp
index ab7f1dc..54b6996 100644
--- a/core/jni/android/graphics/Path.cpp
+++ b/core/jni/android/graphics/Path.cpp
@@ -34,7 +34,8 @@
class SkPathGlue {
public:
- static void finalizer(JNIEnv* env, jobject clazz, SkPath* obj) {
+ static void finalizer(JNIEnv* env, jobject clazz, jlong objHandle) {
+ SkPath* obj = reinterpret_cast<SkPath*>(objHandle);
#ifdef USE_OPENGL_RENDERER
if (android::uirenderer::Caches::hasInstance()) {
android::uirenderer::Caches::getInstance().resourceCache.destructor(obj);
@@ -44,79 +45,96 @@
delete obj;
}
- static SkPath* init1(JNIEnv* env, jobject clazz) {
- return new SkPath();
+ static jlong init1(JNIEnv* env, jobject clazz) {
+ return reinterpret_cast<jlong>(new SkPath());
}
-
- static SkPath* init2(JNIEnv* env, jobject clazz, SkPath* val) {
- return new SkPath(*val);
+
+ static jlong init2(JNIEnv* env, jobject clazz, jlong valHandle) {
+ SkPath* val = reinterpret_cast<SkPath*>(valHandle);
+ return reinterpret_cast<jlong>(new SkPath(*val));
}
-
- static void reset(JNIEnv* env, jobject clazz, SkPath* obj) {
+
+ static void reset(JNIEnv* env, jobject clazz, jlong objHandle) {
+ SkPath* obj = reinterpret_cast<SkPath*>(objHandle);
obj->reset();
}
- static void rewind(JNIEnv* env, jobject clazz, SkPath* obj) {
+ static void rewind(JNIEnv* env, jobject clazz, jlong objHandle) {
+ SkPath* obj = reinterpret_cast<SkPath*>(objHandle);
obj->rewind();
}
- static void assign(JNIEnv* env, jobject clazz, SkPath* dst, const SkPath* src) {
+ static void assign(JNIEnv* env, jobject clazz, jlong dstHandle, jlong srcHandle) {
+ SkPath* dst = reinterpret_cast<SkPath*>(dstHandle);
+ const SkPath* src = reinterpret_cast<SkPath*>(srcHandle);
*dst = *src;
}
-
- static jint getFillType(JNIEnv* env, jobject clazz, SkPath* obj) {
+
+ static jint getFillType(JNIEnv* env, jobject clazz, jlong objHandle) {
+ SkPath* obj = reinterpret_cast<SkPath*>(objHandle);
return obj->getFillType();
}
- static void setFillType(JNIEnv* env, jobject clazz, SkPath* path, SkPath::FillType ft) {
+ static void setFillType(JNIEnv* env, jobject clazz, jlong pathHandle, jint ftHandle) {
+ SkPath* path = reinterpret_cast<SkPath*>(pathHandle);
+ SkPath::FillType ft = static_cast<SkPath::FillType>(ftHandle);
path->setFillType(ft);
}
-
- static jboolean isEmpty(JNIEnv* env, jobject clazz, SkPath* obj) {
+
+ static jboolean isEmpty(JNIEnv* env, jobject clazz, jlong objHandle) {
+ SkPath* obj = reinterpret_cast<SkPath*>(objHandle);
return obj->isEmpty();
}
- static jboolean isRect(JNIEnv* env, jobject clazz, SkPath* obj, jobject rect) {
+ static jboolean isRect(JNIEnv* env, jobject clazz, jlong objHandle, jobject rect) {
SkRect rect_;
+ SkPath* obj = reinterpret_cast<SkPath*>(objHandle);
jboolean result = obj->isRect(&rect_);
GraphicsJNI::rect_to_jrectf(rect_, env, rect);
return result;
}
- static void computeBounds(JNIEnv* env, jobject clazz, SkPath* obj, jobject bounds) {
+ static void computeBounds(JNIEnv* env, jobject clazz, jlong objHandle, jobject bounds) {
+ SkPath* obj = reinterpret_cast<SkPath*>(objHandle);
const SkRect& bounds_ = obj->getBounds();
GraphicsJNI::rect_to_jrectf(bounds_, env, bounds);
}
- static void incReserve(JNIEnv* env, jobject clazz, SkPath* obj, jint extraPtCount) {
+ static void incReserve(JNIEnv* env, jobject clazz, jlong objHandle, jint extraPtCount) {
+ SkPath* obj = reinterpret_cast<SkPath*>(objHandle);
obj->incReserve(extraPtCount);
}
- static void moveTo__FF(JNIEnv* env, jobject clazz, SkPath* obj, jfloat x, jfloat y) {
+ static void moveTo__FF(JNIEnv* env, jobject clazz, jlong objHandle, jfloat x, jfloat y) {
+ SkPath* obj = reinterpret_cast<SkPath*>(objHandle);
SkScalar x_ = SkFloatToScalar(x);
SkScalar y_ = SkFloatToScalar(y);
obj->moveTo(x_, y_);
}
- static void rMoveTo(JNIEnv* env, jobject clazz, SkPath* obj, jfloat dx, jfloat dy) {
+ static void rMoveTo(JNIEnv* env, jobject clazz, jlong objHandle, jfloat dx, jfloat dy) {
+ SkPath* obj = reinterpret_cast<SkPath*>(objHandle);
SkScalar dx_ = SkFloatToScalar(dx);
SkScalar dy_ = SkFloatToScalar(dy);
obj->rMoveTo(dx_, dy_);
}
- static void lineTo__FF(JNIEnv* env, jobject clazz, SkPath* obj, jfloat x, jfloat y) {
+ static void lineTo__FF(JNIEnv* env, jobject clazz, jlong objHandle, jfloat x, jfloat y) {
+ SkPath* obj = reinterpret_cast<SkPath*>(objHandle);
SkScalar x_ = SkFloatToScalar(x);
SkScalar y_ = SkFloatToScalar(y);
obj->lineTo(x_, y_);
}
- static void rLineTo(JNIEnv* env, jobject clazz, SkPath* obj, jfloat dx, jfloat dy) {
+ static void rLineTo(JNIEnv* env, jobject clazz, jlong objHandle, jfloat dx, jfloat dy) {
+ SkPath* obj = reinterpret_cast<SkPath*>(objHandle);
SkScalar dx_ = SkFloatToScalar(dx);
SkScalar dy_ = SkFloatToScalar(dy);
obj->rLineTo(dx_, dy_);
}
- static void quadTo__FFFF(JNIEnv* env, jobject clazz, SkPath* obj, jfloat x1, jfloat y1, jfloat x2, jfloat y2) {
+ static void quadTo__FFFF(JNIEnv* env, jobject clazz, jlong objHandle, jfloat x1, jfloat y1, jfloat x2, jfloat y2) {
+ SkPath* obj = reinterpret_cast<SkPath*>(objHandle);
SkScalar x1_ = SkFloatToScalar(x1);
SkScalar y1_ = SkFloatToScalar(y1);
SkScalar x2_ = SkFloatToScalar(x2);
@@ -124,7 +142,8 @@
obj->quadTo(x1_, y1_, x2_, y2_);
}
- static void rQuadTo(JNIEnv* env, jobject clazz, SkPath* obj, jfloat dx1, jfloat dy1, jfloat dx2, jfloat dy2) {
+ static void rQuadTo(JNIEnv* env, jobject clazz, jlong objHandle, jfloat dx1, jfloat dy1, jfloat dx2, jfloat dy2) {
+ SkPath* obj = reinterpret_cast<SkPath*>(objHandle);
SkScalar dx1_ = SkFloatToScalar(dx1);
SkScalar dy1_ = SkFloatToScalar(dy1);
SkScalar dx2_ = SkFloatToScalar(dx2);
@@ -132,7 +151,8 @@
obj->rQuadTo(dx1_, dy1_, dx2_, dy2_);
}
- static void cubicTo__FFFFFF(JNIEnv* env, jobject clazz, SkPath* obj, jfloat x1, jfloat y1, jfloat x2, jfloat y2, jfloat x3, jfloat y3) {
+ static void cubicTo__FFFFFF(JNIEnv* env, jobject clazz, jlong objHandle, jfloat x1, jfloat y1, jfloat x2, jfloat y2, jfloat x3, jfloat y3) {
+ SkPath* obj = reinterpret_cast<SkPath*>(objHandle);
SkScalar x1_ = SkFloatToScalar(x1);
SkScalar y1_ = SkFloatToScalar(y1);
SkScalar x2_ = SkFloatToScalar(x2);
@@ -142,7 +162,8 @@
obj->cubicTo(x1_, y1_, x2_, y2_, x3_, y3_);
}
- static void rCubicTo(JNIEnv* env, jobject clazz, SkPath* obj, jfloat x1, jfloat y1, jfloat x2, jfloat y2, jfloat x3, jfloat y3) {
+ static void rCubicTo(JNIEnv* env, jobject clazz, jlong objHandle, jfloat x1, jfloat y1, jfloat x2, jfloat y2, jfloat x3, jfloat y3) {
+ SkPath* obj = reinterpret_cast<SkPath*>(objHandle);
SkScalar x1_ = SkFloatToScalar(x1);
SkScalar y1_ = SkFloatToScalar(y1);
SkScalar x2_ = SkFloatToScalar(x2);
@@ -152,7 +173,8 @@
obj->rCubicTo(x1_, y1_, x2_, y2_, x3_, y3_);
}
- static void arcTo(JNIEnv* env, jobject clazz, SkPath* obj, jobject oval, jfloat startAngle, jfloat sweepAngle, jboolean forceMoveTo) {
+ static void arcTo(JNIEnv* env, jobject clazz, jlong objHandle, jobject oval, jfloat startAngle, jfloat sweepAngle, jboolean forceMoveTo) {
+ SkPath* obj = reinterpret_cast<SkPath*>(objHandle);
SkRect oval_;
GraphicsJNI::jrectf_to_rect(env, oval, &oval_);
SkScalar startAngle_ = SkFloatToScalar(startAngle);
@@ -160,17 +182,22 @@
obj->arcTo(oval_, startAngle_, sweepAngle_, forceMoveTo);
}
- static void close(JNIEnv* env, jobject clazz, SkPath* obj) {
+ static void close(JNIEnv* env, jobject clazz, jlong objHandle) {
+ SkPath* obj = reinterpret_cast<SkPath*>(objHandle);
obj->close();
}
- static void addRect__RectFI(JNIEnv* env, jobject clazz, SkPath* obj, jobject rect, SkPath::Direction dir) {
+ static void addRect__RectFI(JNIEnv* env, jobject clazz, jlong objHandle, jobject rect, jint dirHandle) {
SkRect rect_;
+ SkPath* obj = reinterpret_cast<SkPath*>(objHandle);
+ SkPath::Direction dir = static_cast<SkPath::Direction>(dirHandle);
GraphicsJNI::jrectf_to_rect(env, rect, &rect_);
obj->addRect(rect_, dir);
}
- static void addRect__FFFFI(JNIEnv* env, jobject clazz, SkPath* obj, jfloat left, jfloat top, jfloat right, jfloat bottom, SkPath::Direction dir) {
+ static void addRect__FFFFI(JNIEnv* env, jobject clazz, jlong objHandle, jfloat left, jfloat top, jfloat right, jfloat bottom, jint dirHandle) {
+ SkPath* obj = reinterpret_cast<SkPath*>(objHandle);
+ SkPath::Direction dir = static_cast<SkPath::Direction>(dirHandle);
SkScalar left_ = SkFloatToScalar(left);
SkScalar top_ = SkFloatToScalar(top);
SkScalar right_ = SkFloatToScalar(right);
@@ -178,39 +205,48 @@
obj->addRect(left_, top_, right_, bottom_, dir);
}
- static void addOval(JNIEnv* env, jobject clazz, SkPath* obj, jobject oval, SkPath::Direction dir) {
+ static void addOval(JNIEnv* env, jobject clazz, jlong objHandle, jobject oval, jint dirHandle) {
+ SkPath* obj = reinterpret_cast<SkPath*>(objHandle);
+ SkPath::Direction dir = static_cast<SkPath::Direction>(dirHandle);
SkRect oval_;
GraphicsJNI::jrectf_to_rect(env, oval, &oval_);
obj->addOval(oval_, dir);
}
- static void addCircle(JNIEnv* env, jobject clazz, SkPath* obj, jfloat x, jfloat y, jfloat radius, SkPath::Direction dir) {
+ static void addCircle(JNIEnv* env, jobject clazz, jlong objHandle, jfloat x, jfloat y, jfloat radius, jint dirHandle) {
+ SkPath* obj = reinterpret_cast<SkPath*>(objHandle);
+ SkPath::Direction dir = static_cast<SkPath::Direction>(dirHandle);
SkScalar x_ = SkFloatToScalar(x);
SkScalar y_ = SkFloatToScalar(y);
SkScalar radius_ = SkFloatToScalar(radius);
obj->addCircle(x_, y_, radius_, dir);
}
- static void addArc(JNIEnv* env, jobject clazz, SkPath* obj, jobject oval, jfloat startAngle, jfloat sweepAngle) {
+ static void addArc(JNIEnv* env, jobject clazz, jlong objHandle, jobject oval, jfloat startAngle, jfloat sweepAngle) {
SkRect oval_;
+ SkPath* obj = reinterpret_cast<SkPath*>(objHandle);
GraphicsJNI::jrectf_to_rect(env, oval, &oval_);
SkScalar startAngle_ = SkFloatToScalar(startAngle);
SkScalar sweepAngle_ = SkFloatToScalar(sweepAngle);
obj->addArc(oval_, startAngle_, sweepAngle_);
}
- static void addRoundRectXY(JNIEnv* env, jobject clazz, SkPath* obj, jobject rect,
- jfloat rx, jfloat ry, SkPath::Direction dir) {
+ static void addRoundRectXY(JNIEnv* env, jobject clazz, jlong objHandle, jobject rect,
+ jfloat rx, jfloat ry, jint dirHandle) {
SkRect rect_;
+ SkPath* obj = reinterpret_cast<SkPath*>(objHandle);
+ SkPath::Direction dir = static_cast<SkPath::Direction>(dirHandle);
GraphicsJNI::jrectf_to_rect(env, rect, &rect_);
SkScalar rx_ = SkFloatToScalar(rx);
SkScalar ry_ = SkFloatToScalar(ry);
obj->addRoundRect(rect_, rx_, ry_, dir);
}
- static void addRoundRect8(JNIEnv* env, jobject, SkPath* obj, jobject rect,
- jfloatArray array, SkPath::Direction dir) {
+ static void addRoundRect8(JNIEnv* env, jobject, jlong objHandle, jobject rect,
+ jfloatArray array, jint dirHandle) {
SkRect rect_;
+ SkPath* obj = reinterpret_cast<SkPath*>(objHandle);
+ SkPath::Direction dir = static_cast<SkPath::Direction>(dirHandle);
GraphicsJNI::jrectf_to_rect(env, rect, &rect_);
AutoJavaFloatArray afa(env, array, 8);
const float* src = afa.ptr();
@@ -222,90 +258,110 @@
obj->addRoundRect(rect_, dst, dir);
}
- static void addPath__PathFF(JNIEnv* env, jobject clazz, SkPath* obj, SkPath* src, jfloat dx, jfloat dy) {
+ static void addPath__PathFF(JNIEnv* env, jobject clazz, jlong objHandle, jlong srcHandle, jfloat dx, jfloat dy) {
+ SkPath* obj = reinterpret_cast<SkPath*>(objHandle);
+ SkPath* src = reinterpret_cast<SkPath*>(srcHandle);
SkScalar dx_ = SkFloatToScalar(dx);
SkScalar dy_ = SkFloatToScalar(dy);
obj->addPath(*src, dx_, dy_);
}
- static void addPath__Path(JNIEnv* env, jobject clazz, SkPath* obj, SkPath* src) {
+ static void addPath__Path(JNIEnv* env, jobject clazz, jlong objHandle, jlong srcHandle) {
+ SkPath* obj = reinterpret_cast<SkPath*>(objHandle);
+ SkPath* src = reinterpret_cast<SkPath*>(srcHandle);
obj->addPath(*src);
}
- static void addPath__PathMatrix(JNIEnv* env, jobject clazz, SkPath* obj, SkPath* src, SkMatrix* matrix) {
+ static void addPath__PathMatrix(JNIEnv* env, jobject clazz, jlong objHandle, jlong srcHandle, jlong matrixHandle) {
+ SkPath* obj = reinterpret_cast<SkPath*>(objHandle);
+ SkPath* src = reinterpret_cast<SkPath*>(srcHandle);
+ SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle);
obj->addPath(*src, *matrix);
}
- static void offset__FFPath(JNIEnv* env, jobject clazz, SkPath* obj, jfloat dx, jfloat dy, SkPath* dst) {
+ static void offset__FFPath(JNIEnv* env, jobject clazz, jlong objHandle, jfloat dx, jfloat dy, jlong dstHandle) {
+ SkPath* obj = reinterpret_cast<SkPath*>(objHandle);
+ SkPath* dst = reinterpret_cast<SkPath*>(dstHandle);
SkScalar dx_ = SkFloatToScalar(dx);
SkScalar dy_ = SkFloatToScalar(dy);
obj->offset(dx_, dy_, dst);
}
- static void offset__FF(JNIEnv* env, jobject clazz, SkPath* obj, jfloat dx, jfloat dy) {
+ static void offset__FF(JNIEnv* env, jobject clazz, jlong objHandle, jfloat dx, jfloat dy) {
+ SkPath* obj = reinterpret_cast<SkPath*>(objHandle);
SkScalar dx_ = SkFloatToScalar(dx);
SkScalar dy_ = SkFloatToScalar(dy);
obj->offset(dx_, dy_);
}
- static void setLastPoint(JNIEnv* env, jobject clazz, SkPath* obj, jfloat dx, jfloat dy) {
+ static void setLastPoint(JNIEnv* env, jobject clazz, jlong objHandle, jfloat dx, jfloat dy) {
+ SkPath* obj = reinterpret_cast<SkPath*>(objHandle);
SkScalar dx_ = SkFloatToScalar(dx);
SkScalar dy_ = SkFloatToScalar(dy);
obj->setLastPt(dx_, dy_);
}
- static void transform__MatrixPath(JNIEnv* env, jobject clazz, SkPath* obj, SkMatrix* matrix, SkPath* dst) {
+ static void transform__MatrixPath(JNIEnv* env, jobject clazz, jlong objHandle, jlong matrixHandle, jlong dstHandle) {
+ SkPath* obj = reinterpret_cast<SkPath*>(objHandle);
+ SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle);
+ SkPath* dst = reinterpret_cast<SkPath*>(dstHandle);
obj->transform(*matrix, dst);
}
- static void transform__Matrix(JNIEnv* env, jobject clazz, SkPath* obj, SkMatrix* matrix) {
+ static void transform__Matrix(JNIEnv* env, jobject clazz, jlong objHandle, jlong matrixHandle) {
+ SkPath* obj = reinterpret_cast<SkPath*>(objHandle);
+ SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle);
obj->transform(*matrix);
}
- static jboolean op(JNIEnv* env, jobject clazz, SkPath* p1, SkPath* p2, SkPathOp op, SkPath* r) {
- return Op(*p1, *p2, op, r);
+ static jboolean op(JNIEnv* env, jobject clazz, jlong p1Handle, jlong p2Handle, jint opHandle, jlong rHandle) {
+ SkPath* p1 = reinterpret_cast<SkPath*>(p1Handle);
+ SkPath* p2 = reinterpret_cast<SkPath*>(p2Handle);
+ SkPathOp op = static_cast<SkPathOp>(opHandle);
+ SkPath* r = reinterpret_cast<SkPath*>(rHandle);
+ return Op(*p1, *p2, op, r);
}
};
static JNINativeMethod methods[] = {
- {"finalizer", "(I)V", (void*) SkPathGlue::finalizer},
- {"init1","()I", (void*) SkPathGlue::init1},
- {"init2","(I)I", (void*) SkPathGlue::init2},
- {"native_reset","(I)V", (void*) SkPathGlue::reset},
- {"native_rewind","(I)V", (void*) SkPathGlue::rewind},
- {"native_set","(II)V", (void*) SkPathGlue::assign},
- {"native_getFillType","(I)I", (void*) SkPathGlue::getFillType},
- {"native_setFillType","(II)V", (void*) SkPathGlue::setFillType},
- {"native_isEmpty","(I)Z", (void*) SkPathGlue::isEmpty},
- {"native_isRect","(ILandroid/graphics/RectF;)Z", (void*) SkPathGlue::isRect},
- {"native_computeBounds","(ILandroid/graphics/RectF;)V", (void*) SkPathGlue::computeBounds},
- {"native_incReserve","(II)V", (void*) SkPathGlue::incReserve},
- {"native_moveTo","(IFF)V", (void*) SkPathGlue::moveTo__FF},
- {"native_rMoveTo","(IFF)V", (void*) SkPathGlue::rMoveTo},
- {"native_lineTo","(IFF)V", (void*) SkPathGlue::lineTo__FF},
- {"native_rLineTo","(IFF)V", (void*) SkPathGlue::rLineTo},
- {"native_quadTo","(IFFFF)V", (void*) SkPathGlue::quadTo__FFFF},
- {"native_rQuadTo","(IFFFF)V", (void*) SkPathGlue::rQuadTo},
- {"native_cubicTo","(IFFFFFF)V", (void*) SkPathGlue::cubicTo__FFFFFF},
- {"native_rCubicTo","(IFFFFFF)V", (void*) SkPathGlue::rCubicTo},
- {"native_arcTo","(ILandroid/graphics/RectF;FFZ)V", (void*) SkPathGlue::arcTo},
- {"native_close","(I)V", (void*) SkPathGlue::close},
- {"native_addRect","(ILandroid/graphics/RectF;I)V", (void*) SkPathGlue::addRect__RectFI},
- {"native_addRect","(IFFFFI)V", (void*) SkPathGlue::addRect__FFFFI},
- {"native_addOval","(ILandroid/graphics/RectF;I)V", (void*) SkPathGlue::addOval},
- {"native_addCircle","(IFFFI)V", (void*) SkPathGlue::addCircle},
- {"native_addArc","(ILandroid/graphics/RectF;FF)V", (void*) SkPathGlue::addArc},
- {"native_addRoundRect","(ILandroid/graphics/RectF;FFI)V", (void*) SkPathGlue::addRoundRectXY},
- {"native_addRoundRect","(ILandroid/graphics/RectF;[FI)V", (void*) SkPathGlue::addRoundRect8},
- {"native_addPath","(IIFF)V", (void*) SkPathGlue::addPath__PathFF},
- {"native_addPath","(II)V", (void*) SkPathGlue::addPath__Path},
- {"native_addPath","(III)V", (void*) SkPathGlue::addPath__PathMatrix},
- {"native_offset","(IFFI)V", (void*) SkPathGlue::offset__FFPath},
- {"native_offset","(IFF)V", (void*) SkPathGlue::offset__FF},
- {"native_setLastPoint","(IFF)V", (void*) SkPathGlue::setLastPoint},
- {"native_transform","(III)V", (void*) SkPathGlue::transform__MatrixPath},
- {"native_transform","(II)V", (void*) SkPathGlue::transform__Matrix},
- {"native_op","(IIII)Z", (void*) SkPathGlue::op}
+ {"finalizer", "(J)V", (void*) SkPathGlue::finalizer},
+ {"init1","()J", (void*) SkPathGlue::init1},
+ {"init2","(J)J", (void*) SkPathGlue::init2},
+ {"native_reset","(J)V", (void*) SkPathGlue::reset},
+ {"native_rewind","(J)V", (void*) SkPathGlue::rewind},
+ {"native_set","(JJ)V", (void*) SkPathGlue::assign},
+ {"native_getFillType","(J)I", (void*) SkPathGlue::getFillType},
+ {"native_setFillType","(JI)V", (void*) SkPathGlue::setFillType},
+ {"native_isEmpty","(J)Z", (void*) SkPathGlue::isEmpty},
+ {"native_isRect","(JLandroid/graphics/RectF;)Z", (void*) SkPathGlue::isRect},
+ {"native_computeBounds","(JLandroid/graphics/RectF;)V", (void*) SkPathGlue::computeBounds},
+ {"native_incReserve","(JI)V", (void*) SkPathGlue::incReserve},
+ {"native_moveTo","(JFF)V", (void*) SkPathGlue::moveTo__FF},
+ {"native_rMoveTo","(JFF)V", (void*) SkPathGlue::rMoveTo},
+ {"native_lineTo","(JFF)V", (void*) SkPathGlue::lineTo__FF},
+ {"native_rLineTo","(JFF)V", (void*) SkPathGlue::rLineTo},
+ {"native_quadTo","(JFFFF)V", (void*) SkPathGlue::quadTo__FFFF},
+ {"native_rQuadTo","(JFFFF)V", (void*) SkPathGlue::rQuadTo},
+ {"native_cubicTo","(JFFFFFF)V", (void*) SkPathGlue::cubicTo__FFFFFF},
+ {"native_rCubicTo","(JFFFFFF)V", (void*) SkPathGlue::rCubicTo},
+ {"native_arcTo","(JLandroid/graphics/RectF;FFZ)V", (void*) SkPathGlue::arcTo},
+ {"native_close","(J)V", (void*) SkPathGlue::close},
+ {"native_addRect","(JLandroid/graphics/RectF;I)V", (void*) SkPathGlue::addRect__RectFI},
+ {"native_addRect","(JFFFFI)V", (void*) SkPathGlue::addRect__FFFFI},
+ {"native_addOval","(JLandroid/graphics/RectF;I)V", (void*) SkPathGlue::addOval},
+ {"native_addCircle","(JFFFI)V", (void*) SkPathGlue::addCircle},
+ {"native_addArc","(JLandroid/graphics/RectF;FF)V", (void*) SkPathGlue::addArc},
+ {"native_addRoundRect","(JLandroid/graphics/RectF;FFI)V", (void*) SkPathGlue::addRoundRectXY},
+ {"native_addRoundRect","(JLandroid/graphics/RectF;[FI)V", (void*) SkPathGlue::addRoundRect8},
+ {"native_addPath","(JJFF)V", (void*) SkPathGlue::addPath__PathFF},
+ {"native_addPath","(JJ)V", (void*) SkPathGlue::addPath__Path},
+ {"native_addPath","(JJJ)V", (void*) SkPathGlue::addPath__PathMatrix},
+ {"native_offset","(JFFJ)V", (void*) SkPathGlue::offset__FFPath},
+ {"native_offset","(JFF)V", (void*) SkPathGlue::offset__FF},
+ {"native_setLastPoint","(JFF)V", (void*) SkPathGlue::setLastPoint},
+ {"native_transform","(JJJ)V", (void*) SkPathGlue::transform__MatrixPath},
+ {"native_transform","(JJ)V", (void*) SkPathGlue::transform__Matrix},
+ {"native_op","(JJIJ)Z", (void*) SkPathGlue::op}
};
int register_android_graphics_Path(JNIEnv* env) {
diff --git a/core/jni/android/graphics/PathEffect.cpp b/core/jni/android/graphics/PathEffect.cpp
index 0503614..2803758 100644
--- a/core/jni/android/graphics/PathEffect.cpp
+++ b/core/jni/android/graphics/PathEffect.cpp
@@ -11,22 +11,29 @@
class SkPathEffectGlue {
public:
- static void destructor(JNIEnv* env, jobject, SkPathEffect* effect) {
+ static void destructor(JNIEnv* env, jobject, jlong effectHandle) {
+ SkPathEffect* effect = reinterpret_cast<SkPathEffect*>(effectHandle);
SkSafeUnref(effect);
}
- static SkPathEffect* Compose_constructor(JNIEnv* env, jobject,
- SkPathEffect* outer, SkPathEffect* inner) {
- return new SkComposePathEffect(outer, inner);
+ static jlong Compose_constructor(JNIEnv* env, jobject,
+ jlong outerHandle, jlong innerHandle) {
+ SkPathEffect* outer = reinterpret_cast<SkPathEffect*>(outerHandle);
+ SkPathEffect* inner = reinterpret_cast<SkPathEffect*>(innerHandle);
+ SkPathEffect* effect = new SkComposePathEffect(outer, inner);
+ return reinterpret_cast<jlong>(effect);
}
- static SkPathEffect* Sum_constructor(JNIEnv* env, jobject,
- SkPathEffect* first, SkPathEffect* second) {
- return new SkSumPathEffect(first, second);
+ static jlong Sum_constructor(JNIEnv* env, jobject,
+ jlong firstHandle, jlong secondHandle) {
+ SkPathEffect* first = reinterpret_cast<SkPathEffect*>(firstHandle);
+ SkPathEffect* second = reinterpret_cast<SkPathEffect*>(secondHandle);
+ SkPathEffect* effect = new SkSumPathEffect(first, second);
+ return reinterpret_cast<jlong>(effect);
}
- static SkPathEffect* Dash_constructor(JNIEnv* env, jobject,
- jfloatArray intervalArray, float phase) {
+ static jlong Dash_constructor(JNIEnv* env, jobject,
+ jfloatArray intervalArray, jfloat phase) {
AutoJavaFloatArray autoInterval(env, intervalArray);
int count = autoInterval.length() & ~1; // even number
float* values = autoInterval.ptr();
@@ -36,24 +43,29 @@
for (int i = 0; i < count; i++) {
intervals[i] = SkFloatToScalar(values[i]);
}
- return new SkDashPathEffect(intervals, count, SkFloatToScalar(phase));
+ SkPathEffect* effect = new SkDashPathEffect(intervals, count, SkFloatToScalar(phase));
+ return reinterpret_cast<jlong>(effect);
}
- static SkPathEffect* OneD_constructor(JNIEnv* env, jobject,
- const SkPath* shape, float advance, float phase, int style) {
+ static jlong OneD_constructor(JNIEnv* env, jobject,
+ jlong shapeHandle, jfloat advance, jfloat phase, jint style) {
+ const SkPath* shape = reinterpret_cast<SkPath*>(shapeHandle);
SkASSERT(shape != NULL);
- return new SkPath1DPathEffect(*shape, SkFloatToScalar(advance),
+ SkPathEffect* effect = new SkPath1DPathEffect(*shape, SkFloatToScalar(advance),
SkFloatToScalar(phase), (SkPath1DPathEffect::Style)style);
+ return reinterpret_cast<jlong>(effect);
}
- static SkPathEffect* Corner_constructor(JNIEnv* env, jobject, float radius){
- return new SkCornerPathEffect(SkFloatToScalar(radius));
+ static jlong Corner_constructor(JNIEnv* env, jobject, jfloat radius){
+ SkPathEffect* effect = new SkCornerPathEffect(SkFloatToScalar(radius));
+ return reinterpret_cast<jlong>(effect);
}
- static SkPathEffect* Discrete_constructor(JNIEnv* env, jobject,
- float length, float deviation) {
- return new SkDiscretePathEffect(SkFloatToScalar(length),
+ static jlong Discrete_constructor(JNIEnv* env, jobject,
+ jfloat length, jfloat deviation) {
+ SkPathEffect* effect = new SkDiscretePathEffect(SkFloatToScalar(length),
SkFloatToScalar(deviation));
+ return reinterpret_cast<jlong>(effect);
}
};
@@ -61,31 +73,31 @@
////////////////////////////////////////////////////////////////////////////////////////////////////////
static JNINativeMethod gPathEffectMethods[] = {
- { "nativeDestructor", "(I)V", (void*)SkPathEffectGlue::destructor }
+ { "nativeDestructor", "(J)V", (void*)SkPathEffectGlue::destructor }
};
static JNINativeMethod gComposePathEffectMethods[] = {
- { "nativeCreate", "(II)I", (void*)SkPathEffectGlue::Compose_constructor }
+ { "nativeCreate", "(JJ)J", (void*)SkPathEffectGlue::Compose_constructor }
};
static JNINativeMethod gSumPathEffectMethods[] = {
- { "nativeCreate", "(II)I", (void*)SkPathEffectGlue::Sum_constructor }
+ { "nativeCreate", "(JJ)J", (void*)SkPathEffectGlue::Sum_constructor }
};
static JNINativeMethod gDashPathEffectMethods[] = {
- { "nativeCreate", "([FF)I", (void*)SkPathEffectGlue::Dash_constructor }
+ { "nativeCreate", "([FF)J", (void*)SkPathEffectGlue::Dash_constructor }
};
static JNINativeMethod gPathDashPathEffectMethods[] = {
- { "nativeCreate", "(IFFI)I", (void*)SkPathEffectGlue::OneD_constructor }
+ { "nativeCreate", "(JFFI)J", (void*)SkPathEffectGlue::OneD_constructor }
};
static JNINativeMethod gCornerPathEffectMethods[] = {
- { "nativeCreate", "(F)I", (void*)SkPathEffectGlue::Corner_constructor }
+ { "nativeCreate", "(F)J", (void*)SkPathEffectGlue::Corner_constructor }
};
static JNINativeMethod gDiscretePathEffectMethods[] = {
- { "nativeCreate", "(FF)I", (void*)SkPathEffectGlue::Discrete_constructor }
+ { "nativeCreate", "(FF)J", (void*)SkPathEffectGlue::Discrete_constructor }
};
#include <android_runtime/AndroidRuntime.h>
diff --git a/core/jni/android/graphics/PathMeasure.cpp b/core/jni/android/graphics/PathMeasure.cpp
index 51a3f3a..8478a02 100644
--- a/core/jni/android/graphics/PathMeasure.cpp
+++ b/core/jni/android/graphics/PathMeasure.cpp
@@ -52,11 +52,24 @@
class SkPathMeasureGlue {
public:
- static PathMeasurePair* create(JNIEnv* env, jobject clazz, const SkPath* path, jboolean forceClosed) {
- return path ? new PathMeasurePair(*path, forceClosed) : new PathMeasurePair;
+ static jlong create(JNIEnv* env, jobject clazz, jlong pathHandle,
+ jboolean forceClosedHandle) {
+ const SkPath* path = reinterpret_cast<SkPath*>(pathHandle);
+ bool forceClosed = (forceClosedHandle == JNI_TRUE);
+ PathMeasurePair* pair;
+ if(path)
+ pair = new PathMeasurePair(*path, forceClosed);
+ else
+ pair = new PathMeasurePair;
+ return reinterpret_cast<jlong>(pair);
}
-
- static void setPath(JNIEnv* env, jobject clazz, PathMeasurePair* pair, const SkPath* path, jboolean forceClosed) {
+
+ static void setPath(JNIEnv* env, jobject clazz, jlong pairHandle,
+ jlong pathHandle, jboolean forceClosedHandle) {
+ PathMeasurePair* pair = reinterpret_cast<PathMeasurePair*>(pairHandle);
+ const SkPath* path = reinterpret_cast<SkPath*>(pathHandle);
+ bool forceClosed = (forceClosedHandle == JNI_TRUE);
+
if (NULL == path) {
pair->fPath.reset();
} else {
@@ -64,11 +77,12 @@
}
pair->fMeasure.setPath(&pair->fPath, forceClosed);
}
-
- static jfloat getLength(JNIEnv* env, jobject clazz, PathMeasurePair* pair) {
- return SkScalarToFloat(pair->fMeasure.getLength());
+
+ static jfloat getLength(JNIEnv* env, jobject clazz, jlong pairHandle) {
+ PathMeasurePair* pair = reinterpret_cast<PathMeasurePair*>(pairHandle);
+ return static_cast<jfloat>(SkScalarToFloat(pair->fMeasure.getLength()));
}
-
+
static void convertTwoElemFloatArray(JNIEnv* env, jfloatArray array, const SkScalar src[2]) {
AutoJavaFloatArray autoArray(env, array, 2);
jfloat* ptr = autoArray.ptr();
@@ -76,13 +90,14 @@
ptr[1] = SkScalarToFloat(src[1]);
}
- static jboolean getPosTan(JNIEnv* env, jobject clazz, PathMeasurePair* pair, jfloat dist, jfloatArray pos, jfloatArray tan) {
+ static jboolean getPosTan(JNIEnv* env, jobject clazz, jlong pairHandle, jfloat dist, jfloatArray pos, jfloatArray tan) {
+ PathMeasurePair* pair = reinterpret_cast<PathMeasurePair*>(pairHandle);
SkScalar tmpPos[2], tmpTan[2];
SkScalar* posPtr = pos ? tmpPos : NULL;
SkScalar* tanPtr = tan ? tmpTan : NULL;
if (!pair->fMeasure.getPosTan(SkFloatToScalar(dist), (SkPoint*)posPtr, (SkVector*)tanPtr)) {
- return false;
+ return JNI_FALSE;
}
if (pos) {
@@ -91,42 +106,53 @@
if (tan) {
convertTwoElemFloatArray(env, tan, tmpTan);
}
- return true;
+ return JNI_TRUE;
}
-
- static jboolean getMatrix(JNIEnv* env, jobject clazz, PathMeasurePair* pair, jfloat dist,
- SkMatrix* matrix, int flags) {
- return pair->fMeasure.getMatrix(SkFloatToScalar(dist), matrix, (SkPathMeasure::MatrixFlags)flags);
+
+ static jboolean getMatrix(JNIEnv* env, jobject clazz, jlong pairHandle, jfloat dist,
+ jlong matrixHandle, jint flags) {
+ PathMeasurePair* pair = reinterpret_cast<PathMeasurePair*>(pairHandle);
+ SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle);
+ bool result = pair->fMeasure.getMatrix(SkFloatToScalar(dist), matrix, (SkPathMeasure::MatrixFlags)flags);
+ return result ? JNI_TRUE : JNI_FALSE;
}
-
- static jboolean getSegment(JNIEnv* env, jobject clazz, PathMeasurePair* pair, jfloat startF,
- jfloat stopF, SkPath* dst, jboolean startWithMoveTo) {
- return pair->fMeasure.getSegment(SkFloatToScalar(startF), SkFloatToScalar(stopF), dst, startWithMoveTo);
+
+ static jboolean getSegment(JNIEnv* env, jobject clazz, jlong pairHandle, jfloat startF,
+ jfloat stopF, jlong dstHandle, jboolean startWithMoveTo) {
+ PathMeasurePair* pair = reinterpret_cast<PathMeasurePair*>(pairHandle);
+ SkPath* dst = reinterpret_cast<SkPath*>(dstHandle);
+ bool result = pair->fMeasure.getSegment(SkFloatToScalar(startF), SkFloatToScalar(stopF), dst, startWithMoveTo);
+ return result ? JNI_TRUE : JNI_FALSE;
}
-
- static jboolean isClosed(JNIEnv* env, jobject clazz, PathMeasurePair* pair) {
- return pair->fMeasure.isClosed();
+
+ static jboolean isClosed(JNIEnv* env, jobject clazz, jlong pairHandle) {
+ PathMeasurePair* pair = reinterpret_cast<PathMeasurePair*>(pairHandle);
+ bool result = pair->fMeasure.isClosed();
+ return result ? JNI_TRUE : JNI_FALSE;
}
-
- static jboolean nextContour(JNIEnv* env, jobject clazz, PathMeasurePair* pair) {
- return pair->fMeasure.nextContour();
+
+ static jboolean nextContour(JNIEnv* env, jobject clazz, jlong pairHandle) {
+ PathMeasurePair* pair = reinterpret_cast<PathMeasurePair*>(pairHandle);
+ bool result = pair->fMeasure.nextContour();
+ return result ? JNI_TRUE : JNI_FALSE;
}
-
- static void destroy(JNIEnv* env, jobject clazz, PathMeasurePair* pair) {
+
+ static void destroy(JNIEnv* env, jobject clazz, jlong pairHandle) {
+ PathMeasurePair* pair = reinterpret_cast<PathMeasurePair*>(pairHandle);
delete pair;
}
};
static JNINativeMethod methods[] = {
- {"native_create", "(IZ)I", (void*) SkPathMeasureGlue::create },
- {"native_setPath", "(IIZ)V", (void*) SkPathMeasureGlue::setPath },
- {"native_getLength", "(I)F", (void*) SkPathMeasureGlue::getLength },
- {"native_getPosTan", "(IF[F[F)Z", (void*) SkPathMeasureGlue::getPosTan },
- {"native_getMatrix", "(IFII)Z", (void*) SkPathMeasureGlue::getMatrix },
- {"native_getSegment", "(IFFIZ)Z", (void*) SkPathMeasureGlue::getSegment },
- {"native_isClosed", "(I)Z", (void*) SkPathMeasureGlue::isClosed },
- {"native_nextContour", "(I)Z", (void*) SkPathMeasureGlue::nextContour },
- {"native_destroy", "(I)V", (void*) SkPathMeasureGlue::destroy }
+ {"native_create", "(JZ)J", (void*) SkPathMeasureGlue::create },
+ {"native_setPath", "(JJZ)V", (void*) SkPathMeasureGlue::setPath },
+ {"native_getLength", "(J)F", (void*) SkPathMeasureGlue::getLength },
+ {"native_getPosTan", "(JF[F[F)Z", (void*) SkPathMeasureGlue::getPosTan },
+ {"native_getMatrix", "(JFJI)Z", (void*) SkPathMeasureGlue::getMatrix },
+ {"native_getSegment", "(JFFJZ)Z", (void*) SkPathMeasureGlue::getSegment },
+ {"native_isClosed", "(J)Z", (void*) SkPathMeasureGlue::isClosed },
+ {"native_nextContour", "(J)Z", (void*) SkPathMeasureGlue::nextContour },
+ {"native_destroy", "(J)V", (void*) SkPathMeasureGlue::destroy }
};
int register_android_graphics_PathMeasure(JNIEnv* env) {
diff --git a/core/jni/android/graphics/Picture.cpp b/core/jni/android/graphics/Picture.cpp
index fcf22b8..bac8ef7 100644
--- a/core/jni/android/graphics/Picture.cpp
+++ b/core/jni/android/graphics/Picture.cpp
@@ -28,71 +28,80 @@
class SkPictureGlue {
public:
- static SkPicture* newPicture(JNIEnv* env, jobject, const SkPicture* src) {
+ static jlong newPicture(JNIEnv* env, jobject, jlong srcHandle) {
+ const SkPicture* src = reinterpret_cast<SkPicture*>(srcHandle);
if (src) {
- return new SkPicture(*src);
+ return reinterpret_cast<jlong>(new SkPicture(*src));
} else {
- return new SkPicture;
+ return reinterpret_cast<jlong>(new SkPicture);
}
}
-
- static SkPicture* deserialize(JNIEnv* env, jobject, jobject jstream,
- jbyteArray jstorage) {
+
+ static jlong deserialize(JNIEnv* env, jobject, jobject jstream,
+ jbyteArray jstorage) {
SkPicture* picture = NULL;
SkStream* strm = CreateJavaInputStreamAdaptor(env, jstream, jstorage);
if (strm) {
picture = SkPicture::CreateFromStream(strm);
delete strm;
}
- return picture;
+ return reinterpret_cast<jlong>(picture);
}
-
- static void killPicture(JNIEnv* env, jobject, SkPicture* picture) {
+
+ static void killPicture(JNIEnv* env, jobject, jlong pictureHandle) {
+ SkPicture* picture = reinterpret_cast<SkPicture*>(pictureHandle);
SkASSERT(picture);
picture->unref();
}
-
- static void draw(JNIEnv* env, jobject, SkCanvas* canvas,
- SkPicture* picture) {
+
+ static void draw(JNIEnv* env, jobject, jlong canvasHandle,
+ jlong pictureHandle) {
+ SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle);
+ SkPicture* picture = reinterpret_cast<SkPicture*>(pictureHandle);
SkASSERT(canvas);
SkASSERT(picture);
picture->draw(canvas);
}
-
- static bool serialize(JNIEnv* env, jobject, SkPicture* picture,
+
+ static jboolean serialize(JNIEnv* env, jobject, jlong pictureHandle,
jobject jstream, jbyteArray jstorage) {
+ SkPicture* picture = reinterpret_cast<SkPicture*>(pictureHandle);
SkWStream* strm = CreateJavaOutputStreamAdaptor(env, jstream, jstorage);
if (NULL != strm) {
picture->serialize(strm);
delete strm;
- return true;
+ return JNI_TRUE;
}
- return false;
+ return JNI_FALSE;
}
-
- static int getWidth(JNIEnv* env, jobject jpic) {
+
+ static jint getWidth(JNIEnv* env, jobject jpic) {
NPE_CHECK_RETURN_ZERO(env, jpic);
- return GraphicsJNI::getNativePicture(env, jpic)->width();
+ int width = GraphicsJNI::getNativePicture(env, jpic)->width();
+ return static_cast<jint>(width);
}
-
- static int getHeight(JNIEnv* env, jobject jpic) {
+
+ static jint getHeight(JNIEnv* env, jobject jpic) {
NPE_CHECK_RETURN_ZERO(env, jpic);
- return GraphicsJNI::getNativePicture(env, jpic)->height();
+ int height = GraphicsJNI::getNativePicture(env, jpic)->height();
+ return static_cast<jint>(height);
}
-
- static SkCanvas* beginRecording(JNIEnv* env, jobject, SkPicture* pict,
- int w, int h) {
+
+ static jlong beginRecording(JNIEnv* env, jobject, jlong pictHandle,
+ jint w, jint h) {
+ SkPicture* pict = reinterpret_cast<SkPicture*>(pictHandle);
// beginRecording does not ref its return value, it just returns it.
SkCanvas* canvas = pict->beginRecording(w, h);
// the java side will wrap this guy in a Canvas.java, which will call
// unref in its finalizer, so we have to ref it here, so that both that
// Canvas.java and our picture can both be owners
canvas->ref();
- return canvas;
+ return reinterpret_cast<jlong>(canvas);
}
-
- static void endRecording(JNIEnv* env, jobject, SkPicture* pict) {
+
+ static void endRecording(JNIEnv* env, jobject, jlong pictHandle) {
+ SkPicture* pict = reinterpret_cast<SkPicture*>(pictHandle);
pict->endRecording();
}
};
@@ -100,30 +109,30 @@
static JNINativeMethod gPictureMethods[] = {
{"getWidth", "()I", (void*) SkPictureGlue::getWidth},
{"getHeight", "()I", (void*) SkPictureGlue::getHeight},
- {"nativeConstructor", "(I)I", (void*) SkPictureGlue::newPicture},
- {"nativeCreateFromStream", "(Ljava/io/InputStream;[B)I", (void*)SkPictureGlue::deserialize},
- {"nativeBeginRecording", "(III)I", (void*) SkPictureGlue::beginRecording},
- {"nativeEndRecording", "(I)V", (void*) SkPictureGlue::endRecording},
- {"nativeDraw", "(II)V", (void*) SkPictureGlue::draw},
- {"nativeWriteToStream", "(ILjava/io/OutputStream;[B)Z", (void*)SkPictureGlue::serialize},
- {"nativeDestructor","(I)V", (void*) SkPictureGlue::killPicture}
+ {"nativeConstructor", "(J)J", (void*) SkPictureGlue::newPicture},
+ {"nativeCreateFromStream", "(Ljava/io/InputStream;[B)J", (void*)SkPictureGlue::deserialize},
+ {"nativeBeginRecording", "(JII)J", (void*) SkPictureGlue::beginRecording},
+ {"nativeEndRecording", "(J)V", (void*) SkPictureGlue::endRecording},
+ {"nativeDraw", "(JJ)V", (void*) SkPictureGlue::draw},
+ {"nativeWriteToStream", "(JLjava/io/OutputStream;[B)Z", (void*)SkPictureGlue::serialize},
+ {"nativeDestructor","(J)V", (void*) SkPictureGlue::killPicture}
};
#include <android_runtime/AndroidRuntime.h>
-
+
#define REG(env, name, array) \
result = android::AndroidRuntime::registerNativeMethods(env, name, array, \
SK_ARRAY_COUNT(array)); \
if (result < 0) return result
-
+
int register_android_graphics_Picture(JNIEnv* env) {
int result;
-
+
REG(env, "android/graphics/Picture", gPictureMethods);
-
+
return result;
}
-
+
}
diff --git a/core/jni/android/graphics/PorterDuff.cpp b/core/jni/android/graphics/PorterDuff.cpp
index 47de601..8a49eb5 100644
--- a/core/jni/android/graphics/PorterDuff.cpp
+++ b/core/jni/android/graphics/PorterDuff.cpp
@@ -31,15 +31,15 @@
class SkPorterDuffGlue {
public:
- static SkXfermode* CreateXfermode(JNIEnv* env, jobject,
- SkPorterDuff::Mode mode) {
- return SkPorterDuff::CreateXfermode(mode);
+ static jlong CreateXfermode(JNIEnv* env, jobject, jint modeHandle) {
+ SkPorterDuff::Mode mode = static_cast<SkPorterDuff::Mode>(modeHandle);
+ return reinterpret_cast<jlong>(SkPorterDuff::CreateXfermode(mode));
}
};
static JNINativeMethod methods[] = {
- {"nativeCreateXfermode","(I)I", (void*) SkPorterDuffGlue::CreateXfermode},
+ {"nativeCreateXfermode","(I)J", (void*) SkPorterDuffGlue::CreateXfermode},
};
int register_android_graphics_PorterDuff(JNIEnv* env) {
diff --git a/core/jni/android/graphics/Rasterizer.cpp b/core/jni/android/graphics/Rasterizer.cpp
index 4e1b36a..b6450d0 100644
--- a/core/jni/android/graphics/Rasterizer.cpp
+++ b/core/jni/android/graphics/Rasterizer.cpp
@@ -31,14 +31,15 @@
class SkRasterizerGlue {
public:
- static void finalizer(JNIEnv* env, jobject clazz, SkRasterizer* obj) {
+ static void finalizer(JNIEnv* env, jobject clazz, jlong objHandle) {
+ SkRasterizer* obj = reinterpret_cast<SkRasterizer *>(objHandle);
SkSafeUnref(obj);
}
};
static JNINativeMethod methods[] = {
- {"finalizer", "(I)V", (void*) SkRasterizerGlue::finalizer}
+ {"finalizer", "(J)V", (void*) SkRasterizerGlue::finalizer}
};
int register_android_graphics_Rasterizer(JNIEnv* env) {
diff --git a/core/jni/android/graphics/Region.cpp b/core/jni/android/graphics/Region.cpp
index ded2186..bcf1273 100644
--- a/core/jni/android/graphics/Region.cpp
+++ b/core/jni/android/graphics/Region.cpp
@@ -29,95 +29,131 @@
static jfieldID gRegion_nativeInstanceFieldID;
+static inline jboolean boolTojboolean(bool value) {
+ return value ? JNI_TRUE : JNI_FALSE;
+}
+
static inline SkRegion* GetSkRegion(JNIEnv* env, jobject regionObject) {
- SkRegion* rgn = (SkRegion*)env->GetIntField(regionObject, gRegion_nativeInstanceFieldID);
- SkASSERT(rgn != NULL);
- return rgn;
+ jlong regionHandle = env->GetLongField(regionObject, gRegion_nativeInstanceFieldID);
+ SkRegion* region = reinterpret_cast<SkRegion*>(regionHandle);
+ SkASSERT(region != NULL);
+ return region;
}
-static SkRegion* Region_constructor(JNIEnv* env, jobject) {
- return new SkRegion;
+static jlong Region_constructor(JNIEnv* env, jobject) {
+ return reinterpret_cast<jlong>(new SkRegion);
}
-static void Region_destructor(JNIEnv* env, jobject, SkRegion* region) {
+static void Region_destructor(JNIEnv* env, jobject, jlong regionHandle) {
+ SkRegion* region = reinterpret_cast<SkRegion*>(regionHandle);
SkASSERT(region);
delete region;
}
-static void Region_setRegion(JNIEnv* env, jobject, SkRegion* dst, const SkRegion* src) {
+static void Region_setRegion(JNIEnv* env, jobject, jlong dstHandle, jlong srcHandle) {
+ SkRegion* dst = reinterpret_cast<SkRegion*>(dstHandle);
+ const SkRegion* src = reinterpret_cast<SkRegion*>(srcHandle);
SkASSERT(dst && src);
*dst = *src;
}
-static jboolean Region_setRect(JNIEnv* env, jobject, SkRegion* dst, int left, int top, int right, int bottom) {
- return dst->setRect(left, top, right, bottom);
+static jboolean Region_setRect(JNIEnv* env, jobject, jlong dstHandle, jint left, jint top, jint right, jint bottom) {
+ SkRegion* dst = reinterpret_cast<SkRegion*>(dstHandle);
+ bool result = dst->setRect(left, top, right, bottom);
+ return boolTojboolean(result);
}
-static jboolean Region_setPath(JNIEnv* env, jobject, SkRegion* dst,
- const SkPath* path, const SkRegion* clip) {
+static jboolean Region_setPath(JNIEnv* env, jobject, jlong dstHandle,
+ jlong pathHandle, jlong clipHandle) {
+ SkRegion* dst = reinterpret_cast<SkRegion*>(dstHandle);
+ const SkPath* path = reinterpret_cast<SkPath*>(pathHandle);
+ const SkRegion* clip = reinterpret_cast<SkRegion*>(clipHandle);
SkASSERT(dst && path && clip);
- return dst->setPath(*path, *clip);
+ bool result = dst->setPath(*path, *clip);
+ return boolTojboolean(result);
+
}
-static jboolean Region_getBounds(JNIEnv* env, jobject, SkRegion* region, jobject rectBounds) {
+static jboolean Region_getBounds(JNIEnv* env, jobject, jlong regionHandle, jobject rectBounds) {
+ SkRegion* region = reinterpret_cast<SkRegion*>(regionHandle);
GraphicsJNI::irect_to_jrect(region->getBounds(), env, rectBounds);
- return !region->isEmpty();
+ bool result = !region->isEmpty();
+ return boolTojboolean(result);
}
-static jboolean Region_getBoundaryPath(JNIEnv* env, jobject, const SkRegion* region, SkPath* path) {
- return region->getBoundaryPath(path);
+static jboolean Region_getBoundaryPath(JNIEnv* env, jobject, jlong regionHandle, jlong pathHandle) {
+ const SkRegion* region = reinterpret_cast<SkRegion*>(regionHandle);
+ SkPath* path = reinterpret_cast<SkPath*>(pathHandle);
+ bool result = region->getBoundaryPath(path);
+ return boolTojboolean(result);
}
-static jboolean Region_op0(JNIEnv* env, jobject, SkRegion* dst, int left, int top, int right, int bottom, int op) {
+static jboolean Region_op0(JNIEnv* env, jobject, jlong dstHandle, jint left, jint top, jint right, jint bottom, jint op) {
+ SkRegion* dst = reinterpret_cast<SkRegion*>(dstHandle);
SkIRect ir;
ir.set(left, top, right, bottom);
- return dst->op(ir, (SkRegion::Op)op);
+ bool result = dst->op(ir, (SkRegion::Op)op);
+ return boolTojboolean(result);
}
-static jboolean Region_op1(JNIEnv* env, jobject, SkRegion* dst, jobject rectObject, const SkRegion* region, int op) {
+static jboolean Region_op1(JNIEnv* env, jobject, jlong dstHandle, jobject rectObject, jlong regionHandle, jint op) {
+ SkRegion* dst = reinterpret_cast<SkRegion*>(dstHandle);
+ const SkRegion* region = reinterpret_cast<SkRegion*>(regionHandle);
SkIRect ir;
GraphicsJNI::jrect_to_irect(env, rectObject, &ir);
- return dst->op(ir, *region, (SkRegion::Op)op);
+ bool result = dst->op(ir, *region, (SkRegion::Op)op);
+ return boolTojboolean(result);
}
-static jboolean Region_op2(JNIEnv* env, jobject, SkRegion* dst, const SkRegion* region1, const SkRegion* region2, int op) {
- return dst->op(*region1, *region2, (SkRegion::Op)op);
+static jboolean Region_op2(JNIEnv* env, jobject, jlong dstHandle, jlong region1Handle, jlong region2Handle, jint op) {
+ SkRegion* dst = reinterpret_cast<SkRegion*>(dstHandle);
+ const SkRegion* region1 = reinterpret_cast<SkRegion*>(region1Handle);
+ const SkRegion* region2 = reinterpret_cast<SkRegion*>(region2Handle);
+ bool result = dst->op(*region1, *region2, (SkRegion::Op)op);
+ return boolTojboolean(result);
}
//////////////////////////////////// These are methods, not static
static jboolean Region_isEmpty(JNIEnv* env, jobject region) {
- return GetSkRegion(env, region)->isEmpty();
+ bool result = GetSkRegion(env, region)->isEmpty();
+ return boolTojboolean(result);
}
static jboolean Region_isRect(JNIEnv* env, jobject region) {
- return GetSkRegion(env, region)->isRect();
+ bool result = GetSkRegion(env, region)->isRect();
+ return boolTojboolean(result);
}
static jboolean Region_isComplex(JNIEnv* env, jobject region) {
- return GetSkRegion(env, region)->isComplex();
+ bool result = GetSkRegion(env, region)->isComplex();
+ return boolTojboolean(result);
}
-static jboolean Region_contains(JNIEnv* env, jobject region, int x, int y) {
- return GetSkRegion(env, region)->contains(x, y);
+static jboolean Region_contains(JNIEnv* env, jobject region, jint x, jint y) {
+ bool result = GetSkRegion(env, region)->contains(x, y);
+ return boolTojboolean(result);
}
-static jboolean Region_quickContains(JNIEnv* env, jobject region, int left, int top, int right, int bottom) {
- return GetSkRegion(env, region)->quickContains(left, top, right, bottom);
+static jboolean Region_quickContains(JNIEnv* env, jobject region, jint left, jint top, jint right, jint bottom) {
+ bool result = GetSkRegion(env, region)->quickContains(left, top, right, bottom);
+ return boolTojboolean(result);
}
-static jboolean Region_quickRejectIIII(JNIEnv* env, jobject region, int left, int top, int right, int bottom) {
+static jboolean Region_quickRejectIIII(JNIEnv* env, jobject region, jint left, jint top, jint right, jint bottom) {
SkIRect ir;
ir.set(left, top, right, bottom);
- return GetSkRegion(env, region)->quickReject(ir);
+ bool result = GetSkRegion(env, region)->quickReject(ir);
+ return boolTojboolean(result);
}
static jboolean Region_quickRejectRgn(JNIEnv* env, jobject region, jobject other) {
- return GetSkRegion(env, region)->quickReject(*GetSkRegion(env, other));
+ bool result = GetSkRegion(env, region)->quickReject(*GetSkRegion(env, other));
+ return boolTojboolean(result);
}
-static void Region_translate(JNIEnv* env, jobject region, int x, int y, jobject dst) {
+static void Region_translate(JNIEnv* env, jobject region, jint x, jint y, jobject dst) {
SkRegion* rgn = GetSkRegion(env, region);
if (dst)
rgn->translate(x, y, GetSkRegion(env, dst));
@@ -155,7 +191,8 @@
scale_rgn(rgn, *rgn, scale);
}
-static jstring Region_toString(JNIEnv* env, jobject clazz, SkRegion* region) {
+static jstring Region_toString(JNIEnv* env, jobject clazz, jlong regionHandle) {
+ SkRegion* region = reinterpret_cast<SkRegion*>(regionHandle);
char* str = region->toString();
if (str == NULL) {
return NULL;
@@ -167,7 +204,7 @@
////////////////////////////////////////////////////////////////////////////////////////////////////////////
-static SkRegion* Region_createFromParcel(JNIEnv* env, jobject clazz, jobject parcel)
+static jlong Region_createFromParcel(JNIEnv* env, jobject clazz, jobject parcel)
{
if (parcel == NULL) {
return NULL;
@@ -179,13 +216,14 @@
size_t size = p->readInt32();
region->readFromMemory(p->readInplace(size));
- return region;
+ return reinterpret_cast<jlong>(region);
}
-static jboolean Region_writeToParcel(JNIEnv* env, jobject clazz, const SkRegion* region, jobject parcel)
+static jboolean Region_writeToParcel(JNIEnv* env, jobject clazz, jlong regionHandle, jobject parcel)
{
+ const SkRegion* region = reinterpret_cast<SkRegion*>(regionHandle);
if (parcel == NULL) {
- return false;
+ return JNI_FALSE;
}
android::Parcel* p = android::parcelForJavaObject(env, parcel);
@@ -194,14 +232,16 @@
p->writeInt32(size);
region->writeToMemory(p->writeInplace(size));
- return true;
+ return JNI_TRUE;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////
-static jboolean Region_equals(JNIEnv* env, jobject clazz, const SkRegion *r1, const SkRegion* r2)
+static jboolean Region_equals(JNIEnv* env, jobject clazz, jlong r1Handle, jlong r2Handle)
{
- return (jboolean) (*r1 == *r2);
+ const SkRegion *r1 = reinterpret_cast<SkRegion*>(r1Handle);
+ const SkRegion *r2 = reinterpret_cast<SkRegion*>(r2Handle);
+ return boolTojboolean(*r1 == *r2);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -217,20 +257,23 @@
}
};
-static RgnIterPair* RegionIter_constructor(JNIEnv* env, jobject, const SkRegion* region)
+static jlong RegionIter_constructor(JNIEnv* env, jobject, jlong regionHandle)
{
+ const SkRegion* region = reinterpret_cast<SkRegion*>(regionHandle);
SkASSERT(region);
- return new RgnIterPair(*region);
+ return reinterpret_cast<jlong>(new RgnIterPair(*region));
}
-static void RegionIter_destructor(JNIEnv* env, jobject, RgnIterPair* pair)
+static void RegionIter_destructor(JNIEnv* env, jobject, jlong pairHandle)
{
+ RgnIterPair* pair = reinterpret_cast<RgnIterPair*>(pairHandle);
SkASSERT(pair);
delete pair;
}
-static jboolean RegionIter_next(JNIEnv* env, jobject, RgnIterPair* pair, jobject rectObject)
+static jboolean RegionIter_next(JNIEnv* env, jobject, jlong pairHandle, jobject rectObject)
{
+ RgnIterPair* pair = reinterpret_cast<RgnIterPair*>(pairHandle);
// the caller has checked that rectObject is not nul
SkASSERT(pair);
SkASSERT(rectObject);
@@ -238,31 +281,31 @@
if (!pair->fIter.done()) {
GraphicsJNI::irect_to_jrect(pair->fIter.rect(), env, rectObject);
pair->fIter.next();
- return true;
+ return JNI_TRUE;
}
- return false;
+ return JNI_FALSE;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////
static JNINativeMethod gRegionIterMethods[] = {
- { "nativeConstructor", "(I)I", (void*)RegionIter_constructor },
- { "nativeDestructor", "(I)V", (void*)RegionIter_destructor },
- { "nativeNext", "(ILandroid/graphics/Rect;)Z", (void*)RegionIter_next }
+ { "nativeConstructor", "(J)J", (void*)RegionIter_constructor },
+ { "nativeDestructor", "(J)V", (void*)RegionIter_destructor },
+ { "nativeNext", "(JLandroid/graphics/Rect;)Z", (void*)RegionIter_next }
};
static JNINativeMethod gRegionMethods[] = {
// these are static methods
- { "nativeConstructor", "()I", (void*)Region_constructor },
- { "nativeDestructor", "(I)V", (void*)Region_destructor },
- { "nativeSetRegion", "(II)V", (void*)Region_setRegion },
- { "nativeSetRect", "(IIIII)Z", (void*)Region_setRect },
- { "nativeSetPath", "(III)Z", (void*)Region_setPath },
- { "nativeGetBounds", "(ILandroid/graphics/Rect;)Z", (void*)Region_getBounds },
- { "nativeGetBoundaryPath", "(II)Z", (void*)Region_getBoundaryPath },
- { "nativeOp", "(IIIIII)Z", (void*)Region_op0 },
- { "nativeOp", "(ILandroid/graphics/Rect;II)Z", (void*)Region_op1 },
- { "nativeOp", "(IIII)Z", (void*)Region_op2 },
+ { "nativeConstructor", "()J", (void*)Region_constructor },
+ { "nativeDestructor", "(J)V", (void*)Region_destructor },
+ { "nativeSetRegion", "(JJ)V", (void*)Region_setRegion },
+ { "nativeSetRect", "(JIIII)Z", (void*)Region_setRect },
+ { "nativeSetPath", "(JJJ)Z", (void*)Region_setPath },
+ { "nativeGetBounds", "(JLandroid/graphics/Rect;)Z", (void*)Region_getBounds },
+ { "nativeGetBoundaryPath", "(JJ)Z", (void*)Region_getBoundaryPath },
+ { "nativeOp", "(JIIIII)Z", (void*)Region_op0 },
+ { "nativeOp", "(JLandroid/graphics/Rect;JI)Z", (void*)Region_op1 },
+ { "nativeOp", "(JJJI)Z", (void*)Region_op2 },
// these are methods that take the java region object
{ "isEmpty", "()Z", (void*)Region_isEmpty },
{ "isRect", "()Z", (void*)Region_isRect },
@@ -273,11 +316,11 @@
{ "quickReject", "(Landroid/graphics/Region;)Z", (void*)Region_quickRejectRgn },
{ "scale", "(FLandroid/graphics/Region;)V", (void*)Region_scale },
{ "translate", "(IILandroid/graphics/Region;)V", (void*)Region_translate },
- { "nativeToString", "(I)Ljava/lang/String;", (void*)Region_toString },
+ { "nativeToString", "(J)Ljava/lang/String;", (void*)Region_toString },
// parceling methods
- { "nativeCreateFromParcel", "(Landroid/os/Parcel;)I", (void*)Region_createFromParcel },
- { "nativeWriteToParcel", "(ILandroid/os/Parcel;)Z", (void*)Region_writeToParcel },
- { "nativeEquals", "(II)Z", (void*)Region_equals },
+ { "nativeCreateFromParcel", "(Landroid/os/Parcel;)J", (void*)Region_createFromParcel },
+ { "nativeWriteToParcel", "(JLandroid/os/Parcel;)Z", (void*)Region_writeToParcel },
+ { "nativeEquals", "(JJ)Z", (void*)Region_equals },
};
int register_android_graphics_Region(JNIEnv* env)
@@ -285,7 +328,7 @@
jclass clazz = env->FindClass("android/graphics/Region");
SkASSERT(clazz);
- gRegion_nativeInstanceFieldID = env->GetFieldID(clazz, "mNativeRegion", "I");
+ gRegion_nativeInstanceFieldID = env->GetFieldID(clazz, "mNativeRegion", "J");
SkASSERT(gRegion_nativeInstanceFieldID);
int result = android::AndroidRuntime::registerNativeMethods(env, "android/graphics/Region",
diff --git a/core/jni/android/graphics/Shader.cpp b/core/jni/android/graphics/Shader.cpp
index 6323ab3..3047440 100644
--- a/core/jni/android/graphics/Shader.cpp
+++ b/core/jni/android/graphics/Shader.cpp
@@ -24,7 +24,7 @@
}
}
-static void Color_RGBToHSV(JNIEnv* env, jobject, int red, int green, int blue, jfloatArray hsvArray)
+static void Color_RGBToHSV(JNIEnv* env, jobject, jint red, jint green, jint blue, jfloatArray hsvArray)
{
SkScalar hsv[3];
SkRGBToHSV(red, green, blue, hsv);
@@ -36,7 +36,7 @@
}
}
-static int Color_HSVToColor(JNIEnv* env, jobject, int alpha, jfloatArray hsvArray)
+static jint Color_HSVToColor(JNIEnv* env, jobject, jint alpha, jfloatArray hsvArray)
{
AutoJavaFloatArray autoHSV(env, hsvArray, 3);
float* values = autoHSV.ptr();;
@@ -46,13 +46,15 @@
hsv[i] = SkFloatToScalar(values[i]);
}
- return SkHSVToColor(alpha, hsv);
+ return static_cast<jint>(SkHSVToColor(alpha, hsv));
}
///////////////////////////////////////////////////////////////////////////////////////////////
-static void Shader_destructor(JNIEnv* env, jobject o, SkShader* shader, SkiaShader* skiaShader)
+static void Shader_destructor(JNIEnv* env, jobject o, jlong shaderHandle, jlong skiaShaderHandle)
{
+ SkShader* shader = reinterpret_cast<SkShader*>(shaderHandle);
+ SkiaShader* skiaShader = reinterpret_cast<SkiaShader*>(skiaShaderHandle);
SkSafeUnref(shader);
// skiaShader == NULL when not !USE_OPENGL_RENDERER, so no need to delete it outside the ifdef
#ifdef USE_OPENGL_RENDERER
@@ -64,9 +66,12 @@
#endif
}
-static void Shader_setLocalMatrix(JNIEnv* env, jobject o, SkShader* shader, SkiaShader* skiaShader,
- const SkMatrix* matrix)
+static void Shader_setLocalMatrix(JNIEnv* env, jobject o, jlong shaderHandle,
+ jlong skiaShaderHandle, jlong matrixHandle)
{
+ SkShader* shader = reinterpret_cast<SkShader*>(shaderHandle);
+ SkiaShader* skiaShader = reinterpret_cast<SkiaShader*>(skiaShaderHandle);
+ const SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle);
if (shader) {
if (NULL == matrix) {
shader->resetLocalMatrix();
@@ -82,24 +87,27 @@
///////////////////////////////////////////////////////////////////////////////////////////////
-static SkShader* BitmapShader_constructor(JNIEnv* env, jobject o, const SkBitmap* bitmap,
- int tileModeX, int tileModeY)
+static jlong BitmapShader_constructor(JNIEnv* env, jobject o, jlong bitmapHandle,
+ jint tileModeX, jint tileModeY)
{
+ const SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
SkShader* s = SkShader::CreateBitmapShader(*bitmap,
(SkShader::TileMode)tileModeX,
(SkShader::TileMode)tileModeY);
ThrowIAE_IfNull(env, s);
- return s;
+ return reinterpret_cast<jlong>(s);
}
-static SkiaShader* BitmapShader_postConstructor(JNIEnv* env, jobject o, SkShader* shader,
- SkBitmap* bitmap, int tileModeX, int tileModeY) {
+static jlong BitmapShader_postConstructor(JNIEnv* env, jobject o, jlong shaderHandle,
+ jlong bitmapHandle, jint tileModeX, jint tileModeY) {
+ SkShader* shader = reinterpret_cast<SkShader*>(shaderHandle);
+ SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
#ifdef USE_OPENGL_RENDERER
SkiaShader* skiaShader = new SkiaBitmapShader(bitmap, shader,
static_cast<SkShader::TileMode>(tileModeX), static_cast<SkShader::TileMode>(tileModeY),
NULL, (shader->getFlags() & SkShader::kOpaqueAlpha_Flag) == 0);
- return skiaShader;
+ return reinterpret_cast<jlong>(skiaShader);
#else
return NULL;
#endif
@@ -107,9 +115,9 @@
///////////////////////////////////////////////////////////////////////////////////////////////
-static SkShader* LinearGradient_create1(JNIEnv* env, jobject o,
- float x0, float y0, float x1, float y1,
- jintArray colorArray, jfloatArray posArray, int tileMode)
+static jlong LinearGradient_create1(JNIEnv* env, jobject o,
+ jfloat x0, jfloat y0, jfloat x1, jfloat y1,
+ jintArray colorArray, jfloatArray posArray, jint tileMode)
{
SkPoint pts[2];
pts[0].set(SkFloatToScalar(x0), SkFloatToScalar(y0));
@@ -137,13 +145,14 @@
env->ReleaseIntArrayElements(colorArray, const_cast<jint*>(colorValues), JNI_ABORT);
ThrowIAE_IfNull(env, shader);
- return shader;
+ return reinterpret_cast<jlong>(shader);
}
-static SkiaShader* LinearGradient_postCreate1(JNIEnv* env, jobject o, SkShader* shader,
- float x0, float y0, float x1, float y1, jintArray colorArray,
- jfloatArray posArray, int tileMode) {
+static jlong LinearGradient_postCreate1(JNIEnv* env, jobject o, jlong shaderHandle,
+ jfloat x0, jfloat y0, jfloat x1, jfloat y1, jintArray colorArray,
+ jfloatArray posArray, jint tileMode) {
#ifdef USE_OPENGL_RENDERER
+ SkShader* shader = reinterpret_cast<SkShader*>(shaderHandle);
size_t count = env->GetArrayLength(colorArray);
const jint* colorValues = env->GetIntArrayElements(colorArray, NULL);
@@ -206,15 +215,16 @@
(shader->getFlags() & SkShader::kOpaqueAlpha_Flag) == 0);
env->ReleaseIntArrayElements(colorArray, const_cast<jint*>(colorValues), JNI_ABORT);
- return skiaShader;
+ return reinterpret_cast<jlong>(skiaShader);
#else
return NULL;
#endif
}
-static SkiaShader* LinearGradient_postCreate2(JNIEnv* env, jobject o, SkShader* shader,
- float x0, float y0, float x1, float y1, int color0, int color1, int tileMode) {
+static jlong LinearGradient_postCreate2(JNIEnv* env, jobject o, jlong shaderHandle,
+ jfloat x0, jfloat y0, jfloat x1, jfloat y1, jint color0, jint color1, jint tileMode) {
#ifdef USE_OPENGL_RENDERER
+ SkShader* shader = reinterpret_cast<SkShader*>(shaderHandle);
float* storedBounds = new float[4];
storedBounds[0] = x0; storedBounds[1] = y0;
storedBounds[2] = x1; storedBounds[3] = y1;
@@ -231,15 +241,15 @@
storedPositions, 2, shader, static_cast<SkShader::TileMode>(tileMode), NULL,
(shader->getFlags() & SkShader::kOpaqueAlpha_Flag) == 0);
- return skiaShader;
+ return reinterpret_cast<jlong>(skiaShader);
#else
return NULL;
#endif
}
-static SkShader* LinearGradient_create2(JNIEnv* env, jobject o,
- float x0, float y0, float x1, float y1,
- int color0, int color1, int tileMode)
+static jlong LinearGradient_create2(JNIEnv* env, jobject o,
+ jfloat x0, jfloat y0, jfloat x1, jfloat y1,
+ jint color0, jint color1, jint tileMode)
{
SkPoint pts[2];
pts[0].set(SkFloatToScalar(x0), SkFloatToScalar(y0));
@@ -252,13 +262,13 @@
SkShader* s = SkGradientShader::CreateLinear(pts, colors, NULL, 2, (SkShader::TileMode)tileMode);
ThrowIAE_IfNull(env, s);
- return s;
+ return reinterpret_cast<jlong>(s);
}
///////////////////////////////////////////////////////////////////////////////////////////////
-static SkShader* RadialGradient_create1(JNIEnv* env, jobject, float x, float y, float radius,
- jintArray colorArray, jfloatArray posArray, int tileMode) {
+static jlong RadialGradient_create1(JNIEnv* env, jobject, jfloat x, jfloat y, jfloat radius,
+ jintArray colorArray, jfloatArray posArray, jint tileMode) {
SkPoint center;
center.set(SkFloatToScalar(x), SkFloatToScalar(y));
@@ -285,11 +295,11 @@
JNI_ABORT);
ThrowIAE_IfNull(env, shader);
- return shader;
+ return reinterpret_cast<jlong>(shader);
}
-static SkShader* RadialGradient_create2(JNIEnv* env, jobject, float x, float y, float radius,
- int color0, int color1, int tileMode) {
+static jlong RadialGradient_create2(JNIEnv* env, jobject, jfloat x, jfloat y, jfloat radius,
+ jint color0, jint color1, jint tileMode) {
SkPoint center;
center.set(SkFloatToScalar(x), SkFloatToScalar(y));
@@ -300,12 +310,13 @@
SkShader* s = SkGradientShader::CreateRadial(center, SkFloatToScalar(radius), colors, NULL,
2, (SkShader::TileMode)tileMode);
ThrowIAE_IfNull(env, s);
- return s;
+ return reinterpret_cast<jlong>(s);
}
-static SkiaShader* RadialGradient_postCreate1(JNIEnv* env, jobject o, SkShader* shader,
- float x, float y, float radius, jintArray colorArray, jfloatArray posArray, int tileMode) {
+static jlong RadialGradient_postCreate1(JNIEnv* env, jobject o, jlong shaderHandle,
+ jfloat x, jfloat y, jfloat radius, jintArray colorArray, jfloatArray posArray, jint tileMode) {
#ifdef USE_OPENGL_RENDERER
+ SkShader* shader = reinterpret_cast<SkShader*>(shaderHandle);
size_t count = env->GetArrayLength(colorArray);
const jint* colorValues = env->GetIntArrayElements(colorArray, NULL);
@@ -335,15 +346,16 @@
(shader->getFlags() & SkShader::kOpaqueAlpha_Flag) == 0);
env->ReleaseIntArrayElements(colorArray, const_cast<jint*>(colorValues), JNI_ABORT);
- return skiaShader;
+ return reinterpret_cast<jlong>(skiaShader);
#else
return NULL;
#endif
}
-static SkiaShader* RadialGradient_postCreate2(JNIEnv* env, jobject o, SkShader* shader,
- float x, float y, float radius, int color0, int color1, int tileMode) {
+static jlong RadialGradient_postCreate2(JNIEnv* env, jobject o, jlong shaderHandle,
+ jfloat x, jfloat y, jfloat radius, jint color0, jint color1, jint tileMode) {
#ifdef USE_OPENGL_RENDERER
+ SkShader* shader = reinterpret_cast<SkShader*>(shaderHandle);
float* storedPositions = new float[2];
storedPositions[0] = 0.0f;
storedPositions[1] = 1.0f;
@@ -356,7 +368,7 @@
storedPositions, 2, shader, (SkShader::TileMode) tileMode, NULL,
(shader->getFlags() & SkShader::kOpaqueAlpha_Flag) == 0);
- return skiaShader;
+ return reinterpret_cast<jlong>(skiaShader);
#else
return NULL;
#endif
@@ -364,7 +376,7 @@
///////////////////////////////////////////////////////////////////////////////
-static SkShader* SweepGradient_create1(JNIEnv* env, jobject, float x, float y,
+static jlong SweepGradient_create1(JNIEnv* env, jobject, jfloat x, jfloat y,
jintArray jcolors, jfloatArray jpositions) {
size_t count = env->GetArrayLength(jcolors);
const jint* colors = env->GetIntArrayElements(jcolors, NULL);
@@ -388,10 +400,10 @@
env->ReleaseIntArrayElements(jcolors, const_cast<jint*>(colors),
JNI_ABORT);
ThrowIAE_IfNull(env, shader);
- return shader;
+ return reinterpret_cast<jlong>(shader);
}
-static SkShader* SweepGradient_create2(JNIEnv* env, jobject, float x, float y,
+static jlong SweepGradient_create2(JNIEnv* env, jobject, jfloat x, jfloat y,
int color0, int color1) {
SkColor colors[2];
colors[0] = color0;
@@ -399,12 +411,13 @@
SkShader* s = SkGradientShader::CreateSweep(SkFloatToScalar(x), SkFloatToScalar(y),
colors, NULL, 2);
ThrowIAE_IfNull(env, s);
- return s;
+ return reinterpret_cast<jlong>(s);
}
-static SkiaShader* SweepGradient_postCreate1(JNIEnv* env, jobject o, SkShader* shader,
- float x, float y, jintArray colorArray, jfloatArray posArray) {
+static jlong SweepGradient_postCreate1(JNIEnv* env, jobject o, jlong shaderHandle,
+ jfloat x, jfloat y, jintArray colorArray, jfloatArray posArray) {
#ifdef USE_OPENGL_RENDERER
+ SkShader* shader = reinterpret_cast<SkShader*>(shaderHandle);
size_t count = env->GetArrayLength(colorArray);
const jint* colorValues = env->GetIntArrayElements(colorArray, NULL);
@@ -433,15 +446,16 @@
shader, NULL, (shader->getFlags() & SkShader::kOpaqueAlpha_Flag) == 0);
env->ReleaseIntArrayElements(colorArray, const_cast<jint*>(colorValues), JNI_ABORT);
- return skiaShader;
+ return reinterpret_cast<jlong>(skiaShader);
#else
return NULL;
#endif
}
-static SkiaShader* SweepGradient_postCreate2(JNIEnv* env, jobject o, SkShader* shader,
- float x, float y, int color0, int color1) {
+static jlong SweepGradient_postCreate2(JNIEnv* env, jobject o, jlong shaderHandle,
+ jfloat x, jfloat y, jint color0, jint color1) {
#ifdef USE_OPENGL_RENDERER
+ SkShader* shader = reinterpret_cast<SkShader*>(shaderHandle);
float* storedPositions = new float[2];
storedPositions[0] = 0.0f;
storedPositions[1] = 1.0f;
@@ -453,7 +467,7 @@
SkiaShader* skiaShader = new SkiaSweepGradientShader(x, y, storedColors, storedPositions, 2,
shader, NULL, (shader->getFlags() & SkShader::kOpaqueAlpha_Flag) == 0);
- return skiaShader;
+ return reinterpret_cast<jlong>(skiaShader);
#else
return NULL;
#endif
@@ -461,39 +475,57 @@
///////////////////////////////////////////////////////////////////////////////////////////////
-static SkShader* ComposeShader_create1(JNIEnv* env, jobject o,
- SkShader* shaderA, SkShader* shaderB, SkXfermode* mode)
+static jlong ComposeShader_create1(JNIEnv* env, jobject o,
+ jlong shaderAHandle, jlong shaderBHandle, jlong modeHandle)
{
- return new SkComposeShader(shaderA, shaderB, mode);
+ SkShader* shaderA = reinterpret_cast<SkShader *>(shaderAHandle);
+ SkShader* shaderB = reinterpret_cast<SkShader *>(shaderBHandle);
+ SkXfermode* mode = reinterpret_cast<SkXfermode *>(modeHandle);
+ SkShader* shader = new SkComposeShader(shaderA, shaderB, mode);
+ return reinterpret_cast<jlong>(shader);
}
-static SkShader* ComposeShader_create2(JNIEnv* env, jobject o,
- SkShader* shaderA, SkShader* shaderB, SkPorterDuff::Mode porterDuffMode)
+static jlong ComposeShader_create2(JNIEnv* env, jobject o,
+ jlong shaderAHandle, jlong shaderBHandle, jint porterDuffModeHandle)
{
+ SkShader* shaderA = reinterpret_cast<SkShader *>(shaderAHandle);
+ SkShader* shaderB = reinterpret_cast<SkShader *>(shaderBHandle);
+ SkPorterDuff::Mode porterDuffMode = static_cast<SkPorterDuff::Mode>(porterDuffModeHandle);
SkAutoUnref au(SkPorterDuff::CreateXfermode(porterDuffMode));
SkXfermode* mode = (SkXfermode*) au.get();
- return new SkComposeShader(shaderA, shaderB, mode);
+ SkShader* shader = new SkComposeShader(shaderA, shaderB, mode);
+ return reinterpret_cast<jlong>(shader);
}
-static SkiaShader* ComposeShader_postCreate2(JNIEnv* env, jobject o, SkShader* shader,
- SkiaShader* shaderA, SkiaShader* shaderB, SkPorterDuff::Mode porterDuffMode) {
+static jlong ComposeShader_postCreate2(JNIEnv* env, jobject o, jlong shaderHandle,
+ jlong shaderAHandle, jlong shaderBHandle, jint porterDuffModeHandle) {
#ifdef USE_OPENGL_RENDERER
+ SkShader* shader = reinterpret_cast<SkShader *>(shaderHandle);
+ SkiaShader* shaderA = reinterpret_cast<SkiaShader *>(shaderAHandle);
+ SkiaShader* shaderB = reinterpret_cast<SkiaShader *>(shaderBHandle);
+ SkPorterDuff::Mode porterDuffMode = static_cast<SkPorterDuff::Mode>(porterDuffModeHandle);
SkXfermode::Mode mode = SkPorterDuff::ToXfermodeMode(porterDuffMode);
- return new SkiaComposeShader(shaderA, shaderB, mode, shader);
+ SkiaShader* skiaShader = new SkiaComposeShader(shaderA, shaderB, mode, shader);
+ return reinterpret_cast<jlong>(skiaShader);
#else
return NULL;
#endif
}
-static SkiaShader* ComposeShader_postCreate1(JNIEnv* env, jobject o, SkShader* shader,
- SkiaShader* shaderA, SkiaShader* shaderB, SkXfermode* mode) {
+static jlong ComposeShader_postCreate1(JNIEnv* env, jobject o, jlong shaderHandle,
+ jlong shaderAHandle, jlong shaderBHandle, jlong modeHandle) {
#ifdef USE_OPENGL_RENDERER
+ SkShader* shader = reinterpret_cast<SkShader *>(shaderHandle);
+ SkiaShader* shaderA = reinterpret_cast<SkiaShader *>(shaderAHandle);
+ SkiaShader* shaderB = reinterpret_cast<SkiaShader *>(shaderBHandle);
+ SkXfermode* mode = reinterpret_cast<SkXfermode *>(modeHandle);
SkXfermode::Mode skiaMode;
if (!SkXfermode::IsMode(mode, &skiaMode)) {
// TODO: Support other modes
skiaMode = SkXfermode::kSrcOver_Mode;
}
- return new SkiaComposeShader(shaderA, shaderB, skiaMode, shader);
+ SkiaShader* skiaShader = new SkiaComposeShader(shaderA, shaderB, skiaMode, shader);
+ return reinterpret_cast<jlong>(skiaShader);
#else
return NULL;
#endif
@@ -507,41 +539,41 @@
};
static JNINativeMethod gShaderMethods[] = {
- { "nativeDestructor", "(II)V", (void*)Shader_destructor },
- { "nativeSetLocalMatrix", "(III)V", (void*)Shader_setLocalMatrix }
+ { "nativeDestructor", "(JJ)V", (void*)Shader_destructor },
+ { "nativeSetLocalMatrix", "(JJJ)V", (void*)Shader_setLocalMatrix }
};
static JNINativeMethod gBitmapShaderMethods[] = {
- { "nativeCreate", "(III)I", (void*)BitmapShader_constructor },
- { "nativePostCreate", "(IIII)I", (void*)BitmapShader_postConstructor }
+ { "nativeCreate", "(JII)J", (void*)BitmapShader_constructor },
+ { "nativePostCreate", "(JJII)J", (void*)BitmapShader_postConstructor }
};
static JNINativeMethod gLinearGradientMethods[] = {
- { "nativeCreate1", "(FFFF[I[FI)I", (void*)LinearGradient_create1 },
- { "nativeCreate2", "(FFFFIII)I", (void*)LinearGradient_create2 },
- { "nativePostCreate1", "(IFFFF[I[FI)I", (void*)LinearGradient_postCreate1 },
- { "nativePostCreate2", "(IFFFFIII)I", (void*)LinearGradient_postCreate2 }
+ { "nativeCreate1", "(FFFF[I[FI)J", (void*)LinearGradient_create1 },
+ { "nativeCreate2", "(FFFFIII)J", (void*)LinearGradient_create2 },
+ { "nativePostCreate1", "(JFFFF[I[FI)J", (void*)LinearGradient_postCreate1 },
+ { "nativePostCreate2", "(JFFFFIII)J", (void*)LinearGradient_postCreate2 }
};
static JNINativeMethod gRadialGradientMethods[] = {
- { "nativeCreate1", "(FFF[I[FI)I", (void*)RadialGradient_create1 },
- { "nativeCreate2", "(FFFIII)I", (void*)RadialGradient_create2 },
- { "nativePostCreate1", "(IFFF[I[FI)I", (void*)RadialGradient_postCreate1 },
- { "nativePostCreate2", "(IFFFIII)I", (void*)RadialGradient_postCreate2 }
+ { "nativeCreate1", "(FFF[I[FI)J", (void*)RadialGradient_create1 },
+ { "nativeCreate2", "(FFFIII)J", (void*)RadialGradient_create2 },
+ { "nativePostCreate1", "(JFFF[I[FI)J", (void*)RadialGradient_postCreate1 },
+ { "nativePostCreate2", "(JFFFIII)J", (void*)RadialGradient_postCreate2 }
};
static JNINativeMethod gSweepGradientMethods[] = {
- { "nativeCreate1", "(FF[I[F)I", (void*)SweepGradient_create1 },
- { "nativeCreate2", "(FFII)I", (void*)SweepGradient_create2 },
- { "nativePostCreate1", "(IFF[I[F)I", (void*)SweepGradient_postCreate1 },
- { "nativePostCreate2", "(IFFII)I", (void*)SweepGradient_postCreate2 }
+ { "nativeCreate1", "(FF[I[F)J", (void*)SweepGradient_create1 },
+ { "nativeCreate2", "(FFII)J", (void*)SweepGradient_create2 },
+ { "nativePostCreate1", "(JFF[I[F)J", (void*)SweepGradient_postCreate1 },
+ { "nativePostCreate2", "(JFFII)J", (void*)SweepGradient_postCreate2 }
};
static JNINativeMethod gComposeShaderMethods[] = {
- { "nativeCreate1", "(III)I", (void*)ComposeShader_create1 },
- { "nativeCreate2", "(III)I", (void*)ComposeShader_create2 },
- { "nativePostCreate1", "(IIII)I", (void*)ComposeShader_postCreate1 },
- { "nativePostCreate2", "(IIII)I", (void*)ComposeShader_postCreate2 }
+ { "nativeCreate1", "(JJJ)J", (void*)ComposeShader_create1 },
+ { "nativeCreate2", "(JJI)J", (void*)ComposeShader_create2 },
+ { "nativePostCreate1", "(JJJJ)J", (void*)ComposeShader_postCreate1 },
+ { "nativePostCreate2", "(JJJI)J", (void*)ComposeShader_postCreate2 }
};
#include <android_runtime/AndroidRuntime.h>
diff --git a/core/jni/android/graphics/SurfaceTexture.cpp b/core/jni/android/graphics/SurfaceTexture.cpp
index 0c9b3bc..3116955 100644
--- a/core/jni/android/graphics/SurfaceTexture.cpp
+++ b/core/jni/android/graphics/SurfaceTexture.cpp
@@ -55,28 +55,28 @@
const sp<GLConsumer>& surfaceTexture)
{
GLConsumer* const p =
- (GLConsumer*)env->GetIntField(thiz, fields.surfaceTexture);
+ (GLConsumer*)env->GetLongField(thiz, fields.surfaceTexture);
if (surfaceTexture.get()) {
surfaceTexture->incStrong((void*)SurfaceTexture_setSurfaceTexture);
}
if (p) {
p->decStrong((void*)SurfaceTexture_setSurfaceTexture);
}
- env->SetIntField(thiz, fields.surfaceTexture, (int)surfaceTexture.get());
+ env->SetLongField(thiz, fields.surfaceTexture, (jlong)surfaceTexture.get());
}
static void SurfaceTexture_setBufferQueue(JNIEnv* env, jobject thiz,
const sp<BufferQueue>& bq)
{
BufferQueue* const p =
- (BufferQueue*)env->GetIntField(thiz, fields.bufferQueue);
+ (BufferQueue*)env->GetLongField(thiz, fields.bufferQueue);
if (bq.get()) {
bq->incStrong((void*)SurfaceTexture_setBufferQueue);
}
if (p) {
p->decStrong((void*)SurfaceTexture_setBufferQueue);
}
- env->SetIntField(thiz, fields.bufferQueue, (int)bq.get());
+ env->SetLongField(thiz, fields.bufferQueue, (jlong)bq.get());
}
static void SurfaceTexture_setFrameAvailableListener(JNIEnv* env,
@@ -84,22 +84,22 @@
{
GLConsumer::FrameAvailableListener* const p =
(GLConsumer::FrameAvailableListener*)
- env->GetIntField(thiz, fields.frameAvailableListener);
+ env->GetLongField(thiz, fields.frameAvailableListener);
if (listener.get()) {
listener->incStrong((void*)SurfaceTexture_setSurfaceTexture);
}
if (p) {
p->decStrong((void*)SurfaceTexture_setSurfaceTexture);
}
- env->SetIntField(thiz, fields.frameAvailableListener, (int)listener.get());
+ env->SetLongField(thiz, fields.frameAvailableListener, (jlong)listener.get());
}
sp<GLConsumer> SurfaceTexture_getSurfaceTexture(JNIEnv* env, jobject thiz) {
- return (GLConsumer*)env->GetIntField(thiz, fields.surfaceTexture);
+ return (GLConsumer*)env->GetLongField(thiz, fields.surfaceTexture);
}
sp<IGraphicBufferProducer> SurfaceTexture_getProducer(JNIEnv* env, jobject thiz) {
- return (BufferQueue*)env->GetIntField(thiz, fields.bufferQueue);
+ return (BufferQueue*)env->GetLongField(thiz, fields.bufferQueue);
}
sp<ANativeWindow> android_SurfaceTexture_getNativeWindow(JNIEnv* env, jobject thiz) {
@@ -201,19 +201,19 @@
static void SurfaceTexture_classInit(JNIEnv* env, jclass clazz)
{
fields.surfaceTexture = env->GetFieldID(clazz,
- ANDROID_GRAPHICS_SURFACETEXTURE_JNI_ID, "I");
+ ANDROID_GRAPHICS_SURFACETEXTURE_JNI_ID, "J");
if (fields.surfaceTexture == NULL) {
ALOGE("can't find android/graphics/SurfaceTexture.%s",
ANDROID_GRAPHICS_SURFACETEXTURE_JNI_ID);
}
fields.bufferQueue = env->GetFieldID(clazz,
- ANDROID_GRAPHICS_BUFFERQUEUE_JNI_ID, "I");
+ ANDROID_GRAPHICS_BUFFERQUEUE_JNI_ID, "J");
if (fields.bufferQueue == NULL) {
ALOGE("can't find android/graphics/SurfaceTexture.%s",
ANDROID_GRAPHICS_BUFFERQUEUE_JNI_ID);
}
fields.frameAvailableListener = env->GetFieldID(clazz,
- ANDROID_GRAPHICS_FRAMEAVAILABLELISTENER_JNI_ID, "I");
+ ANDROID_GRAPHICS_FRAMEAVAILABLELISTENER_JNI_ID, "J");
if (fields.frameAvailableListener == NULL) {
ALOGE("can't find android/graphics/SurfaceTexture.%s",
ANDROID_GRAPHICS_FRAMEAVAILABLELISTENER_JNI_ID);
diff --git a/core/jni/android/graphics/TextLayoutCache.cpp b/core/jni/android/graphics/TextLayoutCache.cpp
index 92d253f..e2c78b1 100644
--- a/core/jni/android/graphics/TextLayoutCache.cpp
+++ b/core/jni/android/graphics/TextLayoutCache.cpp
@@ -69,7 +69,7 @@
size_t totalSizeToDelete = text.getSize() + desc->getSize();
mSize -= totalSizeToDelete;
if (mDebugEnabled) {
- ALOGD("Cache value %p deleted, size = %d", desc.get(), totalSizeToDelete);
+ ALOGD("Cache value %p deleted, size = %zu", desc.get(), totalSizeToDelete);
}
}
@@ -129,7 +129,7 @@
bool removedOne = mCache.removeOldest();
LOG_ALWAYS_FATAL_IF(!removedOne, "The cache is non-empty but we "
"failed to remove the oldest entry. "
- "mSize = %u, size = %u, mMaxSize = %u, mCache.size() = %u",
+ "mSize = %u, size = %zu, mMaxSize = %u, mCache.size() = %zu",
mSize, size, mMaxSize, mCache.size());
}
}
@@ -148,7 +148,7 @@
nsecs_t totalTime = systemTime(SYSTEM_TIME_MONOTONIC) - startTime;
ALOGD("CACHE MISS: Added entry %p "
"with start = %d, count = %d, contextCount = %d, "
- "entry size %d bytes, remaining space %d bytes"
+ "entry size %zu bytes, remaining space %d bytes"
" - Compute time %0.6f ms - Put time %0.6f ms - Text = '%s'",
value.get(), start, count, contextCount, size, mMaxSize - mSize,
value->getElapsedTime() * 0.000001f,
@@ -159,7 +159,7 @@
if (mDebugEnabled) {
ALOGD("CACHE MISS: Calculated but not storing entry because it is too big "
"with start = %d, count = %d, contextCount = %d, "
- "entry size %d bytes, remaining space %d bytes"
+ "entry size %zu bytes, remaining space %d bytes"
" - Compute time %0.6f ms - Text = '%s'",
start, count, contextCount, size, mMaxSize - mSize,
value->getElapsedTime() * 0.000001f,
@@ -204,7 +204,7 @@
ALOGD("------------------------------------------------");
ALOGD("pid : %d", getpid());
ALOGD("running : %.0f seconds", timeRunningInSec);
- ALOGD("entries : %d", cacheSize);
+ ALOGD("entries : %zu", cacheSize);
ALOGD("max size : %d bytes", mMaxSize);
ALOGD("used : %d bytes according to mSize", mSize);
ALOGD("remaining : %d bytes or %2.2f percent", mMaxSize - mSize, remainingPercent);
diff --git a/core/jni/android/graphics/Typeface.cpp b/core/jni/android/graphics/Typeface.cpp
index ccd75d5..d096c2a 100644
--- a/core/jni/android/graphics/Typeface.cpp
+++ b/core/jni/android/graphics/Typeface.cpp
@@ -27,8 +27,9 @@
const char* fCStr;
};
-static SkTypeface* Typeface_create(JNIEnv* env, jobject, jstring name,
- SkTypeface::Style style) {
+static jlong Typeface_create(JNIEnv* env, jobject, jstring name,
+ jint styleHandle) {
+ SkTypeface::Style style = static_cast<SkTypeface::Style>(styleHandle);
SkTypeface* face = NULL;
if (NULL != name) {
@@ -47,10 +48,11 @@
if (NULL == face) {
face = SkTypeface::CreateFromName(NULL, style);
}
- return face;
+ return reinterpret_cast<jlong>(face);
}
-static SkTypeface* Typeface_createFromTypeface(JNIEnv* env, jobject, SkTypeface* family, int style) {
+static jlong Typeface_createFromTypeface(JNIEnv* env, jobject, jlong familyHandle, jint style) {
+ SkTypeface* family = reinterpret_cast<SkTypeface*>(familyHandle);
SkTypeface* face = SkTypeface::CreateFromTypeface(family, (SkTypeface::Style)style);
// Try to find the closest matching font, using the standard heuristic
if (NULL == face) {
@@ -62,15 +64,17 @@
if (NULL == face) {
face = SkTypeface::CreateFromName(NULL, (SkTypeface::Style)style);
}
- return face;
+ return reinterpret_cast<jlong>(face);
}
-static void Typeface_unref(JNIEnv* env, jobject obj, SkTypeface* face) {
+static void Typeface_unref(JNIEnv* env, jobject obj, jlong faceHandle) {
+ SkTypeface* face = reinterpret_cast<SkTypeface*>(faceHandle);
SkSafeUnref(face);
}
-static int Typeface_getStyle(JNIEnv* env, jobject obj, SkTypeface* face) {
- return face->style();
+static jint Typeface_getStyle(JNIEnv* env, jobject obj, jlong faceHandle) {
+ SkTypeface* face = reinterpret_cast<SkTypeface*>(faceHandle);
+ return static_cast<jint>(face->style());
}
class AssetStream : public SkStream {
@@ -132,9 +136,9 @@
const void* fMemoryBase;
};
-static SkTypeface* Typeface_createFromAsset(JNIEnv* env, jobject,
- jobject jassetMgr,
- jstring jpath) {
+static jlong Typeface_createFromAsset(JNIEnv* env, jobject,
+ jobject jassetMgr,
+ jstring jpath) {
NPE_CHECK_RETURN_ZERO(env, jassetMgr);
NPE_CHECK_RETURN_ZERO(env, jpath);
@@ -156,27 +160,27 @@
// need to unref it here or it won't be freed later on
stream->unref();
- return face;
+ return reinterpret_cast<jlong>(face);
}
-static SkTypeface* Typeface_createFromFile(JNIEnv* env, jobject, jstring jpath) {
+static jlong Typeface_createFromFile(JNIEnv* env, jobject, jstring jpath) {
NPE_CHECK_RETURN_ZERO(env, jpath);
AutoJavaStringToUTF8 str(env, jpath);
- return SkTypeface::CreateFromFile(str.c_str());
+ return reinterpret_cast<jlong>(SkTypeface::CreateFromFile(str.c_str()));
}
///////////////////////////////////////////////////////////////////////////////
static JNINativeMethod gTypefaceMethods[] = {
- { "nativeCreate", "(Ljava/lang/String;I)I", (void*)Typeface_create },
- { "nativeCreateFromTypeface", "(II)I", (void*)Typeface_createFromTypeface },
- { "nativeUnref", "(I)V", (void*)Typeface_unref },
- { "nativeGetStyle", "(I)I", (void*)Typeface_getStyle },
- { "nativeCreateFromAsset", "(Landroid/content/res/AssetManager;Ljava/lang/String;)I",
+ { "nativeCreate", "(Ljava/lang/String;I)J", (void*)Typeface_create },
+ { "nativeCreateFromTypeface", "(JI)J", (void*)Typeface_createFromTypeface },
+ { "nativeUnref", "(J)V", (void*)Typeface_unref },
+ { "nativeGetStyle", "(J)I", (void*)Typeface_getStyle },
+ { "nativeCreateFromAsset", "(Landroid/content/res/AssetManager;Ljava/lang/String;)J",
(void*)Typeface_createFromAsset },
- { "nativeCreateFromFile", "(Ljava/lang/String;)I",
+ { "nativeCreateFromFile", "(Ljava/lang/String;)J",
(void*)Typeface_createFromFile },
};
diff --git a/core/jni/android/graphics/Xfermode.cpp b/core/jni/android/graphics/Xfermode.cpp
index 976a91f..eedceb7 100644
--- a/core/jni/android/graphics/Xfermode.cpp
+++ b/core/jni/android/graphics/Xfermode.cpp
@@ -26,35 +26,37 @@
class SkXfermodeGlue {
public:
- static void finalizer(JNIEnv* env, jobject, SkXfermode* obj)
+ static void finalizer(JNIEnv* env, jobject, jlong objHandle)
{
+ SkXfermode* obj = reinterpret_cast<SkXfermode *>(objHandle);
SkSafeUnref(obj);
}
- static SkXfermode* avoid_create(JNIEnv* env, jobject, SkColor opColor,
- U8CPU tolerance, SkAvoidXfermode::Mode mode)
+ static jlong avoid_create(JNIEnv* env, jobject, jint opColor,
+ jint tolerance, jint modeHandle)
{
- return new SkAvoidXfermode(opColor, tolerance, mode);
+ SkAvoidXfermode::Mode mode = static_cast<SkAvoidXfermode::Mode>(modeHandle);
+ return reinterpret_cast<jlong>(new SkAvoidXfermode(opColor, tolerance, mode));
}
-
- static SkXfermode* pixelxor_create(JNIEnv* env, jobject, SkColor opColor)
+
+ static jlong pixelxor_create(JNIEnv* env, jobject, jint opColor)
{
- return new SkPixelXorXfermode(opColor);
+ return reinterpret_cast<jlong>(new SkPixelXorXfermode(opColor));
}
};
///////////////////////////////////////////////////////////////////////////////
static JNINativeMethod gXfermodeMethods[] = {
- {"finalizer", "(I)V", (void*) SkXfermodeGlue::finalizer}
+ {"finalizer", "(J)V", (void*) SkXfermodeGlue::finalizer}
};
static JNINativeMethod gAvoidMethods[] = {
- {"nativeCreate", "(III)I", (void*) SkXfermodeGlue::avoid_create}
+ {"nativeCreate", "(III)J", (void*) SkXfermodeGlue::avoid_create}
};
static JNINativeMethod gPixelXorMethods[] = {
- {"nativeCreate", "(I)I", (void*) SkXfermodeGlue::pixelxor_create}
+ {"nativeCreate", "(I)J", (void*) SkXfermodeGlue::pixelxor_create}
};
#include <android_runtime/AndroidRuntime.h>
diff --git a/core/jni/android/graphics/YuvToJpegEncoder.cpp b/core/jni/android/graphics/YuvToJpegEncoder.cpp
index f386905..799782d 100644
--- a/core/jni/android/graphics/YuvToJpegEncoder.cpp
+++ b/core/jni/android/graphics/YuvToJpegEncoder.cpp
@@ -217,8 +217,8 @@
///////////////////////////////////////////////////////////////////////////////
static jboolean YuvImage_compressToJpeg(JNIEnv* env, jobject, jbyteArray inYuv,
- int format, int width, int height, jintArray offsets,
- jintArray strides, int jpegQuality, jobject jstream,
+ jint format, jint width, jint height, jintArray offsets,
+ jintArray strides, jint jpegQuality, jobject jstream,
jbyteArray jstorage) {
jbyte* yuv = env->GetByteArrayElements(inYuv, NULL);
SkWStream* strm = CreateJavaOutputStreamAdaptor(env, jstream, jstorage);
@@ -227,7 +227,7 @@
jint* imgStrides = env->GetIntArrayElements(strides, NULL);
YuvToJpegEncoder* encoder = YuvToJpegEncoder::create(format, imgStrides);
if (encoder == NULL) {
- return false;
+ return JNI_FALSE;
}
encoder->encode(strm, yuv, width, height, imgOffsets, jpegQuality);
@@ -235,7 +235,7 @@
env->ReleaseByteArrayElements(inYuv, yuv, 0);
env->ReleaseIntArrayElements(offsets, imgOffsets, 0);
env->ReleaseIntArrayElements(strides, imgStrides, 0);
- return true;
+ return JNI_TRUE;
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/core/jni/android/graphics/pdf/PdfDocument.cpp b/core/jni/android/graphics/pdf/PdfDocument.cpp
index 6175a8f..d54aaa8 100644
--- a/core/jni/android/graphics/pdf/PdfDocument.cpp
+++ b/core/jni/android/graphics/pdf/PdfDocument.cpp
@@ -113,24 +113,24 @@
PageRecord* mCurrentPage;
};
-static jint nativeCreateDocument(JNIEnv* env, jobject thiz) {
- return reinterpret_cast<jint>(new PdfDocument());
+static jlong nativeCreateDocument(JNIEnv* env, jobject thiz) {
+ return reinterpret_cast<jlong>(new PdfDocument());
}
-static jint nativeStartPage(JNIEnv* env, jobject thiz, jint documentPtr,
+static jlong nativeStartPage(JNIEnv* env, jobject thiz, jlong documentPtr,
jint pageWidth, jint pageHeight,
jint contentLeft, jint contentTop, jint contentRight, jint contentBottom) {
PdfDocument* document = reinterpret_cast<PdfDocument*>(documentPtr);
- return reinterpret_cast<jint>(document->startPage(pageWidth, pageHeight,
+ return reinterpret_cast<jlong>(document->startPage(pageWidth, pageHeight,
contentLeft, contentTop, contentRight, contentBottom));
}
-static void nativeFinishPage(JNIEnv* env, jobject thiz, jint documentPtr) {
+static void nativeFinishPage(JNIEnv* env, jobject thiz, jlong documentPtr) {
PdfDocument* document = reinterpret_cast<PdfDocument*>(documentPtr);
document->finishPage();
}
-static void nativeWriteTo(JNIEnv* env, jobject thiz, jint documentPtr, jobject out,
+static void nativeWriteTo(JNIEnv* env, jobject thiz, jlong documentPtr, jobject out,
jbyteArray chunk) {
PdfDocument* document = reinterpret_cast<PdfDocument*>(documentPtr);
SkWStream* skWStream = CreateJavaOutputStreamAdaptor(env, out, chunk);
@@ -138,17 +138,17 @@
delete skWStream;
}
-static void nativeClose(JNIEnv* env, jobject thiz, jint documentPtr) {
+static void nativeClose(JNIEnv* env, jobject thiz, jlong documentPtr) {
PdfDocument* document = reinterpret_cast<PdfDocument*>(documentPtr);
document->close();
}
static JNINativeMethod gPdfDocument_Methods[] = {
- {"nativeCreateDocument", "()I", (void*) nativeCreateDocument},
- {"nativeStartPage", "(IIIIIII)I", (void*) nativeStartPage},
- {"nativeFinishPage", "(I)V", (void*) nativeFinishPage},
- {"nativeWriteTo", "(ILjava/io/OutputStream;[B)V", (void*) nativeWriteTo},
- {"nativeClose", "(I)V", (void*) nativeClose}
+ {"nativeCreateDocument", "()J", (void*) nativeCreateDocument},
+ {"nativeStartPage", "(JIIIIII)J", (void*) nativeStartPage},
+ {"nativeFinishPage", "(J)V", (void*) nativeFinishPage},
+ {"nativeWriteTo", "(JLjava/io/OutputStream;[B)V", (void*) nativeWriteTo},
+ {"nativeClose", "(J)V", (void*) nativeClose}
};
int register_android_graphics_pdf_PdfDocument(JNIEnv* env) {
diff --git a/core/jni/android/opengl/util.cpp b/core/jni/android/opengl/util.cpp
index 44af199..48367ff 100644
--- a/core/jni/android/opengl/util.cpp
+++ b/core/jni/android/opengl/util.cpp
@@ -389,7 +389,7 @@
}
static
-int util_frustumCullSpheres(JNIEnv *env, jclass clazz,
+jint util_frustumCullSpheres(JNIEnv *env, jclass clazz,
jfloatArray mvp_ref, jint mvpOffset,
jfloatArray spheres_ref, jint spheresOffset, jint spheresCount,
jintArray results_ref, jint resultsOffset, jint resultsCapacity) {
@@ -436,7 +436,7 @@
*/
static
-int util_visibilityTest(JNIEnv *env, jclass clazz,
+jint util_visibilityTest(JNIEnv *env, jclass clazz,
jfloatArray ws_ref, jint wsOffset,
jfloatArray positions_ref, jint positionsOffset,
jcharArray indices_ref, jint indicesOffset, jint indexCount) {
@@ -553,7 +553,7 @@
void nativeUtilsClassInit(JNIEnv *env, jclass clazz)
{
jclass bitmapClass = env->FindClass("android/graphics/Bitmap");
- nativeBitmapID = env->GetFieldID(bitmapClass, "mNativeBitmap", "I");
+ nativeBitmapID = env->GetFieldID(bitmapClass, "mNativeBitmap", "J");
}
extern void setGLDebugLevel(int level);
@@ -630,7 +630,7 @@
jobject jbitmap)
{
SkBitmap const * nativeBitmap =
- (SkBitmap const *)env->GetIntField(jbitmap, nativeBitmapID);
+ (SkBitmap const *)env->GetLongField(jbitmap, nativeBitmapID);
const SkBitmap& bitmap(*nativeBitmap);
SkBitmap::Config config = bitmap.getConfig();
return getInternalFormat(config);
@@ -640,7 +640,7 @@
jobject jbitmap)
{
SkBitmap const * nativeBitmap =
- (SkBitmap const *)env->GetIntField(jbitmap, nativeBitmapID);
+ (SkBitmap const *)env->GetLongField(jbitmap, nativeBitmapID);
const SkBitmap& bitmap(*nativeBitmap);
SkBitmap::Config config = bitmap.getConfig();
return getType(config);
@@ -651,7 +651,7 @@
jobject jbitmap, jint type, jint border)
{
SkBitmap const * nativeBitmap =
- (SkBitmap const *)env->GetIntField(jbitmap, nativeBitmapID);
+ (SkBitmap const *)env->GetLongField(jbitmap, nativeBitmapID);
const SkBitmap& bitmap(*nativeBitmap);
SkBitmap::Config config = bitmap.getConfig();
if (internalformat < 0) {
@@ -700,7 +700,7 @@
jobject jbitmap, jint format, jint type)
{
SkBitmap const * nativeBitmap =
- (SkBitmap const *)env->GetIntField(jbitmap, nativeBitmapID);
+ (SkBitmap const *)env->GetLongField(jbitmap, nativeBitmapID);
const SkBitmap& bitmap(*nativeBitmap);
SkBitmap::Config config = bitmap.getConfig();
if (format < 0) {
@@ -773,7 +773,7 @@
pointer = _env->CallStaticLongMethod(nioAccessClass,
getBasePointerID, buffer);
if (pointer != 0L) {
- return (void *) (jint) pointer;
+ return reinterpret_cast<void *>(pointer);
}
return NULL;
}
@@ -974,7 +974,7 @@
result = etc1_pkm_is_valid((etc1_byte*) headerB.getData());
}
}
- return result;
+ return result ? JNI_TRUE : JNI_FALSE;
}
/**
@@ -997,7 +997,7 @@
/**
* Read the image height from a PKM header
*/
-static int etc1_getHeight(JNIEnv *env, jclass clazz,
+static jint etc1_getHeight(JNIEnv *env, jclass clazz,
jobject header) {
jint result = 0;
BufferHelper headerB(env, header);
diff --git a/core/jni/android_animation_PropertyValuesHolder.cpp b/core/jni/android_animation_PropertyValuesHolder.cpp
index 5991805..1e3ec18 100644
--- a/core/jni/android_animation_PropertyValuesHolder.cpp
+++ b/core/jni/android_animation_PropertyValuesHolder.cpp
@@ -29,44 +29,44 @@
const char* const kClassPathName = "android/animation/PropertyValuesHolder";
-static jmethodID android_animation_PropertyValuesHolder_getIntMethod(
+static jlong android_animation_PropertyValuesHolder_getIntMethod(
JNIEnv* env, jclass pvhClass, jclass targetClass, jstring methodName)
{
const char *nativeString = env->GetStringUTFChars(methodName, 0);
jmethodID mid = env->GetMethodID(targetClass, nativeString, "(I)V");
env->ReleaseStringUTFChars(methodName, nativeString);
- return mid;
+ return reinterpret_cast<jlong>(mid);
}
-static jmethodID android_animation_PropertyValuesHolder_getFloatMethod(
+static jlong android_animation_PropertyValuesHolder_getFloatMethod(
JNIEnv* env, jclass pvhClass, jclass targetClass, jstring methodName)
{
const char *nativeString = env->GetStringUTFChars(methodName, 0);
jmethodID mid = env->GetMethodID(targetClass, nativeString, "(F)V");
env->ReleaseStringUTFChars(methodName, nativeString);
- return mid;
+ return reinterpret_cast<jlong>(mid);
}
static void android_animation_PropertyValuesHolder_callIntMethod(
- JNIEnv* env, jclass pvhObject, jobject target, jmethodID methodID, int arg)
+ JNIEnv* env, jclass pvhObject, jobject target, jlong methodID, jint arg)
{
- env->CallVoidMethod(target, methodID, arg);
+ env->CallVoidMethod(target, reinterpret_cast<jmethodID>(methodID), arg);
}
static void android_animation_PropertyValuesHolder_callFloatMethod(
- JNIEnv* env, jclass pvhObject, jobject target, jmethodID methodID, float arg)
+ JNIEnv* env, jclass pvhObject, jobject target, jlong methodID, jfloat arg)
{
- env->CallVoidMethod(target, methodID, arg);
+ env->CallVoidMethod(target, reinterpret_cast<jmethodID>(methodID), arg);
}
static JNINativeMethod gMethods[] = {
- { "nGetIntMethod", "(Ljava/lang/Class;Ljava/lang/String;)I",
+ { "nGetIntMethod", "(Ljava/lang/Class;Ljava/lang/String;)J",
(void*)android_animation_PropertyValuesHolder_getIntMethod },
- { "nGetFloatMethod", "(Ljava/lang/Class;Ljava/lang/String;)I",
+ { "nGetFloatMethod", "(Ljava/lang/Class;Ljava/lang/String;)J",
(void*)android_animation_PropertyValuesHolder_getFloatMethod },
- { "nCallIntMethod", "(Ljava/lang/Object;II)V",
+ { "nCallIntMethod", "(Ljava/lang/Object;JI)V",
(void*)android_animation_PropertyValuesHolder_callIntMethod },
- { "nCallFloatMethod", "(Ljava/lang/Object;IF)V",
+ { "nCallFloatMethod", "(Ljava/lang/Object;JF)V",
(void*)android_animation_PropertyValuesHolder_callFloatMethod }
};
diff --git a/core/jni/android_content_res_Configuration.cpp b/core/jni/android_content_res_Configuration.cpp
index 246e3bd..201ffe8 100644
--- a/core/jni/android_content_res_Configuration.cpp
+++ b/core/jni/android_content_res_Configuration.cpp
@@ -70,15 +70,6 @@
gConfigurationClassInfo.smallestScreenWidthDp);
}
-/*
- * JNI registration.
- */
-static JNINativeMethod gMethods[] = {
- /* name, signature, funcPtr */
- //{ "getObbInfo_native", "(Ljava/lang/String;Landroid/content/res/ObbInfo;)Z",
- // (void*) android_content_res_ObbScanner_getObbInfo },
-};
-
#define FIND_CLASS(var, className) \
var = env->FindClass(className); \
LOG_FATAL_IF(! var, "Unable to find class " className);
@@ -123,8 +114,7 @@
GET_FIELD_ID(gConfigurationClassInfo.smallestScreenWidthDp, clazz,
"smallestScreenWidthDp", "I");
- return AndroidRuntime::registerNativeMethods(env, "android/content/res/Configuration", gMethods,
- NELEM(gMethods));
+ return 0;
}
}; // namespace android
diff --git a/core/jni/android_database_SQLiteGlobal.cpp b/core/jni/android_database_SQLiteGlobal.cpp
index acc2276..89d64fa 100644
--- a/core/jni/android_database_SQLiteGlobal.cpp
+++ b/core/jni/android_database_SQLiteGlobal.cpp
@@ -39,7 +39,7 @@
bool verboseLog = !!data;
if (iErrCode == 0 || iErrCode == SQLITE_CONSTRAINT || iErrCode == SQLITE_SCHEMA) {
if (verboseLog) {
- ALOGV(LOG_VERBOSE, SQLITE_LOG_TAG, "(%d) %s\n", iErrCode, zMsg);
+ ALOG(LOG_VERBOSE, SQLITE_LOG_TAG, "(%d) %s\n", iErrCode, zMsg);
}
} else {
ALOG(LOG_ERROR, SQLITE_LOG_TAG, "(%d) %s\n", iErrCode, zMsg);
diff --git a/core/jni/android_debug_JNITest.cpp b/core/jni/android_debug_JNITest.cpp
deleted file mode 100644
index 9147284..0000000
--- a/core/jni/android_debug_JNITest.cpp
+++ /dev/null
@@ -1,119 +0,0 @@
-/* //device/libs/android_runtime/android_debug_JNITest.cpp
-**
-** Copyright 2006, The Android Open Source Project
-**
-** Licensed under the Apache License, Version 2.0 (the "License");
-** you may not use this file except in compliance with the License.
-** You may obtain a copy of the License at
-**
-** http://www.apache.org/licenses/LICENSE-2.0
-**
-** Unless required by applicable law or agreed to in writing, software
-** distributed under the License is distributed on an "AS IS" BASIS,
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-** See the License for the specific language governing permissions and
-** limitations under the License.
-*/
-
-#define LOG_TAG "DebugJNI"
-
-#include "jni.h"
-#include "nativehelper/JNIHelp.h"
-#include "utils/Log.h"
-#include "utils/misc.h"
-//#include "android_runtime/AndroidRuntime.h"
-
-namespace android {
-
-/*
- * Implements:
- * native int part1(int intArg, double doubleArg, String stringArg,
- * int[] arrayArg)
- */
-static jint android_debug_JNITest_part1(JNIEnv* env, jobject object,
- jint intArg, jdouble doubleArg, jstring stringArg, jobjectArray arrayArg)
-{
- jclass clazz;
- jmethodID part2id;
- jsize arrayLen;
- jint arrayVal;
- int result = -2;
-
- ALOGI("JNI test: in part1, intArg=%d, doubleArg=%.3f\n", intArg, doubleArg);
-
- /* find "int part2(double doubleArg, int fromArray, String stringArg)" */
- clazz = env->GetObjectClass(object);
- part2id = env->GetMethodID(clazz,
- "part2", "(DILjava/lang/String;)I");
- if (part2id == NULL) {
- ALOGE("JNI test: unable to find part2\n");
- return -1;
- }
-
- /* get the length of the array */
- arrayLen = env->GetArrayLength(arrayArg);
- ALOGI(" array size is %d\n", arrayLen);
-
- /*
- * Get the last element in the array.
- * Use the Get<type>ArrayElements functions instead if you need access
- * to multiple elements.
- */
- arrayVal = (int) env->GetObjectArrayElement(arrayArg, arrayLen-1);
- ALOGI(" array val is %d\n", arrayVal);
-
- /* call this->part2 */
- result = env->CallIntMethod(object, part2id,
- doubleArg, arrayVal, stringArg);
-
- return result;
-}
-
-/*
- * Implements:
- * private static native int part3(String stringArg);
- */
-static jint android_debug_JNITest_part3(JNIEnv* env, jclass clazz,
- jstring stringArg)
-{
- const char* utfChars;
- jboolean isCopy;
-
- ALOGI("JNI test: in part3\n");
-
- utfChars = env->GetStringUTFChars(stringArg, &isCopy);
-
- ALOGI(" String is '%s', isCopy=%d\n", (const char*) utfChars, isCopy);
-
- env->ReleaseStringUTFChars(stringArg, utfChars);
-
- return 2000;
-}
-
-/*
- * JNI registration.
- */
-static JNINativeMethod gMethods[] = {
- /* name, signature, funcPtr */
- { "part1", "(IDLjava/lang/String;[I)I",
- (void*) android_debug_JNITest_part1 },
- { "part3", "(Ljava/lang/String;)I",
- (void*) android_debug_JNITest_part3 },
-};
-int register_android_debug_JNITest(JNIEnv* env)
-{
- return jniRegisterNativeMethods(env, "android/debug/JNITest",
- gMethods, NELEM(gMethods));
-}
-
-#if 0
-/* trampoline into C++ */
-extern "C"
-int register_android_debug_JNITest_C(JNIEnv* env)
-{
- return android::register_android_debug_JNITest(env);
-}
-#endif
-
-}; // namespace android
-
diff --git a/core/jni/android_emoji_EmojiFactory.cpp b/core/jni/android_emoji_EmojiFactory.cpp
index 5276934..f127d29 100644
--- a/core/jni/android_emoji_EmojiFactory.cpp
+++ b/core/jni/android_emoji_EmojiFactory.cpp
@@ -104,7 +104,7 @@
static jobject create_java_EmojiFactory(
JNIEnv* env, EmojiFactory* factory, jstring name) {
jobject obj = env->NewObject(gEmojiFactory_class, gEmojiFactory_constructorMethodID,
- static_cast<jint>(reinterpret_cast<uintptr_t>(factory)), name);
+ reinterpret_cast<jlong>(factory), name);
if (env->ExceptionCheck() != 0) {
ALOGE("*** Uncaught exception returned from Java call!\n");
env->ExceptionDescribe();
@@ -155,7 +155,7 @@
}
static jobject android_emoji_EmojiFactory_getBitmapFromAndroidPua(
- JNIEnv* env, jobject clazz, jint nativeEmojiFactory, jint pua) {
+ JNIEnv* env, jobject clazz, jlong nativeEmojiFactory, jint pua) {
EmojiFactory *factory = reinterpret_cast<EmojiFactory *>(nativeEmojiFactory);
int size;
@@ -175,7 +175,7 @@
}
static void android_emoji_EmojiFactory_destructor(
- JNIEnv* env, jobject obj, jint nativeEmojiFactory) {
+ JNIEnv* env, jobject obj, jlong nativeEmojiFactory) {
/*
// Must not delete this object!!
EmojiFactory *factory = reinterpret_cast<EmojiFactory *>(nativeEmojiFactory);
@@ -184,49 +184,49 @@
}
static jint android_emoji_EmojiFactory_getAndroidPuaFromVendorSpecificSjis(
- JNIEnv* env, jobject obj, jint nativeEmojiFactory, jchar sjis) {
+ JNIEnv* env, jobject obj, jlong nativeEmojiFactory, jchar sjis) {
EmojiFactory *factory = reinterpret_cast<EmojiFactory *>(nativeEmojiFactory);
return factory->GetAndroidPuaFromVendorSpecificSjis(sjis);
}
static jint android_emoji_EmojiFactory_getVendorSpecificSjisFromAndroidPua(
- JNIEnv* env, jobject obj, jint nativeEmojiFactory, jint pua) {
+ JNIEnv* env, jobject obj, jlong nativeEmojiFactory, jint pua) {
EmojiFactory *factory = reinterpret_cast<EmojiFactory *>(nativeEmojiFactory);
return factory->GetVendorSpecificSjisFromAndroidPua(pua);
}
static jint android_emoji_EmojiFactory_getAndroidPuaFromVendorSpecificPua(
- JNIEnv* env, jobject obj, jint nativeEmojiFactory, jint vsu) {
+ JNIEnv* env, jobject obj, jlong nativeEmojiFactory, jint vsu) {
EmojiFactory *factory = reinterpret_cast<EmojiFactory *>(nativeEmojiFactory);
return factory->GetAndroidPuaFromVendorSpecificPua(vsu);
}
static jint android_emoji_EmojiFactory_getVendorSpecificPuaFromAndroidPua(
- JNIEnv* env, jobject obj, jint nativeEmojiFactory, jint pua) {
+ JNIEnv* env, jobject obj, jlong nativeEmojiFactory, jint pua) {
EmojiFactory *factory = reinterpret_cast<EmojiFactory *>(nativeEmojiFactory);
return factory->GetVendorSpecificPuaFromAndroidPua(pua);
}
static jint android_emoji_EmojiFactory_getMaximumVendorSpecificPua(
- JNIEnv* env, jobject obj, jint nativeEmojiFactory) {
+ JNIEnv* env, jobject obj, jlong nativeEmojiFactory) {
EmojiFactory *factory = reinterpret_cast<EmojiFactory *>(nativeEmojiFactory);
return factory->GetMaximumVendorSpecificPua();
}
static jint android_emoji_EmojiFactory_getMinimumVendorSpecificPua(
- JNIEnv* env, jobject obj, jint nativeEmojiFactory) {
+ JNIEnv* env, jobject obj, jlong nativeEmojiFactory) {
EmojiFactory *factory = reinterpret_cast<EmojiFactory *>(nativeEmojiFactory);
return factory->GetMinimumVendorSpecificPua();
}
static jint android_emoji_EmojiFactory_getMaximumAndroidPua(
- JNIEnv* env, jobject obj, jint nativeEmojiFactory) {
+ JNIEnv* env, jobject obj, jlong nativeEmojiFactory) {
EmojiFactory *factory = reinterpret_cast<EmojiFactory *>(nativeEmojiFactory);
return factory->GetMaximumAndroidPua();
}
static jint android_emoji_EmojiFactory_getMinimumAndroidPua(
- JNIEnv* env, jobject obj, jint nativeEmojiFactory) {
+ JNIEnv* env, jobject obj, jlong nativeEmojiFactory) {
EmojiFactory *factory = reinterpret_cast<EmojiFactory *>(nativeEmojiFactory);
return factory->GetMinimumAndroidPua();
}
@@ -236,25 +236,25 @@
(void*)android_emoji_EmojiFactory_newInstance},
{ "newAvailableInstance", "()Landroid/emoji/EmojiFactory;",
(void*)android_emoji_EmojiFactory_newAvailableInstance},
- { "nativeDestructor", "(I)V",
+ { "nativeDestructor", "(J)V",
(void*)android_emoji_EmojiFactory_destructor},
- { "nativeGetBitmapFromAndroidPua", "(II)Landroid/graphics/Bitmap;",
+ { "nativeGetBitmapFromAndroidPua", "(JI)Landroid/graphics/Bitmap;",
(void*)android_emoji_EmojiFactory_getBitmapFromAndroidPua},
- { "nativeGetAndroidPuaFromVendorSpecificSjis", "(IC)I",
+ { "nativeGetAndroidPuaFromVendorSpecificSjis", "(JC)I",
(void*)android_emoji_EmojiFactory_getAndroidPuaFromVendorSpecificSjis},
- { "nativeGetVendorSpecificSjisFromAndroidPua", "(II)I",
+ { "nativeGetVendorSpecificSjisFromAndroidPua", "(JI)I",
(void*)android_emoji_EmojiFactory_getVendorSpecificSjisFromAndroidPua},
- { "nativeGetAndroidPuaFromVendorSpecificPua", "(II)I",
+ { "nativeGetAndroidPuaFromVendorSpecificPua", "(JI)I",
(void*)android_emoji_EmojiFactory_getAndroidPuaFromVendorSpecificPua},
- { "nativeGetVendorSpecificPuaFromAndroidPua", "(II)I",
+ { "nativeGetVendorSpecificPuaFromAndroidPua", "(JI)I",
(void*)android_emoji_EmojiFactory_getVendorSpecificPuaFromAndroidPua},
- { "nativeGetMaximumVendorSpecificPua", "(I)I",
+ { "nativeGetMaximumVendorSpecificPua", "(J)I",
(void*)android_emoji_EmojiFactory_getMaximumVendorSpecificPua},
- { "nativeGetMinimumVendorSpecificPua", "(I)I",
+ { "nativeGetMinimumVendorSpecificPua", "(J)I",
(void*)android_emoji_EmojiFactory_getMinimumVendorSpecificPua},
- { "nativeGetMaximumAndroidPua", "(I)I",
+ { "nativeGetMaximumAndroidPua", "(J)I",
(void*)android_emoji_EmojiFactory_getMaximumAndroidPua},
- { "nativeGetMinimumAndroidPua", "(I)I",
+ { "nativeGetMinimumAndroidPua", "(J)I",
(void*)android_emoji_EmojiFactory_getMinimumAndroidPua}
};
@@ -276,7 +276,7 @@
int register_android_emoji_EmojiFactory(JNIEnv* env) {
gEmojiFactory_class = make_globalref(env, "android/emoji/EmojiFactory");
gEmojiFactory_constructorMethodID = env->GetMethodID(
- gEmojiFactory_class, "<init>", "(ILjava/lang/String;)V");
+ gEmojiFactory_class, "<init>", "(JLjava/lang/String;)V");
return jniRegisterNativeMethods(env, "android/emoji/EmojiFactory",
gMethods, NELEM(gMethods));
}
diff --git a/core/jni/android_media_AudioRecord.cpp b/core/jni/android_media_AudioRecord.cpp
index 1c43cc5..ab70f25 100644
--- a/core/jni/android_media_AudioRecord.cpp
+++ b/core/jni/android_media_AudioRecord.cpp
@@ -18,6 +18,7 @@
#define LOG_TAG "AudioRecord-JNI"
+#include <inttypes.h>
#include <jni.h>
#include <JNIHelp.h>
#include <android_runtime/AndroidRuntime.h>
@@ -136,7 +137,7 @@
{
Mutex::Autolock l(sLock);
AudioRecord* const ar =
- (AudioRecord*)env->GetIntField(thiz, javaAudioRecordFields.nativeRecorderInJavaObj);
+ (AudioRecord*)env->GetLongField(thiz, javaAudioRecordFields.nativeRecorderInJavaObj);
return sp<AudioRecord>(ar);
}
@@ -144,19 +145,19 @@
{
Mutex::Autolock l(sLock);
sp<AudioRecord> old =
- (AudioRecord*)env->GetIntField(thiz, javaAudioRecordFields.nativeRecorderInJavaObj);
+ (AudioRecord*)env->GetLongField(thiz, javaAudioRecordFields.nativeRecorderInJavaObj);
if (ar.get()) {
ar->incStrong((void*)setAudioRecord);
}
if (old != 0) {
old->decStrong((void*)setAudioRecord);
}
- env->SetIntField(thiz, javaAudioRecordFields.nativeRecorderInJavaObj, (int)ar.get());
+ env->SetLongField(thiz, javaAudioRecordFields.nativeRecorderInJavaObj, (jlong)ar.get());
return old;
}
// ----------------------------------------------------------------------------
-static int
+static jint
android_media_AudioRecord_setup(JNIEnv *env, jobject thiz, jobject weak_this,
jint source, jint sampleRateInHertz, jint channelMask,
// Java channel masks map directly to the native definition
@@ -168,7 +169,7 @@
if (!audio_is_input_channel(channelMask)) {
ALOGE("Error creating AudioRecord: channel mask %#x is not valid.", channelMask);
- return AUDIORECORD_ERROR_SETUP_INVALIDCHANNELMASK;
+ return (jint) AUDIORECORD_ERROR_SETUP_INVALIDCHANNELMASK;
}
uint32_t nbChannels = popcount(channelMask);
@@ -176,7 +177,7 @@
if ((audioFormat != ENCODING_PCM_16BIT)
&& (audioFormat != ENCODING_PCM_8BIT)) {
ALOGE("Error creating AudioRecord: unsupported audio format.");
- return AUDIORECORD_ERROR_SETUP_INVALIDFORMAT;
+ return (jint) AUDIORECORD_ERROR_SETUP_INVALIDFORMAT;
}
int bytesPerSample = audioFormat == ENCODING_PCM_16BIT ? 2 : 1;
@@ -185,31 +186,31 @@
if (buffSizeInBytes == 0) {
ALOGE("Error creating AudioRecord: frameCount is 0.");
- return AUDIORECORD_ERROR_SETUP_ZEROFRAMECOUNT;
+ return (jint) AUDIORECORD_ERROR_SETUP_ZEROFRAMECOUNT;
}
int frameSize = nbChannels * bytesPerSample;
size_t frameCount = buffSizeInBytes / frameSize;
if ((uint32_t(source) >= AUDIO_SOURCE_CNT) && (uint32_t(source) != AUDIO_SOURCE_HOTWORD)) {
ALOGE("Error creating AudioRecord: unknown source.");
- return AUDIORECORD_ERROR_SETUP_INVALIDSOURCE;
+ return (jint) AUDIORECORD_ERROR_SETUP_INVALIDSOURCE;
}
jclass clazz = env->GetObjectClass(thiz);
if (clazz == NULL) {
ALOGE("Can't find %s when setting up callback.", kClassPathName);
- return AUDIORECORD_ERROR_SETUP_NATIVEINITFAILED;
+ return (jint) AUDIORECORD_ERROR_SETUP_NATIVEINITFAILED;
}
if (jSession == NULL) {
ALOGE("Error creating AudioRecord: invalid session ID pointer");
- return AUDIORECORD_ERROR;
+ return (jint) AUDIORECORD_ERROR;
}
jint* nSession = (jint *) env->GetPrimitiveArrayCritical(jSession, NULL);
if (nSession == NULL) {
ALOGE("Error creating AudioRecord: Error retrieving session id pointer");
- return AUDIORECORD_ERROR;
+ return (jint) AUDIORECORD_ERROR;
}
int sessionId = nSession[0];
env->ReleasePrimitiveArrayCritical(jSession, nSession, 0);
@@ -262,33 +263,33 @@
// save our newly created callback information in the "nativeCallbackCookie" field
// of the Java object (in mNativeCallbackCookie) so we can free the memory in finalize()
- env->SetIntField(thiz, javaAudioRecordFields.nativeCallbackCookie, (int)lpCallbackData);
+ env->SetLongField(thiz, javaAudioRecordFields.nativeCallbackCookie, (jlong)lpCallbackData);
- return AUDIORECORD_SUCCESS;
+ return (jint) AUDIORECORD_SUCCESS;
// failure:
native_init_failure:
env->DeleteGlobalRef(lpCallbackData->audioRecord_class);
env->DeleteGlobalRef(lpCallbackData->audioRecord_ref);
delete lpCallbackData;
- env->SetIntField(thiz, javaAudioRecordFields.nativeCallbackCookie, 0);
+ env->SetLongField(thiz, javaAudioRecordFields.nativeCallbackCookie, 0);
- return AUDIORECORD_ERROR_SETUP_NATIVEINITFAILED;
+ return (jint) AUDIORECORD_ERROR_SETUP_NATIVEINITFAILED;
}
// ----------------------------------------------------------------------------
-static int
+static jint
android_media_AudioRecord_start(JNIEnv *env, jobject thiz, jint event, jint triggerSession)
{
sp<AudioRecord> lpRecorder = getAudioRecord(env, thiz);
if (lpRecorder == NULL ) {
jniThrowException(env, "java/lang/IllegalStateException", NULL);
- return AUDIORECORD_ERROR;
+ return (jint) AUDIORECORD_ERROR;
}
- return android_media_translateRecorderErrorCode(
+ return (jint) android_media_translateRecorderErrorCode(
lpRecorder->start((AudioSystem::sync_event_t)event, triggerSession));
}
@@ -316,20 +317,20 @@
if (lpRecorder == NULL) {
return;
}
- ALOGV("About to delete lpRecorder: %x\n", (int)lpRecorder.get());
+ ALOGV("About to delete lpRecorder: %" PRIxPTR "\n", lpRecorder.get());
lpRecorder->stop();
- audiorecord_callback_cookie *lpCookie = (audiorecord_callback_cookie *)env->GetIntField(
+ audiorecord_callback_cookie *lpCookie = (audiorecord_callback_cookie *)env->GetLongField(
thiz, javaAudioRecordFields.nativeCallbackCookie);
// reset the native resources in the Java object so any attempt to access
// them after a call to release fails.
- env->SetIntField(thiz, javaAudioRecordFields.nativeCallbackCookie, 0);
+ env->SetLongField(thiz, javaAudioRecordFields.nativeCallbackCookie, 0);
// delete the callback information
if (lpCookie) {
Mutex::Autolock l(sLock);
- ALOGV("deleting lpCookie: %x\n", (int)lpCookie);
+ ALOGV("deleting lpCookie: %" PRIxPTR "\n", lpCookie);
while (lpCookie->busy) {
if (lpCookie->cond.waitRelative(sLock,
milliseconds(CALLBACK_COND_WAIT_TIMEOUT_MS)) !=
@@ -585,7 +586,7 @@
// mNativeRecorderInJavaObj
javaAudioRecordFields.nativeRecorderInJavaObj =
env->GetFieldID(audioRecordClass,
- JAVA_NATIVERECORDERINJAVAOBJ_FIELD_NAME, "I");
+ JAVA_NATIVERECORDERINJAVAOBJ_FIELD_NAME, "J");
if (javaAudioRecordFields.nativeRecorderInJavaObj == NULL) {
ALOGE("Can't find AudioRecord.%s", JAVA_NATIVERECORDERINJAVAOBJ_FIELD_NAME);
return -1;
@@ -593,7 +594,7 @@
// mNativeCallbackCookie
javaAudioRecordFields.nativeCallbackCookie = env->GetFieldID(
audioRecordClass,
- JAVA_NATIVECALLBACKINFO_FIELD_NAME, "I");
+ JAVA_NATIVECALLBACKINFO_FIELD_NAME, "J");
if (javaAudioRecordFields.nativeCallbackCookie == NULL) {
ALOGE("Can't find AudioRecord.%s", JAVA_NATIVECALLBACKINFO_FIELD_NAME);
return -1;
diff --git a/core/jni/android_media_AudioSystem.cpp b/core/jni/android_media_AudioSystem.cpp
index 7d99464..a19d111 100644
--- a/core/jni/android_media_AudioSystem.cpp
+++ b/core/jni/android_media_AudioSystem.cpp
@@ -52,10 +52,10 @@
return kAudioStatusError;
}
-static int
+static jint
android_media_AudioSystem_muteMicrophone(JNIEnv *env, jobject thiz, jboolean on)
{
- return check_AudioSystem_Command(AudioSystem::muteMicrophone(on));
+ return (jint) check_AudioSystem_Command(AudioSystem::muteMicrophone(on));
}
static jboolean
@@ -91,7 +91,7 @@
return state;
}
-static int
+static jint
android_media_AudioSystem_setParameters(JNIEnv *env, jobject thiz, jstring keyValuePairs)
{
const jchar* c_keyValuePairs = env->GetStringCritical(keyValuePairs, 0);
@@ -101,7 +101,7 @@
env->ReleaseStringCritical(keyValuePairs, c_keyValuePairs);
}
int status = check_AudioSystem_Command(AudioSystem::setParameters(0, c_keyValuePairs8));
- return status;
+ return (jint) status;
}
static jstring
@@ -131,7 +131,7 @@
check_AudioSystem_Command(err));
}
-static int
+static jint
android_media_AudioSystem_setDeviceConnectionState(JNIEnv *env, jobject thiz, jint device, jint state, jstring device_address)
{
const char *c_address = env->GetStringUTFChars(device_address, NULL);
@@ -139,60 +139,60 @@
static_cast <audio_policy_dev_state_t>(state),
c_address));
env->ReleaseStringUTFChars(device_address, c_address);
- return status;
+ return (jint) status;
}
-static int
+static jint
android_media_AudioSystem_getDeviceConnectionState(JNIEnv *env, jobject thiz, jint device, jstring device_address)
{
const char *c_address = env->GetStringUTFChars(device_address, NULL);
int state = static_cast <int>(AudioSystem::getDeviceConnectionState(static_cast <audio_devices_t>(device),
c_address));
env->ReleaseStringUTFChars(device_address, c_address);
- return state;
+ return (jint) state;
}
-static int
+static jint
android_media_AudioSystem_setPhoneState(JNIEnv *env, jobject thiz, jint state)
{
- return check_AudioSystem_Command(AudioSystem::setPhoneState((audio_mode_t) state));
+ return (jint) check_AudioSystem_Command(AudioSystem::setPhoneState((audio_mode_t) state));
}
-static int
+static jint
android_media_AudioSystem_setForceUse(JNIEnv *env, jobject thiz, jint usage, jint config)
{
- return check_AudioSystem_Command(AudioSystem::setForceUse(static_cast <audio_policy_force_use_t>(usage),
+ return (jint) check_AudioSystem_Command(AudioSystem::setForceUse(static_cast <audio_policy_force_use_t>(usage),
static_cast <audio_policy_forced_cfg_t>(config)));
}
-static int
+static jint
android_media_AudioSystem_getForceUse(JNIEnv *env, jobject thiz, jint usage)
{
- return static_cast <int>(AudioSystem::getForceUse(static_cast <audio_policy_force_use_t>(usage)));
+ return static_cast <jint>(AudioSystem::getForceUse(static_cast <audio_policy_force_use_t>(usage)));
}
-static int
+static jint
android_media_AudioSystem_initStreamVolume(JNIEnv *env, jobject thiz, jint stream, jint indexMin, jint indexMax)
{
- return check_AudioSystem_Command(AudioSystem::initStreamVolume(static_cast <audio_stream_type_t>(stream),
+ return (jint) check_AudioSystem_Command(AudioSystem::initStreamVolume(static_cast <audio_stream_type_t>(stream),
indexMin,
indexMax));
}
-static int
+static jint
android_media_AudioSystem_setStreamVolumeIndex(JNIEnv *env,
jobject thiz,
jint stream,
jint index,
jint device)
{
- return check_AudioSystem_Command(
+ return (jint) check_AudioSystem_Command(
AudioSystem::setStreamVolumeIndex(static_cast <audio_stream_type_t>(stream),
index,
(audio_devices_t)device));
}
-static int
+static jint
android_media_AudioSystem_getStreamVolumeIndex(JNIEnv *env,
jobject thiz,
jint stream,
@@ -205,13 +205,13 @@
!= NO_ERROR) {
index = -1;
}
- return index;
+ return (jint) index;
}
-static int
+static jint
android_media_AudioSystem_setMasterVolume(JNIEnv *env, jobject thiz, jfloat value)
{
- return check_AudioSystem_Command(AudioSystem::setMasterVolume(value));
+ return (jint) check_AudioSystem_Command(AudioSystem::setMasterVolume(value));
}
static jfloat
@@ -224,10 +224,10 @@
return value;
}
-static int
+static jint
android_media_AudioSystem_setMasterMute(JNIEnv *env, jobject thiz, jboolean mute)
{
- return check_AudioSystem_Command(AudioSystem::setMasterMute(mute));
+ return (jint) check_AudioSystem_Command(AudioSystem::setMasterMute(mute));
}
static jfloat
@@ -275,10 +275,10 @@
return (jint) AudioSystem::setLowRamDevice((bool) isLowRamDevice);
}
-static int
+static jint
android_media_AudioSystem_checkAudioFlinger(JNIEnv *env, jobject clazz)
{
- return check_AudioSystem_Command(AudioSystem::checkAudioFlinger());
+ return (jint) check_AudioSystem_Command(AudioSystem::checkAudioFlinger());
}
// ----------------------------------------------------------------------------
diff --git a/core/jni/android_media_AudioTrack.cpp b/core/jni/android_media_AudioTrack.cpp
index 225bf06..dc8d9d8 100644
--- a/core/jni/android_media_AudioTrack.cpp
+++ b/core/jni/android_media_AudioTrack.cpp
@@ -174,7 +174,7 @@
{
Mutex::Autolock l(sLock);
AudioTrack* const at =
- (AudioTrack*)env->GetIntField(thiz, javaAudioTrackFields.nativeTrackInJavaObj);
+ (AudioTrack*)env->GetLongField(thiz, javaAudioTrackFields.nativeTrackInJavaObj);
return sp<AudioTrack>(at);
}
@@ -182,19 +182,19 @@
{
Mutex::Autolock l(sLock);
sp<AudioTrack> old =
- (AudioTrack*)env->GetIntField(thiz, javaAudioTrackFields.nativeTrackInJavaObj);
+ (AudioTrack*)env->GetLongField(thiz, javaAudioTrackFields.nativeTrackInJavaObj);
if (at.get()) {
at->incStrong((void*)setAudioTrack);
}
if (old != 0) {
old->decStrong((void*)setAudioTrack);
}
- env->SetIntField(thiz, javaAudioTrackFields.nativeTrackInJavaObj, (int)at.get());
+ env->SetLongField(thiz, javaAudioTrackFields.nativeTrackInJavaObj, (jlong)at.get());
return old;
}
// ----------------------------------------------------------------------------
-static int
+static jint
android_media_AudioTrack_native_setup(JNIEnv *env, jobject thiz, jobject weak_this,
jint streamType, jint sampleRateInHertz, jint javaChannelMask,
jint audioFormat, jint buffSizeInBytes, jint memoryMode, jintArray jSession)
@@ -206,11 +206,11 @@
if (AudioSystem::getOutputFrameCount(&afFrameCount, (audio_stream_type_t) streamType) != NO_ERROR) {
ALOGE("Error creating AudioTrack: Could not get AudioSystem frame count.");
- return AUDIOTRACK_ERROR_SETUP_AUDIOSYSTEM;
+ return (jint) AUDIOTRACK_ERROR_SETUP_AUDIOSYSTEM;
}
if (AudioSystem::getOutputSamplingRate(&afSampleRate, (audio_stream_type_t) streamType) != NO_ERROR) {
ALOGE("Error creating AudioTrack: Could not get AudioSystem sampling rate.");
- return AUDIOTRACK_ERROR_SETUP_AUDIOSYSTEM;
+ return (jint) AUDIOTRACK_ERROR_SETUP_AUDIOSYSTEM;
}
// Java channel masks don't map directly to the native definition, but it's a simple shift
@@ -219,7 +219,7 @@
if (!audio_is_output_channel(nativeChannelMask)) {
ALOGE("Error creating AudioTrack: invalid channel mask %#x.", javaChannelMask);
- return AUDIOTRACK_ERROR_SETUP_INVALIDCHANNELMASK;
+ return (jint) AUDIOTRACK_ERROR_SETUP_INVALIDCHANNELMASK;
}
int nbChannels = popcount(nativeChannelMask);
@@ -239,7 +239,7 @@
break;
default:
ALOGE("Error creating AudioTrack: unknown stream type.");
- return AUDIOTRACK_ERROR_SETUP_INVALIDSTREAMTYPE;
+ return (jint) AUDIOTRACK_ERROR_SETUP_INVALIDSTREAMTYPE;
}
// check the format.
@@ -247,7 +247,7 @@
if ((audioFormat != ENCODING_PCM_16BIT) && (audioFormat != ENCODING_PCM_8BIT)) {
ALOGE("Error creating AudioTrack: unsupported audio format.");
- return AUDIOTRACK_ERROR_SETUP_INVALIDFORMAT;
+ return (jint) AUDIOTRACK_ERROR_SETUP_INVALIDFORMAT;
}
// for the moment 8bitPCM in MODE_STATIC is not supported natively in the AudioTrack C++ class
@@ -272,18 +272,18 @@
jclass clazz = env->GetObjectClass(thiz);
if (clazz == NULL) {
ALOGE("Can't find %s when setting up callback.", kClassPathName);
- return AUDIOTRACK_ERROR_SETUP_NATIVEINITFAILED;
+ return (jint) AUDIOTRACK_ERROR_SETUP_NATIVEINITFAILED;
}
if (jSession == NULL) {
ALOGE("Error creating AudioTrack: invalid session ID pointer");
- return AUDIOTRACK_ERROR;
+ return (jint) AUDIOTRACK_ERROR;
}
jint* nSession = (jint *) env->GetPrimitiveArrayCritical(jSession, NULL);
if (nSession == NULL) {
ALOGE("Error creating AudioTrack: Error retrieving session id pointer");
- return AUDIOTRACK_ERROR;
+ return (jint) AUDIOTRACK_ERROR;
}
int sessionId = nSession[0];
env->ReleasePrimitiveArrayCritical(jSession, nSession, 0);
@@ -370,10 +370,10 @@
setAudioTrack(env, thiz, lpTrack);
// save the JNI resources so we can free them later
- //ALOGV("storing lpJniStorage: %x\n", (int)lpJniStorage);
- env->SetIntField(thiz, javaAudioTrackFields.jniData, (int)lpJniStorage);
+ //ALOGV("storing lpJniStorage: %x\n", (long)lpJniStorage);
+ env->SetLongField(thiz, javaAudioTrackFields.jniData, (jlong)lpJniStorage);
- return AUDIOTRACK_SUCCESS;
+ return (jint) AUDIOTRACK_SUCCESS;
// failures:
native_init_failure:
@@ -383,9 +383,9 @@
env->DeleteGlobalRef(lpJniStorage->mCallbackData.audioTrack_class);
env->DeleteGlobalRef(lpJniStorage->mCallbackData.audioTrack_ref);
delete lpJniStorage;
- env->SetIntField(thiz, javaAudioTrackFields.jniData, 0);
+ env->SetLongField(thiz, javaAudioTrackFields.jniData, 0);
- return AUDIOTRACK_ERROR_SETUP_NATIVEINITFAILED;
+ return (jint) AUDIOTRACK_ERROR_SETUP_NATIVEINITFAILED;
}
@@ -474,11 +474,11 @@
lpTrack->stop();
// delete the JNI data
- AudioTrackJniStorage* pJniStorage = (AudioTrackJniStorage *)env->GetIntField(
+ AudioTrackJniStorage* pJniStorage = (AudioTrackJniStorage *)env->GetLongField(
thiz, javaAudioTrackFields.jniData);
// reset the native resources in the Java object so any attempt to access
// them after a call to release fails.
- env->SetIntField(thiz, javaAudioTrackFields.jniData, 0);
+ env->SetLongField(thiz, javaAudioTrackFields.jniData, 0);
if (pJniStorage) {
Mutex::Autolock l(sLock);
@@ -955,7 +955,7 @@
// nativeTrackInJavaObj
javaAudioTrackFields.nativeTrackInJavaObj = env->GetFieldID(
audioTrackClass,
- JAVA_NATIVETRACKINJAVAOBJ_FIELD_NAME, "I");
+ JAVA_NATIVETRACKINJAVAOBJ_FIELD_NAME, "J");
if (javaAudioTrackFields.nativeTrackInJavaObj == NULL) {
ALOGE("Can't find AudioTrack.%s", JAVA_NATIVETRACKINJAVAOBJ_FIELD_NAME);
return -1;
@@ -963,7 +963,7 @@
// jniData;
javaAudioTrackFields.jniData = env->GetFieldID(
audioTrackClass,
- JAVA_JNIDATA_FIELD_NAME, "I");
+ JAVA_JNIDATA_FIELD_NAME, "J");
if (javaAudioTrackFields.jniData == NULL) {
ALOGE("Can't find AudioTrack.%s", JAVA_JNIDATA_FIELD_NAME);
return -1;
diff --git a/core/jni/android_media_JetPlayer.cpp b/core/jni/android_media_JetPlayer.cpp
index 5795aba..69f5711 100644
--- a/core/jni/android_media_JetPlayer.cpp
+++ b/core/jni/android_media_JetPlayer.cpp
@@ -87,12 +87,12 @@
if (result==EAS_SUCCESS) {
// save our newly created C++ JetPlayer in the "nativePlayerInJavaObj" field
// of the Java object (in mNativePlayerInJavaObj)
- env->SetIntField(thiz, javaJetPlayerFields.nativePlayerInJavaObj, (int)lpJet);
+ env->SetLongField(thiz, javaJetPlayerFields.nativePlayerInJavaObj, (jlong)lpJet);
return JNI_TRUE;
} else {
ALOGE("android_media_JetPlayer_setup(): initialization failed with EAS error code %d", (int)result);
delete lpJet;
- env->SetIntField(weak_this, javaJetPlayerFields.nativePlayerInJavaObj, 0);
+ env->SetLongField(weak_this, javaJetPlayerFields.nativePlayerInJavaObj, 0);
return JNI_FALSE;
}
}
@@ -103,7 +103,7 @@
android_media_JetPlayer_finalize(JNIEnv *env, jobject thiz)
{
ALOGV("android_media_JetPlayer_finalize(): entering.");
- JetPlayer *lpJet = (JetPlayer *)env->GetIntField(
+ JetPlayer *lpJet = (JetPlayer *)env->GetLongField(
thiz, javaJetPlayerFields.nativePlayerInJavaObj);
if (lpJet != NULL) {
lpJet->release();
@@ -119,7 +119,7 @@
android_media_JetPlayer_release(JNIEnv *env, jobject thiz)
{
android_media_JetPlayer_finalize(env, thiz);
- env->SetIntField(thiz, javaJetPlayerFields.nativePlayerInJavaObj, 0);
+ env->SetLongField(thiz, javaJetPlayerFields.nativePlayerInJavaObj, 0);
ALOGV("android_media_JetPlayer_release() done");
}
@@ -128,7 +128,7 @@
static jboolean
android_media_JetPlayer_loadFromFile(JNIEnv *env, jobject thiz, jstring path)
{
- JetPlayer *lpJet = (JetPlayer *)env->GetIntField(
+ JetPlayer *lpJet = (JetPlayer *)env->GetLongField(
thiz, javaJetPlayerFields.nativePlayerInJavaObj);
if (lpJet == NULL) {
jniThrowException(env, "java/lang/IllegalStateException",
@@ -165,7 +165,7 @@
android_media_JetPlayer_loadFromFileD(JNIEnv *env, jobject thiz,
jobject fileDescriptor, jlong offset, jlong length)
{
- JetPlayer *lpJet = (JetPlayer *)env->GetIntField(
+ JetPlayer *lpJet = (JetPlayer *)env->GetLongField(
thiz, javaJetPlayerFields.nativePlayerInJavaObj);
if (lpJet == NULL) {
jniThrowException(env, "java/lang/IllegalStateException",
@@ -195,7 +195,7 @@
static jboolean
android_media_JetPlayer_closeFile(JNIEnv *env, jobject thiz)
{
- JetPlayer *lpJet = (JetPlayer *)env->GetIntField(
+ JetPlayer *lpJet = (JetPlayer *)env->GetLongField(
thiz, javaJetPlayerFields.nativePlayerInJavaObj);
if (lpJet == NULL) {
jniThrowException(env, "java/lang/IllegalStateException",
@@ -217,7 +217,7 @@
static jboolean
android_media_JetPlayer_play(JNIEnv *env, jobject thiz)
{
- JetPlayer *lpJet = (JetPlayer *)env->GetIntField(
+ JetPlayer *lpJet = (JetPlayer *)env->GetLongField(
thiz, javaJetPlayerFields.nativePlayerInJavaObj);
if (lpJet == NULL) {
jniThrowException(env, "java/lang/IllegalStateException",
@@ -241,7 +241,7 @@
static jboolean
android_media_JetPlayer_pause(JNIEnv *env, jobject thiz)
{
- JetPlayer *lpJet = (JetPlayer *)env->GetIntField(
+ JetPlayer *lpJet = (JetPlayer *)env->GetLongField(
thiz, javaJetPlayerFields.nativePlayerInJavaObj);
if (lpJet == NULL) {
jniThrowException(env, "java/lang/IllegalStateException",
@@ -271,7 +271,7 @@
jint segmentNum, jint libNum, jint repeatCount, jint transpose, jint muteFlags,
jbyte userID)
{
- JetPlayer *lpJet = (JetPlayer *)env->GetIntField(
+ JetPlayer *lpJet = (JetPlayer *)env->GetLongField(
thiz, javaJetPlayerFields.nativePlayerInJavaObj);
if (lpJet == NULL) {
jniThrowException(env, "java/lang/IllegalStateException",
@@ -298,7 +298,7 @@
jint segmentNum, jint libNum, jint repeatCount, jint transpose, jbooleanArray muteArray,
jbyte userID)
{
- JetPlayer *lpJet = (JetPlayer *)env->GetIntField(
+ JetPlayer *lpJet = (JetPlayer *)env->GetLongField(
thiz, javaJetPlayerFields.nativePlayerInJavaObj);
if (lpJet == NULL) {
jniThrowException(env, "java/lang/IllegalStateException",
@@ -344,7 +344,7 @@
android_media_JetPlayer_setMuteFlags(JNIEnv *env, jobject thiz,
jint muteFlags /*unsigned?*/, jboolean bSync)
{
- JetPlayer *lpJet = (JetPlayer *)env->GetIntField(
+ JetPlayer *lpJet = (JetPlayer *)env->GetLongField(
thiz, javaJetPlayerFields.nativePlayerInJavaObj);
if (lpJet == NULL) {
jniThrowException(env, "java/lang/IllegalStateException",
@@ -369,7 +369,7 @@
android_media_JetPlayer_setMuteArray(JNIEnv *env, jobject thiz,
jbooleanArray muteArray, jboolean bSync)
{
- JetPlayer *lpJet = (JetPlayer *)env->GetIntField(
+ JetPlayer *lpJet = (JetPlayer *)env->GetLongField(
thiz, javaJetPlayerFields.nativePlayerInJavaObj);
if (lpJet == NULL) {
jniThrowException(env, "java/lang/IllegalStateException",
@@ -415,7 +415,7 @@
android_media_JetPlayer_setMuteFlag(JNIEnv *env, jobject thiz,
jint trackId, jboolean muteFlag, jboolean bSync)
{
- JetPlayer *lpJet = (JetPlayer *)env->GetIntField(
+ JetPlayer *lpJet = (JetPlayer *)env->GetLongField(
thiz, javaJetPlayerFields.nativePlayerInJavaObj);
if (lpJet == NULL) {
jniThrowException(env, "java/lang/IllegalStateException",
@@ -441,7 +441,7 @@
static jboolean
android_media_JetPlayer_triggerClip(JNIEnv *env, jobject thiz, jint clipId)
{
- JetPlayer *lpJet = (JetPlayer *)env->GetIntField(
+ JetPlayer *lpJet = (JetPlayer *)env->GetLongField(
thiz, javaJetPlayerFields.nativePlayerInJavaObj);
if (lpJet == NULL) {
jniThrowException(env, "java/lang/IllegalStateException",
@@ -466,7 +466,7 @@
static jboolean
android_media_JetPlayer_clearQueue(JNIEnv *env, jobject thiz)
{
- JetPlayer *lpJet = (JetPlayer *)env->GetIntField(
+ JetPlayer *lpJet = (JetPlayer *)env->GetLongField(
thiz, javaJetPlayerFields.nativePlayerInJavaObj);
if (lpJet == NULL) {
jniThrowException(env, "java/lang/IllegalStateException",
@@ -533,7 +533,7 @@
// Get the mNativePlayerInJavaObj variable field
javaJetPlayerFields.nativePlayerInJavaObj = env->GetFieldID(
jetPlayerClass,
- JAVA_NATIVEJETPLAYERINJAVAOBJ_FIELD_NAME, "I");
+ JAVA_NATIVEJETPLAYERINJAVAOBJ_FIELD_NAME, "J");
if (javaJetPlayerFields.nativePlayerInJavaObj == NULL) {
ALOGE("Can't find JetPlayer.%s", JAVA_NATIVEJETPLAYERINJAVAOBJ_FIELD_NAME);
return -1;
diff --git a/core/jni/android_media_RemoteDisplay.cpp b/core/jni/android_media_RemoteDisplay.cpp
index 463be5e..1cd3fbb 100644
--- a/core/jni/android_media_RemoteDisplay.cpp
+++ b/core/jni/android_media_RemoteDisplay.cpp
@@ -134,7 +134,7 @@
// ----------------------------------------------------------------------------
-static jint nativeListen(JNIEnv* env, jobject remoteDisplayObj, jstring ifaceStr) {
+static jlong nativeListen(JNIEnv* env, jobject remoteDisplayObj, jstring ifaceStr) {
ScopedUtfChars iface(env, ifaceStr);
sp<IServiceManager> sm = defaultServiceManager();
@@ -155,20 +155,20 @@
}
NativeRemoteDisplay* wrapper = new NativeRemoteDisplay(display, client);
- return reinterpret_cast<jint>(wrapper);
+ return reinterpret_cast<jlong>(wrapper);
}
-static void nativePause(JNIEnv* env, jobject remoteDisplayObj, jint ptr) {
+static void nativePause(JNIEnv* env, jobject remoteDisplayObj, jlong ptr) {
NativeRemoteDisplay* wrapper = reinterpret_cast<NativeRemoteDisplay*>(ptr);
wrapper->pause();
}
-static void nativeResume(JNIEnv* env, jobject remoteDisplayObj, jint ptr) {
+static void nativeResume(JNIEnv* env, jobject remoteDisplayObj, jlong ptr) {
NativeRemoteDisplay* wrapper = reinterpret_cast<NativeRemoteDisplay*>(ptr);
wrapper->resume();
}
-static void nativeDispose(JNIEnv* env, jobject remoteDisplayObj, jint ptr) {
+static void nativeDispose(JNIEnv* env, jobject remoteDisplayObj, jlong ptr) {
NativeRemoteDisplay* wrapper = reinterpret_cast<NativeRemoteDisplay*>(ptr);
delete wrapper;
}
@@ -176,13 +176,13 @@
// ----------------------------------------------------------------------------
static JNINativeMethod gMethods[] = {
- {"nativeListen", "(Ljava/lang/String;)I",
+ {"nativeListen", "(Ljava/lang/String;)J",
(void*)nativeListen },
- {"nativeDispose", "(I)V",
+ {"nativeDispose", "(J)V",
(void*)nativeDispose },
- {"nativePause", "(I)V",
+ {"nativePause", "(J)V",
(void*)nativePause },
- {"nativeResume", "(I)V",
+ {"nativeResume", "(J)V",
(void*)nativeResume },
};
diff --git a/core/jni/android_media_ToneGenerator.cpp b/core/jni/android_media_ToneGenerator.cpp
index 76e42bc..ca00709 100644
--- a/core/jni/android_media_ToneGenerator.cpp
+++ b/core/jni/android_media_ToneGenerator.cpp
@@ -39,9 +39,9 @@
static fields_t fields;
static jboolean android_media_ToneGenerator_startTone(JNIEnv *env, jobject thiz, jint toneType, jint durationMs) {
- ALOGV("android_media_ToneGenerator_startTone: %x", (int)thiz);
+ ALOGV("android_media_ToneGenerator_startTone: %p", thiz);
- ToneGenerator *lpToneGen = (ToneGenerator *)env->GetIntField(thiz,
+ ToneGenerator *lpToneGen = (ToneGenerator *)env->GetLongField(thiz,
fields.context);
if (lpToneGen == NULL) {
jniThrowRuntimeException(env, "Method called after release()");
@@ -52,12 +52,12 @@
}
static void android_media_ToneGenerator_stopTone(JNIEnv *env, jobject thiz) {
- ALOGV("android_media_ToneGenerator_stopTone: %x", (int)thiz);
+ ALOGV("android_media_ToneGenerator_stopTone: %p", thiz);
- ToneGenerator *lpToneGen = (ToneGenerator *)env->GetIntField(thiz,
+ ToneGenerator *lpToneGen = (ToneGenerator *)env->GetLongField(thiz,
fields.context);
- ALOGV("ToneGenerator lpToneGen: %x", (unsigned int)lpToneGen);
+ ALOGV("ToneGenerator lpToneGen: %p", lpToneGen);
if (lpToneGen == NULL) {
jniThrowRuntimeException(env, "Method called after release()");
return;
@@ -66,7 +66,7 @@
}
static jint android_media_ToneGenerator_getAudioSessionId(JNIEnv *env, jobject thiz) {
- ToneGenerator *lpToneGen = (ToneGenerator *)env->GetIntField(thiz,
+ ToneGenerator *lpToneGen = (ToneGenerator *)env->GetLongField(thiz,
fields.context);
if (lpToneGen == NULL) {
jniThrowRuntimeException(env, "Method called after release()");
@@ -76,11 +76,11 @@
}
static void android_media_ToneGenerator_release(JNIEnv *env, jobject thiz) {
- ToneGenerator *lpToneGen = (ToneGenerator *)env->GetIntField(thiz,
+ ToneGenerator *lpToneGen = (ToneGenerator *)env->GetLongField(thiz,
fields.context);
- ALOGV("android_media_ToneGenerator_release lpToneGen: %x", (int)lpToneGen);
+ ALOGV("android_media_ToneGenerator_release lpToneGen: %p", lpToneGen);
- env->SetIntField(thiz, fields.context, 0);
+ env->SetLongField(thiz, fields.context, 0);
delete lpToneGen;
}
@@ -89,11 +89,11 @@
jint streamType, jint volume) {
ToneGenerator *lpToneGen = new ToneGenerator((audio_stream_type_t) streamType, AudioSystem::linearToLog(volume), true);
- env->SetIntField(thiz, fields.context, 0);
+ env->SetLongField(thiz, fields.context, 0);
- ALOGV("android_media_ToneGenerator_native_setup jobject: %x", (int)thiz);
+ ALOGV("android_media_ToneGenerator_native_setup jobject: %p", thiz);
- ALOGV("ToneGenerator lpToneGen: %x", (unsigned int)lpToneGen);
+ ALOGV("ToneGenerator lpToneGen: %p", lpToneGen);
if (!lpToneGen->isInited()) {
ALOGE("ToneGenerator init failed");
@@ -103,16 +103,16 @@
}
// Stow our new C++ ToneGenerator in an opaque field in the Java object.
- env->SetIntField(thiz, fields.context, (int)lpToneGen);
+ env->SetLongField(thiz, fields.context, (jlong)lpToneGen);
- ALOGV("ToneGenerator fields.context: %x", env->GetIntField(thiz, fields.context));
+ ALOGV("ToneGenerator fields.context: %p", (void*) env->GetLongField(thiz, fields.context));
}
static void android_media_ToneGenerator_native_finalize(JNIEnv *env,
jobject thiz) {
- ALOGV("android_media_ToneGenerator_native_finalize jobject: %x", (int)thiz);
+ ALOGV("android_media_ToneGenerator_native_finalize jobject: %p", thiz);
- ToneGenerator *lpToneGen = (ToneGenerator *)env->GetIntField(thiz,
+ ToneGenerator *lpToneGen = (ToneGenerator *)env->GetLongField(thiz,
fields.context);
if (lpToneGen != NULL) {
@@ -142,12 +142,12 @@
return -1;
}
- fields.context = env->GetFieldID(clazz, "mNativeContext", "I");
+ fields.context = env->GetFieldID(clazz, "mNativeContext", "J");
if (fields.context == NULL) {
ALOGE("Can't find ToneGenerator.mNativeContext");
return -1;
}
- ALOGV("register_android_media_ToneGenerator ToneGenerator fields.context: %x", (unsigned int)fields.context);
+ ALOGV("register_android_media_ToneGenerator ToneGenerator fields.context: %p", fields.context);
return AndroidRuntime::registerNativeMethods(env,
"android/media/ToneGenerator", gMethods, NELEM(gMethods));
diff --git a/core/jni/android_net_LocalSocketImpl.cpp b/core/jni/android_net_LocalSocketImpl.cpp
index 9f79f74..98f4bed 100644
--- a/core/jni/android_net_LocalSocketImpl.cpp
+++ b/core/jni/android_net_LocalSocketImpl.cpp
@@ -111,7 +111,7 @@
/* private native void listen_native(int fd, int backlog) throws IOException; */
static void
-socket_listen (JNIEnv *env, jobject object, jobject fileDescriptor, int backlog)
+socket_listen (JNIEnv *env, jobject object, jobject fileDescriptor, jint backlog)
{
int ret;
int fd;
@@ -231,7 +231,7 @@
}
static jint
-socket_getOption(JNIEnv *env, jobject object, jobject fileDescriptor, int optID)
+socket_getOption(JNIEnv *env, jobject object, jobject fileDescriptor, jint optID)
{
int ret, value;
int opt, level;
@@ -279,7 +279,7 @@
}
static void socket_setOption(
- JNIEnv *env, jobject object, jobject fileDescriptor, int optID,
+ JNIEnv *env, jobject object, jobject fileDescriptor, jint optID,
jint boolValue, jint intValue) {
int ret;
int optname;
diff --git a/core/jni/android_nio_utils.cpp b/core/jni/android_nio_utils.cpp
index 7cbbe12..59d6e41 100644
--- a/core/jni/android_nio_utils.cpp
+++ b/core/jni/android_nio_utils.cpp
@@ -37,7 +37,7 @@
gNioJNI.getBasePointerID, buffer);
if (pointer != 0L) {
*array = NULL;
- return (void *) (jint) pointer;
+ return reinterpret_cast<void *>(pointer);
}
*array = (jarray) _env->CallStaticObjectMethod(gNioJNI.nioAccessClass,
diff --git a/core/jni/android_opengl_EGL14.cpp b/core/jni/android_opengl_EGL14.cpp
index 1fe4b08..19e4d99 100644
--- a/core/jni/android_opengl_EGL14.cpp
+++ b/core/jni/android_opengl_EGL14.cpp
@@ -69,22 +69,22 @@
jclass eglconfigClassLocal = _env->FindClass("android/opengl/EGLConfig");
eglconfigClass = (jclass) _env->NewGlobalRef(eglconfigClassLocal);
- egldisplayGetHandleID = _env->GetMethodID(egldisplayClass, "getHandle", "()I");
- eglcontextGetHandleID = _env->GetMethodID(eglcontextClass, "getHandle", "()I");
- eglsurfaceGetHandleID = _env->GetMethodID(eglsurfaceClass, "getHandle", "()I");
- eglconfigGetHandleID = _env->GetMethodID(eglconfigClass, "getHandle", "()I");
+ egldisplayGetHandleID = _env->GetMethodID(egldisplayClass, "getNativeHandle", "()J");
+ eglcontextGetHandleID = _env->GetMethodID(eglcontextClass, "getNativeHandle", "()J");
+ eglsurfaceGetHandleID = _env->GetMethodID(eglsurfaceClass, "getNativeHandle", "()J");
+ eglconfigGetHandleID = _env->GetMethodID(eglconfigClass, "getNativeHandle", "()J");
- egldisplayConstructor = _env->GetMethodID(egldisplayClass, "<init>", "(I)V");
- eglcontextConstructor = _env->GetMethodID(eglcontextClass, "<init>", "(I)V");
- eglsurfaceConstructor = _env->GetMethodID(eglsurfaceClass, "<init>", "(I)V");
- eglconfigConstructor = _env->GetMethodID(eglconfigClass, "<init>", "(I)V");
+ egldisplayConstructor = _env->GetMethodID(egldisplayClass, "<init>", "(J)V");
+ eglcontextConstructor = _env->GetMethodID(eglcontextClass, "<init>", "(J)V");
+ eglsurfaceConstructor = _env->GetMethodID(eglsurfaceClass, "<init>", "(J)V");
+ eglconfigConstructor = _env->GetMethodID(eglconfigClass, "<init>", "(J)V");
- jobject localeglNoContextObject = _env->NewObject(eglcontextClass, eglcontextConstructor, (jint)EGL_NO_CONTEXT);
+ jobject localeglNoContextObject = _env->NewObject(eglcontextClass, eglcontextConstructor, reinterpret_cast<jlong>(EGL_NO_CONTEXT));
eglNoContextObject = _env->NewGlobalRef(localeglNoContextObject);
- jobject localeglNoDisplayObject = _env->NewObject(egldisplayClass, egldisplayConstructor, (jint)EGL_NO_DISPLAY);
+ jobject localeglNoDisplayObject = _env->NewObject(egldisplayClass, egldisplayConstructor, reinterpret_cast<jlong>(EGL_NO_DISPLAY));
eglNoDisplayObject = _env->NewGlobalRef(localeglNoDisplayObject);
- jobject localeglNoSurfaceObject = _env->NewObject(eglsurfaceClass, eglsurfaceConstructor, (jint)EGL_NO_SURFACE);
+ jobject localeglNoSurfaceObject = _env->NewObject(eglsurfaceClass, eglsurfaceConstructor, reinterpret_cast<jlong>(EGL_NO_SURFACE));
eglNoSurfaceObject = _env->NewGlobalRef(localeglNoSurfaceObject);
@@ -106,7 +106,8 @@
"Object is set to null.");
}
- return (void*) (_env->CallIntMethod(obj, mid));
+ jlong handle = _env->CallLongMethod(obj, mid);
+ return reinterpret_cast<void*>(handle);
}
static jobject
@@ -126,7 +127,7 @@
return eglNoSurfaceObject;
}
- return _env->NewObject(cls, con, (jint)handle);
+ return _env->NewObject(cls, con, reinterpret_cast<jlong>(handle));
}
// --------------------------------------------------------------------------
@@ -142,14 +143,26 @@
/* EGLDisplay eglGetDisplay ( EGLNativeDisplayType display_id ) */
static jobject
android_eglGetDisplay
- (JNIEnv *_env, jobject _this, jint display_id) {
+ (JNIEnv *_env, jobject _this, jlong display_id) {
EGLDisplay _returnValue = (EGLDisplay) 0;
_returnValue = eglGetDisplay(
- (EGLNativeDisplayType)display_id
+ reinterpret_cast<EGLNativeDisplayType>(display_id)
);
return toEGLHandle(_env, egldisplayClass, egldisplayConstructor, _returnValue);
}
+/* EGLDisplay eglGetDisplay ( EGLNativeDisplayType display_id ) */
+static jobject
+android_eglGetDisplayInt
+ (JNIEnv *_env, jobject _this, jint display_id) {
+
+ if ((EGLNativeDisplayType)display_id != EGL_DEFAULT_DISPLAY) {
+ jniThrowException(_env, "java/lang/UnsupportedOperationException", "eglGetDisplay");
+ return 0;
+ }
+ return android_eglGetDisplay(_env, _this, display_id);
+}
+
/* EGLBoolean eglInitialize ( EGLDisplay dpy, EGLint *major, EGLint *minor ) */
static jboolean
android_eglInitialize
@@ -630,7 +643,7 @@
if (producer == NULL)
goto not_valid_surface;
- window = new android::Surface(producer);
+ window = new android::Surface(producer, true);
if (window == NULL)
goto not_valid_surface;
@@ -852,7 +865,7 @@
/* EGLSurface eglCreatePbufferFromClientBuffer ( EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list ) */
static jobject
android_eglCreatePbufferFromClientBuffer
- (JNIEnv *_env, jobject _this, jobject dpy, jint buftype, jint buffer, jobject config, jintArray attrib_list_ref, jint offset) {
+ (JNIEnv *_env, jobject _this, jobject dpy, jint buftype, jlong buffer, jobject config, jintArray attrib_list_ref, jint offset) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
@@ -897,7 +910,7 @@
_returnValue = eglCreatePbufferFromClientBuffer(
(EGLDisplay)dpy_native,
(EGLenum)buftype,
- (EGLClientBuffer)buffer,
+ reinterpret_cast<EGLClientBuffer>(buffer),
(EGLConfig)config_native,
(EGLint *)attrib_list
);
@@ -913,6 +926,16 @@
return toEGLHandle(_env, eglsurfaceClass, eglsurfaceConstructor, _returnValue);
}
+static jobject
+android_eglCreatePbufferFromClientBufferInt
+ (JNIEnv *_env, jobject _this, jobject dpy, jint buftype, jint buffer, jobject config, jintArray attrib_list_ref, jint offset) {
+ if(sizeof(void*) != sizeof(uint32_t)) {
+ jniThrowException(_env, "java/lang/UnsupportedOperationException", "eglCreatePbufferFromClientBuffer");
+ return 0;
+ }
+ return android_eglCreatePbufferFromClientBuffer(_env, _this, dpy, buftype, buffer, config, attrib_list_ref, offset);
+}
+
/* EGLBoolean eglSurfaceAttrib ( EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value ) */
static jboolean
android_eglSurfaceAttrib
@@ -1207,7 +1230,8 @@
static JNINativeMethod methods[] = {
{"_nativeClassInit", "()V", (void*)nativeClassInit },
{"eglGetError", "()I", (void *) android_eglGetError },
-{"eglGetDisplay", "(I)Landroid/opengl/EGLDisplay;", (void *) android_eglGetDisplay },
+{"eglGetDisplay", "(I)Landroid/opengl/EGLDisplay;", (void *) android_eglGetDisplayInt },
+{"eglGetDisplay", "(J)Landroid/opengl/EGLDisplay;", (void *) android_eglGetDisplay },
{"eglInitialize", "(Landroid/opengl/EGLDisplay;[II[II)Z", (void *) android_eglInitialize },
{"eglTerminate", "(Landroid/opengl/EGLDisplay;)Z", (void *) android_eglTerminate },
{"eglQueryString", "(Landroid/opengl/EGLDisplay;I)Ljava/lang/String;", (void *) android_eglQueryString__Landroind_opengl_EGLDisplay_2I },
@@ -1224,7 +1248,8 @@
{"eglQueryAPI", "()I", (void *) android_eglQueryAPI },
{"eglWaitClient", "()Z", (void *) android_eglWaitClient },
{"eglReleaseThread", "()Z", (void *) android_eglReleaseThread },
-{"eglCreatePbufferFromClientBuffer", "(Landroid/opengl/EGLDisplay;IILandroid/opengl/EGLConfig;[II)Landroid/opengl/EGLSurface;", (void *) android_eglCreatePbufferFromClientBuffer },
+{"eglCreatePbufferFromClientBuffer", "(Landroid/opengl/EGLDisplay;IILandroid/opengl/EGLConfig;[II)Landroid/opengl/EGLSurface;", (void *) android_eglCreatePbufferFromClientBufferInt },
+{"eglCreatePbufferFromClientBuffer", "(Landroid/opengl/EGLDisplay;IJLandroid/opengl/EGLConfig;[II)Landroid/opengl/EGLSurface;", (void *) android_eglCreatePbufferFromClientBuffer },
{"eglSurfaceAttrib", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLSurface;II)Z", (void *) android_eglSurfaceAttrib },
{"eglBindTexImage", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLSurface;I)Z", (void *) android_eglBindTexImage },
{"eglReleaseTexImage", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLSurface;I)Z", (void *) android_eglReleaseTexImage },
diff --git a/core/jni/android_opengl_EGLExt.cpp b/core/jni/android_opengl_EGLExt.cpp
index 5179ddc..15899f5 100644
--- a/core/jni/android_opengl_EGLExt.cpp
+++ b/core/jni/android_opengl_EGLExt.cpp
@@ -70,22 +70,22 @@
jclass eglconfigClassLocal = _env->FindClass("android/opengl/EGLConfig");
eglconfigClass = (jclass) _env->NewGlobalRef(eglconfigClassLocal);
- egldisplayGetHandleID = _env->GetMethodID(egldisplayClass, "getHandle", "()I");
- eglcontextGetHandleID = _env->GetMethodID(eglcontextClass, "getHandle", "()I");
- eglsurfaceGetHandleID = _env->GetMethodID(eglsurfaceClass, "getHandle", "()I");
- eglconfigGetHandleID = _env->GetMethodID(eglconfigClass, "getHandle", "()I");
+ egldisplayGetHandleID = _env->GetMethodID(egldisplayClass, "getNativeHandle", "()J");
+ eglcontextGetHandleID = _env->GetMethodID(eglcontextClass, "getNativeHandle", "()J");
+ eglsurfaceGetHandleID = _env->GetMethodID(eglsurfaceClass, "getNativeHandle", "()J");
+ eglconfigGetHandleID = _env->GetMethodID(eglconfigClass, "getNativeHandle", "()J");
- egldisplayConstructor = _env->GetMethodID(egldisplayClass, "<init>", "(I)V");
- eglcontextConstructor = _env->GetMethodID(eglcontextClass, "<init>", "(I)V");
- eglsurfaceConstructor = _env->GetMethodID(eglsurfaceClass, "<init>", "(I)V");
- eglconfigConstructor = _env->GetMethodID(eglconfigClass, "<init>", "(I)V");
+ egldisplayConstructor = _env->GetMethodID(egldisplayClass, "<init>", "(J)V");
+ eglcontextConstructor = _env->GetMethodID(eglcontextClass, "<init>", "(J)V");
+ eglsurfaceConstructor = _env->GetMethodID(eglsurfaceClass, "<init>", "(J)V");
+ eglconfigConstructor = _env->GetMethodID(eglconfigClass, "<init>", "(J)V");
- jobject localeglNoContextObject = _env->NewObject(eglcontextClass, eglcontextConstructor, (jint)EGL_NO_CONTEXT);
+ jobject localeglNoContextObject = _env->NewObject(eglcontextClass, eglcontextConstructor, reinterpret_cast<jlong>(EGL_NO_CONTEXT));
eglNoContextObject = _env->NewGlobalRef(localeglNoContextObject);
- jobject localeglNoDisplayObject = _env->NewObject(egldisplayClass, egldisplayConstructor, (jint)EGL_NO_DISPLAY);
+ jobject localeglNoDisplayObject = _env->NewObject(egldisplayClass, egldisplayConstructor, reinterpret_cast<jlong>(EGL_NO_DISPLAY));
eglNoDisplayObject = _env->NewGlobalRef(localeglNoDisplayObject);
- jobject localeglNoSurfaceObject = _env->NewObject(eglsurfaceClass, eglsurfaceConstructor, (jint)EGL_NO_SURFACE);
+ jobject localeglNoSurfaceObject = _env->NewObject(eglsurfaceClass, eglsurfaceConstructor, reinterpret_cast<jlong>(EGL_NO_SURFACE));
eglNoSurfaceObject = _env->NewGlobalRef(localeglNoSurfaceObject);
@@ -107,7 +107,7 @@
"Object is set to null.");
}
- return (void*) (_env->CallIntMethod(obj, mid));
+ return reinterpret_cast<void*>(_env->CallLongMethod(obj, mid));
}
static jobject
@@ -127,7 +127,7 @@
return eglNoSurfaceObject;
}
- return _env->NewObject(cls, con, (jint)handle);
+ return _env->NewObject(cls, con, reinterpret_cast<jlong>(handle));
}
// --------------------------------------------------------------------------
diff --git a/core/jni/android_opengl_GLES10.cpp b/core/jni/android_opengl_GLES10.cpp
index cc34e99..21e19e1 100644
--- a/core/jni/android_opengl_GLES10.cpp
+++ b/core/jni/android_opengl_GLES10.cpp
@@ -111,7 +111,7 @@
getBasePointerID, buffer);
if (pointer != 0L) {
*array = NULL;
- return (void *) (jint) pointer;
+ return reinterpret_cast<void*>(pointer);
}
*array = (jarray) _env->CallStaticObjectMethod(nioAccessClass,
diff --git a/core/jni/android_opengl_GLES10Ext.cpp b/core/jni/android_opengl_GLES10Ext.cpp
index 9284384..bc83234 100644
--- a/core/jni/android_opengl_GLES10Ext.cpp
+++ b/core/jni/android_opengl_GLES10Ext.cpp
@@ -111,7 +111,7 @@
getBasePointerID, buffer);
if (pointer != 0L) {
*array = NULL;
- return (void *) (jint) pointer;
+ return reinterpret_cast<void*>(pointer);
}
*array = (jarray) _env->CallStaticObjectMethod(nioAccessClass,
diff --git a/core/jni/android_opengl_GLES11.cpp b/core/jni/android_opengl_GLES11.cpp
index 871e84d..a45f269 100644
--- a/core/jni/android_opengl_GLES11.cpp
+++ b/core/jni/android_opengl_GLES11.cpp
@@ -111,7 +111,7 @@
getBasePointerID, buffer);
if (pointer != 0L) {
*array = NULL;
- return (void *) (jint) pointer;
+ return reinterpret_cast<void*>(pointer);
}
*array = (jarray) _env->CallStaticObjectMethod(nioAccessClass,
@@ -578,7 +578,7 @@
(GLint)size,
(GLenum)type,
(GLsizei)stride,
- (GLvoid *)offset
+ reinterpret_cast<GLvoid *>(offset)
);
}
@@ -679,7 +679,7 @@
(GLenum)mode,
(GLsizei)count,
(GLenum)type,
- (GLvoid *)offset
+ reinterpret_cast<GLvoid *>(offset)
);
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
@@ -2302,7 +2302,7 @@
glNormalPointer(
(GLenum)type,
(GLsizei)stride,
- (GLvoid *)offset
+ reinterpret_cast<GLvoid *>(offset)
);
}
@@ -2529,7 +2529,7 @@
(GLint)size,
(GLenum)type,
(GLsizei)stride,
- (GLvoid *)offset
+ reinterpret_cast<GLvoid *>(offset)
);
}
@@ -2937,7 +2937,7 @@
(GLint)size,
(GLenum)type,
(GLsizei)stride,
- (GLvoid *)offset
+ reinterpret_cast<GLvoid *>(offset)
);
}
diff --git a/core/jni/android_opengl_GLES11Ext.cpp b/core/jni/android_opengl_GLES11Ext.cpp
index 3e038ad..05728ef 100644
--- a/core/jni/android_opengl_GLES11Ext.cpp
+++ b/core/jni/android_opengl_GLES11Ext.cpp
@@ -111,7 +111,7 @@
getBasePointerID, buffer);
if (pointer != 0L) {
*array = NULL;
- return (void *) (jint) pointer;
+ return reinterpret_cast<void*>(pointer);
}
*array = (jarray) _env->CallStaticObjectMethod(nioAccessClass,
diff --git a/core/jni/android_opengl_GLES20.cpp b/core/jni/android_opengl_GLES20.cpp
index db03b70..d3e5014 100644
--- a/core/jni/android_opengl_GLES20.cpp
+++ b/core/jni/android_opengl_GLES20.cpp
@@ -111,7 +111,7 @@
getBasePointerID, buffer);
if (pointer != 0L) {
*array = NULL;
- return (void *) (jint) pointer;
+ return reinterpret_cast<void*>(pointer);
}
*array = (jarray) _env->CallStaticObjectMethod(nioAccessClass,
@@ -1180,7 +1180,7 @@
(GLenum)mode,
(GLsizei)count,
(GLenum)type,
- (GLvoid *)offset
+ reinterpret_cast<GLvoid *>(offset)
);
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
@@ -1804,7 +1804,7 @@
(GLsizei *)length,
(GLint *)size,
(GLenum *)type,
- (char *)name
+ reinterpret_cast<char *>(name)
);
if (_typeArray) {
releasePointer(_env, _typeArray, type, JNI_TRUE);
@@ -2132,7 +2132,7 @@
(GLsizei *)length,
(GLint *)size,
(GLenum *)type,
- (char *)name
+ reinterpret_cast<char *>(name)
);
if (_typeArray) {
releasePointer(_env, _typeArray, type, JNI_TRUE);
@@ -3212,7 +3212,7 @@
(GLuint)shader,
(GLsizei)bufsize,
(GLsizei *)length,
- (char *)source
+ reinterpret_cast<char *>(source)
);
if (_array) {
releasePointer(_env, _array, length, JNI_TRUE);
@@ -5985,7 +5985,7 @@
(GLenum)type,
(GLboolean)normalized,
(GLsizei)stride,
- (GLvoid *)offset
+ reinterpret_cast<GLvoid *>(offset)
);
}
diff --git a/core/jni/android_opengl_GLES30.cpp b/core/jni/android_opengl_GLES30.cpp
index 4c62a75..8821352 100644
--- a/core/jni/android_opengl_GLES30.cpp
+++ b/core/jni/android_opengl_GLES30.cpp
@@ -111,7 +111,7 @@
getBasePointerID, buffer);
if (pointer != 0L) {
*array = NULL;
- return (void *) (jint) pointer;
+ return reinterpret_cast<void*>(pointer);
}
*array = (jarray) _env->CallStaticObjectMethod(nioAccessClass,
@@ -370,7 +370,7 @@
(GLuint)end,
(GLsizei)count,
(GLenum)type,
- (GLvoid *)offset
+ reinterpret_cast<GLvoid *>(offset)
);
}
@@ -419,7 +419,7 @@
(GLint)border,
(GLenum)format,
(GLenum)type,
- (GLvoid *)offset
+ reinterpret_cast<GLvoid *>(offset)
);
}
@@ -470,7 +470,7 @@
(GLsizei)depth,
(GLenum)format,
(GLenum)type,
- (GLvoid *)offset
+ reinterpret_cast<GLvoid *>(offset)
);
}
@@ -534,7 +534,7 @@
(GLsizei)depth,
(GLint)border,
(GLsizei)imageSize,
- (GLvoid *)offset
+ reinterpret_cast<GLvoid *>(offset)
);
}
@@ -585,7 +585,7 @@
(GLsizei)depth,
(GLenum)format,
(GLsizei)imageSize,
- (GLvoid *)offset
+ reinterpret_cast<GLvoid *>(offset)
);
}
@@ -2134,7 +2134,7 @@
(GLint)size,
(GLenum)type,
(GLsizei)stride,
- (GLvoid *)offset
+ reinterpret_cast<GLvoid *>(offset)
);
}
diff --git a/core/jni/android_os_Debug.cpp b/core/jni/android_os_Debug.cpp
index a041693..d4873d6 100644
--- a/core/jni/android_os_Debug.cpp
+++ b/core/jni/android_os_Debug.cpp
@@ -800,7 +800,7 @@
fprintf(fp, "Total memory: %zu\n", totalMemory);
fprintf(fp, "Allocation records: %zd\n", recordCount);
if (backtraceSize != BACKTRACE_SIZE) {
- fprintf(fp, "WARNING: mismatched backtrace sizes (%d vs. %d)\n",
+ fprintf(fp, "WARNING: mismatched backtrace sizes (%zu vs. %d)\n",
backtraceSize, BACKTRACE_SIZE);
}
fprintf(fp, "\n");
@@ -823,7 +823,11 @@
if (backtrace[bt] == 0) {
break;
} else {
+#ifdef __LP64__
+ fprintf(fp, " %016x", backtrace[bt]);
+#else
fprintf(fp, " %08x", backtrace[bt]);
+#endif
}
}
fprintf(fp, "\n");
diff --git a/core/jni/android_os_MemoryFile.cpp b/core/jni/android_os_MemoryFile.cpp
index 7134191..27b29bc 100644
--- a/core/jni/android_os_MemoryFile.cpp
+++ b/core/jni/android_os_MemoryFile.cpp
@@ -43,19 +43,20 @@
return jniCreateFileDescriptor(env, result);
}
-static jint android_os_MemoryFile_mmap(JNIEnv* env, jobject clazz, jobject fileDescriptor,
+static jlong android_os_MemoryFile_mmap(JNIEnv* env, jobject clazz, jobject fileDescriptor,
jint length, jint prot)
{
int fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
- jint result = (jint)mmap(NULL, length, prot, MAP_SHARED, fd, 0);
- if (!result)
+ void* result = mmap(NULL, length, prot, MAP_SHARED, fd, 0);
+ if (result == MAP_FAILED) {
jniThrowException(env, "java/io/IOException", "mmap failed");
- return result;
+ }
+ return reinterpret_cast<jlong>(result);
}
-static void android_os_MemoryFile_munmap(JNIEnv* env, jobject clazz, jint addr, jint length)
+static void android_os_MemoryFile_munmap(JNIEnv* env, jobject clazz, jlong addr, jint length)
{
- int result = munmap((void *)addr, length);
+ int result = munmap(reinterpret_cast<void *>(addr), length);
if (result < 0)
jniThrowException(env, "java/io/IOException", "munmap failed");
}
@@ -70,7 +71,7 @@
}
static jint android_os_MemoryFile_read(JNIEnv* env, jobject clazz,
- jobject fileDescriptor, jint address, jbyteArray buffer, jint srcOffset, jint destOffset,
+ jobject fileDescriptor, jlong address, jbyteArray buffer, jint srcOffset, jint destOffset,
jint count, jboolean unpinned)
{
int fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
@@ -89,7 +90,7 @@
}
static jint android_os_MemoryFile_write(JNIEnv* env, jobject clazz,
- jobject fileDescriptor, jint address, jbyteArray buffer, jint srcOffset, jint destOffset,
+ jobject fileDescriptor, jlong address, jbyteArray buffer, jint srcOffset, jint destOffset,
jint count, jboolean unpinned)
{
int fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
@@ -138,11 +139,11 @@
static const JNINativeMethod methods[] = {
{"native_open", "(Ljava/lang/String;I)Ljava/io/FileDescriptor;", (void*)android_os_MemoryFile_open},
- {"native_mmap", "(Ljava/io/FileDescriptor;II)I", (void*)android_os_MemoryFile_mmap},
- {"native_munmap", "(II)V", (void*)android_os_MemoryFile_munmap},
+ {"native_mmap", "(Ljava/io/FileDescriptor;II)J", (void*)android_os_MemoryFile_mmap},
+ {"native_munmap", "(JI)V", (void*)android_os_MemoryFile_munmap},
{"native_close", "(Ljava/io/FileDescriptor;)V", (void*)android_os_MemoryFile_close},
- {"native_read", "(Ljava/io/FileDescriptor;I[BIIIZ)I", (void*)android_os_MemoryFile_read},
- {"native_write", "(Ljava/io/FileDescriptor;I[BIIIZ)V", (void*)android_os_MemoryFile_write},
+ {"native_read", "(Ljava/io/FileDescriptor;J[BIIIZ)I", (void*)android_os_MemoryFile_read},
+ {"native_write", "(Ljava/io/FileDescriptor;J[BIIIZ)V", (void*)android_os_MemoryFile_write},
{"native_pin", "(Ljava/io/FileDescriptor;Z)V", (void*)android_os_MemoryFile_pin},
{"native_get_size", "(Ljava/io/FileDescriptor;)I",
(void*)android_os_MemoryFile_get_size}
diff --git a/core/jni/android_os_MessageQueue.cpp b/core/jni/android_os_MessageQueue.cpp
index c9c3720..a8ed895 100644
--- a/core/jni/android_os_MessageQueue.cpp
+++ b/core/jni/android_os_MessageQueue.cpp
@@ -110,11 +110,11 @@
// ----------------------------------------------------------------------------
sp<MessageQueue> android_os_MessageQueue_getMessageQueue(JNIEnv* env, jobject messageQueueObj) {
- jint intPtr = env->GetIntField(messageQueueObj, gMessageQueueClassInfo.mPtr);
- return reinterpret_cast<NativeMessageQueue*>(intPtr);
+ jlong ptr = env->GetLongField(messageQueueObj, gMessageQueueClassInfo.mPtr);
+ return reinterpret_cast<NativeMessageQueue*>(ptr);
}
-static jint android_os_MessageQueue_nativeInit(JNIEnv* env, jclass clazz) {
+static jlong android_os_MessageQueue_nativeInit(JNIEnv* env, jclass clazz) {
NativeMessageQueue* nativeMessageQueue = new NativeMessageQueue();
if (!nativeMessageQueue) {
jniThrowRuntimeException(env, "Unable to allocate native queue");
@@ -122,26 +122,26 @@
}
nativeMessageQueue->incStrong(env);
- return reinterpret_cast<jint>(nativeMessageQueue);
+ return reinterpret_cast<jlong>(nativeMessageQueue);
}
-static void android_os_MessageQueue_nativeDestroy(JNIEnv* env, jclass clazz, jint ptr) {
+static void android_os_MessageQueue_nativeDestroy(JNIEnv* env, jclass clazz, jlong ptr) {
NativeMessageQueue* nativeMessageQueue = reinterpret_cast<NativeMessageQueue*>(ptr);
nativeMessageQueue->decStrong(env);
}
static void android_os_MessageQueue_nativePollOnce(JNIEnv* env, jclass clazz,
- jint ptr, jint timeoutMillis) {
+ jlong ptr, jint timeoutMillis) {
NativeMessageQueue* nativeMessageQueue = reinterpret_cast<NativeMessageQueue*>(ptr);
nativeMessageQueue->pollOnce(env, timeoutMillis);
}
-static void android_os_MessageQueue_nativeWake(JNIEnv* env, jclass clazz, jint ptr) {
+static void android_os_MessageQueue_nativeWake(JNIEnv* env, jclass clazz, jlong ptr) {
NativeMessageQueue* nativeMessageQueue = reinterpret_cast<NativeMessageQueue*>(ptr);
return nativeMessageQueue->wake();
}
-static jboolean android_os_MessageQueue_nativeIsIdling(JNIEnv* env, jclass clazz, jint ptr) {
+static jboolean android_os_MessageQueue_nativeIsIdling(JNIEnv* env, jclass clazz, jlong ptr) {
NativeMessageQueue* nativeMessageQueue = reinterpret_cast<NativeMessageQueue*>(ptr);
return nativeMessageQueue->getLooper()->isIdling();
}
@@ -150,11 +150,11 @@
static JNINativeMethod gMessageQueueMethods[] = {
/* name, signature, funcPtr */
- { "nativeInit", "()I", (void*)android_os_MessageQueue_nativeInit },
- { "nativeDestroy", "(I)V", (void*)android_os_MessageQueue_nativeDestroy },
- { "nativePollOnce", "(II)V", (void*)android_os_MessageQueue_nativePollOnce },
- { "nativeWake", "(I)V", (void*)android_os_MessageQueue_nativeWake },
- { "nativeIsIdling", "(I)Z", (void*)android_os_MessageQueue_nativeIsIdling }
+ { "nativeInit", "()J", (void*)android_os_MessageQueue_nativeInit },
+ { "nativeDestroy", "(J)V", (void*)android_os_MessageQueue_nativeDestroy },
+ { "nativePollOnce", "(JI)V", (void*)android_os_MessageQueue_nativePollOnce },
+ { "nativeWake", "(J)V", (void*)android_os_MessageQueue_nativeWake },
+ { "nativeIsIdling", "(J)Z", (void*)android_os_MessageQueue_nativeIsIdling }
};
#define FIND_CLASS(var, className) \
@@ -174,7 +174,7 @@
FIND_CLASS(clazz, "android/os/MessageQueue");
GET_FIELD_ID(gMessageQueueClassInfo.mPtr, clazz,
- "mPtr", "I");
+ "mPtr", "J");
return 0;
}
diff --git a/core/jni/android_os_Parcel.cpp b/core/jni/android_os_Parcel.cpp
index aa451e3..50f6c73 100644
--- a/core/jni/android_os_Parcel.cpp
+++ b/core/jni/android_os_Parcel.cpp
@@ -69,7 +69,7 @@
Parcel* parcelForJavaObject(JNIEnv* env, jobject obj)
{
if (obj) {
- Parcel* p = (Parcel*)env->GetIntField(obj, gParcelOffsets.mNativePtr);
+ Parcel* p = (Parcel*)env->GetLongField(obj, gParcelOffsets.mNativePtr);
if (p != NULL) {
return p;
}
@@ -88,31 +88,31 @@
env->CallVoidMethod(parcelObj, gParcelOffsets.recycle);
}
-static jint android_os_Parcel_dataSize(JNIEnv* env, jclass clazz, jint nativePtr)
+static jint android_os_Parcel_dataSize(JNIEnv* env, jclass clazz, jlong nativePtr)
{
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
return parcel ? parcel->dataSize() : 0;
}
-static jint android_os_Parcel_dataAvail(JNIEnv* env, jclass clazz, jint nativePtr)
+static jint android_os_Parcel_dataAvail(JNIEnv* env, jclass clazz, jlong nativePtr)
{
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
return parcel ? parcel->dataAvail() : 0;
}
-static jint android_os_Parcel_dataPosition(JNIEnv* env, jclass clazz, jint nativePtr)
+static jint android_os_Parcel_dataPosition(JNIEnv* env, jclass clazz, jlong nativePtr)
{
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
return parcel ? parcel->dataPosition() : 0;
}
-static jint android_os_Parcel_dataCapacity(JNIEnv* env, jclass clazz, jint nativePtr)
+static jint android_os_Parcel_dataCapacity(JNIEnv* env, jclass clazz, jlong nativePtr)
{
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
return parcel ? parcel->dataCapacity() : 0;
}
-static void android_os_Parcel_setDataSize(JNIEnv* env, jclass clazz, jint nativePtr, jint size)
+static void android_os_Parcel_setDataSize(JNIEnv* env, jclass clazz, jlong nativePtr, jint size)
{
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
if (parcel != NULL) {
@@ -123,7 +123,7 @@
}
}
-static void android_os_Parcel_setDataPosition(JNIEnv* env, jclass clazz, jint nativePtr, jint pos)
+static void android_os_Parcel_setDataPosition(JNIEnv* env, jclass clazz, jlong nativePtr, jint pos)
{
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
if (parcel != NULL) {
@@ -131,7 +131,7 @@
}
}
-static void android_os_Parcel_setDataCapacity(JNIEnv* env, jclass clazz, jint nativePtr, jint size)
+static void android_os_Parcel_setDataCapacity(JNIEnv* env, jclass clazz, jlong nativePtr, jint size)
{
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
if (parcel != NULL) {
@@ -142,7 +142,7 @@
}
}
-static jboolean android_os_Parcel_pushAllowFds(JNIEnv* env, jclass clazz, jint nativePtr, jboolean allowFds)
+static jboolean android_os_Parcel_pushAllowFds(JNIEnv* env, jclass clazz, jlong nativePtr, jboolean allowFds)
{
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
jboolean ret = JNI_TRUE;
@@ -152,7 +152,7 @@
return ret;
}
-static void android_os_Parcel_restoreAllowFds(JNIEnv* env, jclass clazz, jint nativePtr, jboolean lastValue)
+static void android_os_Parcel_restoreAllowFds(JNIEnv* env, jclass clazz, jlong nativePtr, jboolean lastValue)
{
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
if (parcel != NULL) {
@@ -160,7 +160,7 @@
}
}
-static void android_os_Parcel_writeNative(JNIEnv* env, jclass clazz, jint nativePtr, jobject data,
+static void android_os_Parcel_writeNative(JNIEnv* env, jclass clazz, jlong nativePtr, jobject data,
jint offset, jint length)
{
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
@@ -187,7 +187,7 @@
}
}
-static void android_os_Parcel_writeInt(JNIEnv* env, jclass clazz, jint nativePtr, jint val) {
+static void android_os_Parcel_writeInt(JNIEnv* env, jclass clazz, jlong nativePtr, jint val) {
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
const status_t err = parcel->writeInt32(val);
if (err != NO_ERROR) {
@@ -195,7 +195,7 @@
}
}
-static void android_os_Parcel_writeLong(JNIEnv* env, jclass clazz, jint nativePtr, jlong val)
+static void android_os_Parcel_writeLong(JNIEnv* env, jclass clazz, jlong nativePtr, jlong val)
{
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
if (parcel != NULL) {
@@ -206,7 +206,7 @@
}
}
-static void android_os_Parcel_writeFloat(JNIEnv* env, jclass clazz, jint nativePtr, jfloat val)
+static void android_os_Parcel_writeFloat(JNIEnv* env, jclass clazz, jlong nativePtr, jfloat val)
{
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
if (parcel != NULL) {
@@ -217,7 +217,7 @@
}
}
-static void android_os_Parcel_writeDouble(JNIEnv* env, jclass clazz, jint nativePtr, jdouble val)
+static void android_os_Parcel_writeDouble(JNIEnv* env, jclass clazz, jlong nativePtr, jdouble val)
{
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
if (parcel != NULL) {
@@ -228,7 +228,7 @@
}
}
-static void android_os_Parcel_writeString(JNIEnv* env, jclass clazz, jint nativePtr, jstring val)
+static void android_os_Parcel_writeString(JNIEnv* env, jclass clazz, jlong nativePtr, jstring val)
{
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
if (parcel != NULL) {
@@ -248,7 +248,7 @@
}
}
-static void android_os_Parcel_writeStrongBinder(JNIEnv* env, jclass clazz, jint nativePtr, jobject object)
+static void android_os_Parcel_writeStrongBinder(JNIEnv* env, jclass clazz, jlong nativePtr, jobject object)
{
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
if (parcel != NULL) {
@@ -259,7 +259,7 @@
}
}
-static void android_os_Parcel_writeFileDescriptor(JNIEnv* env, jclass clazz, jint nativePtr, jobject object)
+static void android_os_Parcel_writeFileDescriptor(JNIEnv* env, jclass clazz, jlong nativePtr, jobject object)
{
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
if (parcel != NULL) {
@@ -271,7 +271,7 @@
}
}
-static jbyteArray android_os_Parcel_createByteArray(JNIEnv* env, jclass clazz, jint nativePtr)
+static jbyteArray android_os_Parcel_createByteArray(JNIEnv* env, jclass clazz, jlong nativePtr)
{
jbyteArray ret = NULL;
@@ -297,7 +297,7 @@
return ret;
}
-static jint android_os_Parcel_readInt(JNIEnv* env, jclass clazz, jint nativePtr)
+static jint android_os_Parcel_readInt(JNIEnv* env, jclass clazz, jlong nativePtr)
{
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
if (parcel != NULL) {
@@ -306,7 +306,7 @@
return 0;
}
-static jlong android_os_Parcel_readLong(JNIEnv* env, jclass clazz, jint nativePtr)
+static jlong android_os_Parcel_readLong(JNIEnv* env, jclass clazz, jlong nativePtr)
{
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
if (parcel != NULL) {
@@ -315,7 +315,7 @@
return 0;
}
-static jfloat android_os_Parcel_readFloat(JNIEnv* env, jclass clazz, jint nativePtr)
+static jfloat android_os_Parcel_readFloat(JNIEnv* env, jclass clazz, jlong nativePtr)
{
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
if (parcel != NULL) {
@@ -324,7 +324,7 @@
return 0;
}
-static jdouble android_os_Parcel_readDouble(JNIEnv* env, jclass clazz, jint nativePtr)
+static jdouble android_os_Parcel_readDouble(JNIEnv* env, jclass clazz, jlong nativePtr)
{
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
if (parcel != NULL) {
@@ -333,7 +333,7 @@
return 0;
}
-static jstring android_os_Parcel_readString(JNIEnv* env, jclass clazz, jint nativePtr)
+static jstring android_os_Parcel_readString(JNIEnv* env, jclass clazz, jlong nativePtr)
{
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
if (parcel != NULL) {
@@ -347,7 +347,7 @@
return NULL;
}
-static jobject android_os_Parcel_readStrongBinder(JNIEnv* env, jclass clazz, jint nativePtr)
+static jobject android_os_Parcel_readStrongBinder(JNIEnv* env, jclass clazz, jlong nativePtr)
{
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
if (parcel != NULL) {
@@ -356,7 +356,7 @@
return NULL;
}
-static jobject android_os_Parcel_readFileDescriptor(JNIEnv* env, jclass clazz, jint nativePtr)
+static jobject android_os_Parcel_readFileDescriptor(JNIEnv* env, jclass clazz, jlong nativePtr)
{
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
if (parcel != NULL) {
@@ -468,13 +468,13 @@
}
}
-static jint android_os_Parcel_create(JNIEnv* env, jclass clazz)
+static jlong android_os_Parcel_create(JNIEnv* env, jclass clazz)
{
Parcel* parcel = new Parcel();
- return reinterpret_cast<jint>(parcel);
+ return reinterpret_cast<jlong>(parcel);
}
-static void android_os_Parcel_freeBuffer(JNIEnv* env, jclass clazz, jint nativePtr)
+static void android_os_Parcel_freeBuffer(JNIEnv* env, jclass clazz, jlong nativePtr)
{
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
if (parcel != NULL) {
@@ -482,13 +482,13 @@
}
}
-static void android_os_Parcel_destroy(JNIEnv* env, jclass clazz, jint nativePtr)
+static void android_os_Parcel_destroy(JNIEnv* env, jclass clazz, jlong nativePtr)
{
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
delete parcel;
}
-static jbyteArray android_os_Parcel_marshall(JNIEnv* env, jclass clazz, jint nativePtr)
+static jbyteArray android_os_Parcel_marshall(JNIEnv* env, jclass clazz, jlong nativePtr)
{
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
if (parcel == NULL) {
@@ -517,7 +517,7 @@
return ret;
}
-static void android_os_Parcel_unmarshall(JNIEnv* env, jclass clazz, jint nativePtr,
+static void android_os_Parcel_unmarshall(JNIEnv* env, jclass clazz, jlong nativePtr,
jbyteArray data, jint offset, jint length)
{
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
@@ -538,8 +538,8 @@
}
}
-static void android_os_Parcel_appendFrom(JNIEnv* env, jclass clazz, jint thisNativePtr,
- jint otherNativePtr, jint offset, jint length)
+static void android_os_Parcel_appendFrom(JNIEnv* env, jclass clazz, jlong thisNativePtr,
+ jlong otherNativePtr, jint offset, jint length)
{
Parcel* thisParcel = reinterpret_cast<Parcel*>(thisNativePtr);
if (thisParcel == NULL) {
@@ -556,7 +556,7 @@
}
}
-static jboolean android_os_Parcel_hasFileDescriptors(JNIEnv* env, jclass clazz, jint nativePtr)
+static jboolean android_os_Parcel_hasFileDescriptors(JNIEnv* env, jclass clazz, jlong nativePtr)
{
jboolean ret = JNI_FALSE;
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
@@ -568,7 +568,7 @@
return ret;
}
-static void android_os_Parcel_writeInterfaceToken(JNIEnv* env, jclass clazz, jint nativePtr,
+static void android_os_Parcel_writeInterfaceToken(JNIEnv* env, jclass clazz, jlong nativePtr,
jstring name)
{
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
@@ -583,7 +583,7 @@
}
}
-static void android_os_Parcel_enforceInterface(JNIEnv* env, jclass clazz, jint nativePtr, jstring name)
+static void android_os_Parcel_enforceInterface(JNIEnv* env, jclass clazz, jlong nativePtr, jstring name)
{
jboolean ret = JNI_FALSE;
@@ -622,50 +622,50 @@
// ----------------------------------------------------------------------------
static const JNINativeMethod gParcelMethods[] = {
- {"nativeDataSize", "(I)I", (void*)android_os_Parcel_dataSize},
- {"nativeDataAvail", "(I)I", (void*)android_os_Parcel_dataAvail},
- {"nativeDataPosition", "(I)I", (void*)android_os_Parcel_dataPosition},
- {"nativeDataCapacity", "(I)I", (void*)android_os_Parcel_dataCapacity},
- {"nativeSetDataSize", "(II)V", (void*)android_os_Parcel_setDataSize},
- {"nativeSetDataPosition", "(II)V", (void*)android_os_Parcel_setDataPosition},
- {"nativeSetDataCapacity", "(II)V", (void*)android_os_Parcel_setDataCapacity},
+ {"nativeDataSize", "(J)I", (void*)android_os_Parcel_dataSize},
+ {"nativeDataAvail", "(J)I", (void*)android_os_Parcel_dataAvail},
+ {"nativeDataPosition", "(J)I", (void*)android_os_Parcel_dataPosition},
+ {"nativeDataCapacity", "(J)I", (void*)android_os_Parcel_dataCapacity},
+ {"nativeSetDataSize", "(JI)V", (void*)android_os_Parcel_setDataSize},
+ {"nativeSetDataPosition", "(JI)V", (void*)android_os_Parcel_setDataPosition},
+ {"nativeSetDataCapacity", "(JI)V", (void*)android_os_Parcel_setDataCapacity},
- {"nativePushAllowFds", "(IZ)Z", (void*)android_os_Parcel_pushAllowFds},
- {"nativeRestoreAllowFds", "(IZ)V", (void*)android_os_Parcel_restoreAllowFds},
+ {"nativePushAllowFds", "(JZ)Z", (void*)android_os_Parcel_pushAllowFds},
+ {"nativeRestoreAllowFds", "(JZ)V", (void*)android_os_Parcel_restoreAllowFds},
- {"nativeWriteByteArray", "(I[BII)V", (void*)android_os_Parcel_writeNative},
- {"nativeWriteInt", "(II)V", (void*)android_os_Parcel_writeInt},
- {"nativeWriteLong", "(IJ)V", (void*)android_os_Parcel_writeLong},
- {"nativeWriteFloat", "(IF)V", (void*)android_os_Parcel_writeFloat},
- {"nativeWriteDouble", "(ID)V", (void*)android_os_Parcel_writeDouble},
- {"nativeWriteString", "(ILjava/lang/String;)V", (void*)android_os_Parcel_writeString},
- {"nativeWriteStrongBinder", "(ILandroid/os/IBinder;)V", (void*)android_os_Parcel_writeStrongBinder},
- {"nativeWriteFileDescriptor", "(ILjava/io/FileDescriptor;)V", (void*)android_os_Parcel_writeFileDescriptor},
+ {"nativeWriteByteArray", "(J[BII)V", (void*)android_os_Parcel_writeNative},
+ {"nativeWriteInt", "(JI)V", (void*)android_os_Parcel_writeInt},
+ {"nativeWriteLong", "(JJ)V", (void*)android_os_Parcel_writeLong},
+ {"nativeWriteFloat", "(JF)V", (void*)android_os_Parcel_writeFloat},
+ {"nativeWriteDouble", "(JD)V", (void*)android_os_Parcel_writeDouble},
+ {"nativeWriteString", "(JLjava/lang/String;)V", (void*)android_os_Parcel_writeString},
+ {"nativeWriteStrongBinder", "(JLandroid/os/IBinder;)V", (void*)android_os_Parcel_writeStrongBinder},
+ {"nativeWriteFileDescriptor", "(JLjava/io/FileDescriptor;)V", (void*)android_os_Parcel_writeFileDescriptor},
- {"nativeCreateByteArray", "(I)[B", (void*)android_os_Parcel_createByteArray},
- {"nativeReadInt", "(I)I", (void*)android_os_Parcel_readInt},
- {"nativeReadLong", "(I)J", (void*)android_os_Parcel_readLong},
- {"nativeReadFloat", "(I)F", (void*)android_os_Parcel_readFloat},
- {"nativeReadDouble", "(I)D", (void*)android_os_Parcel_readDouble},
- {"nativeReadString", "(I)Ljava/lang/String;", (void*)android_os_Parcel_readString},
- {"nativeReadStrongBinder", "(I)Landroid/os/IBinder;", (void*)android_os_Parcel_readStrongBinder},
- {"nativeReadFileDescriptor", "(I)Ljava/io/FileDescriptor;", (void*)android_os_Parcel_readFileDescriptor},
+ {"nativeCreateByteArray", "(J)[B", (void*)android_os_Parcel_createByteArray},
+ {"nativeReadInt", "(J)I", (void*)android_os_Parcel_readInt},
+ {"nativeReadLong", "(J)J", (void*)android_os_Parcel_readLong},
+ {"nativeReadFloat", "(J)F", (void*)android_os_Parcel_readFloat},
+ {"nativeReadDouble", "(J)D", (void*)android_os_Parcel_readDouble},
+ {"nativeReadString", "(J)Ljava/lang/String;", (void*)android_os_Parcel_readString},
+ {"nativeReadStrongBinder", "(J)Landroid/os/IBinder;", (void*)android_os_Parcel_readStrongBinder},
+ {"nativeReadFileDescriptor", "(J)Ljava/io/FileDescriptor;", (void*)android_os_Parcel_readFileDescriptor},
{"openFileDescriptor", "(Ljava/lang/String;I)Ljava/io/FileDescriptor;", (void*)android_os_Parcel_openFileDescriptor},
{"dupFileDescriptor", "(Ljava/io/FileDescriptor;)Ljava/io/FileDescriptor;", (void*)android_os_Parcel_dupFileDescriptor},
{"closeFileDescriptor", "(Ljava/io/FileDescriptor;)V", (void*)android_os_Parcel_closeFileDescriptor},
{"clearFileDescriptor", "(Ljava/io/FileDescriptor;)V", (void*)android_os_Parcel_clearFileDescriptor},
- {"nativeCreate", "()I", (void*)android_os_Parcel_create},
- {"nativeFreeBuffer", "(I)V", (void*)android_os_Parcel_freeBuffer},
- {"nativeDestroy", "(I)V", (void*)android_os_Parcel_destroy},
+ {"nativeCreate", "()J", (void*)android_os_Parcel_create},
+ {"nativeFreeBuffer", "(J)V", (void*)android_os_Parcel_freeBuffer},
+ {"nativeDestroy", "(J)V", (void*)android_os_Parcel_destroy},
- {"nativeMarshall", "(I)[B", (void*)android_os_Parcel_marshall},
- {"nativeUnmarshall", "(I[BII)V", (void*)android_os_Parcel_unmarshall},
- {"nativeAppendFrom", "(IIII)V", (void*)android_os_Parcel_appendFrom},
- {"nativeHasFileDescriptors", "(I)Z", (void*)android_os_Parcel_hasFileDescriptors},
- {"nativeWriteInterfaceToken", "(ILjava/lang/String;)V", (void*)android_os_Parcel_writeInterfaceToken},
- {"nativeEnforceInterface", "(ILjava/lang/String;)V", (void*)android_os_Parcel_enforceInterface},
+ {"nativeMarshall", "(J)[B", (void*)android_os_Parcel_marshall},
+ {"nativeUnmarshall", "(J[BII)V", (void*)android_os_Parcel_unmarshall},
+ {"nativeAppendFrom", "(JJII)V", (void*)android_os_Parcel_appendFrom},
+ {"nativeHasFileDescriptors", "(J)Z", (void*)android_os_Parcel_hasFileDescriptors},
+ {"nativeWriteInterfaceToken", "(JLjava/lang/String;)V", (void*)android_os_Parcel_writeInterfaceToken},
+ {"nativeEnforceInterface", "(JLjava/lang/String;)V", (void*)android_os_Parcel_enforceInterface},
};
const char* const kParcelPathName = "android/os/Parcel";
@@ -678,7 +678,7 @@
LOG_FATAL_IF(clazz == NULL, "Unable to find class android.os.Parcel");
gParcelOffsets.clazz = (jclass) env->NewGlobalRef(clazz);
- gParcelOffsets.mNativePtr = env->GetFieldID(clazz, "mNativePtr", "I");
+ gParcelOffsets.mNativePtr = env->GetFieldID(clazz, "mNativePtr", "J");
gParcelOffsets.obtain = env->GetStaticMethodID(clazz, "obtain",
"()Landroid/os/Parcel;");
gParcelOffsets.recycle = env->GetMethodID(clazz, "recycle", "()V");
diff --git a/core/jni/android_os_SELinux.cpp b/core/jni/android_os_SELinux.cpp
index ca278cf..26405b5 100644
--- a/core/jni/android_os_SELinux.cpp
+++ b/core/jni/android_os_SELinux.cpp
@@ -411,11 +411,11 @@
ScopedUtfChars pathname(env, pathnameStr);
if (pathname.c_str() == NULL) {
- ALOGV("restorecon(%p) => threw exception", pathname);
+ ALOGV("restorecon(%p) => threw exception", pathnameStr);
return false;
}
- int ret = selinux_android_restorecon(pathname.c_str());
+ int ret = selinux_android_restorecon(pathname.c_str(), 0);
ALOGV("restorecon(%s) => %d", pathname.c_str(), ret);
return (ret == 0);
}
@@ -443,8 +443,21 @@
static int log_callback(int type, const char *fmt, ...) {
va_list ap;
+ int priority;
+
+ switch (type) {
+ case SELINUX_WARNING:
+ priority = ANDROID_LOG_WARN;
+ break;
+ case SELINUX_INFO:
+ priority = ANDROID_LOG_INFO;
+ break;
+ default:
+ priority = ANDROID_LOG_ERROR;
+ break;
+ }
va_start(ap, fmt);
- LOG_PRI_VA(ANDROID_LOG_ERROR, "SELinux", fmt, ap);
+ LOG_PRI_VA(priority, "SELinux", fmt, ap);
va_end(ap);
return 0;
}
diff --git a/core/jni/android_os_SystemClock.cpp b/core/jni/android_os_SystemClock.cpp
index 5f4d570..6247844 100644
--- a/core/jni/android_os_SystemClock.cpp
+++ b/core/jni/android_os_SystemClock.cpp
@@ -19,13 +19,6 @@
* System clock functions.
*/
-#ifdef HAVE_ANDROID_OS
-#include <linux/ioctl.h>
-#include <linux/rtc.h>
-#include <utils/Atomic.h>
-#include <linux/android_alarm.h>
-#endif
-
#include <sys/time.h>
#include <limits.h>
#include <fcntl.h>
@@ -43,109 +36,6 @@
namespace android {
-static int setCurrentTimeMillisAlarmDriver(struct timeval *tv)
-{
- struct timespec ts;
- int fd;
- int res;
-
- fd = open("/dev/alarm", O_RDWR);
- if(fd < 0) {
- ALOGV("Unable to open alarm driver: %s\n", strerror(errno));
- return -1;
- }
- ts.tv_sec = tv->tv_sec;
- ts.tv_nsec = tv->tv_usec * 1000;
- res = ioctl(fd, ANDROID_ALARM_SET_RTC, &ts);
- if (res < 0)
- ALOGV("ANDROID_ALARM_SET_RTC ioctl failed: %s\n", strerror(errno));
- close(fd);
- return res;
-}
-
-static int setCurrentTimeMillisRtc(struct timeval *tv)
-{
- struct rtc_time rtc;
- struct tm tm, *gmtime_res;
- int fd;
- int res;
-
- fd = open("/dev/rtc0", O_RDWR);
- if (fd < 0) {
- ALOGV("Unable to open RTC driver: %s\n", strerror(errno));
- return -1;
- }
-
- res = settimeofday(tv, NULL);
- if (res < 0) {
- ALOGV("settimeofday() failed: %s\n", strerror(errno));
- goto done;
- }
-
- gmtime_res = gmtime_r(&tv->tv_sec, &tm);
- if (!gmtime_res) {
- ALOGV("gmtime_r() failed: %s\n", strerror(errno));
- res = -1;
- goto done;
- }
-
- memset(&rtc, 0, sizeof(rtc));
- rtc.tm_sec = tm.tm_sec;
- rtc.tm_min = tm.tm_min;
- rtc.tm_hour = tm.tm_hour;
- rtc.tm_mday = tm.tm_mday;
- rtc.tm_mon = tm.tm_mon;
- rtc.tm_year = tm.tm_year;
- rtc.tm_wday = tm.tm_wday;
- rtc.tm_yday = tm.tm_yday;
- rtc.tm_isdst = tm.tm_isdst;
- res = ioctl(fd, RTC_SET_TIME, &rtc);
- if (res < 0)
- ALOGV("RTC_SET_TIME ioctl failed: %s\n", strerror(errno));
-done:
- close(fd);
- return res;
-}
-
-/*
- * Set the current time. This only works when running as root.
- */
-static int setCurrentTimeMillis(int64_t millis)
-{
- struct timeval tv;
- int ret;
-
- if (millis <= 0 || millis / 1000LL >= INT_MAX) {
- return -1;
- }
-
- tv.tv_sec = (time_t) (millis / 1000LL);
- tv.tv_usec = (suseconds_t) ((millis % 1000LL) * 1000LL);
-
- ALOGD("Setting time of day to sec=%d\n", (int) tv.tv_sec);
-
- ret = setCurrentTimeMillisAlarmDriver(&tv);
- if (ret < 0)
- ret = setCurrentTimeMillisRtc(&tv);
-
- if(ret < 0) {
- ALOGW("Unable to set rtc to %ld: %s\n", tv.tv_sec, strerror(errno));
- ret = -1;
- }
- return ret;
-}
-
-/*
- * native public static void setCurrentTimeMillis(long millis)
- *
- * Set the current time. This only works when running as root.
- */
-static jboolean android_os_SystemClock_setCurrentTimeMillis(JNIEnv* env,
- jobject clazz, jlong millis)
-{
- return (setCurrentTimeMillis(millis) == 0);
-}
-
/*
* native public static long uptimeMillis();
*/
@@ -230,8 +120,6 @@
*/
static JNINativeMethod gMethods[] = {
/* name, signature, funcPtr */
- { "setCurrentTimeMillis", "(J)Z",
- (void*) android_os_SystemClock_setCurrentTimeMillis },
{ "uptimeMillis", "()J",
(void*) android_os_SystemClock_uptimeMillis },
{ "elapsedRealtime", "()J",
diff --git a/core/jni/android_server_NetworkManagementSocketTagger.cpp b/core/jni/android_server_NetworkManagementSocketTagger.cpp
index 12beff7..7e12b1e 100644
--- a/core/jni/android_server_NetworkManagementSocketTagger.cpp
+++ b/core/jni/android_server_NetworkManagementSocketTagger.cpp
@@ -47,8 +47,8 @@
return (jint)res;
}
-static int QTagUid_untagSocketFd(JNIEnv* env, jclass,
- jobject fileDescriptor) {
+static jint QTagUid_untagSocketFd(JNIEnv* env, jclass,
+ jobject fileDescriptor) {
int userFd = jniGetFDFromFileDescriptor(env, fileDescriptor);
if (env->ExceptionOccurred() != NULL) {
diff --git a/core/jni/android_text_AndroidBidi.cpp b/core/jni/android_text_AndroidBidi.cpp
index d50a69f..6f7ee49 100644
--- a/core/jni/android_text_AndroidBidi.cpp
+++ b/core/jni/android_text_AndroidBidi.cpp
@@ -26,7 +26,7 @@
namespace android {
static jint runBidi(JNIEnv* env, jobject obj, jint dir, jcharArray chsArray,
- jbyteArray infoArray, int n, jboolean haveInfo)
+ jbyteArray infoArray, jint n, jboolean haveInfo)
{
// Parameters are checked on java side
// Failures from GetXXXArrayElements indicate a serious out-of-memory condition
diff --git a/core/jni/android_text_AndroidCharacter.cpp b/core/jni/android_text_AndroidCharacter.cpp
index 8b85a7b7..94bd40f 100644
--- a/core/jni/android_text_AndroidCharacter.cpp
+++ b/core/jni/android_text_AndroidCharacter.cpp
@@ -51,7 +51,8 @@
namespace android {
-static void getDirectionalities(JNIEnv* env, jobject obj, jcharArray srcArray, jbyteArray destArray, int count)
+static void getDirectionalities(JNIEnv* env, jobject obj, jcharArray srcArray,
+ jbyteArray destArray, jint count)
{
ScopedCharArrayRO src(env, srcArray);
if (src.get() == NULL) {
@@ -102,7 +103,7 @@
}
static void getEastAsianWidths(JNIEnv* env, jobject obj, jcharArray srcArray,
- int start, int count, jbyteArray destArray)
+ jint start, jint count, jbyteArray destArray)
{
ScopedCharArrayRO src(env, srcArray);
if (src.get() == NULL) {
@@ -144,20 +145,20 @@
}
}
-static jboolean mirror(JNIEnv* env, jobject obj, jcharArray charArray, int start, int count)
+static jboolean mirror(JNIEnv* env, jobject obj, jcharArray charArray, jint start, jint count)
{
ScopedCharArrayRW data(env, charArray);
if (data.get() == NULL) {
- return false;
+ return JNI_FALSE;
}
if (start < 0 || start > start + count
|| env->GetArrayLength(charArray) < start + count) {
jniThrowException(env, "java/lang/ArrayIndexOutOfBoundsException", NULL);
- return false;
+ return JNI_FALSE;
}
- bool ret = false;
+ jboolean ret = JNI_FALSE;
for (int i = start; i < start + count; i++) {
// XXX this thinks it knows that surrogates are never mirrored
@@ -166,7 +167,7 @@
if (c1 != c2) {
data[i] = c2;
- ret = true;
+ ret = JNI_TRUE;
}
}
return ret;
diff --git a/core/jni/android_text_format_Time.cpp b/core/jni/android_text_format_Time.cpp
index aa2c5f39..28a8a5d 100644
--- a/core/jni/android_text_format_Time.cpp
+++ b/core/jni/android_text_format_Time.cpp
@@ -117,7 +117,7 @@
time2java(env, This, t);
RELEASE_TIMEZONE(This, t)
- return result;
+ return static_cast<jlong>(result);
}
static void android_text_format_Time_switchTimezone(JNIEnv* env, jobject This,
@@ -155,7 +155,7 @@
RELEASE_TIMEZONE(aObject, a)
RELEASE_TIMEZONE(bObject, b)
- return result;
+ return static_cast<jint>(result);
}
static jstring android_text_format_Time_format2445(JNIEnv* env, jobject This)
@@ -346,7 +346,7 @@
RELEASE_TIMEZONE(This, t)
- return result;
+ return static_cast<jlong>(result);
}
static void android_text_format_Time_set(JNIEnv* env, jobject This, jlong millis)
@@ -400,10 +400,10 @@
if (len < 8) {
jniThrowException(env, "android/util/TimeFormatException",
"String too short -- expected at least 8 characters.");
- return false;
+ return JNI_FALSE;
}
- jboolean inUtc = false;
+ jboolean inUtc = JNI_FALSE;
ScopedStringChars s(env, strObj);
@@ -414,49 +414,49 @@
n += get_char(env, s, 1, 100, &thrown);
n += get_char(env, s, 2, 10, &thrown);
n += get_char(env, s, 3, 1, &thrown);
- if (thrown) return false;
+ if (thrown) return JNI_FALSE;
env->SetIntField(This, g_yearField, n);
// month
n = get_char(env, s, 4, 10, &thrown);
n += get_char(env, s, 5, 1, &thrown);
n--;
- if (thrown) return false;
+ if (thrown) return JNI_FALSE;
env->SetIntField(This, g_monField, n);
// day of month
n = get_char(env, s, 6, 10, &thrown);
n += get_char(env, s, 7, 1, &thrown);
- if (thrown) return false;
+ if (thrown) return JNI_FALSE;
env->SetIntField(This, g_mdayField, n);
if (len > 8) {
// T
- if (!check_char(env, s, 8, 'T')) return false;
+ if (!check_char(env, s, 8, 'T')) return JNI_FALSE;
env->SetBooleanField(This, g_allDayField, JNI_FALSE);
// hour
n = get_char(env, s, 9, 10, &thrown);
n += get_char(env, s, 10, 1, &thrown);
- if (thrown) return false;
+ if (thrown) return JNI_FALSE;
env->SetIntField(This, g_hourField, n);
// min
n = get_char(env, s, 11, 10, &thrown);
n += get_char(env, s, 12, 1, &thrown);
- if (thrown) return false;
+ if (thrown) return JNI_FALSE;
env->SetIntField(This, g_minField, n);
// sec
n = get_char(env, s, 13, 10, &thrown);
n += get_char(env, s, 14, 1, &thrown);
- if (thrown) return false;
+ if (thrown) return JNI_FALSE;
env->SetIntField(This, g_secField, n);
if (len > 15) {
// Z
- if (!check_char(env, s, 15, 'Z')) return false;
- inUtc = true;
+ if (!check_char(env, s, 15, 'Z')) return JNI_FALSE;
+ inUtc = JNI_TRUE;
}
} else {
env->SetBooleanField(This, g_allDayField, JNI_TRUE);
@@ -481,10 +481,10 @@
if (len < 10) {
jniThrowException(env, "android/util/TimeFormatException",
"String too short --- expected at least 10 characters.");
- return false;
+ return JNI_FALSE;
}
- jboolean inUtc = false;
+ jboolean inUtc = JNI_FALSE;
ScopedStringChars s(env, strObj);
@@ -495,57 +495,57 @@
n += get_char(env, s, 1, 100, &thrown);
n += get_char(env, s, 2, 10, &thrown);
n += get_char(env, s, 3, 1, &thrown);
- if (thrown) return false;
+ if (thrown) return JNI_FALSE;
env->SetIntField(This, g_yearField, n);
// -
- if (!check_char(env, s, 4, '-')) return false;
+ if (!check_char(env, s, 4, '-')) return JNI_FALSE;
// month
n = get_char(env, s, 5, 10, &thrown);
n += get_char(env, s, 6, 1, &thrown);
--n;
- if (thrown) return false;
+ if (thrown) return JNI_FALSE;
env->SetIntField(This, g_monField, n);
// -
- if (!check_char(env, s, 7, '-')) return false;
+ if (!check_char(env, s, 7, '-')) return JNI_FALSE;
// day
n = get_char(env, s, 8, 10, &thrown);
n += get_char(env, s, 9, 1, &thrown);
- if (thrown) return false;
+ if (thrown) return JNI_FALSE;
env->SetIntField(This, g_mdayField, n);
if (len >= 19) {
// T
- if (!check_char(env, s, 10, 'T')) return false;
+ if (!check_char(env, s, 10, 'T')) return JNI_FALSE;
env->SetBooleanField(This, g_allDayField, JNI_FALSE);
// hour
n = get_char(env, s, 11, 10, &thrown);
n += get_char(env, s, 12, 1, &thrown);
- if (thrown) return false;
+ if (thrown) return JNI_FALSE;
int hour = n;
// env->SetIntField(This, g_hourField, n);
// :
- if (!check_char(env, s, 13, ':')) return false;
+ if (!check_char(env, s, 13, ':')) return JNI_FALSE;
// minute
n = get_char(env, s, 14, 10, &thrown);
n += get_char(env, s, 15, 1, &thrown);
- if (thrown) return false;
+ if (thrown) return JNI_FALSE;
int minute = n;
// env->SetIntField(This, g_minField, n);
// :
- if (!check_char(env, s, 16, ':')) return false;
+ if (!check_char(env, s, 16, ':')) return JNI_FALSE;
// second
n = get_char(env, s, 17, 10, &thrown);
n += get_char(env, s, 18, 1, &thrown);
- if (thrown) return false;
+ if (thrown) return JNI_FALSE;
env->SetIntField(This, g_secField, n);
// skip the '.XYZ' -- we don't care about subsecond precision.
@@ -579,32 +579,32 @@
jniThrowExceptionFmt(env, "android/util/TimeFormatException",
"Unexpected character 0x%02x at position %d. Expected + or -",
c, tz_index);
- return false;
+ return JNI_FALSE;
}
- inUtc = true;
+ inUtc = JNI_TRUE;
if (offset != 0) {
if (len < tz_index + 6) {
jniThrowExceptionFmt(env, "android/util/TimeFormatException",
"Unexpected length; should be %d characters",
tz_index + 6);
- return false;
+ return JNI_FALSE;
}
// hour
n = get_char(env, s, tz_index + 1, 10, &thrown);
n += get_char(env, s, tz_index + 2, 1, &thrown);
- if (thrown) return false;
+ if (thrown) return JNI_FALSE;
n *= offset;
hour += n;
// :
- if (!check_char(env, s, tz_index + 3, ':')) return false;
+ if (!check_char(env, s, tz_index + 3, ':')) return JNI_FALSE;
// minute
n = get_char(env, s, tz_index + 4, 10, &thrown);
n += get_char(env, s, tz_index + 5, 1, &thrown);
- if (thrown) return false;
+ if (thrown) return JNI_FALSE;
n *= offset;
minute += n;
}
diff --git a/core/jni/android_util_AssetManager.cpp b/core/jni/android_util_AssetManager.cpp
index 2c23f9d..7162a1c 100644
--- a/core/jni/android_util_AssetManager.cpp
+++ b/core/jni/android_util_AssetManager.cpp
@@ -35,7 +35,16 @@
#include <androidfw/AssetManager.h>
#include <androidfw/ResourceTypes.h>
+#include <private/android_filesystem_config.h> // for AID_SYSTEM
+
#include <stdio.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+#include <linux/capability.h>
+extern "C" int capget(cap_user_header_t hdrp, cap_user_data_t datap);
+extern "C" int capset(cap_user_header_t hdrp, const cap_user_data_t datap);
+
namespace android {
@@ -88,7 +97,7 @@
{
env->SetIntField(outValue, gTypedValueOffsets.mType, value.dataType);
env->SetIntField(outValue, gTypedValueOffsets.mAssetCookie,
- (jint)table->getTableCookie(block));
+ static_cast<jint>(table->getTableCookie(block)));
env->SetIntField(outValue, gTypedValueOffsets.mData, value.data);
env->SetObjectField(outValue, gTypedValueOffsets.mString, NULL);
env->SetIntField(outValue, gTypedValueOffsets.mResourceId, ref);
@@ -100,12 +109,70 @@
return block;
}
+// This is called by zygote (running as user root) as part of preloadResources.
+static void verifySystemIdmaps()
+{
+ pid_t pid;
+ char system_id[10];
+
+ snprintf(system_id, sizeof(system_id), "%d", AID_SYSTEM);
+
+ switch (pid = fork()) {
+ case -1:
+ ALOGE("failed to fork for idmap: %s", strerror(errno));
+ break;
+ case 0: // child
+ {
+ struct __user_cap_header_struct capheader;
+ struct __user_cap_data_struct capdata;
+
+ memset(&capheader, 0, sizeof(capheader));
+ memset(&capdata, 0, sizeof(capdata));
+
+ capheader.version = _LINUX_CAPABILITY_VERSION;
+ capheader.pid = 0;
+
+ if (capget(&capheader, &capdata) != 0) {
+ ALOGE("capget: %s\n", strerror(errno));
+ exit(1);
+ }
+
+ capdata.effective = capdata.permitted;
+ if (capset(&capheader, &capdata) != 0) {
+ ALOGE("capset: %s\n", strerror(errno));
+ exit(1);
+ }
+
+ if (setgid(AID_SYSTEM) != 0) {
+ ALOGE("setgid: %s\n", strerror(errno));
+ exit(1);
+ }
+
+ if (setuid(AID_SYSTEM) != 0) {
+ ALOGE("setuid: %s\n", strerror(errno));
+ exit(1);
+ }
+
+ execl(AssetManager::IDMAP_BIN, AssetManager::IDMAP_BIN, "--scan",
+ AssetManager::OVERLAY_DIR, AssetManager::TARGET_PACKAGE_NAME,
+ AssetManager::TARGET_APK_PATH, AssetManager::IDMAP_DIR, (char*)NULL);
+ ALOGE("failed to execl for idmap: %s", strerror(errno));
+ exit(1); // should never get here
+ }
+ break;
+ default: // parent
+ waitpid(pid, NULL, 0);
+ break;
+ }
+}
+
// ----------------------------------------------------------------------------
// this guy is exported to other jni routines
AssetManager* assetManagerForJavaObject(JNIEnv* env, jobject obj)
{
- AssetManager* am = (AssetManager*)env->GetIntField(obj, gAssetManagerOffsets.mObject);
+ jlong amHandle = env->GetLongField(obj, gAssetManagerOffsets.mObject);
+ AssetManager* am = reinterpret_cast<AssetManager*>(amHandle);
if (am != NULL) {
return am;
}
@@ -113,7 +180,7 @@
return NULL;
}
-static jint android_content_AssetManager_openAsset(JNIEnv* env, jobject clazz,
+static jlong android_content_AssetManager_openAsset(JNIEnv* env, jobject clazz,
jstring fileName, jint mode)
{
AssetManager* am = assetManagerForJavaObject(env, clazz);
@@ -125,6 +192,7 @@
ScopedUtfChars fileName8(env, fileName);
if (fileName8.c_str() == NULL) {
+ jniThrowException(env, "java/lang/IllegalArgumentException", "Empty file name");
return -1;
}
@@ -143,7 +211,7 @@
//printf("Created Asset Stream: %p\n", a);
- return (jint)a;
+ return reinterpret_cast<jlong>(a);
}
static jobject returnParcelFileDescriptor(JNIEnv* env, Asset* a, jlongArray outOffsets)
@@ -205,7 +273,7 @@
return returnParcelFileDescriptor(env, a, outOffsets);
}
-static jint android_content_AssetManager_openNonAssetNative(JNIEnv* env, jobject clazz,
+static jlong android_content_AssetManager_openNonAssetNative(JNIEnv* env, jobject clazz,
jint cookie,
jstring fileName,
jint mode)
@@ -229,7 +297,8 @@
}
Asset* a = cookie
- ? am->openNonAsset((void*)cookie, fileName8.c_str(), (Asset::AccessMode)mode)
+ ? am->openNonAsset(static_cast<int32_t>(cookie), fileName8.c_str(),
+ (Asset::AccessMode)mode)
: am->openNonAsset(fileName8.c_str(), (Asset::AccessMode)mode);
if (a == NULL) {
@@ -239,7 +308,7 @@
//printf("Created Asset Stream: %p\n", a);
- return (jint)a;
+ return reinterpret_cast<jlong>(a);
}
static jobject android_content_AssetManager_openNonAssetFdNative(JNIEnv* env, jobject clazz,
@@ -260,7 +329,7 @@
}
Asset* a = cookie
- ? am->openNonAsset((void*)cookie, fileName8.c_str(), Asset::ACCESS_RANDOM)
+ ? am->openNonAsset(static_cast<int32_t>(cookie), fileName8.c_str(), Asset::ACCESS_RANDOM)
: am->openNonAsset(fileName8.c_str(), Asset::ACCESS_RANDOM);
if (a == NULL) {
@@ -319,9 +388,9 @@
}
static void android_content_AssetManager_destroyAsset(JNIEnv* env, jobject clazz,
- jint asset)
+ jlong assetHandle)
{
- Asset* a = (Asset*)asset;
+ Asset* a = reinterpret_cast<Asset*>(assetHandle);
//printf("Destroying Asset Stream: %p\n", a);
@@ -334,9 +403,9 @@
}
static jint android_content_AssetManager_readAssetChar(JNIEnv* env, jobject clazz,
- jint asset)
+ jlong assetHandle)
{
- Asset* a = (Asset*)asset;
+ Asset* a = reinterpret_cast<Asset*>(assetHandle);
if (a == NULL) {
jniThrowNullPointerException(env, "asset");
@@ -349,10 +418,10 @@
}
static jint android_content_AssetManager_readAsset(JNIEnv* env, jobject clazz,
- jint asset, jbyteArray bArray,
+ jlong assetHandle, jbyteArray bArray,
jint off, jint len)
{
- Asset* a = (Asset*)asset;
+ Asset* a = reinterpret_cast<Asset*>(assetHandle);
if (a == NULL || bArray == NULL) {
jniThrowNullPointerException(env, "asset");
@@ -373,7 +442,7 @@
ssize_t res = a->read(b+off, len);
env->ReleaseByteArrayElements(bArray, b, 0);
- if (res > 0) return res;
+ if (res > 0) return static_cast<jint>(res);
if (res < 0) {
jniThrowException(env, "java/io/IOException", "");
@@ -382,10 +451,10 @@
}
static jlong android_content_AssetManager_seekAsset(JNIEnv* env, jobject clazz,
- jint asset,
+ jlong assetHandle,
jlong offset, jint whence)
{
- Asset* a = (Asset*)asset;
+ Asset* a = reinterpret_cast<Asset*>(assetHandle);
if (a == NULL) {
jniThrowNullPointerException(env, "asset");
@@ -397,9 +466,9 @@
}
static jlong android_content_AssetManager_getAssetLength(JNIEnv* env, jobject clazz,
- jint asset)
+ jlong assetHandle)
{
- Asset* a = (Asset*)asset;
+ Asset* a = reinterpret_cast<Asset*>(assetHandle);
if (a == NULL) {
jniThrowNullPointerException(env, "asset");
@@ -410,9 +479,9 @@
}
static jlong android_content_AssetManager_getAssetRemainingLength(JNIEnv* env, jobject clazz,
- jint asset)
+ jlong assetHandle)
{
- Asset* a = (Asset*)asset;
+ Asset* a = reinterpret_cast<Asset*>(assetHandle);
if (a == NULL) {
jniThrowNullPointerException(env, "asset");
@@ -435,9 +504,28 @@
return 0;
}
- void* cookie;
+ int32_t cookie;
bool res = am->addAssetPath(String8(path8.c_str()), &cookie);
+ return (res) ? static_cast<jint>(cookie) : 0;
+}
+
+static jint android_content_AssetManager_addOverlayPath(JNIEnv* env, jobject clazz,
+ jstring idmapPath)
+{
+ ScopedUtfChars idmapPath8(env, idmapPath);
+ if (idmapPath8.c_str() == NULL) {
+ return 0;
+ }
+
+ AssetManager* am = assetManagerForJavaObject(env, clazz);
+ if (am == NULL) {
+ return 0;
+ }
+
+ int32_t cookie;
+ bool res = am->addOverlayPath(String8(idmapPath8.c_str()), &cookie);
+
return (res) ? (jint)cookie : 0;
}
@@ -724,7 +812,11 @@
}
#endif
}
- return block >= 0 ? copyValue(env, outValue, &res, value, ref, block, typeSpecFlags, &config) : block;
+ if (block >= 0) {
+ return copyValue(env, outValue, &res, value, ref, block, typeSpecFlags, &config);
+ }
+
+ return static_cast<jint>(block);
}
static jint android_content_AssetManager_loadResourceBagValue(JNIEnv* env, jobject clazz,
@@ -758,7 +850,7 @@
res.unlock();
if (block < 0) {
- return block;
+ return static_cast<jint>(block);
}
uint32_t ref = ident;
@@ -771,7 +863,11 @@
}
#endif
}
- return block >= 0 ? copyValue(env, outValue, &res, value, ref, block, typeSpecFlags) : block;
+ if (block >= 0) {
+ return copyValue(env, outValue, &res, value, ref, block, typeSpecFlags);
+ }
+
+ return static_cast<jint>(block);
}
static jint android_content_AssetManager_getStringBlockCount(JNIEnv* env, jobject clazz)
@@ -783,14 +879,14 @@
return am->getResources().getTableCount();
}
-static jint android_content_AssetManager_getNativeStringBlock(JNIEnv* env, jobject clazz,
+static jlong android_content_AssetManager_getNativeStringBlock(JNIEnv* env, jobject clazz,
jint block)
{
AssetManager* am = assetManagerForJavaObject(env, clazz);
if (am == NULL) {
return 0;
}
- return (jint)am->getResources().getTableStringBlock(block);
+ return reinterpret_cast<jlong>(am->getResources().getTableStringBlock(block));
}
static jstring android_content_AssetManager_getCookieName(JNIEnv* env, jobject clazz,
@@ -800,7 +896,7 @@
if (am == NULL) {
return NULL;
}
- String8 name(am->getAssetPath((void*)cookie));
+ String8 name(am->getAssetPath(static_cast<int32_t>(cookie)));
if (name.length() == 0) {
jniThrowException(env, "java/lang/IndexOutOfBoundsException", "Empty cookie name");
return NULL;
@@ -809,43 +905,43 @@
return str;
}
-static jint android_content_AssetManager_newTheme(JNIEnv* env, jobject clazz)
+static jlong android_content_AssetManager_newTheme(JNIEnv* env, jobject clazz)
{
AssetManager* am = assetManagerForJavaObject(env, clazz);
if (am == NULL) {
return 0;
}
- return (jint)(new ResTable::Theme(am->getResources()));
+ return reinterpret_cast<jlong>(new ResTable::Theme(am->getResources()));
}
static void android_content_AssetManager_deleteTheme(JNIEnv* env, jobject clazz,
- jint themeInt)
+ jlong themeHandle)
{
- ResTable::Theme* theme = (ResTable::Theme*)themeInt;
+ ResTable::Theme* theme = reinterpret_cast<ResTable::Theme*>(themeHandle);
delete theme;
}
static void android_content_AssetManager_applyThemeStyle(JNIEnv* env, jobject clazz,
- jint themeInt,
+ jlong themeHandle,
jint styleRes,
jboolean force)
{
- ResTable::Theme* theme = (ResTable::Theme*)themeInt;
+ ResTable::Theme* theme = reinterpret_cast<ResTable::Theme*>(themeHandle);
theme->applyStyle(styleRes, force ? true : false);
}
static void android_content_AssetManager_copyTheme(JNIEnv* env, jobject clazz,
- jint destInt, jint srcInt)
+ jlong destHandle, jlong srcHandle)
{
- ResTable::Theme* dest = (ResTable::Theme*)destInt;
- ResTable::Theme* src = (ResTable::Theme*)srcInt;
+ ResTable::Theme* dest = reinterpret_cast<ResTable::Theme*>(destHandle);
+ ResTable::Theme* src = reinterpret_cast<ResTable::Theme*>(srcHandle);
dest->setTo(*src);
}
static jint android_content_AssetManager_loadThemeAttributeValue(
- JNIEnv* env, jobject clazz, jint themeInt, jint ident, jobject outValue, jboolean resolve)
+ JNIEnv* env, jobject clazz, jlong themeHandle, jint ident, jobject outValue, jboolean resolve)
{
- ResTable::Theme* theme = (ResTable::Theme*)themeInt;
+ ResTable::Theme* theme = reinterpret_cast<ResTable::Theme*>(themeHandle);
const ResTable& res(theme->getResTable());
Res_value value;
@@ -866,10 +962,10 @@
}
static void android_content_AssetManager_dumpTheme(JNIEnv* env, jobject clazz,
- jint themeInt, jint pri,
+ jlong themeHandle, jint pri,
jstring tag, jstring prefix)
{
- ResTable::Theme* theme = (ResTable::Theme*)themeInt;
+ ResTable::Theme* theme = reinterpret_cast<ResTable::Theme*>(themeHandle);
const ResTable& res(theme->getResTable());
// XXX Need to use params.
@@ -877,10 +973,10 @@
}
static jboolean android_content_AssetManager_applyStyle(JNIEnv* env, jobject clazz,
- jint themeToken,
+ jlong themeToken,
jint defStyleAttr,
jint defStyleRes,
- jint xmlParserToken,
+ jlong xmlParserToken,
jintArray attrs,
jintArray outValues,
jintArray outIndices)
@@ -901,9 +997,9 @@
DEBUG_STYLES(LOGI("APPLY STYLE: theme=0x%x defStyleAttr=0x%x defStyleRes=0x%x xml=0x%x",
themeToken, defStyleAttr, defStyleRes, xmlParserToken));
- ResTable::Theme* theme = (ResTable::Theme*)themeToken;
+ ResTable::Theme* theme = reinterpret_cast<ResTable::Theme*>(themeToken);
const ResTable& res = theme->getResTable();
- ResXMLParser* xmlParser = (ResXMLParser*)xmlParserToken;
+ ResXMLParser* xmlParser = reinterpret_cast<ResXMLParser*>(xmlParserToken);
ResTable_config config;
Res_value value;
@@ -1096,7 +1192,7 @@
dest[STYLE_TYPE] = value.dataType;
dest[STYLE_DATA] = value.data;
dest[STYLE_ASSET_COOKIE] =
- block != kXmlBlock ? (jint)res.getTableCookie(block) : (jint)-1;
+ block != kXmlBlock ? reinterpret_cast<jint>(res.getTableCookie(block)) : (jint)-1;
dest[STYLE_RESOURCE_ID] = resid;
dest[STYLE_CHANGING_CONFIGURATIONS] = typeSetFlags;
dest[STYLE_DENSITY] = config.density;
@@ -1122,7 +1218,7 @@
}
static jboolean android_content_AssetManager_retrieveAttributes(JNIEnv* env, jobject clazz,
- jint xmlParserToken,
+ jlong xmlParserToken,
jintArray attrs,
jintArray outValues,
jintArray outIndices)
@@ -1239,7 +1335,7 @@
dest[STYLE_TYPE] = value.dataType;
dest[STYLE_DATA] = value.data;
dest[STYLE_ASSET_COOKIE] =
- block != kXmlBlock ? (jint)res.getTableCookie(block) : (jint)-1;
+ block != kXmlBlock ? reinterpret_cast<jint>(res.getTableCookie(block)) : (jint)-1;
dest[STYLE_RESOURCE_ID] = resid;
dest[STYLE_CHANGING_CONFIGURATIONS] = typeSetFlags;
dest[STYLE_DENSITY] = config.density;
@@ -1279,7 +1375,7 @@
ssize_t bagOff = res.getBagLocked(id, &defStyleEnt);
res.unlock();
- return bagOff;
+ return static_cast<jint>(bagOff);
}
static jint android_content_AssetManager_retrieveArray(JNIEnv* env, jobject clazz,
@@ -1351,7 +1447,7 @@
// Write the final value back to Java.
dest[STYLE_TYPE] = value.dataType;
dest[STYLE_DATA] = value.data;
- dest[STYLE_ASSET_COOKIE] = (jint)res.getTableCookie(block);
+ dest[STYLE_ASSET_COOKIE] = reinterpret_cast<jint>(res.getTableCookie(block));
dest[STYLE_RESOURCE_ID] = resid;
dest[STYLE_CHANGING_CONFIGURATIONS] = typeSetFlags;
dest[STYLE_DENSITY] = config.density;
@@ -1369,7 +1465,7 @@
return i;
}
-static jint android_content_AssetManager_openXmlAssetNative(JNIEnv* env, jobject clazz,
+static jlong android_content_AssetManager_openXmlAssetNative(JNIEnv* env, jobject clazz,
jint cookie,
jstring fileName)
{
@@ -1386,7 +1482,7 @@
}
Asset* a = cookie
- ? am->openNonAsset((void*)cookie, fileName8.c_str(), Asset::ACCESS_BUFFER)
+ ? am->openNonAsset(static_cast<int32_t>(cookie), fileName8.c_str(), Asset::ACCESS_BUFFER)
: am->openNonAsset(fileName8.c_str(), Asset::ACCESS_BUFFER);
if (a == NULL) {
@@ -1404,7 +1500,7 @@
return 0;
}
- return (jint)block;
+ return reinterpret_cast<jlong>(block);
}
static jintArray android_content_AssetManager_getArrayStringInfo(JNIEnv* env, jobject clazz,
@@ -1568,8 +1664,11 @@
return array;
}
-static void android_content_AssetManager_init(JNIEnv* env, jobject clazz)
+static void android_content_AssetManager_init(JNIEnv* env, jobject clazz, jboolean isSystem)
{
+ if (isSystem) {
+ verifySystemIdmaps();
+ }
AssetManager* am = new AssetManager();
if (am == NULL) {
jniThrowException(env, "java/lang/OutOfMemoryError", "");
@@ -1579,17 +1678,17 @@
am->addDefaultAssets();
ALOGV("Created AssetManager %p for Java object %p\n", am, clazz);
- env->SetIntField(clazz, gAssetManagerOffsets.mObject, (jint)am);
+ env->SetLongField(clazz, gAssetManagerOffsets.mObject, reinterpret_cast<jlong>(am));
}
static void android_content_AssetManager_destroy(JNIEnv* env, jobject clazz)
{
AssetManager* am = (AssetManager*)
- (env->GetIntField(clazz, gAssetManagerOffsets.mObject));
+ (env->GetLongField(clazz, gAssetManagerOffsets.mObject));
ALOGV("Destroying AssetManager %p for Java object %p\n", am, clazz);
if (am != NULL) {
delete am;
- env->SetIntField(clazz, gAssetManagerOffsets.mObject, 0);
+ env->SetLongField(clazz, gAssetManagerOffsets.mObject, 0);
}
}
@@ -1623,30 +1722,32 @@
/* name, signature, funcPtr */
// Basic asset stuff.
- { "openAsset", "(Ljava/lang/String;I)I",
+ { "openAsset", "(Ljava/lang/String;I)J",
(void*) android_content_AssetManager_openAsset },
{ "openAssetFd", "(Ljava/lang/String;[J)Landroid/os/ParcelFileDescriptor;",
(void*) android_content_AssetManager_openAssetFd },
- { "openNonAssetNative", "(ILjava/lang/String;I)I",
+ { "openNonAssetNative", "(ILjava/lang/String;I)J",
(void*) android_content_AssetManager_openNonAssetNative },
{ "openNonAssetFdNative", "(ILjava/lang/String;[J)Landroid/os/ParcelFileDescriptor;",
(void*) android_content_AssetManager_openNonAssetFdNative },
{ "list", "(Ljava/lang/String;)[Ljava/lang/String;",
(void*) android_content_AssetManager_list },
- { "destroyAsset", "(I)V",
+ { "destroyAsset", "(J)V",
(void*) android_content_AssetManager_destroyAsset },
- { "readAssetChar", "(I)I",
+ { "readAssetChar", "(J)I",
(void*) android_content_AssetManager_readAssetChar },
- { "readAsset", "(I[BII)I",
+ { "readAsset", "(J[BII)I",
(void*) android_content_AssetManager_readAsset },
- { "seekAsset", "(IJI)J",
+ { "seekAsset", "(JJI)J",
(void*) android_content_AssetManager_seekAsset },
- { "getAssetLength", "(I)J",
+ { "getAssetLength", "(J)J",
(void*) android_content_AssetManager_getAssetLength },
- { "getAssetRemainingLength", "(I)J",
+ { "getAssetRemainingLength", "(J)J",
(void*) android_content_AssetManager_getAssetRemainingLength },
{ "addAssetPathNative", "(Ljava/lang/String;)I",
(void*) android_content_AssetManager_addAssetPath },
+ { "addOverlayPath", "(Ljava/lang/String;)I",
+ (void*) android_content_AssetManager_addOverlayPath },
{ "isUpToDate", "()Z",
(void*) android_content_AssetManager_isUpToDate },
@@ -1673,27 +1774,27 @@
(void*) android_content_AssetManager_loadResourceBagValue },
{ "getStringBlockCount","()I",
(void*) android_content_AssetManager_getStringBlockCount },
- { "getNativeStringBlock","(I)I",
+ { "getNativeStringBlock","(I)J",
(void*) android_content_AssetManager_getNativeStringBlock },
{ "getCookieName","(I)Ljava/lang/String;",
(void*) android_content_AssetManager_getCookieName },
// Themes.
- { "newTheme", "()I",
+ { "newTheme", "()J",
(void*) android_content_AssetManager_newTheme },
- { "deleteTheme", "(I)V",
+ { "deleteTheme", "(J)V",
(void*) android_content_AssetManager_deleteTheme },
- { "applyThemeStyle", "(IIZ)V",
+ { "applyThemeStyle", "(JIZ)V",
(void*) android_content_AssetManager_applyThemeStyle },
- { "copyTheme", "(II)V",
+ { "copyTheme", "(JJ)V",
(void*) android_content_AssetManager_copyTheme },
- { "loadThemeAttributeValue", "(IILandroid/util/TypedValue;Z)I",
+ { "loadThemeAttributeValue", "(JILandroid/util/TypedValue;Z)I",
(void*) android_content_AssetManager_loadThemeAttributeValue },
- { "dumpTheme", "(IILjava/lang/String;Ljava/lang/String;)V",
+ { "dumpTheme", "(JILjava/lang/String;Ljava/lang/String;)V",
(void*) android_content_AssetManager_dumpTheme },
- { "applyStyle","(IIII[I[I[I)Z",
+ { "applyStyle","(JIIJ[I[I[I)Z",
(void*) android_content_AssetManager_applyStyle },
- { "retrieveAttributes","(I[I[I[I)Z",
+ { "retrieveAttributes","(J[I[I[I)Z",
(void*) android_content_AssetManager_retrieveAttributes },
{ "getArraySize","(I)I",
(void*) android_content_AssetManager_getArraySize },
@@ -1701,7 +1802,7 @@
(void*) android_content_AssetManager_retrieveArray },
// XML files.
- { "openXmlAssetNative", "(ILjava/lang/String;)I",
+ { "openXmlAssetNative", "(ILjava/lang/String;)J",
(void*) android_content_AssetManager_openXmlAssetNative },
// Arrays.
@@ -1713,7 +1814,7 @@
(void*) android_content_AssetManager_getArrayIntResource },
// Bookkeeping.
- { "init", "()V",
+ { "init", "(Z)V",
(void*) android_content_AssetManager_init },
{ "destroy", "()V",
(void*) android_content_AssetManager_destroy },
@@ -1765,7 +1866,7 @@
jclass assetManager = env->FindClass("android/content/res/AssetManager");
LOG_FATAL_IF(assetManager == NULL, "Unable to find class android/content/res/AssetManager");
gAssetManagerOffsets.mObject
- = env->GetFieldID(assetManager, "mObject", "I");
+ = env->GetFieldID(assetManager, "mObject", "J");
LOG_FATAL_IF(gAssetManagerOffsets.mObject == NULL, "Unable to find AssetManager.mObject");
jclass stringClass = env->FindClass("java/lang/String");
diff --git a/core/jni/android_util_Binder.cpp b/core/jni/android_util_Binder.cpp
index 259d030..475e926 100644
--- a/core/jni/android_util_Binder.cpp
+++ b/core/jni/android_util_Binder.cpp
@@ -267,7 +267,7 @@
//data.print();
//printf("\n");
jboolean res = env->CallBooleanMethod(mObject, gBinderOffsets.mExecTransact,
- code, (int32_t)&data, (int32_t)reply, flags);
+ code, reinterpret_cast<jlong>(&data), reinterpret_cast<jlong>(reply), flags);
jthrowable excep = env->ExceptionOccurred();
if (excep) {
@@ -577,7 +577,7 @@
if (object != NULL) {
LOGDEATH("objectForBinder %p: created new proxy %p !\n", val.get(), object);
// The proxy holds a reference to the native object.
- env->SetIntField(object, gBinderProxyOffsets.mObject, (int)val.get());
+ env->SetLongField(object, gBinderProxyOffsets.mObject, (jlong)val.get());
val->incStrong((void*)javaObjectForIBinder);
// The native object needs to hold a weak reference back to the
@@ -590,7 +590,7 @@
// Also remember the death recipients registered on this proxy
sp<DeathRecipientList> drl = new DeathRecipientList;
drl->incStrong((void*)javaObjectForIBinder);
- env->SetIntField(object, gBinderProxyOffsets.mOrgue, reinterpret_cast<jint>(drl.get()));
+ env->SetLongField(object, gBinderProxyOffsets.mOrgue, reinterpret_cast<jlong>(drl.get()));
// Note that a new object reference has been created.
android_atomic_inc(&gNumProxyRefs);
@@ -606,13 +606,13 @@
if (env->IsInstanceOf(obj, gBinderOffsets.mClass)) {
JavaBBinderHolder* jbh = (JavaBBinderHolder*)
- env->GetIntField(obj, gBinderOffsets.mObject);
+ env->GetLongField(obj, gBinderOffsets.mObject);
return jbh != NULL ? jbh->get(env, obj) : NULL;
}
if (env->IsInstanceOf(obj, gBinderProxyOffsets.mClass)) {
return (IBinder*)
- env->GetIntField(obj, gBinderProxyOffsets.mObject);
+ env->GetLongField(obj, gBinderProxyOffsets.mObject);
}
ALOGW("ibinderForJavaObject: %p is not a Binder object", obj);
@@ -764,15 +764,15 @@
}
ALOGV("Java Binder %p: acquiring first ref on holder %p", obj, jbh);
jbh->incStrong((void*)android_os_Binder_init);
- env->SetIntField(obj, gBinderOffsets.mObject, (int)jbh);
+ env->SetLongField(obj, gBinderOffsets.mObject, (jlong)jbh);
}
static void android_os_Binder_destroy(JNIEnv* env, jobject obj)
{
JavaBBinderHolder* jbh = (JavaBBinderHolder*)
- env->GetIntField(obj, gBinderOffsets.mObject);
+ env->GetLongField(obj, gBinderOffsets.mObject);
if (jbh != NULL) {
- env->SetIntField(obj, gBinderOffsets.mObject, 0);
+ env->SetLongField(obj, gBinderOffsets.mObject, 0);
ALOGV("Java Binder %p: removing ref on holder %p", obj, jbh);
jbh->decStrong((void*)android_os_Binder_init);
} else {
@@ -812,11 +812,11 @@
gBinderOffsets.mClass = (jclass) env->NewGlobalRef(clazz);
gBinderOffsets.mExecTransact
- = env->GetMethodID(clazz, "execTransact", "(IIII)Z");
+ = env->GetMethodID(clazz, "execTransact", "(IJJI)Z");
assert(gBinderOffsets.mExecTransact);
gBinderOffsets.mObject
- = env->GetFieldID(clazz, "mObject", "I");
+ = env->GetFieldID(clazz, "mObject", "J");
assert(gBinderOffsets.mObject);
return AndroidRuntime::registerNativeMethods(
@@ -911,7 +911,7 @@
static jboolean android_os_BinderProxy_pingBinder(JNIEnv* env, jobject obj)
{
IBinder* target = (IBinder*)
- env->GetIntField(obj, gBinderProxyOffsets.mObject);
+ env->GetLongField(obj, gBinderProxyOffsets.mObject);
if (target == NULL) {
return JNI_FALSE;
}
@@ -921,7 +921,7 @@
static jstring android_os_BinderProxy_getInterfaceDescriptor(JNIEnv* env, jobject obj)
{
- IBinder* target = (IBinder*) env->GetIntField(obj, gBinderProxyOffsets.mObject);
+ IBinder* target = (IBinder*) env->GetLongField(obj, gBinderProxyOffsets.mObject);
if (target != NULL) {
const String16& desc = target->getInterfaceDescriptor();
return env->NewString(desc.string(), desc.size());
@@ -934,7 +934,7 @@
static jboolean android_os_BinderProxy_isBinderAlive(JNIEnv* env, jobject obj)
{
IBinder* target = (IBinder*)
- env->GetIntField(obj, gBinderProxyOffsets.mObject);
+ env->GetLongField(obj, gBinderProxyOffsets.mObject);
if (target == NULL) {
return JNI_FALSE;
}
@@ -1062,7 +1062,7 @@
}
IBinder* target = (IBinder*)
- env->GetIntField(obj, gBinderProxyOffsets.mObject);
+ env->GetLongField(obj, gBinderProxyOffsets.mObject);
if (target == NULL) {
jniThrowException(env, "java/lang/IllegalStateException", "Binder has been finalized!");
return JNI_FALSE;
@@ -1109,7 +1109,7 @@
}
IBinder* target = (IBinder*)
- env->GetIntField(obj, gBinderProxyOffsets.mObject);
+ env->GetLongField(obj, gBinderProxyOffsets.mObject);
if (target == NULL) {
ALOGW("Binder has been finalized when calling linkToDeath() with recip=%p)\n", recipient);
assert(false);
@@ -1119,7 +1119,7 @@
if (!target->localBinder()) {
DeathRecipientList* list = (DeathRecipientList*)
- env->GetIntField(obj, gBinderProxyOffsets.mOrgue);
+ env->GetLongField(obj, gBinderProxyOffsets.mOrgue);
sp<JavaDeathRecipient> jdr = new JavaDeathRecipient(env, recipient, list);
status_t err = target->linkToDeath(jdr, NULL, flags);
if (err != NO_ERROR) {
@@ -1141,7 +1141,7 @@
}
IBinder* target = (IBinder*)
- env->GetIntField(obj, gBinderProxyOffsets.mObject);
+ env->GetLongField(obj, gBinderProxyOffsets.mObject);
if (target == NULL) {
ALOGW("Binder has been finalized when calling linkToDeath() with recip=%p)\n", recipient);
return JNI_FALSE;
@@ -1154,7 +1154,7 @@
// If we find the matching recipient, proceed to unlink using that
DeathRecipientList* list = (DeathRecipientList*)
- env->GetIntField(obj, gBinderProxyOffsets.mOrgue);
+ env->GetLongField(obj, gBinderProxyOffsets.mOrgue);
sp<JavaDeathRecipient> origJDR = list->find(recipient);
LOGDEATH(" unlink found list %p and JDR %p", list, origJDR.get());
if (origJDR != NULL) {
@@ -1183,13 +1183,13 @@
static void android_os_BinderProxy_destroy(JNIEnv* env, jobject obj)
{
IBinder* b = (IBinder*)
- env->GetIntField(obj, gBinderProxyOffsets.mObject);
+ env->GetLongField(obj, gBinderProxyOffsets.mObject);
DeathRecipientList* drl = (DeathRecipientList*)
- env->GetIntField(obj, gBinderProxyOffsets.mOrgue);
+ env->GetLongField(obj, gBinderProxyOffsets.mOrgue);
LOGDEATH("Destroying BinderProxy %p: binder=%p drl=%p\n", obj, b, drl);
- env->SetIntField(obj, gBinderProxyOffsets.mObject, 0);
- env->SetIntField(obj, gBinderProxyOffsets.mOrgue, 0);
+ env->SetLongField(obj, gBinderProxyOffsets.mObject, 0);
+ env->SetLongField(obj, gBinderProxyOffsets.mOrgue, 0);
drl->decStrong((void*)javaObjectForIBinder);
b->decStrong((void*)javaObjectForIBinder);
@@ -1231,13 +1231,13 @@
assert(gBinderProxyOffsets.mSendDeathNotice);
gBinderProxyOffsets.mObject
- = env->GetFieldID(clazz, "mObject", "I");
+ = env->GetFieldID(clazz, "mObject", "J");
assert(gBinderProxyOffsets.mObject);
gBinderProxyOffsets.mSelf
= env->GetFieldID(clazz, "mSelf", "Ljava/lang/ref/WeakReference;");
assert(gBinderProxyOffsets.mSelf);
gBinderProxyOffsets.mOrgue
- = env->GetFieldID(clazz, "mOrgue", "I");
+ = env->GetFieldID(clazz, "mOrgue", "J");
assert(gBinderProxyOffsets.mOrgue);
clazz = env->FindClass("java/lang/Class");
diff --git a/core/jni/android_util_EventLog.cpp b/core/jni/android_util_EventLog.cpp
index 83d8aa2..8a0eaa2 100644
--- a/core/jni/android_util_EventLog.cpp
+++ b/core/jni/android_util_EventLog.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007 The Android Open Source Project
+ * Copyright (C) 2007-2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,6 +21,8 @@
#include "jni.h"
#include "log/logger.h"
+#define UNUSED __attribute__((__unused__))
+
// The size of the tag number comes out of the payload size.
#define MAX_EVENT_PAYLOAD (LOGGER_ENTRY_MAX_PAYLOAD - sizeof(int32_t))
@@ -44,7 +46,8 @@
* In class android.util.EventLog:
* static native int writeEvent(int tag, int value)
*/
-static jint android_util_EventLog_writeEvent_Integer(JNIEnv* env, jobject clazz,
+static jint android_util_EventLog_writeEvent_Integer(JNIEnv* env UNUSED,
+ jobject clazz UNUSED,
jint tag, jint value)
{
return android_btWriteLog(tag, EVENT_TYPE_INT, &value, sizeof(value));
@@ -54,7 +57,8 @@
* In class android.util.EventLog:
* static native int writeEvent(long tag, long value)
*/
-static jint android_util_EventLog_writeEvent_Long(JNIEnv* env, jobject clazz,
+static jint android_util_EventLog_writeEvent_Long(JNIEnv* env UNUSED,
+ jobject clazz UNUSED,
jint tag, jlong value)
{
return android_btWriteLog(tag, EVENT_TYPE_LONG, &value, sizeof(value));
@@ -64,7 +68,8 @@
* In class android.util.EventLog:
* static native int writeEvent(int tag, String value)
*/
-static jint android_util_EventLog_writeEvent_String(JNIEnv* env, jobject clazz,
+static jint android_util_EventLog_writeEvent_String(JNIEnv* env,
+ jobject clazz UNUSED,
jint tag, jstring value) {
uint8_t buf[MAX_EVENT_PAYLOAD];
@@ -142,18 +147,21 @@
* In class android.util.EventLog:
* static native void readEvents(int[] tags, Collection<Event> output)
*
- * Reads events from the event log, typically /dev/log/events
+ * Reads events from the event log
*/
-static void android_util_EventLog_readEvents(JNIEnv* env, jobject clazz,
+static void android_util_EventLog_readEvents(JNIEnv* env, jobject clazz UNUSED,
jintArray tags,
jobject out) {
+
if (tags == NULL || out == NULL) {
jniThrowNullPointerException(env, NULL);
return;
}
- int fd = open("/dev/" LOGGER_LOG_EVENTS, O_RDONLY | O_NONBLOCK);
- if (fd < 0) {
+ struct logger_list *logger_list = android_logger_list_open(
+ LOG_ID_EVENTS, O_RDONLY | O_NONBLOCK, 0, 0);
+
+ if (!logger_list) {
jniThrowIOException(env, errno);
return;
}
@@ -161,41 +169,26 @@
jsize tagLength = env->GetArrayLength(tags);
jint *tagValues = env->GetIntArrayElements(tags, NULL);
- uint8_t buf[LOGGER_ENTRY_MAX_LEN];
- struct timeval timeout = {0, 0};
- fd_set readset;
- FD_ZERO(&readset);
+ while (1) {
+ log_msg log_msg;
+ int ret = android_logger_list_read(logger_list, &log_msg);
- for (;;) {
- // Use a short select() to try to avoid problems hanging on read().
- // This means we block for 5ms at the end of the log -- oh well.
- timeout.tv_usec = 5000;
- FD_SET(fd, &readset);
- int r = select(fd + 1, &readset, NULL, NULL, &timeout);
- if (r == 0) {
- break; // no more events
- } else if (r < 0 && errno == EINTR) {
- continue; // interrupted by signal, try again
- } else if (r < 0) {
- jniThrowIOException(env, errno); // Will throw on return
+ if (ret == 0) {
+ break;
+ }
+ if (ret < 0) {
+ if (ret == -EINTR) {
+ continue;
+ }
+ if (ret == -EINVAL) {
+ jniThrowException(env, "java/io/IOException", "Event too short");
+ } else if (ret != -EAGAIN) {
+ jniThrowIOException(env, -ret); // Will throw on return
+ }
break;
}
- int len = read(fd, buf, sizeof(buf));
- if (len == 0 || (len < 0 && errno == EAGAIN)) {
- break; // no more events
- } else if (len < 0 && errno == EINTR) {
- continue; // interrupted by signal, try again
- } else if (len < 0) {
- jniThrowIOException(env, errno); // Will throw on return
- break;
- } else if ((size_t) len < sizeof(logger_entry) + sizeof(int32_t)) {
- jniThrowException(env, "java/io/IOException", "Event too short");
- break;
- }
-
- logger_entry* entry = (logger_entry*) buf;
- int32_t tag = * (int32_t*) (buf + sizeof(*entry));
+ int32_t tag = * (int32_t *) log_msg.msg();
int found = 0;
for (int i = 0; !found && i < tagLength; ++i) {
@@ -203,16 +196,20 @@
}
if (found) {
- jsize len = sizeof(*entry) + entry->len;
+ jsize len = ret;
jbyteArray array = env->NewByteArray(len);
- if (array == NULL) break;
+ if (array == NULL) {
+ break;
+ }
jbyte *bytes = env->GetByteArrayElements(array, NULL);
- memcpy(bytes, buf, len);
+ memcpy(bytes, log_msg.buf, len);
env->ReleaseByteArrayElements(array, bytes, 0);
jobject event = env->NewObject(gEventClass, gEventInitID, array);
- if (event == NULL) break;
+ if (event == NULL) {
+ break;
+ }
env->CallBooleanMethod(out, gCollectionAddID, event);
env->DeleteLocalRef(event);
@@ -220,7 +217,8 @@
}
}
- close(fd);
+ android_logger_list_close(logger_list);
+
env->ReleaseIntArrayElements(tags, tagValues, 0);
}
diff --git a/core/jni/android_util_Log.cpp b/core/jni/android_util_Log.cpp
index 536a582..93dcbef 100644
--- a/core/jni/android_util_Log.cpp
+++ b/core/jni/android_util_Log.cpp
@@ -85,7 +85,7 @@
jboolean result = false;
if ((strlen(chars)+sizeof(LOG_NAMESPACE)) > PROPERTY_KEY_MAX) {
char buf2[200];
- snprintf(buf2, sizeof(buf2), "Log tag \"%s\" exceeds limit of %d characters\n",
+ snprintf(buf2, sizeof(buf2), "Log tag \"%s\" exceeds limit of %zu characters\n",
chars, PROPERTY_KEY_MAX - sizeof(LOG_NAMESPACE));
jniThrowException(env, "java/lang/IllegalArgumentException", buf2);
diff --git a/core/jni/android_util_Process.cpp b/core/jni/android_util_Process.cpp
index 601975a..9f8eb34 100644
--- a/core/jni/android_util_Process.cpp
+++ b/core/jni/android_util_Process.cpp
@@ -19,8 +19,8 @@
#include <utils/Log.h>
#include <binder/IPCThreadState.h>
-#include <binder/ProcessState.h>
#include <binder/IServiceManager.h>
+#include <cutils/process_name.h>
#include <cutils/sched_policy.h>
#include <utils/String8.h>
#include <utils/Vector.h>
@@ -402,7 +402,9 @@
}
if (name8.size() > 0) {
- ProcessState::self()->setArgV0(name8.string());
+ const char* procName = name8.string();
+ set_process_name(procName);
+ AndroidRuntime::getRuntime()->setArgv0(procName);
}
}
diff --git a/core/jni/android_util_StringBlock.cpp b/core/jni/android_util_StringBlock.cpp
index 463d3c0..f29250f 100644
--- a/core/jni/android_util_StringBlock.cpp
+++ b/core/jni/android_util_StringBlock.cpp
@@ -31,7 +31,7 @@
// ----------------------------------------------------------------------------
-static jint android_content_StringBlock_nativeCreate(JNIEnv* env, jobject clazz,
+static jlong android_content_StringBlock_nativeCreate(JNIEnv* env, jobject clazz,
jbyteArray bArray,
jint off, jint len)
{
@@ -56,13 +56,13 @@
return 0;
}
- return (jint)osb;
+ return reinterpret_cast<jlong>(osb);
}
static jint android_content_StringBlock_nativeGetSize(JNIEnv* env, jobject clazz,
- jint token)
+ jlong token)
{
- ResStringPool* osb = (ResStringPool*)token;
+ ResStringPool* osb = reinterpret_cast<ResStringPool*>(token);
if (osb == NULL) {
jniThrowNullPointerException(env, NULL);
return 0;
@@ -72,9 +72,9 @@
}
static jstring android_content_StringBlock_nativeGetString(JNIEnv* env, jobject clazz,
- jint token, jint idx)
+ jlong token, jint idx)
{
- ResStringPool* osb = (ResStringPool*)token;
+ ResStringPool* osb = reinterpret_cast<ResStringPool*>(token);
if (osb == NULL) {
jniThrowNullPointerException(env, NULL);
return 0;
@@ -96,9 +96,9 @@
}
static jintArray android_content_StringBlock_nativeGetStyle(JNIEnv* env, jobject clazz,
- jint token, jint idx)
+ jlong token, jint idx)
{
- ResStringPool* osb = (ResStringPool*)token;
+ ResStringPool* osb = reinterpret_cast<ResStringPool*>(token);
if (osb == NULL) {
jniThrowNullPointerException(env, NULL);
return NULL;
@@ -139,9 +139,9 @@
}
static void android_content_StringBlock_nativeDestroy(JNIEnv* env, jobject clazz,
- jint token)
+ jlong token)
{
- ResStringPool* osb = (ResStringPool*)token;
+ ResStringPool* osb = reinterpret_cast<ResStringPool*>(token);
if (osb == NULL) {
jniThrowNullPointerException(env, NULL);
return;
@@ -157,15 +157,15 @@
*/
static JNINativeMethod gStringBlockMethods[] = {
/* name, signature, funcPtr */
- { "nativeCreate", "([BII)I",
+ { "nativeCreate", "([BII)J",
(void*) android_content_StringBlock_nativeCreate },
- { "nativeGetSize", "(I)I",
+ { "nativeGetSize", "(J)I",
(void*) android_content_StringBlock_nativeGetSize },
- { "nativeGetString", "(II)Ljava/lang/String;",
+ { "nativeGetString", "(JI)Ljava/lang/String;",
(void*) android_content_StringBlock_nativeGetString },
- { "nativeGetStyle", "(II)[I",
+ { "nativeGetStyle", "(JI)[I",
(void*) android_content_StringBlock_nativeGetStyle },
- { "nativeDestroy", "(I)V",
+ { "nativeDestroy", "(J)V",
(void*) android_content_StringBlock_nativeDestroy },
};
diff --git a/core/jni/android_util_XmlBlock.cpp b/core/jni/android_util_XmlBlock.cpp
index ad6033b..03de5c0 100644
--- a/core/jni/android_util_XmlBlock.cpp
+++ b/core/jni/android_util_XmlBlock.cpp
@@ -31,7 +31,7 @@
// ----------------------------------------------------------------------------
-static jint android_content_XmlBlock_nativeCreate(JNIEnv* env, jobject clazz,
+static jlong android_content_XmlBlock_nativeCreate(JNIEnv* env, jobject clazz,
jbyteArray bArray,
jint off, jint len)
{
@@ -55,25 +55,25 @@
return 0;
}
- return (jint)osb;
+ return reinterpret_cast<jlong>(osb);
}
-static jint android_content_XmlBlock_nativeGetStringBlock(JNIEnv* env, jobject clazz,
- jint token)
+static jlong android_content_XmlBlock_nativeGetStringBlock(JNIEnv* env, jobject clazz,
+ jlong token)
{
- ResXMLTree* osb = (ResXMLTree*)token;
+ ResXMLTree* osb = reinterpret_cast<ResXMLTree*>(token);
if (osb == NULL) {
jniThrowNullPointerException(env, NULL);
return 0;
}
- return (jint)&osb->getStrings();
+ return reinterpret_cast<jlong>(&osb->getStrings());
}
-static jint android_content_XmlBlock_nativeCreateParseState(JNIEnv* env, jobject clazz,
- jint token)
+static jlong android_content_XmlBlock_nativeCreateParseState(JNIEnv* env, jobject clazz,
+ jlong token)
{
- ResXMLTree* osb = (ResXMLTree*)token;
+ ResXMLTree* osb = reinterpret_cast<ResXMLTree*>(token);
if (osb == NULL) {
jniThrowNullPointerException(env, NULL);
return 0;
@@ -87,19 +87,19 @@
st->restart();
- return (jint)st;
+ return reinterpret_cast<jlong>(st);
}
static jint android_content_XmlBlock_nativeNext(JNIEnv* env, jobject clazz,
- jint token)
+ jlong token)
{
- ResXMLParser* st = (ResXMLParser*)token;
+ ResXMLParser* st = reinterpret_cast<ResXMLParser*>(token);
if (st == NULL) {
return ResXMLParser::END_DOCUMENT;
}
do {
- jint code = (jint)st->next();
+ ResXMLParser::event_code_t code = st->next();
switch (code) {
case ResXMLParser::START_TAG:
return 2;
@@ -123,139 +123,139 @@
}
static jint android_content_XmlBlock_nativeGetNamespace(JNIEnv* env, jobject clazz,
- jint token)
+ jlong token)
{
- ResXMLParser* st = (ResXMLParser*)token;
+ ResXMLParser* st = reinterpret_cast<ResXMLParser*>(token);
if (st == NULL) {
return -1;
}
- return (jint)st->getElementNamespaceID();
+ return static_cast<jint>(st->getElementNamespaceID());
}
static jint android_content_XmlBlock_nativeGetName(JNIEnv* env, jobject clazz,
- jint token)
+ jlong token)
{
- ResXMLParser* st = (ResXMLParser*)token;
+ ResXMLParser* st = reinterpret_cast<ResXMLParser*>(token);
if (st == NULL) {
return -1;
}
- return (jint)st->getElementNameID();
+ return static_cast<jint>(st->getElementNameID());
}
static jint android_content_XmlBlock_nativeGetText(JNIEnv* env, jobject clazz,
- jint token)
+ jlong token)
{
- ResXMLParser* st = (ResXMLParser*)token;
+ ResXMLParser* st = reinterpret_cast<ResXMLParser*>(token);
if (st == NULL) {
return -1;
}
- return (jint)st->getTextID();
+ return static_cast<jint>(st->getTextID());
}
static jint android_content_XmlBlock_nativeGetLineNumber(JNIEnv* env, jobject clazz,
- jint token)
+ jlong token)
{
- ResXMLParser* st = (ResXMLParser*)token;
+ ResXMLParser* st = reinterpret_cast<ResXMLParser*>(token);
if (st == NULL) {
jniThrowNullPointerException(env, NULL);
return 0;
}
- return (jint)st->getLineNumber();
+ return static_cast<jint>(st->getLineNumber());
}
static jint android_content_XmlBlock_nativeGetAttributeCount(JNIEnv* env, jobject clazz,
- jint token)
+ jlong token)
{
- ResXMLParser* st = (ResXMLParser*)token;
+ ResXMLParser* st = reinterpret_cast<ResXMLParser*>(token);
if (st == NULL) {
jniThrowNullPointerException(env, NULL);
return 0;
}
- return (jint)st->getAttributeCount();
+ return static_cast<jint>(st->getAttributeCount());
}
static jint android_content_XmlBlock_nativeGetAttributeNamespace(JNIEnv* env, jobject clazz,
- jint token, jint idx)
+ jlong token, jint idx)
{
- ResXMLParser* st = (ResXMLParser*)token;
+ ResXMLParser* st = reinterpret_cast<ResXMLParser*>(token);
if (st == NULL) {
jniThrowNullPointerException(env, NULL);
return 0;
}
- return (jint)st->getAttributeNamespaceID(idx);
+ return static_cast<jint>(st->getAttributeNamespaceID(idx));
}
static jint android_content_XmlBlock_nativeGetAttributeName(JNIEnv* env, jobject clazz,
- jint token, jint idx)
+ jlong token, jint idx)
{
- ResXMLParser* st = (ResXMLParser*)token;
+ ResXMLParser* st = reinterpret_cast<ResXMLParser*>(token);
if (st == NULL) {
jniThrowNullPointerException(env, NULL);
return 0;
}
- return (jint)st->getAttributeNameID(idx);
+ return static_cast<jint>(st->getAttributeNameID(idx));
}
static jint android_content_XmlBlock_nativeGetAttributeResource(JNIEnv* env, jobject clazz,
- jint token, jint idx)
+ jlong token, jint idx)
{
- ResXMLParser* st = (ResXMLParser*)token;
+ ResXMLParser* st = reinterpret_cast<ResXMLParser*>(token);
if (st == NULL) {
jniThrowNullPointerException(env, NULL);
return 0;
}
- return (jint)st->getAttributeNameResID(idx);
+ return static_cast<jint>(st->getAttributeNameResID(idx));
}
static jint android_content_XmlBlock_nativeGetAttributeDataType(JNIEnv* env, jobject clazz,
- jint token, jint idx)
+ jlong token, jint idx)
{
- ResXMLParser* st = (ResXMLParser*)token;
+ ResXMLParser* st = reinterpret_cast<ResXMLParser*>(token);
if (st == NULL) {
jniThrowNullPointerException(env, NULL);
return 0;
}
- return (jint)st->getAttributeDataType(idx);
+ return static_cast<jint>(st->getAttributeDataType(idx));
}
static jint android_content_XmlBlock_nativeGetAttributeData(JNIEnv* env, jobject clazz,
- jint token, jint idx)
+ jlong token, jint idx)
{
- ResXMLParser* st = (ResXMLParser*)token;
+ ResXMLParser* st = reinterpret_cast<ResXMLParser*>(token);
if (st == NULL) {
jniThrowNullPointerException(env, NULL);
return 0;
}
- return (jint)st->getAttributeData(idx);
+ return static_cast<jint>(st->getAttributeData(idx));
}
static jint android_content_XmlBlock_nativeGetAttributeStringValue(JNIEnv* env, jobject clazz,
- jint token, jint idx)
+ jlong token, jint idx)
{
- ResXMLParser* st = (ResXMLParser*)token;
+ ResXMLParser* st = reinterpret_cast<ResXMLParser*>(token);
if (st == NULL) {
jniThrowNullPointerException(env, NULL);
return 0;
}
- return (jint)st->getAttributeValueStringID(idx);
+ return static_cast<jint>(st->getAttributeValueStringID(idx));
}
static jint android_content_XmlBlock_nativeGetAttributeIndex(JNIEnv* env, jobject clazz,
- jint token,
+ jlong token,
jstring ns, jstring name)
{
- ResXMLParser* st = (ResXMLParser*)token;
+ ResXMLParser* st = reinterpret_cast<ResXMLParser*>(token);
if (st == NULL || name == NULL) {
jniThrowNullPointerException(env, NULL);
return 0;
@@ -271,7 +271,7 @@
const char16_t* name16 = env->GetStringChars(name, NULL);
jsize nameLen = env->GetStringLength(name);
- jint idx = (jint)st->indexOfAttribute(ns16, nsLen, name16, nameLen);
+ jint idx = static_cast<jint>(st->indexOfAttribute(ns16, nsLen, name16, nameLen));
if (ns) {
env->ReleaseStringChars(ns, ns16);
@@ -282,35 +282,35 @@
}
static jint android_content_XmlBlock_nativeGetIdAttribute(JNIEnv* env, jobject clazz,
- jint token)
+ jlong token)
{
- ResXMLParser* st = (ResXMLParser*)token;
+ ResXMLParser* st = reinterpret_cast<ResXMLParser*>(token);
if (st == NULL) {
jniThrowNullPointerException(env, NULL);
return 0;
}
ssize_t idx = st->indexOfID();
- return idx >= 0 ? (jint)st->getAttributeValueStringID(idx) : -1;
+ return idx >= 0 ? static_cast<jint>(st->getAttributeValueStringID(idx)) : -1;
}
static jint android_content_XmlBlock_nativeGetClassAttribute(JNIEnv* env, jobject clazz,
- jint token)
+ jlong token)
{
- ResXMLParser* st = (ResXMLParser*)token;
+ ResXMLParser* st = reinterpret_cast<ResXMLParser*>(token);
if (st == NULL) {
jniThrowNullPointerException(env, NULL);
return 0;
}
ssize_t idx = st->indexOfClass();
- return idx >= 0 ? (jint)st->getAttributeValueStringID(idx) : -1;
+ return idx >= 0 ? static_cast<jint>(st->getAttributeValueStringID(idx)) : -1;
}
static jint android_content_XmlBlock_nativeGetStyleAttribute(JNIEnv* env, jobject clazz,
- jint token)
+ jlong token)
{
- ResXMLParser* st = (ResXMLParser*)token;
+ ResXMLParser* st = reinterpret_cast<ResXMLParser*>(token);
if (st == NULL) {
jniThrowNullPointerException(env, NULL);
return 0;
@@ -332,9 +332,9 @@
}
static void android_content_XmlBlock_nativeDestroyParseState(JNIEnv* env, jobject clazz,
- jint token)
+ jlong token)
{
- ResXMLParser* st = (ResXMLParser*)token;
+ ResXMLParser* st = reinterpret_cast<ResXMLParser*>(token);
if (st == NULL) {
jniThrowNullPointerException(env, NULL);
return;
@@ -344,9 +344,9 @@
}
static void android_content_XmlBlock_nativeDestroy(JNIEnv* env, jobject clazz,
- jint token)
+ jlong token)
{
- ResXMLTree* osb = (ResXMLTree*)token;
+ ResXMLTree* osb = reinterpret_cast<ResXMLTree*>(token);
if (osb == NULL) {
jniThrowNullPointerException(env, NULL);
return;
@@ -362,47 +362,47 @@
*/
static JNINativeMethod gXmlBlockMethods[] = {
/* name, signature, funcPtr */
- { "nativeCreate", "([BII)I",
+ { "nativeCreate", "([BII)J",
(void*) android_content_XmlBlock_nativeCreate },
- { "nativeGetStringBlock", "(I)I",
+ { "nativeGetStringBlock", "(J)J",
(void*) android_content_XmlBlock_nativeGetStringBlock },
- { "nativeCreateParseState", "(I)I",
+ { "nativeCreateParseState", "(J)J",
(void*) android_content_XmlBlock_nativeCreateParseState },
- { "nativeNext", "(I)I",
+ { "nativeNext", "(J)I",
(void*) android_content_XmlBlock_nativeNext },
- { "nativeGetNamespace", "(I)I",
+ { "nativeGetNamespace", "(J)I",
(void*) android_content_XmlBlock_nativeGetNamespace },
- { "nativeGetName", "(I)I",
+ { "nativeGetName", "(J)I",
(void*) android_content_XmlBlock_nativeGetName },
- { "nativeGetText", "(I)I",
+ { "nativeGetText", "(J)I",
(void*) android_content_XmlBlock_nativeGetText },
- { "nativeGetLineNumber", "(I)I",
+ { "nativeGetLineNumber", "(J)I",
(void*) android_content_XmlBlock_nativeGetLineNumber },
- { "nativeGetAttributeCount", "(I)I",
+ { "nativeGetAttributeCount", "(J)I",
(void*) android_content_XmlBlock_nativeGetAttributeCount },
- { "nativeGetAttributeNamespace","(II)I",
+ { "nativeGetAttributeNamespace","(JI)I",
(void*) android_content_XmlBlock_nativeGetAttributeNamespace },
- { "nativeGetAttributeName", "(II)I",
+ { "nativeGetAttributeName", "(JI)I",
(void*) android_content_XmlBlock_nativeGetAttributeName },
- { "nativeGetAttributeResource", "(II)I",
+ { "nativeGetAttributeResource", "(JI)I",
(void*) android_content_XmlBlock_nativeGetAttributeResource },
- { "nativeGetAttributeDataType", "(II)I",
+ { "nativeGetAttributeDataType", "(JI)I",
(void*) android_content_XmlBlock_nativeGetAttributeDataType },
- { "nativeGetAttributeData", "(II)I",
+ { "nativeGetAttributeData", "(JI)I",
(void*) android_content_XmlBlock_nativeGetAttributeData },
- { "nativeGetAttributeStringValue", "(II)I",
+ { "nativeGetAttributeStringValue", "(JI)I",
(void*) android_content_XmlBlock_nativeGetAttributeStringValue },
- { "nativeGetAttributeIndex", "(ILjava/lang/String;Ljava/lang/String;)I",
+ { "nativeGetAttributeIndex", "(JLjava/lang/String;Ljava/lang/String;)I",
(void*) android_content_XmlBlock_nativeGetAttributeIndex },
- { "nativeGetIdAttribute", "(I)I",
+ { "nativeGetIdAttribute", "(J)I",
(void*) android_content_XmlBlock_nativeGetIdAttribute },
- { "nativeGetClassAttribute", "(I)I",
+ { "nativeGetClassAttribute", "(J)I",
(void*) android_content_XmlBlock_nativeGetClassAttribute },
- { "nativeGetStyleAttribute", "(I)I",
+ { "nativeGetStyleAttribute", "(J)I",
(void*) android_content_XmlBlock_nativeGetStyleAttribute },
- { "nativeDestroyParseState", "(I)V",
+ { "nativeDestroyParseState", "(J)V",
(void*) android_content_XmlBlock_nativeDestroyParseState },
- { "nativeDestroy", "(I)V",
+ { "nativeDestroy", "(J)V",
(void*) android_content_XmlBlock_nativeDestroy },
};
diff --git a/core/jni/android_view_GLES20Canvas.cpp b/core/jni/android_view_GLES20Canvas.cpp
index b720e73..591ff77 100644
--- a/core/jni/android_view_GLES20Canvas.cpp
+++ b/core/jni/android_view_GLES20Canvas.cpp
@@ -94,17 +94,17 @@
// ----------------------------------------------------------------------------
static void android_view_GLES20Canvas_flushCaches(JNIEnv* env, jobject clazz,
- Caches::FlushMode mode) {
+ jint mode) {
if (Caches::hasInstance()) {
- Caches::getInstance().flush(mode);
+ Caches::getInstance().flush(static_cast<Caches::FlushMode>(mode));
}
}
-static bool android_view_GLES20Canvas_initCaches(JNIEnv* env, jobject clazz) {
+static jboolean android_view_GLES20Canvas_initCaches(JNIEnv* env, jobject clazz) {
if (Caches::hasInstance()) {
- return Caches::getInstance().init();
+ return Caches::getInstance().init() ? JNI_TRUE : JNI_FALSE;
}
- return false;
+ return JNI_FALSE;
}
static void android_view_GLES20Canvas_terminateCaches(JNIEnv* env, jobject clazz) {
@@ -118,29 +118,28 @@
// ----------------------------------------------------------------------------
static void android_view_GLES20Canvas_initAtlas(JNIEnv* env, jobject clazz,
- jobject graphicBuffer, jintArray atlasMapArray, jint count) {
+ jobject graphicBuffer, jlongArray atlasMapArray, jint count) {
sp<GraphicBuffer> buffer = graphicBufferForJavaObject(env, graphicBuffer);
- jint* atlasMap = env->GetIntArrayElements(atlasMapArray, NULL);
-
- Caches::getInstance().assetAtlas.init(buffer, atlasMap, count);
-
- env->ReleaseIntArrayElements(atlasMapArray, atlasMap, 0);
+ jlong* jAtlasMap = env->GetLongArrayElements(atlasMapArray, NULL);
+ Caches::getInstance().assetAtlas.init(buffer, jAtlasMap, count);
+ env->ReleaseLongArrayElements(atlasMapArray, jAtlasMap, 0);
}
// ----------------------------------------------------------------------------
// Constructors
// ----------------------------------------------------------------------------
-static OpenGLRenderer* android_view_GLES20Canvas_createRenderer(JNIEnv* env, jobject clazz) {
+static jlong android_view_GLES20Canvas_createRenderer(JNIEnv* env, jobject clazz) {
RENDERER_LOGD("Create OpenGLRenderer");
OpenGLRenderer* renderer = new OpenGLRenderer();
renderer->initProperties();
- return renderer;
+ return reinterpret_cast<jlong>(renderer);
}
static void android_view_GLES20Canvas_destroyRenderer(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer) {
+ jlong rendererHandle) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
RENDERER_LOGD("Destroy OpenGLRenderer");
delete renderer;
}
@@ -150,23 +149,27 @@
// ----------------------------------------------------------------------------
static void android_view_GLES20Canvas_setViewport(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer, jint width, jint height) {
+ jlong rendererHandle, jint width, jint height) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
renderer->setViewport(width, height);
}
-static int android_view_GLES20Canvas_prepare(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer, jboolean opaque) {
+static jint android_view_GLES20Canvas_prepare(JNIEnv* env, jobject clazz,
+ jlong rendererHandle, jboolean opaque) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
return renderer->prepare(opaque);
}
-static int android_view_GLES20Canvas_prepareDirty(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer, jint left, jint top, jint right, jint bottom,
+static jint android_view_GLES20Canvas_prepareDirty(JNIEnv* env, jobject clazz,
+ jlong rendererHandle, jint left, jint top, jint right, jint bottom,
jboolean opaque) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
return renderer->prepareDirty(left, top, right, bottom, opaque);
}
static void android_view_GLES20Canvas_finish(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer) {
+ jlong rendererHandle) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
renderer->finish();
}
@@ -175,7 +178,8 @@
}
static void android_view_GLES20Canvas_setName(JNIEnv* env,
- jobject clazz, OpenGLRenderer* renderer, jstring name) {
+ jobject clazz, jlong rendererHandle, jstring name) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
if (name != NULL) {
const char* textArray = env->GetStringUTFChars(name, NULL);
renderer->setName(textArray);
@@ -186,12 +190,14 @@
}
static void android_view_GLES20Canvas_setCountOverdrawEnabled(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer, jboolean enabled) {
+ jlong rendererHandle, jboolean enabled) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
renderer->setCountOverdrawEnabled(enabled);
}
static jfloat android_view_GLES20Canvas_getOverdraw(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer) {
+ jlong rendererHandle) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
return renderer->getOverdraw();
}
@@ -200,23 +206,30 @@
// ----------------------------------------------------------------------------
static jint android_view_GLES20Canvas_callDrawGLFunction(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer, Functor* functor) {
+ jlong rendererHandle, jlong functorHandle) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
+ Functor* functor = reinterpret_cast<Functor*>(functorHandle);
android::uirenderer::Rect dirty;
return renderer->callDrawGLFunction(functor, dirty);
}
static void android_view_GLES20Canvas_detachFunctor(JNIEnv* env,
- jobject clazz, OpenGLRenderer* renderer, Functor* functor) {
+ jobject clazz, jlong rendererPtr, jlong functorPtr) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererPtr);
+ Functor* functor = reinterpret_cast<Functor*>(functorPtr);
renderer->detachFunctor(functor);
}
static void android_view_GLES20Canvas_attachFunctor(JNIEnv* env,
- jobject clazz, OpenGLRenderer* renderer, Functor* functor) {
+ jobject clazz, jlong rendererHandle, jlong functorHandle) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
+ Functor* functor = reinterpret_cast<Functor*>(functorHandle);
renderer->attachFunctor(functor);
}
static jint android_view_GLES20Canvas_invokeFunctors(JNIEnv* env,
- jobject clazz, OpenGLRenderer* renderer, jobject dirty) {
+ jobject clazz, jlong rendererHandle, jobject dirty) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
android::uirenderer::Rect bounds;
status_t status = renderer->invokeFunctors(bounds);
if (status != DrawGlInfo::kStatusDone && dirty != NULL) {
@@ -242,23 +255,27 @@
// State
// ----------------------------------------------------------------------------
-static jint android_view_GLES20Canvas_save(JNIEnv* env, jobject clazz, OpenGLRenderer* renderer,
+static jint android_view_GLES20Canvas_save(JNIEnv* env, jobject clazz, jlong rendererHandle,
jint flags) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
return renderer->save(flags);
}
static jint android_view_GLES20Canvas_getSaveCount(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer) {
+ jlong rendererHandle) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
return renderer->getSaveCount();
}
static void android_view_GLES20Canvas_restore(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer) {
+ jlong rendererHandle) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
renderer->restore();
}
static void android_view_GLES20Canvas_restoreToCount(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer, jint saveCount) {
+ jlong rendererHandle, jint saveCount) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
renderer->restoreToCount(saveCount);
}
@@ -267,26 +284,32 @@
// ----------------------------------------------------------------------------
static jint android_view_GLES20Canvas_saveLayer(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer, jfloat left, jfloat top, jfloat right, jfloat bottom,
- SkPaint* paint, jint saveFlags) {
+ jlong rendererHandle, jfloat left, jfloat top, jfloat right, jfloat bottom,
+ jlong paintHandle, jint saveFlags) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
return renderer->saveLayer(left, top, right, bottom, paint, saveFlags);
}
static jint android_view_GLES20Canvas_saveLayerClip(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer, SkPaint* paint, jint saveFlags) {
+ jlong rendererHandle, jlong paintHandle, jint saveFlags) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
const android::uirenderer::Rect& bounds(renderer->getClipBounds());
return renderer->saveLayer(bounds.left, bounds.top, bounds.right, bounds.bottom,
paint, saveFlags);
}
static jint android_view_GLES20Canvas_saveLayerAlpha(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer, jfloat left, jfloat top, jfloat right, jfloat bottom,
+ jlong rendererHandle, jfloat left, jfloat top, jfloat right, jfloat bottom,
jint alpha, jint saveFlags) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
return renderer->saveLayerAlpha(left, top, right, bottom, alpha, saveFlags);
}
static jint android_view_GLES20Canvas_saveLayerAlphaClip(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer, jint alpha, jint saveFlags) {
+ jlong rendererHandle, jint alpha, jint saveFlags) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
const android::uirenderer::Rect& bounds(renderer->getClipBounds());
return renderer->saveLayerAlpha(bounds.left, bounds.top, bounds.right, bounds.bottom,
alpha, saveFlags);
@@ -296,41 +319,57 @@
// Clipping
// ----------------------------------------------------------------------------
-static bool android_view_GLES20Canvas_quickReject(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer, jfloat left, jfloat top, jfloat right, jfloat bottom) {
- return renderer->quickRejectNoScissor(left, top, right, bottom);
+static jboolean android_view_GLES20Canvas_quickReject(JNIEnv* env, jobject clazz,
+ jlong rendererHandle, jfloat left, jfloat top, jfloat right, jfloat bottom) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
+ bool result = renderer->quickRejectNoScissor(left, top, right, bottom);
+ return result ? JNI_TRUE : JNI_FALSE;
}
-static bool android_view_GLES20Canvas_clipRectF(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer, jfloat left, jfloat top, jfloat right, jfloat bottom,
- SkRegion::Op op) {
- return renderer->clipRect(left, top, right, bottom, op);
+static jboolean android_view_GLES20Canvas_clipRectF(JNIEnv* env, jobject clazz,
+ jlong rendererHandle, jfloat left, jfloat top, jfloat right, jfloat bottom,
+ jint opHandle) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
+ SkRegion::Op op = static_cast<SkRegion::Op>(opHandle);
+ bool result;
+ result = renderer->clipRect(left, top, right, bottom, op);
+ return result ? JNI_TRUE : JNI_FALSE;
}
-static bool android_view_GLES20Canvas_clipRect(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer, jint left, jint top, jint right, jint bottom,
- SkRegion::Op op) {
- return renderer->clipRect(float(left), float(top), float(right), float(bottom), op);
+static jboolean android_view_GLES20Canvas_clipRect(JNIEnv* env, jobject clazz,
+ jlong rendererHandle, jint left, jint top, jint right, jint bottom,
+ jint opHandle) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
+ SkRegion::Op op = static_cast<SkRegion::Op>(opHandle);
+ bool result = renderer->clipRect(float(left), float(top), float(right), float(bottom), op);
+ return result ? JNI_TRUE : JNI_FALSE;
}
-static bool android_view_GLES20Canvas_clipPath(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer, SkPath* path, SkRegion::Op op) {
- return renderer->clipPath(path, op);
+static jboolean android_view_GLES20Canvas_clipPath(JNIEnv* env, jobject clazz,
+ jlong rendererHandle, jlong pathHandle, jint opHandle) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
+ SkPath* path = reinterpret_cast<SkPath*>(pathHandle);
+ SkRegion::Op op = static_cast<SkRegion::Op>(opHandle);
+ return renderer->clipPath(path, op) ? JNI_TRUE : JNI_FALSE;
}
-static bool android_view_GLES20Canvas_clipRegion(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer, SkRegion* region, SkRegion::Op op) {
- return renderer->clipRegion(region, op);
+static jboolean android_view_GLES20Canvas_clipRegion(JNIEnv* env, jobject clazz,
+ jlong rendererHandle, jlong regionHandle, jint opHandle) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
+ SkRegion* region = reinterpret_cast<SkRegion*>(regionHandle);
+ SkRegion::Op op = static_cast<SkRegion::Op>(opHandle);
+ return renderer->clipRegion(region, op) ? JNI_TRUE : JNI_FALSE;
}
-static bool android_view_GLES20Canvas_getClipBounds(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer, jobject rect) {
+static jboolean android_view_GLES20Canvas_getClipBounds(JNIEnv* env, jobject clazz,
+ jlong rendererHandle, jobject rect) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
const android::uirenderer::Rect& bounds(renderer->getClipBounds());
env->CallVoidMethod(rect, gRectClassInfo.set,
int(bounds.left), int(bounds.top), int(bounds.right), int(bounds.bottom));
- return !bounds.isEmpty();
+ return !bounds.isEmpty() ? JNI_TRUE : JNI_FALSE;
}
// ----------------------------------------------------------------------------
@@ -338,37 +377,47 @@
// ----------------------------------------------------------------------------
static void android_view_GLES20Canvas_translate(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer, jfloat dx, jfloat dy) {
+ jlong rendererHandle, jfloat dx, jfloat dy) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
renderer->translate(dx, dy);
}
static void android_view_GLES20Canvas_rotate(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer, jfloat degrees) {
+ jlong rendererHandle, jfloat degrees) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
renderer->rotate(degrees);
}
static void android_view_GLES20Canvas_scale(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer, jfloat sx, jfloat sy) {
+ jlong rendererHandle, jfloat sx, jfloat sy) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
renderer->scale(sx, sy);
}
static void android_view_GLES20Canvas_skew(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer, jfloat sx, jfloat sy) {
+ jlong rendererHandle, jfloat sx, jfloat sy) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
renderer->skew(sx, sy);
}
static void android_view_GLES20Canvas_setMatrix(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer, SkMatrix* matrix) {
+ jlong rendererHandle, jlong matrixHandle) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
+ SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle);
renderer->setMatrix(matrix);
}
static void android_view_GLES20Canvas_getMatrix(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer, SkMatrix* matrix) {
+ jlong rendererHandle, jlong matrixHandle) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
+ SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle);
renderer->getMatrix(matrix);
}
static void android_view_GLES20Canvas_concatMatrix(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer, SkMatrix* matrix) {
+ jlong rendererHandle, jlong matrixHandle) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
+ SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle);
renderer->concatMatrix(matrix);
}
@@ -377,8 +426,11 @@
// ----------------------------------------------------------------------------
static void android_view_GLES20Canvas_drawBitmap(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer, SkBitmap* bitmap, jbyteArray buffer,
- jfloat left, jfloat top, SkPaint* paint) {
+ jlong rendererHandle, jlong bitmapHandle, jbyteArray buffer,
+ jfloat left, jfloat top, jlong paintHandle) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
+ SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
// This object allows the renderer to allocate a global JNI ref to the buffer object.
JavaHeapBitmapRef bitmapRef(env, bitmap, buffer);
@@ -386,9 +438,12 @@
}
static void android_view_GLES20Canvas_drawBitmapRect(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer, SkBitmap* bitmap, jbyteArray buffer,
- float srcLeft, float srcTop, float srcRight, float srcBottom,
- float dstLeft, float dstTop, float dstRight, float dstBottom, SkPaint* paint) {
+ jlong rendererHandle, jlong bitmapHandle, jbyteArray buffer,
+ jfloat srcLeft, jfloat srcTop, jfloat srcRight, jfloat srcBottom,
+ jfloat dstLeft, jfloat dstTop, jfloat dstRight, jfloat dstBottom, jlong paintHandle) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
+ SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
// This object allows the renderer to allocate a global JNI ref to the buffer object.
JavaHeapBitmapRef bitmapRef(env, bitmap, buffer);
@@ -397,8 +452,12 @@
}
static void android_view_GLES20Canvas_drawBitmapMatrix(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer, SkBitmap* bitmap, jbyteArray buffer,
- SkMatrix* matrix, SkPaint* paint) {
+ jlong rendererHandle, jlong bitmapHandle, jbyteArray buffer,
+ jlong matrixHandle, jlong paintHandle) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
+ SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
+ SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle);
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
// This object allows the renderer to allocate a global JNI ref to the buffer object.
JavaHeapBitmapRef bitmapRef(env, bitmap, buffer);
@@ -406,8 +465,10 @@
}
static void android_view_GLES20Canvas_drawBitmapData(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer, jintArray colors, jint offset, jint stride,
- jfloat left, jfloat top, jint width, jint height, jboolean hasAlpha, SkPaint* paint) {
+ jlong rendererHandle, jintArray colors, jint offset, jint stride,
+ jfloat left, jfloat top, jint width, jint height, jboolean hasAlpha, jlong paintHandle) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
SkBitmap* bitmap = new SkBitmap;
bitmap->setConfig(hasAlpha ? SkBitmap::kARGB_8888_Config : SkBitmap::kRGB_565_Config,
width, height);
@@ -431,9 +492,12 @@
}
static void android_view_GLES20Canvas_drawBitmapMesh(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer, SkBitmap* bitmap, jbyteArray buffer,
+ jlong rendererHandle, jlong bitmapHandle, jbyteArray buffer,
jint meshWidth, jint meshHeight, jfloatArray vertices, jint offset, jintArray colors,
- jint colorOffset, SkPaint* paint) {
+ jint colorOffset, jlong paintHandle) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
+ SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
// This object allows the renderer to allocate a global JNI ref to the buffer object.
JavaHeapBitmapRef bitmapRef(env, bitmap, buffer);
@@ -447,8 +511,13 @@
}
static void android_view_GLES20Canvas_drawPatch(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer, SkBitmap* bitmap, jbyteArray buffer, Res_png_9patch* patch,
- float left, float top, float right, float bottom, SkPaint* paint) {
+ jlong rendererHandle, jlong bitmapHandle, jbyteArray buffer, jlong patchHandle,
+ jfloat left, jfloat top, jfloat right, jfloat bottom, jlong paintHandle) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
+ SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
+ Res_png_9patch* patch = reinterpret_cast<Res_png_9patch*>(patchHandle);
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
+
// This object allows the renderer to allocate a global JNI ref to the buffer object.
JavaHeapBitmapRef bitmapRef(env, bitmap, buffer);
@@ -456,41 +525,56 @@
}
static void android_view_GLES20Canvas_drawColor(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer, jint color, SkXfermode::Mode mode) {
+ jlong rendererHandle, jint color, SkXfermode::Mode mode) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
renderer->drawColor(color, mode);
}
static void android_view_GLES20Canvas_drawRect(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer, jfloat left, jfloat top, jfloat right, jfloat bottom,
- SkPaint* paint) {
+ jlong rendererHandle, jfloat left, jfloat top, jfloat right, jfloat bottom,
+ jlong paintHandle) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
renderer->drawRect(left, top, right, bottom, paint);
}
static void android_view_GLES20Canvas_drawRoundRect(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer, jfloat left, jfloat top, jfloat right, jfloat bottom,
- jfloat rx, jfloat ry, SkPaint* paint) {
+ jlong rendererHandle, jfloat left, jfloat top, jfloat right, jfloat bottom,
+ jfloat rx, jfloat ry, jlong paintHandle) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
renderer->drawRoundRect(left, top, right, bottom, rx, ry, paint);
}
static void android_view_GLES20Canvas_drawCircle(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer, jfloat x, jfloat y, jfloat radius, SkPaint* paint) {
+ jlong rendererHandle, jfloat x, jfloat y, jfloat radius, jlong paintHandle) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
renderer->drawCircle(x, y, radius, paint);
}
static void android_view_GLES20Canvas_drawOval(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer, jfloat left, jfloat top, jfloat right, jfloat bottom,
- SkPaint* paint) {
+ jlong rendererHandle, jfloat left, jfloat top, jfloat right, jfloat bottom,
+ jlong paintHandle) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
renderer->drawOval(left, top, right, bottom, paint);
}
static void android_view_GLES20Canvas_drawArc(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer, jfloat left, jfloat top, jfloat right, jfloat bottom,
- jfloat startAngle, jfloat sweepAngle, jboolean useCenter, SkPaint* paint) {
+ jlong rendererHandle, jfloat left, jfloat top, jfloat right, jfloat bottom,
+ jfloat startAngle, jfloat sweepAngle, jboolean useCenter, jlong paintHandle) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
renderer->drawArc(left, top, right, bottom, startAngle, sweepAngle, useCenter, paint);
}
static void android_view_GLES20Canvas_drawRegionAsRects(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer, SkRegion* region, SkPaint* paint) {
+ jlong rendererHandle, jlong regionHandle, jlong paintHandle) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
+ SkRegion* region = reinterpret_cast<SkRegion*>(regionHandle);
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
+
if (paint->getStyle() != SkPaint::kFill_Style ||
(paint->isAntiAlias() && !renderer->isCurrentTransformSimple())) {
SkRegion::Iterator it(*region);
@@ -517,26 +601,35 @@
}
static void android_view_GLES20Canvas_drawRects(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer, jfloatArray rects, jint count, SkPaint* paint) {
+ jlong rendererHandle, jfloatArray rects, jint count, jlong paintHandle) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
jfloat* storage = env->GetFloatArrayElements(rects, NULL);
renderer->drawRects(storage, count, paint);
env->ReleaseFloatArrayElements(rects, storage, 0);
}
static void android_view_GLES20Canvas_drawPoints(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer, jfloatArray points, jint offset, jint count, SkPaint* paint) {
+ jlong rendererHandle, jfloatArray points, jint offset, jint count, jlong paintHandle) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
jfloat* storage = env->GetFloatArrayElements(points, NULL);
renderer->drawPoints(storage + offset, count, paint);
env->ReleaseFloatArrayElements(points, storage, 0);
}
static void android_view_GLES20Canvas_drawPath(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer, SkPath* path, SkPaint* paint) {
+ jlong rendererHandle, jlong pathHandle, jlong paintHandle) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
+ SkPath* path = reinterpret_cast<SkPath*>(pathHandle);
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
renderer->drawPath(path, paint);
}
static void android_view_GLES20Canvas_drawLines(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer, jfloatArray points, jint offset, jint count, SkPaint* paint) {
+ jlong rendererHandle, jfloatArray points, jint offset, jint count, jlong paintHandle) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
jfloat* storage = env->GetFloatArrayElements(points, NULL);
renderer->drawLines(storage + offset, count, paint);
env->ReleaseFloatArrayElements(points, storage, 0);
@@ -547,24 +640,30 @@
// ----------------------------------------------------------------------------
static void android_view_GLES20Canvas_resetModifiers(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer, jint modifiers) {
+ jlong rendererHandle, jint modifiers) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
if (modifiers & MODIFIER_SHADOW) renderer->resetShadow();
if (modifiers & MODIFIER_SHADER) renderer->resetShader();
if (modifiers & MODIFIER_COLOR_FILTER) renderer->resetColorFilter();
}
static void android_view_GLES20Canvas_setupShader(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer, SkiaShader* shader) {
+ jlong rendererHandle, jlong shaderHandle) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
+ SkiaShader* shader = reinterpret_cast<SkiaShader*>(shaderHandle);
renderer->setupShader(shader);
}
static void android_view_GLES20Canvas_setupColorFilter(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer, SkiaColorFilter* filter) {
+ jlong rendererHandle, jlong filterHandle) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
+ SkiaColorFilter* filter = reinterpret_cast<SkiaColorFilter*>(filterHandle);
renderer->setupColorFilter(filter);
}
static void android_view_GLES20Canvas_setupShadow(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer, jfloat radius, jfloat dx, jfloat dy, jint color) {
+ jlong rendererHandle, jfloat radius, jfloat dx, jfloat dy, jint color) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
renderer->setupShadow(radius, dx, dy, color);
}
@@ -573,12 +672,14 @@
// ----------------------------------------------------------------------------
static void android_view_GLES20Canvas_setupPaintFilter(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer, jint clearBits, jint setBits) {
+ jlong rendererHandle, jint clearBits, jint setBits) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
renderer->setupPaintFilter(clearBits, setBits);
}
static void android_view_GLES20Canvas_resetPaintFilter(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer) {
+ jlong rendererHandle) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
renderer->resetPaintFilter();
}
@@ -658,24 +759,31 @@
}
static void android_view_GLES20Canvas_drawTextArray(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer, jcharArray text, jint index, jint count,
- jfloat x, jfloat y, jint flags, SkPaint* paint) {
+ jlong rendererHandle, jcharArray text, jint index, jint count,
+ jfloat x, jfloat y, jint flags, jlong paintHandle) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
jchar* textArray = env->GetCharArrayElements(text, NULL);
renderText(renderer, textArray + index, count, x, y, flags, paint);
env->ReleaseCharArrayElements(text, textArray, JNI_ABORT);
}
static void android_view_GLES20Canvas_drawText(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer, jstring text, jint start, jint end,
- jfloat x, jfloat y, jint flags, SkPaint* paint) {
+ jlong rendererHandle, jstring text, jint start, jint end,
+ jfloat x, jfloat y, jint flags, jlong paintHandle) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
const jchar* textArray = env->GetStringChars(text, NULL);
renderText(renderer, textArray + start, end - start, x, y, flags, paint);
env->ReleaseStringChars(text, textArray);
}
static void android_view_GLES20Canvas_drawTextArrayOnPath(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer, jcharArray text, jint index, jint count,
- SkPath* path, jfloat hOffset, jfloat vOffset, jint flags, SkPaint* paint) {
+ jlong rendererHandle, jcharArray text, jint index, jint count,
+ jlong pathHandle, jfloat hOffset, jfloat vOffset, jint flags, jlong paintHandle) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
+ SkPath* path = reinterpret_cast<SkPath*>(pathHandle);
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
jchar* textArray = env->GetCharArrayElements(text, NULL);
renderTextOnPath(renderer, textArray + index, count, path,
hOffset, vOffset, flags, paint);
@@ -683,8 +791,11 @@
}
static void android_view_GLES20Canvas_drawTextOnPath(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer, jstring text, jint start, jint end,
- SkPath* path, jfloat hOffset, jfloat vOffset, jint flags, SkPaint* paint) {
+ jlong rendererHandle, jstring text, jint start, jint end,
+ jlong pathHandle, jfloat hOffset, jfloat vOffset, jint flags, jlong paintHandle) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
+ SkPath* path = reinterpret_cast<SkPath*>(pathHandle);
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
const jchar* textArray = env->GetStringChars(text, NULL);
renderTextOnPath(renderer, textArray + start, end - start, path,
hOffset, vOffset, flags, paint);
@@ -692,9 +803,11 @@
}
static void android_view_GLES20Canvas_drawTextRunArray(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer, jcharArray text, jint index, jint count,
+ jlong rendererHandle, jcharArray text, jint index, jint count,
jint contextIndex, jint contextCount, jfloat x, jfloat y, jint dirFlags,
- SkPaint* paint) {
+ jlong paintHandle) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
jchar* textArray = env->GetCharArrayElements(text, NULL);
renderTextRun(renderer, textArray + contextIndex, index - contextIndex,
count, contextCount, x, y, dirFlags, paint);
@@ -702,9 +815,11 @@
}
static void android_view_GLES20Canvas_drawTextRun(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer, jstring text, jint start, jint end,
- jint contextStart, int contextEnd, jfloat x, jfloat y, jint dirFlags,
- SkPaint* paint) {
+ jlong rendererHandle, jstring text, jint start, jint end,
+ jint contextStart, jint contextEnd, jfloat x, jfloat y, jint dirFlags,
+ jlong paintHandle) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
const jchar* textArray = env->GetStringChars(text, NULL);
jint count = end - start;
jint contextCount = contextEnd - contextStart;
@@ -729,8 +844,10 @@
}
static void android_view_GLES20Canvas_drawPosTextArray(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer, jcharArray text, jint index, jint count,
- jfloatArray pos, SkPaint* paint) {
+ jlong rendererHandle, jcharArray text, jint index, jint count,
+ jfloatArray pos, jlong paintHandle) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
jchar* textArray = env->GetCharArrayElements(text, NULL);
jfloat* positions = env->GetFloatArrayElements(pos, NULL);
@@ -741,8 +858,10 @@
}
static void android_view_GLES20Canvas_drawPosText(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer, jstring text, jint start, jint end,
- jfloatArray pos, SkPaint* paint) {
+ jlong rendererHandle, jstring text, jint start, jint end,
+ jfloatArray pos, jlong paintHandle) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
const jchar* textArray = env->GetStringChars(text, NULL);
jfloat* positions = env->GetFloatArrayElements(pos, NULL);
@@ -756,24 +875,31 @@
// Display lists
// ----------------------------------------------------------------------------
-static DisplayList* android_view_GLES20Canvas_getDisplayList(JNIEnv* env,
- jobject clazz, DisplayListRenderer* renderer, DisplayList* displayList) {
- return renderer->getDisplayList(displayList);
+static jlong android_view_GLES20Canvas_getDisplayList(JNIEnv* env,
+ jobject clazz, jlong rendererHandle, jlong displayListHandle) {
+ DisplayListRenderer* renderer = reinterpret_cast<DisplayListRenderer*>(rendererHandle);
+ DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle);
+ DisplayList* list = renderer->getDisplayList(displayList);
+ return reinterpret_cast<jlong>(list);
}
-static OpenGLRenderer* android_view_GLES20Canvas_createDisplayListRenderer(JNIEnv* env,
+static jlong android_view_GLES20Canvas_createDisplayListRenderer(JNIEnv* env,
jobject clazz) {
- return new DisplayListRenderer;
+ OpenGLRenderer* renderer = new DisplayListRenderer;
+ return reinterpret_cast<jlong>(renderer);
}
static void android_view_GLES20Canvas_resetDisplayListRenderer(JNIEnv* env,
- jobject clazz, DisplayListRenderer* renderer) {
+ jobject clazz, jlong rendererHandle) {
+ DisplayListRenderer* renderer = reinterpret_cast<DisplayListRenderer*>(rendererHandle);
renderer->reset();
}
static jint android_view_GLES20Canvas_drawDisplayList(JNIEnv* env,
- jobject clazz, OpenGLRenderer* renderer, DisplayList* displayList,
+ jobject clazz, jlong rendererHandle, jlong displayListHandle,
jobject dirty, jint flags) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
+ DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle);
android::uirenderer::Rect bounds;
status_t status = renderer->drawDisplayList(displayList, bounds, flags);
if (status != DrawGlInfo::kStatusDone && dirty != NULL) {
@@ -784,7 +910,9 @@
}
static void android_view_GLES20Canvas_outputDisplayList(JNIEnv* env,
- jobject clazz, OpenGLRenderer* renderer, DisplayList* displayList) {
+ jobject clazz, jlong rendererHandle, jlong displayListHandle) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
+ DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle);
renderer->outputDisplayList(displayList);
}
@@ -793,26 +921,29 @@
// ----------------------------------------------------------------------------
static void android_view_GLES20Canvas_interrupt(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer) {
+ jlong rendererHandle) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
renderer->interrupt();
}
static void android_view_GLES20Canvas_resume(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer) {
+ jlong rendererHandle) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
renderer->resume();
}
-static OpenGLRenderer* android_view_GLES20Canvas_createLayerRenderer(JNIEnv* env,
- jobject clazz, Layer* layer) {
+static jlong android_view_GLES20Canvas_createLayerRenderer(JNIEnv* env,
+ jobject clazz, jlong layerHandle) {
+ Layer* layer = reinterpret_cast<Layer*>(layerHandle);
if (layer) {
OpenGLRenderer* renderer = new LayerRenderer(layer);
renderer->initProperties();
- return renderer;
+ return reinterpret_cast<jlong>(renderer);
}
return NULL;
}
-static Layer* android_view_GLES20Canvas_createTextureLayer(JNIEnv* env, jobject clazz,
+static jlong android_view_GLES20Canvas_createTextureLayer(JNIEnv* env, jobject clazz,
jboolean isOpaque, jintArray layerInfo) {
Layer* layer = LayerRenderer::createTextureLayer(isOpaque);
@@ -822,10 +953,10 @@
env->ReleaseIntArrayElements(layerInfo, storage, 0);
}
- return layer;
+ return reinterpret_cast<jlong>(layer);
}
-static Layer* android_view_GLES20Canvas_createLayer(JNIEnv* env, jobject clazz,
+static jlong android_view_GLES20Canvas_createLayer(JNIEnv* env, jobject clazz,
jint width, jint height, jboolean isOpaque, jintArray layerInfo) {
Layer* layer = LayerRenderer::createLayer(width, height, isOpaque);
@@ -836,44 +967,51 @@
env->ReleaseIntArrayElements(layerInfo, storage, 0);
}
- return layer;
+ return reinterpret_cast<jlong>(layer);
}
-static bool android_view_GLES20Canvas_resizeLayer(JNIEnv* env, jobject clazz,
- Layer* layer, jint width, jint height, jintArray layerInfo) {
+static jboolean android_view_GLES20Canvas_resizeLayer(JNIEnv* env, jobject clazz,
+ jlong layerHandle, jint width, jint height, jintArray layerInfo) {
+ Layer* layer = reinterpret_cast<Layer*>(layerHandle);
if (LayerRenderer::resizeLayer(layer, width, height)) {
jint* storage = env->GetIntArrayElements(layerInfo, NULL);
storage[0] = layer->getWidth();
storage[1] = layer->getHeight();
env->ReleaseIntArrayElements(layerInfo, storage, 0);
- return true;
+ return JNI_TRUE;
}
- return false;
+ return JNI_FALSE;
}
static void android_view_GLES20Canvas_setLayerPaint(JNIEnv* env, jobject clazz,
- Layer* layer, SkPaint* paint) {
+ jlong layerHandle, jlong paintHandle) {
+ Layer* layer = reinterpret_cast<Layer*>(layerHandle);
+ SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
if (layer) {
layer->setPaint(paint);
}
}
static void android_view_GLES20Canvas_setLayerColorFilter(JNIEnv* env, jobject clazz,
- Layer* layer, SkiaColorFilter* colorFilter) {
+ jlong layerHandle, jlong colorFilterHandle) {
+ Layer* layer = reinterpret_cast<Layer*>(layerHandle);
+ SkiaColorFilter* colorFilter = reinterpret_cast<SkiaColorFilter*>(colorFilterHandle);
if (layer) {
layer->setColorFilter(colorFilter);
}
}
static void android_view_GLES20Canvas_setOpaqueLayer(JNIEnv* env, jobject clazz,
- Layer* layer, jboolean isOpaque) {
+ jlong layerHandle, jboolean isOpaque) {
+ Layer* layer = reinterpret_cast<Layer*>(layerHandle);
if (layer) {
layer->setBlend(!isOpaque);
}
}
static void android_view_GLES20Canvas_updateTextureLayer(JNIEnv* env, jobject clazz,
- Layer* layer, jint width, jint height, jboolean isOpaque, jobject surface) {
+ jlong layerHandle, jint width, jint height, jboolean isOpaque, jobject surface) {
+ Layer* layer = reinterpret_cast<Layer*>(layerHandle);
float transform[16];
sp<GLConsumer> surfaceTexture(SurfaceTexture_getSurfaceTexture(env, surface));
@@ -903,57 +1041,75 @@
}
static void android_view_GLES20Canvas_updateRenderLayer(JNIEnv* env, jobject clazz,
- Layer* layer, OpenGLRenderer* renderer, DisplayList* displayList,
+ jlong layerHandle, jlong rendererHandle, jlong displayListHandle,
jint left, jint top, jint right, jint bottom) {
+ Layer* layer = reinterpret_cast<Layer*>(layerHandle);
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
+ DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle);
layer->updateDeferred(renderer, displayList, left, top, right, bottom);
}
static void android_view_GLES20Canvas_clearLayerTexture(JNIEnv* env, jobject clazz,
- Layer* layer) {
+ jlong layerHandle) {
+ Layer* layer = reinterpret_cast<Layer*>(layerHandle);
layer->clearTexture();
}
static void android_view_GLES20Canvas_setTextureLayerTransform(JNIEnv* env, jobject clazz,
- Layer* layer, SkMatrix* matrix) {
+ jlong layerHandle, jlong matrixHandle) {
+ Layer* layer = reinterpret_cast<Layer*>(layerHandle);
+ SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle);
layer->getTransform().load(*matrix);
}
-static void android_view_GLES20Canvas_destroyLayer(JNIEnv* env, jobject clazz, Layer* layer) {
+static void android_view_GLES20Canvas_destroyLayer(JNIEnv* env, jobject clazz, jlong layerHandle) {
+ Layer* layer = reinterpret_cast<Layer*>(layerHandle);
LayerRenderer::destroyLayer(layer);
}
static void android_view_GLES20Canvas_destroyLayerDeferred(JNIEnv* env,
- jobject clazz, Layer* layer) {
+ jobject clazz, jlong layerHandle) {
+ Layer* layer = reinterpret_cast<Layer*>(layerHandle);
LayerRenderer::destroyLayerDeferred(layer);
}
static void android_view_GLES20Canvas_drawLayer(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer, Layer* layer, jfloat x, jfloat y) {
+ jlong rendererHandle, jlong layerHandle, jfloat x, jfloat y) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
+ Layer* layer = reinterpret_cast<Layer*>(layerHandle);
renderer->drawLayer(layer, x, y);
}
static jboolean android_view_GLES20Canvas_copyLayer(JNIEnv* env, jobject clazz,
- Layer* layer, SkBitmap* bitmap) {
+ jlong layerHandle, jlong bitmapHandle) {
+ Layer* layer = reinterpret_cast<Layer*>(layerHandle);
+ SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
return LayerRenderer::copyLayer(layer, bitmap);
}
static void android_view_GLES20Canvas_pushLayerUpdate(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer, Layer* layer) {
+ jlong rendererHandle, jlong layerHandle) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
+ Layer* layer = reinterpret_cast<Layer*>(layerHandle);
renderer->pushLayerUpdate(layer);
}
static void android_view_GLES20Canvas_cancelLayerUpdate(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer, Layer* layer) {
+ jlong rendererHandle, jlong layerHandle) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
+ Layer* layer = reinterpret_cast<Layer*>(layerHandle);
renderer->cancelLayerUpdate(layer);
}
static void android_view_GLES20Canvas_clearLayerUpdates(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer) {
+ jlong rendererHandle) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
renderer->clearLayerUpdates();
}
static void android_view_GLES20Canvas_flushLayerUpdates(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer) {
+ jlong rendererHandle) {
+ OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle);
renderer->flushLayerUpdates();
}
@@ -1005,135 +1161,135 @@
{ "nInitCaches", "()Z", (void*) android_view_GLES20Canvas_initCaches },
{ "nTerminateCaches", "()V", (void*) android_view_GLES20Canvas_terminateCaches },
- { "nInitAtlas", "(Landroid/view/GraphicBuffer;[II)V",
+ { "nInitAtlas", "(Landroid/view/GraphicBuffer;[JI)V",
(void*) android_view_GLES20Canvas_initAtlas },
- { "nCreateRenderer", "()I", (void*) android_view_GLES20Canvas_createRenderer },
- { "nDestroyRenderer", "(I)V", (void*) android_view_GLES20Canvas_destroyRenderer },
- { "nSetViewport", "(III)V", (void*) android_view_GLES20Canvas_setViewport },
- { "nPrepare", "(IZ)I", (void*) android_view_GLES20Canvas_prepare },
- { "nPrepareDirty", "(IIIIIZ)I", (void*) android_view_GLES20Canvas_prepareDirty },
- { "nFinish", "(I)V", (void*) android_view_GLES20Canvas_finish },
- { "nSetName", "(ILjava/lang/String;)V",
+ { "nCreateRenderer", "()J", (void*) android_view_GLES20Canvas_createRenderer },
+ { "nDestroyRenderer", "(J)V", (void*) android_view_GLES20Canvas_destroyRenderer },
+ { "nSetViewport", "(JII)V", (void*) android_view_GLES20Canvas_setViewport },
+ { "nPrepare", "(JZ)I", (void*) android_view_GLES20Canvas_prepare },
+ { "nPrepareDirty", "(JIIIIZ)I", (void*) android_view_GLES20Canvas_prepareDirty },
+ { "nFinish", "(J)V", (void*) android_view_GLES20Canvas_finish },
+ { "nSetName", "(JLjava/lang/String;)V",
(void*) android_view_GLES20Canvas_setName },
- { "nSetCountOverdrawEnabled", "(IZ)V", (void*) android_view_GLES20Canvas_setCountOverdrawEnabled },
- { "nGetOverdraw", "(I)F", (void*) android_view_GLES20Canvas_getOverdraw },
+ { "nSetCountOverdrawEnabled", "(JZ)V", (void*) android_view_GLES20Canvas_setCountOverdrawEnabled },
+ { "nGetOverdraw", "(J)F", (void*) android_view_GLES20Canvas_getOverdraw },
{ "nGetStencilSize", "()I", (void*) android_view_GLES20Canvas_getStencilSize },
- { "nCallDrawGLFunction", "(II)I", (void*) android_view_GLES20Canvas_callDrawGLFunction },
- { "nDetachFunctor", "(II)V", (void*) android_view_GLES20Canvas_detachFunctor },
- { "nAttachFunctor", "(II)V", (void*) android_view_GLES20Canvas_attachFunctor },
- { "nInvokeFunctors", "(ILandroid/graphics/Rect;)I",
+ { "nCallDrawGLFunction", "(JJ)I", (void*) android_view_GLES20Canvas_callDrawGLFunction },
+ { "nDetachFunctor", "(JJ)V", (void*) android_view_GLES20Canvas_detachFunctor },
+ { "nAttachFunctor", "(JJ)V", (void*) android_view_GLES20Canvas_attachFunctor },
+ { "nInvokeFunctors", "(JLandroid/graphics/Rect;)I",
(void*) android_view_GLES20Canvas_invokeFunctors },
- { "nSave", "(II)I", (void*) android_view_GLES20Canvas_save },
- { "nRestore", "(I)V", (void*) android_view_GLES20Canvas_restore },
- { "nRestoreToCount", "(II)V", (void*) android_view_GLES20Canvas_restoreToCount },
- { "nGetSaveCount", "(I)I", (void*) android_view_GLES20Canvas_getSaveCount },
+ { "nSave", "(JI)I", (void*) android_view_GLES20Canvas_save },
+ { "nRestore", "(J)V", (void*) android_view_GLES20Canvas_restore },
+ { "nRestoreToCount", "(JI)V", (void*) android_view_GLES20Canvas_restoreToCount },
+ { "nGetSaveCount", "(J)I", (void*) android_view_GLES20Canvas_getSaveCount },
- { "nSaveLayer", "(IFFFFII)I", (void*) android_view_GLES20Canvas_saveLayer },
- { "nSaveLayer", "(III)I", (void*) android_view_GLES20Canvas_saveLayerClip },
- { "nSaveLayerAlpha", "(IFFFFII)I", (void*) android_view_GLES20Canvas_saveLayerAlpha },
- { "nSaveLayerAlpha", "(III)I", (void*) android_view_GLES20Canvas_saveLayerAlphaClip },
+ { "nSaveLayer", "(JFFFFJI)I", (void*) android_view_GLES20Canvas_saveLayer },
+ { "nSaveLayer", "(JJI)I", (void*) android_view_GLES20Canvas_saveLayerClip },
+ { "nSaveLayerAlpha", "(JFFFFII)I", (void*) android_view_GLES20Canvas_saveLayerAlpha },
+ { "nSaveLayerAlpha", "(JII)I", (void*) android_view_GLES20Canvas_saveLayerAlphaClip },
- { "nQuickReject", "(IFFFF)Z", (void*) android_view_GLES20Canvas_quickReject },
- { "nClipRect", "(IFFFFI)Z", (void*) android_view_GLES20Canvas_clipRectF },
- { "nClipRect", "(IIIIII)Z", (void*) android_view_GLES20Canvas_clipRect },
- { "nClipPath", "(III)Z", (void*) android_view_GLES20Canvas_clipPath },
- { "nClipRegion", "(III)Z", (void*) android_view_GLES20Canvas_clipRegion },
+ { "nQuickReject", "(JFFFF)Z", (void*) android_view_GLES20Canvas_quickReject },
+ { "nClipRect", "(JFFFFI)Z", (void*) android_view_GLES20Canvas_clipRectF },
+ { "nClipRect", "(JIIIII)Z", (void*) android_view_GLES20Canvas_clipRect },
+ { "nClipPath", "(JJI)Z", (void*) android_view_GLES20Canvas_clipPath },
+ { "nClipRegion", "(JJI)Z", (void*) android_view_GLES20Canvas_clipRegion },
- { "nTranslate", "(IFF)V", (void*) android_view_GLES20Canvas_translate },
- { "nRotate", "(IF)V", (void*) android_view_GLES20Canvas_rotate },
- { "nScale", "(IFF)V", (void*) android_view_GLES20Canvas_scale },
- { "nSkew", "(IFF)V", (void*) android_view_GLES20Canvas_skew },
+ { "nTranslate", "(JFF)V", (void*) android_view_GLES20Canvas_translate },
+ { "nRotate", "(JF)V", (void*) android_view_GLES20Canvas_rotate },
+ { "nScale", "(JFF)V", (void*) android_view_GLES20Canvas_scale },
+ { "nSkew", "(JFF)V", (void*) android_view_GLES20Canvas_skew },
- { "nSetMatrix", "(II)V", (void*) android_view_GLES20Canvas_setMatrix },
- { "nGetMatrix", "(II)V", (void*) android_view_GLES20Canvas_getMatrix },
- { "nConcatMatrix", "(II)V", (void*) android_view_GLES20Canvas_concatMatrix },
+ { "nSetMatrix", "(JJ)V", (void*) android_view_GLES20Canvas_setMatrix },
+ { "nGetMatrix", "(JJ)V", (void*) android_view_GLES20Canvas_getMatrix },
+ { "nConcatMatrix", "(JJ)V", (void*) android_view_GLES20Canvas_concatMatrix },
- { "nDrawBitmap", "(II[BFFI)V", (void*) android_view_GLES20Canvas_drawBitmap },
- { "nDrawBitmap", "(II[BFFFFFFFFI)V",(void*) android_view_GLES20Canvas_drawBitmapRect },
- { "nDrawBitmap", "(II[BII)V", (void*) android_view_GLES20Canvas_drawBitmapMatrix },
- { "nDrawBitmap", "(I[IIIFFIIZI)V", (void*) android_view_GLES20Canvas_drawBitmapData },
+ { "nDrawBitmap", "(JJ[BFFJ)V", (void*) android_view_GLES20Canvas_drawBitmap },
+ { "nDrawBitmap", "(JJ[BFFFFFFFFJ)V",(void*) android_view_GLES20Canvas_drawBitmapRect },
+ { "nDrawBitmap", "(JJ[BJJ)V", (void*) android_view_GLES20Canvas_drawBitmapMatrix },
+ { "nDrawBitmap", "(J[IIIFFIIZJ)V", (void*) android_view_GLES20Canvas_drawBitmapData },
- { "nDrawBitmapMesh", "(II[BII[FI[III)V",(void*) android_view_GLES20Canvas_drawBitmapMesh },
+ { "nDrawBitmapMesh", "(JJ[BII[FI[IIJ)V",(void*) android_view_GLES20Canvas_drawBitmapMesh },
- { "nDrawPatch", "(II[BIFFFFI)V", (void*) android_view_GLES20Canvas_drawPatch },
+ { "nDrawPatch", "(JJ[BJFFFFJ)V", (void*) android_view_GLES20Canvas_drawPatch },
- { "nDrawColor", "(III)V", (void*) android_view_GLES20Canvas_drawColor },
- { "nDrawRect", "(IFFFFI)V", (void*) android_view_GLES20Canvas_drawRect },
- { "nDrawRects", "(III)V", (void*) android_view_GLES20Canvas_drawRegionAsRects },
- { "nDrawRects", "(I[FII)V", (void*) android_view_GLES20Canvas_drawRects },
- { "nDrawRoundRect", "(IFFFFFFI)V", (void*) android_view_GLES20Canvas_drawRoundRect },
- { "nDrawCircle", "(IFFFI)V", (void*) android_view_GLES20Canvas_drawCircle },
- { "nDrawOval", "(IFFFFI)V", (void*) android_view_GLES20Canvas_drawOval },
- { "nDrawArc", "(IFFFFFFZI)V", (void*) android_view_GLES20Canvas_drawArc },
- { "nDrawPoints", "(I[FIII)V", (void*) android_view_GLES20Canvas_drawPoints },
+ { "nDrawColor", "(JII)V", (void*) android_view_GLES20Canvas_drawColor },
+ { "nDrawRect", "(JFFFFJ)V", (void*) android_view_GLES20Canvas_drawRect },
+ { "nDrawRects", "(JJJ)V", (void*) android_view_GLES20Canvas_drawRegionAsRects },
+ { "nDrawRects", "(J[FIJ)V", (void*) android_view_GLES20Canvas_drawRects },
+ { "nDrawRoundRect", "(JFFFFFFJ)V", (void*) android_view_GLES20Canvas_drawRoundRect },
+ { "nDrawCircle", "(JFFFJ)V", (void*) android_view_GLES20Canvas_drawCircle },
+ { "nDrawOval", "(JFFFFJ)V", (void*) android_view_GLES20Canvas_drawOval },
+ { "nDrawArc", "(JFFFFFFZJ)V", (void*) android_view_GLES20Canvas_drawArc },
+ { "nDrawPoints", "(J[FIIJ)V", (void*) android_view_GLES20Canvas_drawPoints },
- { "nDrawPath", "(III)V", (void*) android_view_GLES20Canvas_drawPath },
- { "nDrawLines", "(I[FIII)V", (void*) android_view_GLES20Canvas_drawLines },
+ { "nDrawPath", "(JJJ)V", (void*) android_view_GLES20Canvas_drawPath },
+ { "nDrawLines", "(J[FIIJ)V", (void*) android_view_GLES20Canvas_drawLines },
- { "nResetModifiers", "(II)V", (void*) android_view_GLES20Canvas_resetModifiers },
- { "nSetupShader", "(II)V", (void*) android_view_GLES20Canvas_setupShader },
- { "nSetupColorFilter", "(II)V", (void*) android_view_GLES20Canvas_setupColorFilter },
- { "nSetupShadow", "(IFFFI)V", (void*) android_view_GLES20Canvas_setupShadow },
+ { "nResetModifiers", "(JI)V", (void*) android_view_GLES20Canvas_resetModifiers },
+ { "nSetupShader", "(JJ)V", (void*) android_view_GLES20Canvas_setupShader },
+ { "nSetupColorFilter", "(JJ)V", (void*) android_view_GLES20Canvas_setupColorFilter },
+ { "nSetupShadow", "(JFFFI)V", (void*) android_view_GLES20Canvas_setupShadow },
- { "nSetupPaintFilter", "(III)V", (void*) android_view_GLES20Canvas_setupPaintFilter },
- { "nResetPaintFilter", "(I)V", (void*) android_view_GLES20Canvas_resetPaintFilter },
+ { "nSetupPaintFilter", "(JII)V", (void*) android_view_GLES20Canvas_setupPaintFilter },
+ { "nResetPaintFilter", "(J)V", (void*) android_view_GLES20Canvas_resetPaintFilter },
- { "nDrawText", "(I[CIIFFII)V", (void*) android_view_GLES20Canvas_drawTextArray },
- { "nDrawText", "(ILjava/lang/String;IIFFII)V",
+ { "nDrawText", "(J[CIIFFIJ)V", (void*) android_view_GLES20Canvas_drawTextArray },
+ { "nDrawText", "(JLjava/lang/String;IIFFIJ)V",
(void*) android_view_GLES20Canvas_drawText },
- { "nDrawTextOnPath", "(I[CIIIFFII)V", (void*) android_view_GLES20Canvas_drawTextArrayOnPath },
- { "nDrawTextOnPath", "(ILjava/lang/String;IIIFFII)V",
+ { "nDrawTextOnPath", "(J[CIIJFFIJ)V", (void*) android_view_GLES20Canvas_drawTextArrayOnPath },
+ { "nDrawTextOnPath", "(JLjava/lang/String;IIJFFIJ)V",
(void*) android_view_GLES20Canvas_drawTextOnPath },
- { "nDrawTextRun", "(I[CIIIIFFII)V", (void*) android_view_GLES20Canvas_drawTextRunArray },
- { "nDrawTextRun", "(ILjava/lang/String;IIIIFFII)V",
+ { "nDrawTextRun", "(J[CIIIIFFIJ)V", (void*) android_view_GLES20Canvas_drawTextRunArray },
+ { "nDrawTextRun", "(JLjava/lang/String;IIIIFFIJ)V",
(void*) android_view_GLES20Canvas_drawTextRun },
- { "nDrawPosText", "(I[CII[FI)V", (void*) android_view_GLES20Canvas_drawPosTextArray },
- { "nDrawPosText", "(ILjava/lang/String;II[FI)V",
+ { "nDrawPosText", "(J[CII[FJ)V", (void*) android_view_GLES20Canvas_drawPosTextArray },
+ { "nDrawPosText", "(JLjava/lang/String;II[FJ)V",
(void*) android_view_GLES20Canvas_drawPosText },
- { "nGetClipBounds", "(ILandroid/graphics/Rect;)Z",
+ { "nGetClipBounds", "(JLandroid/graphics/Rect;)Z",
(void*) android_view_GLES20Canvas_getClipBounds },
- { "nGetDisplayList", "(II)I", (void*) android_view_GLES20Canvas_getDisplayList },
- { "nOutputDisplayList", "(II)V", (void*) android_view_GLES20Canvas_outputDisplayList },
- { "nDrawDisplayList", "(IILandroid/graphics/Rect;I)I",
+ { "nGetDisplayList", "(JJ)J", (void*) android_view_GLES20Canvas_getDisplayList },
+ { "nOutputDisplayList", "(JJ)V", (void*) android_view_GLES20Canvas_outputDisplayList },
+ { "nDrawDisplayList", "(JJLandroid/graphics/Rect;I)I",
(void*) android_view_GLES20Canvas_drawDisplayList },
- { "nCreateDisplayListRenderer", "()I", (void*) android_view_GLES20Canvas_createDisplayListRenderer },
- { "nResetDisplayListRenderer", "(I)V", (void*) android_view_GLES20Canvas_resetDisplayListRenderer },
+ { "nCreateDisplayListRenderer", "()J", (void*) android_view_GLES20Canvas_createDisplayListRenderer },
+ { "nResetDisplayListRenderer", "(J)V", (void*) android_view_GLES20Canvas_resetDisplayListRenderer },
- { "nInterrupt", "(I)V", (void*) android_view_GLES20Canvas_interrupt },
- { "nResume", "(I)V", (void*) android_view_GLES20Canvas_resume },
+ { "nInterrupt", "(J)V", (void*) android_view_GLES20Canvas_interrupt },
+ { "nResume", "(J)V", (void*) android_view_GLES20Canvas_resume },
- { "nCreateLayerRenderer", "(I)I", (void*) android_view_GLES20Canvas_createLayerRenderer },
- { "nCreateLayer", "(IIZ[I)I", (void*) android_view_GLES20Canvas_createLayer },
- { "nResizeLayer", "(III[I)Z" , (void*) android_view_GLES20Canvas_resizeLayer },
- { "nSetLayerPaint", "(II)V", (void*) android_view_GLES20Canvas_setLayerPaint },
- { "nSetLayerColorFilter", "(II)V", (void*) android_view_GLES20Canvas_setLayerColorFilter },
- { "nSetOpaqueLayer", "(IZ)V", (void*) android_view_GLES20Canvas_setOpaqueLayer },
- { "nCreateTextureLayer", "(Z[I)I", (void*) android_view_GLES20Canvas_createTextureLayer },
- { "nUpdateTextureLayer", "(IIIZLandroid/graphics/SurfaceTexture;)V",
+ { "nCreateLayerRenderer", "(J)J", (void*) android_view_GLES20Canvas_createLayerRenderer },
+ { "nCreateLayer", "(IIZ[I)J", (void*) android_view_GLES20Canvas_createLayer },
+ { "nResizeLayer", "(JII[I)Z" , (void*) android_view_GLES20Canvas_resizeLayer },
+ { "nSetLayerPaint", "(JJ)V", (void*) android_view_GLES20Canvas_setLayerPaint },
+ { "nSetLayerColorFilter", "(JJ)V", (void*) android_view_GLES20Canvas_setLayerColorFilter },
+ { "nSetOpaqueLayer", "(JZ)V", (void*) android_view_GLES20Canvas_setOpaqueLayer },
+ { "nCreateTextureLayer", "(Z[I)J", (void*) android_view_GLES20Canvas_createTextureLayer },
+ { "nUpdateTextureLayer", "(JIIZLandroid/graphics/SurfaceTexture;)V",
(void*) android_view_GLES20Canvas_updateTextureLayer },
- { "nUpdateRenderLayer", "(IIIIIII)V", (void*) android_view_GLES20Canvas_updateRenderLayer },
- { "nClearLayerTexture", "(I)V", (void*) android_view_GLES20Canvas_clearLayerTexture },
- { "nDestroyLayer", "(I)V", (void*) android_view_GLES20Canvas_destroyLayer },
- { "nDestroyLayerDeferred", "(I)V", (void*) android_view_GLES20Canvas_destroyLayerDeferred },
- { "nDrawLayer", "(IIFF)V", (void*) android_view_GLES20Canvas_drawLayer },
- { "nCopyLayer", "(II)Z", (void*) android_view_GLES20Canvas_copyLayer },
- { "nClearLayerUpdates", "(I)V", (void*) android_view_GLES20Canvas_clearLayerUpdates },
- { "nFlushLayerUpdates", "(I)V", (void*) android_view_GLES20Canvas_flushLayerUpdates },
- { "nPushLayerUpdate", "(II)V", (void*) android_view_GLES20Canvas_pushLayerUpdate },
- { "nCancelLayerUpdate", "(II)V", (void*) android_view_GLES20Canvas_cancelLayerUpdate },
+ { "nUpdateRenderLayer", "(JJJIIII)V", (void*) android_view_GLES20Canvas_updateRenderLayer },
+ { "nClearLayerTexture", "(J)V", (void*) android_view_GLES20Canvas_clearLayerTexture },
+ { "nDestroyLayer", "(J)V", (void*) android_view_GLES20Canvas_destroyLayer },
+ { "nDestroyLayerDeferred", "(J)V", (void*) android_view_GLES20Canvas_destroyLayerDeferred },
+ { "nDrawLayer", "(JJFF)V", (void*) android_view_GLES20Canvas_drawLayer },
+ { "nCopyLayer", "(JJ)Z", (void*) android_view_GLES20Canvas_copyLayer },
+ { "nClearLayerUpdates", "(J)V", (void*) android_view_GLES20Canvas_clearLayerUpdates },
+ { "nFlushLayerUpdates", "(J)V", (void*) android_view_GLES20Canvas_flushLayerUpdates },
+ { "nPushLayerUpdate", "(JJ)V", (void*) android_view_GLES20Canvas_pushLayerUpdate },
+ { "nCancelLayerUpdate", "(JJ)V", (void*) android_view_GLES20Canvas_cancelLayerUpdate },
- { "nSetTextureLayerTransform", "(II)V", (void*) android_view_GLES20Canvas_setTextureLayerTransform },
+ { "nSetTextureLayerTransform", "(JJ)V", (void*) android_view_GLES20Canvas_setTextureLayerTransform },
{ "nGetMaximumTextureWidth", "()I", (void*) android_view_GLES20Canvas_getMaxTextureWidth },
{ "nGetMaximumTextureHeight", "()I", (void*) android_view_GLES20Canvas_getMaxTextureHeight },
diff --git a/core/jni/android_view_GLES20DisplayList.cpp b/core/jni/android_view_GLES20DisplayList.cpp
index 4ce2e24..8e19efd 100644
--- a/core/jni/android_view_GLES20DisplayList.cpp
+++ b/core/jni/android_view_GLES20DisplayList.cpp
@@ -42,17 +42,20 @@
// ----------------------------------------------------------------------------
static void android_view_GLES20DisplayList_reset(JNIEnv* env,
- jobject clazz, DisplayList* displayList) {
+ jobject clazz, jlong displayListHandle) {
+ DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle);
displayList->reset();
}
static jint android_view_GLES20DisplayList_getDisplayListSize(JNIEnv* env,
- jobject clazz, DisplayList* displayList) {
+ jobject clazz, jlong displayListHandle) {
+ DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle);
return displayList->getSize();
}
static void android_view_GLES20DisplayList_setDisplayListName(JNIEnv* env,
- jobject clazz, DisplayList* displayList, jstring name) {
+ jobject clazz, jlong displayListHandle, jstring name) {
+ DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle);
if (name != NULL) {
const char* textArray = env->GetStringUTFChars(name, NULL);
displayList->setName(textArray);
@@ -61,7 +64,8 @@
}
static void android_view_GLES20DisplayList_destroyDisplayList(JNIEnv* env,
- jobject clazz, DisplayList* displayList) {
+ jobject clazz, jlong displayListHandle) {
+ DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle);
DisplayList::destroyDisplayListDeferred(displayList);
}
@@ -70,74 +74,91 @@
// ----------------------------------------------------------------------------
static void android_view_GLES20DisplayList_setCaching(JNIEnv* env,
- jobject clazz, DisplayList* displayList, jboolean caching) {
+ jobject clazz, jlong displayListHandle, jboolean caching) {
+ DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle);
displayList->setCaching(caching);
}
+//serban
static void android_view_GLES20DisplayList_setStaticMatrix(JNIEnv* env,
- jobject clazz, DisplayList* displayList, SkMatrix* matrix) {
+ jobject clazz, jlong displayListHandle, jlong matrixHandle) {
+ DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle);
+ SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle);
displayList->setStaticMatrix(matrix);
}
static void android_view_GLES20DisplayList_setAnimationMatrix(JNIEnv* env,
- jobject clazz, DisplayList* displayList, SkMatrix* matrix) {
+ jobject clazz, jlong displayListHandle, jlong matrixHandle) {
+ DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle);
+ SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle);
displayList->setAnimationMatrix(matrix);
}
static void android_view_GLES20DisplayList_setClipToBounds(JNIEnv* env,
- jobject clazz, DisplayList* displayList, jboolean clipToBounds) {
+ jobject clazz, jlong displayListHandle, jboolean clipToBounds) {
+ DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle);
displayList->setClipToBounds(clipToBounds);
}
static void android_view_GLES20DisplayList_setAlpha(JNIEnv* env,
- jobject clazz, DisplayList* displayList, float alpha) {
+ jobject clazz, jlong displayListHandle, jfloat alpha) {
+ DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle);
displayList->setAlpha(alpha);
}
static void android_view_GLES20DisplayList_setHasOverlappingRendering(JNIEnv* env,
- jobject clazz, DisplayList* displayList, bool hasOverlappingRendering) {
+ jobject clazz, jlong displayListHandle, jboolean hasOverlappingRendering) {
+ DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle);
displayList->setHasOverlappingRendering(hasOverlappingRendering);
}
static void android_view_GLES20DisplayList_setTranslationX(JNIEnv* env,
- jobject clazz, DisplayList* displayList, float tx) {
+ jobject clazz, jlong displayListHandle, jfloat tx) {
+ DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle);
displayList->setTranslationX(tx);
}
static void android_view_GLES20DisplayList_setTranslationY(JNIEnv* env,
- jobject clazz, DisplayList* displayList, float ty) {
+ jobject clazz, jlong displayListHandle, jfloat ty) {
+ DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle);
displayList->setTranslationY(ty);
}
static void android_view_GLES20DisplayList_setRotation(JNIEnv* env,
- jobject clazz, DisplayList* displayList, float rotation) {
+ jobject clazz, jlong displayListHandle, jfloat rotation) {
+ DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle);
displayList->setRotation(rotation);
}
static void android_view_GLES20DisplayList_setRotationX(JNIEnv* env,
- jobject clazz, DisplayList* displayList, float rx) {
+ jobject clazz, jlong displayListHandle, jfloat rx) {
+ DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle);
displayList->setRotationX(rx);
}
static void android_view_GLES20DisplayList_setRotationY(JNIEnv* env,
- jobject clazz, DisplayList* displayList, float ry) {
+ jobject clazz, jlong displayListHandle, jfloat ry) {
+ DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle);
displayList->setRotationY(ry);
}
static void android_view_GLES20DisplayList_setScaleX(JNIEnv* env,
- jobject clazz, DisplayList* displayList, float sx) {
+ jobject clazz, jlong displayListHandle, jfloat sx) {
+ DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle);
displayList->setScaleX(sx);
}
static void android_view_GLES20DisplayList_setScaleY(JNIEnv* env,
- jobject clazz, DisplayList* displayList, float sy) {
+ jobject clazz, jlong displayListHandle, jfloat sy) {
+ DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle);
displayList->setScaleY(sy);
}
static void android_view_GLES20DisplayList_setTransformationInfo(JNIEnv* env,
- jobject clazz, DisplayList* displayList, float alpha,
- float translationX, float translationY, float rotation, float rotationX, float rotationY,
- float scaleX, float scaleY) {
+ jobject clazz, jlong displayListHandle, jfloat alpha,
+ jfloat translationX, jfloat translationY, jfloat rotation, jfloat rotationX, jfloat rotationY,
+ jfloat scaleX, jfloat scaleY) {
+ DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle);
displayList->setAlpha(alpha);
displayList->setTranslationX(translationX);
displayList->setTranslationY(translationY);
@@ -149,58 +170,70 @@
}
static void android_view_GLES20DisplayList_setPivotX(JNIEnv* env,
- jobject clazz, DisplayList* displayList, float px) {
+ jobject clazz, jlong displayListHandle, jfloat px) {
+ DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle);
displayList->setPivotX(px);
}
static void android_view_GLES20DisplayList_setPivotY(JNIEnv* env,
- jobject clazz, DisplayList* displayList, float py) {
+ jobject clazz, jlong displayListHandle, jfloat py) {
+ DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle);
displayList->setPivotY(py);
}
static void android_view_GLES20DisplayList_setCameraDistance(JNIEnv* env,
- jobject clazz, DisplayList* displayList, float distance) {
+ jobject clazz, jlong displayListHandle, jfloat distance) {
+ DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle);
displayList->setCameraDistance(distance);
}
static void android_view_GLES20DisplayList_setLeft(JNIEnv* env,
- jobject clazz, DisplayList* displayList, int left) {
+ jobject clazz, jlong displayListHandle, jint left) {
+ DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle);
displayList->setLeft(left);
}
static void android_view_GLES20DisplayList_setTop(JNIEnv* env,
- jobject clazz, DisplayList* displayList, int top) {
+ jobject clazz, jlong displayListHandle, jint top) {
+ DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle);
displayList->setTop(top);
}
static void android_view_GLES20DisplayList_setRight(JNIEnv* env,
- jobject clazz, DisplayList* displayList, int right) {
+ jobject clazz, jlong displayListHandle, jint right) {
+ DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle);
displayList->setRight(right);
}
static void android_view_GLES20DisplayList_setBottom(JNIEnv* env,
- jobject clazz, DisplayList* displayList, int bottom) {
+ jobject clazz, jlong displayListHandle, jint bottom) {
+ DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle);
displayList->setBottom(bottom);
}
static void android_view_GLES20DisplayList_setLeftTopRightBottom(JNIEnv* env,
- jobject clazz, DisplayList* displayList, int left, int top,
+ jobject clazz, jlong displayListHandle, jint left, jint top,
int right, int bottom) {
+ DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle);
displayList->setLeftTopRightBottom(left, top, right, bottom);
}
static void android_view_GLES20DisplayList_offsetLeftAndRight(JNIEnv* env,
- jobject clazz, DisplayList* displayList, float offset) {
+ jobject clazz, jlong displayListHandle, jfloat offset) {
+ DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle);
displayList->offsetLeftRight(offset);
}
static void android_view_GLES20DisplayList_offsetTopAndBottom(JNIEnv* env,
- jobject clazz, DisplayList* displayList, float offset) {
+ jobject clazz, jlong displayListHandle, jfloat offset) {
+ DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle);
displayList->offsetTopBottom(offset);
}
static void android_view_GLES20DisplayList_getMatrix(JNIEnv* env,
- jobject clazz, DisplayList* displayList, SkMatrix* matrix) {
+ jobject clazz, jlong displayListHandle, jlong matrixHandle) {
+ DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle);
+ SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle);
SkMatrix* source = displayList->getStaticMatrix();
if (source) {
matrix->setConcat(SkMatrix::I(), *source);
@@ -210,82 +243,98 @@
}
static jboolean android_view_GLES20DisplayList_hasOverlappingRendering(JNIEnv* env,
- jobject clazz, DisplayList* displayList) {
+ jobject clazz, jlong displayListHandle) {
+ DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle);
return displayList->hasOverlappingRendering();
}
static jfloat android_view_GLES20DisplayList_getAlpha(JNIEnv* env,
- jobject clazz, DisplayList* displayList) {
+ jobject clazz, jlong displayListHandle) {
+ DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle);
return displayList->getAlpha();
}
static jfloat android_view_GLES20DisplayList_getLeft(JNIEnv* env,
- jobject clazz, DisplayList* displayList) {
+ jobject clazz, jlong displayListHandle) {
+ DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle);
return displayList->getLeft();
}
static jfloat android_view_GLES20DisplayList_getTop(JNIEnv* env,
- jobject clazz, DisplayList* displayList) {
+ jobject clazz, jlong displayListHandle) {
+ DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle);
return displayList->getTop();
}
static jfloat android_view_GLES20DisplayList_getRight(JNIEnv* env,
- jobject clazz, DisplayList* displayList) {
+ jobject clazz, jlong displayListHandle) {
+ DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle);
return displayList->getRight();
}
static jfloat android_view_GLES20DisplayList_getBottom(JNIEnv* env,
- jobject clazz, DisplayList* displayList) {
+ jobject clazz, jlong displayListHandle) {
+ DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle);
return displayList->getBottom();
}
static jfloat android_view_GLES20DisplayList_getCameraDistance(JNIEnv* env,
- jobject clazz, DisplayList* displayList) {
+ jobject clazz, jlong displayListHandle) {
+ DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle);
return displayList->getCameraDistance();
}
static jfloat android_view_GLES20DisplayList_getScaleX(JNIEnv* env,
- jobject clazz, DisplayList* displayList) {
+ jobject clazz, jlong displayListHandle) {
+ DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle);
return displayList->getScaleX();
}
static jfloat android_view_GLES20DisplayList_getScaleY(JNIEnv* env,
- jobject clazz, DisplayList* displayList) {
+ jobject clazz, jlong displayListHandle) {
+ DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle);
return displayList->getScaleY();
}
static jfloat android_view_GLES20DisplayList_getTranslationX(JNIEnv* env,
- jobject clazz, DisplayList* displayList) {
+ jobject clazz, jlong displayListHandle) {
+ DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle);
return displayList->getTranslationX();
}
static jfloat android_view_GLES20DisplayList_getTranslationY(JNIEnv* env,
- jobject clazz, DisplayList* displayList) {
+ jobject clazz, jlong displayListHandle) {
+ DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle);
return displayList->getTranslationY();
}
static jfloat android_view_GLES20DisplayList_getRotation(JNIEnv* env,
- jobject clazz, DisplayList* displayList) {
+ jobject clazz, jlong displayListHandle) {
+ DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle);
return displayList->getRotation();
}
static jfloat android_view_GLES20DisplayList_getRotationX(JNIEnv* env,
- jobject clazz, DisplayList* displayList) {
+ jobject clazz, jlong displayListHandle) {
+ DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle);
return displayList->getRotationX();
}
static jfloat android_view_GLES20DisplayList_getRotationY(JNIEnv* env,
- jobject clazz, DisplayList* displayList) {
+ jobject clazz, jlong displayListHandle) {
+ DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle);
return displayList->getRotationY();
}
static jfloat android_view_GLES20DisplayList_getPivotX(JNIEnv* env,
- jobject clazz, DisplayList* displayList) {
+ jobject clazz, jlong displayListHandle) {
+ DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle);
return displayList->getPivotX();
}
static jfloat android_view_GLES20DisplayList_getPivotY(JNIEnv* env,
- jobject clazz, DisplayList* displayList) {
+ jobject clazz, jlong displayListHandle) {
+ DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle);
return displayList->getPivotY();
}
@@ -299,58 +348,58 @@
static JNINativeMethod gMethods[] = {
#ifdef USE_OPENGL_RENDERER
- { "nDestroyDisplayList", "(I)V", (void*) android_view_GLES20DisplayList_destroyDisplayList },
- { "nGetDisplayListSize", "(I)I", (void*) android_view_GLES20DisplayList_getDisplayListSize },
- { "nSetDisplayListName", "(ILjava/lang/String;)V",
+ { "nDestroyDisplayList", "(J)V", (void*) android_view_GLES20DisplayList_destroyDisplayList },
+ { "nGetDisplayListSize", "(J)I", (void*) android_view_GLES20DisplayList_getDisplayListSize },
+ { "nSetDisplayListName", "(JLjava/lang/String;)V",
(void*) android_view_GLES20DisplayList_setDisplayListName },
- { "nReset", "(I)V", (void*) android_view_GLES20DisplayList_reset },
- { "nSetCaching", "(IZ)V", (void*) android_view_GLES20DisplayList_setCaching },
- { "nSetStaticMatrix", "(II)V", (void*) android_view_GLES20DisplayList_setStaticMatrix },
- { "nSetAnimationMatrix", "(II)V", (void*) android_view_GLES20DisplayList_setAnimationMatrix },
- { "nSetClipToBounds", "(IZ)V", (void*) android_view_GLES20DisplayList_setClipToBounds },
- { "nSetAlpha", "(IF)V", (void*) android_view_GLES20DisplayList_setAlpha },
- { "nSetHasOverlappingRendering", "(IZ)V",
+ { "nReset", "(J)V", (void*) android_view_GLES20DisplayList_reset },
+ { "nSetCaching", "(JZ)V", (void*) android_view_GLES20DisplayList_setCaching },
+ { "nSetStaticMatrix", "(JJ)V", (void*) android_view_GLES20DisplayList_setStaticMatrix },
+ { "nSetAnimationMatrix", "(JJ)V", (void*) android_view_GLES20DisplayList_setAnimationMatrix },
+ { "nSetClipToBounds", "(JZ)V", (void*) android_view_GLES20DisplayList_setClipToBounds },
+ { "nSetAlpha", "(JF)V", (void*) android_view_GLES20DisplayList_setAlpha },
+ { "nSetHasOverlappingRendering", "(JZ)V",
(void*) android_view_GLES20DisplayList_setHasOverlappingRendering },
- { "nSetTranslationX", "(IF)V", (void*) android_view_GLES20DisplayList_setTranslationX },
- { "nSetTranslationY", "(IF)V", (void*) android_view_GLES20DisplayList_setTranslationY },
- { "nSetRotation", "(IF)V", (void*) android_view_GLES20DisplayList_setRotation },
- { "nSetRotationX", "(IF)V", (void*) android_view_GLES20DisplayList_setRotationX },
- { "nSetRotationY", "(IF)V", (void*) android_view_GLES20DisplayList_setRotationY },
- { "nSetScaleX", "(IF)V", (void*) android_view_GLES20DisplayList_setScaleX },
- { "nSetScaleY", "(IF)V", (void*) android_view_GLES20DisplayList_setScaleY },
- { "nSetTransformationInfo","(IFFFFFFFF)V",
+ { "nSetTranslationX", "(JF)V", (void*) android_view_GLES20DisplayList_setTranslationX },
+ { "nSetTranslationY", "(JF)V", (void*) android_view_GLES20DisplayList_setTranslationY },
+ { "nSetRotation", "(JF)V", (void*) android_view_GLES20DisplayList_setRotation },
+ { "nSetRotationX", "(JF)V", (void*) android_view_GLES20DisplayList_setRotationX },
+ { "nSetRotationY", "(JF)V", (void*) android_view_GLES20DisplayList_setRotationY },
+ { "nSetScaleX", "(JF)V", (void*) android_view_GLES20DisplayList_setScaleX },
+ { "nSetScaleY", "(JF)V", (void*) android_view_GLES20DisplayList_setScaleY },
+ { "nSetTransformationInfo","(JFFFFFFFF)V",
(void*) android_view_GLES20DisplayList_setTransformationInfo },
- { "nSetPivotX", "(IF)V", (void*) android_view_GLES20DisplayList_setPivotX },
- { "nSetPivotY", "(IF)V", (void*) android_view_GLES20DisplayList_setPivotY },
- { "nSetCameraDistance", "(IF)V", (void*) android_view_GLES20DisplayList_setCameraDistance },
- { "nSetLeft", "(II)V", (void*) android_view_GLES20DisplayList_setLeft },
- { "nSetTop", "(II)V", (void*) android_view_GLES20DisplayList_setTop },
- { "nSetRight", "(II)V", (void*) android_view_GLES20DisplayList_setRight },
- { "nSetBottom", "(II)V", (void*) android_view_GLES20DisplayList_setBottom },
- { "nSetLeftTopRightBottom","(IIIII)V",
+ { "nSetPivotX", "(JF)V", (void*) android_view_GLES20DisplayList_setPivotX },
+ { "nSetPivotY", "(JF)V", (void*) android_view_GLES20DisplayList_setPivotY },
+ { "nSetCameraDistance", "(JF)V", (void*) android_view_GLES20DisplayList_setCameraDistance },
+ { "nSetLeft", "(JI)V", (void*) android_view_GLES20DisplayList_setLeft },
+ { "nSetTop", "(JI)V", (void*) android_view_GLES20DisplayList_setTop },
+ { "nSetRight", "(JI)V", (void*) android_view_GLES20DisplayList_setRight },
+ { "nSetBottom", "(JI)V", (void*) android_view_GLES20DisplayList_setBottom },
+ { "nSetLeftTopRightBottom","(JIIII)V",
(void*) android_view_GLES20DisplayList_setLeftTopRightBottom },
- { "nOffsetLeftAndRight", "(IF)V", (void*) android_view_GLES20DisplayList_offsetLeftAndRight },
- { "nOffsetTopAndBottom", "(IF)V", (void*) android_view_GLES20DisplayList_offsetTopAndBottom },
+ { "nOffsetLeftAndRight", "(JF)V", (void*) android_view_GLES20DisplayList_offsetLeftAndRight },
+ { "nOffsetTopAndBottom", "(JF)V", (void*) android_view_GLES20DisplayList_offsetTopAndBottom },
- { "nGetMatrix", "(II)V", (void*) android_view_GLES20DisplayList_getMatrix },
- { "nHasOverlappingRendering", "(I)Z", (void*) android_view_GLES20DisplayList_hasOverlappingRendering },
- { "nGetAlpha", "(I)F", (void*) android_view_GLES20DisplayList_getAlpha },
- { "nGetLeft", "(I)F", (void*) android_view_GLES20DisplayList_getLeft },
- { "nGetTop", "(I)F", (void*) android_view_GLES20DisplayList_getTop },
- { "nGetRight", "(I)F", (void*) android_view_GLES20DisplayList_getRight },
- { "nGetBottom", "(I)F", (void*) android_view_GLES20DisplayList_getBottom },
- { "nGetCameraDistance", "(I)F", (void*) android_view_GLES20DisplayList_getCameraDistance },
- { "nGetScaleX", "(I)F", (void*) android_view_GLES20DisplayList_getScaleX },
- { "nGetScaleY", "(I)F", (void*) android_view_GLES20DisplayList_getScaleY },
- { "nGetTranslationX", "(I)F", (void*) android_view_GLES20DisplayList_getTranslationX },
- { "nGetTranslationY", "(I)F", (void*) android_view_GLES20DisplayList_getTranslationY },
- { "nGetRotation", "(I)F", (void*) android_view_GLES20DisplayList_getRotation },
- { "nGetRotationX", "(I)F", (void*) android_view_GLES20DisplayList_getRotationX },
- { "nGetRotationY", "(I)F", (void*) android_view_GLES20DisplayList_getRotationY },
- { "nGetPivotX", "(I)F", (void*) android_view_GLES20DisplayList_getPivotX },
- { "nGetPivotY", "(I)F", (void*) android_view_GLES20DisplayList_getPivotY },
+ { "nGetMatrix", "(JJ)V", (void*) android_view_GLES20DisplayList_getMatrix },
+ { "nHasOverlappingRendering", "(J)Z", (void*) android_view_GLES20DisplayList_hasOverlappingRendering },
+ { "nGetAlpha", "(J)F", (void*) android_view_GLES20DisplayList_getAlpha },
+ { "nGetLeft", "(J)F", (void*) android_view_GLES20DisplayList_getLeft },
+ { "nGetTop", "(J)F", (void*) android_view_GLES20DisplayList_getTop },
+ { "nGetRight", "(J)F", (void*) android_view_GLES20DisplayList_getRight },
+ { "nGetBottom", "(J)F", (void*) android_view_GLES20DisplayList_getBottom },
+ { "nGetCameraDistance", "(J)F", (void*) android_view_GLES20DisplayList_getCameraDistance },
+ { "nGetScaleX", "(J)F", (void*) android_view_GLES20DisplayList_getScaleX },
+ { "nGetScaleY", "(J)F", (void*) android_view_GLES20DisplayList_getScaleY },
+ { "nGetTranslationX", "(J)F", (void*) android_view_GLES20DisplayList_getTranslationX },
+ { "nGetTranslationY", "(J)F", (void*) android_view_GLES20DisplayList_getTranslationY },
+ { "nGetRotation", "(J)F", (void*) android_view_GLES20DisplayList_getRotation },
+ { "nGetRotationX", "(J)F", (void*) android_view_GLES20DisplayList_getRotationX },
+ { "nGetRotationY", "(J)F", (void*) android_view_GLES20DisplayList_getRotationY },
+ { "nGetPivotX", "(J)F", (void*) android_view_GLES20DisplayList_getPivotX },
+ { "nGetPivotY", "(J)F", (void*) android_view_GLES20DisplayList_getPivotY },
#endif
};
diff --git a/core/jni/android_view_GraphicBuffer.cpp b/core/jni/android_view_GraphicBuffer.cpp
index d68c0b2..2e8dccf 100644
--- a/core/jni/android_view_GraphicBuffer.cpp
+++ b/core/jni/android_view_GraphicBuffer.cpp
@@ -89,6 +89,12 @@
#define SET_INT(object, field, value) \
env->SetIntField(object, field, value)
+#define GET_LONG(object, field) \
+ env->GetLongField(object, field)
+
+#define SET_LONG(object, field, value) \
+ env->SetLongField(object, field, value)
+
#define INVOKEV(object, method, ...) \
env->CallVoidMethod(object, method, __VA_ARGS__)
@@ -108,7 +114,7 @@
// GraphicBuffer lifecycle
// ----------------------------------------------------------------------------
-static GraphicBufferWrapper* android_view_GraphiceBuffer_create(JNIEnv* env, jobject clazz,
+static jlong android_view_GraphiceBuffer_create(JNIEnv* env, jobject clazz,
jint width, jint height, jint format, jint usage) {
sp<ISurfaceComposer> composer(ComposerService::getComposerService());
@@ -125,11 +131,14 @@
return NULL;
}
- return new GraphicBufferWrapper(buffer);
+ GraphicBufferWrapper* wrapper = new GraphicBufferWrapper(buffer);
+ return reinterpret_cast<jlong>(wrapper);
}
static void android_view_GraphiceBuffer_destroy(JNIEnv* env, jobject clazz,
- GraphicBufferWrapper* wrapper) {
+ jlong wrapperHandle) {
+ GraphicBufferWrapper* wrapper =
+ reinterpret_cast<GraphicBufferWrapper*>(wrapperHandle);
delete wrapper;
}
@@ -140,9 +149,9 @@
static inline void swapCanvasPtr(JNIEnv* env, jobject canvasObj, SkCanvas* newCanvas) {
jobject canvasFinalizerObj = env->GetObjectField(canvasObj, gCanvasClassInfo.mFinalizer);
SkCanvas* previousCanvas = reinterpret_cast<SkCanvas*>(
- GET_INT(canvasObj, gCanvasClassInfo.mNativeCanvas));
- SET_INT(canvasObj, gCanvasClassInfo.mNativeCanvas, (int) newCanvas);
- SET_INT(canvasFinalizerObj, gCanvasFinalizerClassInfo.mNativeCanvas, (int) newCanvas);
+ GET_LONG(canvasObj, gCanvasClassInfo.mNativeCanvas));
+ SET_LONG(canvasObj, gCanvasClassInfo.mNativeCanvas, (long) newCanvas);
+ SET_LONG(canvasFinalizerObj, gCanvasFinalizerClassInfo.mNativeCanvas, (long) newCanvas);
SkSafeUnref(previousCanvas);
}
@@ -160,10 +169,12 @@
}
static jboolean android_view_GraphicBuffer_lockCanvas(JNIEnv* env, jobject,
- GraphicBufferWrapper* wrapper, jobject canvas, jobject dirtyRect) {
+ jlong wrapperHandle, jobject canvas, jobject dirtyRect) {
+ GraphicBufferWrapper* wrapper =
+ reinterpret_cast<GraphicBufferWrapper*>(wrapperHandle);
if (!wrapper) {
- return false;
+ return JNI_FALSE;
}
sp<GraphicBuffer> buffer(wrapper->buffer);
@@ -181,10 +192,10 @@
void* bits = NULL;
status_t status = buffer->lock(LOCK_CANVAS_USAGE, rect, &bits);
- if (status) return false;
+ if (status) return JNI_FALSE;
if (!bits) {
buffer->unlock();
- return false;
+ return JNI_FALSE;
}
ssize_t bytesCount = buffer->getStride() * bytesPerPixel(buffer->getPixelFormat());
@@ -213,21 +224,23 @@
int(rect.left), int(rect.top), int(rect.right), int(rect.bottom));
}
- return true;
+ return JNI_TRUE;
}
static jboolean android_view_GraphicBuffer_unlockCanvasAndPost(JNIEnv* env, jobject,
- GraphicBufferWrapper* wrapper, jobject canvas) {
+ jlong wrapperHandle, jobject canvas) {
+ GraphicBufferWrapper* wrapper =
+ reinterpret_cast<GraphicBufferWrapper*>(wrapperHandle);
SkCanvas* nativeCanvas = SkNEW(SkCanvas);
swapCanvasPtr(env, canvas, nativeCanvas);
if (wrapper) {
status_t status = wrapper->buffer->unlock();
- return status == 0;
+ return status == 0 ? JNI_TRUE : JNI_FALSE;
}
- return false;
+ return JNI_FALSE;
}
// ----------------------------------------------------------------------------
@@ -235,21 +248,23 @@
// ----------------------------------------------------------------------------
static void android_view_GraphiceBuffer_write(JNIEnv* env, jobject clazz,
- GraphicBufferWrapper* wrapper, jobject dest) {
+ jlong wrapperHandle, jobject dest) {
+ GraphicBufferWrapper* wrapper =
+ reinterpret_cast<GraphicBufferWrapper*>(wrapperHandle);
Parcel* parcel = parcelForJavaObject(env, dest);
if (parcel) {
parcel->write(*wrapper->buffer);
}
}
-static GraphicBufferWrapper* android_view_GraphiceBuffer_read(JNIEnv* env, jobject clazz,
+static jlong android_view_GraphiceBuffer_read(JNIEnv* env, jobject clazz,
jobject in) {
Parcel* parcel = parcelForJavaObject(env, in);
if (parcel) {
sp<GraphicBuffer> buffer = new GraphicBuffer();
parcel->read(*buffer);
- return new GraphicBufferWrapper(buffer);
+ return reinterpret_cast<jlong>(new GraphicBufferWrapper(buffer));
}
return NULL;
@@ -261,7 +276,7 @@
sp<GraphicBuffer> graphicBufferForJavaObject(JNIEnv* env, jobject obj) {
if (obj) {
- jint nativeObject = env->GetIntField(obj, gGraphicBufferClassInfo.mNativeObject);
+ jlong nativeObject = env->GetLongField(obj, gGraphicBufferClassInfo.mNativeObject);
GraphicBufferWrapper* wrapper = (GraphicBufferWrapper*) nativeObject;
if (wrapper != NULL) {
sp<GraphicBuffer> buffer(wrapper->buffer);
@@ -290,24 +305,24 @@
const char* const kClassPathName = "android/view/GraphicBuffer";
static JNINativeMethod gMethods[] = {
- { "nCreateGraphicBuffer", "(IIII)I", (void*) android_view_GraphiceBuffer_create },
- { "nDestroyGraphicBuffer", "(I)V", (void*) android_view_GraphiceBuffer_destroy },
+ { "nCreateGraphicBuffer", "(IIII)J", (void*) android_view_GraphiceBuffer_create },
+ { "nDestroyGraphicBuffer", "(J)V", (void*) android_view_GraphiceBuffer_destroy },
- { "nWriteGraphicBufferToParcel", "(ILandroid/os/Parcel;)V",
+ { "nWriteGraphicBufferToParcel", "(JLandroid/os/Parcel;)V",
(void*) android_view_GraphiceBuffer_write },
- { "nReadGraphicBufferFromParcel", "(Landroid/os/Parcel;)I",
+ { "nReadGraphicBufferFromParcel", "(Landroid/os/Parcel;)J",
(void*) android_view_GraphiceBuffer_read },
- { "nLockCanvas", "(ILandroid/graphics/Canvas;Landroid/graphics/Rect;)Z",
+ { "nLockCanvas", "(JLandroid/graphics/Canvas;Landroid/graphics/Rect;)Z",
(void*) android_view_GraphicBuffer_lockCanvas },
- { "nUnlockCanvasAndPost", "(ILandroid/graphics/Canvas;)Z",
+ { "nUnlockCanvasAndPost", "(JLandroid/graphics/Canvas;)Z",
(void*) android_view_GraphicBuffer_unlockCanvasAndPost },
};
int register_android_view_GraphicBuffer(JNIEnv* env) {
jclass clazz;
FIND_CLASS(clazz, "android/view/GraphicBuffer");
- GET_FIELD_ID(gGraphicBufferClassInfo.mNativeObject, clazz, "mNativeObject", "I");
+ GET_FIELD_ID(gGraphicBufferClassInfo.mNativeObject, clazz, "mNativeObject", "J");
FIND_CLASS(clazz, "android/graphics/Rect");
GET_METHOD_ID(gRectClassInfo.set, clazz, "set", "(IIII)V");
@@ -319,11 +334,11 @@
FIND_CLASS(clazz, "android/graphics/Canvas");
GET_FIELD_ID(gCanvasClassInfo.mFinalizer, clazz, "mFinalizer",
"Landroid/graphics/Canvas$CanvasFinalizer;");
- GET_FIELD_ID(gCanvasClassInfo.mNativeCanvas, clazz, "mNativeCanvas", "I");
+ GET_FIELD_ID(gCanvasClassInfo.mNativeCanvas, clazz, "mNativeCanvas", "J");
GET_FIELD_ID(gCanvasClassInfo.mSurfaceFormat, clazz, "mSurfaceFormat", "I");
FIND_CLASS(clazz, "android/graphics/Canvas$CanvasFinalizer");
- GET_FIELD_ID(gCanvasFinalizerClassInfo.mNativeCanvas, clazz, "mNativeCanvas", "I");
+ GET_FIELD_ID(gCanvasFinalizerClassInfo.mNativeCanvas, clazz, "mNativeCanvas", "J");
return AndroidRuntime::registerNativeMethods(env, kClassPathName, gMethods, NELEM(gMethods));
}
diff --git a/core/jni/android_view_InputChannel.cpp b/core/jni/android_view_InputChannel.cpp
index ce475e0..d667920 100644
--- a/core/jni/android_view_InputChannel.cpp
+++ b/core/jni/android_view_InputChannel.cpp
@@ -81,14 +81,14 @@
static NativeInputChannel* android_view_InputChannel_getNativeInputChannel(JNIEnv* env,
jobject inputChannelObj) {
- jint intPtr = env->GetIntField(inputChannelObj, gInputChannelClassInfo.mPtr);
- return reinterpret_cast<NativeInputChannel*>(intPtr);
+ jlong longPtr = env->GetLongField(inputChannelObj, gInputChannelClassInfo.mPtr);
+ return reinterpret_cast<NativeInputChannel*>(longPtr);
}
static void android_view_InputChannel_setNativeInputChannel(JNIEnv* env, jobject inputChannelObj,
NativeInputChannel* nativeInputChannel) {
- env->SetIntField(inputChannelObj, gInputChannelClassInfo.mPtr,
- reinterpret_cast<jint>(nativeInputChannel));
+ env->SetLongField(inputChannelObj, gInputChannelClassInfo.mPtr,
+ reinterpret_cast<jlong>(nativeInputChannel));
}
sp<InputChannel> android_view_InputChannel_getInputChannel(JNIEnv* env, jobject inputChannelObj) {
@@ -296,7 +296,7 @@
FIND_CLASS(gInputChannelClassInfo.clazz, "android/view/InputChannel");
GET_FIELD_ID(gInputChannelClassInfo.mPtr, gInputChannelClassInfo.clazz,
- "mPtr", "I");
+ "mPtr", "J");
GET_METHOD_ID(gInputChannelClassInfo.ctor, gInputChannelClassInfo.clazz,
"<init>", "()V");
diff --git a/core/jni/android_view_InputEventReceiver.cpp b/core/jni/android_view_InputEventReceiver.cpp
index 92a3e62..f36bf31 100644
--- a/core/jni/android_view_InputEventReceiver.cpp
+++ b/core/jni/android_view_InputEventReceiver.cpp
@@ -330,7 +330,7 @@
}
-static jint nativeInit(JNIEnv* env, jclass clazz, jobject receiverWeak,
+static jlong nativeInit(JNIEnv* env, jclass clazz, jobject receiverWeak,
jobject inputChannelObj, jobject messageQueueObj) {
sp<InputChannel> inputChannel = android_view_InputChannel_getInputChannel(env,
inputChannelObj);
@@ -356,17 +356,17 @@
}
receiver->incStrong(gInputEventReceiverClassInfo.clazz); // retain a reference for the object
- return reinterpret_cast<jint>(receiver.get());
+ return reinterpret_cast<jlong>(receiver.get());
}
-static void nativeDispose(JNIEnv* env, jclass clazz, jint receiverPtr) {
+static void nativeDispose(JNIEnv* env, jclass clazz, jlong receiverPtr) {
sp<NativeInputEventReceiver> receiver =
reinterpret_cast<NativeInputEventReceiver*>(receiverPtr);
receiver->dispose();
receiver->decStrong(gInputEventReceiverClassInfo.clazz); // drop reference held by the object
}
-static void nativeFinishInputEvent(JNIEnv* env, jclass clazz, jint receiverPtr,
+static void nativeFinishInputEvent(JNIEnv* env, jclass clazz, jlong receiverPtr,
jint seq, jboolean handled) {
sp<NativeInputEventReceiver> receiver =
reinterpret_cast<NativeInputEventReceiver*>(receiverPtr);
@@ -378,7 +378,7 @@
}
}
-static bool nativeConsumeBatchedInputEvents(JNIEnv* env, jclass clazz, jint receiverPtr,
+static jboolean nativeConsumeBatchedInputEvents(JNIEnv* env, jclass clazz, jlong receiverPtr,
jlong frameTimeNanos) {
sp<NativeInputEventReceiver> receiver =
reinterpret_cast<NativeInputEventReceiver*>(receiverPtr);
@@ -389,22 +389,22 @@
String8 message;
message.appendFormat("Failed to consume batched input event. status=%d", status);
jniThrowRuntimeException(env, message.string());
- return false;
+ return JNI_FALSE;
}
- return consumedBatch;
+ return consumedBatch ? JNI_TRUE : JNI_FALSE;
}
static JNINativeMethod gMethods[] = {
/* name, signature, funcPtr */
{ "nativeInit",
- "(Ljava/lang/ref/WeakReference;Landroid/view/InputChannel;Landroid/os/MessageQueue;)I",
+ "(Ljava/lang/ref/WeakReference;Landroid/view/InputChannel;Landroid/os/MessageQueue;)J",
(void*)nativeInit },
- { "nativeDispose", "(I)V",
+ { "nativeDispose", "(J)V",
(void*)nativeDispose },
- { "nativeFinishInputEvent", "(IIZ)V",
+ { "nativeFinishInputEvent", "(JIZ)V",
(void*)nativeFinishInputEvent },
- { "nativeConsumeBatchedInputEvents", "(IJ)Z",
+ { "nativeConsumeBatchedInputEvents", "(JJ)Z",
(void*)nativeConsumeBatchedInputEvents },
};
diff --git a/core/jni/android_view_InputEventSender.cpp b/core/jni/android_view_InputEventSender.cpp
index e4b65a1..f156b9a 100644
--- a/core/jni/android_view_InputEventSender.cpp
+++ b/core/jni/android_view_InputEventSender.cpp
@@ -230,7 +230,7 @@
}
-static jint nativeInit(JNIEnv* env, jclass clazz, jobject senderWeak,
+static jlong nativeInit(JNIEnv* env, jclass clazz, jobject senderWeak,
jobject inputChannelObj, jobject messageQueueObj) {
sp<InputChannel> inputChannel = android_view_InputChannel_getInputChannel(env,
inputChannelObj);
@@ -256,17 +256,17 @@
}
sender->incStrong(gInputEventSenderClassInfo.clazz); // retain a reference for the object
- return reinterpret_cast<jint>(sender.get());
+ return reinterpret_cast<jlong>(sender.get());
}
-static void nativeDispose(JNIEnv* env, jclass clazz, jint senderPtr) {
+static void nativeDispose(JNIEnv* env, jclass clazz, jlong senderPtr) {
sp<NativeInputEventSender> sender =
reinterpret_cast<NativeInputEventSender*>(senderPtr);
sender->dispose();
sender->decStrong(gInputEventSenderClassInfo.clazz); // drop reference held by the object
}
-static jboolean nativeSendKeyEvent(JNIEnv* env, jclass clazz, jint senderPtr,
+static jboolean nativeSendKeyEvent(JNIEnv* env, jclass clazz, jlong senderPtr,
jint seq, jobject eventObj) {
sp<NativeInputEventSender> sender =
reinterpret_cast<NativeInputEventSender*>(senderPtr);
@@ -276,7 +276,7 @@
return !status;
}
-static jboolean nativeSendMotionEvent(JNIEnv* env, jclass clazz, jint senderPtr,
+static jboolean nativeSendMotionEvent(JNIEnv* env, jclass clazz, jlong senderPtr,
jint seq, jobject eventObj) {
sp<NativeInputEventSender> sender =
reinterpret_cast<NativeInputEventSender*>(senderPtr);
@@ -289,13 +289,13 @@
static JNINativeMethod gMethods[] = {
/* name, signature, funcPtr */
{ "nativeInit",
- "(Ljava/lang/ref/WeakReference;Landroid/view/InputChannel;Landroid/os/MessageQueue;)I",
+ "(Ljava/lang/ref/WeakReference;Landroid/view/InputChannel;Landroid/os/MessageQueue;)J",
(void*)nativeInit },
- { "nativeDispose", "(I)V",
+ { "nativeDispose", "(J)V",
(void*)nativeDispose },
- { "nativeSendKeyEvent", "(IILandroid/view/KeyEvent;)Z",
+ { "nativeSendKeyEvent", "(JILandroid/view/KeyEvent;)Z",
(void*)nativeSendKeyEvent },
- { "nativeSendMotionEvent", "(IILandroid/view/MotionEvent;)Z",
+ { "nativeSendMotionEvent", "(JILandroid/view/MotionEvent;)Z",
(void*)nativeSendMotionEvent },
};
diff --git a/core/jni/android_view_InputQueue.cpp b/core/jni/android_view_InputQueue.cpp
index 7532c9d..21b73b1 100644
--- a/core/jni/android_view_InputQueue.cpp
+++ b/core/jni/android_view_InputQueue.cpp
@@ -151,7 +151,7 @@
mFinishedEvents.removeAt(0);
}
env->CallVoidMethod(inputQueueObj.get(), gInputQueueClassInfo.finishInputEvent,
- reinterpret_cast<jint>(event), handled);
+ reinterpret_cast<jlong>(event), handled);
recycleInputEvent(event);
}
break;
@@ -193,7 +193,7 @@
return new InputQueue(inputQueueObj, looper, pipeFds[0], pipeFds[1]);
}
-static jint nativeInit(JNIEnv* env, jobject clazz, jobject queueWeak, jobject jMsgQueue) {
+static jlong nativeInit(JNIEnv* env, jobject clazz, jobject queueWeak, jobject jMsgQueue) {
sp<MessageQueue> messageQueue = android_os_MessageQueue_getMessageQueue(env, jMsgQueue);
if (messageQueue == NULL) {
jniThrowRuntimeException(env, "MessageQueue is not initialized.");
@@ -205,16 +205,16 @@
return 0;
}
queue->incStrong(&gInputQueueClassInfo);
- return reinterpret_cast<jint>(queue.get());
+ return reinterpret_cast<jlong>(queue.get());
}
-static void nativeDispose(JNIEnv* env, jobject clazz, jint ptr) {
+static void nativeDispose(JNIEnv* env, jobject clazz, jlong ptr) {
sp<InputQueue> queue = reinterpret_cast<InputQueue*>(ptr);
queue->detachLooper();
queue->decStrong(&gInputQueueClassInfo);
}
-static jint nativeSendKeyEvent(JNIEnv* env, jobject clazz, jint ptr, jobject eventObj,
+static jlong nativeSendKeyEvent(JNIEnv* env, jobject clazz, jlong ptr, jobject eventObj,
jboolean predispatch) {
InputQueue* queue = reinterpret_cast<InputQueue*>(ptr);
KeyEvent* event = queue->createKeyEvent();
@@ -230,10 +230,10 @@
}
queue->enqueueEvent(event);
- return reinterpret_cast<jint>(event);
+ return reinterpret_cast<jlong>(event);
}
-static jint nativeSendMotionEvent(JNIEnv* env, jobject clazz, jint ptr, jobject eventObj) {
+static jlong nativeSendMotionEvent(JNIEnv* env, jobject clazz, jlong ptr, jobject eventObj) {
sp<InputQueue> queue = reinterpret_cast<InputQueue*>(ptr);
MotionEvent* originalEvent = android_view_MotionEvent_getNativePtr(env, eventObj);
if (!originalEvent) {
@@ -243,15 +243,15 @@
MotionEvent* event = queue->createMotionEvent();
event->copyFrom(originalEvent, true /* keepHistory */);
queue->enqueueEvent(event);
- return reinterpret_cast<jint>(event);
+ return reinterpret_cast<jlong>(event);
}
static const JNINativeMethod g_methods[] = {
- { "nativeInit", "(Ljava/lang/ref/WeakReference;Landroid/os/MessageQueue;)I",
+ { "nativeInit", "(Ljava/lang/ref/WeakReference;Landroid/os/MessageQueue;)J",
(void*) nativeInit },
- { "nativeDispose", "(I)V", (void*) nativeDispose },
- { "nativeSendKeyEvent", "(ILandroid/view/KeyEvent;Z)I", (void*) nativeSendKeyEvent },
- { "nativeSendMotionEvent", "(ILandroid/view/MotionEvent;)I", (void*) nativeSendMotionEvent },
+ { "nativeDispose", "(J)V", (void*) nativeDispose },
+ { "nativeSendKeyEvent", "(JLandroid/view/KeyEvent;Z)J", (void*) nativeSendKeyEvent },
+ { "nativeSendMotionEvent", "(JLandroid/view/MotionEvent;)J", (void*) nativeSendMotionEvent },
};
static const char* const kInputQueuePathName = "android/view/InputQueue";
@@ -272,7 +272,7 @@
{
jclass clazz;
FIND_CLASS(clazz, kInputQueuePathName);
- GET_METHOD_ID(gInputQueueClassInfo.finishInputEvent, clazz, "finishInputEvent", "(IZ)V");
+ GET_METHOD_ID(gInputQueueClassInfo.finishInputEvent, clazz, "finishInputEvent", "(JZ)V");
return AndroidRuntime::registerNativeMethods(
env, kInputQueuePathName,
diff --git a/core/jni/android_view_KeyCharacterMap.cpp b/core/jni/android_view_KeyCharacterMap.cpp
index ffe2dea..62d5129 100644
--- a/core/jni/android_view_KeyCharacterMap.cpp
+++ b/core/jni/android_view_KeyCharacterMap.cpp
@@ -75,10 +75,10 @@
}
return env->NewObject(gKeyCharacterMapClassInfo.clazz, gKeyCharacterMapClassInfo.ctor,
- reinterpret_cast<jint>(map));
+ reinterpret_cast<jlong>(map));
}
-static jint nativeReadFromParcel(JNIEnv *env, jobject clazz, jobject parcelObj) {
+static jlong nativeReadFromParcel(JNIEnv *env, jobject clazz, jobject parcelObj) {
Parcel* parcel = parcelForJavaObject(env, parcelObj);
if (!parcel) {
return 0;
@@ -95,10 +95,10 @@
}
NativeKeyCharacterMap* map = new NativeKeyCharacterMap(deviceId, kcm);
- return reinterpret_cast<jint>(map);
+ return reinterpret_cast<jlong>(map);
}
-static void nativeWriteToParcel(JNIEnv* env, jobject clazz, jint ptr, jobject parcelObj) {
+static void nativeWriteToParcel(JNIEnv* env, jobject clazz, jlong ptr, jobject parcelObj) {
NativeKeyCharacterMap* map = reinterpret_cast<NativeKeyCharacterMap*>(ptr);
Parcel* parcel = parcelForJavaObject(env, parcelObj);
if (parcel) {
@@ -107,18 +107,18 @@
}
}
-static void nativeDispose(JNIEnv *env, jobject clazz, jint ptr) {
+static void nativeDispose(JNIEnv *env, jobject clazz, jlong ptr) {
NativeKeyCharacterMap* map = reinterpret_cast<NativeKeyCharacterMap*>(ptr);
delete map;
}
-static jchar nativeGetCharacter(JNIEnv *env, jobject clazz, jint ptr,
+static jchar nativeGetCharacter(JNIEnv *env, jobject clazz, jlong ptr,
jint keyCode, jint metaState) {
NativeKeyCharacterMap* map = reinterpret_cast<NativeKeyCharacterMap*>(ptr);
return map->getMap()->getCharacter(keyCode, metaState);
}
-static jboolean nativeGetFallbackAction(JNIEnv *env, jobject clazz, jint ptr, jint keyCode,
+static jboolean nativeGetFallbackAction(JNIEnv *env, jobject clazz, jlong ptr, jint keyCode,
jint metaState, jobject fallbackActionObj) {
NativeKeyCharacterMap* map = reinterpret_cast<NativeKeyCharacterMap*>(ptr);
KeyCharacterMap::FallbackAction fallbackAction;
@@ -133,12 +133,12 @@
return result;
}
-static jchar nativeGetNumber(JNIEnv *env, jobject clazz, jint ptr, jint keyCode) {
+static jchar nativeGetNumber(JNIEnv *env, jobject clazz, jlong ptr, jint keyCode) {
NativeKeyCharacterMap* map = reinterpret_cast<NativeKeyCharacterMap*>(ptr);
return map->getMap()->getNumber(keyCode);
}
-static jchar nativeGetMatch(JNIEnv *env, jobject clazz, jint ptr, jint keyCode,
+static jchar nativeGetMatch(JNIEnv *env, jobject clazz, jlong ptr, jint keyCode,
jcharArray charsArray, jint metaState) {
NativeKeyCharacterMap* map = reinterpret_cast<NativeKeyCharacterMap*>(ptr);
@@ -154,17 +154,17 @@
return result;
}
-static jchar nativeGetDisplayLabel(JNIEnv *env, jobject clazz, jint ptr, jint keyCode) {
+static jchar nativeGetDisplayLabel(JNIEnv *env, jobject clazz, jlong ptr, jint keyCode) {
NativeKeyCharacterMap* map = reinterpret_cast<NativeKeyCharacterMap*>(ptr);
return map->getMap()->getDisplayLabel(keyCode);
}
-static jint nativeGetKeyboardType(JNIEnv *env, jobject clazz, jint ptr) {
+static jint nativeGetKeyboardType(JNIEnv *env, jobject clazz, jlong ptr) {
NativeKeyCharacterMap* map = reinterpret_cast<NativeKeyCharacterMap*>(ptr);
return map->getMap()->getKeyboardType();
}
-static jobjectArray nativeGetEvents(JNIEnv *env, jobject clazz, jint ptr,
+static jobjectArray nativeGetEvents(JNIEnv *env, jobject clazz, jlong ptr,
jcharArray charsArray) {
NativeKeyCharacterMap* map = reinterpret_cast<NativeKeyCharacterMap*>(ptr);
@@ -199,25 +199,25 @@
static JNINativeMethod g_methods[] = {
/* name, signature, funcPtr */
- { "nativeReadFromParcel", "(Landroid/os/Parcel;)I",
+ { "nativeReadFromParcel", "(Landroid/os/Parcel;)J",
(void*)nativeReadFromParcel },
- { "nativeWriteToParcel", "(ILandroid/os/Parcel;)V",
+ { "nativeWriteToParcel", "(JLandroid/os/Parcel;)V",
(void*)nativeWriteToParcel },
- { "nativeDispose", "(I)V",
+ { "nativeDispose", "(J)V",
(void*)nativeDispose },
- { "nativeGetCharacter", "(III)C",
+ { "nativeGetCharacter", "(JII)C",
(void*)nativeGetCharacter },
- { "nativeGetFallbackAction", "(IIILandroid/view/KeyCharacterMap$FallbackAction;)Z",
+ { "nativeGetFallbackAction", "(JIILandroid/view/KeyCharacterMap$FallbackAction;)Z",
(void*)nativeGetFallbackAction },
- { "nativeGetNumber", "(II)C",
+ { "nativeGetNumber", "(JI)C",
(void*)nativeGetNumber },
- { "nativeGetMatch", "(II[CI)C",
+ { "nativeGetMatch", "(JI[CI)C",
(void*)nativeGetMatch },
- { "nativeGetDisplayLabel", "(II)C",
+ { "nativeGetDisplayLabel", "(JI)C",
(void*)nativeGetDisplayLabel },
- { "nativeGetKeyboardType", "(I)I",
+ { "nativeGetKeyboardType", "(J)I",
(void*)nativeGetKeyboardType },
- { "nativeGetEvents", "(I[C)[Landroid/view/KeyEvent;",
+ { "nativeGetEvents", "(J[C)[Landroid/view/KeyEvent;",
(void*)nativeGetEvents },
};
@@ -239,7 +239,7 @@
gKeyCharacterMapClassInfo.clazz = jclass(env->NewGlobalRef(gKeyCharacterMapClassInfo.clazz));
GET_METHOD_ID(gKeyCharacterMapClassInfo.ctor, gKeyCharacterMapClassInfo.clazz,
- "<init>", "(I)V");
+ "<init>", "(J)V");
FIND_CLASS(gKeyEventClassInfo.clazz, "android/view/KeyEvent");
gKeyEventClassInfo.clazz = jclass(env->NewGlobalRef(gKeyEventClassInfo.clazz));
diff --git a/core/jni/android_view_MotionEvent.cpp b/core/jni/android_view_MotionEvent.cpp
index f1b90e1..76e145b 100644
--- a/core/jni/android_view_MotionEvent.cpp
+++ b/core/jni/android_view_MotionEvent.cpp
@@ -67,13 +67,13 @@
return NULL;
}
return reinterpret_cast<MotionEvent*>(
- env->GetIntField(eventObj, gMotionEventClassInfo.mNativePtr));
+ env->GetLongField(eventObj, gMotionEventClassInfo.mNativePtr));
}
static void android_view_MotionEvent_setNativePtr(JNIEnv* env, jobject eventObj,
MotionEvent* event) {
- env->SetIntField(eventObj, gMotionEventClassInfo.mNativePtr,
- reinterpret_cast<int>(event));
+ env->SetLongField(eventObj, gMotionEventClassInfo.mNativePtr,
+ reinterpret_cast<jlong>(event));
}
jobject android_view_MotionEvent_obtainAsCopy(JNIEnv* env, const MotionEvent* event) {
@@ -334,8 +334,8 @@
// ----------------------------------------------------------------------------
-static jint android_view_MotionEvent_nativeInitialize(JNIEnv* env, jclass clazz,
- jint nativePtr,
+static jlong android_view_MotionEvent_nativeInitialize(JNIEnv* env, jclass clazz,
+ jlong nativePtr,
jint deviceId, jint source, jint action, jint flags, jint edgeFlags,
jint metaState, jint buttonState,
jfloat xOffset, jfloat yOffset, jfloat xPrecision, jfloat yPrecision,
@@ -377,7 +377,7 @@
xOffset, yOffset, xPrecision, yPrecision,
downTimeNanos, eventTimeNanos, pointerCount, pointerProperties, rawPointerCoords);
- return reinterpret_cast<jint>(event);
+ return reinterpret_cast<jlong>(event);
Error:
if (!nativePtr) {
@@ -386,25 +386,25 @@
return 0;
}
-static jint android_view_MotionEvent_nativeCopy(JNIEnv* env, jclass clazz,
- jint destNativePtr, jint sourceNativePtr, jboolean keepHistory) {
+static jlong android_view_MotionEvent_nativeCopy(JNIEnv* env, jclass clazz,
+ jlong destNativePtr, jlong sourceNativePtr, jboolean keepHistory) {
MotionEvent* destEvent = reinterpret_cast<MotionEvent*>(destNativePtr);
if (!destEvent) {
destEvent = new MotionEvent();
}
MotionEvent* sourceEvent = reinterpret_cast<MotionEvent*>(sourceNativePtr);
destEvent->copyFrom(sourceEvent, keepHistory);
- return reinterpret_cast<jint>(destEvent);
+ return reinterpret_cast<jlong>(destEvent);
}
static void android_view_MotionEvent_nativeDispose(JNIEnv* env, jclass clazz,
- jint nativePtr) {
+ jlong nativePtr) {
MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr);
delete event;
}
static void android_view_MotionEvent_nativeAddBatch(JNIEnv* env, jclass clazz,
- jint nativePtr, jlong eventTimeNanos, jobjectArray pointerCoordsObjArray,
+ jlong nativePtr, jlong eventTimeNanos, jobjectArray pointerCoordsObjArray,
jint metaState) {
MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr);
size_t pointerCount = event->getPointerCount();
@@ -430,127 +430,127 @@
}
static jint android_view_MotionEvent_nativeGetDeviceId(JNIEnv* env, jclass clazz,
- jint nativePtr) {
+ jlong nativePtr) {
MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr);
return event->getDeviceId();
}
static jint android_view_MotionEvent_nativeGetSource(JNIEnv* env, jclass clazz,
- jint nativePtr) {
+ jlong nativePtr) {
MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr);
return event->getSource();
}
static void android_view_MotionEvent_nativeSetSource(JNIEnv* env, jclass clazz,
- jint nativePtr, jint source) {
+ jlong nativePtr, jint source) {
MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr);
event->setSource(source);
}
static jint android_view_MotionEvent_nativeGetAction(JNIEnv* env, jclass clazz,
- jint nativePtr) {
+ jlong nativePtr) {
MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr);
return event->getAction();
}
static void android_view_MotionEvent_nativeSetAction(JNIEnv* env, jclass clazz,
- jint nativePtr, jint action) {
+ jlong nativePtr, jint action) {
MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr);
event->setAction(action);
}
static jboolean android_view_MotionEvent_nativeIsTouchEvent(JNIEnv* env, jclass clazz,
- jint nativePtr) {
+ jlong nativePtr) {
MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr);
return event->isTouchEvent();
}
static jint android_view_MotionEvent_nativeGetFlags(JNIEnv* env, jclass clazz,
- jint nativePtr) {
+ jlong nativePtr) {
MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr);
return event->getFlags();
}
static void android_view_MotionEvent_nativeSetFlags(JNIEnv* env, jclass clazz,
- jint nativePtr, jint flags) {
+ jlong nativePtr, jint flags) {
MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr);
event->setFlags(flags);
}
static jint android_view_MotionEvent_nativeGetEdgeFlags(JNIEnv* env, jclass clazz,
- jint nativePtr) {
+ jlong nativePtr) {
MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr);
return event->getEdgeFlags();
}
static void android_view_MotionEvent_nativeSetEdgeFlags(JNIEnv* env, jclass clazz,
- jint nativePtr, jint edgeFlags) {
+ jlong nativePtr, jint edgeFlags) {
MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr);
event->setEdgeFlags(edgeFlags);
}
static jint android_view_MotionEvent_nativeGetMetaState(JNIEnv* env, jclass clazz,
- jint nativePtr) {
+ jlong nativePtr) {
MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr);
return event->getMetaState();
}
static jint android_view_MotionEvent_nativeGetButtonState(JNIEnv* env, jclass clazz,
- jint nativePtr) {
+ jlong nativePtr) {
MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr);
return event->getButtonState();
}
static void android_view_MotionEvent_nativeOffsetLocation(JNIEnv* env, jclass clazz,
- jint nativePtr, jfloat deltaX, jfloat deltaY) {
+ jlong nativePtr, jfloat deltaX, jfloat deltaY) {
MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr);
return event->offsetLocation(deltaX, deltaY);
}
static jfloat android_view_MotionEvent_nativeGetXOffset(JNIEnv* env, jclass clazz,
- jint nativePtr) {
+ jlong nativePtr) {
MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr);
return event->getXOffset();
}
static jfloat android_view_MotionEvent_nativeGetYOffset(JNIEnv* env, jclass clazz,
- jint nativePtr) {
+ jlong nativePtr) {
MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr);
return event->getYOffset();
}
static jfloat android_view_MotionEvent_nativeGetXPrecision(JNIEnv* env, jclass clazz,
- jint nativePtr) {
+ jlong nativePtr) {
MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr);
return event->getXPrecision();
}
static jfloat android_view_MotionEvent_nativeGetYPrecision(JNIEnv* env, jclass clazz,
- jint nativePtr) {
+ jlong nativePtr) {
MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr);
return event->getYPrecision();
}
static jlong android_view_MotionEvent_nativeGetDownTimeNanos(JNIEnv* env, jclass clazz,
- jint nativePtr) {
+ jlong nativePtr) {
MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr);
return event->getDownTime();
}
static void android_view_MotionEvent_nativeSetDownTimeNanos(JNIEnv* env, jclass clazz,
- jint nativePtr, jlong downTimeNanos) {
+ jlong nativePtr, jlong downTimeNanos) {
MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr);
event->setDownTime(downTimeNanos);
}
static jint android_view_MotionEvent_nativeGetPointerCount(JNIEnv* env, jclass clazz,
- jint nativePtr) {
+ jlong nativePtr) {
MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr);
return jint(event->getPointerCount());
}
static jint android_view_MotionEvent_nativeGetPointerId(JNIEnv* env, jclass clazz,
- jint nativePtr, jint pointerIndex) {
+ jlong nativePtr, jint pointerIndex) {
MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr);
size_t pointerCount = event->getPointerCount();
if (!validatePointerIndex(env, pointerIndex, pointerCount)) {
@@ -560,7 +560,7 @@
}
static jint android_view_MotionEvent_nativeGetToolType(JNIEnv* env, jclass clazz,
- jint nativePtr, jint pointerIndex) {
+ jlong nativePtr, jint pointerIndex) {
MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr);
size_t pointerCount = event->getPointerCount();
if (!validatePointerIndex(env, pointerIndex, pointerCount)) {
@@ -570,19 +570,19 @@
}
static jint android_view_MotionEvent_nativeFindPointerIndex(JNIEnv* env, jclass clazz,
- jint nativePtr, jint pointerId) {
+ jlong nativePtr, jint pointerId) {
MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr);
return jint(event->findPointerIndex(pointerId));
}
static jint android_view_MotionEvent_nativeGetHistorySize(JNIEnv* env, jclass clazz,
- jint nativePtr) {
+ jlong nativePtr) {
MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr);
return jint(event->getHistorySize());
}
static jlong android_view_MotionEvent_nativeGetEventTimeNanos(JNIEnv* env, jclass clazz,
- jint nativePtr, jint historyPos) {
+ jlong nativePtr, jint historyPos) {
MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr);
if (historyPos == HISTORY_CURRENT) {
return event->getEventTime();
@@ -596,7 +596,7 @@
}
static jfloat android_view_MotionEvent_nativeGetRawAxisValue(JNIEnv* env, jclass clazz,
- jint nativePtr, jint axis, jint pointerIndex, jint historyPos) {
+ jlong nativePtr, jint axis, jint pointerIndex, jint historyPos) {
MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr);
size_t pointerCount = event->getPointerCount();
if (!validatePointerIndex(env, pointerIndex, pointerCount)) {
@@ -615,7 +615,7 @@
}
static jfloat android_view_MotionEvent_nativeGetAxisValue(JNIEnv* env, jclass clazz,
- jint nativePtr, jint axis, jint pointerIndex, jint historyPos) {
+ jlong nativePtr, jint axis, jint pointerIndex, jint historyPos) {
MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr);
size_t pointerCount = event->getPointerCount();
if (!validatePointerIndex(env, pointerIndex, pointerCount)) {
@@ -634,7 +634,7 @@
}
static void android_view_MotionEvent_nativeGetPointerCoords(JNIEnv* env, jclass clazz,
- jint nativePtr, jint pointerIndex, jint historyPos, jobject outPointerCoordsObj) {
+ jlong nativePtr, jint pointerIndex, jint historyPos, jobject outPointerCoordsObj) {
MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr);
size_t pointerCount = event->getPointerCount();
if (!validatePointerIndex(env, pointerIndex, pointerCount)
@@ -657,7 +657,7 @@
}
static void android_view_MotionEvent_nativeGetPointerProperties(JNIEnv* env, jclass clazz,
- jint nativePtr, jint pointerIndex, jobject outPointerPropertiesObj) {
+ jlong nativePtr, jint pointerIndex, jobject outPointerPropertiesObj) {
MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr);
size_t pointerCount = event->getPointerCount();
if (!validatePointerIndex(env, pointerIndex, pointerCount)
@@ -670,13 +670,13 @@
}
static void android_view_MotionEvent_nativeScale(JNIEnv* env, jclass clazz,
- jint nativePtr, jfloat scale) {
+ jlong nativePtr, jfloat scale) {
MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr);
event->scale(scale);
}
static void android_view_MotionEvent_nativeTransform(JNIEnv* env, jclass clazz,
- jint nativePtr, jobject matrixObj) {
+ jlong nativePtr, jobject matrixObj) {
SkMatrix* matrix = android_graphics_Matrix_getSkMatrix(env, matrixObj);
MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr);
@@ -693,8 +693,8 @@
event->transform(m);
}
-static jint android_view_MotionEvent_nativeReadFromParcel(JNIEnv* env, jclass clazz,
- jint nativePtr, jobject parcelObj) {
+static jlong android_view_MotionEvent_nativeReadFromParcel(JNIEnv* env, jclass clazz,
+ jlong nativePtr, jobject parcelObj) {
MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr);
if (!event) {
event = new MotionEvent();
@@ -710,11 +710,11 @@
jniThrowRuntimeException(env, "Failed to read MotionEvent parcel.");
return 0;
}
- return reinterpret_cast<jint>(event);
+ return reinterpret_cast<jlong>(event);
}
static void android_view_MotionEvent_nativeWriteToParcel(JNIEnv* env, jclass clazz,
- jint nativePtr, jobject parcelObj) {
+ jlong nativePtr, jobject parcelObj) {
MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr);
Parcel* parcel = parcelForJavaObject(env, parcelObj);
@@ -729,116 +729,116 @@
static JNINativeMethod gMotionEventMethods[] = {
/* name, signature, funcPtr */
{ "nativeInitialize",
- "(IIIIIIIIFFFFJJI[Landroid/view/MotionEvent$PointerProperties;"
- "[Landroid/view/MotionEvent$PointerCoords;)I",
+ "(JIIIIIIIFFFFJJI[Landroid/view/MotionEvent$PointerProperties;"
+ "[Landroid/view/MotionEvent$PointerCoords;)J",
(void*)android_view_MotionEvent_nativeInitialize },
{ "nativeCopy",
- "(IIZ)I",
+ "(JJZ)J",
(void*)android_view_MotionEvent_nativeCopy },
{ "nativeDispose",
- "(I)V",
+ "(J)V",
(void*)android_view_MotionEvent_nativeDispose },
{ "nativeAddBatch",
- "(IJ[Landroid/view/MotionEvent$PointerCoords;I)V",
+ "(JJ[Landroid/view/MotionEvent$PointerCoords;I)V",
(void*)android_view_MotionEvent_nativeAddBatch },
{ "nativeGetDeviceId",
- "(I)I",
+ "(J)I",
(void*)android_view_MotionEvent_nativeGetDeviceId },
{ "nativeGetSource",
- "(I)I",
+ "(J)I",
(void*)android_view_MotionEvent_nativeGetSource },
{ "nativeSetSource",
- "(II)I",
+ "(JI)I",
(void*)android_view_MotionEvent_nativeSetSource },
{ "nativeGetAction",
- "(I)I",
+ "(J)I",
(void*)android_view_MotionEvent_nativeGetAction },
{ "nativeSetAction",
- "(II)V",
+ "(JI)V",
(void*)android_view_MotionEvent_nativeSetAction },
{ "nativeIsTouchEvent",
- "(I)Z",
+ "(J)Z",
(void*)android_view_MotionEvent_nativeIsTouchEvent },
{ "nativeGetFlags",
- "(I)I",
+ "(J)I",
(void*)android_view_MotionEvent_nativeGetFlags },
{ "nativeSetFlags",
- "(II)V",
+ "(JI)V",
(void*)android_view_MotionEvent_nativeSetFlags },
{ "nativeGetEdgeFlags",
- "(I)I",
+ "(J)I",
(void*)android_view_MotionEvent_nativeGetEdgeFlags },
{ "nativeSetEdgeFlags",
- "(II)V",
+ "(JI)V",
(void*)android_view_MotionEvent_nativeSetEdgeFlags },
{ "nativeGetMetaState",
- "(I)I",
+ "(J)I",
(void*)android_view_MotionEvent_nativeGetMetaState },
{ "nativeGetButtonState",
- "(I)I",
+ "(J)I",
(void*)android_view_MotionEvent_nativeGetButtonState },
{ "nativeOffsetLocation",
- "(IFF)V",
+ "(JFF)V",
(void*)android_view_MotionEvent_nativeOffsetLocation },
{ "nativeGetXOffset",
- "(I)F",
+ "(J)F",
(void*)android_view_MotionEvent_nativeGetXOffset },
{ "nativeGetYOffset",
- "(I)F",
+ "(J)F",
(void*)android_view_MotionEvent_nativeGetYOffset },
{ "nativeGetXPrecision",
- "(I)F",
+ "(J)F",
(void*)android_view_MotionEvent_nativeGetXPrecision },
{ "nativeGetYPrecision",
- "(I)F",
+ "(J)F",
(void*)android_view_MotionEvent_nativeGetYPrecision },
{ "nativeGetDownTimeNanos",
- "(I)J",
+ "(J)J",
(void*)android_view_MotionEvent_nativeGetDownTimeNanos },
{ "nativeSetDownTimeNanos",
- "(IJ)V",
+ "(JJ)V",
(void*)android_view_MotionEvent_nativeSetDownTimeNanos },
{ "nativeGetPointerCount",
- "(I)I",
+ "(J)I",
(void*)android_view_MotionEvent_nativeGetPointerCount },
{ "nativeGetPointerId",
- "(II)I",
+ "(JI)I",
(void*)android_view_MotionEvent_nativeGetPointerId },
{ "nativeGetToolType",
- "(II)I",
+ "(JI)I",
(void*)android_view_MotionEvent_nativeGetToolType },
{ "nativeFindPointerIndex",
- "(II)I",
+ "(JI)I",
(void*)android_view_MotionEvent_nativeFindPointerIndex },
{ "nativeGetHistorySize",
- "(I)I",
+ "(J)I",
(void*)android_view_MotionEvent_nativeGetHistorySize },
{ "nativeGetEventTimeNanos",
- "(II)J",
+ "(JI)J",
(void*)android_view_MotionEvent_nativeGetEventTimeNanos },
{ "nativeGetRawAxisValue",
- "(IIII)F",
+ "(JIII)F",
(void*)android_view_MotionEvent_nativeGetRawAxisValue },
{ "nativeGetAxisValue",
- "(IIII)F",
+ "(JIII)F",
(void*)android_view_MotionEvent_nativeGetAxisValue },
{ "nativeGetPointerCoords",
- "(IIILandroid/view/MotionEvent$PointerCoords;)V",
+ "(JIILandroid/view/MotionEvent$PointerCoords;)V",
(void*)android_view_MotionEvent_nativeGetPointerCoords },
{ "nativeGetPointerProperties",
- "(IILandroid/view/MotionEvent$PointerProperties;)V",
+ "(JILandroid/view/MotionEvent$PointerProperties;)V",
(void*)android_view_MotionEvent_nativeGetPointerProperties },
{ "nativeScale",
- "(IF)V",
+ "(JF)V",
(void*)android_view_MotionEvent_nativeScale },
{ "nativeTransform",
- "(ILandroid/graphics/Matrix;)V",
+ "(JLandroid/graphics/Matrix;)V",
(void*)android_view_MotionEvent_nativeTransform },
{ "nativeReadFromParcel",
- "(ILandroid/os/Parcel;)I",
+ "(JLandroid/os/Parcel;)J",
(void*)android_view_MotionEvent_nativeReadFromParcel },
{ "nativeWriteToParcel",
- "(ILandroid/os/Parcel;)V",
+ "(JLandroid/os/Parcel;)V",
(void*)android_view_MotionEvent_nativeWriteToParcel },
};
@@ -871,7 +871,7 @@
GET_METHOD_ID(gMotionEventClassInfo.recycle, gMotionEventClassInfo.clazz,
"recycle", "()V");
GET_FIELD_ID(gMotionEventClassInfo.mNativePtr, gMotionEventClassInfo.clazz,
- "mNativePtr", "I");
+ "mNativePtr", "J");
jclass clazz;
FIND_CLASS(clazz, "android/view/MotionEvent$PointerCoords");
diff --git a/core/jni/android_view_Surface.cpp b/core/jni/android_view_Surface.cpp
index 1868469..c2d4ec0 100644
--- a/core/jni/android_view_Surface.cpp
+++ b/core/jni/android_view_Surface.cpp
@@ -96,7 +96,7 @@
gSurfaceClassInfo.mLock);
if (env->MonitorEnter(lock) == JNI_OK) {
sur = reinterpret_cast<Surface *>(
- env->GetIntField(surfaceObj, gSurfaceClassInfo.mNativeObject));
+ env->GetLongField(surfaceObj, gSurfaceClassInfo.mNativeObject));
env->MonitorExit(lock);
}
return sur;
@@ -113,7 +113,8 @@
return NULL;
}
- jobject surfaceObj = env->NewObject(gSurfaceClassInfo.clazz, gSurfaceClassInfo.ctor, surface.get());
+ jobject surfaceObj = env->NewObject(gSurfaceClassInfo.clazz,
+ gSurfaceClassInfo.ctor, (jlong)surface.get());
if (surfaceObj == NULL) {
if (env->ExceptionCheck()) {
ALOGE("Could not create instance of Surface from IGraphicBufferProducer.");
@@ -134,7 +135,7 @@
// ----------------------------------------------------------------------------
-static jint nativeCreateFromSurfaceTexture(JNIEnv* env, jclass clazz,
+static jlong nativeCreateFromSurfaceTexture(JNIEnv* env, jclass clazz,
jobject surfaceTextureObj) {
sp<IGraphicBufferProducer> producer(SurfaceTexture_getProducer(env, surfaceTextureObj));
if (producer == NULL) {
@@ -150,20 +151,20 @@
}
surface->incStrong(&sRefBaseOwner);
- return int(surface.get());
+ return jlong(surface.get());
}
-static void nativeRelease(JNIEnv* env, jclass clazz, jint nativeObject) {
+static void nativeRelease(JNIEnv* env, jclass clazz, jlong nativeObject) {
sp<Surface> sur(reinterpret_cast<Surface *>(nativeObject));
sur->decStrong(&sRefBaseOwner);
}
-static jboolean nativeIsValid(JNIEnv* env, jclass clazz, jint nativeObject) {
+static jboolean nativeIsValid(JNIEnv* env, jclass clazz, jlong nativeObject) {
sp<Surface> sur(reinterpret_cast<Surface *>(nativeObject));
return isSurfaceValid(sur) ? JNI_TRUE : JNI_FALSE;
}
-static jboolean nativeIsConsumerRunningBehind(JNIEnv* env, jclass clazz, jint nativeObject) {
+static jboolean nativeIsConsumerRunningBehind(JNIEnv* env, jclass clazz, jlong nativeObject) {
sp<Surface> sur(reinterpret_cast<Surface *>(nativeObject));
if (!isSurfaceValid(sur)) {
doThrowIAE(env);
@@ -191,14 +192,14 @@
static inline void swapCanvasPtr(JNIEnv* env, jobject canvasObj, SkCanvas* newCanvas) {
jobject canvasFinalizerObj = env->GetObjectField(canvasObj, gCanvasClassInfo.mFinalizer);
SkCanvas* previousCanvas = reinterpret_cast<SkCanvas*>(
- env->GetIntField(canvasObj, gCanvasClassInfo.mNativeCanvas));
- env->SetIntField(canvasObj, gCanvasClassInfo.mNativeCanvas, (int)newCanvas);
- env->SetIntField(canvasFinalizerObj, gCanvasFinalizerClassInfo.mNativeCanvas, (int)newCanvas);
+ env->GetLongField(canvasObj, gCanvasClassInfo.mNativeCanvas));
+ env->SetLongField(canvasObj, gCanvasClassInfo.mNativeCanvas, (jlong)newCanvas);
+ env->SetLongField(canvasFinalizerObj, gCanvasFinalizerClassInfo.mNativeCanvas, (jlong)newCanvas);
SkSafeUnref(previousCanvas);
}
-static jint nativeLockCanvas(JNIEnv* env, jclass clazz,
- jint nativeObject, jobject canvasObj, jobject dirtyRectObj) {
+static jlong nativeLockCanvas(JNIEnv* env, jclass clazz,
+ jlong nativeObject, jobject canvasObj, jobject dirtyRectObj) {
sp<Surface> surface(reinterpret_cast<Surface *>(nativeObject));
if (!isSurfaceValid(surface)) {
@@ -262,11 +263,11 @@
// because the latter could be replaced while the surface is locked.
sp<Surface> lockedSurface(surface);
lockedSurface->incStrong(&sRefBaseOwner);
- return (int) lockedSurface.get();
+ return (jlong) lockedSurface.get();
}
static void nativeUnlockCanvasAndPost(JNIEnv* env, jclass clazz,
- jint nativeObject, jobject canvasObj) {
+ jlong nativeObject, jobject canvasObj) {
sp<Surface> surface(reinterpret_cast<Surface *>(nativeObject));
if (!isSurfaceValid(surface)) {
return;
@@ -285,8 +286,8 @@
// ----------------------------------------------------------------------------
-static jint nativeCreateFromSurfaceControl(JNIEnv* env, jclass clazz,
- jint surfaceControlNativeObj) {
+static jlong nativeCreateFromSurfaceControl(JNIEnv* env, jclass clazz,
+ jlong surfaceControlNativeObj) {
/*
* This is used by the WindowManagerService just after constructing
* a Surface and is necessary for returning the Surface reference to
@@ -298,11 +299,11 @@
if (surface != NULL) {
surface->incStrong(&sRefBaseOwner);
}
- return reinterpret_cast<jint>(surface.get());
+ return reinterpret_cast<jlong>(surface.get());
}
-static jint nativeReadFromParcel(JNIEnv* env, jclass clazz,
- jint nativeObject, jobject parcelObj) {
+static jlong nativeReadFromParcel(JNIEnv* env, jclass clazz,
+ jlong nativeObject, jobject parcelObj) {
Parcel* parcel = parcelForJavaObject(env, parcelObj);
if (parcel == NULL) {
doThrowNPE(env);
@@ -317,7 +318,7 @@
if (self != NULL
&& (self->getIGraphicBufferProducer()->asBinder() == binder)) {
// same IGraphicBufferProducer, return ourselves
- return int(self.get());
+ return jlong(self.get());
}
sp<Surface> sur;
@@ -334,11 +335,11 @@
self->decStrong(&sRefBaseOwner);
}
- return int(sur.get());
+ return jlong(sur.get());
}
static void nativeWriteToParcel(JNIEnv* env, jclass clazz,
- jint nativeObject, jobject parcelObj) {
+ jlong nativeObject, jobject parcelObj) {
Parcel* parcel = parcelForJavaObject(env, parcelObj);
if (parcel == NULL) {
doThrowNPE(env);
@@ -351,23 +352,23 @@
// ----------------------------------------------------------------------------
static JNINativeMethod gSurfaceMethods[] = {
- {"nativeCreateFromSurfaceTexture", "(Landroid/graphics/SurfaceTexture;)I",
+ {"nativeCreateFromSurfaceTexture", "(Landroid/graphics/SurfaceTexture;)J",
(void*)nativeCreateFromSurfaceTexture },
- {"nativeRelease", "(I)V",
+ {"nativeRelease", "(J)V",
(void*)nativeRelease },
- {"nativeIsValid", "(I)Z",
+ {"nativeIsValid", "(J)Z",
(void*)nativeIsValid },
- {"nativeIsConsumerRunningBehind", "(I)Z",
+ {"nativeIsConsumerRunningBehind", "(J)Z",
(void*)nativeIsConsumerRunningBehind },
- {"nativeLockCanvas", "(ILandroid/graphics/Canvas;Landroid/graphics/Rect;)I",
+ {"nativeLockCanvas", "(JLandroid/graphics/Canvas;Landroid/graphics/Rect;)J",
(void*)nativeLockCanvas },
- {"nativeUnlockCanvasAndPost", "(ILandroid/graphics/Canvas;)V",
+ {"nativeUnlockCanvasAndPost", "(JLandroid/graphics/Canvas;)V",
(void*)nativeUnlockCanvasAndPost },
- {"nativeCreateFromSurfaceControl", "(I)I",
+ {"nativeCreateFromSurfaceControl", "(J)J",
(void*)nativeCreateFromSurfaceControl },
- {"nativeReadFromParcel", "(ILandroid/os/Parcel;)I",
+ {"nativeReadFromParcel", "(JLandroid/os/Parcel;)J",
(void*)nativeReadFromParcel },
- {"nativeWriteToParcel", "(ILandroid/os/Parcel;)V",
+ {"nativeWriteToParcel", "(JLandroid/os/Parcel;)V",
(void*)nativeWriteToParcel },
};
@@ -379,18 +380,18 @@
jclass clazz = env->FindClass("android/view/Surface");
gSurfaceClassInfo.clazz = jclass(env->NewGlobalRef(clazz));
gSurfaceClassInfo.mNativeObject =
- env->GetFieldID(gSurfaceClassInfo.clazz, "mNativeObject", "I");
+ env->GetFieldID(gSurfaceClassInfo.clazz, "mNativeObject", "J");
gSurfaceClassInfo.mLock =
env->GetFieldID(gSurfaceClassInfo.clazz, "mLock", "Ljava/lang/Object;");
- gSurfaceClassInfo.ctor = env->GetMethodID(gSurfaceClassInfo.clazz, "<init>", "(I)V");
+ gSurfaceClassInfo.ctor = env->GetMethodID(gSurfaceClassInfo.clazz, "<init>", "(J)V");
clazz = env->FindClass("android/graphics/Canvas");
gCanvasClassInfo.mFinalizer = env->GetFieldID(clazz, "mFinalizer", "Landroid/graphics/Canvas$CanvasFinalizer;");
- gCanvasClassInfo.mNativeCanvas = env->GetFieldID(clazz, "mNativeCanvas", "I");
+ gCanvasClassInfo.mNativeCanvas = env->GetFieldID(clazz, "mNativeCanvas", "J");
gCanvasClassInfo.mSurfaceFormat = env->GetFieldID(clazz, "mSurfaceFormat", "I");
clazz = env->FindClass("android/graphics/Canvas$CanvasFinalizer");
- gCanvasFinalizerClassInfo.mNativeCanvas = env->GetFieldID(clazz, "mNativeCanvas", "I");
+ gCanvasFinalizerClassInfo.mNativeCanvas = env->GetFieldID(clazz, "mNativeCanvas", "J");
clazz = env->FindClass("android/graphics/Rect");
gRectClassInfo.left = env->GetFieldID(clazz, "left", "I");
diff --git a/core/jni/android_view_SurfaceControl.cpp b/core/jni/android_view_SurfaceControl.cpp
index 67eade8..bd53095 100644
--- a/core/jni/android_view_SurfaceControl.cpp
+++ b/core/jni/android_view_SurfaceControl.cpp
@@ -122,7 +122,7 @@
// ----------------------------------------------------------------------------
-static jint nativeCreate(JNIEnv* env, jclass clazz, jobject sessionObj,
+static jlong nativeCreate(JNIEnv* env, jclass clazz, jobject sessionObj,
jstring nameStr, jint w, jint h, jint format, jint flags) {
ScopedUtfChars name(env, nameStr);
sp<SurfaceComposerClient> client(android_view_SurfaceSession_getClient(env, sessionObj));
@@ -133,15 +133,15 @@
return 0;
}
surface->incStrong((void *)nativeCreate);
- return int(surface.get());
+ return reinterpret_cast<jlong>(surface.get());
}
-static void nativeRelease(JNIEnv* env, jclass clazz, jint nativeObject) {
+static void nativeRelease(JNIEnv* env, jclass clazz, jlong nativeObject) {
sp<SurfaceControl> ctrl(reinterpret_cast<SurfaceControl *>(nativeObject));
ctrl->decStrong((void *)nativeCreate);
}
-static void nativeDestroy(JNIEnv* env, jclass clazz, jint nativeObject) {
+static void nativeDestroy(JNIEnv* env, jclass clazz, jlong nativeObject) {
sp<SurfaceControl> ctrl(reinterpret_cast<SurfaceControl *>(nativeObject));
ctrl->clear();
ctrl->decStrong((void *)nativeCreate);
@@ -229,7 +229,7 @@
SurfaceComposerClient::setAnimationTransaction();
}
-static void nativeSetLayer(JNIEnv* env, jclass clazz, jint nativeObject, jint zorder) {
+static void nativeSetLayer(JNIEnv* env, jclass clazz, jlong nativeObject, jint zorder) {
SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
status_t err = ctrl->setLayer(zorder);
if (err < 0 && err != NO_INIT) {
@@ -237,7 +237,7 @@
}
}
-static void nativeSetPosition(JNIEnv* env, jclass clazz, jint nativeObject, jfloat x, jfloat y) {
+static void nativeSetPosition(JNIEnv* env, jclass clazz, jlong nativeObject, jfloat x, jfloat y) {
SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
status_t err = ctrl->setPosition(x, y);
if (err < 0 && err != NO_INIT) {
@@ -245,7 +245,7 @@
}
}
-static void nativeSetSize(JNIEnv* env, jclass clazz, jint nativeObject, jint w, jint h) {
+static void nativeSetSize(JNIEnv* env, jclass clazz, jlong nativeObject, jint w, jint h) {
SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
status_t err = ctrl->setSize(w, h);
if (err < 0 && err != NO_INIT) {
@@ -253,7 +253,7 @@
}
}
-static void nativeSetFlags(JNIEnv* env, jclass clazz, jint nativeObject, jint flags, jint mask) {
+static void nativeSetFlags(JNIEnv* env, jclass clazz, jlong nativeObject, jint flags, jint mask) {
SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
status_t err = ctrl->setFlags(flags, mask);
if (err < 0 && err != NO_INIT) {
@@ -261,7 +261,7 @@
}
}
-static void nativeSetTransparentRegionHint(JNIEnv* env, jclass clazz, jint nativeObject, jobject regionObj) {
+static void nativeSetTransparentRegionHint(JNIEnv* env, jclass clazz, jlong nativeObject, jobject regionObj) {
SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
SkRegion* region = android_graphics_Region_getSkRegion(env, regionObj);
if (!region) {
@@ -286,7 +286,7 @@
}
}
-static void nativeSetAlpha(JNIEnv* env, jclass clazz, jint nativeObject, jfloat alpha) {
+static void nativeSetAlpha(JNIEnv* env, jclass clazz, jlong nativeObject, jfloat alpha) {
SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
status_t err = ctrl->setAlpha(alpha);
if (err < 0 && err != NO_INIT) {
@@ -294,7 +294,7 @@
}
}
-static void nativeSetMatrix(JNIEnv* env, jclass clazz, jint nativeObject,
+static void nativeSetMatrix(JNIEnv* env, jclass clazz, jlong nativeObject,
jfloat dsdx, jfloat dtdx, jfloat dsdy, jfloat dtdy) {
SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
status_t err = ctrl->setMatrix(dsdx, dtdx, dsdy, dtdy);
@@ -303,7 +303,7 @@
}
}
-static void nativeSetWindowCrop(JNIEnv* env, jclass clazz, jint nativeObject,
+static void nativeSetWindowCrop(JNIEnv* env, jclass clazz, jlong nativeObject,
jint l, jint t, jint r, jint b) {
SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
Rect crop(l, t, r, b);
@@ -313,7 +313,7 @@
}
}
-static void nativeSetLayerStack(JNIEnv* env, jclass clazz, jint nativeObject, jint layerStack) {
+static void nativeSetLayerStack(JNIEnv* env, jclass clazz, jlong nativeObject, jint layerStack) {
SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
status_t err = ctrl->setLayerStack(layerStack);
if (err < 0 && err != NO_INIT) {
@@ -341,7 +341,7 @@
}
static void nativeSetDisplaySurface(JNIEnv* env, jclass clazz,
- jobject tokenObj, jint nativeSurfaceObject) {
+ jobject tokenObj, jlong nativeSurfaceObject) {
sp<IBinder> token(ibinderForJavaObject(env, tokenObj));
if (token == NULL) return;
sp<IGraphicBufferProducer> bufferProducer;
@@ -410,11 +410,11 @@
// ----------------------------------------------------------------------------
static JNINativeMethod sSurfaceControlMethods[] = {
- {"nativeCreate", "(Landroid/view/SurfaceSession;Ljava/lang/String;IIII)I",
+ {"nativeCreate", "(Landroid/view/SurfaceSession;Ljava/lang/String;IIII)J",
(void*)nativeCreate },
- {"nativeRelease", "(I)V",
+ {"nativeRelease", "(J)V",
(void*)nativeRelease },
- {"nativeDestroy", "(I)V",
+ {"nativeDestroy", "(J)V",
(void*)nativeDestroy },
{"nativeScreenshot", "(Landroid/os/IBinder;IIIIZ)Landroid/graphics/Bitmap;",
(void*)nativeScreenshotBitmap },
@@ -426,23 +426,23 @@
(void*)nativeCloseTransaction },
{"nativeSetAnimationTransaction", "()V",
(void*)nativeSetAnimationTransaction },
- {"nativeSetLayer", "(II)V",
+ {"nativeSetLayer", "(JI)V",
(void*)nativeSetLayer },
- {"nativeSetPosition", "(IFF)V",
+ {"nativeSetPosition", "(JFF)V",
(void*)nativeSetPosition },
- {"nativeSetSize", "(III)V",
+ {"nativeSetSize", "(JII)V",
(void*)nativeSetSize },
- {"nativeSetTransparentRegionHint", "(ILandroid/graphics/Region;)V",
+ {"nativeSetTransparentRegionHint", "(JLandroid/graphics/Region;)V",
(void*)nativeSetTransparentRegionHint },
- {"nativeSetAlpha", "(IF)V",
+ {"nativeSetAlpha", "(JF)V",
(void*)nativeSetAlpha },
- {"nativeSetMatrix", "(IFFFF)V",
+ {"nativeSetMatrix", "(JFFFF)V",
(void*)nativeSetMatrix },
- {"nativeSetFlags", "(III)V",
+ {"nativeSetFlags", "(JII)V",
(void*)nativeSetFlags },
- {"nativeSetWindowCrop", "(IIIII)V",
+ {"nativeSetWindowCrop", "(JIIII)V",
(void*)nativeSetWindowCrop },
- {"nativeSetLayerStack", "(II)V",
+ {"nativeSetLayerStack", "(JI)V",
(void*)nativeSetLayerStack },
{"nativeGetBuiltInDisplay", "(I)Landroid/os/IBinder;",
(void*)nativeGetBuiltInDisplay },
@@ -450,7 +450,7 @@
(void*)nativeCreateDisplay },
{"nativeDestroyDisplay", "(Landroid/os/IBinder;)V",
(void*)nativeDestroyDisplay },
- {"nativeSetDisplaySurface", "(Landroid/os/IBinder;I)V",
+ {"nativeSetDisplaySurface", "(Landroid/os/IBinder;J)V",
(void*)nativeSetDisplaySurface },
{"nativeSetDisplayLayerStack", "(Landroid/os/IBinder;I)V",
(void*)nativeSetDisplayLayerStack },
diff --git a/core/jni/android_view_SurfaceSession.cpp b/core/jni/android_view_SurfaceSession.cpp
index 87e339c..609c565 100644
--- a/core/jni/android_view_SurfaceSession.cpp
+++ b/core/jni/android_view_SurfaceSession.cpp
@@ -35,22 +35,22 @@
sp<SurfaceComposerClient> android_view_SurfaceSession_getClient(
JNIEnv* env, jobject surfaceSessionObj) {
return reinterpret_cast<SurfaceComposerClient*>(
- env->GetIntField(surfaceSessionObj, gSurfaceSessionClassInfo.mNativeClient));
+ env->GetLongField(surfaceSessionObj, gSurfaceSessionClassInfo.mNativeClient));
}
-static jint nativeCreate(JNIEnv* env, jclass clazz) {
+static jlong nativeCreate(JNIEnv* env, jclass clazz) {
SurfaceComposerClient* client = new SurfaceComposerClient();
client->incStrong((void*)nativeCreate);
- return reinterpret_cast<jint>(client);
+ return reinterpret_cast<jlong>(client);
}
-static void nativeDestroy(JNIEnv* env, jclass clazz, jint ptr) {
+static void nativeDestroy(JNIEnv* env, jclass clazz, jlong ptr) {
SurfaceComposerClient* client = reinterpret_cast<SurfaceComposerClient*>(ptr);
client->decStrong((void*)nativeCreate);
}
-static void nativeKill(JNIEnv* env, jclass clazz, jint ptr) {
+static void nativeKill(JNIEnv* env, jclass clazz, jlong ptr) {
SurfaceComposerClient* client = reinterpret_cast<SurfaceComposerClient*>(ptr);
client->dispose();
}
@@ -58,11 +58,11 @@
static JNINativeMethod gMethods[] = {
/* name, signature, funcPtr */
- { "nativeCreate", "()I",
+ { "nativeCreate", "()J",
(void*)nativeCreate },
- { "nativeDestroy", "(I)V",
+ { "nativeDestroy", "(J)V",
(void*)nativeDestroy },
- { "nativeKill", "(I)V",
+ { "nativeKill", "(J)V",
(void*)nativeKill }
};
@@ -72,7 +72,7 @@
LOG_ALWAYS_FATAL_IF(res < 0, "Unable to register native methods.");
jclass clazz = env->FindClass("android/view/SurfaceSession");
- gSurfaceSessionClassInfo.mNativeClient = env->GetFieldID(clazz, "mNativeClient", "I");
+ gSurfaceSessionClassInfo.mNativeClient = env->GetFieldID(clazz, "mNativeClient", "J");
return 0;
}
diff --git a/core/jni/android_view_TextureView.cpp b/core/jni/android_view_TextureView.cpp
index 0f429005..54f9278 100644
--- a/core/jni/android_view_TextureView.cpp
+++ b/core/jni/android_view_TextureView.cpp
@@ -59,9 +59,15 @@
#define GET_INT(object, field) \
env->GetIntField(object, field)
+#define GET_LONG(object, field) \
+ env->GetLongField(object, field)
+
#define SET_INT(object, field, value) \
env->SetIntField(object, field, value)
+#define SET_LONG(object, field, value) \
+ env->SetLongField(object, field, value)
+
#define INVOKEV(object, method, ...) \
env->CallVoidMethod(object, method, __VA_ARGS__)
@@ -103,35 +109,35 @@
sp<ANativeWindow> window = new Surface(producer, true);
window->incStrong((void*)android_view_TextureView_createNativeWindow);
- SET_INT(textureView, gTextureViewClassInfo.nativeWindow, jint(window.get()));
+ SET_LONG(textureView, gTextureViewClassInfo.nativeWindow, jlong(window.get()));
}
static void android_view_TextureView_destroyNativeWindow(JNIEnv* env, jobject textureView) {
ANativeWindow* nativeWindow = (ANativeWindow*)
- GET_INT(textureView, gTextureViewClassInfo.nativeWindow);
+ GET_LONG(textureView, gTextureViewClassInfo.nativeWindow);
if (nativeWindow) {
sp<ANativeWindow> window(nativeWindow);
window->decStrong((void*)android_view_TextureView_createNativeWindow);
- SET_INT(textureView, gTextureViewClassInfo.nativeWindow, 0);
+ SET_LONG(textureView, gTextureViewClassInfo.nativeWindow, 0);
}
}
static inline void swapCanvasPtr(JNIEnv* env, jobject canvasObj, SkCanvas* newCanvas) {
jobject canvasFinalizerObj = env->GetObjectField(canvasObj, gCanvasClassInfo.mFinalizer);
SkCanvas* previousCanvas = reinterpret_cast<SkCanvas*>(
- env->GetIntField(canvasObj, gCanvasClassInfo.mNativeCanvas));
- env->SetIntField(canvasObj, gCanvasClassInfo.mNativeCanvas, (int)newCanvas);
- env->SetIntField(canvasFinalizerObj, gCanvasFinalizerClassInfo.mNativeCanvas, (int)newCanvas);
+ env->GetLongField(canvasObj, gCanvasClassInfo.mNativeCanvas));
+ env->SetLongField(canvasObj, gCanvasClassInfo.mNativeCanvas, (jlong)newCanvas);
+ env->SetLongField(canvasFinalizerObj, gCanvasFinalizerClassInfo.mNativeCanvas, (jlong)newCanvas);
SkSafeUnref(previousCanvas);
}
static jboolean android_view_TextureView_lockCanvas(JNIEnv* env, jobject,
- jint nativeWindow, jobject canvas, jobject dirtyRect) {
+ jlong nativeWindow, jobject canvas, jobject dirtyRect) {
if (!nativeWindow) {
- return false;
+ return JNI_FALSE;
}
ANativeWindow_Buffer buffer;
@@ -148,7 +154,7 @@
sp<ANativeWindow> window((ANativeWindow*) nativeWindow);
int32_t status = native_window_lock(window.get(), &buffer, &rect);
- if (status) return false;
+ if (status) return JNI_FALSE;
ssize_t bytesCount = buffer.stride * bytesPerPixel(buffer.format);
@@ -179,11 +185,11 @@
int(rect.left), int(rect.top), int(rect.right), int(rect.bottom));
}
- return true;
+ return JNI_TRUE;
}
static void android_view_TextureView_unlockCanvasAndPost(JNIEnv* env, jobject,
- jint nativeWindow, jobject canvas) {
+ jlong nativeWindow, jobject canvas) {
SkCanvas* nativeCanvas = SkNEW(SkCanvas);
swapCanvasPtr(env, canvas, nativeCanvas);
@@ -206,9 +212,9 @@
{ "nDestroyNativeWindow", "()V",
(void*) android_view_TextureView_destroyNativeWindow },
- { "nLockCanvas", "(ILandroid/graphics/Canvas;Landroid/graphics/Rect;)Z",
+ { "nLockCanvas", "(JLandroid/graphics/Canvas;Landroid/graphics/Rect;)Z",
(void*) android_view_TextureView_lockCanvas },
- { "nUnlockCanvasAndPost", "(ILandroid/graphics/Canvas;)V",
+ { "nUnlockCanvasAndPost", "(JLandroid/graphics/Canvas;)V",
(void*) android_view_TextureView_unlockCanvasAndPost },
};
@@ -236,14 +242,14 @@
FIND_CLASS(clazz, "android/graphics/Canvas");
GET_FIELD_ID(gCanvasClassInfo.mFinalizer, clazz, "mFinalizer",
"Landroid/graphics/Canvas$CanvasFinalizer;");
- GET_FIELD_ID(gCanvasClassInfo.mNativeCanvas, clazz, "mNativeCanvas", "I");
+ GET_FIELD_ID(gCanvasClassInfo.mNativeCanvas, clazz, "mNativeCanvas", "J");
GET_FIELD_ID(gCanvasClassInfo.mSurfaceFormat, clazz, "mSurfaceFormat", "I");
FIND_CLASS(clazz, "android/graphics/Canvas$CanvasFinalizer");
- GET_FIELD_ID(gCanvasFinalizerClassInfo.mNativeCanvas, clazz, "mNativeCanvas", "I");
+ GET_FIELD_ID(gCanvasFinalizerClassInfo.mNativeCanvas, clazz, "mNativeCanvas", "J");
FIND_CLASS(clazz, "android/view/TextureView");
- GET_FIELD_ID(gTextureViewClassInfo.nativeWindow, clazz, "mNativeWindow", "I");
+ GET_FIELD_ID(gTextureViewClassInfo.nativeWindow, clazz, "mNativeWindow", "J");
return AndroidRuntime::registerNativeMethods(env, kClassPathName, gMethods, NELEM(gMethods));
}
diff --git a/core/jni/android_view_VelocityTracker.cpp b/core/jni/android_view_VelocityTracker.cpp
index 90ba2ba..1e36932 100644
--- a/core/jni/android_view_VelocityTracker.cpp
+++ b/core/jni/android_view_VelocityTracker.cpp
@@ -138,26 +138,26 @@
// --- JNI Methods ---
-static jint android_view_VelocityTracker_nativeInitialize(JNIEnv* env, jclass clazz,
+static jlong android_view_VelocityTracker_nativeInitialize(JNIEnv* env, jclass clazz,
jstring strategyStr) {
if (strategyStr) {
ScopedUtfChars strategy(env, strategyStr);
- return reinterpret_cast<jint>(new VelocityTrackerState(strategy.c_str()));
+ return reinterpret_cast<jlong>(new VelocityTrackerState(strategy.c_str()));
}
- return reinterpret_cast<jint>(new VelocityTrackerState(NULL));
+ return reinterpret_cast<jlong>(new VelocityTrackerState(NULL));
}
-static void android_view_VelocityTracker_nativeDispose(JNIEnv* env, jclass clazz, jint ptr) {
+static void android_view_VelocityTracker_nativeDispose(JNIEnv* env, jclass clazz, jlong ptr) {
VelocityTrackerState* state = reinterpret_cast<VelocityTrackerState*>(ptr);
delete state;
}
-static void android_view_VelocityTracker_nativeClear(JNIEnv* env, jclass clazz, jint ptr) {
+static void android_view_VelocityTracker_nativeClear(JNIEnv* env, jclass clazz, jlong ptr) {
VelocityTrackerState* state = reinterpret_cast<VelocityTrackerState*>(ptr);
state->clear();
}
-static void android_view_VelocityTracker_nativeAddMovement(JNIEnv* env, jclass clazz, jint ptr,
+static void android_view_VelocityTracker_nativeAddMovement(JNIEnv* env, jclass clazz, jlong ptr,
jobject eventObj) {
const MotionEvent* event = android_view_MotionEvent_getNativePtr(env, eventObj);
if (!event) {
@@ -170,13 +170,13 @@
}
static void android_view_VelocityTracker_nativeComputeCurrentVelocity(JNIEnv* env, jclass clazz,
- jint ptr, jint units, jfloat maxVelocity) {
+ jlong ptr, jint units, jfloat maxVelocity) {
VelocityTrackerState* state = reinterpret_cast<VelocityTrackerState*>(ptr);
state->computeCurrentVelocity(units, maxVelocity);
}
static jfloat android_view_VelocityTracker_nativeGetXVelocity(JNIEnv* env, jclass clazz,
- jint ptr, jint id) {
+ jlong ptr, jint id) {
VelocityTrackerState* state = reinterpret_cast<VelocityTrackerState*>(ptr);
float vx;
state->getVelocity(id, &vx, NULL);
@@ -184,7 +184,7 @@
}
static jfloat android_view_VelocityTracker_nativeGetYVelocity(JNIEnv* env, jclass clazz,
- jint ptr, jint id) {
+ jlong ptr, jint id) {
VelocityTrackerState* state = reinterpret_cast<VelocityTrackerState*>(ptr);
float vy;
state->getVelocity(id, NULL, &vy);
@@ -192,7 +192,7 @@
}
static jboolean android_view_VelocityTracker_nativeGetEstimator(JNIEnv* env, jclass clazz,
- jint ptr, jint id, jobject outEstimatorObj) {
+ jlong ptr, jint id, jobject outEstimatorObj) {
VelocityTrackerState* state = reinterpret_cast<VelocityTrackerState*>(ptr);
VelocityTracker::Estimator estimator;
bool result = state->getEstimator(id, &estimator);
@@ -217,28 +217,28 @@
static JNINativeMethod gVelocityTrackerMethods[] = {
/* name, signature, funcPtr */
{ "nativeInitialize",
- "(Ljava/lang/String;)I",
+ "(Ljava/lang/String;)J",
(void*)android_view_VelocityTracker_nativeInitialize },
{ "nativeDispose",
- "(I)V",
+ "(J)V",
(void*)android_view_VelocityTracker_nativeDispose },
{ "nativeClear",
- "(I)V",
+ "(J)V",
(void*)android_view_VelocityTracker_nativeClear },
{ "nativeAddMovement",
- "(ILandroid/view/MotionEvent;)V",
+ "(JLandroid/view/MotionEvent;)V",
(void*)android_view_VelocityTracker_nativeAddMovement },
{ "nativeComputeCurrentVelocity",
- "(IIF)V",
+ "(JIF)V",
(void*)android_view_VelocityTracker_nativeComputeCurrentVelocity },
{ "nativeGetXVelocity",
- "(II)F",
+ "(JI)F",
(void*)android_view_VelocityTracker_nativeGetXVelocity },
{ "nativeGetYVelocity",
- "(II)F",
+ "(JI)F",
(void*)android_view_VelocityTracker_nativeGetYVelocity },
{ "nativeGetEstimator",
- "(IILandroid/view/VelocityTracker$Estimator;)Z",
+ "(JILandroid/view/VelocityTracker$Estimator;)Z",
(void*)android_view_VelocityTracker_nativeGetEstimator },
};
diff --git a/core/jni/com_android_internal_content_NativeLibraryHelper.cpp b/core/jni/com_android_internal_content_NativeLibraryHelper.cpp
index 00da0f7..2004576 100644
--- a/core/jni/com_android_internal_content_NativeLibraryHelper.cpp
+++ b/core/jni/com_android_internal_content_NativeLibraryHelper.cpp
@@ -19,11 +19,12 @@
#include <android_runtime/AndroidRuntime.h>
-#include <utils/Log.h>
-#include <androidfw/ZipFileRO.h>
-#include <androidfw/ZipUtils.h>
#include <ScopedUtfChars.h>
#include <UniquePtr.h>
+#include <androidfw/ZipFileRO.h>
+#include <androidfw/ZipUtils.h>
+#include <utils/Log.h>
+#include <utils/Vector.h>
#include <zlib.h>
@@ -54,17 +55,19 @@
namespace android {
// These match PackageManager.java install codes
-typedef enum {
+enum install_status_t {
INSTALL_SUCCEEDED = 1,
INSTALL_FAILED_INVALID_APK = -2,
INSTALL_FAILED_INSUFFICIENT_STORAGE = -4,
INSTALL_FAILED_CONTAINER_ERROR = -18,
INSTALL_FAILED_INTERNAL_ERROR = -110,
-} install_status_t;
+ INSTALL_FAILED_NO_MATCHING_ABIS = -112,
+ NO_NATIVE_LIBRARIES = -113
+};
typedef install_status_t (*iterFunc)(JNIEnv*, void*, ZipFileRO*, ZipEntryRO, const char*);
-// Equivalent to isFilenameSafe
+// Equivalent to android.os.FileUtils.isFilenameSafe
static bool
isFilenameSafe(const char* filename)
{
@@ -202,7 +205,7 @@
}
// Only copy out the native file if it's different.
- struct stat st;
+ struct stat64 st;
if (!isFileDifferent(localFileName, uncompLen, modTime, crc, &st)) {
return INSTALL_SUCCEEDED;
}
@@ -268,126 +271,252 @@
return INSTALL_SUCCEEDED;
}
-static install_status_t
-iterateOverNativeFiles(JNIEnv *env, jstring javaFilePath, jstring javaCpuAbi, jstring javaCpuAbi2,
- iterFunc callFunc, void* callArg) {
- ScopedUtfChars filePath(env, javaFilePath);
- ScopedUtfChars cpuAbi(env, javaCpuAbi);
- ScopedUtfChars cpuAbi2(env, javaCpuAbi2);
-
- UniquePtr<ZipFileRO> zipFile(ZipFileRO::open(filePath.c_str()));
- if (zipFile.get() == NULL) {
- ALOGI("Couldn't open APK %s\n", filePath.c_str());
- return INSTALL_FAILED_INVALID_APK;
+/*
+ * An iterator over all shared libraries in a zip file. An entry is
+ * considered to be a shared library if all of the conditions below are
+ * satisfied :
+ *
+ * - The entry is under the lib/ directory.
+ * - The entry name ends with ".so" and the entry name starts with "lib",
+ * an exception is made for entries whose name is "gdbserver".
+ * - The entry filename is "safe" (as determined by isFilenameSafe).
+ *
+ */
+class NativeLibrariesIterator {
+private:
+ NativeLibrariesIterator(ZipFileRO* zipFile, void* cookie)
+ : mZipFile(zipFile), mCookie(cookie), mLastSlash(NULL) {
+ fileName[0] = '\0';
}
+public:
+ static NativeLibrariesIterator* create(ZipFileRO* zipFile) {
+ void* cookie = NULL;
+ if (!zipFile->startIteration(&cookie)) {
+ return NULL;
+ }
+
+ return new NativeLibrariesIterator(zipFile, cookie);
+ }
+
+ ZipEntryRO next() {
+ ZipEntryRO next = NULL;
+ while ((next = mZipFile->nextEntry(mCookie)) != NULL) {
+ // Make sure this entry has a filename.
+ if (mZipFile->getEntryFileName(next, fileName, sizeof(fileName))) {
+ continue;
+ }
+
+ // Make sure we're in the lib directory of the ZIP.
+ if (strncmp(fileName, APK_LIB, APK_LIB_LEN)) {
+ continue;
+ }
+
+ // Make sure the filename is at least to the minimum library name size.
+ const size_t fileNameLen = strlen(fileName);
+ static const size_t minLength = APK_LIB_LEN + 2 + LIB_PREFIX_LEN + 1 + LIB_SUFFIX_LEN;
+ if (fileNameLen < minLength) {
+ continue;
+ }
+
+ const char* lastSlash = strrchr(fileName, '/');
+ ALOG_ASSERT(lastSlash != NULL, "last slash was null somehow for %s\n", fileName);
+
+ // Exception: If we find the gdbserver binary, return it.
+ if (!strncmp(lastSlash + 1, GDBSERVER, GDBSERVER_LEN)) {
+ break;
+ }
+
+ // Make sure the filename starts with lib and ends with ".so".
+ if (strncmp(fileName + fileNameLen - LIB_SUFFIX_LEN, LIB_SUFFIX, LIB_SUFFIX_LEN)
+ || strncmp(lastSlash, LIB_PREFIX, LIB_PREFIX_LEN)) {
+ continue;
+ }
+
+ // Make sure the filename is safe.
+ if (!isFilenameSafe(lastSlash + 1)) {
+ continue;
+ }
+
+ mLastSlash = lastSlash;
+ break;
+ }
+
+ return next;
+ }
+
+ inline const char* currentEntry() const {
+ return fileName;
+ }
+
+ inline const char* lastSlash() const {
+ return mLastSlash;
+ }
+
+ virtual ~NativeLibrariesIterator() {
+ mZipFile->endIteration(mCookie);
+ }
+private:
+
char fileName[PATH_MAX];
- bool hasPrimaryAbi = false;
+ ZipFileRO* const mZipFile;
+ void* mCookie;
+ const char* mLastSlash;
+};
- void* cookie = NULL;
- if (!zipFile->startIteration(&cookie)) {
- ALOGI("Couldn't iterate over APK%s\n", filePath.c_str());
+static install_status_t
+iterateOverNativeFiles(JNIEnv *env, jlong apkHandle, jstring javaCpuAbi,
+ iterFunc callFunc, void* callArg) {
+ ZipFileRO* zipFile = reinterpret_cast<ZipFileRO*>(apkHandle);
+ if (zipFile == NULL) {
return INSTALL_FAILED_INVALID_APK;
}
+ UniquePtr<NativeLibrariesIterator> it(NativeLibrariesIterator::create(zipFile));
+ if (it.get() == NULL) {
+ return INSTALL_FAILED_INVALID_APK;
+ }
+
+ const ScopedUtfChars cpuAbi(env, javaCpuAbi);
+ if (cpuAbi.c_str() == NULL) {
+ // This would've thrown, so this return code isn't observable by
+ // Java.
+ return INSTALL_FAILED_INVALID_APK;
+ }
ZipEntryRO entry = NULL;
- while ((entry = zipFile->nextEntry(cookie)) != NULL) {
- // Make sure this entry has a filename.
- if (zipFile->getEntryFileName(entry, fileName, sizeof(fileName))) {
- continue;
- }
-
- // Make sure we're in the lib directory of the ZIP.
- if (strncmp(fileName, APK_LIB, APK_LIB_LEN)) {
- continue;
- }
-
- // Make sure the filename is at least to the minimum library name size.
- const size_t fileNameLen = strlen(fileName);
- static const size_t minLength = APK_LIB_LEN + 2 + LIB_PREFIX_LEN + 1 + LIB_SUFFIX_LEN;
- if (fileNameLen < minLength) {
- continue;
- }
-
- const char* lastSlash = strrchr(fileName, '/');
- ALOG_ASSERT(lastSlash != NULL, "last slash was null somehow for %s\n", fileName);
+ while ((entry = it->next()) != NULL) {
+ const char* fileName = it->currentEntry();
+ const char* lastSlash = it->lastSlash();
// Check to make sure the CPU ABI of this file is one we support.
const char* cpuAbiOffset = fileName + APK_LIB_LEN;
const size_t cpuAbiRegionSize = lastSlash - cpuAbiOffset;
- ALOGV("Comparing ABIs %s and %s versus %s\n", cpuAbi.c_str(), cpuAbi2.c_str(), cpuAbiOffset);
- if (cpuAbi.size() == cpuAbiRegionSize
- && *(cpuAbiOffset + cpuAbi.size()) == '/'
- && !strncmp(cpuAbiOffset, cpuAbi.c_str(), cpuAbiRegionSize)) {
- ALOGV("Using primary ABI %s\n", cpuAbi.c_str());
- hasPrimaryAbi = true;
- } else if (cpuAbi2.size() == cpuAbiRegionSize
- && *(cpuAbiOffset + cpuAbi2.size()) == '/'
- && !strncmp(cpuAbiOffset, cpuAbi2.c_str(), cpuAbiRegionSize)) {
-
- /*
- * If this library matches both the primary and secondary ABIs,
- * only use the primary ABI.
- */
- if (hasPrimaryAbi) {
- ALOGV("Already saw primary ABI, skipping secondary ABI %s\n", cpuAbi2.c_str());
- continue;
- } else {
- ALOGV("Using secondary ABI %s\n", cpuAbi2.c_str());
- }
- } else {
- ALOGV("abi didn't match anything: %s (end at %zd)\n", cpuAbiOffset, cpuAbiRegionSize);
- continue;
- }
-
- // If this is a .so file, check to see if we need to copy it.
- if ((!strncmp(fileName + fileNameLen - LIB_SUFFIX_LEN, LIB_SUFFIX, LIB_SUFFIX_LEN)
- && !strncmp(lastSlash, LIB_PREFIX, LIB_PREFIX_LEN)
- && isFilenameSafe(lastSlash + 1))
- || !strncmp(lastSlash + 1, GDBSERVER, GDBSERVER_LEN)) {
-
- install_status_t ret = callFunc(env, callArg, zipFile.get(), entry, lastSlash + 1);
+ if (cpuAbi.size() == cpuAbiRegionSize && !strncmp(cpuAbiOffset, cpuAbi.c_str(), cpuAbiRegionSize)) {
+ install_status_t ret = callFunc(env, callArg, zipFile, entry, lastSlash + 1);
if (ret != INSTALL_SUCCEEDED) {
ALOGV("Failure for entry %s", lastSlash + 1);
- zipFile->endIteration(cookie);
return ret;
}
}
}
- zipFile->endIteration(cookie);
-
return INSTALL_SUCCEEDED;
}
+
+static int findSupportedAbi(JNIEnv *env, jlong apkHandle, jobjectArray supportedAbisArray) {
+ const int numAbis = env->GetArrayLength(supportedAbisArray);
+ Vector<ScopedUtfChars*> supportedAbis;
+
+ for (int i = 0; i < numAbis; ++i) {
+ supportedAbis.add(new ScopedUtfChars(env,
+ (jstring) env->GetObjectArrayElement(supportedAbisArray, i)));
+ }
+
+ ZipFileRO* zipFile = reinterpret_cast<ZipFileRO*>(apkHandle);
+ if (zipFile == NULL) {
+ return INSTALL_FAILED_INVALID_APK;
+ }
+
+ UniquePtr<NativeLibrariesIterator> it(NativeLibrariesIterator::create(zipFile));
+ if (it.get() == NULL) {
+ return INSTALL_FAILED_INVALID_APK;
+ }
+
+ ZipEntryRO entry = NULL;
+ char fileName[PATH_MAX];
+ int status = NO_NATIVE_LIBRARIES;
+ while ((entry = it->next()) != NULL) {
+ // We're currently in the lib/ directory of the APK, so it does have some native
+ // code. We should return INSTALL_FAILED_NO_MATCHING_ABIS if none of the
+ // libraries match.
+ if (status == NO_NATIVE_LIBRARIES) {
+ status = INSTALL_FAILED_NO_MATCHING_ABIS;
+ }
+
+ const char* fileName = it->currentEntry();
+ const char* lastSlash = it->lastSlash();
+
+ // Check to see if this CPU ABI matches what we are looking for.
+ const char* abiOffset = fileName + APK_LIB_LEN;
+ const size_t abiSize = lastSlash - abiOffset;
+ for (int i = 0; i < numAbis; i++) {
+ const ScopedUtfChars* abi = supportedAbis[i];
+ if (abi->size() == abiSize && !strncmp(abiOffset, abi->c_str(), abiSize)) {
+ // The entry that comes in first (i.e. with a lower index) has the higher priority.
+ if (((i < status) && (status >= 0)) || (status < 0) ) {
+ status = i;
+ }
+ }
+ }
+ }
+
+ for (int i = 0; i < numAbis; ++i) {
+ delete supportedAbis[i];
+ }
+
+ return status;
+}
+
static jint
com_android_internal_content_NativeLibraryHelper_copyNativeBinaries(JNIEnv *env, jclass clazz,
- jstring javaFilePath, jstring javaNativeLibPath, jstring javaCpuAbi, jstring javaCpuAbi2)
+ jlong apkHandle, jstring javaNativeLibPath, jstring javaCpuAbi)
{
- return (jint) iterateOverNativeFiles(env, javaFilePath, javaCpuAbi, javaCpuAbi2,
+ return (jint) iterateOverNativeFiles(env, apkHandle, javaCpuAbi,
copyFileIfChanged, &javaNativeLibPath);
}
static jlong
com_android_internal_content_NativeLibraryHelper_sumNativeBinaries(JNIEnv *env, jclass clazz,
- jstring javaFilePath, jstring javaCpuAbi, jstring javaCpuAbi2)
+ jlong apkHandle, jstring javaCpuAbi)
{
size_t totalSize = 0;
- iterateOverNativeFiles(env, javaFilePath, javaCpuAbi, javaCpuAbi2, sumFiles, &totalSize);
+ iterateOverNativeFiles(env, apkHandle, javaCpuAbi, sumFiles, &totalSize);
return totalSize;
}
+static jint
+com_android_internal_content_NativeLibraryHelper_findSupportedAbi(JNIEnv *env, jclass clazz,
+ jlong apkHandle, jobjectArray javaCpuAbisToSearch)
+{
+ return (jint) findSupportedAbi(env, apkHandle, javaCpuAbisToSearch);
+}
+
+static jlong
+com_android_internal_content_NativeLibraryHelper_openApk(JNIEnv *env, jclass, jstring apkPath)
+{
+ ScopedUtfChars filePath(env, apkPath);
+ ZipFileRO* zipFile = ZipFileRO::open(filePath.c_str());
+
+ return reinterpret_cast<jlong>(zipFile);
+}
+
+static void
+com_android_internal_content_NativeLibraryHelper_close(JNIEnv *env, jclass, jlong apkHandle)
+{
+ delete reinterpret_cast<ZipFileRO*>(apkHandle);
+}
+
static JNINativeMethod gMethods[] = {
+ {"nativeOpenApk",
+ "(Ljava/lang/String;)J",
+ (void *)com_android_internal_content_NativeLibraryHelper_openApk},
+ {"nativeClose",
+ "(J)V",
+ (void *)com_android_internal_content_NativeLibraryHelper_close},
{"nativeCopyNativeBinaries",
- "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I",
+ "(JLjava/lang/String;Ljava/lang/String;)I",
(void *)com_android_internal_content_NativeLibraryHelper_copyNativeBinaries},
{"nativeSumNativeBinaries",
- "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)J",
+ "(JLjava/lang/String;)J",
(void *)com_android_internal_content_NativeLibraryHelper_sumNativeBinaries},
+ {"nativeFindSupportedAbi",
+ "(J[Ljava/lang/String;)I",
+ (void *)com_android_internal_content_NativeLibraryHelper_findSupportedAbi},
};
diff --git a/core/jni/com_android_internal_os_Zygote.cpp b/core/jni/com_android_internal_os_Zygote.cpp
new file mode 100644
index 0000000..a61fa87
--- /dev/null
+++ b/core/jni/com_android_internal_os_Zygote.cpp
@@ -0,0 +1,608 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "android_runtime/AndroidRuntime.h"
+
+// sys/mount.h has to come before linux/fs.h due to redefinition of MS_RDONLY, MS_BIND, etc
+#include <sys/mount.h>
+#include <linux/fs.h>
+
+#include <grp.h>
+#include <paths.h>
+#include <signal.h>
+#include <stdlib.h>
+#include <sys/resource.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/wait.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+#include "cutils/fs.h"
+#include "cutils/multiuser.h"
+#include "cutils/sched_policy.h"
+#include "utils/String8.h"
+#include "JNIHelp.h"
+#include "ScopedLocalRef.h"
+#include "ScopedPrimitiveArray.h"
+#include "ScopedUtfChars.h"
+
+#if defined(HAVE_PRCTL)
+#include <sys/prctl.h>
+#endif
+
+#include <selinux/android.h>
+
+#if defined(__linux__)
+#include <sys/personality.h>
+#include <sys/utsname.h>
+#if defined(HAVE_ANDROID_OS)
+#include <sys/capability.h>
+#endif
+#endif
+
+namespace {
+
+using android::String8;
+
+static pid_t gSystemServerPid = 0;
+
+static const char kZygoteClassName[] = "com/android/internal/os/Zygote";
+static jclass gZygoteClass;
+static jmethodID gCallPostForkChildHooks;
+
+// Must match values in com.android.internal.os.Zygote.
+enum MountExternalKind {
+ MOUNT_EXTERNAL_NONE = 0,
+ MOUNT_EXTERNAL_SINGLEUSER = 1,
+ MOUNT_EXTERNAL_MULTIUSER = 2,
+ MOUNT_EXTERNAL_MULTIUSER_ALL = 3,
+};
+
+static void RuntimeAbort(JNIEnv* env) {
+ env->FatalError("RuntimeAbort");
+}
+
+// This signal handler is for zygote mode, since the zygote must reap its children
+static void SigChldHandler(int /*signal_number*/) {
+ pid_t pid;
+ int status;
+
+ while ((pid = waitpid(-1, &status, WNOHANG)) > 0) {
+ // Log process-death status that we care about. In general it is
+ // not safe to call LOG(...) from a signal handler because of
+ // possible reentrancy. However, we know a priori that the
+ // current implementation of LOG() is safe to call from a SIGCHLD
+ // handler in the zygote process. If the LOG() implementation
+ // changes its locking strategy or its use of syscalls within the
+ // lazy-init critical section, its use here may become unsafe.
+ if (WIFEXITED(status)) {
+ if (WEXITSTATUS(status)) {
+ ALOGI("Process %d exited cleanly (%d)", pid, WEXITSTATUS(status));
+ } else if (false) {
+ ALOGI("Process %d exited cleanly (%d)", pid, WEXITSTATUS(status));
+ }
+ } else if (WIFSIGNALED(status)) {
+ if (WTERMSIG(status) != SIGKILL) {
+ ALOGI("Process %d exited cleanly (%d)", pid, WTERMSIG(status));
+ } else if (false) {
+ ALOGI("Process %d exited cleanly (%d)", pid, WTERMSIG(status));
+ }
+#ifdef WCOREDUMP
+ if (WCOREDUMP(status)) {
+ ALOGI("Process %d dumped core.", pid);
+ }
+#endif /* ifdef WCOREDUMP */
+ }
+
+ // If the just-crashed process is the system_server, bring down zygote
+ // so that it is restarted by init and system server will be restarted
+ // from there.
+ if (pid == gSystemServerPid) {
+ ALOGE("Exit zygote because system server (%d) has terminated");
+ kill(getpid(), SIGKILL);
+ }
+ }
+
+ if (pid < 0) {
+ ALOGW("Zygote SIGCHLD error in waitpid: %d", errno);
+ }
+}
+
+// Configures the SIGCHLD handler for the zygote process. This is configured
+// very late, because earlier in the runtime we may fork() and exec()
+// other processes, and we want to waitpid() for those rather than
+// have them be harvested immediately.
+//
+// This ends up being called repeatedly before each fork(), but there's
+// no real harm in that.
+static void SetSigChldHandler() {
+ struct sigaction sa;
+ memset(&sa, 0, sizeof(sa));
+ sa.sa_handler = SigChldHandler;
+
+ int err = sigaction(SIGCHLD, &sa, NULL);
+ if (err < 0) {
+ ALOGW("Error setting SIGCHLD handler: %d", errno);
+ }
+}
+
+// Sets the SIGCHLD handler back to default behavior in zygote children.
+static void UnsetSigChldHandler() {
+ struct sigaction sa;
+ memset(&sa, 0, sizeof(sa));
+ sa.sa_handler = SIG_DFL;
+
+ int err = sigaction(SIGCHLD, &sa, NULL);
+ if (err < 0) {
+ ALOGW("Error unsetting SIGCHLD handler: %d", errno);
+ }
+}
+
+// Calls POSIX setgroups() using the int[] object as an argument.
+// A NULL argument is tolerated.
+static void SetGids(JNIEnv* env, jintArray javaGids) {
+ if (javaGids == NULL) {
+ return;
+ }
+
+ ScopedIntArrayRO gids(env, javaGids);
+ if (gids.get() == NULL) {
+ RuntimeAbort(env);
+ }
+ int rc = setgroups(gids.size(), reinterpret_cast<const gid_t*>(&gids[0]));
+ if (rc == -1) {
+ ALOGE("setgroups failed");
+ RuntimeAbort(env);
+ }
+}
+
+// Sets the resource limits via setrlimit(2) for the values in the
+// two-dimensional array of integers that's passed in. The second dimension
+// contains a tuple of length 3: (resource, rlim_cur, rlim_max). NULL is
+// treated as an empty array.
+static void SetRLimits(JNIEnv* env, jobjectArray javaRlimits) {
+ if (javaRlimits == NULL) {
+ return;
+ }
+
+ rlimit rlim;
+ memset(&rlim, 0, sizeof(rlim));
+
+ for (int i = 0; i < env->GetArrayLength(javaRlimits); ++i) {
+ ScopedLocalRef<jobject> javaRlimitObject(env, env->GetObjectArrayElement(javaRlimits, i));
+ ScopedIntArrayRO javaRlimit(env, reinterpret_cast<jintArray>(javaRlimitObject.get()));
+ if (javaRlimit.size() != 3) {
+ ALOGE("rlimits array must have a second dimension of size 3");
+ RuntimeAbort(env);
+ }
+
+ rlim.rlim_cur = javaRlimit[1];
+ rlim.rlim_max = javaRlimit[2];
+
+ int rc = setrlimit(javaRlimit[0], &rlim);
+ if (rc == -1) {
+ ALOGE("setrlimit(%d, {%d, %d}) failed", javaRlimit[0], rlim.rlim_cur, rlim.rlim_max);
+ RuntimeAbort(env);
+ }
+ }
+}
+
+#if defined(HAVE_ANDROID_OS)
+
+// The debug malloc library needs to know whether it's the zygote or a child.
+extern "C" int gMallocLeakZygoteChild;
+
+static void EnableKeepCapabilities(JNIEnv* env) {
+ int rc = prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0);
+ if (rc == -1) {
+ ALOGE("prctl(PR_SET_KEEPCAPS) failed");
+ RuntimeAbort(env);
+ }
+}
+
+static void DropCapabilitiesBoundingSet(JNIEnv* env) {
+ for (int i = 0; prctl(PR_CAPBSET_READ, i, 0, 0, 0) >= 0; i++) {
+ int rc = prctl(PR_CAPBSET_DROP, i, 0, 0, 0);
+ if (rc == -1) {
+ if (errno == EINVAL) {
+ ALOGE("prctl(PR_CAPBSET_DROP) failed with EINVAL. Please verify "
+ "your kernel is compiled with file capabilities support");
+ } else {
+ ALOGE("prctl(PR_CAPBSET_DROP) failed");
+ RuntimeAbort(env);
+ }
+ }
+ }
+}
+
+static void SetCapabilities(JNIEnv* env, int64_t permitted, int64_t effective) {
+ __user_cap_header_struct capheader;
+ memset(&capheader, 0, sizeof(capheader));
+ capheader.version = _LINUX_CAPABILITY_VERSION_3;
+ capheader.pid = 0;
+
+ __user_cap_data_struct capdata[2];
+ memset(&capdata, 0, sizeof(capdata));
+ capdata[0].effective = effective;
+ capdata[1].effective = effective >> 32;
+ capdata[0].permitted = permitted;
+ capdata[1].permitted = permitted >> 32;
+
+ if (capset(&capheader, &capdata[0]) == -1) {
+ ALOGE("capset(%lld, %lld) failed", permitted, effective);
+ RuntimeAbort(env);
+ }
+}
+
+static void SetSchedulerPolicy(JNIEnv* env) {
+ errno = -set_sched_policy(0, SP_DEFAULT);
+ if (errno != 0) {
+ ALOGE("set_sched_policy(0, SP_DEFAULT) failed");
+ RuntimeAbort(env);
+ }
+}
+
+#else
+
+static int gMallocLeakZygoteChild = 0;
+
+static void EnableKeepCapabilities(JNIEnv*) {}
+static void DropCapabilitiesBoundingSet(JNIEnv*) {}
+static void SetCapabilities(JNIEnv*, int64_t, int64_t) {}
+static void SetSchedulerPolicy(JNIEnv*) {}
+
+#endif
+
+// Create a private mount namespace and bind mount appropriate emulated
+// storage for the given user.
+static bool MountEmulatedStorage(uid_t uid, jint mount_mode) {
+ if (mount_mode == MOUNT_EXTERNAL_NONE) {
+ return true;
+ }
+
+ // See storage config details at http://source.android.com/tech/storage/
+ userid_t user_id = multiuser_get_user_id(uid);
+
+ // Create a second private mount namespace for our process
+ if (unshare(CLONE_NEWNS) == -1) {
+ ALOGW("Failed to unshare(): %d", errno);
+ return false;
+ }
+
+ // Create bind mounts to expose external storage
+ if (mount_mode == MOUNT_EXTERNAL_MULTIUSER || mount_mode == MOUNT_EXTERNAL_MULTIUSER_ALL) {
+ // These paths must already be created by init.rc
+ const char* source = getenv("EMULATED_STORAGE_SOURCE");
+ const char* target = getenv("EMULATED_STORAGE_TARGET");
+ const char* legacy = getenv("EXTERNAL_STORAGE");
+ if (source == NULL || target == NULL || legacy == NULL) {
+ ALOGW("Storage environment undefined; unable to provide external storage");
+ return false;
+ }
+
+ // Prepare source paths
+
+ // /mnt/shell/emulated/0
+ const String8 source_user(String8::format("%s/%d", source, user_id));
+ // /storage/emulated/0
+ const String8 target_user(String8::format("%s/%d", target, user_id));
+
+ if (fs_prepare_dir(source_user.string(), 0000, 0, 0) == -1
+ || fs_prepare_dir(target_user.string(), 0000, 0, 0) == -1) {
+ return false;
+ }
+
+ if (mount_mode == MOUNT_EXTERNAL_MULTIUSER_ALL) {
+ // Mount entire external storage tree for all users
+ if (TEMP_FAILURE_RETRY(mount(source, target, NULL, MS_BIND, NULL)) == -1) {
+ ALOGW("Failed to mount %s to %s :%d", source, target, errno);
+ return false;
+ }
+ } else {
+ // Only mount user-specific external storage
+ if (TEMP_FAILURE_RETRY(
+ mount(source_user.string(), target_user.string(), NULL, MS_BIND, NULL)) == -1) {
+ ALOGW("Failed to mount %s to %s: %d", source_user.string(), target_user.string(), errno);
+ return false;
+ }
+ }
+
+ if (fs_prepare_dir(legacy, 0000, 0, 0) == -1) {
+ return false;
+ }
+
+ // Finally, mount user-specific path into place for legacy users
+ if (TEMP_FAILURE_RETRY(
+ mount(target_user.string(), legacy, NULL, MS_BIND | MS_REC, NULL)) == -1) {
+ ALOGW("Failed to mount %s to %s: %d", target_user.string(), legacy, errno);
+ return false;
+ }
+ } else {
+ ALOGW("Mount mode %d unsupported", mount_mode);
+ return false;
+ }
+
+ return true;
+}
+
+#if defined(__linux__)
+static bool NeedsNoRandomizeWorkaround() {
+#if !defined(__arm__)
+ return false;
+#else
+ int major;
+ int minor;
+ struct utsname uts;
+ if (uname(&uts) == -1) {
+ return false;
+ }
+
+ if (sscanf(uts.release, "%d.%d", &major, &minor) != 2) {
+ return false;
+ }
+
+ // Kernels before 3.4.* need the workaround.
+ return (major < 3) || ((major == 3) && (minor < 4));
+#endif
+}
+#endif
+
+// Utility to close down the Zygote socket file descriptors while
+// the child is still running as root with Zygote's privileges. Each
+// descriptor (if any) is closed via dup2(), replacing it with a valid
+// (open) descriptor to /dev/null.
+
+static void DetachDescriptors(JNIEnv* env, jintArray fdsToClose) {
+ if (!fdsToClose) {
+ return;
+ }
+ jsize count = env->GetArrayLength(fdsToClose);
+ jint *ar = env->GetIntArrayElements(fdsToClose, 0);
+ if (!ar) {
+ ALOGE("Bad fd array");
+ RuntimeAbort(env);
+ }
+ jsize i;
+ int devnull;
+ for (i = 0; i < count; i++) {
+ devnull = open("/dev/null", O_RDWR);
+ if (devnull < 0) {
+ ALOGE("Failed to open /dev/null");
+ RuntimeAbort(env);
+ continue;
+ }
+ ALOGV("Switching descriptor %d to /dev/null: %d", ar[i], errno);
+ if (dup2(devnull, ar[i]) < 0) {
+ ALOGE("Failed dup2() on descriptor %d", ar[i]);
+ RuntimeAbort(env);
+ }
+ close(devnull);
+ }
+}
+
+void SetThreadName(const char* thread_name) {
+ bool hasAt = false;
+ bool hasDot = false;
+ const char* s = thread_name;
+ while (*s) {
+ if (*s == '.') {
+ hasDot = true;
+ } else if (*s == '@') {
+ hasAt = true;
+ }
+ s++;
+ }
+ const int len = s - thread_name;
+ if (len < 15 || hasAt || !hasDot) {
+ s = thread_name;
+ } else {
+ s = thread_name + len - 15;
+ }
+ // pthread_setname_np fails rather than truncating long strings.
+ char buf[16]; // MAX_TASK_COMM_LEN=16 is hard-coded into bionic
+ strlcpy(buf, s, sizeof(buf)-1);
+ errno = pthread_setname_np(pthread_self(), buf);
+ if (errno != 0) {
+ ALOGW("Unable to set the name of current thread to '%s'", buf);
+ }
+}
+
+// Utility routine to fork zygote and specialize the child process.
+static pid_t ForkAndSpecializeCommon(JNIEnv* env, uid_t uid, gid_t gid, jintArray javaGids,
+ jint debug_flags, jobjectArray javaRlimits,
+ jlong permittedCapabilities, jlong effectiveCapabilities,
+ jint mount_external,
+ jstring java_se_info, jstring java_se_name,
+ bool is_system_server, jintArray fdsToClose) {
+ SetSigChldHandler();
+
+ pid_t pid = fork();
+
+ if (pid == 0) {
+ // The child process.
+ gMallocLeakZygoteChild = 1;
+
+ // Clean up any descriptors which must be closed immediately
+ DetachDescriptors(env, fdsToClose);
+
+ // Keep capabilities across UID change, unless we're staying root.
+ if (uid != 0) {
+ EnableKeepCapabilities(env);
+ }
+
+ DropCapabilitiesBoundingSet(env);
+
+ if (!MountEmulatedStorage(uid, mount_external)) {
+ ALOGW("Failed to mount emulated storage: %d", errno);
+ if (errno == ENOTCONN || errno == EROFS) {
+ // When device is actively encrypting, we get ENOTCONN here
+ // since FUSE was mounted before the framework restarted.
+ // When encrypted device is booting, we get EROFS since
+ // FUSE hasn't been created yet by init.
+ // In either case, continue without external storage.
+ } else {
+ ALOGE("Cannot continue without emulated storage");
+ RuntimeAbort(env);
+ }
+ }
+
+ SetGids(env, javaGids);
+
+ SetRLimits(env, javaRlimits);
+
+ int rc = setresgid(gid, gid, gid);
+ if (rc == -1) {
+ ALOGE("setresgid(%d) failed", gid);
+ RuntimeAbort(env);
+ }
+
+ rc = setresuid(uid, uid, uid);
+ if (rc == -1) {
+ ALOGE("setresuid(%d) failed", uid);
+ RuntimeAbort(env);
+ }
+
+#if defined(__linux__)
+ if (NeedsNoRandomizeWorkaround()) {
+ // Work around ARM kernel ASLR lossage (http://b/5817320).
+ int old_personality = personality(0xffffffff);
+ int new_personality = personality(old_personality | ADDR_NO_RANDOMIZE);
+ if (new_personality == -1) {
+ ALOGW("personality(%d) failed", new_personality);
+ }
+ }
+#endif
+
+ SetCapabilities(env, permittedCapabilities, effectiveCapabilities);
+
+ SetSchedulerPolicy(env);
+
+#if defined(HAVE_ANDROID_OS)
+ { // NOLINT(whitespace/braces)
+ const char* se_info_c_str = NULL;
+ ScopedUtfChars* se_info = NULL;
+ if (java_se_info != NULL) {
+ se_info = new ScopedUtfChars(env, java_se_info);
+ se_info_c_str = se_info->c_str();
+ if (se_info_c_str == NULL) {
+ ALOGE("se_info_c_str == NULL");
+ RuntimeAbort(env);
+ }
+ }
+ const char* se_name_c_str = NULL;
+ ScopedUtfChars* se_name = NULL;
+ if (java_se_name != NULL) {
+ se_name = new ScopedUtfChars(env, java_se_name);
+ se_name_c_str = se_name->c_str();
+ if (se_name_c_str == NULL) {
+ ALOGE("se_name_c_str == NULL");
+ RuntimeAbort(env);
+ }
+ }
+ rc = selinux_android_setcontext(uid, is_system_server, se_info_c_str, se_name_c_str);
+ if (rc == -1) {
+ ALOGE("selinux_android_setcontext(%d, %d, \"%s\", \"%s\") failed", uid,
+ is_system_server, se_info_c_str, se_name_c_str);
+ RuntimeAbort(env);
+ }
+
+ // Make it easier to debug audit logs by setting the main thread's name to the
+ // nice name rather than "app_process".
+ if (se_info_c_str == NULL && is_system_server) {
+ se_name_c_str = "system_server";
+ }
+ if (se_info_c_str != NULL) {
+ SetThreadName(se_name_c_str);
+ }
+
+ delete se_info;
+ delete se_name;
+ }
+#else
+ UNUSED(is_system_server);
+ UNUSED(java_se_info);
+ UNUSED(java_se_name);
+#endif
+
+ UnsetSigChldHandler();
+
+ env->CallStaticVoidMethod(gZygoteClass, gCallPostForkChildHooks, debug_flags);
+ if (env->ExceptionCheck()) {
+ ALOGE("Error calling post fork hooks.");
+ RuntimeAbort(env);
+ }
+ } else if (pid > 0) {
+ // the parent process
+ }
+ return pid;
+}
+} // anonymous namespace
+
+namespace android {
+
+static jint com_android_internal_os_Zygote_nativeForkAndSpecialize(
+ JNIEnv* env, jclass, jint uid, jint gid, jintArray gids,
+ jint debug_flags, jobjectArray rlimits,
+ jint mount_external, jstring se_info, jstring se_name,
+ jintArray fdsToClose) {
+ return ForkAndSpecializeCommon(env, uid, gid, gids, debug_flags,
+ rlimits, 0, 0, mount_external, se_info, se_name, false, fdsToClose);
+}
+
+static jint com_android_internal_os_Zygote_nativeForkSystemServer(
+ JNIEnv* env, jclass, uid_t uid, gid_t gid, jintArray gids,
+ jint debug_flags, jobjectArray rlimits, jlong permittedCapabilities,
+ jlong effectiveCapabilities) {
+ pid_t pid = ForkAndSpecializeCommon(env, uid, gid, gids,
+ debug_flags, rlimits,
+ permittedCapabilities, effectiveCapabilities,
+ MOUNT_EXTERNAL_NONE, NULL, NULL, true, NULL);
+ if (pid > 0) {
+ // The zygote process checks whether the child process has died or not.
+ ALOGI("System server process %d has been created", pid);
+ gSystemServerPid = pid;
+ // There is a slight window that the system server process has crashed
+ // but it went unnoticed because we haven't published its pid yet. So
+ // we recheck here just to make sure that all is well.
+ int status;
+ if (waitpid(pid, &status, WNOHANG) == pid) {
+ ALOGE("System server process %d has died. Restarting Zygote!", pid);
+ RuntimeAbort(env);
+ }
+ }
+ return pid;
+}
+
+static JNINativeMethod gMethods[] = {
+ { "nativeForkAndSpecialize", "(II[II[[IILjava/lang/String;Ljava/lang/String;[I)I",
+ (void *) com_android_internal_os_Zygote_nativeForkAndSpecialize },
+ { "nativeForkSystemServer", "(II[II[[IJJ)I",
+ (void *) com_android_internal_os_Zygote_nativeForkSystemServer }
+};
+
+int register_com_android_internal_os_Zygote(JNIEnv* env) {
+ gZygoteClass = (jclass) env->NewGlobalRef(env->FindClass(kZygoteClassName));
+ if (gZygoteClass == NULL) {
+ RuntimeAbort(env);
+ }
+ gCallPostForkChildHooks = env->GetStaticMethodID(gZygoteClass, "callPostForkChildHooks", "(I)V");
+
+ return AndroidRuntime::registerNativeMethods(env, "com/android/internal/os/Zygote",
+ gMethods, NELEM(gMethods));
+}
+} // namespace android
+
diff --git a/core/jni/com_google_android_gles_jni_EGLImpl.cpp b/core/jni/com_google_android_gles_jni_EGLImpl.cpp
index 50b3302..3035d15 100644
--- a/core/jni/com_google_android_gles_jni_EGLImpl.cpp
+++ b/core/jni/com_google_android_gles_jni_EGLImpl.cpp
@@ -50,39 +50,44 @@
static inline EGLDisplay getDisplay(JNIEnv* env, jobject o) {
if (!o) return EGL_NO_DISPLAY;
- return (EGLDisplay)env->GetIntField(o, gDisplay_EGLDisplayFieldID);
+ return (EGLDisplay)env->GetLongField(o, gDisplay_EGLDisplayFieldID);
}
static inline EGLSurface getSurface(JNIEnv* env, jobject o) {
if (!o) return EGL_NO_SURFACE;
- return (EGLSurface)env->GetIntField(o, gSurface_EGLSurfaceFieldID);
+ return (EGLSurface)env->GetLongField(o, gSurface_EGLSurfaceFieldID);
}
static inline EGLContext getContext(JNIEnv* env, jobject o) {
if (!o) return EGL_NO_CONTEXT;
- return (EGLContext)env->GetIntField(o, gContext_EGLContextFieldID);
+ return (EGLContext)env->GetLongField(o, gContext_EGLContextFieldID);
}
static inline EGLConfig getConfig(JNIEnv* env, jobject o) {
if (!o) return 0;
- return (EGLConfig)env->GetIntField(o, gConfig_EGLConfigFieldID);
+ return (EGLConfig)env->GetLongField(o, gConfig_EGLConfigFieldID);
}
+
+static inline jboolean EglBoolToJBool(EGLBoolean eglBool) {
+ return eglBool == EGL_TRUE ? JNI_TRUE : JNI_FALSE;
+}
+
static void nativeClassInit(JNIEnv *_env, jclass eglImplClass)
{
jclass config_class = _env->FindClass("com/google/android/gles_jni/EGLConfigImpl");
gConfig_class = (jclass) _env->NewGlobalRef(config_class);
- gConfig_ctorID = _env->GetMethodID(gConfig_class, "<init>", "(I)V");
- gConfig_EGLConfigFieldID = _env->GetFieldID(gConfig_class, "mEGLConfig", "I");
+ gConfig_ctorID = _env->GetMethodID(gConfig_class, "<init>", "(J)V");
+ gConfig_EGLConfigFieldID = _env->GetFieldID(gConfig_class, "mEGLConfig", "J");
jclass display_class = _env->FindClass("com/google/android/gles_jni/EGLDisplayImpl");
- gDisplay_EGLDisplayFieldID = _env->GetFieldID(display_class, "mEGLDisplay", "I");
+ gDisplay_EGLDisplayFieldID = _env->GetFieldID(display_class, "mEGLDisplay", "J");
jclass context_class = _env->FindClass("com/google/android/gles_jni/EGLContextImpl");
- gContext_EGLContextFieldID = _env->GetFieldID(context_class, "mEGLContext", "I");
+ gContext_EGLContextFieldID = _env->GetFieldID(context_class, "mEGLContext", "J");
jclass surface_class = _env->FindClass("com/google/android/gles_jni/EGLSurfaceImpl");
- gSurface_EGLSurfaceFieldID = _env->GetFieldID(surface_class, "mEGLSurface", "I");
- gSurface_NativePixelRefFieldID = _env->GetFieldID(surface_class, "mNativePixelRef", "I");
+ gSurface_EGLSurfaceFieldID = _env->GetFieldID(surface_class, "mEGLSurface", "J");
+ gSurface_NativePixelRefFieldID = _env->GetFieldID(surface_class, "mNativePixelRef", "J");
jclass bitmap_class = _env->FindClass("android/graphics/Bitmap");
- gBitmap_NativeBitmapFieldID = _env->GetFieldID(bitmap_class, "mNativeBitmap", "I");
+ gBitmap_NativeBitmapFieldID = _env->GetFieldID(bitmap_class, "mNativeBitmap", "J");
}
static const jint gNull_attrib_base[] = {EGL_NONE};
@@ -123,7 +128,7 @@
}
EGLDisplay dpy = getDisplay(_env, display);
- jboolean success = eglInitialize(dpy, NULL, NULL);
+ EGLBoolean success = eglInitialize(dpy, NULL, NULL);
if (success && major_minor) {
int len = _env->GetArrayLength(major_minor);
if (len) {
@@ -134,7 +139,7 @@
_env->ReleasePrimitiveArrayCritical(major_minor, base, JNI_ABORT);
}
}
- return success;
+ return EglBoolToJBool(success);
}
static jboolean jni_eglQueryContext(JNIEnv *_env, jobject _this, jobject display,
@@ -146,14 +151,14 @@
}
EGLDisplay dpy = getDisplay(_env, display);
EGLContext ctx = getContext(_env, context);
- jboolean success = JNI_FALSE;
+ EGLBoolean success = EGL_FALSE;
int len = _env->GetArrayLength(value);
if (len) {
jint* base = (jint *)_env->GetPrimitiveArrayCritical(value, (jboolean *)0);
success = eglQueryContext(dpy, ctx, attribute, base);
_env->ReleasePrimitiveArrayCritical(value, base, JNI_ABORT);
}
- return success;
+ return EglBoolToJBool(success);
}
static jboolean jni_eglQuerySurface(JNIEnv *_env, jobject _this, jobject display,
@@ -166,14 +171,14 @@
EGLDisplay dpy = getDisplay(_env, display);
EGLContext sur = getSurface(_env, surface);
- jboolean success = JNI_FALSE;
+ EGLBoolean success = EGL_FALSE;
int len = _env->GetArrayLength(value);
if (len) {
jint* base = (jint *)_env->GetPrimitiveArrayCritical(value, (jboolean *)0);
success = eglQuerySurface(dpy, sur, attribute, base);
_env->ReleasePrimitiveArrayCritical(value, base, JNI_ABORT);
}
- return success;
+ return EglBoolToJBool(success);
}
static jint jni_getInitCount(JNIEnv *_env, jobject _clazz, jobject display) {
@@ -183,7 +188,7 @@
}
static jboolean jni_eglReleaseThread(JNIEnv *_env, jobject _this) {
- return eglReleaseThread();
+ return EglBoolToJBool(eglReleaseThread());
}
static jboolean jni_eglChooseConfig(JNIEnv *_env, jobject _this, jobject display,
@@ -196,7 +201,7 @@
return JNI_FALSE;
}
EGLDisplay dpy = getDisplay(_env, display);
- jboolean success = JNI_FALSE;
+ EGLBoolean success = EGL_FALSE;
if (configs == NULL) {
config_size = 0;
@@ -214,14 +219,14 @@
if (success && configs!=NULL) {
for (int i=0 ; i<num ; i++) {
- jobject obj = _env->NewObject(gConfig_class, gConfig_ctorID, (jint)nativeConfigs[i]);
+ jobject obj = _env->NewObject(gConfig_class, gConfig_ctorID, reinterpret_cast<jlong>(nativeConfigs[i]));
_env->SetObjectArrayElement(configs, i, obj);
}
}
- return success;
+ return EglBoolToJBool(success);
}
-static jint jni_eglCreateContext(JNIEnv *_env, jobject _this, jobject display,
+static jlong jni_eglCreateContext(JNIEnv *_env, jobject _this, jobject display,
jobject config, jobject share_context, jintArray attrib_list) {
if (display == NULL || config == NULL || share_context == NULL
|| !validAttribList(_env, attrib_list)) {
@@ -234,10 +239,10 @@
jint* base = beginNativeAttribList(_env, attrib_list);
EGLContext ctx = eglCreateContext(dpy, cnf, shr, base);
endNativeAttributeList(_env, attrib_list, base);
- return (jint)ctx;
+ return reinterpret_cast<jlong>(ctx);
}
-static jint jni_eglCreatePbufferSurface(JNIEnv *_env, jobject _this, jobject display,
+static jlong jni_eglCreatePbufferSurface(JNIEnv *_env, jobject _this, jobject display,
jobject config, jintArray attrib_list) {
if (display == NULL || config == NULL
|| !validAttribList(_env, attrib_list)) {
@@ -249,7 +254,7 @@
jint* base = beginNativeAttribList(_env, attrib_list);
EGLSurface sur = eglCreatePbufferSurface(dpy, cnf, base);
endNativeAttributeList(_env, attrib_list, base);
- return (jint)sur;
+ return reinterpret_cast<jlong>(sur);
}
static PixelFormat convertPixelFormat(SkBitmap::Config format)
@@ -276,7 +281,7 @@
jint* base = 0;
SkBitmap const * nativeBitmap =
- (SkBitmap const *)_env->GetIntField(native_pixmap,
+ (SkBitmap const *)_env->GetLongField(native_pixmap,
gBitmap_NativeBitmapFieldID);
SkPixelRef* ref = nativeBitmap ? nativeBitmap->pixelRef() : 0;
if (ref == NULL) {
@@ -300,15 +305,15 @@
endNativeAttributeList(_env, attrib_list, base);
if (sur != EGL_NO_SURFACE) {
- _env->SetIntField(out_sur, gSurface_EGLSurfaceFieldID, (int)sur);
- _env->SetIntField(out_sur, gSurface_NativePixelRefFieldID, (int)ref);
+ _env->SetLongField(out_sur, gSurface_EGLSurfaceFieldID, reinterpret_cast<jlong>(sur));
+ _env->SetLongField(out_sur, gSurface_NativePixelRefFieldID, reinterpret_cast<jlong>(ref));
} else {
ref->unlockPixels();
SkSafeUnref(ref);
}
}
-static jint jni_eglCreateWindowSurface(JNIEnv *_env, jobject _this, jobject display,
+static jlong jni_eglCreateWindowSurface(JNIEnv *_env, jobject _this, jobject display,
jobject config, jobject native_window, jintArray attrib_list) {
if (display == NULL || config == NULL
|| !validAttribList(_env, attrib_list)) {
@@ -332,15 +337,15 @@
jint* base = beginNativeAttribList(_env, attrib_list);
EGLSurface sur = eglCreateWindowSurface(dpy, cnf, window.get(), base);
endNativeAttributeList(_env, attrib_list, base);
- return (jint)sur;
+ return reinterpret_cast<jlong>(sur);
}
-static jint jni_eglCreateWindowSurfaceTexture(JNIEnv *_env, jobject _this, jobject display,
+static jlong jni_eglCreateWindowSurfaceTexture(JNIEnv *_env, jobject _this, jobject display,
jobject config, jobject native_window, jintArray attrib_list) {
if (display == NULL || config == NULL
|| !validAttribList(_env, attrib_list)) {
jniThrowException(_env, "java/lang/IllegalArgumentException", NULL);
- return JNI_FALSE;
+ return 0;
}
EGLDisplay dpy = getDisplay(_env, display);
EGLContext cnf = getConfig(_env, config);
@@ -360,7 +365,7 @@
jint* base = beginNativeAttribList(_env, attrib_list);
EGLSurface sur = eglCreateWindowSurface(dpy, cnf, window.get(), base);
endNativeAttributeList(_env, attrib_list, base);
- return (jint)sur;
+ return reinterpret_cast<jlong>(sur);
}
static jboolean jni_eglGetConfigAttrib(JNIEnv *_env, jobject _this, jobject display,
@@ -372,13 +377,13 @@
}
EGLDisplay dpy = getDisplay(_env, display);
EGLContext cnf = getConfig(_env, config);
- jboolean success = JNI_FALSE;
+ EGLBoolean success = EGL_FALSE;
jint localValue;
success = eglGetConfigAttrib(dpy, cnf, attribute, &localValue);
if (success) {
_env->SetIntArrayRegion(value, 0, 1, &localValue);
}
- return success;
+ return EglBoolToJBool(success);
}
static jboolean jni_eglGetConfigs(JNIEnv *_env, jobject _this, jobject display,
@@ -389,7 +394,7 @@
return JNI_FALSE;
}
EGLDisplay dpy = getDisplay(_env, display);
- jboolean success = JNI_FALSE;
+ EGLBoolean success = EGL_FALSE;
if (configs == NULL) {
config_size = 0;
}
@@ -401,11 +406,11 @@
}
if (success && configs) {
for (int i=0 ; i<num ; i++) {
- jobject obj = _env->NewObject(gConfig_class, gConfig_ctorID, (jint)nativeConfigs[i]);
+ jobject obj = _env->NewObject(gConfig_class, gConfig_ctorID, reinterpret_cast<jlong>(nativeConfigs[i]));
_env->SetObjectArrayElement(configs, i, obj);
}
}
- return success;
+ return EglBoolToJBool(success);
}
static jint jni_eglGetError(JNIEnv *_env, jobject _this) {
@@ -413,20 +418,20 @@
return error;
}
-static jint jni_eglGetCurrentContext(JNIEnv *_env, jobject _this) {
- return (jint)eglGetCurrentContext();
+static jlong jni_eglGetCurrentContext(JNIEnv *_env, jobject _this) {
+ return reinterpret_cast<jlong>(eglGetCurrentContext());
}
-static jint jni_eglGetCurrentDisplay(JNIEnv *_env, jobject _this) {
- return (jint)eglGetCurrentDisplay();
+static jlong jni_eglGetCurrentDisplay(JNIEnv *_env, jobject _this) {
+ return reinterpret_cast<jlong>(eglGetCurrentDisplay());
}
-static jint jni_eglGetCurrentSurface(JNIEnv *_env, jobject _this, jint readdraw) {
+static jlong jni_eglGetCurrentSurface(JNIEnv *_env, jobject _this, jint readdraw) {
if ((readdraw != EGL_READ) && (readdraw != EGL_DRAW)) {
jniThrowException(_env, "java/lang/IllegalArgumentException", NULL);
return 0;
}
- return (jint)eglGetCurrentSurface(readdraw);
+ return reinterpret_cast<jlong>(eglGetCurrentSurface(readdraw));
}
static jboolean jni_eglDestroyContext(JNIEnv *_env, jobject _this, jobject display, jobject context) {
@@ -436,7 +441,7 @@
}
EGLDisplay dpy = getDisplay(_env, display);
EGLContext ctx = getContext(_env, context);
- return eglDestroyContext(dpy, ctx);
+ return EglBoolToJBool(eglDestroyContext(dpy, ctx));
}
static jboolean jni_eglDestroySurface(JNIEnv *_env, jobject _this, jobject display, jobject surface) {
@@ -448,18 +453,18 @@
EGLSurface sur = getSurface(_env, surface);
if (sur) {
- SkPixelRef* ref = (SkPixelRef*)(_env->GetIntField(surface,
+ SkPixelRef* ref = (SkPixelRef*)(_env->GetLongField(surface,
gSurface_NativePixelRefFieldID));
if (ref) {
ref->unlockPixels();
SkSafeUnref(ref);
}
}
- return eglDestroySurface(dpy, sur);
+ return EglBoolToJBool(eglDestroySurface(dpy, sur));
}
-static jint jni_eglGetDisplay(JNIEnv *_env, jobject _this, jobject native_display) {
- return (jint)eglGetDisplay(EGL_DEFAULT_DISPLAY);
+static jlong jni_eglGetDisplay(JNIEnv *_env, jobject _this, jobject native_display) {
+ return reinterpret_cast<jlong>(eglGetDisplay(EGL_DEFAULT_DISPLAY));
}
static jboolean jni_eglMakeCurrent(JNIEnv *_env, jobject _this, jobject display, jobject draw, jobject read, jobject context) {
@@ -471,7 +476,7 @@
EGLSurface sdr = getSurface(_env, draw);
EGLSurface srd = getSurface(_env, read);
EGLContext ctx = getContext(_env, context);
- return eglMakeCurrent(dpy, sdr, srd, ctx);
+ return EglBoolToJBool(eglMakeCurrent(dpy, sdr, srd, ctx));
}
static jstring jni_eglQueryString(JNIEnv *_env, jobject _this, jobject display, jint name) {
@@ -491,7 +496,7 @@
}
EGLDisplay dpy = getDisplay(_env, display);
EGLSurface sur = getSurface(_env, surface);
- return eglSwapBuffers(dpy, sur);
+ return EglBoolToJBool(eglSwapBuffers(dpy, sur));
}
static jboolean jni_eglTerminate(JNIEnv *_env, jobject _this, jobject display) {
@@ -500,7 +505,7 @@
return JNI_FALSE;
}
EGLDisplay dpy = getDisplay(_env, display);
- return eglTerminate(dpy);
+ return EglBoolToJBool(eglTerminate(dpy));
}
static jboolean jni_eglCopyBuffers(JNIEnv *_env, jobject _this, jobject display,
@@ -514,11 +519,11 @@
}
static jboolean jni_eglWaitGL(JNIEnv *_env, jobject _this) {
- return eglWaitGL();
+ return EglBoolToJBool(eglWaitGL());
}
static jboolean jni_eglWaitNative(JNIEnv *_env, jobject _this, jint engine, jobject bindTarget) {
- return eglWaitNative(engine);
+ return EglBoolToJBool(eglWaitNative(engine));
}
@@ -540,21 +545,21 @@
{"eglReleaseThread","()Z", (void*)jni_eglReleaseThread },
{"getInitCount", "(" DISPLAY ")I", (void*)jni_getInitCount },
{"eglChooseConfig", "(" DISPLAY "[I[" CONFIG "I[I)Z", (void*)jni_eglChooseConfig },
-{"_eglCreateContext","(" DISPLAY CONFIG CONTEXT "[I)I", (void*)jni_eglCreateContext },
+{"_eglCreateContext","(" DISPLAY CONFIG CONTEXT "[I)J", (void*)jni_eglCreateContext },
{"eglGetConfigs", "(" DISPLAY "[" CONFIG "I[I)Z", (void*)jni_eglGetConfigs },
{"eglTerminate", "(" DISPLAY ")Z", (void*)jni_eglTerminate },
{"eglCopyBuffers", "(" DISPLAY SURFACE OBJECT ")Z", (void*)jni_eglCopyBuffers },
{"eglWaitNative", "(I" OBJECT ")Z", (void*)jni_eglWaitNative },
{"eglGetError", "()I", (void*)jni_eglGetError },
{"eglGetConfigAttrib", "(" DISPLAY CONFIG "I[I)Z", (void*)jni_eglGetConfigAttrib },
-{"_eglGetDisplay", "(" OBJECT ")I", (void*)jni_eglGetDisplay },
-{"_eglGetCurrentContext", "()I", (void*)jni_eglGetCurrentContext },
-{"_eglGetCurrentDisplay", "()I", (void*)jni_eglGetCurrentDisplay },
-{"_eglGetCurrentSurface", "(I)I", (void*)jni_eglGetCurrentSurface },
-{"_eglCreatePbufferSurface","(" DISPLAY CONFIG "[I)I", (void*)jni_eglCreatePbufferSurface },
+{"_eglGetDisplay", "(" OBJECT ")J", (void*)jni_eglGetDisplay },
+{"_eglGetCurrentContext", "()J", (void*)jni_eglGetCurrentContext },
+{"_eglGetCurrentDisplay", "()J", (void*)jni_eglGetCurrentDisplay },
+{"_eglGetCurrentSurface", "(I)J", (void*)jni_eglGetCurrentSurface },
+{"_eglCreatePbufferSurface","(" DISPLAY CONFIG "[I)J", (void*)jni_eglCreatePbufferSurface },
{"_eglCreatePixmapSurface", "(" SURFACE DISPLAY CONFIG OBJECT "[I)V", (void*)jni_eglCreatePixmapSurface },
-{"_eglCreateWindowSurface", "(" DISPLAY CONFIG OBJECT "[I)I", (void*)jni_eglCreateWindowSurface },
-{"_eglCreateWindowSurfaceTexture", "(" DISPLAY CONFIG OBJECT "[I)I", (void*)jni_eglCreateWindowSurfaceTexture },
+{"_eglCreateWindowSurface", "(" DISPLAY CONFIG OBJECT "[I)J", (void*)jni_eglCreateWindowSurface },
+{"_eglCreateWindowSurfaceTexture", "(" DISPLAY CONFIG OBJECT "[I)J", (void*)jni_eglCreateWindowSurfaceTexture },
{"eglDestroyContext", "(" DISPLAY CONTEXT ")Z", (void*)jni_eglDestroyContext },
{"eglDestroySurface", "(" DISPLAY SURFACE ")Z", (void*)jni_eglDestroySurface },
{"eglMakeCurrent", "(" DISPLAY SURFACE SURFACE CONTEXT")Z", (void*)jni_eglMakeCurrent },
diff --git a/core/jni/com_google_android_gles_jni_GLImpl.cpp b/core/jni/com_google_android_gles_jni_GLImpl.cpp
index b3b0049..7975987 100644
--- a/core/jni/com_google_android_gles_jni_GLImpl.cpp
+++ b/core/jni/com_google_android_gles_jni_GLImpl.cpp
@@ -129,7 +129,7 @@
getBasePointerID, buffer);
if (pointer != 0L) {
*array = NULL;
- return (void *) (jint) pointer;
+ return reinterpret_cast<void *>(pointer);
}
*array = (jarray) _env->CallStaticObjectMethod(nioAccessClass,
@@ -4359,7 +4359,7 @@
(GLint)size,
(GLenum)type,
(GLsizei)stride,
- (GLvoid *)offset
+ reinterpret_cast<GLvoid *>(offset)
);
}
@@ -4460,7 +4460,7 @@
(GLenum)mode,
(GLsizei)count,
(GLenum)type,
- (GLvoid *)offset
+ reinterpret_cast<GLvoid *>(offset)
);
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
@@ -6099,7 +6099,7 @@
glNormalPointer(
(GLenum)type,
(GLsizei)stride,
- (GLvoid *)offset
+ reinterpret_cast<GLvoid *>(offset)
);
}
@@ -6326,7 +6326,7 @@
(GLint)size,
(GLenum)type,
(GLsizei)stride,
- (GLvoid *)offset
+ reinterpret_cast<GLvoid *>(offset)
);
}
@@ -6756,7 +6756,7 @@
(GLint)size,
(GLenum)type,
(GLsizei)stride,
- (GLvoid *)offset
+ reinterpret_cast<GLvoid *>(offset)
);
}
@@ -7196,7 +7196,7 @@
(GLint)size,
(GLenum)type,
(GLsizei)stride,
- (GLvoid *)offset
+ reinterpret_cast<GLvoid *>(offset)
);
}
@@ -7232,7 +7232,7 @@
(GLint)size,
(GLenum)type,
(GLsizei)stride,
- (GLvoid *)offset
+ reinterpret_cast<GLvoid *>(offset)
);
}
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index b198937..8355928 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -1088,6 +1088,14 @@
android:label="@string/permlab_readPhoneState"
android:description="@string/permdesc_readPhoneState" />
+ <!-- Allows read only access to precise phone state.
+ @hide Pending API council approval -->
+ <permission android:name="android.permission.READ_PRECISE_PHONE_STATE"
+ android:permissionGroup="android.permission-group.PHONE_CALLS"
+ android:protectionLevel="dangerous"
+ android:label="@string/permlab_readPrecisePhoneState"
+ android:description="@string/permdesc_readPrecisePhoneState" />
+
<!-- Allows read access to privileged phone state.
@hide Used internally. -->
<permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE"
diff --git a/core/res/res/values/attrs_manifest.xml b/core/res/res/values/attrs_manifest.xml
index b20f5ba..4647413 100644
--- a/core/res/res/values/attrs_manifest.xml
+++ b/core/res/res/values/attrs_manifest.xml
@@ -1777,6 +1777,16 @@
<attr name="publicKey" />
</declare-styleable>
+ <!-- Attributes relating to resource overlay packages. -->
+ <declare-styleable name="AndroidManifestResourceOverlay" parent="AndroidManifest">
+ <!-- Package name of base package whose resources will be overlaid. -->
+ <attr name="targetPackage" />
+
+ <!-- Load order of overlay package. -->
+ <attr name="priority" />
+
+ </declare-styleable>
+
<!-- Declaration of an {@link android.content.Intent} object in XML. May
also include zero or more {@link #IntentCategory <category> and
{@link #Extra <extra>} tags. -->
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 9025400a..012fb83 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -1639,6 +1639,14 @@
connected by a call.</string>
<!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
+ <string name="permlab_readPrecisePhoneState">read precise phone states</string>
+ <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
+ <string name="permdesc_readPrecisePhoneState">Allows the app to access the precise
+ phone states. This permission allows the app to determine the real
+ call status, whether a call is active or in the background, call fails,
+ precise data connection status and data connection fails.</string>
+
+ <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
<string name="permlab_wakeLock" product="tablet">prevent tablet from sleeping</string>
<!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
<string name="permlab_wakeLock" product="default">prevent phone from sleeping</string>
@@ -4191,7 +4199,7 @@
<!-- Message shown when the user enters an invalid SIM pin password in PUK screen -->
<string name="kg_invalid_sim_pin_hint">Type a PIN that is 4 to 8 numbers.</string>
<!-- Message shown when the user enters an invalid PUK code in the PUK screen -->
- <string name="kg_invalid_sim_puk_hint">PUK code should be 8 numbers or more.</string>
+ <string name="kg_invalid_sim_puk_hint">PUK code should be 8 numbers.</string>
<!-- Message shown when the user enters an invalid PUK code -->
<string name="kg_invalid_puk">Re-enter the correct PUK code. Repeated attempts will permanently disable the SIM.</string>
<!-- String shown in PUK screen when PIN codes don't match -->
diff --git a/core/tests/coretests/src/android/util/JsonReaderTest.java b/core/tests/coretests/src/android/util/JsonReaderTest.java
deleted file mode 100644
index 42b7640..0000000
--- a/core/tests/coretests/src/android/util/JsonReaderTest.java
+++ /dev/null
@@ -1,909 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.util;
-
-import java.io.IOException;
-import java.io.StringReader;
-import java.util.Arrays;
-import junit.framework.TestCase;
-
-public final class JsonReaderTest extends TestCase {
-
- private static final int READER_BUFFER_SIZE = 1024;
-
- public void testReadArray() throws IOException {
- JsonReader reader = new JsonReader(new StringReader("[true, true]"));
- reader.beginArray();
- assertEquals(true, reader.nextBoolean());
- assertEquals(true, reader.nextBoolean());
- reader.endArray();
- assertEquals(JsonToken.END_DOCUMENT, reader.peek());
- }
-
- public void testReadEmptyArray() throws IOException {
- JsonReader reader = new JsonReader(new StringReader("[]"));
- reader.beginArray();
- assertFalse(reader.hasNext());
- reader.endArray();
- assertEquals(JsonToken.END_DOCUMENT, reader.peek());
- }
-
- public void testReadObject() throws IOException {
- JsonReader reader = new JsonReader(new StringReader(
- "{\"a\": \"android\", \"b\": \"banana\"}"));
- reader.beginObject();
- assertEquals("a", reader.nextName());
- assertEquals("android", reader.nextString());
- assertEquals("b", reader.nextName());
- assertEquals("banana", reader.nextString());
- reader.endObject();
- assertEquals(JsonToken.END_DOCUMENT, reader.peek());
- }
-
- public void testReadEmptyObject() throws IOException {
- JsonReader reader = new JsonReader(new StringReader("{}"));
- reader.beginObject();
- assertFalse(reader.hasNext());
- reader.endObject();
- assertEquals(JsonToken.END_DOCUMENT, reader.peek());
- }
-
- public void testSkipObject() throws IOException {
- JsonReader reader = new JsonReader(new StringReader(
- "{\"a\": { \"c\": [], \"d\": [true, true, {}] }, \"b\": \"banana\"}"));
- reader.beginObject();
- assertEquals("a", reader.nextName());
- reader.skipValue();
- assertEquals("b", reader.nextName());
- reader.skipValue();
- reader.endObject();
- assertEquals(JsonToken.END_DOCUMENT, reader.peek());
- }
-
- public void testHelloWorld() throws IOException {
- String json = "{\n" +
- " \"hello\": true,\n" +
- " \"foo\": [\"world\"]\n" +
- "}";
- JsonReader reader = new JsonReader(new StringReader(json));
- reader.beginObject();
- assertEquals("hello", reader.nextName());
- assertEquals(true, reader.nextBoolean());
- assertEquals("foo", reader.nextName());
- reader.beginArray();
- assertEquals("world", reader.nextString());
- reader.endArray();
- reader.endObject();
- assertEquals(JsonToken.END_DOCUMENT, reader.peek());
- }
-
- public void testNulls() {
- try {
- new JsonReader(null);
- fail();
- } catch (NullPointerException expected) {
- }
- }
-
- public void testEmptyString() throws IOException {
- try {
- new JsonReader(new StringReader("")).beginArray();
- } catch (IOException expected) {
- }
- try {
- new JsonReader(new StringReader("")).beginObject();
- } catch (IOException expected) {
- }
- }
-
- public void testNoTopLevelObject() throws IOException {
- try {
- new JsonReader(new StringReader("true")).nextBoolean();
- } catch (IOException expected) {
- }
- }
-
- public void testCharacterUnescaping() throws IOException {
- String json = "[\"a\","
- + "\"a\\\"\","
- + "\"\\\"\","
- + "\":\","
- + "\",\","
- + "\"\\b\","
- + "\"\\f\","
- + "\"\\n\","
- + "\"\\r\","
- + "\"\\t\","
- + "\" \","
- + "\"\\\\\","
- + "\"{\","
- + "\"}\","
- + "\"[\","
- + "\"]\","
- + "\"\\u0000\","
- + "\"\\u0019\","
- + "\"\\u20AC\""
- + "]";
- JsonReader reader = new JsonReader(new StringReader(json));
- reader.beginArray();
- assertEquals("a", reader.nextString());
- assertEquals("a\"", reader.nextString());
- assertEquals("\"", reader.nextString());
- assertEquals(":", reader.nextString());
- assertEquals(",", reader.nextString());
- assertEquals("\b", reader.nextString());
- assertEquals("\f", reader.nextString());
- assertEquals("\n", reader.nextString());
- assertEquals("\r", reader.nextString());
- assertEquals("\t", reader.nextString());
- assertEquals(" ", reader.nextString());
- assertEquals("\\", reader.nextString());
- assertEquals("{", reader.nextString());
- assertEquals("}", reader.nextString());
- assertEquals("[", reader.nextString());
- assertEquals("]", reader.nextString());
- assertEquals("\0", reader.nextString());
- assertEquals("\u0019", reader.nextString());
- assertEquals("\u20AC", reader.nextString());
- reader.endArray();
- assertEquals(JsonToken.END_DOCUMENT, reader.peek());
- }
-
- public void testIntegersWithFractionalPartSpecified() throws IOException {
- JsonReader reader = new JsonReader(new StringReader("[1.0,1.0,1.0]"));
- reader.beginArray();
- assertEquals(1.0, reader.nextDouble());
- assertEquals(1, reader.nextInt());
- assertEquals(1L, reader.nextLong());
- }
-
- public void testDoubles() throws IOException {
- String json = "[-0.0,"
- + "1.0,"
- + "1.7976931348623157E308,"
- + "4.9E-324,"
- + "0.0,"
- + "-0.5,"
- + "2.2250738585072014E-308,"
- + "3.141592653589793,"
- + "2.718281828459045,"
- + "\"1.0\","
- + "\"011.0\","
- + "\"NaN\","
- + "\"Infinity\","
- + "\"-Infinity\""
- + "]";
- JsonReader reader = new JsonReader(new StringReader(json));
- reader.beginArray();
- assertEquals(-0.0, reader.nextDouble());
- assertEquals(1.0, reader.nextDouble());
- assertEquals(1.7976931348623157E308, reader.nextDouble());
- assertEquals(4.9E-324, reader.nextDouble());
- assertEquals(0.0, reader.nextDouble());
- assertEquals(-0.5, reader.nextDouble());
- assertEquals(2.2250738585072014E-308, reader.nextDouble());
- assertEquals(3.141592653589793, reader.nextDouble());
- assertEquals(2.718281828459045, reader.nextDouble());
- assertEquals(1,0, reader.nextDouble());
- assertEquals(11.0, reader.nextDouble());
- assertTrue(Double.isNaN(reader.nextDouble()));
- assertEquals(Double.POSITIVE_INFINITY, reader.nextDouble());
- assertEquals(Double.NEGATIVE_INFINITY, reader.nextDouble());
- reader.endArray();
- assertEquals(JsonToken.END_DOCUMENT, reader.peek());
- }
-
- public void testLenientDoubles() throws IOException {
- String json = "["
- + "011.0,"
- + "NaN,"
- + "NAN,"
- + "Infinity,"
- + "INFINITY,"
- + "-Infinity"
- + "]";
- JsonReader reader = new JsonReader(new StringReader(json));
- reader.setLenient(true);
- reader.beginArray();
- assertEquals(11.0, reader.nextDouble());
- assertTrue(Double.isNaN(reader.nextDouble()));
- try {
- reader.nextDouble();
- fail();
- } catch (NumberFormatException expected) {
- }
- assertEquals("NAN", reader.nextString());
- assertEquals(Double.POSITIVE_INFINITY, reader.nextDouble());
- try {
- reader.nextDouble();
- fail();
- } catch (NumberFormatException expected) {
- }
- assertEquals("INFINITY", reader.nextString());
- assertEquals(Double.NEGATIVE_INFINITY, reader.nextDouble());
- reader.endArray();
- assertEquals(JsonToken.END_DOCUMENT, reader.peek());
- }
-
- public void testBufferBoundary() throws IOException {
- char[] pad = new char[READER_BUFFER_SIZE - 8];
- Arrays.fill(pad, '5');
- String json = "[\"" + new String(pad) + "\",33333]";
- JsonReader reader = new JsonReader(new StringReader(json));
- reader.beginArray();
- assertEquals(JsonToken.STRING, reader.peek());
- assertEquals(new String(pad), reader.nextString());
- assertEquals(JsonToken.NUMBER, reader.peek());
- assertEquals(33333, reader.nextInt());
- }
-
- public void testTruncatedBufferBoundary() throws IOException {
- char[] pad = new char[READER_BUFFER_SIZE - 8];
- Arrays.fill(pad, '5');
- String json = "[\"" + new String(pad) + "\",33333";
- JsonReader reader = new JsonReader(new StringReader(json));
- reader.setLenient(true);
- reader.beginArray();
- assertEquals(JsonToken.STRING, reader.peek());
- assertEquals(new String(pad), reader.nextString());
- assertEquals(JsonToken.NUMBER, reader.peek());
- assertEquals(33333, reader.nextInt());
- try {
- reader.endArray();
- fail();
- } catch (IOException e) {
- }
- }
-
- public void testLongestSupportedNumericLiterals() throws IOException {
- testLongNumericLiterals(READER_BUFFER_SIZE - 1, JsonToken.NUMBER);
- }
-
- public void testLongerNumericLiterals() throws IOException {
- testLongNumericLiterals(READER_BUFFER_SIZE, JsonToken.STRING);
- }
-
- private void testLongNumericLiterals(int length, JsonToken expectedToken) throws IOException {
- char[] longNumber = new char[length];
- Arrays.fill(longNumber, '9');
- longNumber[0] = '1';
- longNumber[1] = '.';
-
- String json = "[" + new String(longNumber) + "]";
- JsonReader reader = new JsonReader(new StringReader(json));
- reader.setLenient(true);
- reader.beginArray();
- assertEquals(expectedToken, reader.peek());
- assertEquals(2.0d, reader.nextDouble());
- reader.endArray();
- }
-
- public void testLongs() throws IOException {
- String json = "[0,0,0,"
- + "1,1,1,"
- + "-1,-1,-1,"
- + "-9223372036854775808,"
- + "9223372036854775807,"
- + "5.0,"
- + "1.0e2,"
- + "\"011\","
- + "\"5.0\","
- + "\"1.0e2\""
- + "]";
- JsonReader reader = new JsonReader(new StringReader(json));
- reader.beginArray();
- assertEquals(0L, reader.nextLong());
- assertEquals(0, reader.nextInt());
- assertEquals(0.0, reader.nextDouble());
- assertEquals(1L, reader.nextLong());
- assertEquals(1, reader.nextInt());
- assertEquals(1.0, reader.nextDouble());
- assertEquals(-1L, reader.nextLong());
- assertEquals(-1, reader.nextInt());
- assertEquals(-1.0, reader.nextDouble());
- try {
- reader.nextInt();
- fail();
- } catch (NumberFormatException expected) {
- }
- assertEquals(Long.MIN_VALUE, reader.nextLong());
- try {
- reader.nextInt();
- fail();
- } catch (NumberFormatException expected) {
- }
- assertEquals(Long.MAX_VALUE, reader.nextLong());
- assertEquals(5, reader.nextLong());
- assertEquals(100, reader.nextLong());
- assertEquals(11, reader.nextLong());
- assertEquals(5, reader.nextLong());
- assertEquals(100, reader.nextLong());
- reader.endArray();
- assertEquals(JsonToken.END_DOCUMENT, reader.peek());
- }
-
- /**
- * This test fails because there's no double for 9223372036854775806, and
- * our long parsing uses Double.parseDouble() for fractional values.
- */
- public void testHighPrecisionLong() throws IOException {
- String json = "[9223372036854775806.000]";
- JsonReader reader = new JsonReader(new StringReader(json));
- reader.beginArray();
- assertEquals(9223372036854775806L, reader.nextLong());
- reader.endArray();
- }
-
- public void testMatchingValidNumbers() throws IOException {
- String json = "[-1,99,-0,0,0e1,0e+1,0e-1,0E1,0E+1,0E-1,0.0,1.0,-1.0,1.0e0,1.0e+1,1.0e-1]";
- JsonReader reader = new JsonReader(new StringReader(json));
- reader.beginArray();
- for (int i = 0; i < 16; i++) {
- assertEquals(JsonToken.NUMBER, reader.peek());
- reader.nextDouble();
- }
- reader.endArray();
- }
-
- public void testRecognizingInvalidNumbers() throws IOException {
- String json = "[-00,00,001,+1,1f,0x,0xf,0x0,0f1,0ee1,1..0,1e0.1,1.-01,1.+1,1.0x,1.0+]";
- JsonReader reader = new JsonReader(new StringReader(json));
- reader.setLenient(true);
- reader.beginArray();
- for (int i = 0; i < 16; i++) {
- assertEquals(JsonToken.STRING, reader.peek());
- reader.nextString();
- }
- reader.endArray();
- }
-
- public void testNonFiniteDouble() throws IOException {
- String json = "[NaN]";
- JsonReader reader = new JsonReader(new StringReader(json));
- reader.beginArray();
- try {
- reader.nextDouble();
- fail();
- } catch (IOException expected) {
- }
- }
-
- public void testNumberWithHexPrefix() throws IOException {
- String json = "[0x11]";
- JsonReader reader = new JsonReader(new StringReader(json));
- reader.beginArray();
- try {
- reader.nextLong();
- fail();
- } catch (IOException expected) {
- }
- }
-
- public void testNumberWithOctalPrefix() throws IOException {
- String json = "[01]";
- JsonReader reader = new JsonReader(new StringReader(json));
- reader.beginArray();
- try {
- reader.nextInt();
- fail();
- } catch (IOException expected) {
- }
- }
-
- public void testBooleans() throws IOException {
- JsonReader reader = new JsonReader(new StringReader("[true,false]"));
- reader.beginArray();
- assertEquals(true, reader.nextBoolean());
- assertEquals(false, reader.nextBoolean());
- reader.endArray();
- assertEquals(JsonToken.END_DOCUMENT, reader.peek());
- }
-
- public void testMixedCaseLiterals() throws IOException {
- JsonReader reader = new JsonReader(new StringReader("[True,TruE,False,FALSE,NULL,nulL]"));
- reader.beginArray();
- assertEquals(true, reader.nextBoolean());
- assertEquals(true, reader.nextBoolean());
- assertEquals(false, reader.nextBoolean());
- assertEquals(false, reader.nextBoolean());
- reader.nextNull();
- reader.nextNull();
- reader.endArray();
- assertEquals(JsonToken.END_DOCUMENT, reader.peek());
- }
-
- public void testMissingValue() throws IOException {
- JsonReader reader = new JsonReader(new StringReader("{\"a\":}"));
- reader.beginObject();
- assertEquals("a", reader.nextName());
- try {
- reader.nextString();
- fail();
- } catch (IOException expected) {
- }
- }
-
- public void testPrematureEndOfInput() throws IOException {
- JsonReader reader = new JsonReader(new StringReader("{\"a\":true,"));
- reader.beginObject();
- assertEquals("a", reader.nextName());
- assertEquals(true, reader.nextBoolean());
- try {
- reader.nextName();
- fail();
- } catch (IOException expected) {
- }
- }
-
- public void testPrematurelyClosed() throws IOException {
- try {
- JsonReader reader = new JsonReader(new StringReader("{\"a\":[]}"));
- reader.beginObject();
- reader.close();
- reader.nextName();
- fail();
- } catch (IllegalStateException expected) {
- }
-
- try {
- JsonReader reader = new JsonReader(new StringReader("{\"a\":[]}"));
- reader.close();
- reader.beginObject();
- fail();
- } catch (IllegalStateException expected) {
- }
-
- try {
- JsonReader reader = new JsonReader(new StringReader("{\"a\":true}"));
- reader.beginObject();
- reader.nextName();
- reader.peek();
- reader.close();
- reader.nextBoolean();
- fail();
- } catch (IllegalStateException expected) {
- }
- }
-
- public void testNextFailuresDoNotAdvance() throws IOException {
- JsonReader reader = new JsonReader(new StringReader("{\"a\":true}"));
- reader.beginObject();
- try {
- reader.nextString();
- fail();
- } catch (IllegalStateException expected) {
- }
- assertEquals("a", reader.nextName());
- try {
- reader.nextName();
- fail();
- } catch (IllegalStateException expected) {
- }
- try {
- reader.beginArray();
- fail();
- } catch (IllegalStateException expected) {
- }
- try {
- reader.endArray();
- fail();
- } catch (IllegalStateException expected) {
- }
- try {
- reader.beginObject();
- fail();
- } catch (IllegalStateException expected) {
- }
- try {
- reader.endObject();
- fail();
- } catch (IllegalStateException expected) {
- }
- assertEquals(true, reader.nextBoolean());
- try {
- reader.nextString();
- fail();
- } catch (IllegalStateException expected) {
- }
- try {
- reader.nextName();
- fail();
- } catch (IllegalStateException expected) {
- }
- try {
- reader.beginArray();
- fail();
- } catch (IllegalStateException expected) {
- }
- try {
- reader.endArray();
- fail();
- } catch (IllegalStateException expected) {
- }
- reader.endObject();
- assertEquals(JsonToken.END_DOCUMENT, reader.peek());
- reader.close();
- }
-
- public void testStringNullIsNotNull() throws IOException {
- JsonReader reader = new JsonReader(new StringReader("[\"null\"]"));
- reader.beginArray();
- try {
- reader.nextNull();
- fail();
- } catch (IllegalStateException expected) {
- }
- }
-
- public void testNullLiteralIsNotAString() throws IOException {
- JsonReader reader = new JsonReader(new StringReader("[null]"));
- reader.beginArray();
- try {
- reader.nextString();
- fail();
- } catch (IllegalStateException expected) {
- }
- }
-
- public void testStrictNameValueSeparator() throws IOException {
- JsonReader reader = new JsonReader(new StringReader("{\"a\"=true}"));
- reader.beginObject();
- assertEquals("a", reader.nextName());
- try {
- reader.nextBoolean();
- fail();
- } catch (IOException expected) {
- }
-
- reader = new JsonReader(new StringReader("{\"a\"=>true}"));
- reader.beginObject();
- assertEquals("a", reader.nextName());
- try {
- reader.nextBoolean();
- fail();
- } catch (IOException expected) {
- }
- }
-
- public void testLenientNameValueSeparator() throws IOException {
- JsonReader reader = new JsonReader(new StringReader("{\"a\"=true}"));
- reader.setLenient(true);
- reader.beginObject();
- assertEquals("a", reader.nextName());
- assertEquals(true, reader.nextBoolean());
-
- reader = new JsonReader(new StringReader("{\"a\"=>true}"));
- reader.setLenient(true);
- reader.beginObject();
- assertEquals("a", reader.nextName());
- assertEquals(true, reader.nextBoolean());
- }
-
- public void testStrictComments() throws IOException {
- JsonReader reader = new JsonReader(new StringReader("[// comment \n true]"));
- reader.beginArray();
- try {
- reader.nextBoolean();
- fail();
- } catch (IOException expected) {
- }
-
- reader = new JsonReader(new StringReader("[# comment \n true]"));
- reader.beginArray();
- try {
- reader.nextBoolean();
- fail();
- } catch (IOException expected) {
- }
-
- reader = new JsonReader(new StringReader("[/* comment */ true]"));
- reader.beginArray();
- try {
- reader.nextBoolean();
- fail();
- } catch (IOException expected) {
- }
- }
-
- public void testLenientComments() throws IOException {
- JsonReader reader = new JsonReader(new StringReader("[// comment \n true]"));
- reader.setLenient(true);
- reader.beginArray();
- assertEquals(true, reader.nextBoolean());
-
- reader = new JsonReader(new StringReader("[# comment \n true]"));
- reader.setLenient(true);
- reader.beginArray();
- assertEquals(true, reader.nextBoolean());
-
- reader = new JsonReader(new StringReader("[/* comment */ true]"));
- reader.setLenient(true);
- reader.beginArray();
- assertEquals(true, reader.nextBoolean());
- }
-
- public void testStrictUnquotedNames() throws IOException {
- JsonReader reader = new JsonReader(new StringReader("{a:true}"));
- reader.beginObject();
- try {
- reader.nextName();
- fail();
- } catch (IOException expected) {
- }
- }
-
- public void testLenientUnquotedNames() throws IOException {
- JsonReader reader = new JsonReader(new StringReader("{a:true}"));
- reader.setLenient(true);
- reader.beginObject();
- assertEquals("a", reader.nextName());
- }
-
- public void testStrictSingleQuotedNames() throws IOException {
- JsonReader reader = new JsonReader(new StringReader("{'a':true}"));
- reader.beginObject();
- try {
- reader.nextName();
- fail();
- } catch (IOException expected) {
- }
- }
-
- public void testLenientSingleQuotedNames() throws IOException {
- JsonReader reader = new JsonReader(new StringReader("{'a':true}"));
- reader.setLenient(true);
- reader.beginObject();
- assertEquals("a", reader.nextName());
- }
-
- public void testStrictUnquotedStrings() throws IOException {
- JsonReader reader = new JsonReader(new StringReader("[a]"));
- reader.beginArray();
- try {
- reader.nextString();
- fail();
- } catch (MalformedJsonException expected) {
- }
- }
-
- public void testLenientUnquotedStrings() throws IOException {
- JsonReader reader = new JsonReader(new StringReader("[a]"));
- reader.setLenient(true);
- reader.beginArray();
- assertEquals("a", reader.nextString());
- }
-
- public void testStrictSingleQuotedStrings() throws IOException {
- JsonReader reader = new JsonReader(new StringReader("['a']"));
- reader.beginArray();
- try {
- reader.nextString();
- fail();
- } catch (IOException expected) {
- }
- }
-
- public void testLenientSingleQuotedStrings() throws IOException {
- JsonReader reader = new JsonReader(new StringReader("['a']"));
- reader.setLenient(true);
- reader.beginArray();
- assertEquals("a", reader.nextString());
- }
-
- public void testStrictSemicolonDelimitedArray() throws IOException {
- JsonReader reader = new JsonReader(new StringReader("[true;true]"));
- reader.beginArray();
- try {
- reader.nextBoolean();
- reader.nextBoolean();
- fail();
- } catch (IOException expected) {
- }
- }
-
- public void testLenientSemicolonDelimitedArray() throws IOException {
- JsonReader reader = new JsonReader(new StringReader("[true;true]"));
- reader.setLenient(true);
- reader.beginArray();
- assertEquals(true, reader.nextBoolean());
- assertEquals(true, reader.nextBoolean());
- }
-
- public void testStrictSemicolonDelimitedNameValuePair() throws IOException {
- JsonReader reader = new JsonReader(new StringReader("{\"a\":true;\"b\":true}"));
- reader.beginObject();
- assertEquals("a", reader.nextName());
- try {
- reader.nextBoolean();
- reader.nextName();
- fail();
- } catch (IOException expected) {
- }
- }
-
- public void testLenientSemicolonDelimitedNameValuePair() throws IOException {
- JsonReader reader = new JsonReader(new StringReader("{\"a\":true;\"b\":true}"));
- reader.setLenient(true);
- reader.beginObject();
- assertEquals("a", reader.nextName());
- assertEquals(true, reader.nextBoolean());
- assertEquals("b", reader.nextName());
- }
-
- public void testStrictUnnecessaryArraySeparators() throws IOException {
- JsonReader reader = new JsonReader(new StringReader("[true,,true]"));
- reader.beginArray();
- assertEquals(true, reader.nextBoolean());
- try {
- reader.nextNull();
- fail();
- } catch (IOException expected) {
- }
-
- reader = new JsonReader(new StringReader("[,true]"));
- reader.beginArray();
- try {
- reader.nextNull();
- fail();
- } catch (IOException expected) {
- }
-
- reader = new JsonReader(new StringReader("[true,]"));
- reader.beginArray();
- assertEquals(true, reader.nextBoolean());
- try {
- reader.nextNull();
- fail();
- } catch (IOException expected) {
- }
-
- reader = new JsonReader(new StringReader("[,]"));
- reader.beginArray();
- try {
- reader.nextNull();
- fail();
- } catch (IOException expected) {
- }
- }
-
- public void testLenientUnnecessaryArraySeparators() throws IOException {
- JsonReader reader = new JsonReader(new StringReader("[true,,true]"));
- reader.setLenient(true);
- reader.beginArray();
- assertEquals(true, reader.nextBoolean());
- reader.nextNull();
- assertEquals(true, reader.nextBoolean());
- reader.endArray();
-
- reader = new JsonReader(new StringReader("[,true]"));
- reader.setLenient(true);
- reader.beginArray();
- reader.nextNull();
- assertEquals(true, reader.nextBoolean());
- reader.endArray();
-
- reader = new JsonReader(new StringReader("[true,]"));
- reader.setLenient(true);
- reader.beginArray();
- assertEquals(true, reader.nextBoolean());
- reader.nextNull();
- reader.endArray();
-
- reader = new JsonReader(new StringReader("[,]"));
- reader.setLenient(true);
- reader.beginArray();
- reader.nextNull();
- reader.nextNull();
- reader.endArray();
- }
-
- public void testStrictMultipleTopLevelValues() throws IOException {
- JsonReader reader = new JsonReader(new StringReader("[] []"));
- reader.beginArray();
- reader.endArray();
- try {
- reader.peek();
- fail();
- } catch (IOException expected) {
- }
- }
-
- public void testLenientMultipleTopLevelValues() throws IOException {
- JsonReader reader = new JsonReader(new StringReader("[] true {}"));
- reader.setLenient(true);
- reader.beginArray();
- reader.endArray();
- assertEquals(true, reader.nextBoolean());
- reader.beginObject();
- reader.endObject();
- assertEquals(JsonToken.END_DOCUMENT, reader.peek());
- }
-
- public void testStrictTopLevelValueType() {
- JsonReader reader = new JsonReader(new StringReader("true"));
- try {
- reader.nextBoolean();
- fail();
- } catch (IOException expected) {
- }
- }
-
- public void testLenientTopLevelValueType() throws IOException {
- JsonReader reader = new JsonReader(new StringReader("true"));
- reader.setLenient(true);
- assertEquals(true, reader.nextBoolean());
- }
-
- public void testStrictNonExecutePrefix() {
- JsonReader reader = new JsonReader(new StringReader(")]}'\n []"));
- try {
- reader.beginArray();
- fail();
- } catch (IOException expected) {
- }
- }
-
- public void testBomIgnoredAsFirstCharacterOfDocument() throws IOException {
- JsonReader reader = new JsonReader(new StringReader("\ufeff[]"));
- reader.beginArray();
- reader.endArray();
- }
-
- public void testBomForbiddenAsOtherCharacterInDocument() throws IOException {
- JsonReader reader = new JsonReader(new StringReader("[\ufeff]"));
- reader.beginArray();
- try {
- reader.endArray();
- fail();
- } catch (IOException expected) {
- }
- }
-
- public void testFailWithPosition() throws IOException {
- testFailWithPosition("Expected literal value at line 6 column 3",
- "[\n\n\n\n\n0,}]");
- }
-
- public void testFailWithPositionIsOffsetByBom() throws IOException {
- testFailWithPosition("Expected literal value at line 1 column 4",
- "\ufeff[0,}]");
- }
-
- public void testFailWithPositionGreaterThanBufferSize() throws IOException {
- String spaces = repeat(' ', 8192);
- testFailWithPosition("Expected literal value at line 6 column 3",
- "[\n\n" + spaces + "\n\n\n0,}]");
- }
-
- private void testFailWithPosition(String message, String json) throws IOException {
- JsonReader reader = new JsonReader(new StringReader(json));
- reader.beginArray();
- reader.nextInt();
- try {
- reader.peek();
- fail();
- } catch (IOException expected) {
- assertEquals(message, expected.getMessage());
- }
- }
-
- private String repeat(char c, int count) {
- char[] array = new char[count];
- Arrays.fill(array, c);
- return new String(array);
- }
-}
diff --git a/core/tests/coretests/src/android/util/JsonWriterTest.java b/core/tests/coretests/src/android/util/JsonWriterTest.java
deleted file mode 100644
index 1239a3c..0000000
--- a/core/tests/coretests/src/android/util/JsonWriterTest.java
+++ /dev/null
@@ -1,466 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.util;
-
-import java.io.IOException;
-import java.io.StringWriter;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import junit.framework.TestCase;
-
-public final class JsonWriterTest extends TestCase {
-
- public void testWrongTopLevelType() throws IOException {
- StringWriter stringWriter = new StringWriter();
- JsonWriter jsonWriter = new JsonWriter(stringWriter);
- try {
- jsonWriter.value("a");
- fail();
- } catch (IllegalStateException expected) {
- }
- }
-
- public void testTwoNames() throws IOException {
- StringWriter stringWriter = new StringWriter();
- JsonWriter jsonWriter = new JsonWriter(stringWriter);
- jsonWriter.beginObject();
- jsonWriter.name("a");
- try {
- jsonWriter.name("a");
- fail();
- } catch (IllegalStateException expected) {
- }
- }
-
- public void testNameWithoutValue() throws IOException {
- StringWriter stringWriter = new StringWriter();
- JsonWriter jsonWriter = new JsonWriter(stringWriter);
- jsonWriter.beginObject();
- jsonWriter.name("a");
- try {
- jsonWriter.endObject();
- fail();
- } catch (IllegalStateException expected) {
- }
- }
-
- public void testValueWithoutName() throws IOException {
- StringWriter stringWriter = new StringWriter();
- JsonWriter jsonWriter = new JsonWriter(stringWriter);
- jsonWriter.beginObject();
- try {
- jsonWriter.value(true);
- fail();
- } catch (IllegalStateException expected) {
- }
- }
-
- public void testMultipleTopLevelValues() throws IOException {
- StringWriter stringWriter = new StringWriter();
- JsonWriter jsonWriter = new JsonWriter(stringWriter);
- jsonWriter.beginArray().endArray();
- try {
- jsonWriter.beginArray();
- fail();
- } catch (IllegalStateException expected) {
- }
- }
-
- public void testBadNestingObject() throws IOException {
- StringWriter stringWriter = new StringWriter();
- JsonWriter jsonWriter = new JsonWriter(stringWriter);
- jsonWriter.beginArray();
- jsonWriter.beginObject();
- try {
- jsonWriter.endArray();
- fail();
- } catch (IllegalStateException expected) {
- }
- }
-
- public void testBadNestingArray() throws IOException {
- StringWriter stringWriter = new StringWriter();
- JsonWriter jsonWriter = new JsonWriter(stringWriter);
- jsonWriter.beginArray();
- jsonWriter.beginArray();
- try {
- jsonWriter.endObject();
- fail();
- } catch (IllegalStateException expected) {
- }
- }
-
- public void testNullName() throws IOException {
- StringWriter stringWriter = new StringWriter();
- JsonWriter jsonWriter = new JsonWriter(stringWriter);
- jsonWriter.beginObject();
- try {
- jsonWriter.name(null);
- fail();
- } catch (NullPointerException expected) {
- }
- }
-
- public void testNullStringValue() throws IOException {
- StringWriter stringWriter = new StringWriter();
- JsonWriter jsonWriter = new JsonWriter(stringWriter);
- jsonWriter.beginObject();
- jsonWriter.name("a");
- jsonWriter.value((String) null);
- jsonWriter.endObject();
- assertEquals("{\"a\":null}", stringWriter.toString());
- }
-
- public void testNonFiniteDoubles() throws IOException {
- StringWriter stringWriter = new StringWriter();
- JsonWriter jsonWriter = new JsonWriter(stringWriter);
- jsonWriter.beginArray();
- try {
- jsonWriter.value(Double.NaN);
- fail();
- } catch (IllegalArgumentException expected) {
- }
- try {
- jsonWriter.value(Double.NEGATIVE_INFINITY);
- fail();
- } catch (IllegalArgumentException expected) {
- }
- try {
- jsonWriter.value(Double.POSITIVE_INFINITY);
- fail();
- } catch (IllegalArgumentException expected) {
- }
- }
-
- public void testNonFiniteBoxedDoubles() throws IOException {
- StringWriter stringWriter = new StringWriter();
- JsonWriter jsonWriter = new JsonWriter(stringWriter);
- jsonWriter.beginArray();
- try {
- jsonWriter.value(new Double(Double.NaN));
- fail();
- } catch (IllegalArgumentException expected) {
- }
- try {
- jsonWriter.value(new Double(Double.NEGATIVE_INFINITY));
- fail();
- } catch (IllegalArgumentException expected) {
- }
- try {
- jsonWriter.value(new Double(Double.POSITIVE_INFINITY));
- fail();
- } catch (IllegalArgumentException expected) {
- }
- }
-
- public void testDoubles() throws IOException {
- StringWriter stringWriter = new StringWriter();
- JsonWriter jsonWriter = new JsonWriter(stringWriter);
- jsonWriter.beginArray();
- jsonWriter.value(-0.0);
- jsonWriter.value(1.0);
- jsonWriter.value(Double.MAX_VALUE);
- jsonWriter.value(Double.MIN_VALUE);
- jsonWriter.value(0.0);
- jsonWriter.value(-0.5);
- jsonWriter.value(Double.MIN_NORMAL);
- jsonWriter.value(Math.PI);
- jsonWriter.value(Math.E);
- jsonWriter.endArray();
- jsonWriter.close();
- assertEquals("[-0.0,"
- + "1.0,"
- + "1.7976931348623157E308,"
- + "4.9E-324,"
- + "0.0,"
- + "-0.5,"
- + "2.2250738585072014E-308,"
- + "3.141592653589793,"
- + "2.718281828459045]", stringWriter.toString());
- }
-
- public void testLongs() throws IOException {
- StringWriter stringWriter = new StringWriter();
- JsonWriter jsonWriter = new JsonWriter(stringWriter);
- jsonWriter.beginArray();
- jsonWriter.value(0);
- jsonWriter.value(1);
- jsonWriter.value(-1);
- jsonWriter.value(Long.MIN_VALUE);
- jsonWriter.value(Long.MAX_VALUE);
- jsonWriter.endArray();
- jsonWriter.close();
- assertEquals("[0,"
- + "1,"
- + "-1,"
- + "-9223372036854775808,"
- + "9223372036854775807]", stringWriter.toString());
- }
-
- public void testNumbers() throws IOException {
- StringWriter stringWriter = new StringWriter();
- JsonWriter jsonWriter = new JsonWriter(stringWriter);
- jsonWriter.beginArray();
- jsonWriter.value(new BigInteger("0"));
- jsonWriter.value(new BigInteger("9223372036854775808"));
- jsonWriter.value(new BigInteger("-9223372036854775809"));
- jsonWriter.value(new BigDecimal("3.141592653589793238462643383"));
- jsonWriter.endArray();
- jsonWriter.close();
- assertEquals("[0,"
- + "9223372036854775808,"
- + "-9223372036854775809,"
- + "3.141592653589793238462643383]", stringWriter.toString());
- }
-
- public void testBooleans() throws IOException {
- StringWriter stringWriter = new StringWriter();
- JsonWriter jsonWriter = new JsonWriter(stringWriter);
- jsonWriter.beginArray();
- jsonWriter.value(true);
- jsonWriter.value(false);
- jsonWriter.endArray();
- assertEquals("[true,false]", stringWriter.toString());
- }
-
- public void testNulls() throws IOException {
- StringWriter stringWriter = new StringWriter();
- JsonWriter jsonWriter = new JsonWriter(stringWriter);
- jsonWriter.beginArray();
- jsonWriter.nullValue();
- jsonWriter.endArray();
- assertEquals("[null]", stringWriter.toString());
- }
-
- public void testStrings() throws IOException {
- StringWriter stringWriter = new StringWriter();
- JsonWriter jsonWriter = new JsonWriter(stringWriter);
- jsonWriter.beginArray();
- jsonWriter.value("a");
- jsonWriter.value("a\"");
- jsonWriter.value("\"");
- jsonWriter.value(":");
- jsonWriter.value(",");
- jsonWriter.value("\b");
- jsonWriter.value("\f");
- jsonWriter.value("\n");
- jsonWriter.value("\r");
- jsonWriter.value("\t");
- jsonWriter.value(" ");
- jsonWriter.value("\\");
- jsonWriter.value("{");
- jsonWriter.value("}");
- jsonWriter.value("[");
- jsonWriter.value("]");
- jsonWriter.value("\0");
- jsonWriter.value("\u0019");
- jsonWriter.endArray();
- assertEquals("[\"a\","
- + "\"a\\\"\","
- + "\"\\\"\","
- + "\":\","
- + "\",\","
- + "\"\\b\","
- + "\"\\f\","
- + "\"\\n\","
- + "\"\\r\","
- + "\"\\t\","
- + "\" \","
- + "\"\\\\\","
- + "\"{\","
- + "\"}\","
- + "\"[\","
- + "\"]\","
- + "\"\\u0000\","
- + "\"\\u0019\"]", stringWriter.toString());
- }
-
- public void testUnicodeLineBreaksEscaped() throws IOException {
- StringWriter stringWriter = new StringWriter();
- JsonWriter jsonWriter = new JsonWriter(stringWriter);
- jsonWriter.beginArray();
- jsonWriter.value("\u2028 \u2029");
- jsonWriter.endArray();
- assertEquals("[\"\\u2028 \\u2029\"]", stringWriter.toString());
- }
-
- public void testEmptyArray() throws IOException {
- StringWriter stringWriter = new StringWriter();
- JsonWriter jsonWriter = new JsonWriter(stringWriter);
- jsonWriter.beginArray();
- jsonWriter.endArray();
- assertEquals("[]", stringWriter.toString());
- }
-
- public void testEmptyObject() throws IOException {
- StringWriter stringWriter = new StringWriter();
- JsonWriter jsonWriter = new JsonWriter(stringWriter);
- jsonWriter.beginObject();
- jsonWriter.endObject();
- assertEquals("{}", stringWriter.toString());
- }
-
- public void testObjectsInArrays() throws IOException {
- StringWriter stringWriter = new StringWriter();
- JsonWriter jsonWriter = new JsonWriter(stringWriter);
- jsonWriter.beginArray();
- jsonWriter.beginObject();
- jsonWriter.name("a").value(5);
- jsonWriter.name("b").value(false);
- jsonWriter.endObject();
- jsonWriter.beginObject();
- jsonWriter.name("c").value(6);
- jsonWriter.name("d").value(true);
- jsonWriter.endObject();
- jsonWriter.endArray();
- assertEquals("[{\"a\":5,\"b\":false},"
- + "{\"c\":6,\"d\":true}]", stringWriter.toString());
- }
-
- public void testArraysInObjects() throws IOException {
- StringWriter stringWriter = new StringWriter();
- JsonWriter jsonWriter = new JsonWriter(stringWriter);
- jsonWriter.beginObject();
- jsonWriter.name("a");
- jsonWriter.beginArray();
- jsonWriter.value(5);
- jsonWriter.value(false);
- jsonWriter.endArray();
- jsonWriter.name("b");
- jsonWriter.beginArray();
- jsonWriter.value(6);
- jsonWriter.value(true);
- jsonWriter.endArray();
- jsonWriter.endObject();
- assertEquals("{\"a\":[5,false],"
- + "\"b\":[6,true]}", stringWriter.toString());
- }
-
- public void testDeepNestingArrays() throws IOException {
- StringWriter stringWriter = new StringWriter();
- JsonWriter jsonWriter = new JsonWriter(stringWriter);
- for (int i = 0; i < 20; i++) {
- jsonWriter.beginArray();
- }
- for (int i = 0; i < 20; i++) {
- jsonWriter.endArray();
- }
- assertEquals("[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]", stringWriter.toString());
- }
-
- public void testDeepNestingObjects() throws IOException {
- StringWriter stringWriter = new StringWriter();
- JsonWriter jsonWriter = new JsonWriter(stringWriter);
- jsonWriter.beginObject();
- for (int i = 0; i < 20; i++) {
- jsonWriter.name("a");
- jsonWriter.beginObject();
- }
- for (int i = 0; i < 20; i++) {
- jsonWriter.endObject();
- }
- jsonWriter.endObject();
- assertEquals("{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":"
- + "{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{"
- + "}}}}}}}}}}}}}}}}}}}}}", stringWriter.toString());
- }
-
- public void testRepeatedName() throws IOException {
- StringWriter stringWriter = new StringWriter();
- JsonWriter jsonWriter = new JsonWriter(stringWriter);
- jsonWriter.beginObject();
- jsonWriter.name("a").value(true);
- jsonWriter.name("a").value(false);
- jsonWriter.endObject();
- // JsonWriter doesn't attempt to detect duplicate names
- assertEquals("{\"a\":true,\"a\":false}", stringWriter.toString());
- }
-
- public void testPrettyPrintObject() throws IOException {
- StringWriter stringWriter = new StringWriter();
- JsonWriter jsonWriter = new JsonWriter(stringWriter);
- jsonWriter.setIndent(" ");
-
- jsonWriter.beginObject();
- jsonWriter.name("a").value(true);
- jsonWriter.name("b").value(false);
- jsonWriter.name("c").value(5.0);
- jsonWriter.name("e").nullValue();
- jsonWriter.name("f").beginArray();
- jsonWriter.value(6.0);
- jsonWriter.value(7.0);
- jsonWriter.endArray();
- jsonWriter.name("g").beginObject();
- jsonWriter.name("h").value(8.0);
- jsonWriter.name("i").value(9.0);
- jsonWriter.endObject();
- jsonWriter.endObject();
-
- String expected = "{\n"
- + " \"a\": true,\n"
- + " \"b\": false,\n"
- + " \"c\": 5.0,\n"
- + " \"e\": null,\n"
- + " \"f\": [\n"
- + " 6.0,\n"
- + " 7.0\n"
- + " ],\n"
- + " \"g\": {\n"
- + " \"h\": 8.0,\n"
- + " \"i\": 9.0\n"
- + " }\n"
- + "}";
- assertEquals(expected, stringWriter.toString());
- }
-
- public void testPrettyPrintArray() throws IOException {
- StringWriter stringWriter = new StringWriter();
- JsonWriter jsonWriter = new JsonWriter(stringWriter);
- jsonWriter.setIndent(" ");
-
- jsonWriter.beginArray();
- jsonWriter.value(true);
- jsonWriter.value(false);
- jsonWriter.value(5.0);
- jsonWriter.nullValue();
- jsonWriter.beginObject();
- jsonWriter.name("a").value(6.0);
- jsonWriter.name("b").value(7.0);
- jsonWriter.endObject();
- jsonWriter.beginArray();
- jsonWriter.value(8.0);
- jsonWriter.value(9.0);
- jsonWriter.endArray();
- jsonWriter.endArray();
-
- String expected = "[\n"
- + " true,\n"
- + " false,\n"
- + " 5.0,\n"
- + " null,\n"
- + " {\n"
- + " \"a\": 6.0,\n"
- + " \"b\": 7.0\n"
- + " },\n"
- + " [\n"
- + " 8.0,\n"
- + " 9.0\n"
- + " ]\n"
- + "]";
- assertEquals(expected, stringWriter.toString());
- }
-}
diff --git a/core/tests/coretests/src/com/android/internal/util/FileRotatorTest.java b/core/tests/coretests/src/com/android/internal/util/FileRotatorTest.java
index 95f0e67..0e3c13a 100644
--- a/core/tests/coretests/src/com/android/internal/util/FileRotatorTest.java
+++ b/core/tests/coretests/src/com/android/internal/util/FileRotatorTest.java
@@ -43,7 +43,10 @@
import java.util.Arrays;
import java.util.Random;
+import junit.framework.Assert;
+
import libcore.io.IoUtils;
+import libcore.io.Libcore;
/**
* Tests for {@link FileRotator}.
@@ -367,6 +370,16 @@
assertReadAll(rotate, "bar");
}
+ public void testFileSystemInaccessible() throws Exception {
+ File inaccessibleDir = null;
+ String dirPath = getContext().getFilesDir() + File.separator + "inaccessible";
+ inaccessibleDir = new File(dirPath);
+ final FileRotator rotate = new FileRotator(inaccessibleDir, PREFIX, SECOND_IN_MILLIS, SECOND_IN_MILLIS);
+
+ // rotate should not throw on dir not mkdir-ed (or otherwise inaccessible)
+ rotate.maybeRotate(TEST_TIME);
+ }
+
private void touch(String... names) throws IOException {
for (String name : names) {
final OutputStream out = new FileOutputStream(new File(mBasePath, name));
diff --git a/core/tests/overlaytests/OverlayAppFirst/Android.mk b/core/tests/overlaytests/OverlayAppFirst/Android.mk
new file mode 100644
index 0000000..ee991fc
--- /dev/null
+++ b/core/tests/overlaytests/OverlayAppFirst/Android.mk
@@ -0,0 +1,12 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_SDK_VERSION := current
+
+LOCAL_PACKAGE_NAME := com.android.overlaytest.first_app_overlay
+
+include $(BUILD_PACKAGE)
diff --git a/core/tests/overlaytests/OverlayAppFirst/AndroidManifest.xml b/core/tests/overlaytests/OverlayAppFirst/AndroidManifest.xml
new file mode 100644
index 0000000..ec10bbc
--- /dev/null
+++ b/core/tests/overlaytests/OverlayAppFirst/AndroidManifest.xml
@@ -0,0 +1,6 @@
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.overlaytest.first_app_overlay"
+ android:versionCode="1"
+ android:versionName="1.0">
+ <overlay android:targetPackage="com.android.overlaytest" android:priority="1"/>
+</manifest>
diff --git a/core/tests/overlaytests/OverlayTestOverlay/res/drawable-nodpi/default_wallpaper.jpg b/core/tests/overlaytests/OverlayAppFirst/res/drawable-nodpi/drawable.jpg
similarity index 100%
rename from core/tests/overlaytests/OverlayTestOverlay/res/drawable-nodpi/default_wallpaper.jpg
rename to core/tests/overlaytests/OverlayAppFirst/res/drawable-nodpi/drawable.jpg
Binary files differ
diff --git a/core/tests/overlaytests/OverlayAppFirst/res/raw/lorem_ipsum.txt b/core/tests/overlaytests/OverlayAppFirst/res/raw/lorem_ipsum.txt
new file mode 100644
index 0000000..756b0a3
--- /dev/null
+++ b/core/tests/overlaytests/OverlayAppFirst/res/raw/lorem_ipsum.txt
@@ -0,0 +1 @@
+Lorem ipsum: single overlay.
diff --git a/core/tests/overlaytests/OverlayAppFirst/res/values-sv/config.xml b/core/tests/overlaytests/OverlayAppFirst/res/values-sv/config.xml
new file mode 100644
index 0000000..9cdc73e
--- /dev/null
+++ b/core/tests/overlaytests/OverlayAppFirst/res/values-sv/config.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <integer name="matrix_100100">400</integer>
+ <integer name="matrix_100101">400</integer>
+ <integer name="matrix_100110">400</integer>
+ <integer name="matrix_100111">400</integer>
+ <integer name="matrix_101100">400</integer>
+ <integer name="matrix_101101">400</integer>
+ <integer name="matrix_101110">400</integer>
+ <integer name="matrix_101111">400</integer>
+ <integer name="matrix_110100">400</integer>
+ <integer name="matrix_110101">400</integer>
+ <integer name="matrix_110110">400</integer>
+ <integer name="matrix_110111">400</integer>
+ <integer name="matrix_111100">400</integer>
+ <integer name="matrix_111101">400</integer>
+ <integer name="matrix_111110">400</integer>
+ <integer name="matrix_111111">400</integer>
+</resources>
diff --git a/core/tests/overlaytests/OverlayAppFirst/res/values/config.xml b/core/tests/overlaytests/OverlayAppFirst/res/values/config.xml
new file mode 100644
index 0000000..972137a
--- /dev/null
+++ b/core/tests/overlaytests/OverlayAppFirst/res/values/config.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string name="str">single</string>
+ <string name="str2">single</string>
+ <integer name="matrix_101000">300</integer>
+ <integer name="matrix_101001">300</integer>
+ <integer name="matrix_101010">300</integer>
+ <integer name="matrix_101011">300</integer>
+ <integer name="matrix_101100">300</integer>
+ <integer name="matrix_101101">300</integer>
+ <integer name="matrix_101110">300</integer>
+ <integer name="matrix_101111">300</integer>
+ <integer name="matrix_111000">300</integer>
+ <integer name="matrix_111001">300</integer>
+ <integer name="matrix_111010">300</integer>
+ <integer name="matrix_111011">300</integer>
+ <integer name="matrix_111100">300</integer>
+ <integer name="matrix_111101">300</integer>
+ <integer name="matrix_111110">300</integer>
+ <integer name="matrix_111111">300</integer>
+ <bool name="usually_false">true</bool>
+ <integer-array name="fibonacci">
+ <item>21</item>
+ <item>13</item>
+ <item>8</item>
+ <item>5</item>
+ <item>3</item>
+ <item>2</item>
+ <item>1</item>
+ <item>1</item>
+ </integer-array>
+ <!-- The following integer does not exist in the original package. Idmap
+ generation should therefore ignore it. -->
+ <integer name="integer_not_in_original_package">0</integer>
+</resources>
diff --git a/core/tests/overlaytests/OverlayAppFirst/res/xml/integer.xml b/core/tests/overlaytests/OverlayAppFirst/res/xml/integer.xml
new file mode 100644
index 0000000..7f628d9
--- /dev/null
+++ b/core/tests/overlaytests/OverlayAppFirst/res/xml/integer.xml
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="utf-8"?>
+<integer value="1"/>
diff --git a/core/tests/overlaytests/OverlayAppSecond/Android.mk b/core/tests/overlaytests/OverlayAppSecond/Android.mk
new file mode 100644
index 0000000..87402c43
--- /dev/null
+++ b/core/tests/overlaytests/OverlayAppSecond/Android.mk
@@ -0,0 +1,12 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_SDK_VERSION := current
+
+LOCAL_PACKAGE_NAME := com.android.overlaytest.second_app_overlay
+
+include $(BUILD_PACKAGE)
diff --git a/core/tests/overlaytests/OverlayAppSecond/AndroidManifest.xml b/core/tests/overlaytests/OverlayAppSecond/AndroidManifest.xml
new file mode 100644
index 0000000..ed49863
--- /dev/null
+++ b/core/tests/overlaytests/OverlayAppSecond/AndroidManifest.xml
@@ -0,0 +1,6 @@
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.overlaytest.second_app_overlay"
+ android:versionCode="1"
+ android:versionName="1.0">
+ <overlay android:targetPackage="com.android.overlaytest" android:priority="2"/>
+</manifest>
diff --git a/core/tests/overlaytests/OverlayAppSecond/res/raw/lorem_ipsum.txt b/core/tests/overlaytests/OverlayAppSecond/res/raw/lorem_ipsum.txt
new file mode 100644
index 0000000..613f5b6
--- /dev/null
+++ b/core/tests/overlaytests/OverlayAppSecond/res/raw/lorem_ipsum.txt
@@ -0,0 +1 @@
+Lorem ipsum: multiple overlays.
diff --git a/core/tests/overlaytests/OverlayAppSecond/res/values-sv/config.xml b/core/tests/overlaytests/OverlayAppSecond/res/values-sv/config.xml
new file mode 100644
index 0000000..ec4b6c0
--- /dev/null
+++ b/core/tests/overlaytests/OverlayAppSecond/res/values-sv/config.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <integer name="matrix_100001">600</integer>
+ <integer name="matrix_100011">600</integer>
+ <integer name="matrix_100101">600</integer>
+ <integer name="matrix_100111">600</integer>
+ <integer name="matrix_101001">600</integer>
+ <integer name="matrix_101011">600</integer>
+ <integer name="matrix_101101">600</integer>
+ <integer name="matrix_101111">600</integer>
+ <integer name="matrix_110001">600</integer>
+ <integer name="matrix_110011">600</integer>
+ <integer name="matrix_110101">600</integer>
+ <integer name="matrix_110111">600</integer>
+ <integer name="matrix_111001">600</integer>
+ <integer name="matrix_111011">600</integer>
+ <integer name="matrix_111101">600</integer>
+ <integer name="matrix_111111">600</integer>
+</resources>
diff --git a/core/tests/overlaytests/OverlayAppSecond/res/values/config.xml b/core/tests/overlaytests/OverlayAppSecond/res/values/config.xml
new file mode 100644
index 0000000..8b07216
--- /dev/null
+++ b/core/tests/overlaytests/OverlayAppSecond/res/values/config.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string name="str">multiple</string>
+ <integer name="matrix_100010">500</integer>
+ <integer name="matrix_100011">500</integer>
+ <integer name="matrix_100110">500</integer>
+ <integer name="matrix_100111">500</integer>
+ <integer name="matrix_101010">500</integer>
+ <integer name="matrix_101011">500</integer>
+ <integer name="matrix_101110">500</integer>
+ <integer name="matrix_101111">500</integer>
+ <integer name="matrix_110010">500</integer>
+ <integer name="matrix_110011">500</integer>
+ <integer name="matrix_110110">500</integer>
+ <integer name="matrix_110111">500</integer>
+ <integer name="matrix_111010">500</integer>
+ <integer name="matrix_111011">500</integer>
+ <integer name="matrix_111110">500</integer>
+ <integer name="matrix_111111">500</integer>
+ <bool name="usually_false">false</bool>
+</resources>
diff --git a/core/tests/overlaytests/OverlayAppSecond/res/xml/integer.xml b/core/tests/overlaytests/OverlayAppSecond/res/xml/integer.xml
new file mode 100644
index 0000000..f3370a6
--- /dev/null
+++ b/core/tests/overlaytests/OverlayAppSecond/res/xml/integer.xml
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="utf-8"?>
+<integer value="2"/>
diff --git a/core/tests/overlaytests/OverlayTest/Android.mk b/core/tests/overlaytests/OverlayTest/Android.mk
index f7f67f6..4767e52 100644
--- a/core/tests/overlaytests/OverlayTest/Android.mk
+++ b/core/tests/overlaytests/OverlayTest/Android.mk
@@ -5,6 +5,10 @@
LOCAL_PACKAGE_NAME := OverlayTest
+LOCAL_DEX_PREOPT := false
+
+LOCAL_MODULE_PATH := $(TARGET_OUT)/app
+
LOCAL_SRC_FILES := $(call all-java-files-under, src)
include $(BUILD_PACKAGE)
diff --git a/core/tests/overlaytests/OverlayTest/res/drawable-nodpi/drawable.jpg b/core/tests/overlaytests/OverlayTest/res/drawable-nodpi/drawable.jpg
new file mode 100644
index 0000000..a3f14f3
--- /dev/null
+++ b/core/tests/overlaytests/OverlayTest/res/drawable-nodpi/drawable.jpg
Binary files differ
diff --git a/core/tests/overlaytests/OverlayTest/res/raw/lorem_ipsum.txt b/core/tests/overlaytests/OverlayTest/res/raw/lorem_ipsum.txt
new file mode 100644
index 0000000..cee7a92
--- /dev/null
+++ b/core/tests/overlaytests/OverlayTest/res/raw/lorem_ipsum.txt
@@ -0,0 +1 @@
+Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
diff --git a/core/tests/overlaytests/OverlayTest/res/values-sv/config.xml b/core/tests/overlaytests/OverlayTest/res/values-sv/config.xml
new file mode 100644
index 0000000..891853e
--- /dev/null
+++ b/core/tests/overlaytests/OverlayTest/res/values-sv/config.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <integer name="matrix_110000">200</integer>
+ <integer name="matrix_110001">200</integer>
+ <integer name="matrix_110010">200</integer>
+ <integer name="matrix_110011">200</integer>
+ <integer name="matrix_110100">200</integer>
+ <integer name="matrix_110101">200</integer>
+ <integer name="matrix_110110">200</integer>
+ <integer name="matrix_110111">200</integer>
+ <integer name="matrix_111000">200</integer>
+ <integer name="matrix_111001">200</integer>
+ <integer name="matrix_111010">200</integer>
+ <integer name="matrix_111011">200</integer>
+ <integer name="matrix_111100">200</integer>
+ <integer name="matrix_111101">200</integer>
+ <integer name="matrix_111110">200</integer>
+ <integer name="matrix_111111">200</integer>
+</resources>
diff --git a/core/tests/overlaytests/OverlayTest/res/values/config.xml b/core/tests/overlaytests/OverlayTest/res/values/config.xml
new file mode 100644
index 0000000..c692a26
--- /dev/null
+++ b/core/tests/overlaytests/OverlayTest/res/values/config.xml
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string name="str">none</string>
+ <string name="str2">none</string>
+ <integer name="matrix_100000">100</integer>
+ <integer name="matrix_100001">100</integer>
+ <integer name="matrix_100010">100</integer>
+ <integer name="matrix_100011">100</integer>
+ <integer name="matrix_100100">100</integer>
+ <integer name="matrix_100101">100</integer>
+ <integer name="matrix_100110">100</integer>
+ <integer name="matrix_100111">100</integer>
+ <integer name="matrix_101000">100</integer>
+ <integer name="matrix_101001">100</integer>
+ <integer name="matrix_101010">100</integer>
+ <integer name="matrix_101011">100</integer>
+ <integer name="matrix_101100">100</integer>
+ <integer name="matrix_101101">100</integer>
+ <integer name="matrix_101110">100</integer>
+ <integer name="matrix_101111">100</integer>
+ <integer name="matrix_110000">100</integer>
+ <integer name="matrix_110001">100</integer>
+ <integer name="matrix_110010">100</integer>
+ <integer name="matrix_110011">100</integer>
+ <integer name="matrix_110100">100</integer>
+ <integer name="matrix_110101">100</integer>
+ <integer name="matrix_110110">100</integer>
+ <integer name="matrix_110111">100</integer>
+ <integer name="matrix_111000">100</integer>
+ <integer name="matrix_111001">100</integer>
+ <integer name="matrix_111010">100</integer>
+ <integer name="matrix_111011">100</integer>
+ <integer name="matrix_111100">100</integer>
+ <integer name="matrix_111101">100</integer>
+ <integer name="matrix_111110">100</integer>
+ <integer name="matrix_111111">100</integer>
+ <bool name="usually_false">false</bool>
+ <bool name="always_true">true</bool>
+ <integer-array name="fibonacci">
+ <item>1</item>
+ <item>1</item>
+ <item>2</item>
+ <item>3</item>
+ <item>5</item>
+ <item>8</item>
+ <item>13</item>
+ <item>21</item>
+ </integer-array>
+ <integer-array name="prime_numbers">
+ <item>2</item>
+ <item>3</item>
+ <item>5</item>
+ <item>7</item>
+ <item>11</item>
+ <item>13</item>
+ <item>17</item>
+ <item>19</item>
+ </integer-array>
+</resources>
diff --git a/core/tests/overlaytests/OverlayTest/res/xml/integer.xml b/core/tests/overlaytests/OverlayTest/res/xml/integer.xml
new file mode 100644
index 0000000..9383daa
--- /dev/null
+++ b/core/tests/overlaytests/OverlayTest/res/xml/integer.xml
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="utf-8"?>
+<integer value="0"/>
diff --git a/core/tests/overlaytests/OverlayTest/src/com/android/overlaytest/OverlayBaseTest.java b/core/tests/overlaytests/OverlayTest/src/com/android/overlaytest/OverlayBaseTest.java
index 6211c1c..58b7db9 100644
--- a/core/tests/overlaytests/OverlayTest/src/com/android/overlaytest/OverlayBaseTest.java
+++ b/core/tests/overlaytests/OverlayTest/src/com/android/overlaytest/OverlayBaseTest.java
@@ -2,13 +2,21 @@
import android.content.res.Configuration;
import android.content.res.Resources;
+import android.content.res.XmlResourceParser;
import android.test.AndroidTestCase;
+import android.util.AttributeSet;
+import android.util.Xml;
+import java.io.BufferedReader;
import java.io.InputStream;
+import java.io.InputStreamReader;
import java.util.Locale;
public abstract class OverlayBaseTest extends AndroidTestCase {
private Resources mResources;
- protected boolean mWithOverlay; // will be set by subclasses
+ protected int mMode; // will be set by subclasses
+ static final protected int MODE_NO_OVERLAY = 0;
+ static final protected int MODE_SINGLE_OVERLAY = 1;
+ static final protected int MODE_MULTIPLE_OVERLAYS = 2;
protected void setUp() {
mResources = getContext().getResources();
@@ -36,20 +44,82 @@
mResources.updateConfiguration(config, mResources.getDisplayMetrics());
}
- private void assertResource(int resId, boolean ewo, boolean ew) throws Throwable {
- boolean expected = mWithOverlay ? ew : ewo;
+ private boolean getExpected(boolean no, boolean so, boolean mo) {
+ switch (mMode) {
+ case MODE_NO_OVERLAY:
+ return no;
+ case MODE_SINGLE_OVERLAY:
+ return so;
+ case MODE_MULTIPLE_OVERLAYS:
+ return mo;
+ default:
+ fail("Unknown mode!");
+ return no;
+ }
+ }
+
+ private String getExpected(String no, String so, String mo) {
+ switch (mMode) {
+ case MODE_NO_OVERLAY:
+ return no;
+ case MODE_SINGLE_OVERLAY:
+ return so;
+ case MODE_MULTIPLE_OVERLAYS:
+ return mo;
+ default:
+ fail("Unknown mode!");
+ return no;
+ }
+ }
+
+ private int getExpected(int no, int so, int mo) {
+ switch (mMode) {
+ case MODE_NO_OVERLAY:
+ return no;
+ case MODE_SINGLE_OVERLAY:
+ return so;
+ case MODE_MULTIPLE_OVERLAYS:
+ return mo;
+ default:
+ fail("Unknown mode!");
+ return no;
+ }
+ }
+
+ private int[] getExpected(int[] no, int[] so, int[] mo) {
+ switch (mMode) {
+ case MODE_NO_OVERLAY:
+ return no;
+ case MODE_SINGLE_OVERLAY:
+ return so;
+ case MODE_MULTIPLE_OVERLAYS:
+ return mo;
+ default:
+ fail("Unknown mode!");
+ return no;
+ }
+ }
+
+ private void assertResource(int resId, boolean no, boolean so, boolean mo) throws Throwable {
+ boolean expected = getExpected(no, so, mo);
boolean actual = mResources.getBoolean(resId);
assertEquals(expected, actual);
}
- private void assertResource(int resId, String ewo, String ew) throws Throwable {
- String expected = mWithOverlay ? ew : ewo;
+ private void assertResource(int resId, int no, int so, int mo) throws Throwable {
+ int expected = getExpected(no, so, mo);
+ int actual = mResources.getInteger(resId);
+ assertEquals(expected, actual);
+ }
+
+ private void assertResource(int resId, String no, String so, String mo) throws Throwable {
+ String expected = getExpected(no, so, mo);
String actual = mResources.getString(resId);
assertEquals(expected, actual);
}
- private void assertResource(int resId, int[] ewo, int[] ew) throws Throwable {
- int[] expected = mWithOverlay ? ew : ewo;
+ private void assertResource(int resId, int[] no, int[] so, int[] mo) throws Throwable {
+ int[] expected = getExpected(no, so, mo);
int[] actual = mResources.getIntArray(resId);
assertEquals("length:", expected.length, actual.length);
for (int i = 0; i < actual.length; ++i) {
@@ -57,62 +127,334 @@
}
}
+ public void testFrameworkBooleanOverlay() throws Throwable {
+ // config_annoy_dianne has the value:
+ // - true when no overlay exists (MODE_NO_OVERLAY)
+ // - false when a single overlay exists (MODE_SINGLE_OVERLAY)
+ // - false when multiple overlays exists (MODE_MULTIPLE_OVERLAYS)
+ final int resId = com.android.internal.R.bool.config_annoy_dianne;
+ assertResource(resId, true, false, false);
+ }
+
public void testBooleanOverlay() throws Throwable {
- // config_automatic_brightness_available has overlay (default config)
- final int resId = com.android.internal.R.bool.config_automatic_brightness_available;
- assertResource(resId, false, true);
+ // usually_false has the value:
+ // - false when no overlay exists (MODE_NO_OVERLAY)
+ // - true when a single overlay exists (MODE_SINGLE_OVERLAY)
+ // - false when multiple overlays exists (MODE_MULTIPLE_OVERLAYS)
+ final int resId = R.bool.usually_false;
+ assertResource(resId, false, true, false);
}
public void testBoolean() throws Throwable {
- // config_annoy_dianne has no overlay
- final int resId = com.android.internal.R.bool.config_annoy_dianne;
- assertResource(resId, true, true);
- }
-
- public void testStringOverlay() throws Throwable {
- // phoneTypeCar has an overlay (default config), which shouldn't shadow
- // the Swedish translation
- final int resId = com.android.internal.R.string.phoneTypeCar;
- setLocale("sv_SE");
- assertResource(resId, "Bil", "Bil");
- }
-
- public void testStringSwedishOverlay() throws Throwable {
- // phoneTypeWork has overlay (no default config, only for lang=sv)
- final int resId = com.android.internal.R.string.phoneTypeWork;
- setLocale("en_US");
- assertResource(resId, "Work", "Work");
- setLocale("sv_SE");
- assertResource(resId, "Arbete", "Jobb");
- }
-
- public void testString() throws Throwable {
- // phoneTypeHome has no overlay
- final int resId = com.android.internal.R.string.phoneTypeHome;
- setLocale("en_US");
- assertResource(resId, "Home", "Home");
- setLocale("sv_SE");
- assertResource(resId, "Hem", "Hem");
+ // always_true has no overlay
+ final int resId = R.bool.always_true;
+ assertResource(resId, true, true, true);
}
public void testIntegerArrayOverlay() throws Throwable {
- // config_scrollBarrierVibePattern has overlay (default config)
- final int resId = com.android.internal.R.array.config_scrollBarrierVibePattern;
- assertResource(resId, new int[]{0, 15, 10, 10}, new int[]{100, 200, 300});
+ // fibonacci has values:
+ // - eight first values of Fibonacci sequence, when no overlay exists (MODE_NO_OVERLAY)
+ // - eight first values of Fibonacci sequence (reversed), for single and multiple overlays
+ // (MODE_SINGLE_OVERLAY, MODE_MULTIPLE_OVERLAYS)
+ final int resId = R.array.fibonacci;
+ assertResource(resId,
+ new int[]{1, 1, 2, 3, 5, 8, 13, 21},
+ new int[]{21, 13, 8, 5, 3, 2, 1, 1},
+ new int[]{21, 13, 8, 5, 3, 2, 1, 1});
}
public void testIntegerArray() throws Throwable {
- // config_virtualKeyVibePattern has no overlay
- final int resId = com.android.internal.R.array.config_virtualKeyVibePattern;
- final int[] expected = {0, 10, 20, 30};
- assertResource(resId, expected, expected);
+ // prime_numbers has no overlay
+ final int resId = R.array.prime_numbers;
+ final int[] expected = {2, 3, 5, 7, 11, 13, 17, 19};
+ assertResource(resId, expected, expected, expected);
}
- public void testAsset() throws Throwable {
- // drawable/default_background.jpg has overlay (default config)
- final int resId = com.android.internal.R.drawable.default_wallpaper;
+ public void testDrawable() throws Throwable {
+ // drawable-nodpi/drawable has overlay (default config)
+ final int resId = R.drawable.drawable;
int actual = calculateRawResourceChecksum(resId);
- int expected = mWithOverlay ? 0x000051da : 0x0014ebce;
+ int expected = 0;
+ switch (mMode) {
+ case MODE_NO_OVERLAY:
+ expected = 0x00005665;
+ break;
+ case MODE_SINGLE_OVERLAY:
+ case MODE_MULTIPLE_OVERLAYS:
+ expected = 0x000051da;
+ break;
+ default:
+ fail("Unknown mode " + mMode);
+ }
assertEquals(expected, actual);
}
+
+ public void testAppString() throws Throwable {
+ final int resId = R.string.str;
+ assertResource(resId, "none", "single", "multiple");
+ }
+
+ public void testApp2() throws Throwable {
+ final int resId = R.string.str2; // only in base package and first app overlay
+ assertResource(resId, "none", "single", "single");
+ }
+
+ public void testAppXml() throws Throwable {
+ int expected = getExpected(0, 1, 2);
+ int actual = -1;
+ XmlResourceParser parser = mResources.getXml(R.xml.integer);
+ int type = parser.getEventType();
+ while (type != XmlResourceParser.END_DOCUMENT && actual == -1) {
+ if (type == XmlResourceParser.START_TAG && "integer".equals(parser.getName())) {
+ AttributeSet as = Xml.asAttributeSet(parser);
+ actual = as.getAttributeIntValue(null, "value", -1);
+ }
+ type = parser.next();
+ }
+ parser.close();
+ assertEquals(expected, actual);
+ }
+
+ public void testAppRaw() throws Throwable {
+ final int resId = R.raw.lorem_ipsum;
+
+ InputStream input = null;
+ BufferedReader reader = null;
+ String actual = "";
+ try {
+ input = mResources.openRawResource(resId);
+ reader = new BufferedReader(new InputStreamReader(input));
+ actual = reader.readLine();
+ } finally {
+ reader.close();
+ input.close();
+ }
+
+ final String no = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, " +
+ "sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. " +
+ "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip " +
+ "ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit " +
+ "esse cillum dolore eu fugiat nulla pariatur. " +
+ "Excepteur sint occaecat cupidatat non proident, " +
+ "sunt in culpa qui officia deserunt mollit anim id est laborum.";
+ final String so = "Lorem ipsum: single overlay.";
+ final String mo = "Lorem ipsum: multiple overlays.";
+
+ assertEquals(getExpected(no, so, mo), actual);
+ }
+
+ /*
+ * testMatrix* tests
+ *
+ * The naming convention textMatrixABCDEF refers to in which packages and
+ * which configurations a resource is defined (1 if the resource is
+ * defined). If defined, a slot is always given the same value.
+ *
+ * SLOT PACKAGE CONFIGURATION VALUE
+ * A target package (default) 100
+ * B target package -sv 200
+ * C OverlayAppFirst (default) 300
+ * D OverlayAppFirst -sv 400
+ * E OverlayAppSecond (default) 500
+ * F OverlayAppSecond -sv 600
+ *
+ * Example: in testMatrix101110, the base package defines the
+ * R.integer.matrix101110 resource for the default configuration (value
+ * 100), OverlayAppFirst defines it for both default and Swedish
+ * configurations (values 300 and 400, respectively), and OverlayAppSecond
+ * defines it for the default configuration (value 500). If both overlays
+ * are loaded, the expected value after setting the language to Swedish is
+ * 400.
+ */
+ public void testMatrix100000() throws Throwable {
+ final int resId = R.integer.matrix_100000;
+ setLocale("sv_SE");
+ assertResource(resId, 100, 100, 100);
+ }
+
+ public void testMatrix100001() throws Throwable {
+ final int resId = R.integer.matrix_100001;
+ setLocale("sv_SE");
+ assertResource(resId, 100, 100, 600);
+ }
+
+ public void testMatrix100010() throws Throwable {
+ final int resId = R.integer.matrix_100010;
+ setLocale("sv_SE");
+ assertResource(resId, 100, 100, 500);
+ }
+
+ public void testMatrix100011() throws Throwable {
+ final int resId = R.integer.matrix_100011;
+ setLocale("sv_SE");
+ assertResource(resId, 100, 100, 600);
+ }
+
+ public void testMatrix100100() throws Throwable {
+ final int resId = R.integer.matrix_100100;
+ setLocale("sv_SE");
+ assertResource(resId, 100, 400, 400);
+ }
+
+ public void testMatrix100101() throws Throwable {
+ final int resId = R.integer.matrix_100101;
+ setLocale("sv_SE");
+ assertResource(resId, 100, 400, 600);
+ }
+
+ public void testMatrix100110() throws Throwable {
+ final int resId = R.integer.matrix_100110;
+ setLocale("sv_SE");
+ assertResource(resId, 100, 400, 400);
+ }
+
+ public void testMatrix100111() throws Throwable {
+ final int resId = R.integer.matrix_100111;
+ setLocale("sv_SE");
+ assertResource(resId, 100, 400, 600);
+ }
+
+ public void testMatrix101000() throws Throwable {
+ final int resId = R.integer.matrix_101000;
+ setLocale("sv_SE");
+ assertResource(resId, 100, 300, 300);
+ }
+
+ public void testMatrix101001() throws Throwable {
+ final int resId = R.integer.matrix_101001;
+ setLocale("sv_SE");
+ assertResource(resId, 100, 300, 600);
+ }
+
+ public void testMatrix101010() throws Throwable {
+ final int resId = R.integer.matrix_101010;
+ setLocale("sv_SE");
+ assertResource(resId, 100, 300, 500);
+ }
+
+ public void testMatrix101011() throws Throwable {
+ final int resId = R.integer.matrix_101011;
+ setLocale("sv_SE");
+ assertResource(resId, 100, 300, 600);
+ }
+
+ public void testMatrix101100() throws Throwable {
+ final int resId = R.integer.matrix_101100;
+ setLocale("sv_SE");
+ assertResource(resId, 100, 400, 400);
+ }
+
+ public void testMatrix101101() throws Throwable {
+ final int resId = R.integer.matrix_101101;
+ setLocale("sv_SE");
+ assertResource(resId, 100, 400, 600);
+ }
+
+ public void testMatrix101110() throws Throwable {
+ final int resId = R.integer.matrix_101110;
+ setLocale("sv_SE");
+ assertResource(resId, 100, 400, 400);
+ }
+
+ public void testMatrix101111() throws Throwable {
+ final int resId = R.integer.matrix_101111;
+ setLocale("sv_SE");
+ assertResource(resId, 100, 400, 600);
+ }
+
+ public void testMatrix110000() throws Throwable {
+ final int resId = R.integer.matrix_110000;
+ setLocale("sv_SE");
+ assertResource(resId, 200, 200, 200);
+ }
+
+ public void testMatrix110001() throws Throwable {
+ final int resId = R.integer.matrix_110001;
+ setLocale("sv_SE");
+ assertResource(resId, 200, 200, 600);
+ }
+
+ public void testMatrix110010() throws Throwable {
+ final int resId = R.integer.matrix_110010;
+ setLocale("sv_SE");
+ assertResource(resId, 200, 200, 200);
+ }
+
+ public void testMatrix110011() throws Throwable {
+ final int resId = R.integer.matrix_110011;
+ setLocale("sv_SE");
+ assertResource(resId, 200, 200, 600);
+ }
+
+ public void testMatrix110100() throws Throwable {
+ final int resId = R.integer.matrix_110100;
+ setLocale("sv_SE");
+ assertResource(resId, 200, 400, 400);
+ }
+
+ public void testMatrix110101() throws Throwable {
+ final int resId = R.integer.matrix_110101;
+ setLocale("sv_SE");
+ assertResource(resId, 200, 400, 600);
+ }
+
+ public void testMatrix110110() throws Throwable {
+ final int resId = R.integer.matrix_110110;
+ setLocale("sv_SE");
+ assertResource(resId, 200, 400, 400);
+ }
+
+ public void testMatrix110111() throws Throwable {
+ final int resId = R.integer.matrix_110111;
+ setLocale("sv_SE");
+ assertResource(resId, 200, 400, 600);
+ }
+
+ public void testMatrix111000() throws Throwable {
+ final int resId = R.integer.matrix_111000;
+ setLocale("sv_SE");
+ assertResource(resId, 200, 200, 200);
+ }
+
+ public void testMatrix111001() throws Throwable {
+ final int resId = R.integer.matrix_111001;
+ setLocale("sv_SE");
+ assertResource(resId, 200, 200, 600);
+ }
+
+ public void testMatrix111010() throws Throwable {
+ final int resId = R.integer.matrix_111010;
+ setLocale("sv_SE");
+ assertResource(resId, 200, 200, 200);
+ }
+
+ public void testMatrix111011() throws Throwable {
+ final int resId = R.integer.matrix_111011;
+ setLocale("sv_SE");
+ assertResource(resId, 200, 200, 600);
+ }
+
+ public void testMatrix111100() throws Throwable {
+ final int resId = R.integer.matrix_111100;
+ setLocale("sv_SE");
+ assertResource(resId, 200, 400, 400);
+ }
+
+ public void testMatrix111101() throws Throwable {
+ final int resId = R.integer.matrix_111101;
+ setLocale("sv_SE");
+ assertResource(resId, 200, 400, 600);
+ }
+
+ public void testMatrix111110() throws Throwable {
+ final int resId = R.integer.matrix_111110;
+ setLocale("sv_SE");
+ assertResource(resId, 200, 400, 400);
+ }
+
+ public void testMatrix111111() throws Throwable {
+ final int resId = R.integer.matrix_111111;
+ setLocale("sv_SE");
+ assertResource(resId, 200, 400, 600);
+ }
}
diff --git a/core/tests/overlaytests/OverlayTest/src/com/android/overlaytest/WithMultipleOverlaysTest.java b/core/tests/overlaytests/OverlayTest/src/com/android/overlaytest/WithMultipleOverlaysTest.java
new file mode 100644
index 0000000..e104f5a
--- /dev/null
+++ b/core/tests/overlaytests/OverlayTest/src/com/android/overlaytest/WithMultipleOverlaysTest.java
@@ -0,0 +1,7 @@
+package com.android.overlaytest;
+
+public class WithMultipleOverlaysTest extends OverlayBaseTest {
+ public WithMultipleOverlaysTest() {
+ mMode = MODE_MULTIPLE_OVERLAYS;
+ }
+}
diff --git a/core/tests/overlaytests/OverlayTest/src/com/android/overlaytest/WithOverlayTest.java b/core/tests/overlaytests/OverlayTest/src/com/android/overlaytest/WithOverlayTest.java
index 1292d03..816a476 100644
--- a/core/tests/overlaytests/OverlayTest/src/com/android/overlaytest/WithOverlayTest.java
+++ b/core/tests/overlaytests/OverlayTest/src/com/android/overlaytest/WithOverlayTest.java
@@ -2,6 +2,6 @@
public class WithOverlayTest extends OverlayBaseTest {
public WithOverlayTest() {
- mWithOverlay = true;
+ mMode = MODE_SINGLE_OVERLAY;
}
}
diff --git a/core/tests/overlaytests/OverlayTest/src/com/android/overlaytest/WithoutOverlayTest.java b/core/tests/overlaytests/OverlayTest/src/com/android/overlaytest/WithoutOverlayTest.java
index 630ff8f..318cccc 100644
--- a/core/tests/overlaytests/OverlayTest/src/com/android/overlaytest/WithoutOverlayTest.java
+++ b/core/tests/overlaytests/OverlayTest/src/com/android/overlaytest/WithoutOverlayTest.java
@@ -2,6 +2,6 @@
public class WithoutOverlayTest extends OverlayBaseTest {
public WithoutOverlayTest() {
- mWithOverlay = false;
+ mMode = MODE_NO_OVERLAY;
}
}
diff --git a/core/tests/overlaytests/OverlayTestOverlay/AndroidManifest.xml b/core/tests/overlaytests/OverlayTestOverlay/AndroidManifest.xml
index bcbb0d1..f8b6c7b 100644
--- a/core/tests/overlaytests/OverlayTestOverlay/AndroidManifest.xml
+++ b/core/tests/overlaytests/OverlayTestOverlay/AndroidManifest.xml
@@ -2,5 +2,5 @@
package="com.android.overlaytest.overlay"
android:versionCode="1"
android:versionName="1.0">
- <overlay-package android:name="android"/>
+ <overlay android:targetPackage="android" android:priority="1"/>
</manifest>
diff --git a/core/tests/overlaytests/OverlayTestOverlay/res/values-sv/config.xml b/core/tests/overlaytests/OverlayTestOverlay/res/values-sv/config.xml
deleted file mode 100644
index bc52367..0000000
--- a/core/tests/overlaytests/OverlayTestOverlay/res/values-sv/config.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
- <string name="phoneTypeWork">Jobb</string>
-</resources>
diff --git a/core/tests/overlaytests/OverlayTestOverlay/res/values/config.xml b/core/tests/overlaytests/OverlayTestOverlay/res/values/config.xml
index 794f475..c1e3de1 100644
--- a/core/tests/overlaytests/OverlayTestOverlay/res/values/config.xml
+++ b/core/tests/overlaytests/OverlayTestOverlay/res/values/config.xml
@@ -1,13 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
- <bool name="config_automatic_brightness_available">true</bool>
- <string name="phoneTypeCar">Automobile</string>
- <integer-array name="config_scrollBarrierVibePattern">
- <item>100</item>
- <item>200</item>
- <item>300</item>
- </integer-array>
- <!-- The following integer does not exist in the original package. Idmap
- generation should therefore ignore it. -->
- <integer name="integer_not_in_original_package">0</integer>
+ <bool name="config_annoy_dianne">false</bool>
</resources>
diff --git a/core/tests/overlaytests/README b/core/tests/overlaytests/README
deleted file mode 100644
index 4b3e6f2..0000000
--- a/core/tests/overlaytests/README
+++ /dev/null
@@ -1,15 +0,0 @@
-Unit tests for runtime resource overlay
-=======================================
-
-As of this writing, runtime resource overlay is only triggered for
-/system/framework/framework-res.apk. Because of this, installation of
-overlay packages require the Android platform be rebooted. However, the
-regular unit tests (triggered via development/testrunner/runtest.py)
-cannot handle reboots. As a workaround, this directory contains a shell
-script which will trigger the tests in a non-standard way.
-
-Once runtime resource overlay may be applied to applications, the tests
-in this directory should be moved to core/tests/coretests. Also, by
-applying runtime resource overlay to a dedicated test application, the
-test cases would not need to assume default values for non-overlaid
-resources.
diff --git a/core/tests/overlaytests/runtests.sh b/core/tests/overlaytests/runtests.sh
deleted file mode 100755
index 0a721ad40..0000000
--- a/core/tests/overlaytests/runtests.sh
+++ /dev/null
@@ -1,129 +0,0 @@
-#!/bin/bash
-
-adb="adb"
-if [[ $# -gt 0 ]]; then
- adb="adb $*" # for setting -e, -d or -s <serial>
-fi
-
-function atexit()
-{
- local retval=$?
-
- if [[ $retval -eq 0 ]]; then
- rm $log
- else
- echo "There were errors, please check log at $log"
- fi
-}
-
-log=$(mktemp)
-trap "atexit" EXIT
-
-function compile_module()
-{
- local android_mk="$1"
-
- echo "Compiling .${android_mk:${#PWD}}"
- ONE_SHOT_MAKEFILE="$android_mk" make -C "../../../../../" files | tee -a $log
- if [[ ${PIPESTATUS[0]} -ne 0 ]]; then
- exit 1
- fi
-}
-
-function wait_for_boot_completed()
-{
- echo "Rebooting device"
- $adb wait-for-device logcat -c
- $adb wait-for-device logcat | grep -m 1 -e 'PowerManagerService.*bootCompleted' >/dev/null
-}
-
-function mkdir_if_needed()
-{
- local path="$1"
-
- if [[ "${path:0:1}" != "/" ]]; then
- echo "mkdir_if_needed: error: path '$path' does not begin with /" | tee -a $log
- exit 1
- fi
-
- local basename=$(basename "$path")
- local dirname=$(dirname "$path")
- local t=$($adb shell ls -l $dirname | tr -d '\r' | grep -e "${basename}$" | grep -oe '^.')
-
- case "$t" in
- d) # File exists, and is a directory ...
- # do nothing
- ;;
- l) # ... (or symbolic link possibly to a directory).
- # do nothing
- ;;
- "") # File does not exist.
- mkdir_if_needed "$dirname"
- $adb shell mkdir "$path"
- ;;
- *) # File exists, but is not a directory.
- echo "mkdir_if_needed: file '$path' exists, but is not a directory" | tee -a $log
- exit 1
- ;;
- esac
-}
-
-function disable_overlay()
-{
- echo "Disabling overlay"
- $adb shell rm /vendor/overlay/framework/framework-res.apk
- $adb shell rm /data/resource-cache/vendor@overlay@framework@framework-res.apk@idmap
-}
-
-function enable_overlay()
-{
- echo "Enabling overlay"
- mkdir_if_needed "/system/vendor"
- mkdir_if_needed "/vendor/overlay/framework"
- $adb shell ln -s /data/app/com.android.overlaytest.overlay.apk /vendor/overlay/framework/framework-res.apk
-}
-
-function instrument()
-{
- local class="$1"
-
- echo "Instrumenting $class"
- $adb shell am instrument -w -e class $class com.android.overlaytest/android.test.InstrumentationTestRunner | tee -a $log
-}
-
-function remount()
-{
- echo "Remounting file system writable"
- $adb remount | tee -a $log
-}
-
-function sync()
-{
- echo "Syncing to device"
- $adb sync data | tee -a $log
-}
-
-# some commands require write access, remount once and for all
-remount
-
-# build and sync
-compile_module "$PWD/OverlayTest/Android.mk"
-compile_module "$PWD/OverlayTestOverlay/Android.mk"
-sync
-
-# instrument test (without overlay)
-$adb shell stop
-disable_overlay
-$adb shell start
-wait_for_boot_completed
-instrument "com.android.overlaytest.WithoutOverlayTest"
-
-# instrument test (with overlay)
-$adb shell stop
-enable_overlay
-$adb shell start
-wait_for_boot_completed
-instrument "com.android.overlaytest.WithOverlayTest"
-
-# cleanup
-exit $(grep -c -e '^FAILURES' $log)
diff --git a/core/tests/overlaytests/testrunner.py b/core/tests/overlaytests/testrunner.py
new file mode 100755
index 0000000..4f94373
--- /dev/null
+++ b/core/tests/overlaytests/testrunner.py
@@ -0,0 +1,679 @@
+#!/usr/bin/python
+import hashlib
+import optparse
+import os
+import re
+import shlex
+import subprocess
+import sys
+import threading
+import time
+
+TASK_COMPILATION = 'compile'
+TASK_DISABLE_OVERLAYS = 'disable overlays'
+TASK_ENABLE_MULTIPLE_OVERLAYS = 'enable multiple overlays'
+TASK_ENABLE_SINGLE_OVERLAY = 'enable single overlay'
+TASK_FILE_EXISTS_TEST = 'test (file exists)'
+TASK_GREP_IDMAP_TEST = 'test (grep idmap)'
+TASK_MD5_TEST = 'test (md5)'
+TASK_IDMAP_PATH = 'idmap --path'
+TASK_IDMAP_SCAN = 'idmap --scan'
+TASK_INSTRUMENTATION = 'instrumentation'
+TASK_INSTRUMENTATION_TEST = 'test (instrumentation)'
+TASK_MKDIR = 'mkdir'
+TASK_PUSH = 'push'
+TASK_ROOT = 'root'
+TASK_REMOUNT = 'remount'
+TASK_RM = 'rm'
+TASK_SETUP_IDMAP_PATH = 'setup idmap --path'
+TASK_SETUP_IDMAP_SCAN = 'setup idmap --scan'
+TASK_START = 'start'
+TASK_STOP = 'stop'
+
+adb = 'adb'
+
+def _adb_shell(cmd):
+ argv = shlex.split(adb + " shell '" + cmd + "; echo $?'")
+ proc = subprocess.Popen(argv, bufsize=1, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ (stdout, stderr) = proc.communicate()
+ (stdout, stderr) = (stdout.replace('\r', ''), stderr.replace('\r', ''))
+ tmp = stdout.rsplit('\n', 2)
+ if len(tmp) == 2:
+ stdout == ''
+ returncode = int(tmp[0])
+ else:
+ stdout = tmp[0] + '\n'
+ returncode = int(tmp[1])
+ return returncode, stdout, stderr
+
+class VerbosePrinter:
+ class Ticker(threading.Thread):
+ def _print(self):
+ s = '\r' + self.text + '[' + '.' * self.i + ' ' * (4 - self.i) + ']'
+ sys.stdout.write(s)
+ sys.stdout.flush()
+ self.i = (self.i + 1) % 5
+
+ def __init__(self, cond_var, text):
+ threading.Thread.__init__(self)
+ self.text = text
+ self.setDaemon(True)
+ self.cond_var = cond_var
+ self.running = False
+ self.i = 0
+ self._print()
+ self.running = True
+
+ def run(self):
+ self.cond_var.acquire()
+ while True:
+ self.cond_var.wait(0.25)
+ running = self.running
+ if not running:
+ break
+ self._print()
+ self.cond_var.release()
+
+ def stop(self):
+ self.cond_var.acquire()
+ self.running = False
+ self.cond_var.notify_all()
+ self.cond_var.release()
+
+ def _start_ticker(self):
+ self.ticker = VerbosePrinter.Ticker(self.cond_var, self.text)
+ self.ticker.start()
+
+ def _stop_ticker(self):
+ self.ticker.stop()
+ self.ticker.join()
+ self.ticker = None
+
+ def _format_begin(self, type, name):
+ N = self.width - len(type) - len(' [ ] ')
+ fmt = '%%s %%-%ds ' % N
+ return fmt % (type, name)
+
+ def __init__(self, use_color):
+ self.cond_var = threading.Condition()
+ self.ticker = None
+ if use_color:
+ self.color_RED = '\033[1;31m'
+ self.color_red = '\033[0;31m'
+ self.color_reset = '\033[0;37m'
+ else:
+ self.color_RED = ''
+ self.color_red = ''
+ self.color_reset = ''
+
+ argv = shlex.split('stty size') # get terminal width
+ proc = subprocess.Popen(argv, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ (stdout, stderr) = proc.communicate()
+ if proc.returncode == 0:
+ (h, w) = stdout.split()
+ self.width = int(w)
+ else:
+ self.width = 72 # conservative guesstimate
+
+ def begin(self, type, name):
+ self.text = self._format_begin(type, name)
+ sys.stdout.write(self.text + '[ ]')
+ sys.stdout.flush()
+ self._start_ticker()
+
+ def end_pass(self, type, name):
+ self._stop_ticker()
+ sys.stdout.write('\r' + self.text + '[ OK ]\n')
+ sys.stdout.flush()
+
+ def end_fail(self, type, name, msg):
+ self._stop_ticker()
+ sys.stdout.write('\r' + self.color_RED + self.text + '[FAIL]\n')
+ sys.stdout.write(self.color_red)
+ sys.stdout.write(msg)
+ sys.stdout.write(self.color_reset)
+ sys.stdout.flush()
+
+class QuietPrinter:
+ def begin(self, type, name):
+ pass
+
+ def end_pass(self, type, name):
+ sys.stdout.write('PASS ' + type + ' ' + name + '\n')
+ sys.stdout.flush()
+
+ def end_fail(self, type, name, msg):
+ sys.stdout.write('FAIL ' + type + ' ' + name + '\n')
+ sys.stdout.flush()
+
+class CompilationTask:
+ def __init__(self, makefile):
+ self.makefile = makefile
+
+ def get_type(self):
+ return TASK_COMPILATION
+
+ def get_name(self):
+ return self.makefile
+
+ def execute(self):
+ os.putenv('ONE_SHOT_MAKEFILE', os.getcwd() + "/" + self.makefile)
+ argv = shlex.split('make -C "../../../../../" files')
+ proc = subprocess.Popen(argv, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ (stdout, stderr) = proc.communicate()
+ return proc.returncode, stdout, stderr
+
+class InstrumentationTask:
+ def __init__(self, instrumentation_class):
+ self.instrumentation_class = instrumentation_class
+
+ def get_type(self):
+ return TASK_INSTRUMENTATION
+
+ def get_name(self):
+ return self.instrumentation_class
+
+ def execute(self):
+ return _adb_shell('am instrument -r -w -e class %s com.android.overlaytest/android.test.InstrumentationTestRunner' % self.instrumentation_class)
+
+class PushTask:
+ def __init__(self, src, dest):
+ self.src = src
+ self.dest = dest
+
+ def get_type(self):
+ return TASK_PUSH
+
+ def get_name(self):
+ return "%s -> %s" % (self.src, self.dest)
+
+ def execute(self):
+ src = os.getenv('OUT') + "/" + self.src
+ argv = shlex.split(adb + ' push %s %s' % (src, self.dest))
+ proc = subprocess.Popen(argv, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ (stdout, stderr) = proc.communicate()
+ return proc.returncode, stdout, stderr
+
+class MkdirTask:
+ def __init__(self, path):
+ self.path = path
+
+ def get_type(self):
+ return TASK_MKDIR
+
+ def get_name(self):
+ return self.path
+
+ def execute(self):
+ return _adb_shell('mkdir -p %s' % self.path)
+
+class RmTask:
+ def __init__(self, path):
+ self.path = path
+
+ def get_type(self):
+ return TASK_RM
+
+ def get_name(self):
+ return self.path
+
+ def execute(self):
+ returncode, stdout, stderr = _adb_shell('ls %s' % self.path)
+ if returncode != 0 and stdout.endswith(': No such file or directory\n'):
+ return 0, "", ""
+ return _adb_shell('rm -r %s' % self.path)
+
+class IdmapPathTask:
+ def __init__(self, path_target_apk, path_overlay_apk, path_idmap):
+ self.path_target_apk = path_target_apk
+ self.path_overlay_apk = path_overlay_apk
+ self.path_idmap = path_idmap
+
+ def get_type(self):
+ return TASK_IDMAP_PATH
+
+ def get_name(self):
+ return self.path_idmap
+
+ def execute(self):
+ return _adb_shell('su system idmap --path "%s" "%s" "%s"' % (self.path_target_apk, self.path_overlay_apk, self.path_idmap))
+
+class IdmapScanTask:
+ def __init__(self, overlay_dir, target_pkg_name, target_pkg, idmap_dir, symlink_dir):
+ self.overlay_dir = overlay_dir
+ self.target_pkg_name = target_pkg_name
+ self.target_pkg = target_pkg
+ self.idmap_dir = idmap_dir
+ self.symlink_dir = symlink_dir
+
+ def get_type(self):
+ return TASK_IDMAP_SCAN
+
+ def get_name(self):
+ return self.target_pkg_name
+
+ def execute(self):
+ return _adb_shell('su system idmap --scan "%s" "%s" "%s" "%s"' % (self.overlay_dir, self.target_pkg_name, self.target_pkg, self.idmap_dir))
+
+class FileExistsTest:
+ def __init__(self, path):
+ self.path = path
+
+ def get_type(self):
+ return TASK_FILE_EXISTS_TEST
+
+ def get_name(self):
+ return self.path
+
+ def execute(self):
+ return _adb_shell('ls %s' % self.path)
+
+class GrepIdmapTest:
+ def __init__(self, path_idmap, pattern, expected_n):
+ self.path_idmap = path_idmap
+ self.pattern = pattern
+ self.expected_n = expected_n
+
+ def get_type(self):
+ return TASK_GREP_IDMAP_TEST
+
+ def get_name(self):
+ return self.pattern
+
+ def execute(self):
+ returncode, stdout, stderr = _adb_shell('idmap --inspect %s' % self.path_idmap)
+ if returncode != 0:
+ return returncode, stdout, stderr
+ all_matches = re.findall('\s' + self.pattern + '$', stdout, flags=re.MULTILINE)
+ if len(all_matches) != self.expected_n:
+ return 1, 'pattern=%s idmap=%s expected=%d found=%d\n' % (self.pattern, self.path_idmap, self.expected_n, len(all_matches)), ''
+ return 0, "", ""
+
+class Md5Test:
+ def __init__(self, path, expected_content):
+ self.path = path
+ self.expected_md5 = hashlib.md5(expected_content).hexdigest()
+
+ def get_type(self):
+ return TASK_MD5_TEST
+
+ def get_name(self):
+ return self.path
+
+ def execute(self):
+ returncode, stdout, stderr = _adb_shell('md5 %s' % self.path)
+ if returncode != 0:
+ return returncode, stdout, stderr
+ actual_md5 = stdout.split()[0]
+ if actual_md5 != self.expected_md5:
+ return 1, 'expected %s, got %s\n' % (self.expected_md5, actual_md5), ''
+ return 0, "", ""
+
+class StartTask:
+ def get_type(self):
+ return TASK_START
+
+ def get_name(self):
+ return ""
+
+ def execute(self):
+ (returncode, stdout, stderr) = _adb_shell('start')
+ if returncode != 0:
+ return returncode, stdout, stderr
+
+ while True:
+ (returncode, stdout, stderr) = _adb_shell('getprop dev.bootcomplete')
+ if returncode != 0:
+ return returncode, stdout, stderr
+ if stdout.strip() == "1":
+ break
+ time.sleep(0.5)
+
+ return 0, "", ""
+
+class StopTask:
+ def get_type(self):
+ return TASK_STOP
+
+ def get_name(self):
+ return ""
+
+ def execute(self):
+ (returncode, stdout, stderr) = _adb_shell('stop')
+ if returncode != 0:
+ return returncode, stdout, stderr
+ return _adb_shell('setprop dev.bootcomplete 0')
+
+class RootTask:
+ def get_type(self):
+ return TASK_ROOT
+
+ def get_name(self):
+ return ""
+
+ def execute(self):
+ (returncode, stdout, stderr) = _adb_shell('getprop service.adb.root 0')
+ if returncode != 0:
+ return returncode, stdout, stderr
+ if stdout.strip() == '1': # already root
+ return 0, "", ""
+
+ argv = shlex.split(adb + ' root')
+ proc = subprocess.Popen(argv, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ (stdout, stderr) = proc.communicate()
+ if proc.returncode != 0:
+ return proc.returncode, stdout, stderr
+
+ argv = shlex.split(adb + ' wait-for-device')
+ proc = subprocess.Popen(argv, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ (stdout, stderr) = proc.communicate()
+ return proc.returncode, stdout, stderr
+
+class RemountTask:
+ def get_type(self):
+ return TASK_REMOUNT
+
+ def get_name(self):
+ return ""
+
+ def execute(self):
+ argv = shlex.split(adb + ' remount')
+ proc = subprocess.Popen(argv, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ (stdout, stderr) = proc.communicate()
+ # adb remount returns 0 even if the operation failed, so check stdout
+ if stdout.startswith('remount failed:'):
+ return 1, stdout, stderr
+ return proc.returncode, stdout, stderr
+
+class CompoundTask:
+ def __init__(self, type, tasks):
+ self.type = type
+ self.tasks = tasks
+
+ def get_type(self):
+ return self.type
+
+ def get_name(self):
+ return ""
+
+ def execute(self):
+ for t in self.tasks:
+ (returncode, stdout, stderr) = t.execute()
+ if returncode != 0:
+ return returncode, stdout, stderr
+ return 0, "", ""
+
+def _create_disable_overlays_task():
+ tasks = [
+ RmTask("/vendor/overlay/framework_a.apk"),
+ RmTask("/vendor/overlay/framework_b.apk"),
+ RmTask("/data/resource-cache/vendor@overlay@framework_a.apk@idmap"),
+ RmTask("/data/resource-cache/vendor@overlay@framework_b.apk@idmap"),
+ RmTask("/vendor/overlay/app_a.apk"),
+ RmTask("/vendor/overlay/app_b.apk"),
+ RmTask("/data/resource-cache/vendor@overlay@app_a.apk@idmap"),
+ RmTask("/data/resource-cache/vendor@overlay@app_b.apk@idmap"),
+ ]
+ return CompoundTask(TASK_DISABLE_OVERLAYS, tasks)
+
+def _create_enable_single_overlay_task():
+ tasks = [
+ _create_disable_overlays_task(),
+ MkdirTask('/system/vendor'),
+ MkdirTask('/vendor/overlay'),
+ PushTask('/data/app/com.android.overlaytest.overlay.apk', '/vendor/overlay/framework_a.apk'),
+ PushTask('/data/app/com.android.overlaytest.first_app_overlay.apk', '/vendor/overlay/app_a.apk'),
+ ]
+ return CompoundTask(TASK_ENABLE_SINGLE_OVERLAY, tasks)
+
+def _create_enable_multiple_overlays_task():
+ tasks = [
+ _create_disable_overlays_task(),
+ MkdirTask('/system/vendor'),
+ MkdirTask('/vendor/overlay'),
+
+ PushTask('/data/app/com.android.overlaytest.overlay.apk', '/vendor/overlay/framework_b.apk'),
+ PushTask('/data/app/com.android.overlaytest.first_app_overlay.apk', '/vendor/overlay/app_a.apk'),
+ PushTask('/data/app/com.android.overlaytest.second_app_overlay.apk', '/vendor/overlay/app_b.apk'),
+ ]
+ return CompoundTask(TASK_ENABLE_MULTIPLE_OVERLAYS, tasks)
+
+def _create_setup_idmap_path_task(idmaps, symlinks):
+ tasks = [
+ _create_enable_single_overlay_task(),
+ RmTask(symlinks),
+ RmTask(idmaps),
+ MkdirTask(idmaps),
+ MkdirTask(symlinks),
+ ]
+ return CompoundTask(TASK_SETUP_IDMAP_PATH, tasks)
+
+def _create_setup_idmap_scan_task(idmaps, symlinks):
+ tasks = [
+ _create_enable_single_overlay_task(),
+ RmTask(symlinks),
+ RmTask(idmaps),
+ MkdirTask(idmaps),
+ MkdirTask(symlinks),
+ _create_enable_multiple_overlays_task(),
+ ]
+ return CompoundTask(TASK_SETUP_IDMAP_SCAN, tasks)
+
+def _handle_instrumentation_task_output(stdout, printer):
+ regex_status_code = re.compile(r'^INSTRUMENTATION_STATUS_CODE: -?(\d+)')
+ regex_name = re.compile(r'^INSTRUMENTATION_STATUS: test=(.*)')
+ regex_begin_stack = re.compile(r'^INSTRUMENTATION_STATUS: stack=(.*)')
+ regex_end_stack = re.compile(r'^$')
+
+ failed_tests = 0
+ current_test = None
+ current_stack = []
+ mode_stack = False
+ for line in stdout.split("\n"):
+ line = line.rstrip() # strip \r from adb output
+ m = regex_status_code.match(line)
+ if m:
+ c = int(m.group(1))
+ if c == 1:
+ printer.begin(TASK_INSTRUMENTATION_TEST, current_test)
+ elif c == 0:
+ printer.end_pass(TASK_INSTRUMENTATION_TEST, current_test)
+ else:
+ failed_tests += 1
+ current_stack.append("\n")
+ msg = "\n".join(current_stack)
+ printer.end_fail(TASK_INSTRUMENTATION_TEST, current_test, msg.rstrip() + '\n')
+ continue
+
+ m = regex_name.match(line)
+ if m:
+ current_test = m.group(1)
+ continue
+
+ m = regex_begin_stack.match(line)
+ if m:
+ mode_stack = True
+ current_stack = []
+ current_stack.append(" " + m.group(1))
+ continue
+
+ m = regex_end_stack.match(line)
+ if m:
+ mode_stack = False
+ continue
+
+ if mode_stack:
+ current_stack.append(" " + line.strip())
+
+ return failed_tests
+
+def _set_adb_device(option, opt, value, parser):
+ global adb
+ if opt == '-d' or opt == '--device':
+ adb = 'adb -d'
+ if opt == '-e' or opt == '--emulator':
+ adb = 'adb -e'
+ if opt == '-s' or opt == '--serial':
+ adb = 'adb -s ' + value
+
+def _create_opt_parser():
+ parser = optparse.OptionParser()
+ parser.add_option('-d', '--device', action='callback', callback=_set_adb_device,
+ help='pass -d to adb')
+ parser.add_option('-e', '--emulator', action='callback', callback=_set_adb_device,
+ help='pass -e to adb')
+ parser.add_option('-s', '--serial', type="str", action='callback', callback=_set_adb_device,
+ help='pass -s <serical> to adb')
+ parser.add_option('-C', '--no-color', action='store_false',
+ dest='use_color', default=True,
+ help='disable color escape sequences in output')
+ parser.add_option('-q', '--quiet', action='store_true',
+ dest='quiet_mode', default=False,
+ help='quiet mode, output only results')
+ parser.add_option('-b', '--no-build', action='store_false',
+ dest='do_build', default=True,
+ help='do not rebuild test projects')
+ parser.add_option('-k', '--continue', action='store_true',
+ dest='do_continue', default=False,
+ help='do not rebuild test projects')
+ parser.add_option('-i', '--test-idmap', action='store_true',
+ dest='test_idmap', default=False,
+ help='run tests for single overlay')
+ parser.add_option('-0', '--test-no-overlay', action='store_true',
+ dest='test_no_overlay', default=False,
+ help='run tests without any overlay')
+ parser.add_option('-1', '--test-single-overlay', action='store_true',
+ dest='test_single_overlay', default=False,
+ help='run tests for single overlay')
+ parser.add_option('-2', '--test-multiple-overlays', action='store_true',
+ dest='test_multiple_overlays', default=False,
+ help='run tests for multiple overlays')
+ return parser
+
+if __name__ == '__main__':
+ opt_parser = _create_opt_parser()
+ opts, args = opt_parser.parse_args(sys.argv[1:])
+ if not opts.test_idmap and not opts.test_no_overlay and not opts.test_single_overlay and not opts.test_multiple_overlays:
+ opts.test_idmap = True
+ opts.test_no_overlay = True
+ opts.test_single_overlay = True
+ opts.test_multiple_overlays = True
+ if len(args) > 0:
+ opt_parser.error("unexpected arguments: %s" % " ".join(args))
+ # will never reach this: opt_parser.error will call sys.exit
+
+ if opts.quiet_mode:
+ printer = QuietPrinter()
+ else:
+ printer = VerbosePrinter(opts.use_color)
+ tasks = []
+
+ # must be in the same directory as this script for compilation tasks to work
+ script = sys.argv[0]
+ dirname = os.path.dirname(script)
+ wd = os.path.realpath(dirname)
+ os.chdir(wd)
+
+ # build test cases
+ if opts.do_build:
+ tasks.append(CompilationTask('OverlayTest/Android.mk'))
+ tasks.append(CompilationTask('OverlayTestOverlay/Android.mk'))
+ tasks.append(CompilationTask('OverlayAppFirst/Android.mk'))
+ tasks.append(CompilationTask('OverlayAppSecond/Android.mk'))
+
+ # remount filesystem, install test project
+ tasks.append(RootTask())
+ tasks.append(RemountTask())
+ tasks.append(PushTask('/system/app/OverlayTest.apk', '/system/app/OverlayTest.apk'))
+
+ # test idmap
+ if opts.test_idmap:
+ idmaps='/data/local/tmp/idmaps'
+ symlinks='/data/local/tmp/symlinks'
+
+ # idmap --path
+ tasks.append(StopTask())
+ tasks.append(_create_setup_idmap_path_task(idmaps, symlinks))
+ tasks.append(StartTask())
+ tasks.append(IdmapPathTask('/vendor/overlay/framework_a.apk', '/system/framework/framework-res.apk', idmaps + '/a.idmap'))
+ tasks.append(FileExistsTest(idmaps + '/a.idmap'))
+ tasks.append(GrepIdmapTest(idmaps + '/a.idmap', 'bool/config_annoy_dianne', 1))
+
+ # idmap --scan
+ idmap = idmaps + '/vendor@overlay@framework_b.apk@idmap'
+ tasks.append(StopTask())
+ tasks.append(_create_setup_idmap_scan_task(idmaps, symlinks))
+ tasks.append(StartTask())
+ tasks.append(IdmapScanTask('/vendor/overlay', 'android', '/system/framework/framework-res.apk', idmaps, symlinks))
+ tasks.append(FileExistsTest(idmap))
+ tasks.append(GrepIdmapTest(idmap, 'bool/config_annoy_dianne', 1))
+
+ # overlays.list
+ overlays_list_path = '/data/resource-cache/overlays.list'
+ expected_content = '''\
+/vendor/overlay/framework_b.apk /data/resource-cache/vendor@overlay@framework_b.apk@idmap
+'''
+ tasks.append(FileExistsTest(overlays_list_path))
+ tasks.append(Md5Test(overlays_list_path, expected_content))
+
+ # idmap cleanup
+ tasks.append(RmTask(symlinks))
+ tasks.append(RmTask(idmaps))
+
+ # test no overlay
+ if opts.test_no_overlay:
+ tasks.append(StopTask())
+ tasks.append(_create_disable_overlays_task())
+ tasks.append(StartTask())
+ tasks.append(InstrumentationTask('com.android.overlaytest.WithoutOverlayTest'))
+
+ # test single overlay
+ if opts.test_single_overlay:
+ tasks.append(StopTask())
+ tasks.append(_create_enable_single_overlay_task())
+ tasks.append(StartTask())
+ tasks.append(InstrumentationTask('com.android.overlaytest.WithOverlayTest'))
+
+ # test multiple overlays
+ if opts.test_multiple_overlays:
+ tasks.append(StopTask())
+ tasks.append(_create_enable_multiple_overlays_task())
+ tasks.append(StartTask())
+ tasks.append(InstrumentationTask('com.android.overlaytest.WithMultipleOverlaysTest'))
+
+ ignored_errors = 0
+ for t in tasks:
+ type = t.get_type()
+ name = t.get_name()
+ if type == TASK_INSTRUMENTATION:
+ # InstrumentationTask will run several tests, but we want it
+ # to appear as if each test was run individually. Calling
+ # "am instrument" with a single test method is prohibitively
+ # expensive, so let's instead post-process the output to
+ # emulate individual calls.
+ retcode, stdout, stderr = t.execute()
+ if retcode != 0:
+ printer.begin(TASK_INSTRUMENTATION, name)
+ printer.end_fail(TASK_INSTRUMENTATION, name, stderr)
+ sys.exit(retcode)
+ retcode = _handle_instrumentation_task_output(stdout, printer)
+ if retcode != 0:
+ if not opts.do_continue:
+ sys.exit(retcode)
+ else:
+ ignored_errors += retcode
+ else:
+ printer.begin(type, name)
+ retcode, stdout, stderr = t.execute()
+ if retcode == 0:
+ printer.end_pass(type, name)
+ if retcode != 0:
+ if len(stderr) == 0:
+ # hope for output from stdout instead (true for eg adb shell rm)
+ stderr = stdout
+ printer.end_fail(type, name, stderr)
+ if not opts.do_continue:
+ sys.exit(retcode)
+ else:
+ ignored_errors += retcode
+ sys.exit(ignored_errors)
diff --git a/data/fonts/system_fonts.xml b/data/fonts/system_fonts.xml
index 16e4c7c..549f061b 100644
--- a/data/fonts/system_fonts.xml
+++ b/data/fonts/system_fonts.xml
@@ -75,7 +75,6 @@
<name>baskerville</name>
<name>goudy</name>
<name>fantasy</name>
- <name>cursive</name>
<name>ITC Stone Serif</name>
</nameset>
<fileset>
@@ -108,4 +107,32 @@
</fileset>
</family>
+ <family>
+ <nameset>
+ <name>casual</name>
+ </nameset>
+ <fileset>
+ <file>ComingSoon.ttf</file>
+ </fileset>
+ </family>
+
+ <family>
+ <nameset>
+ <name>cursive</name>
+ </nameset>
+ <fileset>
+ <file>DancingScript-Regular.ttf</file>
+ <file>DancingScript-Bold.ttf</file>
+ </fileset>
+ </family>
+
+ <family>
+ <nameset>
+ <name>sans-serif-smallcaps</name>
+ </nameset>
+ <fileset>
+ <file>CarroisGothicSC-Regular.ttf</file>
+ </fileset>
+ </family>
+
</familyset>
diff --git a/docs/html/guide/topics/manifest/activity-element.jd b/docs/html/guide/topics/manifest/activity-element.jd
index 8df1fdf..eabfa60 100644
--- a/docs/html/guide/topics/manifest/activity-element.jd
+++ b/docs/html/guide/topics/manifest/activity-element.jd
@@ -580,7 +580,7 @@
<a href="#nm"><code>android:name</code></a> attribute.
<p>The system reads this attribute to determine which activity should be started when
- the use presses the Up button in the action bar. The system can also use this information to
+ the user presses the Up button in the action bar. The system can also use this information to
synthesize a back stack of activities with {@link android.app.TaskStackBuilder}.</p>
<p>To support API levels 4 - 16, you can also declare the parent activity with a {@code
diff --git a/docs/html/guide/topics/renderscript/compute.jd b/docs/html/guide/topics/renderscript/compute.jd
index c62510b..297a2dc 100644
--- a/docs/html/guide/topics/renderscript/compute.jd
+++ b/docs/html/guide/topics/renderscript/compute.jd
@@ -56,7 +56,9 @@
RenderScript kernel language used in this script. Currently, 1 is the only valid value.</li>
<li>A pragma declaration (<code>#pragma rs java_package_name(com.example.app)</code>) that
-declares the package name of the Java classes reflected from this script.</li>
+declares the package name of the Java classes reflected from this script.
+Note that your .rs file must be part of your application package, and not in a
+library project.</li>
<li>Some number of invokable functions. An invokable function is a single-threaded RenderScript
function that you can call from your Java code with arbitrary arguments. These are often useful for
@@ -308,4 +310,4 @@
<li><strong>Tear down the RenderScript context.</strong> The RenderScript context can be destroyed
with {@link android.renderscript.RenderScript#destroy} or by allowing the RenderScript context
object to be garbage collected. This will cause any further use of any object belonging to that
-context to throw an exception.</li> </ol>
\ No newline at end of file
+context to throw an exception.</li> </ol>
diff --git a/docs/html/tools/testing/testing_ui.jd b/docs/html/tools/testing/testing_ui.jd
index 701415e..4318a21 100644
--- a/docs/html/tools/testing/testing_ui.jd
+++ b/docs/html/tools/testing/testing_ui.jd
@@ -90,7 +90,7 @@
alt="User interface of uiautomatorviewer tool" height="327px" id="figure1"/>
</a>
<p class="img-caption">
- <strong>Figure 1.</strong> The {@code uiautomatorviewer} showing the captured interface of a test deviice.
+ <strong>Figure 1.</strong> The {@code uiautomatorviewer} showing the captured interface of a test device.
</p>
<p>To analyze the UI components of the application that you want to test:</p>
diff --git a/drm/java/android/drm/DrmManagerClient.java b/drm/java/android/drm/DrmManagerClient.java
index 10cdab0..c05ea2e 100644
--- a/drm/java/android/drm/DrmManagerClient.java
+++ b/drm/java/android/drm/DrmManagerClient.java
@@ -116,7 +116,7 @@
private static final int ACTION_PROCESS_DRM_INFO = 1002;
private int mUniqueId;
- private int mNativeContext;
+ private long mNativeContext;
private volatile boolean mReleased;
private Context mContext;
private InfoHandler mInfoHandler;
diff --git a/drm/jni/android_drm_DrmManagerClient.cpp b/drm/jni/android_drm_DrmManagerClient.cpp
index baddf62..de8531b 100644
--- a/drm/jni/android_drm_DrmManagerClient.cpp
+++ b/drm/jni/android_drm_DrmManagerClient.cpp
@@ -182,25 +182,27 @@
JNIEnv* env, jobject thiz, const sp<DrmManagerClientImpl>& client) {
Mutex::Autolock l(sLock);
jclass clazz = env->FindClass("android/drm/DrmManagerClient");
- jfieldID fieldId = env->GetFieldID(clazz, "mNativeContext", "I");
+ jfieldID fieldId = env->GetFieldID(clazz, "mNativeContext", "J");
- sp<DrmManagerClientImpl> old = (DrmManagerClientImpl*)env->GetIntField(thiz, fieldId);
+ jlong oldHandle = env->GetLongField(thiz, fieldId);
+ sp<DrmManagerClientImpl> old = reinterpret_cast<DrmManagerClientImpl*>(oldHandle);
if (client.get()) {
client->incStrong(thiz);
}
if (old != 0) {
old->decStrong(thiz);
}
- env->SetIntField(thiz, fieldId, (int)client.get());
+ env->SetLongField(thiz, fieldId, reinterpret_cast<jlong>(client.get()));
return old;
}
static sp<DrmManagerClientImpl> getDrmManagerClientImpl(JNIEnv* env, jobject thiz) {
Mutex::Autolock l(sLock);
jclass clazz = env->FindClass("android/drm/DrmManagerClient");
- jfieldID fieldId = env->GetFieldID(clazz, "mNativeContext", "I");
+ jfieldID fieldId = env->GetFieldID(clazz, "mNativeContext", "J");
- DrmManagerClientImpl* const client = (DrmManagerClientImpl*)env->GetIntField(thiz, fieldId);
+ jlong clientHandle = env->GetLongField(thiz, fieldId);
+ DrmManagerClientImpl* const client = reinterpret_cast<DrmManagerClientImpl*>(clientHandle);
return sp<DrmManagerClientImpl>(client);
}
@@ -214,7 +216,7 @@
setDrmManagerClientImpl(env, thiz, drmManager);
ALOGV("initialize - Exit");
- return uniqueId;
+ return static_cast<jint>(uniqueId);
}
static void android_drm_DrmManagerClient_setListeners(
@@ -406,7 +408,7 @@
delete[] mData; mData = NULL;
ALOGV("saveRights - Exit");
- return result;
+ return static_cast<jint>(result);
}
static jboolean android_drm_DrmManagerClient_canHandle(
@@ -583,7 +585,7 @@
->getDrmObjectType(uniqueId, Utility::getStringValue(env, path),
Utility::getStringValue(env, mimeType));
ALOGV("getDrmObjectType Exit");
- return drmObjectType;
+ return static_cast<jint>(drmObjectType);
}
static jstring android_drm_DrmManagerClient_getOriginalMimeType(
@@ -609,20 +611,21 @@
= getDrmManagerClientImpl(env, thiz)
->checkRightsStatus(uniqueId, Utility::getStringValue(env, path), action);
ALOGV("checkRightsStatus Exit");
- return rightsStatus;
+ return static_cast<jint>(rightsStatus);
}
static jint android_drm_DrmManagerClient_removeRights(
JNIEnv* env, jobject thiz, jint uniqueId, jstring path) {
ALOGV("removeRights");
- return getDrmManagerClientImpl(env, thiz)
- ->removeRights(uniqueId, Utility::getStringValue(env, path));
+ return static_cast<jint>(getDrmManagerClientImpl(env, thiz)
+ ->removeRights(uniqueId, Utility::getStringValue(env, path)));
}
static jint android_drm_DrmManagerClient_removeAllRights(
JNIEnv* env, jobject thiz, jint uniqueId) {
ALOGV("removeAllRights");
- return getDrmManagerClientImpl(env, thiz)->removeAllRights(uniqueId);
+ return static_cast<jint>(getDrmManagerClientImpl(env, thiz)
+ ->removeAllRights(uniqueId));
}
static jint android_drm_DrmManagerClient_openConvertSession(
@@ -632,7 +635,7 @@
= getDrmManagerClientImpl(env, thiz)
->openConvertSession(uniqueId, Utility::getStringValue(env, mimeType));
ALOGV("openConvertSession Exit");
- return convertId;
+ return static_cast<jint>(convertId);
}
static jobject GetConvertedStatus(JNIEnv* env, DrmConvertedStatus* pDrmConvertedStatus) {
@@ -686,7 +689,7 @@
}
static jobject android_drm_DrmManagerClient_closeConvertSession(
- JNIEnv* env, jobject thiz, int uniqueId, jint convertId) {
+ JNIEnv* env, jobject thiz, jint uniqueId, jint convertId) {
ALOGV("closeConvertSession Enter");
diff --git a/graphics/java/android/graphics/AvoidXfermode.java b/graphics/java/android/graphics/AvoidXfermode.java
index 5a59e36..206c959 100644
--- a/graphics/java/android/graphics/AvoidXfermode.java
+++ b/graphics/java/android/graphics/AvoidXfermode.java
@@ -56,6 +56,6 @@
native_instance = nativeCreate(opColor, tolerance, mode.nativeInt);
}
- private static native int nativeCreate(int opColor, int tolerance,
- int nativeMode);
+ private static native long nativeCreate(int opColor, int tolerance,
+ int nativeMode);
}
diff --git a/graphics/java/android/graphics/Bitmap.java b/graphics/java/android/graphics/Bitmap.java
index 3c24683..efce606 100644
--- a/graphics/java/android/graphics/Bitmap.java
+++ b/graphics/java/android/graphics/Bitmap.java
@@ -41,7 +41,7 @@
*
* @hide
*/
- public final int mNativeBitmap;
+ public final long mNativeBitmap;
/**
* Backing buffer for the Bitmap.
@@ -103,7 +103,7 @@
* int (pointer).
*/
@SuppressWarnings({"UnusedDeclaration"}) // called from JNI
- Bitmap(int nativeBitmap, byte[] buffer, int width, int height, int density,
+ Bitmap(long nativeBitmap, byte[] buffer, int width, int height, int density,
boolean isMutable, boolean isPremultiplied,
byte[] ninePatchChunk, int[] layoutBounds) {
if (nativeBitmap == 0) {
@@ -1511,7 +1511,7 @@
*/
public Bitmap extractAlpha(Paint paint, int[] offsetXY) {
checkRecycled("Can't extractAlpha on a recycled bitmap");
- int nativePaint = paint != null ? paint.mNativePaint : 0;
+ long nativePaint = paint != null ? paint.mNativePaint : 0;
Bitmap bm = nativeExtractAlpha(mNativeBitmap, nativePaint, offsetXY);
if (bm == null) {
throw new RuntimeException("Failed to extractAlpha on Bitmap");
@@ -1545,9 +1545,9 @@
}
private static class BitmapFinalizer {
- private final int mNativeBitmap;
+ private final long mNativeBitmap;
- BitmapFinalizer(int nativeBitmap) {
+ BitmapFinalizer(long nativeBitmap) {
mNativeBitmap = nativeBitmap;
}
@@ -1568,55 +1568,55 @@
private static native Bitmap nativeCreate(int[] colors, int offset,
int stride, int width, int height,
int nativeConfig, boolean mutable);
- private static native Bitmap nativeCopy(int srcBitmap, int nativeConfig,
+ private static native Bitmap nativeCopy(long nativeSrcBitmap, int nativeConfig,
boolean isMutable);
- private static native void nativeDestructor(int nativeBitmap);
- private static native boolean nativeRecycle(int nativeBitmap);
- private static native void nativeReconfigure(int nativeBitmap, int width, int height,
+ private static native void nativeDestructor(long nativeBitmap);
+ private static native boolean nativeRecycle(long nativeBitmap);
+ private static native void nativeReconfigure(long nativeBitmap, int width, int height,
int config, int allocSize);
- private static native boolean nativeCompress(int nativeBitmap, int format,
+ private static native boolean nativeCompress(long nativeBitmap, int format,
int quality, OutputStream stream,
byte[] tempStorage);
- private static native void nativeErase(int nativeBitmap, int color);
- private static native int nativeRowBytes(int nativeBitmap);
- private static native int nativeConfig(int nativeBitmap);
+ private static native void nativeErase(long nativeBitmap, int color);
+ private static native int nativeRowBytes(long nativeBitmap);
+ private static native int nativeConfig(long nativeBitmap);
- private static native int nativeGetPixel(int nativeBitmap, int x, int y,
+ private static native int nativeGetPixel(long nativeBitmap, int x, int y,
boolean isPremultiplied);
- private static native void nativeGetPixels(int nativeBitmap, int[] pixels,
+ private static native void nativeGetPixels(long nativeBitmap, int[] pixels,
int offset, int stride, int x, int y,
int width, int height, boolean isPremultiplied);
- private static native void nativeSetPixel(int nativeBitmap, int x, int y,
+ private static native void nativeSetPixel(long nativeBitmap, int x, int y,
int color, boolean isPremultiplied);
- private static native void nativeSetPixels(int nativeBitmap, int[] colors,
+ private static native void nativeSetPixels(long nativeBitmap, int[] colors,
int offset, int stride, int x, int y,
int width, int height, boolean isPremultiplied);
- private static native void nativeCopyPixelsToBuffer(int nativeBitmap,
+ private static native void nativeCopyPixelsToBuffer(long nativeBitmap,
Buffer dst);
- private static native void nativeCopyPixelsFromBuffer(int nb, Buffer src);
- private static native int nativeGenerationId(int nativeBitmap);
+ private static native void nativeCopyPixelsFromBuffer(long nativeBitmap, Buffer src);
+ private static native int nativeGenerationId(long nativeBitmap);
private static native Bitmap nativeCreateFromParcel(Parcel p);
// returns true on success
- private static native boolean nativeWriteToParcel(int nativeBitmap,
+ private static native boolean nativeWriteToParcel(long nativeBitmap,
boolean isMutable,
int density,
Parcel p);
// returns a new bitmap built from the native bitmap's alpha, and the paint
- private static native Bitmap nativeExtractAlpha(int nativeBitmap,
- int nativePaint,
+ private static native Bitmap nativeExtractAlpha(long nativeBitmap,
+ long nativePaint,
int[] offsetXY);
- private static native void nativePrepareToDraw(int nativeBitmap);
- private static native boolean nativeHasAlpha(int nativeBitmap);
- private static native void nativeSetHasAlpha(int nBitmap, boolean hasAlpha);
- private static native boolean nativeHasMipMap(int nativeBitmap);
- private static native void nativeSetHasMipMap(int nBitmap, boolean hasMipMap);
- private static native boolean nativeSameAs(int nb0, int nb1);
-
- /* package */ final int ni() {
+ private static native void nativePrepareToDraw(long nativeBitmap);
+ private static native boolean nativeHasAlpha(long nativeBitmap);
+ private static native void nativeSetHasAlpha(long nativeBitmap, boolean hasAlpha);
+ private static native boolean nativeHasMipMap(long nativeBitmap);
+ private static native void nativeSetHasMipMap(long nativeBitmap, boolean hasMipMap);
+ private static native boolean nativeSameAs(long nativeBitmap0, long nativeBitmap1);
+
+ /* package */ final long ni() {
return mNativeBitmap;
}
}
diff --git a/graphics/java/android/graphics/BitmapFactory.java b/graphics/java/android/graphics/BitmapFactory.java
index 429be49..1f35e50 100644
--- a/graphics/java/android/graphics/BitmapFactory.java
+++ b/graphics/java/android/graphics/BitmapFactory.java
@@ -583,7 +583,7 @@
Trace.traceBegin(Trace.TRACE_TAG_GRAPHICS, "decodeBitmap");
try {
if (is instanceof AssetManager.AssetInputStream) {
- final int asset = ((AssetManager.AssetInputStream) is).getAssetInt();
+ final long asset = ((AssetManager.AssetInputStream) is).getNativeAsset();
bm = nativeDecodeAsset(asset, outPadding, opts);
} else {
bm = decodeStreamInternal(is, outPadding, opts);
@@ -686,7 +686,7 @@
Rect padding, Options opts);
private static native Bitmap nativeDecodeFileDescriptor(FileDescriptor fd,
Rect padding, Options opts);
- private static native Bitmap nativeDecodeAsset(int asset, Rect padding, Options opts);
+ private static native Bitmap nativeDecodeAsset(long nativeAsset, Rect padding, Options opts);
private static native Bitmap nativeDecodeByteArray(byte[] data, int offset,
int length, Options opts);
private static native boolean nativeIsSeekable(FileDescriptor fd);
diff --git a/graphics/java/android/graphics/BitmapRegionDecoder.java b/graphics/java/android/graphics/BitmapRegionDecoder.java
index 3a99977..e689b08 100644
--- a/graphics/java/android/graphics/BitmapRegionDecoder.java
+++ b/graphics/java/android/graphics/BitmapRegionDecoder.java
@@ -33,7 +33,7 @@
*
*/
public final class BitmapRegionDecoder {
- private int mNativeBitmapRegionDecoder;
+ private long mNativeBitmapRegionDecoder;
private boolean mRecycled;
// ensures that the native decoder object exists and that only one decode can
// occur at a time.
@@ -114,7 +114,7 @@
boolean isShareable) throws IOException {
if (is instanceof AssetManager.AssetInputStream) {
return nativeNewInstance(
- ((AssetManager.AssetInputStream) is).getAssetInt(),
+ ((AssetManager.AssetInputStream) is).getNativeAsset(),
isShareable);
} else {
// pass some temp storage down to the native code. 1024 is made up,
@@ -165,7 +165,7 @@
This can be called from JNI code.
*/
- private BitmapRegionDecoder(int decoder) {
+ private BitmapRegionDecoder(long decoder) {
mNativeBitmapRegionDecoder = decoder;
mRecycled = false;
}
@@ -254,12 +254,12 @@
}
}
- private static native Bitmap nativeDecodeRegion(int lbm,
+ private static native Bitmap nativeDecodeRegion(long lbm,
int start_x, int start_y, int width, int height,
BitmapFactory.Options options);
- private static native int nativeGetWidth(int lbm);
- private static native int nativeGetHeight(int lbm);
- private static native void nativeClean(int lbm);
+ private static native int nativeGetWidth(long lbm);
+ private static native int nativeGetHeight(long lbm);
+ private static native void nativeClean(long lbm);
private static native BitmapRegionDecoder nativeNewInstance(
byte[] data, int offset, int length, boolean isShareable);
@@ -268,5 +268,5 @@
private static native BitmapRegionDecoder nativeNewInstance(
InputStream is, byte[] storage, boolean isShareable);
private static native BitmapRegionDecoder nativeNewInstance(
- int asset, boolean isShareable);
+ long asset, boolean isShareable);
}
diff --git a/graphics/java/android/graphics/BitmapShader.java b/graphics/java/android/graphics/BitmapShader.java
index a4f75b9..b7673d8 100644
--- a/graphics/java/android/graphics/BitmapShader.java
+++ b/graphics/java/android/graphics/BitmapShader.java
@@ -42,7 +42,7 @@
mBitmap = bitmap;
mTileX = tileX;
mTileY = tileY;
- final int b = bitmap.ni();
+ final long b = bitmap.ni();
native_instance = nativeCreate(b, tileX.nativeInt, tileY.nativeInt);
native_shader = nativePostCreate(native_instance, b, tileX.nativeInt, tileY.nativeInt);
}
@@ -57,8 +57,8 @@
return copy;
}
- private static native int nativeCreate(int native_bitmap, int shaderTileModeX,
+ private static native long nativeCreate(long native_bitmap, int shaderTileModeX,
int shaderTileModeY);
- private static native int nativePostCreate(int native_shader, int native_bitmap,
+ private static native long nativePostCreate(long native_shader, long native_bitmap,
int shaderTileModeX, int shaderTileModeY);
}
diff --git a/graphics/java/android/graphics/BlurMaskFilter.java b/graphics/java/android/graphics/BlurMaskFilter.java
index 5eafe76..939af52 100644
--- a/graphics/java/android/graphics/BlurMaskFilter.java
+++ b/graphics/java/android/graphics/BlurMaskFilter.java
@@ -47,5 +47,5 @@
native_instance = nativeConstructor(radius, style.native_int);
}
- private static native int nativeConstructor(float radius, int style);
+ private static native long nativeConstructor(float radius, int style);
}
diff --git a/graphics/java/android/graphics/Camera.java b/graphics/java/android/graphics/Camera.java
index 9e07bd4..c263a84 100644
--- a/graphics/java/android/graphics/Camera.java
+++ b/graphics/java/android/graphics/Camera.java
@@ -159,7 +159,7 @@
}
public native float dotWithNormal(float dx, float dy, float dz);
-
+
protected void finalize() throws Throwable {
try {
nativeDestructor();
@@ -170,8 +170,8 @@
private native void nativeConstructor();
private native void nativeDestructor();
- private native void nativeGetMatrix(int native_matrix);
- private native void nativeApplyToCanvas(int native_canvas);
-
- int native_instance;
+ private native void nativeGetMatrix(long native_matrix);
+ private native void nativeApplyToCanvas(long native_canvas);
+
+ long native_instance;
}
diff --git a/graphics/java/android/graphics/Canvas.java b/graphics/java/android/graphics/Canvas.java
index d46238f..f86840e 100644
--- a/graphics/java/android/graphics/Canvas.java
+++ b/graphics/java/android/graphics/Canvas.java
@@ -40,7 +40,7 @@
// assigned in constructors or setBitmap, freed in finalizer
/** @hide */
- public int mNativeCanvas;
+ public long mNativeCanvas;
// may be null
private Bitmap mBitmap;
@@ -84,9 +84,9 @@
private final CanvasFinalizer mFinalizer;
private static final class CanvasFinalizer {
- private int mNativeCanvas;
+ private long mNativeCanvas;
- public CanvasFinalizer(int nativeCanvas) {
+ public CanvasFinalizer(long nativeCanvas) {
mNativeCanvas = nativeCanvas;
}
@@ -144,7 +144,7 @@
}
/** @hide */
- public Canvas(int nativeCanvas) {
+ public Canvas(long nativeCanvas) {
if (nativeCanvas == 0) {
throw new IllegalStateException();
}
@@ -157,8 +157,8 @@
* Replace existing canvas while ensuring that the swap has occurred before
* the previous native canvas is unreferenced.
*/
- private void safeCanvasSwap(int nativeCanvas, boolean copyState) {
- final int oldCanvas = mNativeCanvas;
+ private void safeCanvasSwap(long nativeCanvas, boolean copyState) {
+ final long oldCanvas = mNativeCanvas;
mNativeCanvas = nativeCanvas;
mFinalizer.mNativeCanvas = nativeCanvas;
if (copyState) {
@@ -174,7 +174,7 @@
*
* @hide
*/
- public int getNativeCanvas() {
+ public long getNativeCanvas() {
return mNativeCanvas;
}
@@ -712,7 +712,7 @@
}
public void setDrawFilter(DrawFilter filter) {
- int nativeFilter = 0;
+ long nativeFilter = 0;
if (filter != null) {
nativeFilter = filter.mNativeInt;
}
@@ -1387,7 +1387,7 @@
vertOffset, texs, texOffset, colors, colorOffset,
indices, indexOffset, indexCount, paint.mNativePaint);
}
-
+
/**
* Draw the text, with origin at (x,y), using the specified paint. The
* origin is interpreted based on the Align setting in the paint.
@@ -1713,137 +1713,155 @@
*/
public static native void freeTextLayoutCaches();
- private static native int initRaster(int nativeBitmapOrZero);
- private static native void copyNativeCanvasState(int srcCanvas, int dstCanvas);
- private static native int native_saveLayer(int nativeCanvas, RectF bounds,
- int paint, int layerFlags);
- private static native int native_saveLayer(int nativeCanvas, float l,
+ private static native long initRaster(long nativeBitmapOrZero);
+ private static native void copyNativeCanvasState(long nativeSrcCanvas,
+ long nativeDstCanvas);
+ private static native int native_saveLayer(long nativeCanvas,
+ RectF bounds,
+ long nativePaint,
+ int layerFlags);
+ private static native int native_saveLayer(long nativeCanvas, float l,
float t, float r, float b,
- int paint, int layerFlags);
- private static native int native_saveLayerAlpha(int nativeCanvas,
+ long nativePaint,
+ int layerFlags);
+ private static native int native_saveLayerAlpha(long nativeCanvas,
RectF bounds, int alpha,
int layerFlags);
- private static native int native_saveLayerAlpha(int nativeCanvas, float l,
+ private static native int native_saveLayerAlpha(long nativeCanvas, float l,
float t, float r, float b,
int alpha, int layerFlags);
- private static native void native_concat(int nCanvas, int nMatrix);
- private static native void native_setMatrix(int nCanvas, int nMatrix);
- private static native boolean native_clipRect(int nCanvas,
+ private static native void native_concat(long nativeCanvas,
+ long nativeMatrix);
+ private static native void native_setMatrix(long nativeCanvas,
+ long nativeMatrix);
+ private static native boolean native_clipRect(long nativeCanvas,
float left, float top,
float right, float bottom,
int regionOp);
- private static native boolean native_clipPath(int nativeCanvas,
- int nativePath,
+ private static native boolean native_clipPath(long nativeCanvas,
+ long nativePath,
int regionOp);
- private static native boolean native_clipRegion(int nativeCanvas,
- int nativeRegion,
+ private static native boolean native_clipRegion(long nativeCanvas,
+ long nativeRegion,
int regionOp);
- private static native void nativeSetDrawFilter(int nativeCanvas,
- int nativeFilter);
- private static native boolean native_getClipBounds(int nativeCanvas,
+ private static native void nativeSetDrawFilter(long nativeCanvas,
+ long nativeFilter);
+ private static native boolean native_getClipBounds(long nativeCanvas,
Rect bounds);
- private static native void native_getCTM(int canvas, int matrix);
- private static native boolean native_quickReject(int nativeCanvas,
+ private static native void native_getCTM(long nativeCanvas,
+ long nativeMatrix);
+ private static native boolean native_quickReject(long nativeCanvas,
RectF rect);
- private static native boolean native_quickReject(int nativeCanvas,
- int path);
- private static native boolean native_quickReject(int nativeCanvas,
+ private static native boolean native_quickReject(long nativeCanvas,
+ long nativePath);
+ private static native boolean native_quickReject(long nativeCanvas,
float left, float top,
float right, float bottom);
- private static native void native_drawRGB(int nativeCanvas, int r, int g,
+ private static native void native_drawRGB(long nativeCanvas, int r, int g,
int b);
- private static native void native_drawARGB(int nativeCanvas, int a, int r,
+ private static native void native_drawARGB(long nativeCanvas, int a, int r,
int g, int b);
- private static native void native_drawColor(int nativeCanvas, int color);
- private static native void native_drawColor(int nativeCanvas, int color,
+ private static native void native_drawColor(long nativeCanvas, int color);
+ private static native void native_drawColor(long nativeCanvas, int color,
int mode);
- private static native void native_drawPaint(int nativeCanvas, int paint);
- private static native void native_drawLine(int nativeCanvas, float startX,
+ private static native void native_drawPaint(long nativeCanvas,
+ long nativePaint);
+ private static native void native_drawLine(long nativeCanvas, float startX,
float startY, float stopX,
- float stopY, int paint);
- private static native void native_drawRect(int nativeCanvas, RectF rect,
- int paint);
- private static native void native_drawRect(int nativeCanvas, float left,
+ float stopY, long nativePaint);
+ private static native void native_drawRect(long nativeCanvas, RectF rect,
+ long nativePaint);
+ private static native void native_drawRect(long nativeCanvas, float left,
float top, float right,
- float bottom, int paint);
- private static native void native_drawOval(int nativeCanvas, RectF oval,
- int paint);
- private static native void native_drawCircle(int nativeCanvas, float cx,
+ float bottom,
+ long nativePaint);
+ private static native void native_drawOval(long nativeCanvas, RectF oval,
+ long nativePaint);
+ private static native void native_drawCircle(long nativeCanvas, float cx,
float cy, float radius,
- int paint);
- private static native void native_drawArc(int nativeCanvas, RectF oval,
+ long nativePaint);
+ private static native void native_drawArc(long nativeCanvas, RectF oval,
float startAngle, float sweep,
- boolean useCenter, int paint);
- private static native void native_drawRoundRect(int nativeCanvas,
+ boolean useCenter,
+ long nativePaint);
+ private static native void native_drawRoundRect(long nativeCanvas,
RectF rect, float rx,
- float ry, int paint);
- private static native void native_drawPath(int nativeCanvas, int path,
- int paint);
- private native void native_drawBitmap(int nativeCanvas, int bitmap,
+ float ry, long nativePaint);
+ private static native void native_drawPath(long nativeCanvas,
+ long nativePath,
+ long nativePaint);
+ private native void native_drawBitmap(long nativeCanvas, long nativeBitmap,
float left, float top,
- int nativePaintOrZero,
+ long nativePaintOrZero,
int canvasDensity,
int screenDensity,
int bitmapDensity);
- private native void native_drawBitmap(int nativeCanvas, int bitmap,
+ private native void native_drawBitmap(long nativeCanvas, long nativeBitmap,
Rect src, RectF dst,
- int nativePaintOrZero,
+ long nativePaintOrZero,
int screenDensity,
int bitmapDensity);
- private static native void native_drawBitmap(int nativeCanvas, int bitmap,
+ private static native void native_drawBitmap(long nativeCanvas,
+ long nativeBitmap,
Rect src, Rect dst,
- int nativePaintOrZero,
+ long nativePaintOrZero,
int screenDensity,
int bitmapDensity);
- private static native void native_drawBitmap(int nativeCanvas, int[] colors,
+ private static native void native_drawBitmap(long nativeCanvas, int[] colors,
int offset, int stride, float x,
float y, int width, int height,
boolean hasAlpha,
- int nativePaintOrZero);
- private static native void nativeDrawBitmapMatrix(int nCanvas, int nBitmap,
- int nMatrix, int nPaint);
- private static native void nativeDrawBitmapMesh(int nCanvas, int nBitmap,
+ long nativePaintOrZero);
+ private static native void nativeDrawBitmapMatrix(long nativeCanvas,
+ long nativeBitmap,
+ long nativeMatrix,
+ long nativePaint);
+ private static native void nativeDrawBitmapMesh(long nativeCanvas,
+ long nativeBitmap,
int meshWidth, int meshHeight,
float[] verts, int vertOffset,
- int[] colors, int colorOffset, int nPaint);
- private static native void nativeDrawVertices(int nCanvas, int mode, int n,
+ int[] colors, int colorOffset,
+ long nativePaint);
+ private static native void nativeDrawVertices(long nativeCanvas, int mode, int n,
float[] verts, int vertOffset, float[] texs, int texOffset,
int[] colors, int colorOffset, short[] indices,
- int indexOffset, int indexCount, int nPaint);
-
- private static native void native_drawText(int nativeCanvas, char[] text,
+ int indexOffset, int indexCount, long nativePaint);
+
+ private static native void native_drawText(long nativeCanvas, char[] text,
int index, int count, float x,
- float y, int flags, int paint);
- private static native void native_drawText(int nativeCanvas, String text,
+ float y, int flags,
+ long nativePaint);
+ private static native void native_drawText(long nativeCanvas, String text,
int start, int end, float x,
- float y, int flags, int paint);
+ float y, int flags,
+ long nativePaint);
- private static native void native_drawTextRun(int nativeCanvas, String text,
+ private static native void native_drawTextRun(long nativeCanvas, String text,
int start, int end, int contextStart, int contextEnd,
- float x, float y, int flags, int paint);
+ float x, float y, int flags, long nativePaint);
- private static native void native_drawTextRun(int nativeCanvas, char[] text,
+ private static native void native_drawTextRun(long nativeCanvas, char[] text,
int start, int count, int contextStart, int contextCount,
- float x, float y, int flags, int paint);
+ float x, float y, int flags, long nativePaint);
- private static native void native_drawPosText(int nativeCanvas,
+ private static native void native_drawPosText(long nativeCanvas,
char[] text, int index,
int count, float[] pos,
- int paint);
- private static native void native_drawPosText(int nativeCanvas,
+ long nativePaint);
+ private static native void native_drawPosText(long nativeCanvas,
String text, float[] pos,
- int paint);
- private static native void native_drawTextOnPath(int nativeCanvas,
+ long nativePaint);
+ private static native void native_drawTextOnPath(long nativeCanvas,
char[] text, int index,
- int count, int path,
+ int count, long nativePath,
float hOffset,
float vOffset, int bidiFlags,
- int paint);
- private static native void native_drawTextOnPath(int nativeCanvas,
- String text, int path,
- float hOffset,
- float vOffset,
- int flags, int paint);
- private static native void finalizer(int nativeCanvas);
+ long nativePaint);
+ private static native void native_drawTextOnPath(long nativeCanvas,
+ String text, long nativePath,
+ float hOffset,
+ float vOffset,
+ int flags, long nativePaint);
+ private static native void finalizer(long nativeCanvas);
}
diff --git a/graphics/java/android/graphics/ColorFilter.java b/graphics/java/android/graphics/ColorFilter.java
index e5cf830..8e432da 100644
--- a/graphics/java/android/graphics/ColorFilter.java
+++ b/graphics/java/android/graphics/ColorFilter.java
@@ -23,12 +23,12 @@
public class ColorFilter {
- int native_instance;
+ long native_instance;
/**
* @hide
*/
- public int nativeColorFilter;
+ public long nativeColorFilter;
protected void finalize() throws Throwable {
try {
@@ -38,5 +38,5 @@
}
}
- private static native void finalizer(int native_instance, int nativeColorFilter);
+ private static native void finalizer(long native_instance, long nativeColorFilter);
}
diff --git a/graphics/java/android/graphics/ColorMatrixColorFilter.java b/graphics/java/android/graphics/ColorMatrixColorFilter.java
index 4f32342..21b7721 100644
--- a/graphics/java/android/graphics/ColorMatrixColorFilter.java
+++ b/graphics/java/android/graphics/ColorMatrixColorFilter.java
@@ -45,6 +45,6 @@
nativeColorFilter = nColorMatrixFilter(native_instance, array);
}
- private static native int nativeColorMatrixFilter(float[] array);
- private static native int nColorMatrixFilter(int nativeFilter, float[] array);
+ private static native long nativeColorMatrixFilter(float[] array);
+ private static native long nColorMatrixFilter(long nativeFilter, float[] array);
}
diff --git a/graphics/java/android/graphics/ComposePathEffect.java b/graphics/java/android/graphics/ComposePathEffect.java
index beac78e..3fc9eb5 100644
--- a/graphics/java/android/graphics/ComposePathEffect.java
+++ b/graphics/java/android/graphics/ComposePathEffect.java
@@ -27,6 +27,7 @@
innerpe.native_instance);
}
- private static native int nativeCreate(int outerpe, int innerpe);
+ private static native long nativeCreate(long nativeOuterpe,
+ long nativeInnerpe);
}
diff --git a/graphics/java/android/graphics/ComposeShader.java b/graphics/java/android/graphics/ComposeShader.java
index de0d3d6..5109ffd 100644
--- a/graphics/java/android/graphics/ComposeShader.java
+++ b/graphics/java/android/graphics/ComposeShader.java
@@ -104,12 +104,12 @@
return copy;
}
- private static native int nativeCreate1(int native_shaderA, int native_shaderB,
- int native_mode);
- private static native int nativeCreate2(int native_shaderA, int native_shaderB,
+ private static native long nativeCreate1(long native_shaderA, long native_shaderB,
+ long native_mode);
+ private static native long nativeCreate2(long native_shaderA, long native_shaderB,
int porterDuffMode);
- private static native int nativePostCreate1(int native_shader, int native_skiaShaderA,
- int native_skiaShaderB, int native_mode);
- private static native int nativePostCreate2(int native_shader, int native_skiaShaderA,
- int native_skiaShaderB, int porterDuffMode);
+ private static native long nativePostCreate1(long native_shader, long native_skiaShaderA,
+ long native_skiaShaderB, long native_mode);
+ private static native long nativePostCreate2(long native_shader, long native_skiaShaderA,
+ long native_skiaShaderB, int porterDuffMode);
}
diff --git a/graphics/java/android/graphics/CornerPathEffect.java b/graphics/java/android/graphics/CornerPathEffect.java
index 400c886..8f4d7d9 100644
--- a/graphics/java/android/graphics/CornerPathEffect.java
+++ b/graphics/java/android/graphics/CornerPathEffect.java
@@ -28,6 +28,6 @@
native_instance = nativeCreate(radius);
}
- private static native int nativeCreate(float radius);
+ private static native long nativeCreate(float radius);
}
diff --git a/graphics/java/android/graphics/DashPathEffect.java b/graphics/java/android/graphics/DashPathEffect.java
index 2bdecce..ef3ebe8 100644
--- a/graphics/java/android/graphics/DashPathEffect.java
+++ b/graphics/java/android/graphics/DashPathEffect.java
@@ -38,6 +38,6 @@
native_instance = nativeCreate(intervals, phase);
}
- private static native int nativeCreate(float intervals[], float phase);
+ private static native long nativeCreate(float intervals[], float phase);
}
diff --git a/graphics/java/android/graphics/DiscretePathEffect.java b/graphics/java/android/graphics/DiscretePathEffect.java
index de8b2f0..3b3c9c9 100644
--- a/graphics/java/android/graphics/DiscretePathEffect.java
+++ b/graphics/java/android/graphics/DiscretePathEffect.java
@@ -26,6 +26,6 @@
native_instance = nativeCreate(segmentLength, deviation);
}
- private static native int nativeCreate(float length, float deviation);
+ private static native long nativeCreate(float length, float deviation);
}
diff --git a/graphics/java/android/graphics/DrawFilter.java b/graphics/java/android/graphics/DrawFilter.java
index 1f64539..ed38f37 100644
--- a/graphics/java/android/graphics/DrawFilter.java
+++ b/graphics/java/android/graphics/DrawFilter.java
@@ -25,7 +25,7 @@
public class DrawFilter {
// this is set by subclasses, but don't make it public
- /* package */ int mNativeInt; // pointer to native object
+ /* package */ long mNativeInt; // pointer to native object
protected void finalize() throws Throwable {
try {
@@ -35,6 +35,6 @@
}
}
- private static native void nativeDestructor(int nativeDrawFilter);
+ private static native void nativeDestructor(long nativeDrawFilter);
}
diff --git a/graphics/java/android/graphics/EmbossMaskFilter.java b/graphics/java/android/graphics/EmbossMaskFilter.java
index 5dd8611..a9e180f 100644
--- a/graphics/java/android/graphics/EmbossMaskFilter.java
+++ b/graphics/java/android/graphics/EmbossMaskFilter.java
@@ -33,6 +33,6 @@
native_instance = nativeConstructor(direction, ambient, specular, blurRadius);
}
- private static native int nativeConstructor(float[] direction, float ambient, float specular, float blurRadius);
+ private static native long nativeConstructor(float[] direction, float ambient, float specular, float blurRadius);
}
diff --git a/graphics/java/android/graphics/Interpolator.java b/graphics/java/android/graphics/Interpolator.java
index 75851a6..f695a9e 100644
--- a/graphics/java/android/graphics/Interpolator.java
+++ b/graphics/java/android/graphics/Interpolator.java
@@ -151,13 +151,13 @@
private int mValueCount;
private int mFrameCount;
- private final int native_instance;
+ private final long native_instance;
- private static native int nativeConstructor(int valueCount, int frameCount);
- private static native void nativeDestructor(int native_instance);
- private static native void nativeReset(int native_instance, int valueCount, int frameCount);
- private static native void nativeSetKeyFrame(int native_instance, int index, int msec, float[] values, float[] blend);
- private static native void nativeSetRepeatMirror(int native_instance, float repeatCount, boolean mirror);
- private static native int nativeTimeToValues(int native_instance, int msec, float[] values);
+ private static native long nativeConstructor(int valueCount, int frameCount);
+ private static native void nativeDestructor(long native_instance);
+ private static native void nativeReset(long native_instance, int valueCount, int frameCount);
+ private static native void nativeSetKeyFrame(long native_instance, int index, int msec, float[] values, float[] blend);
+ private static native void nativeSetRepeatMirror(long native_instance, float repeatCount, boolean mirror);
+ private static native int nativeTimeToValues(long native_instance, int msec, float[] values);
}
diff --git a/graphics/java/android/graphics/LargeBitmap.java b/graphics/java/android/graphics/LargeBitmap.java
index 6656b17..238b32a 100644
--- a/graphics/java/android/graphics/LargeBitmap.java
+++ b/graphics/java/android/graphics/LargeBitmap.java
@@ -37,7 +37,7 @@
* @hide
*/
public final class LargeBitmap {
- private int mNativeLargeBitmap;
+ private long mNativeLargeBitmap;
private boolean mRecycled;
/* Private constructor that must received an already allocated native
@@ -45,8 +45,8 @@
This can be called from JNI code.
*/
- private LargeBitmap(int lbm) {
- mNativeLargeBitmap = lbm;
+ private LargeBitmap(long nativeLbm) {
+ mNativeLargeBitmap = nativeLbm;
mRecycled = false;
}
@@ -119,10 +119,10 @@
recycle();
}
- private static native Bitmap nativeDecodeRegion(int lbm,
+ private static native Bitmap nativeDecodeRegion(long nativeLbm,
int start_x, int start_y, int width, int height,
BitmapFactory.Options options);
- private static native int nativeGetWidth(int lbm);
- private static native int nativeGetHeight(int lbm);
- private static native void nativeClean(int lbm);
+ private static native int nativeGetWidth(long nativeLbm);
+ private static native int nativeGetHeight(long nativeLbm);
+ private static native void nativeClean(long nativeLbm);
}
diff --git a/graphics/java/android/graphics/LayerRasterizer.java b/graphics/java/android/graphics/LayerRasterizer.java
index 9bd55a5..dc307c6 100644
--- a/graphics/java/android/graphics/LayerRasterizer.java
+++ b/graphics/java/android/graphics/LayerRasterizer.java
@@ -34,7 +34,7 @@
nativeAddLayer(native_instance, paint.mNativePaint, 0, 0);
}
- private static native int nativeConstructor();
- private static native void nativeAddLayer(int native_layer, int native_paint, float dx, float dy);
+ private static native long nativeConstructor();
+ private static native void nativeAddLayer(long native_layer, long native_paint, float dx, float dy);
}
diff --git a/graphics/java/android/graphics/LightingColorFilter.java b/graphics/java/android/graphics/LightingColorFilter.java
index c621de6..fbd2694 100644
--- a/graphics/java/android/graphics/LightingColorFilter.java
+++ b/graphics/java/android/graphics/LightingColorFilter.java
@@ -33,6 +33,6 @@
nativeColorFilter = nCreateLightingFilter(native_instance, mul, add);
}
- private static native int native_CreateLightingFilter(int mul, int add);
- private static native int nCreateLightingFilter(int nativeFilter, int mul, int add);
+ private static native long native_CreateLightingFilter(int mul, int add);
+ private static native long nCreateLightingFilter(long nativeFilter, int mul, int add);
}
diff --git a/graphics/java/android/graphics/LinearGradient.java b/graphics/java/android/graphics/LinearGradient.java
index 4c88de3..9ad3e49 100644
--- a/graphics/java/android/graphics/LinearGradient.java
+++ b/graphics/java/android/graphics/LinearGradient.java
@@ -116,12 +116,12 @@
return copy;
}
- private native int nativeCreate1(float x0, float y0, float x1, float y1,
+ private native long nativeCreate1(float x0, float y0, float x1, float y1,
int colors[], float positions[], int tileMode);
- private native int nativeCreate2(float x0, float y0, float x1, float y1,
+ private native long nativeCreate2(float x0, float y0, float x1, float y1,
int color0, int color1, int tileMode);
- private native int nativePostCreate1(int native_shader, float x0, float y0, float x1, float y1,
+ private native long nativePostCreate1(long native_shader, float x0, float y0, float x1, float y1,
int colors[], float positions[], int tileMode);
- private native int nativePostCreate2(int native_shader, float x0, float y0, float x1, float y1,
+ private native long nativePostCreate2(long native_shader, float x0, float y0, float x1, float y1,
int color0, int color1, int tileMode);
}
diff --git a/graphics/java/android/graphics/MaskFilter.java b/graphics/java/android/graphics/MaskFilter.java
index 4ebb619..27a7dda 100644
--- a/graphics/java/android/graphics/MaskFilter.java
+++ b/graphics/java/android/graphics/MaskFilter.java
@@ -27,6 +27,6 @@
nativeDestructor(native_instance);
}
- private static native void nativeDestructor(int native_filter);
- int native_instance;
+ private static native void nativeDestructor(long native_filter);
+ long native_instance;
}
diff --git a/graphics/java/android/graphics/Matrix.java b/graphics/java/android/graphics/Matrix.java
index 32e0c01..c8bcf26 100644
--- a/graphics/java/android/graphics/Matrix.java
+++ b/graphics/java/android/graphics/Matrix.java
@@ -219,7 +219,7 @@
/**
* @hide
*/
- public int native_instance;
+ public long native_instance;
/**
* Create an identity matrix
@@ -800,83 +800,86 @@
}
}
- /*package*/ final int ni() {
+ /*package*/ final long ni() {
return native_instance;
}
- private static native int native_create(int native_src_or_zero);
- private static native boolean native_isIdentity(int native_object);
- private static native boolean native_rectStaysRect(int native_object);
- private static native void native_reset(int native_object);
- private static native void native_set(int native_object, int other);
- private static native void native_setTranslate(int native_object,
+ private static native long native_create(long native_src_or_zero);
+ private static native boolean native_isIdentity(long native_object);
+ private static native boolean native_rectStaysRect(long native_object);
+ private static native void native_reset(long native_object);
+ private static native void native_set(long native_object,
+ long native_other);
+ private static native void native_setTranslate(long native_object,
float dx, float dy);
- private static native void native_setScale(int native_object,
+ private static native void native_setScale(long native_object,
float sx, float sy, float px, float py);
- private static native void native_setScale(int native_object,
+ private static native void native_setScale(long native_object,
float sx, float sy);
- private static native void native_setRotate(int native_object,
+ private static native void native_setRotate(long native_object,
float degrees, float px, float py);
- private static native void native_setRotate(int native_object,
+ private static native void native_setRotate(long native_object,
float degrees);
- private static native void native_setSinCos(int native_object,
+ private static native void native_setSinCos(long native_object,
float sinValue, float cosValue, float px, float py);
- private static native void native_setSinCos(int native_object,
+ private static native void native_setSinCos(long native_object,
float sinValue, float cosValue);
- private static native void native_setSkew(int native_object,
+ private static native void native_setSkew(long native_object,
float kx, float ky, float px, float py);
- private static native void native_setSkew(int native_object,
+ private static native void native_setSkew(long native_object,
float kx, float ky);
- private static native boolean native_setConcat(int native_object,
- int a, int b);
- private static native boolean native_preTranslate(int native_object,
+ private static native boolean native_setConcat(long native_object,
+ long native_a,
+ long native_b);
+ private static native boolean native_preTranslate(long native_object,
float dx, float dy);
- private static native boolean native_preScale(int native_object,
+ private static native boolean native_preScale(long native_object,
float sx, float sy, float px, float py);
- private static native boolean native_preScale(int native_object,
+ private static native boolean native_preScale(long native_object,
float sx, float sy);
- private static native boolean native_preRotate(int native_object,
+ private static native boolean native_preRotate(long native_object,
float degrees, float px, float py);
- private static native boolean native_preRotate(int native_object,
+ private static native boolean native_preRotate(long native_object,
float degrees);
- private static native boolean native_preSkew(int native_object,
+ private static native boolean native_preSkew(long native_object,
float kx, float ky, float px, float py);
- private static native boolean native_preSkew(int native_object,
+ private static native boolean native_preSkew(long native_object,
float kx, float ky);
- private static native boolean native_preConcat(int native_object,
- int other_matrix);
- private static native boolean native_postTranslate(int native_object,
+ private static native boolean native_preConcat(long native_object,
+ long native_other_matrix);
+ private static native boolean native_postTranslate(long native_object,
float dx, float dy);
- private static native boolean native_postScale(int native_object,
+ private static native boolean native_postScale(long native_object,
float sx, float sy, float px, float py);
- private static native boolean native_postScale(int native_object,
+ private static native boolean native_postScale(long native_object,
float sx, float sy);
- private static native boolean native_postRotate(int native_object,
+ private static native boolean native_postRotate(long native_object,
float degrees, float px, float py);
- private static native boolean native_postRotate(int native_object,
+ private static native boolean native_postRotate(long native_object,
float degrees);
- private static native boolean native_postSkew(int native_object,
+ private static native boolean native_postSkew(long native_object,
float kx, float ky, float px, float py);
- private static native boolean native_postSkew(int native_object,
+ private static native boolean native_postSkew(long native_object,
float kx, float ky);
- private static native boolean native_postConcat(int native_object,
- int other_matrix);
- private static native boolean native_setRectToRect(int native_object,
+ private static native boolean native_postConcat(long native_object,
+ long native_other_matrix);
+ private static native boolean native_setRectToRect(long native_object,
RectF src, RectF dst, int stf);
- private static native boolean native_setPolyToPoly(int native_object,
+ private static native boolean native_setPolyToPoly(long native_object,
float[] src, int srcIndex, float[] dst, int dstIndex, int pointCount);
- private static native boolean native_invert(int native_object, int inverse);
- private static native void native_mapPoints(int native_object,
+ private static native boolean native_invert(long native_object,
+ long native_inverse);
+ private static native void native_mapPoints(long native_object,
float[] dst, int dstIndex, float[] src, int srcIndex,
int ptCount, boolean isPts);
- private static native boolean native_mapRect(int native_object,
+ private static native boolean native_mapRect(long native_object,
RectF dst, RectF src);
- private static native float native_mapRadius(int native_object,
+ private static native float native_mapRadius(long native_object,
float radius);
- private static native void native_getValues(int native_object,
+ private static native void native_getValues(long native_object,
float[] values);
- private static native void native_setValues(int native_object,
+ private static native void native_setValues(long native_object,
float[] values);
- private static native boolean native_equals(int native_a, int native_b);
- private static native void finalizer(int native_instance);
+ private static native boolean native_equals(long native_a, long native_b);
+ private static native void finalizer(long native_instance);
}
diff --git a/graphics/java/android/graphics/Movie.java b/graphics/java/android/graphics/Movie.java
index 9419faf..b0a4553 100644
--- a/graphics/java/android/graphics/Movie.java
+++ b/graphics/java/android/graphics/Movie.java
@@ -21,9 +21,9 @@
import java.io.FileInputStream;
public class Movie {
- private final int mNativeMovie;
+ private final long mNativeMovie;
- private Movie(int nativeMovie) {
+ private Movie(long nativeMovie) {
if (nativeMovie == 0) {
throw new RuntimeException("native movie creation failed");
}
@@ -48,19 +48,19 @@
return null;
}
if (is instanceof AssetManager.AssetInputStream) {
- final int asset = ((AssetManager.AssetInputStream) is).getAssetInt();
+ final long asset = ((AssetManager.AssetInputStream) is).getNativeAsset();
return nativeDecodeAsset(asset);
}
return nativeDecodeStream(is);
}
- private static native Movie nativeDecodeAsset(int asset);
+ private static native Movie nativeDecodeAsset(long asset);
private static native Movie nativeDecodeStream(InputStream is);
public static native Movie decodeByteArray(byte[] data, int offset,
int length);
- private static native void nativeDestructor(int nativeMovie);
+ private static native void nativeDestructor(long nativeMovie);
public static Movie decodeFile(String pathName) {
InputStream is;
diff --git a/graphics/java/android/graphics/NinePatch.java b/graphics/java/android/graphics/NinePatch.java
index 528d9de..69089b1 100644
--- a/graphics/java/android/graphics/NinePatch.java
+++ b/graphics/java/android/graphics/NinePatch.java
@@ -39,7 +39,7 @@
*
* @hide
*/
- public final int mNativeChunk;
+ public final long mNativeChunk;
private Paint mPaint;
private String mSrcName;
@@ -217,7 +217,7 @@
* that are transparent.
*/
public final Region getTransparentRegion(Rect bounds) {
- int r = nativeGetTransparentRegion(mBitmap.ni(), mNativeChunk, bounds);
+ long r = nativeGetTransparentRegion(mBitmap.ni(), mNativeChunk, bounds);
return r != 0 ? new Region(r) : null;
}
@@ -236,11 +236,11 @@
* If validation is successful, this method returns a native Res_png_9patch*
* object used by the renderers.
*/
- private static native int validateNinePatchChunk(int bitmap, byte[] chunk);
- private static native void nativeFinalize(int chunk);
- private static native void nativeDraw(int canvas_instance, RectF loc, int bitmap_instance,
- int c, int paint_instance_or_null, int destDensity, int srcDensity);
- private static native void nativeDraw(int canvas_instance, Rect loc, int bitmap_instance,
- int c, int paint_instance_or_null, int destDensity, int srcDensity);
- private static native int nativeGetTransparentRegion(int bitmap, int chunk, Rect location);
+ private static native long validateNinePatchChunk(long bitmap, byte[] chunk);
+ private static native void nativeFinalize(long chunk);
+ private static native void nativeDraw(long canvas_instance, RectF loc, long bitmap_instance,
+ long c, long paint_instance_or_null, int destDensity, int srcDensity);
+ private static native void nativeDraw(long canvas_instance, Rect loc, long bitmap_instance,
+ long c, long paint_instance_or_null, int destDensity, int srcDensity);
+ private static native long nativeGetTransparentRegion(long bitmap, long chunk, Rect location);
}
diff --git a/graphics/java/android/graphics/Paint.java b/graphics/java/android/graphics/Paint.java
index 5fc2588..33832a7 100644
--- a/graphics/java/android/graphics/Paint.java
+++ b/graphics/java/android/graphics/Paint.java
@@ -32,7 +32,7 @@
/**
* @hide
*/
- public int mNativePaint;
+ public long mNativePaint;
private ColorFilter mColorFilter;
private MaskFilter mMaskFilter;
@@ -943,7 +943,7 @@
* @return shader
*/
public Shader setShader(Shader shader) {
- int shaderNative = 0;
+ long shaderNative = 0;
if (shader != null)
shaderNative = shader.native_instance;
native_setShader(mNativePaint, shaderNative);
@@ -967,7 +967,7 @@
* @return filter
*/
public ColorFilter setColorFilter(ColorFilter filter) {
- int filterNative = 0;
+ long filterNative = 0;
if (filter != null)
filterNative = filter.native_instance;
native_setColorFilter(mNativePaint, filterNative);
@@ -994,7 +994,7 @@
* @return xfermode
*/
public Xfermode setXfermode(Xfermode xfermode) {
- int xfermodeNative = 0;
+ long xfermodeNative = 0;
if (xfermode != null)
xfermodeNative = xfermode.native_instance;
native_setXfermode(mNativePaint, xfermodeNative);
@@ -1021,7 +1021,7 @@
* @return effect
*/
public PathEffect setPathEffect(PathEffect effect) {
- int effectNative = 0;
+ long effectNative = 0;
if (effect != null) {
effectNative = effect.native_instance;
}
@@ -1050,7 +1050,7 @@
* @return maskfilter
*/
public MaskFilter setMaskFilter(MaskFilter maskfilter) {
- int maskfilterNative = 0;
+ long maskfilterNative = 0;
if (maskfilter != null) {
maskfilterNative = maskfilter.native_instance;
}
@@ -1081,7 +1081,7 @@
* @return typeface
*/
public Typeface setTypeface(Typeface typeface) {
- int typefaceNative = 0;
+ long typefaceNative = 0;
if (typeface != null) {
typefaceNative = typeface.native_instance;
}
@@ -1112,7 +1112,7 @@
* @return rasterizer
*/
public Rasterizer setRasterizer(Rasterizer rasterizer) {
- int rasterizerNative = 0;
+ long rasterizerNative = 0;
if (rasterizer != null) {
rasterizerNative = rasterizer.native_instance;
}
@@ -2207,68 +2207,68 @@
}
}
- private static native int native_init();
- private static native int native_initWithPaint(int paint);
- private static native void native_reset(int native_object);
- private static native void native_set(int native_dst, int native_src);
- private static native int native_getStyle(int native_object);
- private static native void native_setStyle(int native_object, int style);
- private static native int native_getStrokeCap(int native_object);
- private static native void native_setStrokeCap(int native_object, int cap);
- private static native int native_getStrokeJoin(int native_object);
- private static native void native_setStrokeJoin(int native_object,
+ private static native long native_init();
+ private static native long native_initWithPaint(long paint);
+ private static native void native_reset(long native_object);
+ private static native void native_set(long native_dst, long native_src);
+ private static native int native_getStyle(long native_object);
+ private static native void native_setStyle(long native_object, int style);
+ private static native int native_getStrokeCap(long native_object);
+ private static native void native_setStrokeCap(long native_object, int cap);
+ private static native int native_getStrokeJoin(long native_object);
+ private static native void native_setStrokeJoin(long native_object,
int join);
- private static native boolean native_getFillPath(int native_object,
- int src, int dst);
- private static native int native_setShader(int native_object, int shader);
- private static native int native_setColorFilter(int native_object,
- int filter);
- private static native int native_setXfermode(int native_object,
- int xfermode);
- private static native int native_setPathEffect(int native_object,
- int effect);
- private static native int native_setMaskFilter(int native_object,
- int maskfilter);
- private static native int native_setTypeface(int native_object,
- int typeface);
- private static native int native_setRasterizer(int native_object,
- int rasterizer);
+ private static native boolean native_getFillPath(long native_object,
+ long src, long dst);
+ private static native long native_setShader(long native_object, long shader);
+ private static native long native_setColorFilter(long native_object,
+ long filter);
+ private static native long native_setXfermode(long native_object,
+ long xfermode);
+ private static native long native_setPathEffect(long native_object,
+ long effect);
+ private static native long native_setMaskFilter(long native_object,
+ long maskfilter);
+ private static native long native_setTypeface(long native_object,
+ long typeface);
+ private static native long native_setRasterizer(long native_object,
+ long rasterizer);
- private static native int native_getTextAlign(int native_object);
- private static native void native_setTextAlign(int native_object,
+ private static native int native_getTextAlign(long native_object);
+ private static native void native_setTextAlign(long native_object,
int align);
- private static native void native_setTextLocale(int native_object,
+ private static native void native_setTextLocale(long native_object,
String locale);
- private static native int native_getTextWidths(int native_object,
+ private static native int native_getTextWidths(long native_object,
char[] text, int index, int count, int bidiFlags, float[] widths);
- private static native int native_getTextWidths(int native_object,
+ private static native int native_getTextWidths(long native_object,
String text, int start, int end, int bidiFlags, float[] widths);
- private static native int native_getTextGlyphs(int native_object,
+ private static native int native_getTextGlyphs(long native_object,
String text, int start, int end, int contextStart, int contextEnd,
int flags, char[] glyphs);
- private static native float native_getTextRunAdvances(int native_object,
+ private static native float native_getTextRunAdvances(long native_object,
char[] text, int index, int count, int contextIndex, int contextCount,
int flags, float[] advances, int advancesIndex);
- private static native float native_getTextRunAdvances(int native_object,
+ private static native float native_getTextRunAdvances(long native_object,
String text, int start, int end, int contextStart, int contextEnd,
int flags, float[] advances, int advancesIndex);
- private native int native_getTextRunCursor(int native_object, char[] text,
+ private native int native_getTextRunCursor(long native_object, char[] text,
int contextStart, int contextLength, int flags, int offset, int cursorOpt);
- private native int native_getTextRunCursor(int native_object, String text,
+ private native int native_getTextRunCursor(long native_object, String text,
int contextStart, int contextEnd, int flags, int offset, int cursorOpt);
- private static native void native_getTextPath(int native_object, int bidiFlags,
- char[] text, int index, int count, float x, float y, int path);
- private static native void native_getTextPath(int native_object, int bidiFlags,
- String text, int start, int end, float x, float y, int path);
- private static native void nativeGetStringBounds(int nativePaint,
+ private static native void native_getTextPath(long native_object, int bidiFlags,
+ char[] text, int index, int count, float x, float y, long path);
+ private static native void native_getTextPath(long native_object, int bidiFlags,
+ String text, int start, int end, float x, float y, long path);
+ private static native void nativeGetStringBounds(long nativePaint,
String text, int start, int end, int bidiFlags, Rect bounds);
- private static native void nativeGetCharArrayBounds(int nativePaint,
+ private static native void nativeGetCharArrayBounds(long nativePaint,
char[] text, int index, int count, int bidiFlags, Rect bounds);
- private static native void finalizer(int nativePaint);
+ private static native void finalizer(long nativePaint);
}
diff --git a/graphics/java/android/graphics/PaintFlagsDrawFilter.java b/graphics/java/android/graphics/PaintFlagsDrawFilter.java
index c833a12..65a6218 100644
--- a/graphics/java/android/graphics/PaintFlagsDrawFilter.java
+++ b/graphics/java/android/graphics/PaintFlagsDrawFilter.java
@@ -38,6 +38,6 @@
mNativeInt = nativeConstructor(clearBits, setBits);
}
- private static native int nativeConstructor(int clearBits, int setBits);
+ private static native long nativeConstructor(int clearBits, int setBits);
}
diff --git a/graphics/java/android/graphics/Path.java b/graphics/java/android/graphics/Path.java
index 5b04a91..b5a1f64 100644
--- a/graphics/java/android/graphics/Path.java
+++ b/graphics/java/android/graphics/Path.java
@@ -29,7 +29,7 @@
/**
* @hide
*/
- public final int mNativePath;
+ public final long mNativePath;
/**
* @hide
@@ -56,7 +56,7 @@
* @param src The path to copy from when initializing the new path
*/
public Path(Path src) {
- int valNative = 0;
+ long valNative = 0;
if (src != null) {
valNative = src.mNativePath;
isSimplePath = src.isSimplePath;
@@ -634,7 +634,7 @@
* the original path is modified.
*/
public void offset(float dx, float dy, Path dst) {
- int dstNative = 0;
+ long dstNative = 0;
if (dst != null) {
dstNative = dst.mNativePath;
dst.isSimplePath = false;
@@ -673,7 +673,7 @@
* then the the original path is modified
*/
public void transform(Matrix matrix, Path dst) {
- int dstNative = 0;
+ long dstNative = 0;
if (dst != null) {
dst.isSimplePath = false;
dstNative = dst.mNativePath;
@@ -699,54 +699,54 @@
}
}
- final int ni() {
+ final long ni() {
return mNativePath;
}
- private static native int init1();
- private static native int init2(int nPath);
- private static native void native_reset(int nPath);
- private static native void native_rewind(int nPath);
- private static native void native_set(int native_dst, int native_src);
- private static native int native_getFillType(int nPath);
- private static native void native_setFillType(int nPath, int ft);
- private static native boolean native_isEmpty(int nPath);
- private static native boolean native_isRect(int nPath, RectF rect);
- private static native void native_computeBounds(int nPath, RectF bounds);
- private static native void native_incReserve(int nPath, int extraPtCount);
- private static native void native_moveTo(int nPath, float x, float y);
- private static native void native_rMoveTo(int nPath, float dx, float dy);
- private static native void native_lineTo(int nPath, float x, float y);
- private static native void native_rLineTo(int nPath, float dx, float dy);
- private static native void native_quadTo(int nPath, float x1, float y1,
+ private static native long init1();
+ private static native long init2(long nPath);
+ private static native void native_reset(long nPath);
+ private static native void native_rewind(long nPath);
+ private static native void native_set(long native_dst, long native_src);
+ private static native int native_getFillType(long nPath);
+ private static native void native_setFillType(long nPath, int ft);
+ private static native boolean native_isEmpty(long nPath);
+ private static native boolean native_isRect(long nPath, RectF rect);
+ private static native void native_computeBounds(long nPath, RectF bounds);
+ private static native void native_incReserve(long nPath, int extraPtCount);
+ private static native void native_moveTo(long nPath, float x, float y);
+ private static native void native_rMoveTo(long nPath, float dx, float dy);
+ private static native void native_lineTo(long nPath, float x, float y);
+ private static native void native_rLineTo(long nPath, float dx, float dy);
+ private static native void native_quadTo(long nPath, float x1, float y1,
float x2, float y2);
- private static native void native_rQuadTo(int nPath, float dx1, float dy1,
+ private static native void native_rQuadTo(long nPath, float dx1, float dy1,
float dx2, float dy2);
- private static native void native_cubicTo(int nPath, float x1, float y1,
+ private static native void native_cubicTo(long nPath, float x1, float y1,
float x2, float y2, float x3, float y3);
- private static native void native_rCubicTo(int nPath, float x1, float y1,
+ private static native void native_rCubicTo(long nPath, float x1, float y1,
float x2, float y2, float x3, float y3);
- private static native void native_arcTo(int nPath, RectF oval,
+ private static native void native_arcTo(long nPath, RectF oval,
float startAngle, float sweepAngle, boolean forceMoveTo);
- private static native void native_close(int nPath);
- private static native void native_addRect(int nPath, RectF rect, int dir);
- private static native void native_addRect(int nPath, float left, float top,
+ private static native void native_close(long nPath);
+ private static native void native_addRect(long nPath, RectF rect, int dir);
+ private static native void native_addRect(long nPath, float left, float top,
float right, float bottom, int dir);
- private static native void native_addOval(int nPath, RectF oval, int dir);
- private static native void native_addCircle(int nPath, float x, float y, float radius, int dir);
- private static native void native_addArc(int nPath, RectF oval,
+ private static native void native_addOval(long nPath, RectF oval, int dir);
+ private static native void native_addCircle(long nPath, float x, float y, float radius, int dir);
+ private static native void native_addArc(long nPath, RectF oval,
float startAngle, float sweepAngle);
- private static native void native_addRoundRect(int nPath, RectF rect,
+ private static native void native_addRoundRect(long nPath, RectF rect,
float rx, float ry, int dir);
- private static native void native_addRoundRect(int nPath, RectF r, float[] radii, int dir);
- private static native void native_addPath(int nPath, int src, float dx, float dy);
- private static native void native_addPath(int nPath, int src);
- private static native void native_addPath(int nPath, int src, int matrix);
- private static native void native_offset(int nPath, float dx, float dy, int dst_path);
- private static native void native_offset(int nPath, float dx, float dy);
- private static native void native_setLastPoint(int nPath, float dx, float dy);
- private static native void native_transform(int nPath, int matrix, int dst_path);
- private static native void native_transform(int nPath, int matrix);
- private static native boolean native_op(int path1, int path2, int op, int result);
- private static native void finalizer(int nPath);
+ private static native void native_addRoundRect(long nPath, RectF r, float[] radii, int dir);
+ private static native void native_addPath(long nPath, long src, float dx, float dy);
+ private static native void native_addPath(long nPath, long src);
+ private static native void native_addPath(long nPath, long src, long matrix);
+ private static native void native_offset(long nPath, float dx, float dy, long dst_path);
+ private static native void native_offset(long nPath, float dx, float dy);
+ private static native void native_setLastPoint(long nPath, float dx, float dy);
+ private static native void native_transform(long nPath, long matrix, long dst_path);
+ private static native void native_transform(long nPath, long matrix);
+ private static native boolean native_op(long path1, long path2, int op, long result);
+ private static native void finalizer(long nPath);
}
diff --git a/graphics/java/android/graphics/PathDashPathEffect.java b/graphics/java/android/graphics/PathDashPathEffect.java
index e8ad5fd8..4f43f68 100644
--- a/graphics/java/android/graphics/PathDashPathEffect.java
+++ b/graphics/java/android/graphics/PathDashPathEffect.java
@@ -45,7 +45,7 @@
style.native_style);
}
- private static native int nativeCreate(int native_path, float advance,
+ private static native long nativeCreate(long native_path, float advance,
float phase, int native_style);
}
diff --git a/graphics/java/android/graphics/PathEffect.java b/graphics/java/android/graphics/PathEffect.java
index 9b2cd66..617dfca 100644
--- a/graphics/java/android/graphics/PathEffect.java
+++ b/graphics/java/android/graphics/PathEffect.java
@@ -27,6 +27,6 @@
nativeDestructor(native_instance);
}
- private static native void nativeDestructor(int native_patheffect);
- int native_instance;
+ private static native void nativeDestructor(long native_patheffect);
+ long native_instance;
}
diff --git a/graphics/java/android/graphics/PathMeasure.java b/graphics/java/android/graphics/PathMeasure.java
index 7062824..e56716f 100644
--- a/graphics/java/android/graphics/PathMeasure.java
+++ b/graphics/java/android/graphics/PathMeasure.java
@@ -138,16 +138,16 @@
native_destroy(native_instance);
}
- private static native int native_create(int native_path, boolean forceClosed);
- private static native void native_setPath(int native_instance, int native_path, boolean forceClosed);
- private static native float native_getLength(int native_instance);
- private static native boolean native_getPosTan(int native_instance, float distance, float pos[], float tan[]);
- private static native boolean native_getMatrix(int native_instance, float distance, int native_matrix, int flags);
- private static native boolean native_getSegment(int native_instance, float startD, float stopD, int native_path, boolean startWithMoveTo);
- private static native boolean native_isClosed(int native_instance);
- private static native boolean native_nextContour(int native_instance);
- private static native void native_destroy(int native_instance);
+ private static native long native_create(long native_path, boolean forceClosed);
+ private static native void native_setPath(long native_instance, long native_path, boolean forceClosed);
+ private static native float native_getLength(long native_instance);
+ private static native boolean native_getPosTan(long native_instance, float distance, float pos[], float tan[]);
+ private static native boolean native_getMatrix(long native_instance, float distance, long native_matrix, int flags);
+ private static native boolean native_getSegment(long native_instance, float startD, float stopD, long native_path, boolean startWithMoveTo);
+ private static native boolean native_isClosed(long native_instance);
+ private static native boolean native_nextContour(long native_instance);
+ private static native void native_destroy(long native_instance);
- /* package */private final int native_instance;
+ /* package */private final long native_instance;
}
diff --git a/graphics/java/android/graphics/Picture.java b/graphics/java/android/graphics/Picture.java
index 71e02f6..25188e0 100644
--- a/graphics/java/android/graphics/Picture.java
+++ b/graphics/java/android/graphics/Picture.java
@@ -29,7 +29,7 @@
*/
public class Picture {
private Canvas mRecordingCanvas;
- private final int mNativePicture;
+ private final long mNativePicture;
/**
* @hide
@@ -63,7 +63,7 @@
* into it.
*/
public Canvas beginRecording(int width, int height) {
- int ni = nativeBeginRecording(mNativePicture, width, height);
+ long ni = nativeBeginRecording(mNativePicture, width, height);
mRecordingCanvas = new RecordingCanvas(this, ni);
return mRecordingCanvas;
}
@@ -164,11 +164,11 @@
}
}
- final int ni() {
+ final long ni() {
return mNativePicture;
}
- private Picture(int nativePicture, boolean fromStream) {
+ private Picture(long nativePicture, boolean fromStream) {
if (nativePicture == 0) {
throw new RuntimeException();
}
@@ -177,21 +177,21 @@
}
// return empty picture if src is 0, or a copy of the native src
- private static native int nativeConstructor(int nativeSrcOr0);
- private static native int nativeCreateFromStream(InputStream stream,
+ private static native long nativeConstructor(long nativeSrcOr0);
+ private static native long nativeCreateFromStream(InputStream stream,
byte[] storage);
- private static native int nativeBeginRecording(int nativeCanvas,
+ private static native long nativeBeginRecording(long nativeCanvas,
int w, int h);
- private static native void nativeEndRecording(int nativeCanvas);
- private static native void nativeDraw(int nativeCanvas, int nativePicture);
- private static native boolean nativeWriteToStream(int nativePicture,
+ private static native void nativeEndRecording(long nativeCanvas);
+ private static native void nativeDraw(long nativeCanvas, long nativePicture);
+ private static native boolean nativeWriteToStream(long nativePicture,
OutputStream stream, byte[] storage);
- private static native void nativeDestructor(int nativePicture);
+ private static native void nativeDestructor(long nativePicture);
private static class RecordingCanvas extends Canvas {
private final Picture mPicture;
- public RecordingCanvas(Picture pict, int nativeCanvas) {
+ public RecordingCanvas(Picture pict, long nativeCanvas) {
super(nativeCanvas);
mPicture = pict;
}
diff --git a/graphics/java/android/graphics/PixelXorXfermode.java b/graphics/java/android/graphics/PixelXorXfermode.java
index 6075ec3..0080e65 100644
--- a/graphics/java/android/graphics/PixelXorXfermode.java
+++ b/graphics/java/android/graphics/PixelXorXfermode.java
@@ -29,5 +29,5 @@
native_instance = nativeCreate(opColor);
}
- private static native int nativeCreate(int opColor);
+ private static native long nativeCreate(int opColor);
}
diff --git a/graphics/java/android/graphics/PorterDuffColorFilter.java b/graphics/java/android/graphics/PorterDuffColorFilter.java
index ecc7c24..894284f 100644
--- a/graphics/java/android/graphics/PorterDuffColorFilter.java
+++ b/graphics/java/android/graphics/PorterDuffColorFilter.java
@@ -29,7 +29,7 @@
nativeColorFilter = nCreatePorterDuffFilter(native_instance, srcColor, mode.nativeInt);
}
- private static native int native_CreatePorterDuffFilter(int srcColor, int porterDuffMode);
- private static native int nCreatePorterDuffFilter(int nativeFilter, int srcColor,
+ private static native long native_CreatePorterDuffFilter(int srcColor, int porterDuffMode);
+ private static native long nCreatePorterDuffFilter(long nativeFilter, int srcColor,
int porterDuffMode);
}
diff --git a/graphics/java/android/graphics/PorterDuffXfermode.java b/graphics/java/android/graphics/PorterDuffXfermode.java
index 6ba064c..d9d7689 100644
--- a/graphics/java/android/graphics/PorterDuffXfermode.java
+++ b/graphics/java/android/graphics/PorterDuffXfermode.java
@@ -32,5 +32,5 @@
native_instance = nativeCreateXfermode(mode.nativeInt);
}
- private static native int nativeCreateXfermode(int mode);
+ private static native long nativeCreateXfermode(int mode);
}
diff --git a/graphics/java/android/graphics/RadialGradient.java b/graphics/java/android/graphics/RadialGradient.java
index f011e5c..f10e5d6 100644
--- a/graphics/java/android/graphics/RadialGradient.java
+++ b/graphics/java/android/graphics/RadialGradient.java
@@ -117,14 +117,14 @@
return copy;
}
- private static native int nativeCreate1(float x, float y, float radius,
+ private static native long nativeCreate1(float x, float y, float radius,
int colors[], float positions[], int tileMode);
- private static native int nativeCreate2(float x, float y, float radius,
+ private static native long nativeCreate2(float x, float y, float radius,
int color0, int color1, int tileMode);
- private static native int nativePostCreate1(int native_shader, float x, float y, float radius,
+ private static native long nativePostCreate1(long native_shader, float x, float y, float radius,
int colors[], float positions[], int tileMode);
- private static native int nativePostCreate2(int native_shader, float x, float y, float radius,
+ private static native long nativePostCreate2(long native_shader, float x, float y, float radius,
int color0, int color1, int tileMode);
}
diff --git a/graphics/java/android/graphics/Rasterizer.java b/graphics/java/android/graphics/Rasterizer.java
index feb5f0c..817814c 100644
--- a/graphics/java/android/graphics/Rasterizer.java
+++ b/graphics/java/android/graphics/Rasterizer.java
@@ -27,7 +27,7 @@
finalizer(native_instance);
}
- private static native void finalizer(int native_instance);
+ private static native void finalizer(long native_instance);
- int native_instance;
+ long native_instance;
}
diff --git a/graphics/java/android/graphics/Region.java b/graphics/java/android/graphics/Region.java
index 72d0c43..727723d 100644
--- a/graphics/java/android/graphics/Region.java
+++ b/graphics/java/android/graphics/Region.java
@@ -30,7 +30,7 @@
/**
* @hide
*/
- public final int mNativeRegion;
+ public final long mNativeRegion;
// the native values for these must match up with the enum in SkRegion.h
public enum Op {
@@ -342,7 +342,7 @@
* @return a new region created from the data in the parcel
*/
public Region createFromParcel(Parcel p) {
- int ni = nativeCreateFromParcel(p);
+ long ni = nativeCreateFromParcel(p);
if (ni == 0) {
throw new RuntimeException();
}
@@ -385,7 +385,7 @@
}
}
- Region(int ni) {
+ Region(long ni) {
if (ni == 0) {
throw new RuntimeException();
}
@@ -394,38 +394,38 @@
/* add dummy parameter so constructor can be called from jni without
triggering 'not cloneable' exception */
- private Region(int ni, int dummy) {
+ private Region(long ni, int dummy) {
this(ni);
}
- final int ni() {
+ final long ni() {
return mNativeRegion;
}
- private static native boolean nativeEquals(int native_r1, int native_r2);
+ private static native boolean nativeEquals(long native_r1, long native_r2);
- private static native int nativeConstructor();
- private static native void nativeDestructor(int native_region);
+ private static native long nativeConstructor();
+ private static native void nativeDestructor(long native_region);
- private static native void nativeSetRegion(int native_dst, int native_src);
- private static native boolean nativeSetRect(int native_dst, int left,
+ private static native void nativeSetRegion(long native_dst, long native_src);
+ private static native boolean nativeSetRect(long native_dst, int left,
int top, int right, int bottom);
- private static native boolean nativeSetPath(int native_dst, int native_path,
- int native_clip);
- private static native boolean nativeGetBounds(int native_region, Rect rect);
- private static native boolean nativeGetBoundaryPath(int native_region,
- int native_path);
+ private static native boolean nativeSetPath(long native_dst, long native_path,
+ long native_clip);
+ private static native boolean nativeGetBounds(long native_region, Rect rect);
+ private static native boolean nativeGetBoundaryPath(long native_region,
+ long native_path);
- private static native boolean nativeOp(int native_dst, int left, int top,
+ private static native boolean nativeOp(long native_dst, int left, int top,
int right, int bottom, int op);
- private static native boolean nativeOp(int native_dst, Rect rect,
- int native_region, int op);
- private static native boolean nativeOp(int native_dst, int native_region1,
- int native_region2, int op);
+ private static native boolean nativeOp(long native_dst, Rect rect,
+ long native_region, int op);
+ private static native boolean nativeOp(long native_dst, long native_region1,
+ long native_region2, int op);
- private static native int nativeCreateFromParcel(Parcel p);
- private static native boolean nativeWriteToParcel(int native_region,
+ private static native long nativeCreateFromParcel(Parcel p);
+ private static native boolean nativeWriteToParcel(long native_region,
Parcel p);
- private static native String nativeToString(int native_region);
+ private static native String nativeToString(long native_region);
}
diff --git a/graphics/java/android/graphics/RegionIterator.java b/graphics/java/android/graphics/RegionIterator.java
index 817f853..8401adb 100644
--- a/graphics/java/android/graphics/RegionIterator.java
+++ b/graphics/java/android/graphics/RegionIterator.java
@@ -45,10 +45,10 @@
nativeDestructor(mNativeIter);
}
- private static native int nativeConstructor(int native_region);
- private static native void nativeDestructor(int native_iter);
- private static native boolean nativeNext(int native_iter, Rect r);
-
- private final int mNativeIter;
+ private static native long nativeConstructor(long native_region);
+ private static native void nativeDestructor(long native_iter);
+ private static native boolean nativeNext(long native_iter, Rect r);
+
+ private final long mNativeIter;
}
diff --git a/graphics/java/android/graphics/Shader.java b/graphics/java/android/graphics/Shader.java
index afc68d8..94b4c4a 100644
--- a/graphics/java/android/graphics/Shader.java
+++ b/graphics/java/android/graphics/Shader.java
@@ -28,11 +28,11 @@
*
* @hide
*/
- public int native_instance;
+ public long native_instance;
/**
* @hide
*/
- public int native_shader;
+ public long native_shader;
private Matrix mLocalMatrix;
@@ -112,7 +112,7 @@
}
}
- private static native void nativeDestructor(int native_shader, int native_skiaShader);
- private static native void nativeSetLocalMatrix(int native_shader,
- int native_skiaShader, int matrix_instance);
+ private static native void nativeDestructor(long native_shader, long native_skiaShader);
+ private static native void nativeSetLocalMatrix(long native_shader,
+ long native_skiaShader, long matrix_instance);
}
diff --git a/graphics/java/android/graphics/SumPathEffect.java b/graphics/java/android/graphics/SumPathEffect.java
index cc7c778..8fedc31 100644
--- a/graphics/java/android/graphics/SumPathEffect.java
+++ b/graphics/java/android/graphics/SumPathEffect.java
@@ -27,6 +27,6 @@
second.native_instance);
}
- private static native int nativeCreate(int first, int second);
+ private static native long nativeCreate(long first, long second);
}
diff --git a/graphics/java/android/graphics/SurfaceTexture.java b/graphics/java/android/graphics/SurfaceTexture.java
index b910a24..1f8e223 100644
--- a/graphics/java/android/graphics/SurfaceTexture.java
+++ b/graphics/java/android/graphics/SurfaceTexture.java
@@ -69,9 +69,9 @@
/**
* These fields are used by native code, do not access or modify.
*/
- private int mSurfaceTexture;
- private int mBufferQueue;
- private int mFrameAvailableListener;
+ private long mSurfaceTexture;
+ private long mBufferQueue;
+ private long mFrameAvailableListener;
/**
* Callback interface for being notified that a new stream frame is available.
diff --git a/graphics/java/android/graphics/SweepGradient.java b/graphics/java/android/graphics/SweepGradient.java
index e9cda39..21239f7 100644
--- a/graphics/java/android/graphics/SweepGradient.java
+++ b/graphics/java/android/graphics/SweepGradient.java
@@ -106,12 +106,12 @@
return copy;
}
- private static native int nativeCreate1(float x, float y, int colors[], float positions[]);
- private static native int nativeCreate2(float x, float y, int color0, int color1);
+ private static native long nativeCreate1(float x, float y, int colors[], float positions[]);
+ private static native long nativeCreate2(float x, float y, int color0, int color1);
- private static native int nativePostCreate1(int native_shader, float cx, float cy,
+ private static native long nativePostCreate1(long native_shader, float cx, float cy,
int[] colors, float[] positions);
- private static native int nativePostCreate2(int native_shader, float cx, float cy,
+ private static native long nativePostCreate2(long native_shader, float cx, float cy,
int color0, int color1);
}
diff --git a/graphics/java/android/graphics/TableMaskFilter.java b/graphics/java/android/graphics/TableMaskFilter.java
index a8a7ff0..d0c1438 100644
--- a/graphics/java/android/graphics/TableMaskFilter.java
+++ b/graphics/java/android/graphics/TableMaskFilter.java
@@ -28,7 +28,7 @@
native_instance = nativeNewTable(table);
}
- private TableMaskFilter(int ni) {
+ private TableMaskFilter(long ni) {
native_instance = ni;
}
@@ -40,7 +40,7 @@
return new TableMaskFilter(nativeNewGamma(gamma));
}
- private static native int nativeNewTable(byte[] table);
- private static native int nativeNewClip(int min, int max);
- private static native int nativeNewGamma(float gamma);
+ private static native long nativeNewTable(byte[] table);
+ private static native long nativeNewClip(int min, int max);
+ private static native long nativeNewGamma(float gamma);
}
diff --git a/graphics/java/android/graphics/Typeface.java b/graphics/java/android/graphics/Typeface.java
index c68c9f7..936ea4f 100644
--- a/graphics/java/android/graphics/Typeface.java
+++ b/graphics/java/android/graphics/Typeface.java
@@ -18,6 +18,7 @@
import android.content.res.AssetManager;
import android.util.SparseArray;
+import android.util.LongSparseArray;
import java.io.File;
@@ -45,10 +46,10 @@
public static final Typeface MONOSPACE;
static Typeface[] sDefaults;
- private static final SparseArray<SparseArray<Typeface>> sTypefaceCache =
- new SparseArray<SparseArray<Typeface>>(3);
+ private static final LongSparseArray<SparseArray<Typeface>> sTypefaceCache =
+ new LongSparseArray<SparseArray<Typeface>>(3);
- int native_instance;
+ long native_instance;
// Style
public static final int NORMAL = 0;
@@ -100,7 +101,7 @@
* @return The best matching typeface.
*/
public static Typeface create(Typeface family, int style) {
- int ni = 0;
+ long ni = 0;
if (family != null) {
// Return early if we're asked for the same face/style
if (family.mStyle == style) {
@@ -170,7 +171,7 @@
}
// don't allow clients to call this directly
- private Typeface(int ni) {
+ private Typeface(long ni) {
if (ni == 0) {
throw new RuntimeException("native typeface cannot be made");
}
@@ -214,15 +215,20 @@
@Override
public int hashCode() {
- int result = native_instance;
+ /*
+ * Modified method for hashCode with long native_instance derived from
+ * http://developer.android.com/reference/java/lang/Object.html
+ */
+ int result = 17;
+ result = 31 * result + (int) (native_instance ^ (native_instance >>> 32));
result = 31 * result + mStyle;
return result;
}
- private static native int nativeCreate(String familyName, int style);
- private static native int nativeCreateFromTypeface(int native_instance, int style);
- private static native void nativeUnref(int native_instance);
- private static native int nativeGetStyle(int native_instance);
- private static native int nativeCreateFromAsset(AssetManager mgr, String path);
- private static native int nativeCreateFromFile(String path);
+ private static native long nativeCreate(String familyName, int style);
+ private static native long nativeCreateFromTypeface(long native_instance, int style);
+ private static native void nativeUnref(long native_instance);
+ private static native int nativeGetStyle(long native_instance);
+ private static native long nativeCreateFromAsset(AssetManager mgr, String path);
+ private static native long nativeCreateFromFile(String path);
}
diff --git a/graphics/java/android/graphics/Xfermode.java b/graphics/java/android/graphics/Xfermode.java
index 2467bdc..883350d 100644
--- a/graphics/java/android/graphics/Xfermode.java
+++ b/graphics/java/android/graphics/Xfermode.java
@@ -38,7 +38,7 @@
}
}
- private static native void finalizer(int native_instance);
+ private static native void finalizer(long native_instance);
- int native_instance;
+ long native_instance;
}
diff --git a/graphics/java/android/graphics/pdf/PdfDocument.java b/graphics/java/android/graphics/pdf/PdfDocument.java
index 29d14a2..f5b07c1 100644
--- a/graphics/java/android/graphics/pdf/PdfDocument.java
+++ b/graphics/java/android/graphics/pdf/PdfDocument.java
@@ -82,7 +82,7 @@
private final List<PageInfo> mPages = new ArrayList<PageInfo>();
- private int mNativeDocument;
+ private long mNativeDocument;
private Page mCurrentPage;
@@ -235,20 +235,20 @@
}
}
- private native int nativeCreateDocument();
+ private native long nativeCreateDocument();
- private native void nativeClose(int document);
+ private native void nativeClose(long nativeDocument);
- private native void nativeFinishPage(int document);
+ private native void nativeFinishPage(long nativeDocument);
- private native void nativeWriteTo(int document, OutputStream out, byte[] chunk);
+ private native void nativeWriteTo(long nativeDocument, OutputStream out, byte[] chunk);
- private static native int nativeStartPage(int documentPtr, int pageWidth, int pageHeight,
+ private static native long nativeStartPage(long nativeDocument, int pageWidth, int pageHeight,
int contentLeft, int contentTop, int contentRight, int contentBottom);
private final class PdfCanvas extends Canvas {
- public PdfCanvas(int nativeCanvas) {
+ public PdfCanvas(long nativeCanvas) {
super(nativeCanvas);
}
diff --git a/graphics/jni/android_renderscript_RenderScript.cpp b/graphics/jni/android_renderscript_RenderScript.cpp
deleted file mode 100644
index a4221dc..0000000
--- a/graphics/jni/android_renderscript_RenderScript.cpp
+++ /dev/null
@@ -1,1726 +0,0 @@
-/*
- * Copyright (C) 2011-2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "libRS_jni"
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <math.h>
-#include <utils/misc.h>
-
-#include <core/SkBitmap.h>
-#include <core/SkPixelRef.h>
-#include <core/SkStream.h>
-#include <core/SkTemplates.h>
-
-#include <androidfw/Asset.h>
-#include <androidfw/AssetManager.h>
-#include <androidfw/ResourceTypes.h>
-
-#include "jni.h"
-#include "JNIHelp.h"
-#include "android_runtime/AndroidRuntime.h"
-#include "android_runtime/android_view_Surface.h"
-#include "android_runtime/android_util_AssetManager.h"
-
-#include <rs.h>
-#include <rsEnv.h>
-#include <gui/Surface.h>
-#include <gui/GLConsumer.h>
-#include <gui/Surface.h>
-#include <android_runtime/android_graphics_SurfaceTexture.h>
-
-//#define LOG_API ALOGE
-#define LOG_API(...)
-
-using namespace android;
-
-class AutoJavaStringToUTF8 {
-public:
- AutoJavaStringToUTF8(JNIEnv* env, jstring str) : fEnv(env), fJStr(str) {
- fCStr = env->GetStringUTFChars(str, NULL);
- fLength = env->GetStringUTFLength(str);
- }
- ~AutoJavaStringToUTF8() {
- fEnv->ReleaseStringUTFChars(fJStr, fCStr);
- }
- const char* c_str() const { return fCStr; }
- jsize length() const { return fLength; }
-
-private:
- JNIEnv* fEnv;
- jstring fJStr;
- const char* fCStr;
- jsize fLength;
-};
-
-class AutoJavaStringArrayToUTF8 {
-public:
- AutoJavaStringArrayToUTF8(JNIEnv* env, jobjectArray strings, jsize stringsLength)
- : mEnv(env), mStrings(strings), mStringsLength(stringsLength) {
- mCStrings = NULL;
- mSizeArray = NULL;
- if (stringsLength > 0) {
- mCStrings = (const char **)calloc(stringsLength, sizeof(char *));
- mSizeArray = (size_t*)calloc(stringsLength, sizeof(size_t));
- for (jsize ct = 0; ct < stringsLength; ct ++) {
- jstring s = (jstring)mEnv->GetObjectArrayElement(mStrings, ct);
- mCStrings[ct] = mEnv->GetStringUTFChars(s, NULL);
- mSizeArray[ct] = mEnv->GetStringUTFLength(s);
- }
- }
- }
- ~AutoJavaStringArrayToUTF8() {
- for (jsize ct=0; ct < mStringsLength; ct++) {
- jstring s = (jstring)mEnv->GetObjectArrayElement(mStrings, ct);
- mEnv->ReleaseStringUTFChars(s, mCStrings[ct]);
- }
- free(mCStrings);
- free(mSizeArray);
- }
- const char **c_str() const { return mCStrings; }
- size_t *c_str_len() const { return mSizeArray; }
- jsize length() const { return mStringsLength; }
-
-private:
- JNIEnv *mEnv;
- jobjectArray mStrings;
- const char **mCStrings;
- size_t *mSizeArray;
- jsize mStringsLength;
-};
-
-// ---------------------------------------------------------------------------
-
-static jfieldID gContextId = 0;
-static jfieldID gNativeBitmapID = 0;
-static jfieldID gTypeNativeCache = 0;
-
-static void _nInit(JNIEnv *_env, jclass _this)
-{
- gContextId = _env->GetFieldID(_this, "mContext", "I");
-
- jclass bitmapClass = _env->FindClass("android/graphics/Bitmap");
- gNativeBitmapID = _env->GetFieldID(bitmapClass, "mNativeBitmap", "I");
-}
-
-// ---------------------------------------------------------------------------
-
-static void
-nContextFinish(JNIEnv *_env, jobject _this, RsContext con)
-{
- LOG_API("nContextFinish, con(%p)", con);
- rsContextFinish(con);
-}
-
-static void
-nAssignName(JNIEnv *_env, jobject _this, RsContext con, jint obj, jbyteArray str)
-{
- LOG_API("nAssignName, con(%p), obj(%p)", con, (void *)obj);
- jint len = _env->GetArrayLength(str);
- jbyte * cptr = (jbyte *) _env->GetPrimitiveArrayCritical(str, 0);
- rsAssignName(con, (void *)obj, (const char *)cptr, len);
- _env->ReleasePrimitiveArrayCritical(str, cptr, JNI_ABORT);
-}
-
-static jstring
-nGetName(JNIEnv *_env, jobject _this, RsContext con, jint obj)
-{
- LOG_API("nGetName, con(%p), obj(%p)", con, (void *)obj);
- const char *name = NULL;
- rsaGetName(con, (void *)obj, &name);
- if(name == NULL || strlen(name) == 0) {
- return NULL;
- }
- return _env->NewStringUTF(name);
-}
-
-static void
-nObjDestroy(JNIEnv *_env, jobject _this, RsContext con, jint obj)
-{
- LOG_API("nObjDestroy, con(%p) obj(%p)", con, (void *)obj);
- rsObjDestroy(con, (void *)obj);
-}
-
-// ---------------------------------------------------------------------------
-
-static jint
-nDeviceCreate(JNIEnv *_env, jobject _this)
-{
- LOG_API("nDeviceCreate");
- return (jint)rsDeviceCreate();
-}
-
-static void
-nDeviceDestroy(JNIEnv *_env, jobject _this, jint dev)
-{
- LOG_API("nDeviceDestroy");
- return rsDeviceDestroy((RsDevice)dev);
-}
-
-static void
-nDeviceSetConfig(JNIEnv *_env, jobject _this, jint dev, jint p, jint value)
-{
- LOG_API("nDeviceSetConfig dev(%p), param(%i), value(%i)", (void *)dev, p, value);
- return rsDeviceSetConfig((RsDevice)dev, (RsDeviceParam)p, value);
-}
-
-static jint
-nContextCreate(JNIEnv *_env, jobject _this, jint dev, jint ver, jint sdkVer, jint ct)
-{
- LOG_API("nContextCreate");
- return (jint)rsContextCreate((RsDevice)dev, ver, sdkVer, (RsContextType)ct, 0);
-}
-
-static jint
-nContextCreateGL(JNIEnv *_env, jobject _this, jint dev, jint ver, jint sdkVer,
- int colorMin, int colorPref,
- int alphaMin, int alphaPref,
- int depthMin, int depthPref,
- int stencilMin, int stencilPref,
- int samplesMin, int samplesPref, float samplesQ,
- int dpi)
-{
- RsSurfaceConfig sc;
- sc.alphaMin = alphaMin;
- sc.alphaPref = alphaPref;
- sc.colorMin = colorMin;
- sc.colorPref = colorPref;
- sc.depthMin = depthMin;
- sc.depthPref = depthPref;
- sc.samplesMin = samplesMin;
- sc.samplesPref = samplesPref;
- sc.samplesQ = samplesQ;
-
- LOG_API("nContextCreateGL");
- return (jint)rsContextCreateGL((RsDevice)dev, ver, sdkVer, sc, dpi);
-}
-
-static void
-nContextSetPriority(JNIEnv *_env, jobject _this, RsContext con, jint p)
-{
- LOG_API("ContextSetPriority, con(%p), priority(%i)", con, p);
- rsContextSetPriority(con, p);
-}
-
-
-
-static void
-nContextSetSurface(JNIEnv *_env, jobject _this, RsContext con, jint width, jint height, jobject wnd)
-{
- LOG_API("nContextSetSurface, con(%p), width(%i), height(%i), surface(%p)", con, width, height, (Surface *)wnd);
-
- ANativeWindow * window = NULL;
- if (wnd == NULL) {
-
- } else {
- window = android_view_Surface_getNativeWindow(_env, wnd).get();
- }
-
- rsContextSetSurface(con, width, height, window);
-}
-
-static void
-nContextDestroy(JNIEnv *_env, jobject _this, RsContext con)
-{
- LOG_API("nContextDestroy, con(%p)", con);
- rsContextDestroy(con);
-}
-
-static void
-nContextDump(JNIEnv *_env, jobject _this, RsContext con, jint bits)
-{
- LOG_API("nContextDump, con(%p) bits(%i)", (RsContext)con, bits);
- rsContextDump((RsContext)con, bits);
-}
-
-static void
-nContextPause(JNIEnv *_env, jobject _this, RsContext con)
-{
- LOG_API("nContextPause, con(%p)", con);
- rsContextPause(con);
-}
-
-static void
-nContextResume(JNIEnv *_env, jobject _this, RsContext con)
-{
- LOG_API("nContextResume, con(%p)", con);
- rsContextResume(con);
-}
-
-
-static jstring
-nContextGetErrorMessage(JNIEnv *_env, jobject _this, RsContext con)
-{
- LOG_API("nContextGetErrorMessage, con(%p)", con);
- char buf[1024];
-
- size_t receiveLen;
- uint32_t subID;
- int id = rsContextGetMessage(con,
- buf, sizeof(buf),
- &receiveLen, sizeof(receiveLen),
- &subID, sizeof(subID));
- if (!id && receiveLen) {
- ALOGV("message receive buffer too small. %i", receiveLen);
- }
- return _env->NewStringUTF(buf);
-}
-
-static jint
-nContextGetUserMessage(JNIEnv *_env, jobject _this, RsContext con, jintArray data)
-{
- jint len = _env->GetArrayLength(data);
- LOG_API("nContextGetMessage, con(%p), len(%i)", con, len);
- jint *ptr = _env->GetIntArrayElements(data, NULL);
- size_t receiveLen;
- uint32_t subID;
- int id = rsContextGetMessage(con,
- ptr, len * 4,
- &receiveLen, sizeof(receiveLen),
- &subID, sizeof(subID));
- if (!id && receiveLen) {
- ALOGV("message receive buffer too small. %i", receiveLen);
- }
- _env->ReleaseIntArrayElements(data, ptr, 0);
- return id;
-}
-
-static jint
-nContextPeekMessage(JNIEnv *_env, jobject _this, RsContext con, jintArray auxData)
-{
- LOG_API("nContextPeekMessage, con(%p)", con);
- jint *auxDataPtr = _env->GetIntArrayElements(auxData, NULL);
- size_t receiveLen;
- uint32_t subID;
- int id = rsContextPeekMessage(con, &receiveLen, sizeof(receiveLen),
- &subID, sizeof(subID));
- auxDataPtr[0] = (jint)subID;
- auxDataPtr[1] = (jint)receiveLen;
- _env->ReleaseIntArrayElements(auxData, auxDataPtr, 0);
- return id;
-}
-
-static void nContextInitToClient(JNIEnv *_env, jobject _this, RsContext con)
-{
- LOG_API("nContextInitToClient, con(%p)", con);
- rsContextInitToClient(con);
-}
-
-static void nContextDeinitToClient(JNIEnv *_env, jobject _this, RsContext con)
-{
- LOG_API("nContextDeinitToClient, con(%p)", con);
- rsContextDeinitToClient(con);
-}
-
-static void
-nContextSendMessage(JNIEnv *_env, jobject _this, RsContext con, jint id, jintArray data)
-{
- jint *ptr = NULL;
- jint len = 0;
- if (data) {
- len = _env->GetArrayLength(data);
- ptr = _env->GetIntArrayElements(data, NULL);
- }
- LOG_API("nContextSendMessage, con(%p), id(%i), len(%i)", con, id, len);
- rsContextSendMessage(con, id, (const uint8_t *)ptr, len * sizeof(int));
- if (data) {
- _env->ReleaseIntArrayElements(data, ptr, JNI_ABORT);
- }
-}
-
-
-
-static jint
-nElementCreate(JNIEnv *_env, jobject _this, RsContext con, jint type, jint kind, jboolean norm, jint size)
-{
- LOG_API("nElementCreate, con(%p), type(%i), kind(%i), norm(%i), size(%i)", con, type, kind, norm, size);
- return (jint)rsElementCreate(con, (RsDataType)type, (RsDataKind)kind, norm, size);
-}
-
-static jint
-nElementCreate2(JNIEnv *_env, jobject _this, RsContext con,
- jintArray _ids, jobjectArray _names, jintArray _arraySizes)
-{
- int fieldCount = _env->GetArrayLength(_ids);
- LOG_API("nElementCreate2, con(%p)", con);
-
- jint *ids = _env->GetIntArrayElements(_ids, NULL);
- jint *arraySizes = _env->GetIntArrayElements(_arraySizes, NULL);
-
- AutoJavaStringArrayToUTF8 names(_env, _names, fieldCount);
-
- const char **nameArray = names.c_str();
- size_t *sizeArray = names.c_str_len();
-
- jint id = (jint)rsElementCreate2(con,
- (RsElement *)ids, fieldCount,
- nameArray, fieldCount * sizeof(size_t), sizeArray,
- (const uint32_t *)arraySizes, fieldCount);
-
- _env->ReleaseIntArrayElements(_ids, ids, JNI_ABORT);
- _env->ReleaseIntArrayElements(_arraySizes, arraySizes, JNI_ABORT);
- return (jint)id;
-}
-
-static void
-nElementGetNativeData(JNIEnv *_env, jobject _this, RsContext con, jint id, jintArray _elementData)
-{
- int dataSize = _env->GetArrayLength(_elementData);
- LOG_API("nElementGetNativeData, con(%p)", con);
-
- // we will pack mType; mKind; mNormalized; mVectorSize; NumSubElements
- assert(dataSize == 5);
-
- uint32_t elementData[5];
- rsaElementGetNativeData(con, (RsElement)id, elementData, dataSize);
-
- for(jint i = 0; i < dataSize; i ++) {
- _env->SetIntArrayRegion(_elementData, i, 1, (const jint*)&elementData[i]);
- }
-}
-
-
-static void
-nElementGetSubElements(JNIEnv *_env, jobject _this, RsContext con, jint id,
- jintArray _IDs,
- jobjectArray _names,
- jintArray _arraySizes)
-{
- int dataSize = _env->GetArrayLength(_IDs);
- LOG_API("nElementGetSubElements, con(%p)", con);
-
- uint32_t *ids = (uint32_t *)malloc((uint32_t)dataSize * sizeof(uint32_t));
- const char **names = (const char **)malloc((uint32_t)dataSize * sizeof(const char *));
- uint32_t *arraySizes = (uint32_t *)malloc((uint32_t)dataSize * sizeof(uint32_t));
-
- rsaElementGetSubElements(con, (RsElement)id, ids, names, arraySizes, (uint32_t)dataSize);
-
- for(jint i = 0; i < dataSize; i++) {
- _env->SetObjectArrayElement(_names, i, _env->NewStringUTF(names[i]));
- _env->SetIntArrayRegion(_IDs, i, 1, (const jint*)&ids[i]);
- _env->SetIntArrayRegion(_arraySizes, i, 1, (const jint*)&arraySizes[i]);
- }
-
- free(ids);
- free(names);
- free(arraySizes);
-}
-
-// -----------------------------------
-
-static int
-nTypeCreate(JNIEnv *_env, jobject _this, RsContext con, RsElement eid,
- jint dimx, jint dimy, jint dimz, jboolean mips, jboolean faces, jint yuv)
-{
- LOG_API("nTypeCreate, con(%p) eid(%p), x(%i), y(%i), z(%i), mips(%i), faces(%i), yuv(%i)",
- con, eid, dimx, dimy, dimz, mips, faces, yuv);
-
- jint id = (jint)rsTypeCreate(con, (RsElement)eid, dimx, dimy, dimz, mips, faces, yuv);
- return (jint)id;
-}
-
-static void
-nTypeGetNativeData(JNIEnv *_env, jobject _this, RsContext con, jint id, jintArray _typeData)
-{
- // We are packing 6 items: mDimX; mDimY; mDimZ;
- // mDimLOD; mDimFaces; mElement; into typeData
- int elementCount = _env->GetArrayLength(_typeData);
-
- assert(elementCount == 6);
- LOG_API("nTypeCreate, con(%p)", con);
-
- uint32_t typeData[6];
- rsaTypeGetNativeData(con, (RsType)id, typeData, 6);
-
- for(jint i = 0; i < elementCount; i ++) {
- _env->SetIntArrayRegion(_typeData, i, 1, (const jint*)&typeData[i]);
- }
-}
-
-// -----------------------------------
-
-static jint
-nAllocationCreateTyped(JNIEnv *_env, jobject _this, RsContext con, jint type, jint mips, jint usage, jint pointer)
-{
- LOG_API("nAllocationCreateTyped, con(%p), type(%p), mip(%i), usage(%i), ptr(%p)", con, (RsElement)type, mips, usage, (void *)pointer);
- return (jint) rsAllocationCreateTyped(con, (RsType)type, (RsAllocationMipmapControl)mips, (uint32_t)usage, (uint32_t)pointer);
-}
-
-static void
-nAllocationSyncAll(JNIEnv *_env, jobject _this, RsContext con, jint a, jint bits)
-{
- LOG_API("nAllocationSyncAll, con(%p), a(%p), bits(0x%08x)", con, (RsAllocation)a, bits);
- rsAllocationSyncAll(con, (RsAllocation)a, (RsAllocationUsageType)bits);
-}
-
-static jobject
-nAllocationGetSurface(JNIEnv *_env, jobject _this, RsContext con, jint a)
-{
- LOG_API("nAllocationGetSurface, con(%p), a(%p)", con, (RsAllocation)a);
-
- IGraphicBufferProducer *v = (IGraphicBufferProducer *)rsAllocationGetSurface(con, (RsAllocation)a);
- sp<IGraphicBufferProducer> bp = v;
- v->decStrong(NULL);
-
- jobject o = android_view_Surface_createFromIGraphicBufferProducer(_env, bp);
- return o;
-}
-
-static void
-nAllocationSetSurface(JNIEnv *_env, jobject _this, RsContext con, RsAllocation alloc, jobject sur)
-{
- LOG_API("nAllocationSetSurface, con(%p), alloc(%p), surface(%p)",
- con, alloc, (Surface *)sur);
-
- sp<Surface> s;
- if (sur != 0) {
- s = android_view_Surface_getSurface(_env, sur);
- }
-
- rsAllocationSetSurface(con, alloc, static_cast<ANativeWindow *>(s.get()));
-}
-
-static void
-nAllocationIoSend(JNIEnv *_env, jobject _this, RsContext con, RsAllocation alloc)
-{
- LOG_API("nAllocationIoSend, con(%p), alloc(%p)", con, alloc);
- rsAllocationIoSend(con, alloc);
-}
-
-static void
-nAllocationIoReceive(JNIEnv *_env, jobject _this, RsContext con, RsAllocation alloc)
-{
- LOG_API("nAllocationIoReceive, con(%p), alloc(%p)", con, alloc);
- rsAllocationIoReceive(con, alloc);
-}
-
-
-static void
-nAllocationGenerateMipmaps(JNIEnv *_env, jobject _this, RsContext con, jint alloc)
-{
- LOG_API("nAllocationGenerateMipmaps, con(%p), a(%p)", con, (RsAllocation)alloc);
- rsAllocationGenerateMipmaps(con, (RsAllocation)alloc);
-}
-
-static int
-nAllocationCreateFromBitmap(JNIEnv *_env, jobject _this, RsContext con, jint type, jint mip, jobject jbitmap, jint usage)
-{
- SkBitmap const * nativeBitmap =
- (SkBitmap const *)_env->GetIntField(jbitmap, gNativeBitmapID);
- const SkBitmap& bitmap(*nativeBitmap);
-
- bitmap.lockPixels();
- const void* ptr = bitmap.getPixels();
- jint id = (jint)rsAllocationCreateFromBitmap(con,
- (RsType)type, (RsAllocationMipmapControl)mip,
- ptr, bitmap.getSize(), usage);
- bitmap.unlockPixels();
- return id;
-}
-
-static int
-nAllocationCreateBitmapBackedAllocation(JNIEnv *_env, jobject _this, RsContext con, jint type, jint mip, jobject jbitmap, jint usage)
-{
- SkBitmap const * nativeBitmap =
- (SkBitmap const *)_env->GetIntField(jbitmap, gNativeBitmapID);
- const SkBitmap& bitmap(*nativeBitmap);
-
- bitmap.lockPixels();
- const void* ptr = bitmap.getPixels();
- jint id = (jint)rsAllocationCreateTyped(con,
- (RsType)type, (RsAllocationMipmapControl)mip,
- (uint32_t)usage, (size_t)ptr);
- bitmap.unlockPixels();
- return id;
-}
-
-static int
-nAllocationCubeCreateFromBitmap(JNIEnv *_env, jobject _this, RsContext con, jint type, jint mip, jobject jbitmap, jint usage)
-{
- SkBitmap const * nativeBitmap =
- (SkBitmap const *)_env->GetIntField(jbitmap, gNativeBitmapID);
- const SkBitmap& bitmap(*nativeBitmap);
-
- bitmap.lockPixels();
- const void* ptr = bitmap.getPixels();
- jint id = (jint)rsAllocationCubeCreateFromBitmap(con,
- (RsType)type, (RsAllocationMipmapControl)mip,
- ptr, bitmap.getSize(), usage);
- bitmap.unlockPixels();
- return id;
-}
-
-static void
-nAllocationCopyFromBitmap(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jobject jbitmap)
-{
- SkBitmap const * nativeBitmap =
- (SkBitmap const *)_env->GetIntField(jbitmap, gNativeBitmapID);
- const SkBitmap& bitmap(*nativeBitmap);
- int w = bitmap.width();
- int h = bitmap.height();
-
- bitmap.lockPixels();
- const void* ptr = bitmap.getPixels();
- rsAllocation2DData(con, (RsAllocation)alloc, 0, 0,
- 0, RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_X,
- w, h, ptr, bitmap.getSize(), 0);
- bitmap.unlockPixels();
-}
-
-static void
-nAllocationCopyToBitmap(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jobject jbitmap)
-{
- SkBitmap const * nativeBitmap =
- (SkBitmap const *)_env->GetIntField(jbitmap, gNativeBitmapID);
- const SkBitmap& bitmap(*nativeBitmap);
-
- bitmap.lockPixels();
- void* ptr = bitmap.getPixels();
- rsAllocationCopyToBitmap(con, (RsAllocation)alloc, ptr, bitmap.getSize());
- bitmap.unlockPixels();
- bitmap.notifyPixelsChanged();
-}
-
-static void ReleaseBitmapCallback(void *bmp)
-{
- SkBitmap const * nativeBitmap = (SkBitmap const *)bmp;
- nativeBitmap->unlockPixels();
-}
-
-
-static void
-nAllocationData1D_i(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint offset, jint lod, jint count, jintArray data, int sizeBytes)
-{
- jint len = _env->GetArrayLength(data);
- LOG_API("nAllocation1DData_i, con(%p), adapter(%p), offset(%i), count(%i), len(%i), sizeBytes(%i)", con, (RsAllocation)alloc, offset, count, len, sizeBytes);
- jint *ptr = _env->GetIntArrayElements(data, NULL);
- rsAllocation1DData(con, (RsAllocation)alloc, offset, lod, count, ptr, sizeBytes);
- _env->ReleaseIntArrayElements(data, ptr, JNI_ABORT);
-}
-
-static void
-nAllocationData1D_s(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint offset, jint lod, jint count, jshortArray data, int sizeBytes)
-{
- jint len = _env->GetArrayLength(data);
- LOG_API("nAllocation1DData_s, con(%p), adapter(%p), offset(%i), count(%i), len(%i), sizeBytes(%i)", con, (RsAllocation)alloc, offset, count, len, sizeBytes);
- jshort *ptr = _env->GetShortArrayElements(data, NULL);
- rsAllocation1DData(con, (RsAllocation)alloc, offset, lod, count, ptr, sizeBytes);
- _env->ReleaseShortArrayElements(data, ptr, JNI_ABORT);
-}
-
-static void
-nAllocationData1D_b(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint offset, jint lod, jint count, jbyteArray data, int sizeBytes)
-{
- jint len = _env->GetArrayLength(data);
- LOG_API("nAllocation1DData_b, con(%p), adapter(%p), offset(%i), count(%i), len(%i), sizeBytes(%i)", con, (RsAllocation)alloc, offset, count, len, sizeBytes);
- jbyte *ptr = _env->GetByteArrayElements(data, NULL);
- rsAllocation1DData(con, (RsAllocation)alloc, offset, lod, count, ptr, sizeBytes);
- _env->ReleaseByteArrayElements(data, ptr, JNI_ABORT);
-}
-
-static void
-nAllocationData1D_f(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint offset, jint lod, jint count, jfloatArray data, int sizeBytes)
-{
- jint len = _env->GetArrayLength(data);
- LOG_API("nAllocation1DData_f, con(%p), adapter(%p), offset(%i), count(%i), len(%i), sizeBytes(%i)", con, (RsAllocation)alloc, offset, count, len, sizeBytes);
- jfloat *ptr = _env->GetFloatArrayElements(data, NULL);
- rsAllocation1DData(con, (RsAllocation)alloc, offset, lod, count, ptr, sizeBytes);
- _env->ReleaseFloatArrayElements(data, ptr, JNI_ABORT);
-}
-
-static void
-// native void rsnAllocationElementData1D(int con, int id, int xoff, int compIdx, byte[] d, int sizeBytes);
-nAllocationElementData1D(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint offset, jint lod, jint compIdx, jbyteArray data, int sizeBytes)
-{
- jint len = _env->GetArrayLength(data);
- LOG_API("nAllocationElementData1D, con(%p), alloc(%p), offset(%i), comp(%i), len(%i), sizeBytes(%i)", con, (RsAllocation)alloc, offset, compIdx, len, sizeBytes);
- jbyte *ptr = _env->GetByteArrayElements(data, NULL);
- rsAllocation1DElementData(con, (RsAllocation)alloc, offset, lod, ptr, sizeBytes, compIdx);
- _env->ReleaseByteArrayElements(data, ptr, JNI_ABORT);
-}
-
-static void
-nAllocationData2D_s(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint xoff, jint yoff, jint lod, jint face,
- jint w, jint h, jshortArray data, int sizeBytes)
-{
- jint len = _env->GetArrayLength(data);
- LOG_API("nAllocation2DData_s, con(%p), adapter(%p), xoff(%i), yoff(%i), w(%i), h(%i), len(%i)", con, (RsAllocation)alloc, xoff, yoff, w, h, len);
- jshort *ptr = _env->GetShortArrayElements(data, NULL);
- rsAllocation2DData(con, (RsAllocation)alloc, xoff, yoff, lod, (RsAllocationCubemapFace)face, w, h, ptr, sizeBytes, 0);
- _env->ReleaseShortArrayElements(data, ptr, JNI_ABORT);
-}
-
-static void
-nAllocationData2D_b(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint xoff, jint yoff, jint lod, jint face,
- jint w, jint h, jbyteArray data, int sizeBytes)
-{
- jint len = _env->GetArrayLength(data);
- LOG_API("nAllocation2DData_b, con(%p), adapter(%p), xoff(%i), yoff(%i), w(%i), h(%i), len(%i)", con, (RsAllocation)alloc, xoff, yoff, w, h, len);
- jbyte *ptr = _env->GetByteArrayElements(data, NULL);
- rsAllocation2DData(con, (RsAllocation)alloc, xoff, yoff, lod, (RsAllocationCubemapFace)face, w, h, ptr, sizeBytes, 0);
- _env->ReleaseByteArrayElements(data, ptr, JNI_ABORT);
-}
-
-static void
-nAllocationData2D_i(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint xoff, jint yoff, jint lod, jint face,
- jint w, jint h, jintArray data, int sizeBytes)
-{
- jint len = _env->GetArrayLength(data);
- LOG_API("nAllocation2DData_i, con(%p), adapter(%p), xoff(%i), yoff(%i), w(%i), h(%i), len(%i)", con, (RsAllocation)alloc, xoff, yoff, w, h, len);
- jint *ptr = _env->GetIntArrayElements(data, NULL);
- rsAllocation2DData(con, (RsAllocation)alloc, xoff, yoff, lod, (RsAllocationCubemapFace)face, w, h, ptr, sizeBytes, 0);
- _env->ReleaseIntArrayElements(data, ptr, JNI_ABORT);
-}
-
-static void
-nAllocationData2D_f(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint xoff, jint yoff, jint lod, jint face,
- jint w, jint h, jfloatArray data, int sizeBytes)
-{
- jint len = _env->GetArrayLength(data);
- LOG_API("nAllocation2DData_i, con(%p), adapter(%p), xoff(%i), yoff(%i), w(%i), h(%i), len(%i)", con, (RsAllocation)alloc, xoff, yoff, w, h, len);
- jfloat *ptr = _env->GetFloatArrayElements(data, NULL);
- rsAllocation2DData(con, (RsAllocation)alloc, xoff, yoff, lod, (RsAllocationCubemapFace)face, w, h, ptr, sizeBytes, 0);
- _env->ReleaseFloatArrayElements(data, ptr, JNI_ABORT);
-}
-
-static void
-nAllocationData2D_alloc(JNIEnv *_env, jobject _this, RsContext con,
- jint dstAlloc, jint dstXoff, jint dstYoff,
- jint dstMip, jint dstFace,
- jint width, jint height,
- jint srcAlloc, jint srcXoff, jint srcYoff,
- jint srcMip, jint srcFace)
-{
- LOG_API("nAllocation2DData_s, con(%p), dstAlloc(%p), dstXoff(%i), dstYoff(%i),"
- " dstMip(%i), dstFace(%i), width(%i), height(%i),"
- " srcAlloc(%p), srcXoff(%i), srcYoff(%i), srcMip(%i), srcFace(%i)",
- con, (RsAllocation)dstAlloc, dstXoff, dstYoff, dstMip, dstFace,
- width, height, (RsAllocation)srcAlloc, srcXoff, srcYoff, srcMip, srcFace);
-
- rsAllocationCopy2DRange(con,
- (RsAllocation)dstAlloc,
- dstXoff, dstYoff,
- dstMip, dstFace,
- width, height,
- (RsAllocation)srcAlloc,
- srcXoff, srcYoff,
- srcMip, srcFace);
-}
-
-static void
-nAllocationData3D_s(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint xoff, jint yoff, jint zoff, jint lod,
- jint w, jint h, jint d, jshortArray data, int sizeBytes)
-{
- jint len = _env->GetArrayLength(data);
- LOG_API("nAllocation3DData_s, con(%p), adapter(%p), xoff(%i), yoff(%i), w(%i), h(%i), len(%i)", con, (RsAllocation)alloc, xoff, yoff, zoff, w, h, d, len);
- jshort *ptr = _env->GetShortArrayElements(data, NULL);
- rsAllocation3DData(con, (RsAllocation)alloc, xoff, yoff, zoff, lod, w, h, d, ptr, sizeBytes, 0);
- _env->ReleaseShortArrayElements(data, ptr, JNI_ABORT);
-}
-
-static void
-nAllocationData3D_b(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint xoff, jint yoff, jint zoff, jint lod,
- jint w, jint h, jint d, jbyteArray data, int sizeBytes)
-{
- jint len = _env->GetArrayLength(data);
- LOG_API("nAllocation3DData_b, con(%p), adapter(%p), xoff(%i), yoff(%i), w(%i), h(%i), len(%i)", con, (RsAllocation)alloc, xoff, yoff, zoff, w, h, d, len);
- jbyte *ptr = _env->GetByteArrayElements(data, NULL);
- rsAllocation3DData(con, (RsAllocation)alloc, xoff, yoff, zoff, lod, w, h, d, ptr, sizeBytes, 0);
- _env->ReleaseByteArrayElements(data, ptr, JNI_ABORT);
-}
-
-static void
-nAllocationData3D_i(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint xoff, jint yoff, jint zoff, jint lod,
- jint w, jint h, jint d, jintArray data, int sizeBytes)
-{
- jint len = _env->GetArrayLength(data);
- LOG_API("nAllocation3DData_i, con(%p), adapter(%p), xoff(%i), yoff(%i), w(%i), h(%i), len(%i)", con, (RsAllocation)alloc, xoff, yoff, zoff, w, h, d, len);
- jint *ptr = _env->GetIntArrayElements(data, NULL);
- rsAllocation3DData(con, (RsAllocation)alloc, xoff, yoff, zoff, lod, w, h, d, ptr, sizeBytes, 0);
- _env->ReleaseIntArrayElements(data, ptr, JNI_ABORT);
-}
-
-static void
-nAllocationData3D_f(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint xoff, jint yoff, jint zoff, jint lod,
- jint w, jint h, jint d, jfloatArray data, int sizeBytes)
-{
- jint len = _env->GetArrayLength(data);
- LOG_API("nAllocation3DData_f, con(%p), adapter(%p), xoff(%i), yoff(%i), w(%i), h(%i), len(%i)", con, (RsAllocation)alloc, xoff, yoff, zoff, w, h, d, len);
- jfloat *ptr = _env->GetFloatArrayElements(data, NULL);
- rsAllocation3DData(con, (RsAllocation)alloc, xoff, yoff, zoff, lod, w, h, d, ptr, sizeBytes, 0);
- _env->ReleaseFloatArrayElements(data, ptr, JNI_ABORT);
-}
-
-static void
-nAllocationData3D_alloc(JNIEnv *_env, jobject _this, RsContext con,
- jint dstAlloc, jint dstXoff, jint dstYoff, jint dstZoff,
- jint dstMip,
- jint width, jint height, jint depth,
- jint srcAlloc, jint srcXoff, jint srcYoff, jint srcZoff,
- jint srcMip)
-{
- LOG_API("nAllocationData3D_alloc, con(%p), dstAlloc(%p), dstXoff(%i), dstYoff(%i),"
- " dstMip(%i), width(%i), height(%i),"
- " srcAlloc(%p), srcXoff(%i), srcYoff(%i), srcMip(%i)",
- con, (RsAllocation)dstAlloc, dstXoff, dstYoff, dstMip, dstFace,
- width, height, (RsAllocation)srcAlloc, srcXoff, srcYoff, srcMip, srcFace);
-
- rsAllocationCopy3DRange(con,
- (RsAllocation)dstAlloc,
- dstXoff, dstYoff, dstZoff, dstMip,
- width, height, depth,
- (RsAllocation)srcAlloc,
- srcXoff, srcYoff, srcZoff, srcMip);
-}
-
-static void
-nAllocationRead_i(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jintArray data)
-{
- jint len = _env->GetArrayLength(data);
- LOG_API("nAllocationRead_i, con(%p), alloc(%p), len(%i)", con, (RsAllocation)alloc, len);
- jint *ptr = _env->GetIntArrayElements(data, NULL);
- jsize length = _env->GetArrayLength(data);
- rsAllocationRead(con, (RsAllocation)alloc, ptr, length * sizeof(int));
- _env->ReleaseIntArrayElements(data, ptr, 0);
-}
-
-static void
-nAllocationRead_s(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jshortArray data)
-{
- jint len = _env->GetArrayLength(data);
- LOG_API("nAllocationRead_i, con(%p), alloc(%p), len(%i)", con, (RsAllocation)alloc, len);
- jshort *ptr = _env->GetShortArrayElements(data, NULL);
- jsize length = _env->GetArrayLength(data);
- rsAllocationRead(con, (RsAllocation)alloc, ptr, length * sizeof(short));
- _env->ReleaseShortArrayElements(data, ptr, 0);
-}
-
-static void
-nAllocationRead_b(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jbyteArray data)
-{
- jint len = _env->GetArrayLength(data);
- LOG_API("nAllocationRead_i, con(%p), alloc(%p), len(%i)", con, (RsAllocation)alloc, len);
- jbyte *ptr = _env->GetByteArrayElements(data, NULL);
- jsize length = _env->GetArrayLength(data);
- rsAllocationRead(con, (RsAllocation)alloc, ptr, length * sizeof(char));
- _env->ReleaseByteArrayElements(data, ptr, 0);
-}
-
-static void
-nAllocationRead_f(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jfloatArray data)
-{
- jint len = _env->GetArrayLength(data);
- LOG_API("nAllocationRead_f, con(%p), alloc(%p), len(%i)", con, (RsAllocation)alloc, len);
- jfloat *ptr = _env->GetFloatArrayElements(data, NULL);
- jsize length = _env->GetArrayLength(data);
- rsAllocationRead(con, (RsAllocation)alloc, ptr, length * sizeof(float));
- _env->ReleaseFloatArrayElements(data, ptr, 0);
-}
-
-static jint
-nAllocationGetType(JNIEnv *_env, jobject _this, RsContext con, jint a)
-{
- LOG_API("nAllocationGetType, con(%p), a(%p)", con, (RsAllocation)a);
- return (jint) rsaAllocationGetType(con, (RsAllocation)a);
-}
-
-static void
-nAllocationResize1D(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint dimX)
-{
- LOG_API("nAllocationResize1D, con(%p), alloc(%p), sizeX(%i)", con, (RsAllocation)alloc, dimX);
- rsAllocationResize1D(con, (RsAllocation)alloc, dimX);
-}
-
-// -----------------------------------
-
-static int
-nFileA3DCreateFromAssetStream(JNIEnv *_env, jobject _this, RsContext con, jint native_asset)
-{
- ALOGV("______nFileA3D %u", (uint32_t) native_asset);
-
- Asset* asset = reinterpret_cast<Asset*>(native_asset);
-
- jint id = (jint)rsaFileA3DCreateFromMemory(con, asset->getBuffer(false), asset->getLength());
- return id;
-}
-
-static int
-nFileA3DCreateFromAsset(JNIEnv *_env, jobject _this, RsContext con, jobject _assetMgr, jstring _path)
-{
- AssetManager* mgr = assetManagerForJavaObject(_env, _assetMgr);
- if (mgr == NULL) {
- return 0;
- }
-
- AutoJavaStringToUTF8 str(_env, _path);
- Asset* asset = mgr->open(str.c_str(), Asset::ACCESS_BUFFER);
- if (asset == NULL) {
- return 0;
- }
-
- jint id = (jint)rsaFileA3DCreateFromAsset(con, asset);
- return id;
-}
-
-static int
-nFileA3DCreateFromFile(JNIEnv *_env, jobject _this, RsContext con, jstring fileName)
-{
- AutoJavaStringToUTF8 fileNameUTF(_env, fileName);
- jint id = (jint)rsaFileA3DCreateFromFile(con, fileNameUTF.c_str());
-
- return id;
-}
-
-static int
-nFileA3DGetNumIndexEntries(JNIEnv *_env, jobject _this, RsContext con, jint fileA3D)
-{
- int32_t numEntries = 0;
- rsaFileA3DGetNumIndexEntries(con, &numEntries, (RsFile)fileA3D);
- return numEntries;
-}
-
-static void
-nFileA3DGetIndexEntries(JNIEnv *_env, jobject _this, RsContext con, jint fileA3D, jint numEntries, jintArray _ids, jobjectArray _entries)
-{
- ALOGV("______nFileA3D %u", (uint32_t) fileA3D);
- RsFileIndexEntry *fileEntries = (RsFileIndexEntry*)malloc((uint32_t)numEntries * sizeof(RsFileIndexEntry));
-
- rsaFileA3DGetIndexEntries(con, fileEntries, (uint32_t)numEntries, (RsFile)fileA3D);
-
- for(jint i = 0; i < numEntries; i ++) {
- _env->SetObjectArrayElement(_entries, i, _env->NewStringUTF(fileEntries[i].objectName));
- _env->SetIntArrayRegion(_ids, i, 1, (const jint*)&fileEntries[i].classID);
- }
-
- free(fileEntries);
-}
-
-static int
-nFileA3DGetEntryByIndex(JNIEnv *_env, jobject _this, RsContext con, jint fileA3D, jint index)
-{
- ALOGV("______nFileA3D %u", (uint32_t) fileA3D);
- jint id = (jint)rsaFileA3DGetEntryByIndex(con, (uint32_t)index, (RsFile)fileA3D);
- return id;
-}
-
-// -----------------------------------
-
-static int
-nFontCreateFromFile(JNIEnv *_env, jobject _this, RsContext con,
- jstring fileName, jfloat fontSize, jint dpi)
-{
- AutoJavaStringToUTF8 fileNameUTF(_env, fileName);
- jint id = (jint)rsFontCreateFromFile(con,
- fileNameUTF.c_str(), fileNameUTF.length(),
- fontSize, dpi);
-
- return id;
-}
-
-static int
-nFontCreateFromAssetStream(JNIEnv *_env, jobject _this, RsContext con,
- jstring name, jfloat fontSize, jint dpi, jint native_asset)
-{
- Asset* asset = reinterpret_cast<Asset*>(native_asset);
- AutoJavaStringToUTF8 nameUTF(_env, name);
-
- jint id = (jint)rsFontCreateFromMemory(con,
- nameUTF.c_str(), nameUTF.length(),
- fontSize, dpi,
- asset->getBuffer(false), asset->getLength());
- return id;
-}
-
-static int
-nFontCreateFromAsset(JNIEnv *_env, jobject _this, RsContext con, jobject _assetMgr, jstring _path,
- jfloat fontSize, jint dpi)
-{
- AssetManager* mgr = assetManagerForJavaObject(_env, _assetMgr);
- if (mgr == NULL) {
- return 0;
- }
-
- AutoJavaStringToUTF8 str(_env, _path);
- Asset* asset = mgr->open(str.c_str(), Asset::ACCESS_BUFFER);
- if (asset == NULL) {
- return 0;
- }
-
- jint id = (jint)rsFontCreateFromMemory(con,
- str.c_str(), str.length(),
- fontSize, dpi,
- asset->getBuffer(false), asset->getLength());
- delete asset;
- return id;
-}
-
-// -----------------------------------
-
-static void
-nScriptBindAllocation(JNIEnv *_env, jobject _this, RsContext con, jint script, jint alloc, jint slot)
-{
- LOG_API("nScriptBindAllocation, con(%p), script(%p), alloc(%p), slot(%i)", con, (RsScript)script, (RsAllocation)alloc, slot);
- rsScriptBindAllocation(con, (RsScript)script, (RsAllocation)alloc, slot);
-}
-
-static void
-nScriptSetVarI(JNIEnv *_env, jobject _this, RsContext con, jint script, jint slot, jint val)
-{
- LOG_API("nScriptSetVarI, con(%p), s(%p), slot(%i), val(%i)", con, (void *)script, slot, val);
- rsScriptSetVarI(con, (RsScript)script, slot, val);
-}
-
-static jint
-nScriptGetVarI(JNIEnv *_env, jobject _this, RsContext con, jint script, jint slot)
-{
- LOG_API("nScriptGetVarI, con(%p), s(%p), slot(%i)", con, (void *)script, slot);
- int value = 0;
- rsScriptGetVarV(con, (RsScript)script, slot, &value, sizeof(value));
- return value;
-}
-
-static void
-nScriptSetVarObj(JNIEnv *_env, jobject _this, RsContext con, jint script, jint slot, jint val)
-{
- LOG_API("nScriptSetVarObj, con(%p), s(%p), slot(%i), val(%i)", con, (void *)script, slot, val);
- rsScriptSetVarObj(con, (RsScript)script, slot, (RsObjectBase)val);
-}
-
-static void
-nScriptSetVarJ(JNIEnv *_env, jobject _this, RsContext con, jint script, jint slot, jlong val)
-{
- LOG_API("nScriptSetVarJ, con(%p), s(%p), slot(%i), val(%lli)", con, (void *)script, slot, val);
- rsScriptSetVarJ(con, (RsScript)script, slot, val);
-}
-
-static jlong
-nScriptGetVarJ(JNIEnv *_env, jobject _this, RsContext con, jint script, jint slot)
-{
- LOG_API("nScriptGetVarJ, con(%p), s(%p), slot(%i)", con, (void *)script, slot);
- jlong value = 0;
- rsScriptGetVarV(con, (RsScript)script, slot, &value, sizeof(value));
- return value;
-}
-
-static void
-nScriptSetVarF(JNIEnv *_env, jobject _this, RsContext con, jint script, jint slot, float val)
-{
- LOG_API("nScriptSetVarF, con(%p), s(%p), slot(%i), val(%f)", con, (void *)script, slot, val);
- rsScriptSetVarF(con, (RsScript)script, slot, val);
-}
-
-static jfloat
-nScriptGetVarF(JNIEnv *_env, jobject _this, RsContext con, jint script, jint slot)
-{
- LOG_API("nScriptGetVarF, con(%p), s(%p), slot(%i)", con, (void *)script, slot);
- jfloat value = 0;
- rsScriptGetVarV(con, (RsScript)script, slot, &value, sizeof(value));
- return value;
-}
-
-static void
-nScriptSetVarD(JNIEnv *_env, jobject _this, RsContext con, jint script, jint slot, double val)
-{
- LOG_API("nScriptSetVarD, con(%p), s(%p), slot(%i), val(%lf)", con, (void *)script, slot, val);
- rsScriptSetVarD(con, (RsScript)script, slot, val);
-}
-
-static jdouble
-nScriptGetVarD(JNIEnv *_env, jobject _this, RsContext con, jint script, jint slot)
-{
- LOG_API("nScriptGetVarD, con(%p), s(%p), slot(%i)", con, (void *)script, slot);
- jdouble value = 0;
- rsScriptGetVarV(con, (RsScript)script, slot, &value, sizeof(value));
- return value;
-}
-
-static void
-nScriptSetVarV(JNIEnv *_env, jobject _this, RsContext con, jint script, jint slot, jbyteArray data)
-{
- LOG_API("nScriptSetVarV, con(%p), s(%p), slot(%i)", con, (void *)script, slot);
- jint len = _env->GetArrayLength(data);
- jbyte *ptr = _env->GetByteArrayElements(data, NULL);
- rsScriptSetVarV(con, (RsScript)script, slot, ptr, len);
- _env->ReleaseByteArrayElements(data, ptr, JNI_ABORT);
-}
-
-static void
-nScriptGetVarV(JNIEnv *_env, jobject _this, RsContext con, jint script, jint slot, jbyteArray data)
-{
- LOG_API("nScriptSetVarV, con(%p), s(%p), slot(%i)", con, (void *)script, slot);
- jint len = _env->GetArrayLength(data);
- jbyte *ptr = _env->GetByteArrayElements(data, NULL);
- rsScriptGetVarV(con, (RsScript)script, slot, ptr, len);
- _env->ReleaseByteArrayElements(data, ptr, JNI_ABORT);
-}
-
-static void
-nScriptSetVarVE(JNIEnv *_env, jobject _this, RsContext con, jint script, jint slot, jbyteArray data, jint elem, jintArray dims)
-{
- LOG_API("nScriptSetVarVE, con(%p), s(%p), slot(%i)", con, (void *)script, slot);
- jint len = _env->GetArrayLength(data);
- jbyte *ptr = _env->GetByteArrayElements(data, NULL);
- jint dimsLen = _env->GetArrayLength(dims) * sizeof(int);
- jint *dimsPtr = _env->GetIntArrayElements(dims, NULL);
- rsScriptSetVarVE(con, (RsScript)script, slot, ptr, len, (RsElement)elem,
- (const size_t*) dimsPtr, dimsLen);
- _env->ReleaseByteArrayElements(data, ptr, JNI_ABORT);
- _env->ReleaseIntArrayElements(dims, dimsPtr, JNI_ABORT);
-}
-
-
-static void
-nScriptSetTimeZone(JNIEnv *_env, jobject _this, RsContext con, jint script, jbyteArray timeZone)
-{
- LOG_API("nScriptCSetTimeZone, con(%p), s(%p), timeZone(%s)", con, (void *)script, (const char *)timeZone);
-
- jint length = _env->GetArrayLength(timeZone);
- jbyte* timeZone_ptr;
- timeZone_ptr = (jbyte *) _env->GetPrimitiveArrayCritical(timeZone, (jboolean *)0);
-
- rsScriptSetTimeZone(con, (RsScript)script, (const char *)timeZone_ptr, length);
-
- if (timeZone_ptr) {
- _env->ReleasePrimitiveArrayCritical(timeZone, timeZone_ptr, 0);
- }
-}
-
-static void
-nScriptInvoke(JNIEnv *_env, jobject _this, RsContext con, jint obj, jint slot)
-{
- LOG_API("nScriptInvoke, con(%p), script(%p)", con, (void *)obj);
- rsScriptInvoke(con, (RsScript)obj, slot);
-}
-
-static void
-nScriptInvokeV(JNIEnv *_env, jobject _this, RsContext con, jint script, jint slot, jbyteArray data)
-{
- LOG_API("nScriptInvokeV, con(%p), s(%p), slot(%i)", con, (void *)script, slot);
- jint len = _env->GetArrayLength(data);
- jbyte *ptr = _env->GetByteArrayElements(data, NULL);
- rsScriptInvokeV(con, (RsScript)script, slot, ptr, len);
- _env->ReleaseByteArrayElements(data, ptr, JNI_ABORT);
-}
-
-static void
-nScriptForEach(JNIEnv *_env, jobject _this, RsContext con,
- jint script, jint slot, jint ain, jint aout)
-{
- LOG_API("nScriptForEach, con(%p), s(%p), slot(%i)", con, (void *)script, slot);
- rsScriptForEach(con, (RsScript)script, slot, (RsAllocation)ain, (RsAllocation)aout, NULL, 0, NULL, 0);
-}
-static void
-nScriptForEachV(JNIEnv *_env, jobject _this, RsContext con,
- jint script, jint slot, jint ain, jint aout, jbyteArray params)
-{
- LOG_API("nScriptForEach, con(%p), s(%p), slot(%i)", con, (void *)script, slot);
- jint len = _env->GetArrayLength(params);
- jbyte *ptr = _env->GetByteArrayElements(params, NULL);
- rsScriptForEach(con, (RsScript)script, slot, (RsAllocation)ain, (RsAllocation)aout, ptr, len, NULL, 0);
- _env->ReleaseByteArrayElements(params, ptr, JNI_ABORT);
-}
-
-static void
-nScriptForEachClipped(JNIEnv *_env, jobject _this, RsContext con,
- jint script, jint slot, jint ain, jint aout,
- jint xstart, jint xend,
- jint ystart, jint yend, jint zstart, jint zend)
-{
- LOG_API("nScriptForEachClipped, con(%p), s(%p), slot(%i)", con, (void *)script, slot);
- RsScriptCall sc;
- sc.xStart = xstart;
- sc.xEnd = xend;
- sc.yStart = ystart;
- sc.yEnd = yend;
- sc.zStart = zstart;
- sc.zEnd = zend;
- sc.strategy = RS_FOR_EACH_STRATEGY_DONT_CARE;
- sc.arrayStart = 0;
- sc.arrayEnd = 0;
- rsScriptForEach(con, (RsScript)script, slot, (RsAllocation)ain, (RsAllocation)aout, NULL, 0, &sc, sizeof(sc));
-}
-
-static void
-nScriptForEachClippedV(JNIEnv *_env, jobject _this, RsContext con,
- jint script, jint slot, jint ain, jint aout,
- jbyteArray params, jint xstart, jint xend,
- jint ystart, jint yend, jint zstart, jint zend)
-{
- LOG_API("nScriptForEachClipped, con(%p), s(%p), slot(%i)", con, (void *)script, slot);
- jint len = _env->GetArrayLength(params);
- jbyte *ptr = _env->GetByteArrayElements(params, NULL);
- RsScriptCall sc;
- sc.xStart = xstart;
- sc.xEnd = xend;
- sc.yStart = ystart;
- sc.yEnd = yend;
- sc.zStart = zstart;
- sc.zEnd = zend;
- sc.strategy = RS_FOR_EACH_STRATEGY_DONT_CARE;
- sc.arrayStart = 0;
- sc.arrayEnd = 0;
- rsScriptForEach(con, (RsScript)script, slot, (RsAllocation)ain, (RsAllocation)aout, ptr, len, &sc, sizeof(sc));
- _env->ReleaseByteArrayElements(params, ptr, JNI_ABORT);
-}
-
-// -----------------------------------
-
-static jint
-nScriptCCreate(JNIEnv *_env, jobject _this, RsContext con,
- jstring resName, jstring cacheDir,
- jbyteArray scriptRef, jint length)
-{
- LOG_API("nScriptCCreate, con(%p)", con);
-
- AutoJavaStringToUTF8 resNameUTF(_env, resName);
- AutoJavaStringToUTF8 cacheDirUTF(_env, cacheDir);
- jint ret = 0;
- jbyte* script_ptr = NULL;
- jint _exception = 0;
- jint remaining;
- if (!scriptRef) {
- _exception = 1;
- //jniThrowException(_env, "java/lang/IllegalArgumentException", "script == null");
- goto exit;
- }
- if (length < 0) {
- _exception = 1;
- //jniThrowException(_env, "java/lang/IllegalArgumentException", "length < 0");
- goto exit;
- }
- remaining = _env->GetArrayLength(scriptRef);
- if (remaining < length) {
- _exception = 1;
- //jniThrowException(_env, "java/lang/IllegalArgumentException",
- // "length > script.length - offset");
- goto exit;
- }
- script_ptr = (jbyte *)
- _env->GetPrimitiveArrayCritical(scriptRef, (jboolean *)0);
-
- //rsScriptCSetText(con, (const char *)script_ptr, length);
-
- ret = (jint)rsScriptCCreate(con,
- resNameUTF.c_str(), resNameUTF.length(),
- cacheDirUTF.c_str(), cacheDirUTF.length(),
- (const char *)script_ptr, length);
-
-exit:
- if (script_ptr) {
- _env->ReleasePrimitiveArrayCritical(scriptRef, script_ptr,
- _exception ? JNI_ABORT: 0);
- }
-
- return ret;
-}
-
-static jint
-nScriptIntrinsicCreate(JNIEnv *_env, jobject _this, RsContext con, jint id, jint eid)
-{
- LOG_API("nScriptIntrinsicCreate, con(%p) id(%i) element(%p)", con, id, (void *)eid);
- return (jint)rsScriptIntrinsicCreate(con, id, (RsElement)eid);
-}
-
-static jint
-nScriptKernelIDCreate(JNIEnv *_env, jobject _this, RsContext con, jint sid, jint slot, jint sig)
-{
- LOG_API("nScriptKernelIDCreate, con(%p) script(%p), slot(%i), sig(%i)", con, (void *)sid, slot, sig);
- return (jint)rsScriptKernelIDCreate(con, (RsScript)sid, slot, sig);
-}
-
-static jint
-nScriptFieldIDCreate(JNIEnv *_env, jobject _this, RsContext con, jint sid, jint slot)
-{
- LOG_API("nScriptFieldIDCreate, con(%p) script(%p), slot(%i)", con, (void *)sid, slot);
- return (jint)rsScriptFieldIDCreate(con, (RsScript)sid, slot);
-}
-
-static jint
-nScriptGroupCreate(JNIEnv *_env, jobject _this, RsContext con, jintArray _kernels, jintArray _src,
- jintArray _dstk, jintArray _dstf, jintArray _types)
-{
- LOG_API("nScriptGroupCreate, con(%p)", con);
-
- jint kernelsLen = _env->GetArrayLength(_kernels) * sizeof(int);
- jint *kernelsPtr = _env->GetIntArrayElements(_kernels, NULL);
- jint srcLen = _env->GetArrayLength(_src) * sizeof(int);
- jint *srcPtr = _env->GetIntArrayElements(_src, NULL);
- jint dstkLen = _env->GetArrayLength(_dstk) * sizeof(int);
- jint *dstkPtr = _env->GetIntArrayElements(_dstk, NULL);
- jint dstfLen = _env->GetArrayLength(_dstf) * sizeof(int);
- jint *dstfPtr = _env->GetIntArrayElements(_dstf, NULL);
- jint typesLen = _env->GetArrayLength(_types) * sizeof(int);
- jint *typesPtr = _env->GetIntArrayElements(_types, NULL);
-
- int id = (int)rsScriptGroupCreate(con,
- (RsScriptKernelID *)kernelsPtr, kernelsLen,
- (RsScriptKernelID *)srcPtr, srcLen,
- (RsScriptKernelID *)dstkPtr, dstkLen,
- (RsScriptFieldID *)dstfPtr, dstfLen,
- (RsType *)typesPtr, typesLen);
-
- _env->ReleaseIntArrayElements(_kernels, kernelsPtr, 0);
- _env->ReleaseIntArrayElements(_src, srcPtr, 0);
- _env->ReleaseIntArrayElements(_dstk, dstkPtr, 0);
- _env->ReleaseIntArrayElements(_dstf, dstfPtr, 0);
- _env->ReleaseIntArrayElements(_types, typesPtr, 0);
- return id;
-}
-
-static void
-nScriptGroupSetInput(JNIEnv *_env, jobject _this, RsContext con, jint gid, jint kid, jint alloc)
-{
- LOG_API("nScriptGroupSetInput, con(%p) group(%p), kernelId(%p), alloc(%p)", con,
- (void *)gid, (void *)kid, (void *)alloc);
- rsScriptGroupSetInput(con, (RsScriptGroup)gid, (RsScriptKernelID)kid, (RsAllocation)alloc);
-}
-
-static void
-nScriptGroupSetOutput(JNIEnv *_env, jobject _this, RsContext con, jint gid, jint kid, jint alloc)
-{
- LOG_API("nScriptGroupSetOutput, con(%p) group(%p), kernelId(%p), alloc(%p)", con,
- (void *)gid, (void *)kid, (void *)alloc);
- rsScriptGroupSetOutput(con, (RsScriptGroup)gid, (RsScriptKernelID)kid, (RsAllocation)alloc);
-}
-
-static void
-nScriptGroupExecute(JNIEnv *_env, jobject _this, RsContext con, jint gid)
-{
- LOG_API("nScriptGroupSetOutput, con(%p) group(%p)", con, (void *)gid);
- rsScriptGroupExecute(con, (RsScriptGroup)gid);
-}
-
-// ---------------------------------------------------------------------------
-
-static jint
-nProgramStoreCreate(JNIEnv *_env, jobject _this, RsContext con,
- jboolean colorMaskR, jboolean colorMaskG, jboolean colorMaskB, jboolean colorMaskA,
- jboolean depthMask, jboolean ditherEnable,
- jint srcFunc, jint destFunc,
- jint depthFunc)
-{
- LOG_API("nProgramStoreCreate, con(%p)", con);
- return (jint)rsProgramStoreCreate(con, colorMaskR, colorMaskG, colorMaskB, colorMaskA,
- depthMask, ditherEnable, (RsBlendSrcFunc)srcFunc,
- (RsBlendDstFunc)destFunc, (RsDepthFunc)depthFunc);
-}
-
-// ---------------------------------------------------------------------------
-
-static void
-nProgramBindConstants(JNIEnv *_env, jobject _this, RsContext con, jint vpv, jint slot, jint a)
-{
- LOG_API("nProgramBindConstants, con(%p), vpf(%p), sloat(%i), a(%p)", con, (RsProgramVertex)vpv, slot, (RsAllocation)a);
- rsProgramBindConstants(con, (RsProgram)vpv, slot, (RsAllocation)a);
-}
-
-static void
-nProgramBindTexture(JNIEnv *_env, jobject _this, RsContext con, jint vpf, jint slot, jint a)
-{
- LOG_API("nProgramBindTexture, con(%p), vpf(%p), slot(%i), a(%p)", con, (RsProgramFragment)vpf, slot, (RsAllocation)a);
- rsProgramBindTexture(con, (RsProgramFragment)vpf, slot, (RsAllocation)a);
-}
-
-static void
-nProgramBindSampler(JNIEnv *_env, jobject _this, RsContext con, jint vpf, jint slot, jint a)
-{
- LOG_API("nProgramBindSampler, con(%p), vpf(%p), slot(%i), a(%p)", con, (RsProgramFragment)vpf, slot, (RsSampler)a);
- rsProgramBindSampler(con, (RsProgramFragment)vpf, slot, (RsSampler)a);
-}
-
-// ---------------------------------------------------------------------------
-
-static jint
-nProgramFragmentCreate(JNIEnv *_env, jobject _this, RsContext con, jstring shader,
- jobjectArray texNames, jintArray params)
-{
- AutoJavaStringToUTF8 shaderUTF(_env, shader);
- jint *paramPtr = _env->GetIntArrayElements(params, NULL);
- jint paramLen = _env->GetArrayLength(params);
-
- int texCount = _env->GetArrayLength(texNames);
- AutoJavaStringArrayToUTF8 names(_env, texNames, texCount);
- const char ** nameArray = names.c_str();
- size_t* sizeArray = names.c_str_len();
-
- LOG_API("nProgramFragmentCreate, con(%p), paramLen(%i)", con, paramLen);
-
- jint ret = (jint)rsProgramFragmentCreate(con, shaderUTF.c_str(), shaderUTF.length(),
- nameArray, texCount, sizeArray,
- (uint32_t *)paramPtr, paramLen);
-
- _env->ReleaseIntArrayElements(params, paramPtr, JNI_ABORT);
- return ret;
-}
-
-
-// ---------------------------------------------------------------------------
-
-static jint
-nProgramVertexCreate(JNIEnv *_env, jobject _this, RsContext con, jstring shader,
- jobjectArray texNames, jintArray params)
-{
- AutoJavaStringToUTF8 shaderUTF(_env, shader);
- jint *paramPtr = _env->GetIntArrayElements(params, NULL);
- jint paramLen = _env->GetArrayLength(params);
-
- LOG_API("nProgramVertexCreate, con(%p), paramLen(%i)", con, paramLen);
-
- int texCount = _env->GetArrayLength(texNames);
- AutoJavaStringArrayToUTF8 names(_env, texNames, texCount);
- const char ** nameArray = names.c_str();
- size_t* sizeArray = names.c_str_len();
-
- jint ret = (jint)rsProgramVertexCreate(con, shaderUTF.c_str(), shaderUTF.length(),
- nameArray, texCount, sizeArray,
- (uint32_t *)paramPtr, paramLen);
-
- _env->ReleaseIntArrayElements(params, paramPtr, JNI_ABORT);
- return ret;
-}
-
-// ---------------------------------------------------------------------------
-
-static jint
-nProgramRasterCreate(JNIEnv *_env, jobject _this, RsContext con, jboolean pointSprite, jint cull)
-{
- LOG_API("nProgramRasterCreate, con(%p), pointSprite(%i), cull(%i)", con, pointSprite, cull);
- return (jint)rsProgramRasterCreate(con, pointSprite, (RsCullMode)cull);
-}
-
-
-// ---------------------------------------------------------------------------
-
-static void
-nContextBindRootScript(JNIEnv *_env, jobject _this, RsContext con, jint script)
-{
- LOG_API("nContextBindRootScript, con(%p), script(%p)", con, (RsScript)script);
- rsContextBindRootScript(con, (RsScript)script);
-}
-
-static void
-nContextBindProgramStore(JNIEnv *_env, jobject _this, RsContext con, jint pfs)
-{
- LOG_API("nContextBindProgramStore, con(%p), pfs(%p)", con, (RsProgramStore)pfs);
- rsContextBindProgramStore(con, (RsProgramStore)pfs);
-}
-
-static void
-nContextBindProgramFragment(JNIEnv *_env, jobject _this, RsContext con, jint pf)
-{
- LOG_API("nContextBindProgramFragment, con(%p), pf(%p)", con, (RsProgramFragment)pf);
- rsContextBindProgramFragment(con, (RsProgramFragment)pf);
-}
-
-static void
-nContextBindProgramVertex(JNIEnv *_env, jobject _this, RsContext con, jint pf)
-{
- LOG_API("nContextBindProgramVertex, con(%p), pf(%p)", con, (RsProgramVertex)pf);
- rsContextBindProgramVertex(con, (RsProgramVertex)pf);
-}
-
-static void
-nContextBindProgramRaster(JNIEnv *_env, jobject _this, RsContext con, jint pf)
-{
- LOG_API("nContextBindProgramRaster, con(%p), pf(%p)", con, (RsProgramRaster)pf);
- rsContextBindProgramRaster(con, (RsProgramRaster)pf);
-}
-
-
-// ---------------------------------------------------------------------------
-
-static jint
-nSamplerCreate(JNIEnv *_env, jobject _this, RsContext con, jint magFilter, jint minFilter,
- jint wrapS, jint wrapT, jint wrapR, jfloat aniso)
-{
- LOG_API("nSamplerCreate, con(%p)", con);
- return (jint)rsSamplerCreate(con,
- (RsSamplerValue)magFilter,
- (RsSamplerValue)minFilter,
- (RsSamplerValue)wrapS,
- (RsSamplerValue)wrapT,
- (RsSamplerValue)wrapR,
- aniso);
-}
-
-// ---------------------------------------------------------------------------
-
-//native int rsnPathCreate(int con, int prim, boolean isStatic, int vtx, int loop, float q);
-static jint
-nPathCreate(JNIEnv *_env, jobject _this, RsContext con, jint prim, jboolean isStatic, jint _vtx, jint _loop, jfloat q) {
- LOG_API("nPathCreate, con(%p)", con);
-
- int id = (int)rsPathCreate(con, (RsPathPrimitive)prim, isStatic,
- (RsAllocation)_vtx,
- (RsAllocation)_loop, q);
- return id;
-}
-
-static jint
-nMeshCreate(JNIEnv *_env, jobject _this, RsContext con, jintArray _vtx, jintArray _idx, jintArray _prim)
-{
- LOG_API("nMeshCreate, con(%p)", con);
-
- jint vtxLen = _env->GetArrayLength(_vtx);
- jint *vtxPtr = _env->GetIntArrayElements(_vtx, NULL);
- jint idxLen = _env->GetArrayLength(_idx);
- jint *idxPtr = _env->GetIntArrayElements(_idx, NULL);
- jint primLen = _env->GetArrayLength(_prim);
- jint *primPtr = _env->GetIntArrayElements(_prim, NULL);
-
- int id = (int)rsMeshCreate(con,
- (RsAllocation *)vtxPtr, vtxLen,
- (RsAllocation *)idxPtr, idxLen,
- (uint32_t *)primPtr, primLen);
-
- _env->ReleaseIntArrayElements(_vtx, vtxPtr, 0);
- _env->ReleaseIntArrayElements(_idx, idxPtr, 0);
- _env->ReleaseIntArrayElements(_prim, primPtr, 0);
- return id;
-}
-
-static jint
-nMeshGetVertexBufferCount(JNIEnv *_env, jobject _this, RsContext con, jint mesh)
-{
- LOG_API("nMeshGetVertexBufferCount, con(%p), Mesh(%p)", con, (RsMesh)mesh);
- jint vtxCount = 0;
- rsaMeshGetVertexBufferCount(con, (RsMesh)mesh, &vtxCount);
- return vtxCount;
-}
-
-static jint
-nMeshGetIndexCount(JNIEnv *_env, jobject _this, RsContext con, jint mesh)
-{
- LOG_API("nMeshGetIndexCount, con(%p), Mesh(%p)", con, (RsMesh)mesh);
- jint idxCount = 0;
- rsaMeshGetIndexCount(con, (RsMesh)mesh, &idxCount);
- return idxCount;
-}
-
-static void
-nMeshGetVertices(JNIEnv *_env, jobject _this, RsContext con, jint mesh, jintArray _ids, int numVtxIDs)
-{
- LOG_API("nMeshGetVertices, con(%p), Mesh(%p)", con, (RsMesh)mesh);
-
- RsAllocation *allocs = (RsAllocation*)malloc((uint32_t)numVtxIDs * sizeof(RsAllocation));
- rsaMeshGetVertices(con, (RsMesh)mesh, allocs, (uint32_t)numVtxIDs);
-
- for(jint i = 0; i < numVtxIDs; i ++) {
- _env->SetIntArrayRegion(_ids, i, 1, (const jint*)&allocs[i]);
- }
-
- free(allocs);
-}
-
-static void
-nMeshGetIndices(JNIEnv *_env, jobject _this, RsContext con, jint mesh, jintArray _idxIds, jintArray _primitives, int numIndices)
-{
- LOG_API("nMeshGetVertices, con(%p), Mesh(%p)", con, (RsMesh)mesh);
-
- RsAllocation *allocs = (RsAllocation*)malloc((uint32_t)numIndices * sizeof(RsAllocation));
- uint32_t *prims= (uint32_t*)malloc((uint32_t)numIndices * sizeof(uint32_t));
-
- rsaMeshGetIndices(con, (RsMesh)mesh, allocs, prims, (uint32_t)numIndices);
-
- for(jint i = 0; i < numIndices; i ++) {
- _env->SetIntArrayRegion(_idxIds, i, 1, (const jint*)&allocs[i]);
- _env->SetIntArrayRegion(_primitives, i, 1, (const jint*)&prims[i]);
- }
-
- free(allocs);
- free(prims);
-}
-
-// ---------------------------------------------------------------------------
-
-
-static const char *classPathName = "android/renderscript/RenderScript";
-
-static JNINativeMethod methods[] = {
-{"_nInit", "()V", (void*)_nInit },
-
-{"nDeviceCreate", "()I", (void*)nDeviceCreate },
-{"nDeviceDestroy", "(I)V", (void*)nDeviceDestroy },
-{"nDeviceSetConfig", "(III)V", (void*)nDeviceSetConfig },
-{"nContextGetUserMessage", "(I[I)I", (void*)nContextGetUserMessage },
-{"nContextGetErrorMessage", "(I)Ljava/lang/String;", (void*)nContextGetErrorMessage },
-{"nContextPeekMessage", "(I[I)I", (void*)nContextPeekMessage },
-
-{"nContextInitToClient", "(I)V", (void*)nContextInitToClient },
-{"nContextDeinitToClient", "(I)V", (void*)nContextDeinitToClient },
-
-
-// All methods below are thread protected in java.
-{"rsnContextCreate", "(IIII)I", (void*)nContextCreate },
-{"rsnContextCreateGL", "(IIIIIIIIIIIIIFI)I", (void*)nContextCreateGL },
-{"rsnContextFinish", "(I)V", (void*)nContextFinish },
-{"rsnContextSetPriority", "(II)V", (void*)nContextSetPriority },
-{"rsnContextSetSurface", "(IIILandroid/view/Surface;)V", (void*)nContextSetSurface },
-{"rsnContextDestroy", "(I)V", (void*)nContextDestroy },
-{"rsnContextDump", "(II)V", (void*)nContextDump },
-{"rsnContextPause", "(I)V", (void*)nContextPause },
-{"rsnContextResume", "(I)V", (void*)nContextResume },
-{"rsnContextSendMessage", "(II[I)V", (void*)nContextSendMessage },
-{"rsnAssignName", "(II[B)V", (void*)nAssignName },
-{"rsnGetName", "(II)Ljava/lang/String;", (void*)nGetName },
-{"rsnObjDestroy", "(II)V", (void*)nObjDestroy },
-
-{"rsnFileA3DCreateFromFile", "(ILjava/lang/String;)I", (void*)nFileA3DCreateFromFile },
-{"rsnFileA3DCreateFromAssetStream", "(II)I", (void*)nFileA3DCreateFromAssetStream },
-{"rsnFileA3DCreateFromAsset", "(ILandroid/content/res/AssetManager;Ljava/lang/String;)I", (void*)nFileA3DCreateFromAsset },
-{"rsnFileA3DGetNumIndexEntries", "(II)I", (void*)nFileA3DGetNumIndexEntries },
-{"rsnFileA3DGetIndexEntries", "(III[I[Ljava/lang/String;)V", (void*)nFileA3DGetIndexEntries },
-{"rsnFileA3DGetEntryByIndex", "(III)I", (void*)nFileA3DGetEntryByIndex },
-
-{"rsnFontCreateFromFile", "(ILjava/lang/String;FI)I", (void*)nFontCreateFromFile },
-{"rsnFontCreateFromAssetStream", "(ILjava/lang/String;FII)I", (void*)nFontCreateFromAssetStream },
-{"rsnFontCreateFromAsset", "(ILandroid/content/res/AssetManager;Ljava/lang/String;FI)I", (void*)nFontCreateFromAsset },
-
-{"rsnElementCreate", "(IIIZI)I", (void*)nElementCreate },
-{"rsnElementCreate2", "(I[I[Ljava/lang/String;[I)I", (void*)nElementCreate2 },
-{"rsnElementGetNativeData", "(II[I)V", (void*)nElementGetNativeData },
-{"rsnElementGetSubElements", "(II[I[Ljava/lang/String;[I)V", (void*)nElementGetSubElements },
-
-{"rsnTypeCreate", "(IIIIIZZI)I", (void*)nTypeCreate },
-{"rsnTypeGetNativeData", "(II[I)V", (void*)nTypeGetNativeData },
-
-{"rsnAllocationCreateTyped", "(IIIII)I", (void*)nAllocationCreateTyped },
-{"rsnAllocationCreateFromBitmap", "(IIILandroid/graphics/Bitmap;I)I", (void*)nAllocationCreateFromBitmap },
-{"rsnAllocationCreateBitmapBackedAllocation", "(IIILandroid/graphics/Bitmap;I)I", (void*)nAllocationCreateBitmapBackedAllocation },
-{"rsnAllocationCubeCreateFromBitmap","(IIILandroid/graphics/Bitmap;I)I", (void*)nAllocationCubeCreateFromBitmap },
-
-{"rsnAllocationCopyFromBitmap", "(IILandroid/graphics/Bitmap;)V", (void*)nAllocationCopyFromBitmap },
-{"rsnAllocationCopyToBitmap", "(IILandroid/graphics/Bitmap;)V", (void*)nAllocationCopyToBitmap },
-
-{"rsnAllocationSyncAll", "(III)V", (void*)nAllocationSyncAll },
-{"rsnAllocationGetSurface", "(II)Landroid/view/Surface;", (void*)nAllocationGetSurface },
-{"rsnAllocationSetSurface", "(IILandroid/view/Surface;)V", (void*)nAllocationSetSurface },
-{"rsnAllocationIoSend", "(II)V", (void*)nAllocationIoSend },
-{"rsnAllocationIoReceive", "(II)V", (void*)nAllocationIoReceive },
-{"rsnAllocationData1D", "(IIIII[II)V", (void*)nAllocationData1D_i },
-{"rsnAllocationData1D", "(IIIII[SI)V", (void*)nAllocationData1D_s },
-{"rsnAllocationData1D", "(IIIII[BI)V", (void*)nAllocationData1D_b },
-{"rsnAllocationData1D", "(IIIII[FI)V", (void*)nAllocationData1D_f },
-{"rsnAllocationElementData1D", "(IIIII[BI)V", (void*)nAllocationElementData1D },
-{"rsnAllocationData2D", "(IIIIIIII[II)V", (void*)nAllocationData2D_i },
-{"rsnAllocationData2D", "(IIIIIIII[SI)V", (void*)nAllocationData2D_s },
-{"rsnAllocationData2D", "(IIIIIIII[BI)V", (void*)nAllocationData2D_b },
-{"rsnAllocationData2D", "(IIIIIIII[FI)V", (void*)nAllocationData2D_f },
-{"rsnAllocationData2D", "(IIIIIIIIIIIII)V", (void*)nAllocationData2D_alloc },
-{"rsnAllocationData3D", "(IIIIIIIII[II)V", (void*)nAllocationData3D_i },
-{"rsnAllocationData3D", "(IIIIIIIII[SI)V", (void*)nAllocationData3D_s },
-{"rsnAllocationData3D", "(IIIIIIIII[BI)V", (void*)nAllocationData3D_b },
-{"rsnAllocationData3D", "(IIIIIIIII[FI)V", (void*)nAllocationData3D_f },
-{"rsnAllocationData3D", "(IIIIIIIIIIIIII)V", (void*)nAllocationData3D_alloc },
-{"rsnAllocationRead", "(II[I)V", (void*)nAllocationRead_i },
-{"rsnAllocationRead", "(II[S)V", (void*)nAllocationRead_s },
-{"rsnAllocationRead", "(II[B)V", (void*)nAllocationRead_b },
-{"rsnAllocationRead", "(II[F)V", (void*)nAllocationRead_f },
-{"rsnAllocationGetType", "(II)I", (void*)nAllocationGetType},
-{"rsnAllocationResize1D", "(III)V", (void*)nAllocationResize1D },
-{"rsnAllocationGenerateMipmaps", "(II)V", (void*)nAllocationGenerateMipmaps },
-
-{"rsnScriptBindAllocation", "(IIII)V", (void*)nScriptBindAllocation },
-{"rsnScriptSetTimeZone", "(II[B)V", (void*)nScriptSetTimeZone },
-{"rsnScriptInvoke", "(III)V", (void*)nScriptInvoke },
-{"rsnScriptInvokeV", "(III[B)V", (void*)nScriptInvokeV },
-{"rsnScriptForEach", "(IIIII)V", (void*)nScriptForEach },
-{"rsnScriptForEach", "(IIIII[B)V", (void*)nScriptForEachV },
-{"rsnScriptForEachClipped", "(IIIIIIIIIII)V", (void*)nScriptForEachClipped },
-{"rsnScriptForEachClipped", "(IIIII[BIIIIII)V", (void*)nScriptForEachClippedV },
-{"rsnScriptSetVarI", "(IIII)V", (void*)nScriptSetVarI },
-{"rsnScriptGetVarI", "(III)I", (void*)nScriptGetVarI },
-{"rsnScriptSetVarJ", "(IIIJ)V", (void*)nScriptSetVarJ },
-{"rsnScriptGetVarJ", "(III)J", (void*)nScriptGetVarJ },
-{"rsnScriptSetVarF", "(IIIF)V", (void*)nScriptSetVarF },
-{"rsnScriptGetVarF", "(III)F", (void*)nScriptGetVarF },
-{"rsnScriptSetVarD", "(IIID)V", (void*)nScriptSetVarD },
-{"rsnScriptGetVarD", "(III)D", (void*)nScriptGetVarD },
-{"rsnScriptSetVarV", "(III[B)V", (void*)nScriptSetVarV },
-{"rsnScriptGetVarV", "(III[B)V", (void*)nScriptGetVarV },
-{"rsnScriptSetVarVE", "(III[BI[I)V", (void*)nScriptSetVarVE },
-{"rsnScriptSetVarObj", "(IIII)V", (void*)nScriptSetVarObj },
-
-{"rsnScriptCCreate", "(ILjava/lang/String;Ljava/lang/String;[BI)I", (void*)nScriptCCreate },
-{"rsnScriptIntrinsicCreate", "(III)I", (void*)nScriptIntrinsicCreate },
-{"rsnScriptKernelIDCreate", "(IIII)I", (void*)nScriptKernelIDCreate },
-{"rsnScriptFieldIDCreate", "(III)I", (void*)nScriptFieldIDCreate },
-{"rsnScriptGroupCreate", "(I[I[I[I[I[I)I", (void*)nScriptGroupCreate },
-{"rsnScriptGroupSetInput", "(IIII)V", (void*)nScriptGroupSetInput },
-{"rsnScriptGroupSetOutput", "(IIII)V", (void*)nScriptGroupSetOutput },
-{"rsnScriptGroupExecute", "(II)V", (void*)nScriptGroupExecute },
-
-{"rsnProgramStoreCreate", "(IZZZZZZIII)I", (void*)nProgramStoreCreate },
-
-{"rsnProgramBindConstants", "(IIII)V", (void*)nProgramBindConstants },
-{"rsnProgramBindTexture", "(IIII)V", (void*)nProgramBindTexture },
-{"rsnProgramBindSampler", "(IIII)V", (void*)nProgramBindSampler },
-
-{"rsnProgramFragmentCreate", "(ILjava/lang/String;[Ljava/lang/String;[I)I", (void*)nProgramFragmentCreate },
-{"rsnProgramRasterCreate", "(IZI)I", (void*)nProgramRasterCreate },
-{"rsnProgramVertexCreate", "(ILjava/lang/String;[Ljava/lang/String;[I)I", (void*)nProgramVertexCreate },
-
-{"rsnContextBindRootScript", "(II)V", (void*)nContextBindRootScript },
-{"rsnContextBindProgramStore", "(II)V", (void*)nContextBindProgramStore },
-{"rsnContextBindProgramFragment", "(II)V", (void*)nContextBindProgramFragment },
-{"rsnContextBindProgramVertex", "(II)V", (void*)nContextBindProgramVertex },
-{"rsnContextBindProgramRaster", "(II)V", (void*)nContextBindProgramRaster },
-
-{"rsnSamplerCreate", "(IIIIIIF)I", (void*)nSamplerCreate },
-
-{"rsnPathCreate", "(IIZIIF)I", (void*)nPathCreate },
-{"rsnMeshCreate", "(I[I[I[I)I", (void*)nMeshCreate },
-
-{"rsnMeshGetVertexBufferCount", "(II)I", (void*)nMeshGetVertexBufferCount },
-{"rsnMeshGetIndexCount", "(II)I", (void*)nMeshGetIndexCount },
-{"rsnMeshGetVertices", "(II[II)V", (void*)nMeshGetVertices },
-{"rsnMeshGetIndices", "(II[I[II)V", (void*)nMeshGetIndices },
-
-};
-
-static int registerFuncs(JNIEnv *_env)
-{
- return android::AndroidRuntime::registerNativeMethods(
- _env, classPathName, methods, NELEM(methods));
-}
-
-// ---------------------------------------------------------------------------
-
-jint JNI_OnLoad(JavaVM* vm, void* reserved)
-{
- JNIEnv* env = NULL;
- jint result = -1;
-
- if (vm->GetEnv((void**) &env, JNI_VERSION_1_4) != JNI_OK) {
- ALOGE("ERROR: GetEnv failed\n");
- goto bail;
- }
- assert(env != NULL);
-
- if (registerFuncs(env) < 0) {
- ALOGE("ERROR: MediaPlayer native registration failed\n");
- goto bail;
- }
-
- /* success -- return valid version number */
- result = JNI_VERSION_1_4;
-
-bail:
- return result;
-}
diff --git a/include/android_runtime/AndroidRuntime.h b/include/android_runtime/AndroidRuntime.h
index 0b3ce9a..3dfdb46 100644
--- a/include/android_runtime/AndroidRuntime.h
+++ b/include/android_runtime/AndroidRuntime.h
@@ -34,7 +34,7 @@
class AndroidRuntime
{
public:
- AndroidRuntime();
+ AndroidRuntime(char* argBlockStart, size_t argBlockSize);
virtual ~AndroidRuntime();
enum StartMode {
@@ -44,6 +44,8 @@
Tool,
};
+ void setArgv0(const char* argv0);
+
/**
* Register a set of methods in the specified class.
*/
@@ -53,8 +55,7 @@
/**
* Call a class's static main method with the given arguments,
*/
- status_t callMain(const char* className, jclass clazz, int argc,
- const char* const argv[]);
+ status_t callMain(const String8& className, jclass clazz, const Vector<String8>& args);
/**
* Find a class, with the input either of the form
@@ -64,7 +65,7 @@
int addVmArguments(int argc, const char* const argv[]);
- void start(const char *classname, const char* options);
+ void start(const char *classname, const Vector<String8>& options);
void exit(int code);
@@ -115,11 +116,13 @@
private:
static int startReg(JNIEnv* env);
- void parseExtraOpts(char* extraOptsBuf);
+ void parseExtraOpts(char* extraOptsBuf, const char* quotingArg);
int startVm(JavaVM** pJavaVM, JNIEnv** pEnv);
Vector<JavaVMOption> mOptions;
bool mExitWithoutCleanup;
+ char* const mArgBlockStart;
+ const size_t mArgBlockLength;
/* JNI JavaVM pointer */
static JavaVM* mJavaVM;
diff --git a/include/androidfw/AssetManager.h b/include/androidfw/AssetManager.h
index d95b45e..a13dd16 100644
--- a/include/androidfw/AssetManager.h
+++ b/include/androidfw/AssetManager.h
@@ -69,6 +69,13 @@
*/
class AssetManager : public AAssetManager {
public:
+ static const char* RESOURCES_FILENAME;
+ static const char* IDMAP_BIN;
+ static const char* OVERLAY_DIR;
+ static const char* TARGET_PACKAGE_NAME;
+ static const char* TARGET_APK_PATH;
+ static const char* IDMAP_DIR;
+
typedef enum CacheMode {
CACHE_UNKNOWN = 0,
CACHE_OFF, // don't try to cache file locations
@@ -92,7 +99,8 @@
* then on success, *cookie is set to the value corresponding to the
* newly-added asset source.
*/
- bool addAssetPath(const String8& path, void** cookie);
+ bool addAssetPath(const String8& path, int32_t* cookie);
+ bool addOverlayPath(const String8& path, int32_t* cookie);
/*
* Convenience for adding the standard system assets. Uses the
@@ -103,17 +111,17 @@
/*
* Iterate over the asset paths in this manager. (Previously
* added via addAssetPath() and addDefaultAssets().) On first call,
- * 'cookie' must be NULL, resulting in the first cookie being returned.
- * Each next cookie will be returned there-after, until NULL indicating
+ * 'cookie' must be 0, resulting in the first cookie being returned.
+ * Each next cookie will be returned there-after, until -1 indicating
* the end has been reached.
*/
- void* nextAssetPath(void* cookie) const;
+ int32_t nextAssetPath(const int32_t cookie) const;
/*
* Return an asset path in the manager. 'which' must be between 0 and
* countAssetPaths().
*/
- String8 getAssetPath(void* cookie) const;
+ String8 getAssetPath(const int32_t cookie) const;
/*
* Set the current locale and vendor. The locale can change during
@@ -159,7 +167,7 @@
* Explicit non-asset file. The file explicitly named by the cookie (the
* resource set to look in) and fileName will be opened and returned.
*/
- Asset* openNonAsset(void* cookie, const char* fileName, AccessMode mode);
+ Asset* openNonAsset(const int32_t cookie, const char* fileName, AccessMode mode);
/*
* Open a directory within the asset hierarchy.
@@ -183,7 +191,7 @@
*
* To open the top-level directory, pass in "".
*/
- AssetDir* openNonAssetDir(void* cookie, const char* dirName);
+ AssetDir* openNonAssetDir(const int32_t cookie, const char* dirName);
/*
* Get the type of a file in the asset hierarchy. They will either
@@ -218,6 +226,13 @@
*/
void getLocales(Vector<String8>* locales) const;
+ /**
+ * Generate idmap data to translate resources IDs between a package and a
+ * corresponding overlay package.
+ */
+ bool createIdmap(const char* targetApkPath, const char* overlayApkPath,
+ uint32_t targetCrc, uint32_t overlayCrc, uint32_t** outData, size_t* outSize);
+
private:
struct asset_path
{
@@ -264,19 +279,14 @@
void setLocaleLocked(const char* locale);
void updateResourceParamsLocked() const;
- bool createIdmapFileLocked(const String8& originalPath, const String8& overlayPath,
- const String8& idmapPath);
-
- bool isIdmapStaleLocked(const String8& originalPath, const String8& overlayPath,
- const String8& idmapPath);
-
Asset* openIdmapLocked(const struct asset_path& ap) const;
- bool getZipEntryCrcLocked(const String8& zipPath, const char* entryFilename, uint32_t* pCrc);
+ void addSystemOverlays(const char* pathOverlaysList, const String8& targetPackagePath,
+ ResTable* sharedRes, size_t offset) const;
class SharedZip : public RefBase {
public:
- static sp<SharedZip> get(const String8& path);
+ static sp<SharedZip> get(const String8& path, bool createIfNotPresent = true);
ZipFileRO* getZip();
@@ -287,6 +297,9 @@
ResTable* setResourceTable(ResTable* res);
bool isUpToDate();
+
+ void addOverlay(const asset_path& ap);
+ bool getOverlay(size_t idx, asset_path* out) const;
protected:
~SharedZip();
@@ -302,6 +315,8 @@
Asset* mResourceTableAsset;
ResTable* mResourceTable;
+ Vector<asset_path> mOverlays;
+
static Mutex gLock;
static DefaultKeyedVector<String8, wp<SharedZip> > gOpen;
};
@@ -334,6 +349,9 @@
static String8 getPathName(const char* path);
bool isUpToDate();
+
+ void addOverlay(const String8& path, const asset_path& overlay);
+ bool getOverlay(const String8& path, size_t idx, asset_path* out) const;
private:
void closeZip(int idx);
diff --git a/include/androidfw/ResourceTypes.h b/include/androidfw/ResourceTypes.h
index 5151b06..b334aab 100644
--- a/include/androidfw/ResourceTypes.h
+++ b/include/androidfw/ResourceTypes.h
@@ -79,7 +79,7 @@
* two stretchable slices is exactly the ratio of their corresponding
* segment lengths.
*
- * xDivs and yDivs point to arrays of horizontal and vertical pixel
+ * xDivs and yDivs are arrays of horizontal and vertical pixel
* indices. The first pair of Divs (in either array) indicate the
* starting and ending points of the first stretchable segment in that
* axis. The next pair specifies the next stretchable segment, etc. So
@@ -92,32 +92,31 @@
* go to xDiv[0] and slices 2, 6 and 10 start at xDiv[1] and end at
* xDiv[2].
*
- * The array pointed to by the colors field lists contains hints for
- * each of the regions. They are ordered according left-to-right and
- * top-to-bottom as indicated above. For each segment that is a solid
- * color the array entry will contain that color value; otherwise it
- * will contain NO_COLOR. Segments that are completely transparent
- * will always have the value TRANSPARENT_COLOR.
+ * The colors array contains hints for each of the regions. They are
+ * ordered according left-to-right and top-to-bottom as indicated above.
+ * For each segment that is a solid color the array entry will contain
+ * that color value; otherwise it will contain NO_COLOR. Segments that
+ * are completely transparent will always have the value TRANSPARENT_COLOR.
*
* The PNG chunk type is "npTc".
*/
struct Res_png_9patch
{
- Res_png_9patch() : wasDeserialized(false), xDivs(NULL),
- yDivs(NULL), colors(NULL) { }
+ Res_png_9patch() : wasDeserialized(false), xDivsOffset(0),
+ yDivsOffset(0), colorsOffset(0) { }
int8_t wasDeserialized;
int8_t numXDivs;
int8_t numYDivs;
int8_t numColors;
- // These tell where the next section of a patch starts.
- // For example, the first patch includes the pixels from
- // 0 to xDivs[0]-1 and the second patch includes the pixels
- // from xDivs[0] to xDivs[1]-1.
- // Note: allocation/free of these pointers is left to the caller.
- int32_t* xDivs;
- int32_t* yDivs;
+ // The offset (from the start of this structure) to the xDivs & yDivs
+ // array for this 9patch. To get a pointer to this array, call
+ // getXDivs or getYDivs. Note that the serialized form for 9patches places
+ // the xDivs, yDivs and colors arrays immediately after the location
+ // of the Res_png_9patch struct.
+ uint32_t xDivsOffset;
+ uint32_t yDivsOffset;
int32_t paddingLeft, paddingRight;
int32_t paddingTop, paddingBottom;
@@ -129,22 +128,42 @@
// The 9 patch segment is completely transparent.
TRANSPARENT_COLOR = 0x00000000
};
- // Note: allocation/free of this pointer is left to the caller.
- uint32_t* colors;
+
+ // The offset (from the start of this structure) to the colors array
+ // for this 9patch.
+ uint32_t colorsOffset;
// Convert data from device representation to PNG file representation.
void deviceToFile();
// Convert data from PNG file representation to device representation.
void fileToDevice();
- // Serialize/Marshall the patch data into a newly malloc-ed block
- void* serialize();
- // Serialize/Marshall the patch data
- void serialize(void* outData);
+
+ // Serialize/Marshall the patch data into a newly malloc-ed block.
+ static void* serialize(const Res_png_9patch& patchHeader, const int32_t* xDivs,
+ const int32_t* yDivs, const uint32_t* colors);
+ // Serialize/Marshall the patch data into |outData|.
+ static void serialize(const Res_png_9patch& patchHeader, const int32_t* xDivs,
+ const int32_t* yDivs, const uint32_t* colors, void* outData);
// Deserialize/Unmarshall the patch data
- static Res_png_9patch* deserialize(const void* data);
+ static Res_png_9patch* deserialize(void* data);
// Compute the size of the serialized data structure
- size_t serializedSize();
-};
+ size_t serializedSize() const;
+
+ // These tell where the next section of a patch starts.
+ // For example, the first patch includes the pixels from
+ // 0 to xDivs[0]-1 and the second patch includes the pixels
+ // from xDivs[0] to xDivs[1]-1.
+ inline int32_t* getXDivs() const {
+ return reinterpret_cast<int32_t*>(reinterpret_cast<uintptr_t>(this) + xDivsOffset);
+ }
+ inline int32_t* getYDivs() const {
+ return reinterpret_cast<int32_t*>(reinterpret_cast<uintptr_t>(this) + yDivsOffset);
+ }
+ inline uint32_t* getColors() const {
+ return reinterpret_cast<uint32_t*>(reinterpret_cast<uintptr_t>(this) + colorsOffset);
+ }
+
+} __attribute__((packed));
/** ********************************************************************
* Base Types
@@ -808,6 +827,19 @@
uint32_t lastPublicKey;
};
+// The most specific locale can consist of:
+//
+// - a 3 char language code
+// - a 3 char region code prefixed by a 'r'
+// - a 4 char script code prefixed by a 's'
+// - a 8 char variant code prefixed by a 'v'
+//
+// each separated by a single char separator, which sums up to a total of 24
+// chars, (25 include the string terminator) rounded up to 28 to be 4 byte
+// aligned.
+#define RESTABLE_MAX_LOCALE_LEN 28
+
+
/**
* Describes a particular resource configuration.
*/
@@ -828,10 +860,42 @@
union {
struct {
- // \0\0 means "any". Otherwise, en, fr, etc.
+ // This field can take three different forms:
+ // - \0\0 means "any".
+ //
+ // - Two 7 bit ascii values interpreted as ISO-639-1 language
+ // codes ('fr', 'en' etc. etc.). The high bit for both bytes is
+ // zero.
+ //
+ // - A single 16 bit little endian packed value representing an
+ // ISO-639-2 3 letter language code. This will be of the form:
+ //
+ // {1, t, t, t, t, t, s, s, s, s, s, f, f, f, f, f}
+ //
+ // bit[0, 4] = first letter of the language code
+ // bit[5, 9] = second letter of the language code
+ // bit[10, 14] = third letter of the language code.
+ // bit[15] = 1 always
+ //
+ // For backwards compatibility, languages that have unambiguous
+ // two letter codes are represented in that format.
+ //
+ // The layout is always bigendian irrespective of the runtime
+ // architecture.
char language[2];
- // \0\0 means "any". Otherwise, US, CA, etc.
+ // This field can take three different forms:
+ // - \0\0 means "any".
+ //
+ // - Two 7 bit ascii values interpreted as 2 letter region
+ // codes ('US', 'GB' etc.). The high bit for both bytes is zero.
+ //
+ // - An UN M.49 3 digit region code. For simplicity, these are packed
+ // in the same manner as the language codes, though we should need
+ // only 10 bits to represent them, instead of the 15.
+ //
+ // The layout is always bigendian irrespective of the runtime
+ // architecture.
char country[2];
};
uint32_t locale;
@@ -933,7 +997,7 @@
SDKVERSION_ANY = 0
};
- enum {
+ enum {
MINORVERSION_ANY = 0
};
@@ -1006,6 +1070,15 @@
uint32_t screenSizeDp;
};
+ // The ISO-15924 short name for the script corresponding to this
+ // configuration. (eg. Hant, Latn, etc.). Interpreted in conjunction with
+ // the locale field.
+ char localeScript[4];
+
+ // A single BCP-47 variant subtag. Will vary in length between 5 and 8
+ // chars. Interpreted in conjunction with the locale field.
+ char localeVariant[8];
+
void copyFromDeviceNoSwap(const ResTable_config& o);
void copyFromDtoH(const ResTable_config& o);
@@ -1063,7 +1136,46 @@
// settings is the requested settings
bool match(const ResTable_config& settings) const;
- void getLocale(char str[6]) const;
+ // Get the string representation of the locale component of this
+ // Config. The maximum size of this representation will be
+ // |RESTABLE_MAX_LOCALE_LEN| (including a terminating '\0').
+ //
+ // Example: en-US, en-Latn-US, en-POSIX.
+ void getBcp47Locale(char* out) const;
+
+ // Sets the values of language, region, script and variant to the
+ // well formed BCP-47 locale contained in |in|. The input locale is
+ // assumed to be valid and no validation is performed.
+ void setBcp47Locale(const char* in);
+
+ inline void clearLocale() {
+ locale = 0;
+ memset(localeScript, 0, sizeof(localeScript));
+ memset(localeVariant, 0, sizeof(localeVariant));
+ }
+
+ // Get the 2 or 3 letter language code of this configuration. Trailing
+ // bytes are set to '\0'.
+ size_t unpackLanguage(char language[4]) const;
+ // Get the 2 or 3 letter language code of this configuration. Trailing
+ // bytes are set to '\0'.
+ size_t unpackRegion(char region[4]) const;
+
+ // Sets the language code of this configuration to the first three
+ // chars at |language|.
+ //
+ // If |language| is a 2 letter code, the trailing byte must be '\0' or
+ // the BCP-47 separator '-'.
+ void packLanguage(const char* language);
+ // Sets the region code of this configuration to the first three bytes
+ // at |region|. If |region| is a 2 letter code, the trailing byte must be '\0'
+ // or the BCP-47 separator '-'.
+ void packRegion(const char* region);
+
+ // Returns a positive integer if this config is more specific than |o|
+ // with respect to their locales, a negative integer if |o| is more specific
+ // and 0 if they're equally specific.
+ int isLocaleMoreSpecificThan(const ResTable_config &o) const;
String8 toString() const;
};
@@ -1279,14 +1391,13 @@
{
public:
ResTable();
- ResTable(const void* data, size_t size, void* cookie,
+ ResTable(const void* data, size_t size, const int32_t cookie,
bool copyData=false);
~ResTable();
- status_t add(const void* data, size_t size, void* cookie,
- bool copyData=false, const void* idmap = NULL);
- status_t add(Asset* asset, void* cookie,
- bool copyData=false, const void* idmap = NULL);
+ status_t add(Asset* asset, const int32_t cookie, bool copyData,
+ const void* idmap = NULL);
+ status_t add(const void *data, size_t size);
status_t add(ResTable* src);
status_t getError() const;
@@ -1534,7 +1645,7 @@
// but not the names their entries or types.
const ResStringPool* getTableStringBlock(size_t index) const;
// Return unique cookie identifier for the given resource table.
- void* getTableCookie(size_t index) const;
+ int32_t getTableCookie(size_t index) const;
// Return the configurations (ResTable_config) that we know about
void getConfigurations(Vector<ResTable_config>* configs) const;
@@ -1546,18 +1657,21 @@
// Return value: on success: NO_ERROR; caller is responsible for free-ing
// outData (using free(3)). On failure, any status_t value other than
// NO_ERROR; the caller should not free outData.
- status_t createIdmap(const ResTable& overlay, uint32_t originalCrc, uint32_t overlayCrc,
- void** outData, size_t* outSize) const;
+ status_t createIdmap(const ResTable& overlay,
+ uint32_t targetCrc, uint32_t overlayCrc,
+ const char* targetPath, const char* overlayPath,
+ void** outData, size_t* outSize) const;
enum {
- IDMAP_HEADER_SIZE_BYTES = 3 * sizeof(uint32_t),
+ IDMAP_HEADER_SIZE_BYTES = 3 * sizeof(uint32_t) + 2 * 256,
};
// Retrieve idmap meta-data.
//
// This function only requires the idmap header (the first
// IDMAP_HEADER_SIZE_BYTES) bytes of an idmap file.
static bool getIdmapInfo(const void* idmap, size_t size,
- uint32_t* pOriginalCrc, uint32_t* pOverlayCrc);
+ uint32_t* pTargetCrc, uint32_t* pOverlayCrc,
+ String8* pTargetPath, String8* pOverlayPath);
void print(bool inclValues) const;
static String8 normalizeForOutput(const char* input);
@@ -1569,7 +1683,7 @@
struct PackageGroup;
struct bag_set;
- status_t add(const void* data, size_t size, void* cookie,
+ status_t addInternal(const void* data, size_t size, const int32_t cookie,
Asset* asset, bool copyData, const Asset* idmap);
ssize_t getResourcePackageIndex(uint32_t resID) const;
diff --git a/libs/androidfw/Asset.cpp b/libs/androidfw/Asset.cpp
index ce6cc38..589211f 100644
--- a/libs/androidfw/Asset.cpp
+++ b/libs/androidfw/Asset.cpp
@@ -72,7 +72,7 @@
}
cur = cur->mNext;
}
-
+
return res;
}
@@ -84,18 +84,18 @@
mNext = mPrev = NULL;
if (gTail == NULL) {
gHead = gTail = this;
- } else {
- mPrev = gTail;
- gTail->mNext = this;
- gTail = this;
- }
+ } else {
+ mPrev = gTail;
+ gTail->mNext = this;
+ gTail = this;
+ }
//ALOGI("Creating Asset %p #%d\n", this, gCount);
}
Asset::~Asset(void)
{
AutoMutex _l(gAssetLock);
- gCount--;
+ gCount--;
if (gHead == this) {
gHead = mNext;
}
@@ -409,7 +409,7 @@
}
mFileName = fileName != NULL ? strdup(fileName) : NULL;
-
+
return NO_ERROR;
}
@@ -538,7 +538,7 @@
free(mFileName);
mFileName = NULL;
}
-
+
if (mFp != NULL) {
// can only be NULL when called from destructor
// (otherwise we would never return this object)
diff --git a/libs/androidfw/AssetManager.cpp b/libs/androidfw/AssetManager.cpp
index 503c030..b4d482a 100644
--- a/libs/androidfw/AssetManager.cpp
+++ b/libs/androidfw/AssetManager.cpp
@@ -41,10 +41,8 @@
#include <assert.h>
#include <dirent.h>
#include <errno.h>
-#include <fcntl.h>
+#include <string.h> // strerror
#include <strings.h>
-#include <sys/stat.h>
-#include <unistd.h>
#ifndef TEMP_FAILURE_RETRY
/* Used to retry syscalls that can return EINTR. */
@@ -75,7 +73,7 @@
static const char* kAssetsRoot = "assets";
static const char* kAppZipName = NULL; //"classes.jar";
static const char* kSystemAssets = "framework/framework-res.apk";
-static const char* kIdmapCacheDir = "resource-cache";
+static const char* kResourceCache = "resource-cache";
static const char* kExcludeExtension = ".EXCLUDE";
@@ -83,14 +81,20 @@
static volatile int32_t gCount = 0;
+const char* AssetManager::RESOURCES_FILENAME = "resources.arsc";
+const char* AssetManager::IDMAP_BIN = "/system/bin/idmap";
+const char* AssetManager::OVERLAY_DIR = "/vendor/overlay";
+const char* AssetManager::TARGET_PACKAGE_NAME = "android";
+const char* AssetManager::TARGET_APK_PATH = "/system/framework/framework-res.apk";
+const char* AssetManager::IDMAP_DIR = "/data/resource-cache";
+
namespace {
- // Transform string /a/b/c.apk to /data/resource-cache/a@b@c.apk@idmap
String8 idmapPathForPackagePath(const String8& pkgPath)
{
const char* root = getenv("ANDROID_DATA");
LOG_ALWAYS_FATAL_IF(root == NULL, "ANDROID_DATA not set");
String8 path(root);
- path.appendPath(kIdmapCacheDir);
+ path.appendPath(kResourceCache);
char buf[256]; // 256 chars should be enough for anyone...
strncpy(buf, pkgPath.string(), 255);
@@ -165,7 +169,7 @@
delete[] mVendor;
}
-bool AssetManager::addAssetPath(const String8& path, void** cookie)
+bool AssetManager::addAssetPath(const String8& path, int32_t* cookie)
{
AutoMutex _l(mLock);
@@ -192,7 +196,7 @@
for (size_t i=0; i<mAssetPaths.size(); i++) {
if (mAssetPaths[i].path == ap.path) {
if (cookie) {
- *cookie = (void*)(i+1);
+ *cookie = static_cast<int32_t>(i+1);
}
return true;
}
@@ -205,183 +209,102 @@
// new paths are always added at the end
if (cookie) {
- *cookie = (void*)mAssetPaths.size();
+ *cookie = static_cast<int32_t>(mAssetPaths.size());
}
- // add overlay packages for /system/framework; apps are handled by the
- // (Java) package manager
- if (strncmp(path.string(), "/system/framework/", 18) == 0) {
- // When there is an environment variable for /vendor, this
- // should be changed to something similar to how ANDROID_ROOT
- // and ANDROID_DATA are used in this file.
- String8 overlayPath("/vendor/overlay/framework/");
- overlayPath.append(path.getPathLeaf());
- if (TEMP_FAILURE_RETRY(access(overlayPath.string(), R_OK)) == 0) {
- asset_path oap;
- oap.path = overlayPath;
- oap.type = ::getFileType(overlayPath.string());
- bool addOverlay = (oap.type == kFileTypeRegular); // only .apks supported as overlay
- if (addOverlay) {
- oap.idmap = idmapPathForPackagePath(overlayPath);
-
- if (isIdmapStaleLocked(ap.path, oap.path, oap.idmap)) {
- addOverlay = createIdmapFileLocked(ap.path, oap.path, oap.idmap);
- }
- }
- if (addOverlay) {
- mAssetPaths.add(oap);
- } else {
- ALOGW("failed to add overlay package %s\n", overlayPath.string());
- }
- }
+#ifdef HAVE_ANDROID_OS
+ // Load overlays, if any
+ asset_path oap;
+ for (size_t idx = 0; mZipSet.getOverlay(ap.path, idx, &oap); idx++) {
+ mAssetPaths.add(oap);
}
+#endif
return true;
}
-bool AssetManager::isIdmapStaleLocked(const String8& originalPath, const String8& overlayPath,
- const String8& idmapPath)
+bool AssetManager::addOverlayPath(const String8& packagePath, int32_t* cookie)
{
- struct stat st;
- if (TEMP_FAILURE_RETRY(stat(idmapPath.string(), &st)) == -1) {
- if (errno == ENOENT) {
- return true; // non-existing idmap is always stale
- } else {
- ALOGW("failed to stat file %s: %s\n", idmapPath.string(), strerror(errno));
- return false;
- }
- }
- if (st.st_size < ResTable::IDMAP_HEADER_SIZE_BYTES) {
- ALOGW("file %s has unexpectedly small size=%zd\n", idmapPath.string(), (size_t)st.st_size);
- return false;
- }
- int fd = TEMP_FAILURE_RETRY(::open(idmapPath.string(), O_RDONLY));
- if (fd == -1) {
- ALOGW("failed to open file %s: %s\n", idmapPath.string(), strerror(errno));
- return false;
- }
- char buf[ResTable::IDMAP_HEADER_SIZE_BYTES];
- ssize_t bytesLeft = ResTable::IDMAP_HEADER_SIZE_BYTES;
- for (;;) {
- ssize_t r = TEMP_FAILURE_RETRY(read(fd, buf + ResTable::IDMAP_HEADER_SIZE_BYTES - bytesLeft,
- bytesLeft));
- if (r < 0) {
- TEMP_FAILURE_RETRY(close(fd));
- return false;
- }
- bytesLeft -= r;
- if (bytesLeft == 0) {
- break;
- }
- }
- TEMP_FAILURE_RETRY(close(fd));
+ const String8 idmapPath = idmapPathForPackagePath(packagePath);
- uint32_t cachedOriginalCrc, cachedOverlayCrc;
- if (!ResTable::getIdmapInfo(buf, ResTable::IDMAP_HEADER_SIZE_BYTES,
- &cachedOriginalCrc, &cachedOverlayCrc)) {
+ AutoMutex _l(mLock);
+
+ for (size_t i = 0; i < mAssetPaths.size(); ++i) {
+ if (mAssetPaths[i].idmap == idmapPath) {
+ *cookie = static_cast<int32_t>(i + 1);
+ return true;
+ }
+ }
+
+ Asset* idmap = NULL;
+ if ((idmap = openAssetFromFileLocked(idmapPath, Asset::ACCESS_BUFFER)) == NULL) {
+ ALOGW("failed to open idmap file %s\n", idmapPath.string());
return false;
}
- uint32_t actualOriginalCrc, actualOverlayCrc;
- if (!getZipEntryCrcLocked(originalPath, "resources.arsc", &actualOriginalCrc)) {
+ String8 targetPath;
+ String8 overlayPath;
+ if (!ResTable::getIdmapInfo(idmap->getBuffer(false), idmap->getLength(),
+ NULL, NULL, &targetPath, &overlayPath)) {
+ ALOGW("failed to read idmap file %s\n", idmapPath.string());
+ delete idmap;
return false;
}
- if (!getZipEntryCrcLocked(overlayPath, "resources.arsc", &actualOverlayCrc)) {
- return false;
- }
- return cachedOriginalCrc != actualOriginalCrc || cachedOverlayCrc != actualOverlayCrc;
-}
+ delete idmap;
-bool AssetManager::getZipEntryCrcLocked(const String8& zipPath, const char* entryFilename,
- uint32_t* pCrc)
+ if (overlayPath != packagePath) {
+ ALOGW("idmap file %s inconcistent: expected path %s does not match actual path %s\n",
+ idmapPath.string(), packagePath.string(), overlayPath.string());
+ return false;
+ }
+ if (access(targetPath.string(), R_OK) != 0) {
+ ALOGW("failed to access file %s: %s\n", targetPath.string(), strerror(errno));
+ return false;
+ }
+ if (access(idmapPath.string(), R_OK) != 0) {
+ ALOGW("failed to access file %s: %s\n", idmapPath.string(), strerror(errno));
+ return false;
+ }
+ if (access(overlayPath.string(), R_OK) != 0) {
+ ALOGW("failed to access file %s: %s\n", overlayPath.string(), strerror(errno));
+ return false;
+ }
+
+ asset_path oap;
+ oap.path = overlayPath;
+ oap.type = ::getFileType(overlayPath.string());
+ oap.idmap = idmapPath;
+#if 0
+ ALOGD("Overlay added: targetPath=%s overlayPath=%s idmapPath=%s\n",
+ targetPath.string(), overlayPath.string(), idmapPath.string());
+#endif
+ mAssetPaths.add(oap);
+ *cookie = static_cast<int32_t>(mAssetPaths.size());
+
+ return true;
+ }
+
+bool AssetManager::createIdmap(const char* targetApkPath, const char* overlayApkPath,
+ uint32_t targetCrc, uint32_t overlayCrc, uint32_t** outData, size_t* outSize)
{
- asset_path ap;
- ap.path = zipPath;
- const ZipFileRO* zip = getZipFileLocked(ap);
- if (zip == NULL) {
- return false;
- }
- const ZipEntryRO entry = zip->findEntryByName(entryFilename);
- if (entry == NULL) {
- return false;
- }
-
- const bool gotInfo = zip->getEntryInfo(entry, NULL, NULL, NULL, NULL, NULL, (long*)pCrc);
- zip->releaseEntry(entry);
-
- return gotInfo;
-}
-
-bool AssetManager::createIdmapFileLocked(const String8& originalPath, const String8& overlayPath,
- const String8& idmapPath)
-{
- ALOGD("%s: originalPath=%s overlayPath=%s idmapPath=%s\n",
- __FUNCTION__, originalPath.string(), overlayPath.string(), idmapPath.string());
+ AutoMutex _l(mLock);
+ const String8 paths[2] = { String8(targetApkPath), String8(overlayApkPath) };
ResTable tables[2];
- const String8* paths[2] = { &originalPath, &overlayPath };
- uint32_t originalCrc, overlayCrc;
- bool retval = false;
- ssize_t offset = 0;
- int fd = 0;
- uint32_t* data = NULL;
- size_t size;
for (int i = 0; i < 2; ++i) {
asset_path ap;
ap.type = kFileTypeRegular;
- ap.path = *paths[i];
+ ap.path = paths[i];
Asset* ass = openNonAssetInPathLocked("resources.arsc", Asset::ACCESS_BUFFER, ap);
if (ass == NULL) {
ALOGW("failed to find resources.arsc in %s\n", ap.path.string());
- goto error;
+ return false;
}
- tables[i].add(ass, (void*)1, false);
+ tables[i].add(ass, 1, false /* copyData */, NULL /* idMap */);
}
- if (!getZipEntryCrcLocked(originalPath, "resources.arsc", &originalCrc)) {
- ALOGW("failed to retrieve crc for resources.arsc in %s\n", originalPath.string());
- goto error;
- }
- if (!getZipEntryCrcLocked(overlayPath, "resources.arsc", &overlayCrc)) {
- ALOGW("failed to retrieve crc for resources.arsc in %s\n", overlayPath.string());
- goto error;
- }
-
- if (tables[0].createIdmap(tables[1], originalCrc, overlayCrc,
- (void**)&data, &size) != NO_ERROR) {
- ALOGW("failed to generate idmap data for file %s\n", idmapPath.string());
- goto error;
- }
-
- // This should be abstracted (eg replaced by a stand-alone
- // application like dexopt, triggered by something equivalent to
- // installd).
- fd = TEMP_FAILURE_RETRY(::open(idmapPath.string(), O_WRONLY | O_CREAT | O_TRUNC, 0644));
- if (fd == -1) {
- ALOGW("failed to write idmap file %s (open: %s)\n", idmapPath.string(), strerror(errno));
- goto error_free;
- }
- for (;;) {
- ssize_t written = TEMP_FAILURE_RETRY(write(fd, data + offset, size));
- if (written < 0) {
- ALOGW("failed to write idmap file %s (write: %s)\n", idmapPath.string(),
- strerror(errno));
- goto error_close;
- }
- size -= (size_t)written;
- offset += written;
- if (size == 0) {
- break;
- }
- }
-
- retval = true;
-error_close:
- TEMP_FAILURE_RETRY(close(fd));
-error_free:
- free(data);
-error:
- return retval;
+ return tables[0].createIdmap(tables[1], targetCrc, overlayCrc,
+ targetApkPath, overlayApkPath, (void**)outData, outSize) == NO_ERROR;
}
bool AssetManager::addDefaultAssets()
@@ -395,17 +318,17 @@
return addAssetPath(path, NULL);
}
-void* AssetManager::nextAssetPath(void* cookie) const
+int32_t AssetManager::nextAssetPath(const int32_t cookie) const
{
AutoMutex _l(mLock);
- size_t next = ((size_t)cookie)+1;
- return next > mAssetPaths.size() ? NULL : (void*)next;
+ const size_t next = static_cast<size_t>(cookie) + 1;
+ return next > mAssetPaths.size() ? -1 : next;
}
-String8 AssetManager::getAssetPath(void* cookie) const
+String8 AssetManager::getAssetPath(const int32_t cookie) const
{
AutoMutex _l(mLock);
- const size_t which = ((size_t)cookie)-1;
+ const size_t which = static_cast<size_t>(cookie) - 1;
if (which < mAssetPaths.size()) {
return mAssetPaths[which].path;
}
@@ -463,17 +386,8 @@
if (locale) {
setLocaleLocked(locale);
} else if (config.language[0] != 0) {
- char spec[9];
- spec[0] = config.language[0];
- spec[1] = config.language[1];
- if (config.country[0] != 0) {
- spec[2] = '_';
- spec[3] = config.country[0];
- spec[4] = config.country[1];
- spec[5] = 0;
- } else {
- spec[3] = 0;
- }
+ char spec[RESTABLE_MAX_LOCALE_LEN];
+ config.getBcp47Locale(spec);
setLocaleLocked(spec);
} else {
updateResourceParamsLocked();
@@ -575,15 +489,14 @@
return NULL;
}
-Asset* AssetManager::openNonAsset(void* cookie, const char* fileName, AccessMode mode)
+Asset* AssetManager::openNonAsset(const int32_t cookie, const char* fileName, AccessMode mode)
{
- const size_t which = ((size_t)cookie)-1;
+ const size_t which = static_cast<size_t>(cookie) - 1;
AutoMutex _l(mLock);
LOG_FATAL_IF(mAssetPaths.size() == 0, "No assets added to AssetManager");
-
if (mCacheMode != CACHE_OFF && !mCacheValid)
loadFileNameCacheLocked();
@@ -661,6 +574,10 @@
// which we want to avoid parsing every time.
sharedRes = const_cast<AssetManager*>(this)->
mZipSet.getZipResourceTable(ap.path);
+ if (sharedRes != NULL) {
+ // skip ahead the number of system overlay packages preloaded
+ i += sharedRes->getTableCount() - 1;
+ }
}
if (sharedRes == NULL) {
ass = const_cast<AssetManager*>(this)->
@@ -683,7 +600,15 @@
// can quickly copy it out for others.
ALOGV("Creating shared resources for %s", ap.path.string());
sharedRes = new ResTable();
- sharedRes->add(ass, (void*)(i+1), false, idmap);
+ sharedRes->add(ass, i + 1, false, idmap);
+#ifdef HAVE_ANDROID_OS
+ const char* data = getenv("ANDROID_DATA");
+ LOG_ALWAYS_FATAL_IF(data == NULL, "ANDROID_DATA not set");
+ String8 overlaysListPath(data);
+ overlaysListPath.appendPath(kResourceCache);
+ overlaysListPath.appendPath("overlays.list");
+ addSystemOverlays(overlaysListPath.string(), ap.path, sharedRes, i);
+#endif
sharedRes = const_cast<AssetManager*>(this)->
mZipSet.setZipResourceTable(ap.path, sharedRes);
}
@@ -707,7 +632,7 @@
rt->add(sharedRes);
} else {
ALOGV("Parsing resources for %s", ap.path.string());
- rt->add(ass, (void*)(i+1), !shared, idmap);
+ rt->add(ass, i + 1, !shared, idmap);
}
if (!shared) {
@@ -734,20 +659,11 @@
return;
}
- size_t llen = mLocale ? strlen(mLocale) : 0;
- mConfig->language[0] = 0;
- mConfig->language[1] = 0;
- mConfig->country[0] = 0;
- mConfig->country[1] = 0;
- if (llen >= 2) {
- mConfig->language[0] = mLocale[0];
- mConfig->language[1] = mLocale[1];
+ if (mLocale) {
+ mConfig->setBcp47Locale(mLocale);
+ } else {
+ mConfig->clearLocale();
}
- if (llen >= 5) {
- mConfig->country[0] = mLocale[3];
- mConfig->country[1] = mLocale[4];
- }
- mConfig->size = sizeof(*mConfig);
res->setParameters(mConfig);
}
@@ -767,6 +683,46 @@
return ass;
}
+void AssetManager::addSystemOverlays(const char* pathOverlaysList,
+ const String8& targetPackagePath, ResTable* sharedRes, size_t offset) const
+{
+ FILE* fin = fopen(pathOverlaysList, "r");
+ if (fin == NULL) {
+ return;
+ }
+
+ char buf[1024];
+ while (fgets(buf, sizeof(buf), fin)) {
+ // format of each line:
+ // <path to apk><space><path to idmap><newline>
+ char* space = strchr(buf, ' ');
+ char* newline = strchr(buf, '\n');
+ asset_path oap;
+
+ if (space == NULL || newline == NULL || newline < space) {
+ continue;
+ }
+
+ oap.path = String8(buf, space - buf);
+ oap.type = kFileTypeRegular;
+ oap.idmap = String8(space + 1, newline - space - 1);
+
+ Asset* oass = const_cast<AssetManager*>(this)->
+ openNonAssetInPathLocked("resources.arsc",
+ Asset::ACCESS_BUFFER,
+ oap);
+
+ if (oass != NULL) {
+ Asset* oidmap = openIdmapLocked(oap);
+ offset++;
+ sharedRes->add(oass, offset + 1, false, oidmap);
+ const_cast<AssetManager*>(this)->mAssetPaths.add(oap);
+ const_cast<AssetManager*>(this)->mZipSet.addOverlay(targetPackagePath, oap);
+ }
+ }
+ fclose(fin);
+}
+
const ResTable& AssetManager::getResources(bool required) const
{
const ResTable* rt = getResTable(required);
@@ -1206,7 +1162,7 @@
*
* Pass in "" for the root dir.
*/
-AssetDir* AssetManager::openNonAssetDir(void* cookie, const char* dirName)
+AssetDir* AssetManager::openNonAssetDir(const int32_t cookie, const char* dirName)
{
AutoMutex _l(mLock);
@@ -1225,7 +1181,7 @@
pMergedInfo = new SortedVector<AssetDir::FileInfo>;
- const size_t which = ((size_t)cookie)-1;
+ const size_t which = static_cast<size_t>(cookie) - 1;
if (which < mAssetPaths.size()) {
const asset_path& ap = mAssetPaths.itemAt(which);
@@ -1825,7 +1781,8 @@
}
}
-sp<AssetManager::SharedZip> AssetManager::SharedZip::get(const String8& path)
+sp<AssetManager::SharedZip> AssetManager::SharedZip::get(const String8& path,
+ bool createIfNotPresent)
{
AutoMutex _l(gLock);
time_t modWhen = getFileModDate(path);
@@ -1833,6 +1790,9 @@
if (zip != NULL && zip->mModWhen == modWhen) {
return zip;
}
+ if (zip == NULL && !createIfNotPresent) {
+ return NULL;
+ }
zip = new SharedZip(path, modWhen);
gOpen.add(path, zip);
return zip;
@@ -1891,6 +1851,20 @@
return mModWhen == modWhen;
}
+void AssetManager::SharedZip::addOverlay(const asset_path& ap)
+{
+ mOverlays.add(ap);
+}
+
+bool AssetManager::SharedZip::getOverlay(size_t idx, asset_path* out) const
+{
+ if (idx >= mOverlays.size()) {
+ return false;
+ }
+ *out = mOverlays[idx];
+ return true;
+}
+
AssetManager::SharedZip::~SharedZip()
{
//ALOGI("Destroying SharedZip %p %s\n", this, (const char*)mPath);
@@ -2014,6 +1988,22 @@
return true;
}
+void AssetManager::ZipSet::addOverlay(const String8& path, const asset_path& overlay)
+{
+ int idx = getIndex(path);
+ sp<SharedZip> zip = mZipFile[idx];
+ zip->addOverlay(overlay);
+}
+
+bool AssetManager::ZipSet::getOverlay(const String8& path, size_t idx, asset_path* out) const
+{
+ sp<SharedZip> zip = SharedZip::get(path, false);
+ if (zip == NULL) {
+ return false;
+ }
+ return zip->getOverlay(idx, out);
+}
+
/*
* Compute the zip file's index.
*
diff --git a/libs/androidfw/BackupData.cpp b/libs/androidfw/BackupData.cpp
index 4e3b522..bd9dc76 100644
--- a/libs/androidfw/BackupData.cpp
+++ b/libs/androidfw/BackupData.cpp
@@ -78,7 +78,7 @@
paddingSize = padding_extra(n);
if (paddingSize > 0) {
uint32_t padding = 0xbcbcbcbc;
- if (DEBUG) ALOGI("writing %d padding bytes for %d", paddingSize, n);
+ if (DEBUG) ALOGI("writing %zd padding bytes for %d", paddingSize, n);
amt = write(m_fd, &padding, paddingSize);
if (amt != paddingSize) {
m_status = errno;
@@ -112,7 +112,7 @@
k = key;
}
if (DEBUG) {
- ALOGD("Writing header: prefix='%s' key='%s' dataSize=%d", m_keyPrefix.string(),
+ ALOGD("Writing header: prefix='%s' key='%s' dataSize=%zu", m_keyPrefix.string(),
key.string(), dataSize);
}
@@ -125,7 +125,7 @@
header.keyLen = tolel(keyLen);
header.dataSize = tolel(dataSize);
- if (DEBUG) ALOGI("writing entity header, %d bytes", sizeof(entity_header_v1));
+ if (DEBUG) ALOGI("writing entity header, %zu bytes", sizeof(entity_header_v1));
amt = write(m_fd, &header, sizeof(entity_header_v1));
if (amt != sizeof(entity_header_v1)) {
m_status = errno;
@@ -133,7 +133,7 @@
}
m_pos += amt;
- if (DEBUG) ALOGI("writing entity header key, %d bytes", keyLen+1);
+ if (DEBUG) ALOGI("writing entity header key, %zd bytes", keyLen+1);
amt = write(m_fd, k.string(), keyLen+1);
if (amt != keyLen+1) {
m_status = errno;
@@ -289,7 +289,7 @@
(int)(m_pos - sizeof(m_header)), (int)m_header.type);
m_status = EINVAL;
}
-
+
return m_status;
}
diff --git a/libs/androidfw/BackupHelpers.cpp b/libs/androidfw/BackupHelpers.cpp
index b8d3f48..52dce9f 100644
--- a/libs/androidfw/BackupHelpers.cpp
+++ b/libs/androidfw/BackupHelpers.cpp
@@ -568,8 +568,8 @@
// [ 108 : 8 ] uid -- ignored in Android format; uids are remapped at restore time
// [ 116 : 8 ] gid -- ignored in Android format
- snprintf(buf + 108, 8, "0%lo", s.st_uid);
- snprintf(buf + 116, 8, "0%lo", s.st_gid);
+ snprintf(buf + 108, 8, "0%lo", (unsigned long)s.st_uid);
+ snprintf(buf + 116, 8, "0%lo", (unsigned long)s.st_gid);
// [ 124 : 12 ] file size in bytes
if (s.st_size > 077777777777LL) {
@@ -639,7 +639,7 @@
// size header -- calc len in digits by actually rendering the number
// to a string - brute force but simple
- snprintf(sizeStr, sizeof(sizeStr), "%lld", s.st_size);
+ snprintf(sizeStr, sizeof(sizeStr), "%lld", (long long)s.st_size);
p += write_pax_header_entry(p, "size", sizeStr);
// fullname was generated above with the ustar paths
@@ -661,7 +661,7 @@
// [ 124 : 12 ] size of pax extended header data
memset(paxHeader + 124, 0, 12);
- snprintf(paxHeader + 124, 12, "%011o", p - paxData);
+ snprintf(paxHeader + 124, 12, "%011o", (unsigned int)(p - paxData));
// Checksum and write the pax block header
calc_tar_checksum(paxHeader);
@@ -681,7 +681,10 @@
if (!isdir) {
off64_t toWrite = s.st_size;
while (toWrite > 0) {
- size_t toRead = (toWrite < BUFSIZE) ? toWrite : BUFSIZE;
+ size_t toRead = toWrite;
+ if (toRead > BUFSIZE) {
+ toRead = BUFSIZE;
+ }
ssize_t nRead = read(fd, buf, toRead);
if (nRead < 0) {
err = errno;
@@ -778,7 +781,7 @@
ALOGW("Could not open file %s -- %s", filename.string(), strerror(errno));
return errno;
}
-
+
while ((amt = in->ReadEntityData(buf, RESTORE_BUF_SIZE)) > 0) {
err = write(fd, buf, amt);
if (err != amt) {
@@ -1083,7 +1086,7 @@
}
if (readSnapshot.size() != 4) {
- fprintf(stderr, "readSnapshot should be length 4 is %d\n", readSnapshot.size());
+ fprintf(stderr, "readSnapshot should be length 4 is %zu\n", readSnapshot.size());
return 1;
}
@@ -1095,8 +1098,8 @@
if (name != filenames[i] || states[i].modTime_sec != state.modTime_sec
|| states[i].modTime_nsec != state.modTime_nsec || states[i].mode != state.mode
|| states[i].size != state.size || states[i].crc32 != states[i].crc32) {
- fprintf(stderr, "state %d expected={%d/%d, 0x%08x, %04o, 0x%08x, %3d} '%s'\n"
- " actual={%d/%d, 0x%08x, %04o, 0x%08x, %3d} '%s'\n", i,
+ fprintf(stderr, "state %zu expected={%d/%d, %04o, 0x%08x, 0x%08x, %3zu} '%s'\n"
+ " actual={%d/%d, %04o, 0x%08x, 0x%08x, %3d} '%s'\n", i,
states[i].modTime_sec, states[i].modTime_nsec, states[i].mode, states[i].size,
states[i].crc32, name.length(), filenames[i].string(),
state.modTime_sec, state.modTime_nsec, state.mode, state.size, state.crc32,
@@ -1194,7 +1197,7 @@
test_read_header_and_entity(BackupDataReader& reader, const char* str)
{
int err;
- int bufSize = strlen(str)+1;
+ size_t bufSize = strlen(str)+1;
char* buf = (char*)malloc(bufSize);
String8 string;
int cookie = 0x11111111;
@@ -1229,9 +1232,9 @@
err = EINVAL;
goto finished;
}
- if ((int)actualSize != bufSize) {
- fprintf(stderr, "ReadEntityHeader expected dataSize 0x%08x got 0x%08x\n", bufSize,
- actualSize);
+ if (actualSize != bufSize) {
+ fprintf(stderr, "ReadEntityHeader expected dataSize %zu got %zu\n",
+ bufSize, actualSize);
err = EINVAL;
goto finished;
}
diff --git a/libs/androidfw/CursorWindow.cpp b/libs/androidfw/CursorWindow.cpp
index 0f54edb..166863c 100644
--- a/libs/androidfw/CursorWindow.cpp
+++ b/libs/androidfw/CursorWindow.cpp
@@ -1,16 +1,16 @@
/*
* Copyright (C) 2006-2007 The Android Open Source Project
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * 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
+ * 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
+ * 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.
*/
@@ -210,8 +210,8 @@
uint32_t offset = mHeader->freeOffset + padding;
uint32_t nextFreeOffset = offset + size;
if (nextFreeOffset > mSize) {
- ALOGW("Window is full: requested allocation %d bytes, "
- "free space %d bytes, window size %d bytes",
+ ALOGW("Window is full: requested allocation %zu bytes, "
+ "free space %zu bytes, window size %zu bytes",
size, freeSpace(), mSize);
return 0;
}
diff --git a/libs/androidfw/ResourceTypes.cpp b/libs/androidfw/ResourceTypes.cpp
index 1cc3563..1ffe665 100644
--- a/libs/androidfw/ResourceTypes.cpp
+++ b/libs/androidfw/ResourceTypes.cpp
@@ -66,11 +66,6 @@
// size measured in sizeof(uint32_t)
#define IDMAP_HEADER_SIZE (ResTable::IDMAP_HEADER_SIZE_BYTES / sizeof(uint32_t))
-static void printToLogFunc(void* cookie, const char* txt)
-{
- ALOGV("%s", txt);
-}
-
// Standard C isspace() is only required to look at the low byte of its input, so
// produces incorrect results for UTF-16 characters. For safety's sake, assume that
// any high-byte UTF-16 code point is not whitespace.
@@ -106,24 +101,29 @@
if ((ssize_t)size <= (dataEnd-((const uint8_t*)chunk))) {
return NO_ERROR;
}
- ALOGW("%s data size %p extends beyond resource end %p.",
- name, (void*)size,
- (void*)(dataEnd-((const uint8_t*)chunk)));
+ ALOGW("%s data size 0x%x extends beyond resource end %p.",
+ name, size, (void*)(dataEnd-((const uint8_t*)chunk)));
return BAD_TYPE;
}
ALOGW("%s size 0x%x or headerSize 0x%x is not on an integer boundary.",
name, (int)size, (int)headerSize);
return BAD_TYPE;
}
- ALOGW("%s size %p is smaller than header size %p.",
- name, (void*)size, (void*)(int)headerSize);
+ ALOGW("%s size 0x%x is smaller than header size 0x%x.",
+ name, size, headerSize);
return BAD_TYPE;
}
- ALOGW("%s header size %p is too small.",
- name, (void*)(int)headerSize);
+ ALOGW("%s header size 0x%x is too small.",
+ name, headerSize);
return BAD_TYPE;
}
+static void fill9patchOffsets(Res_png_9patch* patch) {
+ patch->xDivsOffset = sizeof(Res_png_9patch);
+ patch->yDivsOffset = patch->xDivsOffset + (patch->numXDivs * sizeof(int32_t));
+ patch->colorsOffset = patch->yDivsOffset + (patch->numYDivs * sizeof(int32_t));
+}
+
inline void Res_value::copyFrom_dtoh(const Res_value& src)
{
size = dtohs(src.size);
@@ -134,9 +134,11 @@
void Res_png_9patch::deviceToFile()
{
+ int32_t* xDivs = getXDivs();
for (int i = 0; i < numXDivs; i++) {
xDivs[i] = htonl(xDivs[i]);
}
+ int32_t* yDivs = getYDivs();
for (int i = 0; i < numYDivs; i++) {
yDivs[i] = htonl(yDivs[i]);
}
@@ -144,6 +146,7 @@
paddingRight = htonl(paddingRight);
paddingTop = htonl(paddingTop);
paddingBottom = htonl(paddingBottom);
+ uint32_t* colors = getColors();
for (int i=0; i<numColors; i++) {
colors[i] = htonl(colors[i]);
}
@@ -151,9 +154,11 @@
void Res_png_9patch::fileToDevice()
{
+ int32_t* xDivs = getXDivs();
for (int i = 0; i < numXDivs; i++) {
xDivs[i] = ntohl(xDivs[i]);
}
+ int32_t* yDivs = getYDivs();
for (int i = 0; i < numYDivs; i++) {
yDivs[i] = ntohl(yDivs[i]);
}
@@ -161,60 +166,49 @@
paddingRight = ntohl(paddingRight);
paddingTop = ntohl(paddingTop);
paddingBottom = ntohl(paddingBottom);
+ uint32_t* colors = getColors();
for (int i=0; i<numColors; i++) {
colors[i] = ntohl(colors[i]);
}
}
-size_t Res_png_9patch::serializedSize()
+size_t Res_png_9patch::serializedSize() const
{
// The size of this struct is 32 bytes on the 32-bit target system
// 4 * int8_t
// 4 * int32_t
- // 3 * pointer
+ // 3 * uint32_t
return 32
+ numXDivs * sizeof(int32_t)
+ numYDivs * sizeof(int32_t)
+ numColors * sizeof(uint32_t);
}
-void* Res_png_9patch::serialize()
+void* Res_png_9patch::serialize(const Res_png_9patch& patch, const int32_t* xDivs,
+ const int32_t* yDivs, const uint32_t* colors)
{
// Use calloc since we're going to leave a few holes in the data
// and want this to run cleanly under valgrind
- void* newData = calloc(1, serializedSize());
- serialize(newData);
+ void* newData = calloc(1, patch.serializedSize());
+ serialize(patch, xDivs, yDivs, colors, newData);
return newData;
}
-void Res_png_9patch::serialize(void * outData)
+void Res_png_9patch::serialize(const Res_png_9patch& patch, const int32_t* xDivs,
+ const int32_t* yDivs, const uint32_t* colors, void* outData)
{
- char* data = (char*) outData;
- memmove(data, &wasDeserialized, 4); // copy wasDeserialized, numXDivs, numYDivs, numColors
- memmove(data + 12, &paddingLeft, 16); // copy paddingXXXX
+ uint8_t* data = (uint8_t*) outData;
+ memcpy(data, &patch.wasDeserialized, 4); // copy wasDeserialized, numXDivs, numYDivs, numColors
+ memcpy(data + 12, &patch.paddingLeft, 16); // copy paddingXXXX
data += 32;
- memmove(data, this->xDivs, numXDivs * sizeof(int32_t));
- data += numXDivs * sizeof(int32_t);
- memmove(data, this->yDivs, numYDivs * sizeof(int32_t));
- data += numYDivs * sizeof(int32_t);
- memmove(data, this->colors, numColors * sizeof(uint32_t));
-}
+ memcpy(data, xDivs, patch.numXDivs * sizeof(int32_t));
+ data += patch.numXDivs * sizeof(int32_t);
+ memcpy(data, yDivs, patch.numYDivs * sizeof(int32_t));
+ data += patch.numYDivs * sizeof(int32_t);
+ memcpy(data, colors, patch.numColors * sizeof(uint32_t));
-static void deserializeInternal(const void* inData, Res_png_9patch* outData) {
- char* patch = (char*) inData;
- if (inData != outData) {
- memmove(&outData->wasDeserialized, patch, 4); // copy wasDeserialized, numXDivs, numYDivs, numColors
- memmove(&outData->paddingLeft, patch + 12, 4); // copy wasDeserialized, numXDivs, numYDivs, numColors
- }
- outData->wasDeserialized = true;
- char* data = (char*)outData;
- data += sizeof(Res_png_9patch);
- outData->xDivs = (int32_t*) data;
- data += outData->numXDivs * sizeof(int32_t);
- outData->yDivs = (int32_t*) data;
- data += outData->numYDivs * sizeof(int32_t);
- outData->colors = (uint32_t*) data;
+ fill9patchOffsets(reinterpret_cast<Res_png_9patch*>(outData));
}
static bool assertIdmapHeader(const uint32_t* map, size_t sizeBytes)
@@ -284,22 +278,48 @@
if (!assertIdmapHeader(map, mapSize)) {
return UNKNOWN_ERROR;
}
+ if (mapSize <= IDMAP_HEADER_SIZE + 1) {
+ ALOGW("corrupt idmap: map size %d too short\n", mapSize);
+ return UNKNOWN_ERROR;
+ }
+ uint32_t typeCount = *(map + IDMAP_HEADER_SIZE);
+ if (typeCount == 0) {
+ ALOGW("corrupt idmap: no types\n");
+ return UNKNOWN_ERROR;
+ }
+ if (IDMAP_HEADER_SIZE + 1 + typeCount > mapSize) {
+ ALOGW("corrupt idmap: number of types %d extends past idmap size %d\n", typeCount, mapSize);
+ return UNKNOWN_ERROR;
+ }
const uint32_t* p = map + IDMAP_HEADER_SIZE + 1;
+ // find first defined type
while (*p == 0) {
++p;
+ if (--typeCount == 0) {
+ ALOGW("corrupt idmap: types declared, none found\n");
+ return UNKNOWN_ERROR;
+ }
}
- *outId = (map[*p + IDMAP_HEADER_SIZE + 2] >> 24) & 0x000000ff;
+
+ // determine package id from first entry of first type
+ const uint32_t offset = *p + IDMAP_HEADER_SIZE + 2;
+ if (offset > mapSize) {
+ ALOGW("corrupt idmap: entry offset %d points outside map size %d\n", offset, mapSize);
+ return UNKNOWN_ERROR;
+ }
+ *outId = (map[offset] >> 24) & 0x000000ff;
+
return NO_ERROR;
}
-Res_png_9patch* Res_png_9patch::deserialize(const void* inData)
+Res_png_9patch* Res_png_9patch::deserialize(void* inData)
{
- if (sizeof(void*) != sizeof(int32_t)) {
- ALOGE("Cannot deserialize on non 32-bit system\n");
- return NULL;
- }
- deserializeInternal(inData, (Res_png_9patch*) inData);
- return (Res_png_9patch*) inData;
+
+ Res_png_9patch* patch = reinterpret_cast<Res_png_9patch*>(inData);
+ patch->wasDeserialized = true;
+ fill9patchOffsets(patch);
+
+ return patch;
}
// --------------------------------------------------------------------
@@ -1246,7 +1266,7 @@
const ResXMLTree_node* next = (const ResXMLTree_node*)
(((const uint8_t*)mCurNode) + dtohl(mCurNode->header.size));
//ALOGW("Next node: prev=%p, next=%p\n", mCurNode, next);
-
+
if (((const uint8_t*)next) >= mTree.mDataEnd) {
mCurNode = NULL;
return (mEventCode=END_DOCUMENT);
@@ -1283,7 +1303,7 @@
(int)(((const uint8_t*)next)-((const uint8_t*)mTree.mHeader)));
continue;
}
-
+
if ((totalSize-headerSize) < minExtSize) {
ALOGW("Bad XML block: header type 0x%x in node at 0x%x has size %d, need %d\n",
(int)dtohs(next->header.type),
@@ -1291,10 +1311,10 @@
(int)(totalSize-headerSize), (int)minExtSize);
return (mEventCode=BAD_DOCUMENT);
}
-
+
//printf("CurNode=%p, CurExt=%p, headerSize=%d, minExtSize=%d\n",
// mCurNode, mCurExt, headerSize, minExtSize);
-
+
return eventCode;
} while (true);
}
@@ -1539,6 +1559,71 @@
}
}
+/* static */ size_t unpackLanguageOrRegion(const char in[2], const char base,
+ char out[4]) {
+ if (in[0] & 0x80) {
+ // The high bit is "1", which means this is a packed three letter
+ // language code.
+
+ // The smallest 5 bits of the second char are the first alphabet.
+ const uint8_t first = in[1] & 0x1f;
+ // The last three bits of the second char and the first two bits
+ // of the first char are the second alphabet.
+ const uint8_t second = ((in[1] & 0xe0) >> 5) + ((in[0] & 0x03) << 3);
+ // Bits 3 to 7 (inclusive) of the first char are the third alphabet.
+ const uint8_t third = (in[0] & 0x7c) >> 2;
+
+ out[0] = first + base;
+ out[1] = second + base;
+ out[2] = third + base;
+ out[3] = 0;
+
+ return 3;
+ }
+
+ if (in[0]) {
+ memcpy(out, in, 2);
+ memset(out + 2, 0, 2);
+ return 2;
+ }
+
+ memset(out, 0, 4);
+ return 0;
+}
+
+/* static */ void packLanguageOrRegion(const char* in, const char base,
+ char out[2]) {
+ if (in[2] == 0 || in[2] == '-') {
+ out[0] = in[0];
+ out[1] = in[1];
+ } else {
+ uint8_t first = (in[0] - base) & 0x00ef;
+ uint8_t second = (in[1] - base) & 0x00ef;
+ uint8_t third = (in[2] - base) & 0x00ef;
+
+ out[0] = (0x80 | (third << 2) | (second >> 3));
+ out[1] = ((second << 5) | first);
+ }
+}
+
+
+void ResTable_config::packLanguage(const char* language) {
+ packLanguageOrRegion(language, 'a', this->language);
+}
+
+void ResTable_config::packRegion(const char* region) {
+ packLanguageOrRegion(region, '0', this->country);
+}
+
+size_t ResTable_config::unpackLanguage(char language[4]) const {
+ return unpackLanguageOrRegion(this->language, 'a', language);
+}
+
+size_t ResTable_config::unpackRegion(char region[4]) const {
+ return unpackLanguageOrRegion(this->country, '0', region);
+}
+
+
void ResTable_config::copyFromDtoH(const ResTable_config& o) {
copyFromDeviceNoSwap(o);
size = sizeof(ResTable_config);
@@ -1568,10 +1653,30 @@
screenHeightDp = htods(screenHeightDp);
}
+/* static */ inline int compareLocales(const ResTable_config &l, const ResTable_config &r) {
+ if (l.locale != r.locale) {
+ // NOTE: This is the old behaviour with respect to comparison orders.
+ // The diff value here doesn't make much sense (given our bit packing scheme)
+ // but it's stable, and that's all we need.
+ return l.locale - r.locale;
+ }
+
+ // The language & region are equal, so compare the scripts and variants.
+ int script = memcmp(l.localeScript, r.localeScript, sizeof(l.localeScript));
+ if (script) {
+ return script;
+ }
+
+ // The language, region and script are equal, so compare variants.
+ //
+ // This should happen very infrequently (if at all.)
+ return memcmp(l.localeVariant, r.localeVariant, sizeof(l.localeVariant));
+}
+
int ResTable_config::compare(const ResTable_config& o) const {
int32_t diff = (int32_t)(imsi - o.imsi);
if (diff != 0) return diff;
- diff = (int32_t)(locale - o.locale);
+ diff = compareLocales(*this, o);
if (diff != 0) return diff;
diff = (int32_t)(screenType - o.screenType);
if (diff != 0) return diff;
@@ -1598,18 +1703,15 @@
if (mnc != o.mnc) {
return mnc < o.mnc ? -1 : 1;
}
- if (language[0] != o.language[0]) {
- return language[0] < o.language[0] ? -1 : 1;
+
+ int diff = compareLocales(*this, o);
+ if (diff < 0) {
+ return -1;
}
- if (language[1] != o.language[1]) {
- return language[1] < o.language[1] ? -1 : 1;
+ if (diff > 0) {
+ return 1;
}
- if (country[0] != o.country[0]) {
- return country[0] < o.country[0] ? -1 : 1;
- }
- if (country[1] != o.country[1]) {
- return country[1] < o.country[1] ? -1 : 1;
- }
+
if ((screenLayout & MASK_LAYOUTDIR) != (o.screenLayout & MASK_LAYOUTDIR)) {
return (screenLayout & MASK_LAYOUTDIR) < (o.screenLayout & MASK_LAYOUTDIR) ? -1 : 1;
}
@@ -1656,7 +1758,6 @@
int diffs = 0;
if (mcc != o.mcc) diffs |= CONFIG_MCC;
if (mnc != o.mnc) diffs |= CONFIG_MNC;
- if (locale != o.locale) diffs |= CONFIG_LOCALE;
if (orientation != o.orientation) diffs |= CONFIG_ORIENTATION;
if (density != o.density) diffs |= CONFIG_DENSITY;
if (touchscreen != o.touchscreen) diffs |= CONFIG_TOUCHSCREEN;
@@ -1671,9 +1772,44 @@
if (uiMode != o.uiMode) diffs |= CONFIG_UI_MODE;
if (smallestScreenWidthDp != o.smallestScreenWidthDp) diffs |= CONFIG_SMALLEST_SCREEN_SIZE;
if (screenSizeDp != o.screenSizeDp) diffs |= CONFIG_SCREEN_SIZE;
+
+ const int diff = compareLocales(*this, o);
+ if (diff) diffs |= CONFIG_LOCALE;
+
return diffs;
}
+int ResTable_config::isLocaleMoreSpecificThan(const ResTable_config& o) const {
+ if (locale || o.locale) {
+ if (language[0] != o.language[0]) {
+ if (!language[0]) return -1;
+ if (!o.language[0]) return 1;
+ }
+
+ if (country[0] != o.country[0]) {
+ if (!country[0]) return -1;
+ if (!o.country[0]) return 1;
+ }
+ }
+
+ // There isn't a well specified "importance" order between variants and
+ // scripts. We can't easily tell whether, say "en-Latn-US" is more or less
+ // specific than "en-US-POSIX".
+ //
+ // We therefore arbitrarily decide to give priority to variants over
+ // scripts since it seems more useful to do so. We will consider
+ // "en-US-POSIX" to be more specific than "en-Latn-US".
+
+ const int score = ((localeScript[0] != 0) ? 1 : 0) +
+ ((localeVariant[0] != 0) ? 2 : 0);
+
+ const int oScore = ((o.localeScript[0] != 0) ? 1 : 0) +
+ ((o.localeVariant[0] != 0) ? 2 : 0);
+
+ return score - oScore;
+
+}
+
bool ResTable_config::isMoreSpecificThan(const ResTable_config& o) const {
// The order of the following tests defines the importance of one
// configuration parameter over another. Those tests first are more
@@ -1691,14 +1827,13 @@
}
if (locale || o.locale) {
- if (language[0] != o.language[0]) {
- if (!language[0]) return false;
- if (!o.language[0]) return true;
+ const int diff = isLocaleMoreSpecificThan(o);
+ if (diff < 0) {
+ return false;
}
- if (country[0] != o.country[0]) {
- if (!country[0]) return false;
- if (!o.country[0]) return true;
+ if (diff > 0) {
+ return true;
}
}
@@ -1834,6 +1969,18 @@
}
}
+ if (localeScript[0] || o.localeScript[0]) {
+ if (localeScript[0] != o.localeScript[0] && requested->localeScript[0]) {
+ return localeScript[0];
+ }
+ }
+
+ if (localeVariant[0] || o.localeVariant[0]) {
+ if (localeVariant[0] != o.localeVariant[0] && requested->localeVariant[0]) {
+ return localeVariant[0];
+ }
+ }
+
if (screenLayout || o.screenLayout) {
if (((screenLayout^o.screenLayout) & MASK_LAYOUTDIR) != 0
&& (requested->screenLayout & MASK_LAYOUTDIR)) {
@@ -2054,17 +2201,23 @@
}
}
if (locale != 0) {
+ // Don't consider the script & variants when deciding matches.
+ //
+ // If we two configs differ only in their script or language, they
+ // can be weeded out in the isMoreSpecificThan test.
if (language[0] != 0
&& (language[0] != settings.language[0]
|| language[1] != settings.language[1])) {
return false;
}
+
if (country[0] != 0
&& (country[0] != settings.country[0]
|| country[1] != settings.country[1])) {
return false;
}
}
+
if (screenConfig != 0) {
const int layoutDir = screenLayout&MASK_LAYOUTDIR;
const int setLayoutDir = settings.screenLayout&MASK_LAYOUTDIR;
@@ -2166,17 +2319,92 @@
return true;
}
-void ResTable_config::getLocale(char str[6]) const {
- memset(str, 0, 6);
- if (language[0]) {
- str[0] = language[0];
- str[1] = language[1];
- if (country[0]) {
- str[2] = '_';
- str[3] = country[0];
- str[4] = country[1];
- }
+void ResTable_config::getBcp47Locale(char str[RESTABLE_MAX_LOCALE_LEN]) const {
+ memset(str, 0, RESTABLE_MAX_LOCALE_LEN);
+
+ // This represents the "any" locale value, which has traditionally been
+ // represented by the empty string.
+ if (!language[0] && !country[0]) {
+ return;
}
+
+ size_t charsWritten = 0;
+ if (language[0]) {
+ charsWritten += unpackLanguage(str);
+ }
+
+ if (localeScript[0]) {
+ if (charsWritten) {
+ str[charsWritten++] = '-';
+ }
+ memcpy(str + charsWritten, localeScript, sizeof(localeScript));
+ charsWritten += sizeof(localeScript);
+ }
+
+ if (country[0]) {
+ if (charsWritten) {
+ str[charsWritten++] = '-';
+ }
+ charsWritten += unpackRegion(str + charsWritten);
+ }
+
+ if (localeVariant[0]) {
+ if (charsWritten) {
+ str[charsWritten++] = '-';
+ }
+ memcpy(str + charsWritten, localeVariant, sizeof(localeVariant));
+ }
+}
+
+/* static */ inline bool assignLocaleComponent(ResTable_config* config,
+ const char* start, size_t size) {
+
+ switch (size) {
+ case 0:
+ return false;
+ case 2:
+ case 3:
+ config->language[0] ? config->packRegion(start) : config->packLanguage(start);
+ break;
+ case 4:
+ config->localeScript[0] = toupper(start[0]);
+ for (size_t i = 1; i < 4; ++i) {
+ config->localeScript[i] = tolower(start[i]);
+ }
+ break;
+ case 5:
+ case 6:
+ case 7:
+ case 8:
+ for (size_t i = 0; i < size; ++i) {
+ config->localeVariant[i] = tolower(start[i]);
+ }
+ break;
+ default:
+ return false;
+ }
+
+ return true;
+}
+
+void ResTable_config::setBcp47Locale(const char* in) {
+ locale = 0;
+ memset(localeScript, 0, sizeof(localeScript));
+ memset(localeVariant, 0, sizeof(localeVariant));
+
+ const char* separator = in;
+ const char* start = in;
+ while ((separator = strchr(start, '-')) != NULL) {
+ const size_t size = separator - start;
+ if (!assignLocaleComponent(this, start, size)) {
+ fprintf(stderr, "Invalid BCP-47 locale string: %s", in);
+ }
+
+ start = (separator + 1);
+ }
+
+ const size_t size = in + strlen(in) - start;
+ assignLocaleComponent(this, start, size);
}
String8 ResTable_config::toString() const {
@@ -2190,14 +2418,10 @@
if (res.size() > 0) res.append("-");
res.appendFormat("%dmnc", dtohs(mnc));
}
- if (language[0] != 0) {
- if (res.size() > 0) res.append("-");
- res.append(language, 2);
- }
- if (country[0] != 0) {
- if (res.size() > 0) res.append("-");
- res.append(country, 2);
- }
+ char localeStr[RESTABLE_MAX_LOCALE_LEN];
+ getBcp47Locale(localeStr);
+ res.append(localeStr);
+
if ((screenLayout&MASK_LAYOUTDIR) != 0) {
if (res.size() > 0) res.append("-");
switch (screenLayout&ResTable_config::MASK_LAYOUTDIR) {
@@ -2461,7 +2685,7 @@
size_t size;
const uint8_t* dataEnd;
size_t index;
- void* cookie;
+ int32_t cookie;
ResStringPool values;
uint32_t* resourceIDMap;
@@ -2493,7 +2717,7 @@
delete types[i];
}
}
-
+
ResTable* const owner;
const Header* const header;
const ResTable_package* const package;
@@ -2501,7 +2725,7 @@
ResStringPool typeStrings;
ResStringPool keyStrings;
-
+
const Type* getType(size_t idx) const {
return idx < types.size() ? types[idx] : NULL;
}
@@ -2551,18 +2775,18 @@
bags = NULL;
}
}
-
+
ResTable* const owner;
String16 const name;
uint32_t const id;
Vector<Package*> packages;
-
+
// This is for finding typeStrings and other common package stuff.
Package* basePackage;
// For quick access.
size_t typeCount;
-
+
// Computed attribute bags, first indexed by the type and second
// by the entry in that type.
bag_set*** bags;
@@ -2711,7 +2935,7 @@
//ALOGI("Applying style 0x%08x (force=%d) theme %p...\n", resID, force, this);
//dumpToLog();
-
+
return NO_ERROR;
}
@@ -2720,7 +2944,7 @@
//ALOGI("Setting theme %p from theme %p...\n", this, &other);
//dumpToLog();
//other.dumpToLog();
-
+
if (&mTable == &other.mTable) {
for (size_t i=0; i<Res_MAXPACKAGE; i++) {
if (mPackages[i] != NULL) {
@@ -2750,7 +2974,7 @@
//ALOGI("Final theme:");
//dumpToLog();
-
+
return NO_ERROR;
}
@@ -2760,7 +2984,7 @@
int cnt = 20;
if (outTypeSpecFlags != NULL) *outTypeSpecFlags = 0;
-
+
do {
const ssize_t p = mTable.getResourcePackageIndex(resID);
const uint32_t t = Res_GETTYPE(resID);
@@ -2834,12 +3058,12 @@
for (size_t i=0; i<Res_MAXPACKAGE; i++) {
package_info* pi = mPackages[i];
if (pi == NULL) continue;
-
+
ALOGI(" Package #0x%02x:\n", (int)(i+1));
for (size_t j=0; j<pi->numTypes; j++) {
type_info& ti = pi->types[j];
if (ti.numEntries == 0) continue;
-
+
ALOGI(" Type #0x%02x:\n", (int)(j+1));
for (size_t k=0; k<ti.numEntries; k++) {
theme_entry& te = ti.entries[k];
@@ -2860,12 +3084,12 @@
//ALOGI("Creating ResTable %p\n", this);
}
-ResTable::ResTable(const void* data, size_t size, void* cookie, bool copyData)
+ResTable::ResTable(const void* data, size_t size, const int32_t cookie, bool copyData)
: mError(NO_INIT)
{
memset(&mParams, 0, sizeof(mParams));
memset(mPackageMap, 0, sizeof(mPackageMap));
- add(data, size, cookie, copyData);
+ addInternal(data, size, cookie, NULL /* asset */, copyData, NULL /* idMap */);
LOG_FATAL_IF(mError != NO_ERROR, "Error parsing resource table");
//ALOGI("Creating ResTable %p\n", this);
}
@@ -2881,13 +3105,12 @@
return ((ssize_t)mPackageMap[Res_GETPACKAGE(resID)+1])-1;
}
-status_t ResTable::add(const void* data, size_t size, void* cookie, bool copyData,
- const void* idmap)
-{
- return add(data, size, cookie, NULL, copyData, reinterpret_cast<const Asset*>(idmap));
+status_t ResTable::add(const void* data, size_t size) {
+ return addInternal(data, size, 0 /* cookie */, NULL /* asset */,
+ false /* copyData */, NULL /* idMap */);
}
-status_t ResTable::add(Asset* asset, void* cookie, bool copyData, const void* idmap)
+status_t ResTable::add(Asset* asset, const int32_t cookie, bool copyData, const void* idmap)
{
const void* data = asset->getBuffer(true);
if (data == NULL) {
@@ -2895,17 +3118,18 @@
return UNKNOWN_ERROR;
}
size_t size = (size_t)asset->getLength();
- return add(data, size, cookie, asset, copyData, reinterpret_cast<const Asset*>(idmap));
+ return addInternal(data, size, cookie, asset, copyData,
+ reinterpret_cast<const Asset*>(idmap));
}
status_t ResTable::add(ResTable* src)
{
mError = src->mError;
-
+
for (size_t i=0; i<src->mHeaders.size(); i++) {
mHeaders.add(src->mHeaders[i]);
}
-
+
for (size_t i=0; i<src->mPackageGroups.size(); i++) {
PackageGroup* srcPg = src->mPackageGroups[i];
PackageGroup* pg = new PackageGroup(this, srcPg->name, srcPg->id);
@@ -2916,14 +3140,14 @@
pg->typeCount = srcPg->typeCount;
mPackageGroups.add(pg);
}
-
+
memcpy(mPackageMap, src->mPackageMap, sizeof(mPackageMap));
-
+
return mError;
}
-status_t ResTable::add(const void* data, size_t size, void* cookie,
- Asset* asset, bool copyData, const Asset* idmap)
+status_t ResTable::addInternal(const void* data, size_t size, const int32_t cookie,
+ Asset* /*asset*/, bool copyData, const Asset* idmap)
{
if (!data) return NO_ERROR;
Header* header = new Header(this);
@@ -2945,9 +3169,9 @@
const bool notDeviceEndian = htods(0xf0) != 0xf0;
LOAD_TABLE_NOISY(
- ALOGV("Adding resources to ResTable: data=%p, size=0x%x, cookie=%p, asset=%p, copy=%d "
+ ALOGV("Adding resources to ResTable: data=%p, size=0x%x, cookie=%d, asset=%p, copy=%d "
"idmap=%p\n", data, size, cookie, asset, copyData, idmap));
-
+
if (copyData || notDeviceEndian) {
header->ownedData = malloc(size);
if (header->ownedData == NULL) {
@@ -3027,8 +3251,8 @@
}
curPackage++;
} else {
- ALOGW("Unknown chunk type %p in table at %p.\n",
- (void*)(int)(ctype),
+ ALOGW("Unknown chunk type 0x%x in table at %p.\n",
+ ctype,
(void*)(((const uint8_t*)chunk) - ((const uint8_t*)header->header)));
}
chunk = (const ResChunk_header*)
@@ -3244,8 +3468,8 @@
if ((dtohs(entry->flags)&entry->FLAG_COMPLEX) != 0) {
if (!mayBeBag) {
- ALOGW("Requesting resource %p failed because it is complex\n",
- (void*)resID);
+ ALOGW("Requesting resource 0x%x failed because it is complex\n",
+ resID);
}
continue;
}
@@ -3279,7 +3503,7 @@
// are identical (diff == 0), or overlay packages will not take effect.
continue;
}
-
+
bestItem = thisConfig;
bestValue = item;
bestPackage = package;
@@ -3349,7 +3573,7 @@
const char16_t* ResTable::valueToString(
const Res_value* value, size_t stringBlock,
- char16_t tmpBuffer[TMP_BUFFER_SIZE], size_t* outLen)
+ char16_t /*tmpBuffer*/ [TMP_BUFFER_SIZE], size_t* outLen)
{
if (!value) {
return NULL;
@@ -3372,7 +3596,7 @@
return err;
}
-void ResTable::unlockBag(const bag_entry* bag) const
+void ResTable::unlockBag(const bag_entry* /*bag*/) const
{
//printf("<<< unlockBag %p\n", this);
mLock.unlock();
@@ -3473,7 +3697,7 @@
bag_set* set = NULL;
TABLE_NOISY(ALOGI("Building bag: %p\n", (void*)resID));
-
+
ResTable_config bestConfig;
memset(&bestConfig, 0, sizeof(bestConfig));
@@ -3520,8 +3744,8 @@
}
if ((dtohs(entry->flags)&entry->FLAG_COMPLEX) == 0) {
- ALOGW("Skipping entry %p in package table %d because it is not complex!\n",
- (void*)resID, (int)ip);
+ ALOGW("Skipping entry 0x%x in package table %zu because it is not complex!\n",
+ resID, ip);
continue;
}
@@ -3539,7 +3763,7 @@
? dtohl(((const ResTable_map_entry*)entry)->parent.ident) : 0;
const uint32_t count = entrySize >= sizeof(ResTable_map_entry)
? dtohl(((const ResTable_map_entry*)entry)->count) : 0;
-
+
size_t N = count;
TABLE_NOISY(ALOGI("Found map: size=%p parent=%p count=%d\n",
@@ -3583,7 +3807,7 @@
} else {
set->typeSpecFlags = -1;
}
-
+
// Now merge in the new attributes...
ssize_t curOff = offset;
const ResTable_map* map;
@@ -3846,7 +4070,7 @@
TABLE_NOISY(printf("Expected type structure not found in package %s for idnex %d\n",
String8(group->name).string(), ti));
}
-
+
size_t NTC = typeConfigs->configs.size();
for (size_t tci=0; tci<NTC; tci++) {
const ResTable_type* const ty = typeConfigs->configs[tci];
@@ -3862,9 +4086,9 @@
if (offset == ResTable_type::NO_ENTRY) {
continue;
}
-
+
offset += typeOffset;
-
+
if (offset > (dtohl(ty->header.size)-sizeof(ResTable_entry))) {
ALOGW("ResTable_entry at %d is beyond type chunk data %d",
offset, dtohl(ty->header.size));
@@ -3878,7 +4102,7 @@
String8(name, nameLen).string());
return 0;
}
-
+
const ResTable_entry* const entry = (const ResTable_entry*)
(((const uint8_t*)ty) + offset);
if (dtohs(entry->size) < sizeof(*entry)) {
@@ -4035,7 +4259,7 @@
if (*realEnd != 0) {
return false;
}
-
+
const unit_entry* cur = unitNames;
while (cur->name) {
if (len == cur->len && strncmp(cur->name, str, len) == 0) {
@@ -4186,7 +4410,7 @@
if (neg) {
mantissa = (-mantissa) & Res_value::COMPLEX_MANTISSA_MASK;
}
- outValue->data |=
+ outValue->data |=
(radix<<Res_value::COMPLEX_RADIX_SHIFT)
| (mantissa<<Res_value::COMPLEX_MANTISSA_SHIFT);
//printf("Input value: %f 0x%016Lx, mult: %f, radix: %d, shift: %d, final: 0x%08x\n",
@@ -4299,7 +4523,7 @@
// Note: we don't check attrType here because the reference can
// be to any other type; we just need to count on the client making
// sure the referenced type is correct.
-
+
//printf("Looking up ref: %s\n", String8(s, len).string());
// It's a reference!
@@ -4386,7 +4610,7 @@
}
}
}
-
+
if (*s == '#') {
// It's a color! Convert to an integer of the form 0xaarrggbb.
uint32_t color = 0;
@@ -4486,7 +4710,7 @@
// String8(package).string(), String8(type).string(),
// String8(name).string());
uint32_t specFlags = 0;
- uint32_t rid =
+ uint32_t rid =
identifierForName(name.string(), name.size(),
type.string(), type.size(),
package.string(), package.size(), &specFlags);
@@ -4651,7 +4875,7 @@
return true;
}
}
-
+
}
bag++;
cnt--;
@@ -4930,7 +5154,7 @@
return &mHeaders[index]->values;
}
-void* ResTable::getTableCookie(size_t index) const
+int32_t ResTable::getTableCookie(size_t index) const
{
return mHeaders[index]->cookie;
}
@@ -4950,18 +5174,20 @@
const size_t L = type->configs.size();
for (size_t l=0; l<L; l++) {
const ResTable_type* config = type->configs[l];
- const ResTable_config* cfg = &config->config;
+ ResTable_config cfg;
+ memset(&cfg, 0, sizeof(ResTable_config));
+ cfg.copyFromDtoH(config->config);
// only insert unique
const size_t M = configs->size();
size_t m;
for (m=0; m<M; m++) {
- if (0 == (*configs)[m].compare(*cfg)) {
+ if (0 == (*configs)[m].compare(cfg)) {
break;
}
}
// if we didn't find it
if (m == M) {
- configs->add(*cfg);
+ configs->add(cfg);
}
}
}
@@ -4976,9 +5202,10 @@
getConfigurations(&configs);
ALOGV("called getConfigurations size=%d", (int)configs.size());
const size_t I = configs.size();
+
+ char locale[RESTABLE_MAX_LOCALE_LEN];
for (size_t i=0; i<I; i++) {
- char locale[6];
- configs[i].getLocale(locale);
+ configs[i].getBcp47Locale(locale);
const size_t J = locales->size();
size_t j;
for (j=0; j<J; j++) {
@@ -5013,43 +5240,43 @@
entryIndex, (int)allTypes->entryCount);
return BAD_TYPE;
}
-
+
const ResTable_type* type = NULL;
uint32_t offset = ResTable_type::NO_ENTRY;
ResTable_config bestConfig;
memset(&bestConfig, 0, sizeof(bestConfig)); // make the compiler shut up
-
+
const size_t NT = allTypes->configs.size();
for (size_t i=0; i<NT; i++) {
const ResTable_type* const thisType = allTypes->configs[i];
if (thisType == NULL) continue;
-
+
ResTable_config thisConfig;
thisConfig.copyFromDtoH(thisType->config);
TABLE_GETENTRY(ALOGI("Match entry 0x%x in type 0x%x (sz 0x%x): %s\n",
entryIndex, typeIndex+1, dtohl(thisType->config.size),
thisConfig.toString().string()));
-
+
// Check to make sure this one is valid for the current parameters.
if (config && !thisConfig.match(*config)) {
TABLE_GETENTRY(ALOGI("Does not match config!\n"));
continue;
}
-
+
// Check if there is the desired entry in this type.
-
+
const uint8_t* const end = ((const uint8_t*)thisType)
+ dtohl(thisType->header.size);
const uint32_t* const eindex = (const uint32_t*)
(((const uint8_t*)thisType) + dtohs(thisType->header.headerSize));
-
+
uint32_t thisOffset = dtohl(eindex[entryIndex]);
if (thisOffset == ResTable_type::NO_ENTRY) {
TABLE_GETENTRY(ALOGI("Skipping because it is not defined!\n"));
continue;
}
-
+
if (type != NULL) {
// Check if this one is less specific than the last found. If so,
// we will skip it. We check starting with things we most care
@@ -5059,19 +5286,19 @@
continue;
}
}
-
+
type = thisType;
offset = thisOffset;
bestConfig = thisConfig;
TABLE_GETENTRY(ALOGI("Best entry so far -- using it!\n"));
if (!config) break;
}
-
+
if (type == NULL) {
TABLE_GETENTRY(ALOGI("No value found for requested entry!\n"));
return BAD_INDEX;
}
-
+
offset += dtohl(type->entriesStart);
TABLE_NOISY(aout << "Looking in resource table " << package->header->header
<< ", typeOff="
@@ -5114,29 +5341,29 @@
return (mError=err);
}
- const size_t pkgSize = dtohl(pkg->header.size);
+ const uint32_t pkgSize = dtohl(pkg->header.size);
if (dtohl(pkg->typeStrings) >= pkgSize) {
- ALOGW("ResTable_package type strings at %p are past chunk size %p.",
- (void*)dtohl(pkg->typeStrings), (void*)pkgSize);
+ ALOGW("ResTable_package type strings at 0x%x are past chunk size 0x%x.",
+ dtohl(pkg->typeStrings), pkgSize);
return (mError=BAD_TYPE);
}
if ((dtohl(pkg->typeStrings)&0x3) != 0) {
- ALOGW("ResTable_package type strings at %p is not on an integer boundary.",
- (void*)dtohl(pkg->typeStrings));
+ ALOGW("ResTable_package type strings at 0x%x is not on an integer boundary.",
+ dtohl(pkg->typeStrings));
return (mError=BAD_TYPE);
}
if (dtohl(pkg->keyStrings) >= pkgSize) {
- ALOGW("ResTable_package key strings at %p are past chunk size %p.",
- (void*)dtohl(pkg->keyStrings), (void*)pkgSize);
+ ALOGW("ResTable_package key strings at 0x%x are past chunk size 0x%x.",
+ dtohl(pkg->keyStrings), pkgSize);
return (mError=BAD_TYPE);
}
if ((dtohl(pkg->keyStrings)&0x3) != 0) {
- ALOGW("ResTable_package key strings at %p is not on an integer boundary.",
- (void*)dtohl(pkg->keyStrings));
+ ALOGW("ResTable_package key strings at 0x%x is not on an integer boundary.",
+ dtohl(pkg->keyStrings));
return (mError=BAD_TYPE);
}
-
+
Package* package = NULL;
PackageGroup* group = NULL;
uint32_t id = idmap_id != 0 ? idmap_id : dtohl(pkg->id);
@@ -5145,12 +5372,12 @@
// always loaded alongside their idmaps, but during idmap creation
// the package is temporarily loaded by itself.
if (id < 256) {
-
+
package = new Package(this, header, pkg);
if (package == NULL) {
return (mError=NO_MEMORY);
}
-
+
size_t idx = mPackageMap[id];
if (idx == 0) {
idx = mPackageGroups.size()+1;
@@ -5184,7 +5411,7 @@
return (mError=err);
}
group->basePackage = package;
-
+
mPackageMap[id] = (uint8_t)idx;
} else {
group = mPackageGroups.itemAt(idx-1);
@@ -5201,10 +5428,10 @@
return NO_ERROR;
}
-
+
// Iterate through all chunks.
size_t curPackage = 0;
-
+
const ResChunk_header* chunk =
(const ResChunk_header*)(((const uint8_t*)pkg)
+ dtohs(pkg->header.headerSize));
@@ -5223,9 +5450,9 @@
if (err != NO_ERROR) {
return (mError=err);
}
-
+
const size_t typeSpecSize = dtohl(typeSpec->header.size);
-
+
LOAD_TABLE_NOISY(printf("TypeSpec off %p: type=0x%x, headerSize=0x%x, size=%p\n",
(void*)(base-(const uint8_t*)chunk),
dtohs(typeSpec->header.type),
@@ -5241,12 +5468,12 @@
(void*)typeSpecSize);
return (mError=BAD_TYPE);
}
-
+
if (typeSpec->id == 0) {
ALOGW("ResTable_type has an id of 0.");
return (mError=BAD_TYPE);
}
-
+
while (package->types.size() < typeSpec->id) {
package->types.add(NULL);
}
@@ -5262,7 +5489,7 @@
t->typeSpecFlags = (const uint32_t*)(
((const uint8_t*)typeSpec) + dtohs(typeSpec->header.headerSize));
t->typeSpec = typeSpec;
-
+
} else if (ctype == RES_TABLE_TYPE_TYPE) {
const ResTable_type* type = (const ResTable_type*)(chunk);
err = validate_chunk(&type->header, sizeof(*type)-sizeof(ResTable_config)+4,
@@ -5270,9 +5497,9 @@
if (err != NO_ERROR) {
return (mError=err);
}
-
- const size_t typeSize = dtohl(type->header.size);
-
+
+ const uint32_t typeSize = dtohl(type->header.size);
+
LOAD_TABLE_NOISY(printf("Type off %p: type=0x%x, headerSize=0x%x, size=%p\n",
(void*)(base-(const uint8_t*)chunk),
dtohs(type->header.type),
@@ -5280,23 +5507,23 @@
(void*)typeSize));
if (dtohs(type->header.headerSize)+(sizeof(uint32_t)*dtohl(type->entryCount))
> typeSize) {
- ALOGW("ResTable_type entry index to %p extends beyond chunk end %p.",
+ ALOGW("ResTable_type entry index to %p extends beyond chunk end 0x%x.",
(void*)(dtohs(type->header.headerSize)
+(sizeof(uint32_t)*dtohl(type->entryCount))),
- (void*)typeSize);
+ typeSize);
return (mError=BAD_TYPE);
}
if (dtohl(type->entryCount) != 0
&& dtohl(type->entriesStart) > (typeSize-sizeof(ResTable_entry))) {
- ALOGW("ResTable_type entriesStart at %p extends beyond chunk end %p.",
- (void*)dtohl(type->entriesStart), (void*)typeSize);
+ ALOGW("ResTable_type entriesStart at 0x%x extends beyond chunk end 0x%x.",
+ dtohl(type->entriesStart), typeSize);
return (mError=BAD_TYPE);
}
if (type->id == 0) {
ALOGW("ResTable_type has an id of 0.");
return (mError=BAD_TYPE);
}
-
+
while (package->types.size() < type->id) {
package->types.add(NULL);
}
@@ -5309,7 +5536,7 @@
(int)dtohl(type->entryCount), (int)t->entryCount);
return (mError=BAD_TYPE);
}
-
+
TABLE_GETENTRY(
ResTable_config thisConfig;
thisConfig.copyFromDtoH(type->config);
@@ -5330,27 +5557,34 @@
if (group->typeCount == 0) {
group->typeCount = package->types.size();
}
-
+
return NO_ERROR;
}
-status_t ResTable::createIdmap(const ResTable& overlay, uint32_t originalCrc, uint32_t overlayCrc,
- void** outData, size_t* outSize) const
+status_t ResTable::createIdmap(const ResTable& overlay,
+ uint32_t targetCrc, uint32_t overlayCrc,
+ const char* targetPath, const char* overlayPath,
+ void** outData, size_t* outSize) const
{
// see README for details on the format of map
if (mPackageGroups.size() == 0) {
+ ALOGW("idmap: target package has no package groups, cannot create idmap\n");
return UNKNOWN_ERROR;
}
if (mPackageGroups[0]->packages.size() == 0) {
+ ALOGW("idmap: target package has no packages in its first package group, "
+ "cannot create idmap\n");
return UNKNOWN_ERROR;
}
Vector<Vector<uint32_t> > map;
+ // overlaid packages are assumed to contain only one package group
const PackageGroup* pg = mPackageGroups[0];
const Package* pkg = pg->packages[0];
size_t typeCount = pkg->types.size();
// starting size is header + first item (number of types in map)
*outSize = (IDMAP_HEADER_SIZE + 1) * sizeof(uint32_t);
+ // overlay packages are assumed to contain only one package group
const String16 overlayPackage(overlay.mPackageGroups[0]->packages[0]->package->name);
const uint32_t pkg_id = pkg->package->id << 24;
@@ -5368,7 +5602,7 @@
| (0x00ff0000 & ((typeIndex+1)<<16))
| (0x0000ffff & (entryIndex));
resource_name resName;
- if (!this->getResourceName(resID, true, &resName)) {
+ if (!this->getResourceName(resID, false, &resName)) {
ALOGW("idmap: resource 0x%08x has spec but lacks values, skipping\n", resID);
// add dummy value, or trimming leading/trailing zeroes later will fail
vector.push(0);
@@ -5426,8 +5660,22 @@
}
uint32_t* data = (uint32_t*)*outData;
*data++ = htodl(IDMAP_MAGIC);
- *data++ = htodl(originalCrc);
+ *data++ = htodl(targetCrc);
*data++ = htodl(overlayCrc);
+ const char* paths[] = { targetPath, overlayPath };
+ for (int j = 0; j < 2; ++j) {
+ char* p = (char*)data;
+ const char* path = paths[j];
+ const size_t I = strlen(path);
+ if (I > 255) {
+ ALOGV("path exceeds expected 255 characters: %s\n", path);
+ return UNKNOWN_ERROR;
+ }
+ for (size_t i = 0; i < 256; ++i) {
+ *p++ = i < I ? path[i] : '\0';
+ }
+ data += 256 / sizeof(uint32_t);
+ }
const size_t mapSize = map.size();
*data++ = htodl(mapSize);
size_t offset = mapSize;
@@ -5442,6 +5690,10 @@
offset += N;
}
}
+ if (offset == mapSize) {
+ ALOGW("idmap: no resources in overlay package present in base package\n");
+ return UNKNOWN_ERROR;
+ }
for (size_t i = 0; i < mapSize; ++i) {
const Vector<uint32_t>& vector = map.itemAt(i);
const size_t N = vector.size();
@@ -5463,14 +5715,25 @@
}
bool ResTable::getIdmapInfo(const void* idmap, size_t sizeBytes,
- uint32_t* pOriginalCrc, uint32_t* pOverlayCrc)
+ uint32_t* pTargetCrc, uint32_t* pOverlayCrc,
+ String8* pTargetPath, String8* pOverlayPath)
{
const uint32_t* map = (const uint32_t*)idmap;
if (!assertIdmapHeader(map, sizeBytes)) {
return false;
}
- *pOriginalCrc = map[1];
- *pOverlayCrc = map[2];
+ if (pTargetCrc) {
+ *pTargetCrc = map[1];
+ }
+ if (pOverlayCrc) {
+ *pOverlayCrc = map[2];
+ }
+ if (pTargetPath) {
+ pTargetPath->setTo(reinterpret_cast<const char*>(map + 3));
+ }
+ if (pOverlayPath) {
+ pOverlayPath->setTo(reinterpret_cast<const char*>(map + 3 + 256 / sizeof(uint32_t)));
+ }
return true;
}
@@ -5494,7 +5757,7 @@
* RADIX_MULTS[(complex>>Res_value::COMPLEX_RADIX_SHIFT)
& Res_value::COMPLEX_RADIX_MASK];
printf("%f", value);
-
+
if (!isFraction) {
switch ((complex>>Res_value::COMPLEX_UNIT_SHIFT)&Res_value::COMPLEX_UNIT_MASK) {
case Res_value::COMPLEX_UNIT_PX: printf("px"); break;
@@ -5569,7 +5832,7 @@
} else {
printf("(string) null\n");
}
- }
+ }
} else if (value.dataType == Res_value::TYPE_FLOAT) {
printf("(float) %g\n", *(const float*)&value.data);
} else if (value.dataType == Res_value::TYPE_DIMENSION) {
@@ -5601,9 +5864,9 @@
printf("mError=0x%x (%s)\n", mError, strerror(mError));
}
#if 0
- printf("mParams=%c%c-%c%c,\n",
- mParams.language[0], mParams.language[1],
- mParams.country[0], mParams.country[1]);
+ char localeStr[RESTABLE_MAX_LOCALE_LEN];
+ mParams.getBcp47Locale(localeStr);
+ printf("mParams=%s,\n" localeStr);
#endif
size_t pgCount = mPackageGroups.size();
printf("Package Groups (%d)\n", (int)pgCount);
@@ -5612,7 +5875,7 @@
printf("Package Group %d id=%d packageCount=%d name=%s\n",
(int)pgIndex, pg->id, (int)pg->packages.size(),
String8(pg->name).string());
-
+
size_t pkgCount = pg->packages.size();
for (size_t pkgIndex=0; pkgIndex<pkgCount; pkgIndex++) {
const Package* pkg = pg->packages[pkgIndex];
@@ -5670,26 +5933,26 @@
size_t entryCount = dtohl(type->entryCount);
uint32_t entriesStart = dtohl(type->entriesStart);
if ((entriesStart&0x3) != 0) {
- printf(" NON-INTEGER ResTable_type entriesStart OFFSET: %p\n", (void*)entriesStart);
+ printf(" NON-INTEGER ResTable_type entriesStart OFFSET: 0x%x\n", entriesStart);
continue;
}
uint32_t typeSize = dtohl(type->header.size);
if ((typeSize&0x3) != 0) {
- printf(" NON-INTEGER ResTable_type header.size: %p\n", (void*)typeSize);
+ printf(" NON-INTEGER ResTable_type header.size: 0x%x\n", typeSize);
continue;
}
for (size_t entryIndex=0; entryIndex<entryCount; entryIndex++) {
-
+
const uint8_t* const end = ((const uint8_t*)type)
+ dtohl(type->header.size);
const uint32_t* const eindex = (const uint32_t*)
(((const uint8_t*)type) + dtohs(type->header.headerSize));
-
+
uint32_t thisOffset = dtohl(eindex[entryIndex]);
if (thisOffset == ResTable_type::NO_ENTRY) {
continue;
}
-
+
uint32_t resID = (0xff000000 & ((pkg->package->id)<<24))
| (0x00ff0000 & ((typeIndex+1)<<16))
| (0x0000ffff & (entryIndex));
@@ -5714,36 +5977,34 @@
printf(" INVALID RESOURCE 0x%08x: ", resID);
}
if ((thisOffset&0x3) != 0) {
- printf("NON-INTEGER OFFSET: %p\n", (void*)thisOffset);
+ printf("NON-INTEGER OFFSET: 0x%x\n", thisOffset);
continue;
}
if ((thisOffset+sizeof(ResTable_entry)) > typeSize) {
- printf("OFFSET OUT OF BOUNDS: %p+%p (size is %p)\n",
- (void*)entriesStart, (void*)thisOffset,
- (void*)typeSize);
+ printf("OFFSET OUT OF BOUNDS: 0x%x+0x%x (size is 0x%x)\n",
+ entriesStart, thisOffset, typeSize);
continue;
}
-
+
const ResTable_entry* ent = (const ResTable_entry*)
(((const uint8_t*)type) + entriesStart + thisOffset);
if (((entriesStart + thisOffset)&0x3) != 0) {
- printf("NON-INTEGER ResTable_entry OFFSET: %p\n",
- (void*)(entriesStart + thisOffset));
+ printf("NON-INTEGER ResTable_entry OFFSET: 0x%x\n",
+ (entriesStart + thisOffset));
continue;
}
-
- uint16_t esize = dtohs(ent->size);
+
+ uintptr_t esize = dtohs(ent->size);
if ((esize&0x3) != 0) {
- printf("NON-INTEGER ResTable_entry SIZE: %p\n", (void*)esize);
+ printf("NON-INTEGER ResTable_entry SIZE: %p\n", (void *)esize);
continue;
}
if ((thisOffset+esize) > typeSize) {
- printf("ResTable_entry OUT OF BOUNDS: %p+%p+%p (size is %p)\n",
- (void*)entriesStart, (void*)thisOffset,
- (void*)esize, (void*)typeSize);
+ printf("ResTable_entry OUT OF BOUNDS: 0x%x+0x%x+%p (size is 0x%x)\n",
+ entriesStart, thisOffset, (void *)esize, typeSize);
continue;
}
-
+
const Res_value* valuePtr = NULL;
const ResTable_map_entry* bagPtr = NULL;
Res_value value;
@@ -5758,12 +6019,12 @@
(int)value.dataType, (int)value.data,
(int)value.size, (int)value.res0);
}
-
+
if ((dtohs(ent->flags)&ResTable_entry::FLAG_PUBLIC) != 0) {
printf(" (PUBLIC)");
}
printf("\n");
-
+
if (inclValues) {
if (valuePtr != NULL) {
printf(" ");
diff --git a/libs/androidfw/ZipUtils.cpp b/libs/androidfw/ZipUtils.cpp
index e9ac2fe..6fa0f14 100644
--- a/libs/androidfw/ZipUtils.cpp
+++ b/libs/androidfw/ZipUtils.cpp
@@ -127,7 +127,7 @@
goto z_bail;
}
- /* output buffer holds all, so no need to write the output */
+ /* output buffer holds all, so no need to write the output */
} while (zerr == Z_OK);
assert(zerr == Z_STREAM_END); /* other errors should've been caught */
@@ -197,7 +197,7 @@
{
}
- long read(unsigned char** nextBuffer, long readSize) {
+ long read(unsigned char** nextBuffer, long /*readSize*/) {
if (!mBufferReturned) {
mBufferReturned = true;
*nextBuffer = mInput;
diff --git a/libs/androidfw/tests/Android.mk b/libs/androidfw/tests/Android.mk
index 3c55375..977ba80 100644
--- a/libs/androidfw/tests/Android.mk
+++ b/libs/androidfw/tests/Android.mk
@@ -5,7 +5,8 @@
# Build the unit tests.
test_src_files := \
ObbFile_test.cpp \
- ZipUtils_test.cpp
+ ZipUtils_test.cpp \
+ ResourceTypes_test.cpp
shared_libraries := \
libandroidfw \
diff --git a/libs/androidfw/tests/ResourceTypes_test.cpp b/libs/androidfw/tests/ResourceTypes_test.cpp
new file mode 100644
index 0000000..4888b4a
--- /dev/null
+++ b/libs/androidfw/tests/ResourceTypes_test.cpp
@@ -0,0 +1,185 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <androidfw/ResourceTypes.h>
+#include <utils/Log.h>
+#include <utils/String8.h>
+
+#include <gtest/gtest.h>
+namespace android {
+
+TEST(ResourceTypesTest, ResourceConfig_packAndUnpack2LetterLanguage) {
+ ResTable_config config;
+ config.packLanguage("en");
+
+ EXPECT_EQ('e', config.language[0]);
+ EXPECT_EQ('n', config.language[1]);
+
+ char out[4] = { 1, 1, 1, 1};
+ config.unpackLanguage(out);
+ EXPECT_EQ('e', out[0]);
+ EXPECT_EQ('n', out[1]);
+ EXPECT_EQ(0, out[2]);
+ EXPECT_EQ(0, out[3]);
+
+ memset(out, 1, sizeof(out));
+ config.locale = 0;
+ config.unpackLanguage(out);
+ EXPECT_EQ(0, out[0]);
+ EXPECT_EQ(0, out[1]);
+ EXPECT_EQ(0, out[2]);
+ EXPECT_EQ(0, out[3]);
+}
+
+TEST(ResourceTypesTest, ResourceConfig_packAndUnpack2LetterRegion) {
+ ResTable_config config;
+ config.packRegion("US");
+
+ EXPECT_EQ('U', config.country[0]);
+ EXPECT_EQ('S', config.country[1]);
+
+ char out[4] = { 1, 1, 1, 1};
+ config.unpackRegion(out);
+ EXPECT_EQ('U', out[0]);
+ EXPECT_EQ('S', out[1]);
+ EXPECT_EQ(0, out[2]);
+ EXPECT_EQ(0, out[3]);
+}
+
+TEST(ResourceTypesTest, ResourceConfig_packAndUnpack3LetterLanguage) {
+ ResTable_config config;
+ config.packLanguage("eng");
+
+ // 1-00110-01 101-00100
+ EXPECT_EQ(0x99, config.language[0]);
+ EXPECT_EQ(0xa4, config.language[1]);
+
+ char out[4] = { 1, 1, 1, 1};
+ config.unpackLanguage(out);
+ EXPECT_EQ('e', out[0]);
+ EXPECT_EQ('n', out[1]);
+ EXPECT_EQ('g', out[2]);
+ EXPECT_EQ(0, out[3]);
+}
+
+TEST(ResourceTypesTest, ResourceConfig_packAndUnpack3LetterRegion) {
+ ResTable_config config;
+ config.packRegion("419");
+
+ char out[4] = { 1, 1, 1, 1};
+ config.unpackRegion(out);
+
+ EXPECT_EQ('4', out[0]);
+ EXPECT_EQ('1', out[1]);
+ EXPECT_EQ('9', out[2]);
+}
+
+/* static */ void fillIn(const char* lang, const char* country,
+ const char* script, const char* variant, ResTable_config* out) {
+ memset(out, 0, sizeof(ResTable_config));
+ if (lang != NULL) {
+ out->packLanguage(lang);
+ }
+
+ if (country != NULL) {
+ out->packRegion(country);
+ }
+
+ if (script != NULL) {
+ memcpy(out->localeScript, script, 4);
+ }
+
+ if (variant != NULL) {
+ memcpy(out->localeVariant, variant, strlen(variant));
+ }
+}
+
+TEST(ResourceTypesTest, IsMoreSpecificThan) {
+ ResTable_config l;
+ ResTable_config r;
+
+ fillIn("en", NULL, NULL, NULL, &l);
+ fillIn(NULL, NULL, NULL, NULL, &r);
+
+ EXPECT_TRUE(l.isMoreSpecificThan(r));
+ EXPECT_FALSE(r.isMoreSpecificThan(l));
+
+ fillIn("eng", NULL, NULL, NULL, &l);
+ EXPECT_TRUE(l.isMoreSpecificThan(r));
+ EXPECT_FALSE(r.isMoreSpecificThan(l));
+
+ fillIn("eng", "419", NULL, NULL, &r);
+ EXPECT_FALSE(l.isMoreSpecificThan(r));
+ EXPECT_TRUE(r.isMoreSpecificThan(l));
+
+ fillIn("en", NULL, NULL, NULL, &l);
+ fillIn("en", "US", NULL, NULL, &r);
+ EXPECT_FALSE(l.isMoreSpecificThan(r));
+ EXPECT_TRUE(r.isMoreSpecificThan(l));
+
+ fillIn("en", "US", NULL, NULL, &l);
+ fillIn("en", "US", "Latn", NULL, &r);
+ EXPECT_FALSE(l.isMoreSpecificThan(r));
+ EXPECT_TRUE(r.isMoreSpecificThan(l));
+
+ fillIn("en", "US", NULL, NULL, &l);
+ fillIn("en", "US", NULL, "POSIX", &r);
+ EXPECT_FALSE(l.isMoreSpecificThan(r));
+ EXPECT_TRUE(r.isMoreSpecificThan(l));
+
+ fillIn("en", "US", "Latn", NULL, &l);
+ fillIn("en", "US", NULL, "POSIX", &r);
+ EXPECT_FALSE(l.isMoreSpecificThan(r));
+ EXPECT_TRUE(r.isMoreSpecificThan(l));
+}
+
+TEST(ResourceTypesTest, setLocale) {
+ ResTable_config test;
+ test.setBcp47Locale("en-US");
+ EXPECT_EQ('e', test.language[0]);
+ EXPECT_EQ('n', test.language[1]);
+ EXPECT_EQ('U', test.country[0]);
+ EXPECT_EQ('S', test.country[1]);
+ EXPECT_EQ(0, test.localeScript[0]);
+ EXPECT_EQ(0, test.localeVariant[0]);
+
+ test.setBcp47Locale("eng-419");
+ char out[4] = { 1, 1, 1, 1};
+ test.unpackLanguage(out);
+ EXPECT_EQ('e', out[0]);
+ EXPECT_EQ('n', out[1]);
+ EXPECT_EQ('g', out[2]);
+ EXPECT_EQ(0, out[3]);
+ memset(out, 1, 4);
+ test.unpackRegion(out);
+ EXPECT_EQ('4', out[0]);
+ EXPECT_EQ('1', out[1]);
+ EXPECT_EQ('9', out[2]);
+
+
+ test.setBcp47Locale("en-Latn-419");
+ memset(out, 1, 4);
+ EXPECT_EQ('e', test.language[0]);
+ EXPECT_EQ('n', test.language[1]);
+
+ EXPECT_EQ(0, memcmp("Latn", test.localeScript, 4));
+ test.unpackRegion(out);
+ EXPECT_EQ('4', out[0]);
+ EXPECT_EQ('1', out[1]);
+ EXPECT_EQ('9', out[2]);
+}
+
+} // namespace android.
diff --git a/libs/hwui/AssetAtlas.cpp b/libs/hwui/AssetAtlas.cpp
index eb8bb9f..e8c3d3c 100644
--- a/libs/hwui/AssetAtlas.cpp
+++ b/libs/hwui/AssetAtlas.cpp
@@ -28,7 +28,7 @@
// Lifecycle
///////////////////////////////////////////////////////////////////////////////
-void AssetAtlas::init(sp<GraphicBuffer> buffer, int* map, int count) {
+void AssetAtlas::init(sp<GraphicBuffer> buffer, int64_t* map, int count) {
if (mImage) {
return;
}
@@ -108,14 +108,19 @@
/**
* TODO: This method does not take the rotation flag into account
*/
-void AssetAtlas::createEntries(Caches& caches, int* map, int count) {
+void AssetAtlas::createEntries(Caches& caches, int64_t* map, int count) {
const float width = float(mTexture->width);
const float height = float(mTexture->height);
for (int i = 0; i < count; ) {
- SkBitmap* bitmap = (SkBitmap*) map[i++];
- int x = map[i++];
- int y = map[i++];
+ SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(map[i++]);
+ // NOTE: We're converting from 64 bit signed values to 32 bit
+ // signed values. This is guaranteed to be safe because the "x"
+ // and "y" coordinate values are guaranteed to be representable
+ // with 32 bits. The array is 64 bits wide so that it can carry
+ // pointers on 64 bit architectures.
+ const int x = static_cast<int>(map[i++]);
+ const int y = static_cast<int>(map[i++]);
bool rotated = map[i++] > 0;
// Bitmaps should never be null, we're just extra paranoid
diff --git a/libs/hwui/AssetAtlas.h b/libs/hwui/AssetAtlas.h
index a28efc6..163bdbc 100644
--- a/libs/hwui/AssetAtlas.h
+++ b/libs/hwui/AssetAtlas.h
@@ -121,7 +121,7 @@
* initialized. To re-initialize the atlas, you must
* first call terminate().
*/
- ANDROID_API void init(sp<GraphicBuffer> buffer, int* map, int count);
+ ANDROID_API void init(sp<GraphicBuffer> buffer, int64_t* map, int count);
/**
* Destroys the atlas texture. This object can be
@@ -176,7 +176,7 @@
}
private:
- void createEntries(Caches& caches, int* map, int count);
+ void createEntries(Caches& caches, int64_t* map, int count);
Texture* mTexture;
Image* mImage;
diff --git a/libs/hwui/DisplayListOp.h b/libs/hwui/DisplayListOp.h
index 326805a..842e028 100644
--- a/libs/hwui/DisplayListOp.h
+++ b/libs/hwui/DisplayListOp.h
@@ -1444,7 +1444,7 @@
DeferredDisplayList::kOpBatch_Text :
DeferredDisplayList::kOpBatch_ColorText;
- deferInfo.mergeId = (mergeid_t)mPaint->getColor();
+ deferInfo.mergeId = reinterpret_cast<mergeid_t>(mPaint->getColor());
// don't merge decorated text - the decorations won't draw in order
bool noDecorations = !(mPaint->getFlags() & (SkPaint::kUnderlineText_Flag |
diff --git a/libs/hwui/Patch.cpp b/libs/hwui/Patch.cpp
index 9b023f9..442e9ba 100644
--- a/libs/hwui/Patch.cpp
+++ b/libs/hwui/Patch.cpp
@@ -36,6 +36,7 @@
}
Patch::~Patch() {
+ delete[] vertices;
}
///////////////////////////////////////////////////////////////////////////////
@@ -57,7 +58,7 @@
if (vertices) return vertices;
int8_t emptyQuads = 0;
- mColors = patch->colors;
+ mColors = patch->getColors();
const int8_t numColors = patch->numColors;
if (uint8_t(numColors) < sizeof(uint32_t) * 4) {
@@ -79,8 +80,8 @@
TextureVertex* tempVertices = new TextureVertex[maxVertices];
TextureVertex* vertex = tempVertices;
- const int32_t* xDivs = patch->xDivs;
- const int32_t* yDivs = patch->yDivs;
+ const int32_t* xDivs = patch->getXDivs();
+ const int32_t* yDivs = patch->getYDivs();
const uint32_t xStretchCount = (xCount + 1) >> 1;
const uint32_t yStretchCount = (yCount + 1) >> 1;
diff --git a/libs/hwui/Patch.h b/libs/hwui/Patch.h
index 763a785..b5e8838 100644
--- a/libs/hwui/Patch.h
+++ b/libs/hwui/Patch.h
@@ -66,7 +66,7 @@
void generateQuad(TextureVertex*& vertex, float x1, float y1, float x2, float y2,
float u1, float v1, float u2, float v2, uint32_t& quadCount);
- uint32_t* mColors;
+ const uint32_t* mColors;
UvMapper mUvMapper;
}; // struct Patch
diff --git a/libs/hwui/PatchCache.cpp b/libs/hwui/PatchCache.cpp
index dc0d98c..2f2debc 100644
--- a/libs/hwui/PatchCache.cpp
+++ b/libs/hwui/PatchCache.cpp
@@ -119,6 +119,17 @@
void PatchCache::removeDeferred(Res_png_9patch* patch) {
Mutex::Autolock _l(mLock);
+
+ // Assert that patch is not already garbage
+ size_t count = mGarbage.size();
+ for (size_t i = 0; i < count; i++) {
+ if (patch == mGarbage[i]) {
+ patch = NULL;
+ break;
+ }
+ }
+ LOG_ALWAYS_FATAL_IF(patch == NULL);
+
mGarbage.push(patch);
}
@@ -129,7 +140,11 @@
Mutex::Autolock _l(mLock);
size_t count = mGarbage.size();
for (size_t i = 0; i < count; i++) {
- remove(patchesToRemove, mGarbage[i]);
+ Res_png_9patch* patch = mGarbage[i];
+ remove(patchesToRemove, patch);
+ // A Res_png_9patch is actually an array of byte that's larger
+ // than sizeof(Res_png_9patch). It must be freed as an array.
+ delete[] (int8_t*) patch;
}
mGarbage.clear();
}
@@ -139,8 +154,8 @@
for (size_t i = 0; i < patchesToRemove.size(); i++) {
const patch_pair_t& pair = patchesToRemove[i];
- // Add a new free block to the list
- const Patch* patch = pair.getSecond();
+ // Release the patch and mark the space in the free list
+ Patch* patch = pair.getSecond();
BufferBlock* block = new BufferBlock(patch->offset, patch->getSize());
block->next = mFreeBlocks;
mFreeBlocks = block;
@@ -148,6 +163,7 @@
mSize -= patch->getSize();
mCache.remove(*pair.getFirst());
+ delete patch;
}
#if DEBUG_PATCHES
@@ -212,6 +228,7 @@
} else {
mFreeBlocks = block->next;
}
+ delete block;
} else {
// Resize the block now that it's occupied
block->offset += size;
diff --git a/libs/hwui/PathCache.cpp b/libs/hwui/PathCache.cpp
index 5df6408..cf8adf8 100644
--- a/libs/hwui/PathCache.cpp
+++ b/libs/hwui/PathCache.cpp
@@ -395,7 +395,9 @@
Mutex::Autolock l(mLock);
size_t count = mGarbage.size();
for (size_t i = 0; i < count; i++) {
- remove(pathsToRemove, mGarbage.itemAt(i));
+ const path_pair_t& pair = mGarbage.itemAt(i);
+ remove(pathsToRemove, pair);
+ delete pair.getFirst();
}
mGarbage.clear();
}
diff --git a/libs/hwui/PixelBuffer.cpp b/libs/hwui/PixelBuffer.cpp
index 36e89c6..5b642b9 100644
--- a/libs/hwui/PixelBuffer.cpp
+++ b/libs/hwui/PixelBuffer.cpp
@@ -151,7 +151,7 @@
mCaches.bindPixelBuffer(mBuffer);
unmap();
glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, width, height, mFormat,
- GL_UNSIGNED_BYTE, (void*) offset);
+ GL_UNSIGNED_BYTE, reinterpret_cast<void*>(offset));
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/libs/hwui/ResourceCache.cpp b/libs/hwui/ResourceCache.cpp
index 3f77021..77292bf 100644
--- a/libs/hwui/ResourceCache.cpp
+++ b/libs/hwui/ResourceCache.cpp
@@ -31,9 +31,9 @@
ALOGD("ResourceCache: cacheReport:");
for (size_t i = 0; i < mCache->size(); ++i) {
ResourceReference* ref = mCache->valueAt(i);
- ALOGD(" ResourceCache: mCache(%d): resource, ref = 0x%p, 0x%p",
+ ALOGD(" ResourceCache: mCache(%zu): resource, ref = 0x%p, 0x%p",
i, mCache->keyAt(i), mCache->valueAt(i));
- ALOGD(" ResourceCache: mCache(%d): refCount, recycled, destroyed, type = %d, %d, %d, %d",
+ ALOGD(" ResourceCache: mCache(%zu): refCount, recycled, destroyed, type = %d, %d, %d, %d",
i, ref->refCount, ref->recycled, ref->destroyed, ref->resourceType);
}
}
@@ -213,8 +213,9 @@
// If we're not tracking this resource, just delete it
if (Caches::hasInstance()) {
Caches::getInstance().pathCache.removeDeferred(resource);
+ } else {
+ delete resource;
}
- delete resource;
return;
}
ref->destroyed = true;
@@ -235,8 +236,9 @@
// If we're not tracking this resource, just delete it
if (Caches::hasInstance()) {
Caches::getInstance().textureCache.removeDeferred(resource);
+ } else {
+ delete resource;
}
- delete resource;
return;
}
ref->destroyed = true;
@@ -292,13 +294,14 @@
ssize_t index = mCache->indexOfKey(resource);
ResourceReference* ref = index >= 0 ? mCache->valueAt(index) : NULL;
if (ref == NULL) {
+ // If we're not tracking this resource, just delete it
if (Caches::hasInstance()) {
Caches::getInstance().patchCache.removeDeferred(resource);
+ } else {
+ // A Res_png_9patch is actually an array of byte that's larger
+ // than sizeof(Res_png_9patch). It must be freed as an array.
+ delete[] (int8_t*) resource;
}
- // If we're not tracking this resource, just delete it
- // A Res_png_9patch is actually an array of byte that's larger
- // than sizeof(Res_png_9patch). It must be freed as an array.
- delete[] (int8_t*) resource;
return;
}
ref->destroyed = true;
@@ -355,16 +358,18 @@
SkBitmap* bitmap = (SkBitmap*) resource;
if (Caches::hasInstance()) {
Caches::getInstance().textureCache.removeDeferred(bitmap);
+ } else {
+ delete bitmap;
}
- delete bitmap;
}
break;
case kPath: {
SkPath* path = (SkPath*) resource;
if (Caches::hasInstance()) {
Caches::getInstance().pathCache.removeDeferred(path);
+ } else {
+ delete path;
}
- delete path;
}
break;
case kShader: {
@@ -380,11 +385,12 @@
case kNinePatch: {
if (Caches::hasInstance()) {
Caches::getInstance().patchCache.removeDeferred((Res_png_9patch*) resource);
+ } else {
+ // A Res_png_9patch is actually an array of byte that's larger
+ // than sizeof(Res_png_9patch). It must be freed as an array.
+ int8_t* patch = (int8_t*) resource;
+ delete[] patch;
}
- // A Res_png_9patch is actually an array of byte that's larger
- // than sizeof(Res_png_9patch). It must be freed as an array.
- int8_t* patch = (int8_t*) resource;
- delete[] patch;
}
break;
case kLayer: {
diff --git a/libs/hwui/SkiaShader.h b/libs/hwui/SkiaShader.h
index a63431c..cc56c50 100644
--- a/libs/hwui/SkiaShader.h
+++ b/libs/hwui/SkiaShader.h
@@ -145,7 +145,7 @@
GLuint* textureUnit);
private:
- SkiaBitmapShader() {
+ SkiaBitmapShader() : mBitmap(NULL), mTexture(NULL) {
}
SkBitmap* mBitmap;
diff --git a/libs/hwui/Snapshot.h b/libs/hwui/Snapshot.h
index cc6d0cd..5bdb18a 100644
--- a/libs/hwui/Snapshot.h
+++ b/libs/hwui/Snapshot.h
@@ -108,7 +108,7 @@
* Returns the current clip in local coordinates. The clip rect is
* transformed by the inverse transform matrix.
*/
- const Rect& getLocalClip();
+ ANDROID_API const Rect& getLocalClip();
/**
* Resets the clip to the specified rect.
diff --git a/libs/hwui/TextureCache.cpp b/libs/hwui/TextureCache.cpp
index ed0a79a..ad235a9 100644
--- a/libs/hwui/TextureCache.cpp
+++ b/libs/hwui/TextureCache.cpp
@@ -184,7 +184,9 @@
Mutex::Autolock _l(mLock);
size_t count = mGarbage.size();
for (size_t i = 0; i < count; i++) {
- mCache.remove(mGarbage.itemAt(i));
+ SkBitmap* bitmap = mGarbage.itemAt(i);
+ mCache.remove(bitmap);
+ delete bitmap;
}
mGarbage.clear();
}
diff --git a/libs/hwui/font/Font.cpp b/libs/hwui/font/Font.cpp
index 18983d8..8f5beb8 100644
--- a/libs/hwui/font/Font.cpp
+++ b/libs/hwui/font/Font.cpp
@@ -404,10 +404,10 @@
// If it's still not valid, we couldn't cache it, so we shouldn't
// draw garbage; also skip empty glyphs (spaces)
if (cachedGlyph->mIsValid && cachedGlyph->mCacheTexture) {
- float penX = x + positions[(glyphsCount << 1)];
- float penY = y + positions[(glyphsCount << 1) + 1];
+ int penX = x + (int) roundf(positions[(glyphsCount << 1)]);
+ int penY = y + (int) roundf(positions[(glyphsCount << 1) + 1]);
- (*this.*render)(cachedGlyph, roundf(penX), roundf(penY),
+ (*this.*render)(cachedGlyph, penX, penY,
bitmap, bitmapW, bitmapH, bounds, positions);
}
diff --git a/libs/hwui/utils/TinyHashMap.h b/libs/hwui/utils/TinyHashMap.h
index 8855140..4ff9a42 100644
--- a/libs/hwui/utils/TinyHashMap.h
+++ b/libs/hwui/utils/TinyHashMap.h
@@ -24,8 +24,6 @@
/**
* A very simple hash map that doesn't allow duplicate keys, overwriting the older entry.
- *
- * Currently, expects simple keys that are handled by hash_t()
*/
template <typename TKey, typename TValue>
class TinyHashMap {
@@ -36,7 +34,7 @@
* Puts an entry in the hash, removing any existing entry with the same key
*/
void put(TKey key, TValue value) {
- hash_t hash = hash_t(key);
+ hash_t hash = android::hash_type(key);
ssize_t index = mTable.find(-1, hash, key);
if (index != -1) {
@@ -51,7 +49,7 @@
* Return true if key is in the map, in which case stores the value in the output ref
*/
bool get(TKey key, TValue& outValue) {
- hash_t hash = hash_t(key);
+ hash_t hash = android::hash_type(key);
ssize_t index = mTable.find(-1, hash, key);
if (index == -1) {
return false;
diff --git a/libs/usb/tests/AccessoryChat/accessorychat/accessorychat.c b/libs/usb/tests/AccessoryChat/accessorychat/accessorychat.c
index 06b477f..57c0320 100644
--- a/libs/usb/tests/AccessoryChat/accessorychat/accessorychat.c
+++ b/libs/usb/tests/AccessoryChat/accessorychat/accessorychat.c
@@ -32,7 +32,7 @@
struct usb_device *sDevice = NULL;
static void* read_thread(void* arg) {
- int endpoint = (int)arg;
+ int endpoint = (int)(uintptr_t)arg;
int ret = 0;
while (sDevice && ret >= 0) {
@@ -52,7 +52,7 @@
}
static void* write_thread(void* arg) {
- int endpoint = (int)arg;
+ int endpoint = (int)(uintptr_t)arg;
int ret = 0;
while (ret >= 0) {
@@ -136,11 +136,11 @@
}
if ((ep1->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN) {
- pthread_create(&th, NULL, read_thread, (void *)ep1->bEndpointAddress);
- pthread_create(&th, NULL, write_thread, (void *)ep2->bEndpointAddress);
+ pthread_create(&th, NULL, read_thread, (void *)(uintptr_t)ep1->bEndpointAddress);
+ pthread_create(&th, NULL, write_thread, (void *)(uintptr_t)ep2->bEndpointAddress);
} else {
- pthread_create(&th, NULL, read_thread, (void *)ep2->bEndpointAddress);
- pthread_create(&th, NULL, write_thread, (void *)ep1->bEndpointAddress);
+ pthread_create(&th, NULL, read_thread, (void *)(uintptr_t)ep2->bEndpointAddress);
+ pthread_create(&th, NULL, write_thread, (void *)(uintptr_t)ep1->bEndpointAddress);
}
} else {
printf("Found possible android device - attempting to switch to accessory mode\n");
diff --git a/media/java/android/media/AudioRecord.java b/media/java/android/media/AudioRecord.java
index f49ef2e..461b52f 100644
--- a/media/java/android/media/AudioRecord.java
+++ b/media/java/android/media/AudioRecord.java
@@ -107,13 +107,13 @@
* Accessed by native methods: provides access to C++ AudioRecord object
*/
@SuppressWarnings("unused")
- private int mNativeRecorderInJavaObj;
+ private long mNativeRecorderInJavaObj;
/**
* Accessed by native methods: provides access to the callback data.
*/
@SuppressWarnings("unused")
- private int mNativeCallbackCookie;
+ private long mNativeCallbackCookie;
//---------------------------------------------------------
diff --git a/media/java/android/media/AudioTrack.java b/media/java/android/media/AudioTrack.java
index 78a37c5..01a6fc2 100644
--- a/media/java/android/media/AudioTrack.java
+++ b/media/java/android/media/AudioTrack.java
@@ -221,13 +221,13 @@
* Accessed by native methods: provides access to C++ AudioTrack object.
*/
@SuppressWarnings("unused")
- private int mNativeTrackInJavaObj;
+ private long mNativeTrackInJavaObj;
/**
* Accessed by native methods: provides access to the JNI data (i.e. resources used by
* the native AudioTrack object, but not stored in it).
*/
@SuppressWarnings("unused")
- private int mJniData;
+ private long mJniData;
//--------------------------------------------------------------------------
diff --git a/media/java/android/media/FaceDetector.java b/media/java/android/media/FaceDetector.java
index cf900ce..61991e3 100644
--- a/media/java/android/media/FaceDetector.java
+++ b/media/java/android/media/FaceDetector.java
@@ -191,9 +191,9 @@
native private void fft_get_face(Face face, int i);
native private void fft_destroy();
- private int mFD;
- private int mSDK;
- private int mDCR;
+ private long mFD;
+ private long mSDK;
+ private long mDCR;
private int mWidth;
private int mHeight;
private int mMaxFaces;
diff --git a/media/java/android/media/JetPlayer.java b/media/java/android/media/JetPlayer.java
index 06cda34..bd91fc5 100644
--- a/media/java/android/media/JetPlayer.java
+++ b/media/java/android/media/JetPlayer.java
@@ -127,7 +127,7 @@
* Accessed by native methods: provides access to C++ JetPlayer object
*/
@SuppressWarnings("unused")
- private int mNativePlayerInJavaObj;
+ private long mNativePlayerInJavaObj;
//--------------------------------------------
diff --git a/media/java/android/media/MediaCodec.java b/media/java/android/media/MediaCodec.java
index 5175830..ddf88df 100644
--- a/media/java/android/media/MediaCodec.java
+++ b/media/java/android/media/MediaCodec.java
@@ -644,5 +644,5 @@
native_init();
}
- private int mNativeContext;
+ private long mNativeContext;
}
diff --git a/media/java/android/media/MediaCrypto.java b/media/java/android/media/MediaCrypto.java
index 40a1326..c7c3fc2 100644
--- a/media/java/android/media/MediaCrypto.java
+++ b/media/java/android/media/MediaCrypto.java
@@ -88,5 +88,5 @@
native_init();
}
- private int mNativeContext;
+ private long mNativeContext;
}
diff --git a/media/java/android/media/MediaExtractor.java b/media/java/android/media/MediaExtractor.java
index e558c07..c3e5035 100644
--- a/media/java/android/media/MediaExtractor.java
+++ b/media/java/android/media/MediaExtractor.java
@@ -352,5 +352,5 @@
native_init();
}
- private int mNativeContext;
+ private long mNativeContext;
}
diff --git a/media/java/android/media/MediaMetadataRetriever.java b/media/java/android/media/MediaMetadataRetriever.java
index 9014453..db27d09 100644
--- a/media/java/android/media/MediaMetadataRetriever.java
+++ b/media/java/android/media/MediaMetadataRetriever.java
@@ -42,7 +42,7 @@
// The field below is accessed by native methods
@SuppressWarnings("unused")
- private int mNativeContext;
+ private long mNativeContext;
private static final int EMBEDDED_PICTURE_TYPE_ANY = 0xFFFF;
diff --git a/media/java/android/media/MediaPlayer.java b/media/java/android/media/MediaPlayer.java
index 706258a..b34cea8 100644
--- a/media/java/android/media/MediaPlayer.java
+++ b/media/java/android/media/MediaPlayer.java
@@ -572,8 +572,8 @@
// macro invocation in IMediaPlayer.cpp
private final static String IMEDIA_PLAYER = "android.media.IMediaPlayer";
- private int mNativeContext; // accessed by native methods
- private int mNativeSurfaceTexture; // accessed by native methods
+ private long mNativeContext; // accessed by native methods
+ private long mNativeSurfaceTexture; // accessed by native methods
private int mListenerContext; // accessed by native methods
private SurfaceHolder mSurfaceHolder;
private EventHandler mEventHandler;
diff --git a/media/java/android/media/MediaRecorder.java b/media/java/android/media/MediaRecorder.java
index 8dcbd6b..5a9d577 100644
--- a/media/java/android/media/MediaRecorder.java
+++ b/media/java/android/media/MediaRecorder.java
@@ -81,7 +81,7 @@
// The two fields below are accessed by native methods
@SuppressWarnings("unused")
- private int mNativeContext;
+ private long mNativeContext;
@SuppressWarnings("unused")
private Surface mSurface;
diff --git a/media/java/android/media/MediaScanner.java b/media/java/android/media/MediaScanner.java
index de3041e..53835e2 100644
--- a/media/java/android/media/MediaScanner.java
+++ b/media/java/android/media/MediaScanner.java
@@ -301,7 +301,7 @@
// 148 and up don't seem to have been defined yet.
};
- private int mNativeContext;
+ private long mNativeContext;
private Context mContext;
private String mPackageName;
private IContentProvider mMediaProvider;
diff --git a/media/java/android/media/RemoteDisplay.java b/media/java/android/media/RemoteDisplay.java
index 7afce1a..4e937a5 100644
--- a/media/java/android/media/RemoteDisplay.java
+++ b/media/java/android/media/RemoteDisplay.java
@@ -38,12 +38,12 @@
private final Listener mListener;
private final Handler mHandler;
- private int mPtr;
+ private long mPtr;
- private native int nativeListen(String iface);
- private native void nativeDispose(int ptr);
- private native void nativePause(int ptr);
- private native void nativeResume(int ptr);
+ private native long nativeListen(String iface);
+ private native void nativeDispose(long ptr);
+ private native void nativePause(long ptr);
+ private native void nativeResume(long ptr);
private RemoteDisplay(Listener listener, Handler handler) {
mListener = listener;
diff --git a/media/java/android/media/SoundPool.java b/media/java/android/media/SoundPool.java
index 06af5de..fbfc574 100644
--- a/media/java/android/media/SoundPool.java
+++ b/media/java/android/media/SoundPool.java
@@ -443,7 +443,7 @@
private final static String TAG = "SoundPool";
private final static boolean DEBUG = false;
- private int mNativeContext; // accessed by native methods
+ private long mNativeContext; // accessed by native methods
private EventHandler mEventHandler;
private SoundPool.OnLoadCompleteListener mOnLoadCompleteListener;
diff --git a/media/java/android/media/ToneGenerator.java b/media/java/android/media/ToneGenerator.java
index 5592105..713f147 100644
--- a/media/java/android/media/ToneGenerator.java
+++ b/media/java/android/media/ToneGenerator.java
@@ -887,5 +887,5 @@
protected void finalize() { native_finalize(); }
@SuppressWarnings("unused")
- private int mNativeContext; // accessed by native methods
+ private long mNativeContext; // accessed by native methods
}
diff --git a/media/jni/android_media_ImageReader.cpp b/media/jni/android_media_ImageReader.cpp
index 0030dbd..d475eee 100644
--- a/media/jni/android_media_ImageReader.cpp
+++ b/media/jni/android_media_ImageReader.cpp
@@ -707,6 +707,7 @@
}
status_t res = consumer->lockNextBuffer(buffer);
if (res != NO_ERROR) {
+ ctx->returnLockedBuffer(buffer);
if (res != BAD_VALUE /*no buffers*/) {
if (res == NOT_ENOUGH_DATA) {
return ACQUIRE_MAX_IMAGES;
diff --git a/media/jni/android_media_MediaCodec.cpp b/media/jni/android_media_MediaCodec.cpp
index b8d437c..221ea57 100644
--- a/media/jni/android_media_MediaCodec.cpp
+++ b/media/jni/android_media_MediaCodec.cpp
@@ -328,20 +328,20 @@
static sp<JMediaCodec> setMediaCodec(
JNIEnv *env, jobject thiz, const sp<JMediaCodec> &codec) {
- sp<JMediaCodec> old = (JMediaCodec *)env->GetIntField(thiz, gFields.context);
+ sp<JMediaCodec> old = (JMediaCodec *)env->GetLongField(thiz, gFields.context);
if (codec != NULL) {
codec->incStrong(thiz);
}
if (old != NULL) {
old->decStrong(thiz);
}
- env->SetIntField(thiz, gFields.context, (int)codec.get());
+ env->SetLongField(thiz, gFields.context, (jlong)codec.get());
return old;
}
static sp<JMediaCodec> getMediaCodec(JNIEnv *env, jobject thiz) {
- return (JMediaCodec *)env->GetIntField(thiz, gFields.context);
+ return (JMediaCodec *)env->GetLongField(thiz, gFields.context);
}
static void android_media_MediaCodec_release(JNIEnv *env, jobject thiz) {
@@ -710,7 +710,7 @@
status_t err = codec->dequeueInputBuffer(&index, timeoutUs);
if (err == OK) {
- return index;
+ return (jint) index;
}
return throwExceptionAsNecessary(env, err);
@@ -732,7 +732,7 @@
env, bufferInfo, &index, timeoutUs);
if (err == OK) {
- return index;
+ return (jint) index;
}
return throwExceptionAsNecessary(env, err);
@@ -885,7 +885,7 @@
env, env->FindClass("android/media/MediaCodec"));
CHECK(clazz.get() != NULL);
- gFields.context = env->GetFieldID(clazz.get(), "mNativeContext", "I");
+ gFields.context = env->GetFieldID(clazz.get(), "mNativeContext", "J");
CHECK(gFields.context != NULL);
clazz.reset(env->FindClass("android/media/MediaCodec$CryptoInfo"));
diff --git a/media/jni/android_media_MediaCrypto.cpp b/media/jni/android_media_MediaCrypto.cpp
index d0f56ea..a6f8dcd 100644
--- a/media/jni/android_media_MediaCrypto.cpp
+++ b/media/jni/android_media_MediaCrypto.cpp
@@ -38,7 +38,7 @@
static fields_t gFields;
static sp<JCrypto> getCrypto(JNIEnv *env, jobject thiz) {
- return (JCrypto *)env->GetIntField(thiz, gFields.context);
+ return (JCrypto *)env->GetLongField(thiz, gFields.context);
}
JCrypto::JCrypto(
@@ -146,14 +146,14 @@
static sp<JCrypto> setCrypto(
JNIEnv *env, jobject thiz, const sp<JCrypto> &crypto) {
- sp<JCrypto> old = (JCrypto *)env->GetIntField(thiz, gFields.context);
+ sp<JCrypto> old = (JCrypto *)env->GetLongField(thiz, gFields.context);
if (crypto != NULL) {
crypto->incStrong(thiz);
}
if (old != NULL) {
old->decStrong(thiz);
}
- env->SetIntField(thiz, gFields.context, (int)crypto.get());
+ env->SetLongField(thiz, gFields.context, (jlong)crypto.get());
return old;
}
@@ -166,7 +166,7 @@
jclass clazz = env->FindClass("android/media/MediaCrypto");
CHECK(clazz != NULL);
- gFields.context = env->GetFieldID(clazz, "mNativeContext", "I");
+ gFields.context = env->GetFieldID(clazz, "mNativeContext", "J");
CHECK(gFields.context != NULL);
}
@@ -232,7 +232,7 @@
env,
"java/lang/IllegalArgumentException",
NULL);
- return false;
+ return JNI_FALSE;
}
jboolean isCopy;
@@ -243,27 +243,27 @@
env->ReleaseByteArrayElements(uuidObj, uuid, 0);
uuid = NULL;
- return result;
+ return result ? JNI_TRUE : JNI_FALSE;
}
static jboolean android_media_MediaCrypto_requiresSecureDecoderComponent(
JNIEnv *env, jobject thiz, jstring mimeObj) {
if (mimeObj == NULL) {
jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
- return false;
+ return JNI_FALSE;
}
sp<JCrypto> crypto = getCrypto(env, thiz);
if (crypto == NULL) {
jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
- return false;
+ return JNI_FALSE;
}
const char *mime = env->GetStringUTFChars(mimeObj, NULL);
if (mime == NULL) {
- return false;
+ return JNI_FALSE;
}
bool result = crypto->requiresSecureDecoderComponent(mime);
@@ -271,7 +271,7 @@
env->ReleaseStringUTFChars(mimeObj, mime);
mime = NULL;
- return result;
+ return result ? JNI_TRUE : JNI_FALSE;
}
static JNINativeMethod gMethods[] = {
diff --git a/media/jni/android_media_MediaDrm.cpp b/media/jni/android_media_MediaDrm.cpp
index eb7d51c..052d97d 100644
--- a/media/jni/android_media_MediaDrm.cpp
+++ b/media/jni/android_media_MediaDrm.cpp
@@ -186,6 +186,7 @@
nativeParcel->setData(obj->data(), obj->dataSize());
env->CallStaticVoidMethod(mClass, gFields.post_event, mObject,
jeventType, extra, jParcel);
+ env->DeleteLocalRef(jParcel);
}
}
diff --git a/media/jni/android_media_MediaExtractor.cpp b/media/jni/android_media_MediaExtractor.cpp
index 1ac45d4..854ee79 100644
--- a/media/jni/android_media_MediaExtractor.cpp
+++ b/media/jni/android_media_MediaExtractor.cpp
@@ -84,11 +84,11 @@
jbyteArray byteArrayObj = env->NewByteArray(size);
env->DeleteLocalRef(env->GetObjectClass(mDataSource));
env->DeleteLocalRef(env->GetObjectClass(byteArrayObj));
- ssize_t numread = env->CallIntMethod(mDataSource, mReadMethod, offset, byteArrayObj, size);
+ ssize_t numread = env->CallIntMethod(mDataSource, mReadMethod, offset, byteArrayObj, (jint)size);
env->GetByteArrayRegion(byteArrayObj, 0, size, (jbyte*) buffer);
env->DeleteLocalRef(byteArrayObj);
if (env->ExceptionCheck()) {
- ALOGW("Exception occurred while reading %d at %lld", size, offset);
+ ALOGW("Exception occurred while reading %zu at %lld", size, offset);
LOGW_EX(env);
env->ExceptionClear();
return -1;
@@ -198,7 +198,7 @@
void *dst = env->GetDirectBufferAddress(byteBuf);
- jlong dstSize;
+ size_t dstSize;
jbyteArray byteArray = NULL;
if (dst == NULL) {
@@ -219,9 +219,9 @@
jboolean isCopy;
dst = env->GetByteArrayElements(byteArray, &isCopy);
- dstSize = env->GetArrayLength(byteArray);
+ dstSize = (size_t) env->GetArrayLength(byteArray);
} else {
- dstSize = env->GetDirectBufferCapacity(byteBuf);
+ dstSize = (size_t) env->GetDirectBufferCapacity(byteBuf);
}
if (dstSize < offset) {
@@ -299,7 +299,7 @@
static sp<JMediaExtractor> setMediaExtractor(
JNIEnv *env, jobject thiz, const sp<JMediaExtractor> &extractor) {
sp<JMediaExtractor> old =
- (JMediaExtractor *)env->GetIntField(thiz, gFields.context);
+ (JMediaExtractor *)env->GetLongField(thiz, gFields.context);
if (extractor != NULL) {
extractor->incStrong(thiz);
@@ -307,13 +307,13 @@
if (old != NULL) {
old->decStrong(thiz);
}
- env->SetIntField(thiz, gFields.context, (int)extractor.get());
+ env->SetLongField(thiz, gFields.context, (jlong)extractor.get());
return old;
}
static sp<JMediaExtractor> getMediaExtractor(JNIEnv *env, jobject thiz) {
- return (JMediaExtractor *)env->GetIntField(thiz, gFields.context);
+ return (JMediaExtractor *)env->GetLongField(thiz, gFields.context);
}
static void android_media_MediaExtractor_release(JNIEnv *env, jobject thiz) {
@@ -329,7 +329,7 @@
return -1;
}
- return extractor->countTracks();
+ return (jint) extractor->countTracks();
}
static jobject android_media_MediaExtractor_getTrackFormatNative(
@@ -430,19 +430,19 @@
if (extractor == NULL) {
jniThrowException(env, "java/lang/IllegalStateException", NULL);
- return false;
+ return JNI_FALSE;
}
status_t err = extractor->advance();
if (err == ERROR_END_OF_STREAM) {
- return false;
+ return JNI_FALSE;
} else if (err != OK) {
jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
- return false;
+ return JNI_FALSE;
}
- return true;
+ return JNI_TRUE;
}
static jint android_media_MediaExtractor_readSampleData(
@@ -461,10 +461,10 @@
return -1;
} else if (err != OK) {
jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
- return false;
+ return -1;
}
- return sampleSize;
+ return (jint) sampleSize;
}
static jint android_media_MediaExtractor_getSampleTrackIndex(
@@ -483,10 +483,10 @@
return -1;
} else if (err != OK) {
jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
- return false;
+ return -1;
}
- return trackIndex;
+ return (jint) trackIndex;
}
static jlong android_media_MediaExtractor_getSampleTime(
@@ -505,10 +505,10 @@
return -1ll;
} else if (err != OK) {
jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
- return false;
+ return -1ll;
}
- return sampleTimeUs;
+ return (jlong) sampleTimeUs;
}
static jint android_media_MediaExtractor_getSampleFlags(
@@ -517,20 +517,20 @@
if (extractor == NULL) {
jniThrowException(env, "java/lang/IllegalStateException", NULL);
- return -1ll;
+ return -1;
}
uint32_t sampleFlags;
status_t err = extractor->getSampleFlags(&sampleFlags);
if (err == ERROR_END_OF_STREAM) {
- return -1ll;
+ return -1;
} else if (err != OK) {
jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
- return false;
+ return -1;
}
- return sampleFlags;
+ return (jint) sampleFlags;
}
static jboolean android_media_MediaExtractor_getSampleCryptoInfo(
@@ -539,34 +539,34 @@
if (extractor == NULL) {
jniThrowException(env, "java/lang/IllegalStateException", NULL);
- return -1ll;
+ return JNI_FALSE;
}
sp<MetaData> meta;
status_t err = extractor->getSampleMeta(&meta);
if (err != OK) {
- return false;
+ return JNI_FALSE;
}
uint32_t type;
const void *data;
size_t size;
if (!meta->findData(kKeyEncryptedSizes, &type, &data, &size)) {
- return false;
+ return JNI_FALSE;
}
- size_t numSubSamples = size / sizeof(size_t);
+ size_t numSubSamples = size / sizeof(int32_t);
if (numSubSamples == 0) {
- return false;
+ return JNI_FALSE;
}
jintArray numBytesOfEncryptedDataObj = env->NewIntArray(numSubSamples);
jboolean isCopy;
jint *dst = env->GetIntArrayElements(numBytesOfEncryptedDataObj, &isCopy);
for (size_t i = 0; i < numSubSamples; ++i) {
- dst[i] = ((const size_t *)data)[i];
+ dst[i] = ((const int32_t *)data)[i];
}
env->ReleaseIntArrayElements(numBytesOfEncryptedDataObj, dst, 0);
dst = NULL;
@@ -576,14 +576,14 @@
if (meta->findData(kKeyPlainSizes, &type, &data, &size)) {
if (size != encSize) {
// The two must be of the same length.
- return false;
+ return JNI_FALSE;
}
numBytesOfPlainDataObj = env->NewIntArray(numSubSamples);
jboolean isCopy;
jint *dst = env->GetIntArrayElements(numBytesOfPlainDataObj, &isCopy);
for (size_t i = 0; i < numSubSamples; ++i) {
- dst[i] = ((const size_t *)data)[i];
+ dst[i] = ((const int32_t *)data)[i];
}
env->ReleaseIntArrayElements(numBytesOfPlainDataObj, dst, 0);
dst = NULL;
@@ -593,7 +593,7 @@
if (meta->findData(kKeyCryptoKey, &type, &data, &size)) {
if (size != 16) {
// Keys must be 16 bytes in length.
- return false;
+ return JNI_FALSE;
}
keyObj = env->NewByteArray(size);
@@ -608,7 +608,7 @@
if (meta->findData(kKeyCryptoIV, &type, &data, &size)) {
if (size != 16) {
// IVs must be 16 bytes in length.
- return false;
+ return JNI_FALSE;
}
ivObj = env->NewByteArray(size);
@@ -627,21 +627,21 @@
env->CallVoidMethod(
cryptoInfoObj,
gFields.cryptoInfoSetID,
- numSubSamples,
+ (jint)numSubSamples,
numBytesOfPlainDataObj,
numBytesOfEncryptedDataObj,
keyObj,
ivObj,
mode);
- return true;
+ return JNI_TRUE;
}
static void android_media_MediaExtractor_native_init(JNIEnv *env) {
jclass clazz = env->FindClass("android/media/MediaExtractor");
CHECK(clazz != NULL);
- gFields.context = env->GetFieldID(clazz, "mNativeContext", "I");
+ gFields.context = env->GetFieldID(clazz, "mNativeContext", "J");
CHECK(gFields.context != NULL);
clazz = env->FindClass("android/media/MediaCodec$CryptoInfo");
@@ -770,7 +770,7 @@
return -1ll;
}
- return cachedDurationUs;
+ return (jlong) cachedDurationUs;
}
static jboolean android_media_MediaExtractor_hasCacheReachedEOS(
@@ -779,16 +779,16 @@
if (extractor == NULL) {
jniThrowException(env, "java/lang/IllegalStateException", NULL);
- return true;
+ return JNI_TRUE;
}
int64_t cachedDurationUs;
bool eos;
if (!extractor->getCachedDuration(&cachedDurationUs, &eos)) {
- return true;
+ return JNI_TRUE;
}
- return eos;
+ return eos ? JNI_TRUE : JNI_FALSE;
}
static void android_media_MediaExtractor_native_finalize(
diff --git a/media/jni/android_media_MediaMetadataRetriever.cpp b/media/jni/android_media_MediaMetadataRetriever.cpp
index 297dadf..6176f0f 100644
--- a/media/jni/android_media_MediaMetadataRetriever.cpp
+++ b/media/jni/android_media_MediaMetadataRetriever.cpp
@@ -67,15 +67,15 @@
static MediaMetadataRetriever* getRetriever(JNIEnv* env, jobject thiz)
{
// No lock is needed, since it is called internally by other methods that are protected
- MediaMetadataRetriever* retriever = (MediaMetadataRetriever*) env->GetIntField(thiz, fields.context);
+ MediaMetadataRetriever* retriever = (MediaMetadataRetriever*) env->GetLongField(thiz, fields.context);
return retriever;
}
-static void setRetriever(JNIEnv* env, jobject thiz, int retriever)
+static void setRetriever(JNIEnv* env, jobject thiz, MediaMetadataRetriever* retriever)
{
// No lock is needed, since it is called internally by other methods that are protected
- MediaMetadataRetriever *old = (MediaMetadataRetriever*) env->GetIntField(thiz, fields.context);
- env->SetIntField(thiz, fields.context, retriever);
+ MediaMetadataRetriever *old = (MediaMetadataRetriever*) env->GetLongField(thiz, fields.context);
+ env->SetLongField(thiz, fields.context, (jlong) retriever);
}
static void
@@ -146,10 +146,10 @@
int fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
if (offset < 0 || length < 0 || fd < 0) {
if (offset < 0) {
- ALOGE("negative offset (%lld)", offset);
+ ALOGE("negative offset (%lld)", (long long)offset);
}
if (length < 0) {
- ALOGE("negative length (%lld)", length);
+ ALOGE("negative length (%lld)", (long long)length);
}
if (fd < 0) {
ALOGE("invalid file descriptor");
@@ -245,7 +245,7 @@
fields.createConfigMethod,
SkBitmap::kRGB_565_Config);
- size_t width, height;
+ uint32_t width, height;
bool swapWidthAndHeight = false;
if (videoFrame->mRotationAngle == 90 || videoFrame->mRotationAngle == 270) {
width = videoFrame->mHeight;
@@ -264,7 +264,7 @@
config);
SkBitmap *bitmap =
- (SkBitmap *) env->GetIntField(jBitmap, fields.nativeBitmap);
+ (SkBitmap *) env->GetLongField(jBitmap, fields.nativeBitmap);
bitmap->lockPixels();
rotate((uint16_t*)bitmap->getPixels(),
@@ -276,8 +276,8 @@
if (videoFrame->mDisplayWidth != videoFrame->mWidth ||
videoFrame->mDisplayHeight != videoFrame->mHeight) {
- size_t displayWidth = videoFrame->mDisplayWidth;
- size_t displayHeight = videoFrame->mDisplayHeight;
+ uint32_t displayWidth = videoFrame->mDisplayWidth;
+ uint32_t displayHeight = videoFrame->mDisplayHeight;
if (swapWidthAndHeight) {
displayWidth = videoFrame->mDisplayHeight;
displayHeight = videoFrame->mDisplayWidth;
@@ -359,7 +359,7 @@
Mutex::Autolock lock(sLock);
MediaMetadataRetriever* retriever = getRetriever(env, thiz);
delete retriever;
- setRetriever(env, thiz, 0);
+ setRetriever(env, thiz, (MediaMetadataRetriever*) 0);
}
static void android_media_MediaMetadataRetriever_native_finalize(JNIEnv *env, jobject thiz)
@@ -379,7 +379,7 @@
return;
}
- fields.context = env->GetFieldID(clazz, "mNativeContext", "I");
+ fields.context = env->GetFieldID(clazz, "mNativeContext", "J");
if (fields.context == NULL) {
return;
}
@@ -406,7 +406,7 @@
if (fields.createScaledBitmapMethod == NULL) {
return;
}
- fields.nativeBitmap = env->GetFieldID(fields.bitmapClazz, "mNativeBitmap", "I");
+ fields.nativeBitmap = env->GetFieldID(fields.bitmapClazz, "mNativeBitmap", "J");
if (fields.nativeBitmap == NULL) {
return;
}
@@ -435,7 +435,7 @@
jniThrowException(env, "java/lang/RuntimeException", "Out of memory");
return;
}
- setRetriever(env, thiz, (int)retriever);
+ setRetriever(env, thiz, retriever);
}
// JNI mapping between Java methods and native methods
diff --git a/media/jni/android_media_MediaMuxer.cpp b/media/jni/android_media_MediaMuxer.cpp
index 2c16a05..3561b06 100644
--- a/media/jni/android_media_MediaMuxer.cpp
+++ b/media/jni/android_media_MediaMuxer.cpp
@@ -132,7 +132,7 @@
}
// Constructor counterpart.
-static jint android_media_MediaMuxer_native_setup(
+static jlong android_media_MediaMuxer_native_setup(
JNIEnv *env, jclass clazz, jobject fileDescriptor,
jint format) {
int fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
@@ -142,7 +142,7 @@
static_cast<MediaMuxer::OutputFormat>(format);
sp<MediaMuxer> muxer = new MediaMuxer(fd, fileFormat);
muxer->incStrong(clazz);
- return int(muxer.get());
+ return reinterpret_cast<jlong>(muxer.get());
}
static void android_media_MediaMuxer_setOrientationHint(
diff --git a/media/jni/android_media_MediaPlayer.cpp b/media/jni/android_media_MediaPlayer.cpp
index 4be9cd6..9d0d5a6 100644
--- a/media/jni/android_media_MediaPlayer.cpp
+++ b/media/jni/android_media_MediaPlayer.cpp
@@ -133,21 +133,21 @@
static sp<MediaPlayer> getMediaPlayer(JNIEnv* env, jobject thiz)
{
Mutex::Autolock l(sLock);
- MediaPlayer* const p = (MediaPlayer*)env->GetIntField(thiz, fields.context);
+ MediaPlayer* const p = (MediaPlayer*)env->GetLongField(thiz, fields.context);
return sp<MediaPlayer>(p);
}
static sp<MediaPlayer> setMediaPlayer(JNIEnv* env, jobject thiz, const sp<MediaPlayer>& player)
{
Mutex::Autolock l(sLock);
- sp<MediaPlayer> old = (MediaPlayer*)env->GetIntField(thiz, fields.context);
+ sp<MediaPlayer> old = (MediaPlayer*)env->GetLongField(thiz, fields.context);
if (player.get()) {
player->incStrong((void*)setMediaPlayer);
}
if (old != 0) {
old->decStrong((void*)setMediaPlayer);
}
- env->SetIntField(thiz, fields.context, (int)player.get());
+ env->SetLongField(thiz, fields.context, (jlong)player.get());
return old;
}
@@ -244,7 +244,7 @@
static sp<IGraphicBufferProducer>
getVideoSurfaceTexture(JNIEnv* env, jobject thiz) {
- IGraphicBufferProducer * const p = (IGraphicBufferProducer*)env->GetIntField(thiz, fields.surface_texture);
+ IGraphicBufferProducer * const p = (IGraphicBufferProducer*)env->GetLongField(thiz, fields.surface_texture);
return sp<IGraphicBufferProducer>(p);
}
@@ -293,7 +293,7 @@
}
}
- env->SetIntField(thiz, fields.surface_texture, (int)new_st.get());
+ env->SetLongField(thiz, fields.surface_texture, (jlong)new_st.get());
// This will fail if the media player has not been initialized yet. This
// can be the case if setDisplay() on MediaPlayer.java has been called
@@ -384,7 +384,7 @@
sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
if (mp == NULL ) {
jniThrowException(env, "java/lang/IllegalStateException", NULL);
- return false;
+ return JNI_FALSE;
}
const jboolean is_playing = mp->isPlaying();
@@ -393,7 +393,7 @@
}
static void
-android_media_MediaPlayer_seekTo(JNIEnv *env, jobject thiz, int msec)
+android_media_MediaPlayer_seekTo(JNIEnv *env, jobject thiz, jint msec)
{
sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
if (mp == NULL ) {
@@ -404,7 +404,7 @@
process_media_player_call( env, thiz, mp->seekTo(msec), NULL, NULL );
}
-static int
+static jint
android_media_MediaPlayer_getVideoWidth(JNIEnv *env, jobject thiz)
{
sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
@@ -418,10 +418,10 @@
w = 0;
}
ALOGV("getVideoWidth: %d", w);
- return w;
+ return (jint) w;
}
-static int
+static jint
android_media_MediaPlayer_getVideoHeight(JNIEnv *env, jobject thiz)
{
sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
@@ -435,11 +435,11 @@
h = 0;
}
ALOGV("getVideoHeight: %d", h);
- return h;
+ return (jint) h;
}
-static int
+static jint
android_media_MediaPlayer_getCurrentPosition(JNIEnv *env, jobject thiz)
{
sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
@@ -450,10 +450,10 @@
int msec;
process_media_player_call( env, thiz, mp->getCurrentPosition(&msec), NULL, NULL );
ALOGV("getCurrentPosition: %d (msec)", msec);
- return msec;
+ return (jint) msec;
}
-static int
+static jint
android_media_MediaPlayer_getDuration(JNIEnv *env, jobject thiz)
{
sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
@@ -464,7 +464,7 @@
int msec;
process_media_player_call( env, thiz, mp->getDuration(&msec), NULL, NULL );
ALOGV("getDuration: %d (msec)", msec);
- return msec;
+ return (jint) msec;
}
static void
@@ -480,7 +480,7 @@
}
static void
-android_media_MediaPlayer_setAudioStreamType(JNIEnv *env, jobject thiz, int streamtype)
+android_media_MediaPlayer_setAudioStreamType(JNIEnv *env, jobject thiz, jint streamtype)
{
ALOGV("setAudioStreamType: %d", streamtype);
sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
@@ -510,21 +510,21 @@
sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
if (mp == NULL ) {
jniThrowException(env, "java/lang/IllegalStateException", NULL);
- return false;
+ return JNI_FALSE;
}
- return mp->isLooping();
+ return mp->isLooping() ? JNI_TRUE : JNI_FALSE;
}
static void
-android_media_MediaPlayer_setVolume(JNIEnv *env, jobject thiz, float leftVolume, float rightVolume)
+android_media_MediaPlayer_setVolume(JNIEnv *env, jobject thiz, jfloat leftVolume, jfloat rightVolume)
{
- ALOGV("setVolume: left %f right %f", leftVolume, rightVolume);
+ ALOGV("setVolume: left %f right %f", (float) leftVolume, (float) rightVolume);
sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
if (mp == NULL ) {
jniThrowException(env, "java/lang/IllegalStateException", NULL);
return;
}
- process_media_player_call( env, thiz, mp->setVolume(leftVolume, rightVolume), NULL, NULL );
+ process_media_player_call( env, thiz, mp->setVolume((float) leftVolume, (float) rightVolume), NULL, NULL );
}
// Sends the request and reply parcels to the media player via the
@@ -544,7 +544,7 @@
// Don't use process_media_player_call which use the async loop to
// report errors, instead returns the status.
- return media_player->invoke(*request, reply);
+ return (jint) media_player->invoke(*request, reply);
}
// Sends the new filter to the client.
@@ -564,7 +564,7 @@
return UNKNOWN_ERROR;
}
- return media_player->setMetadataFilter(*filter);
+ return (jint) media_player->setMetadataFilter(*filter);
}
static jboolean
@@ -574,14 +574,14 @@
sp<MediaPlayer> media_player = getMediaPlayer(env, thiz);
if (media_player == NULL ) {
jniThrowException(env, "java/lang/IllegalStateException", NULL);
- return false;
+ return JNI_FALSE;
}
Parcel *metadata = parcelForJavaObject(env, reply);
if (metadata == NULL ) {
jniThrowException(env, "java/lang/RuntimeException", "Reply parcel is null");
- return false;
+ return JNI_FALSE;
}
metadata->freeData();
@@ -589,7 +589,11 @@
// metadata. Note however that the parcel actually starts with the
// return code so you should not rewind the parcel using
// setDataPosition(0).
- return media_player->getMetadata(update_only, apply_filter, metadata) == OK;
+ if (media_player->getMetadata(update_only, apply_filter, metadata) == OK) {
+ return JNI_TRUE;
+ } else {
+ return JNI_FALSE;
+ }
}
// This function gets some field IDs, which in turn causes class initialization.
@@ -605,7 +609,7 @@
return;
}
- fields.context = env->GetFieldID(clazz, "mNativeContext", "I");
+ fields.context = env->GetFieldID(clazz, "mNativeContext", "J");
if (fields.context == NULL) {
return;
}
@@ -616,7 +620,7 @@
return;
}
- fields.surface_texture = env->GetFieldID(clazz, "mNativeSurfaceTexture", "I");
+ fields.surface_texture = env->GetFieldID(clazz, "mNativeSurfaceTexture", "J");
if (fields.surface_texture == NULL) {
return;
}
@@ -696,7 +700,7 @@
return 0;
}
- return mp->getAudioSessionId();
+ return (jint) mp->getAudioSessionId();
}
static void
@@ -733,7 +737,7 @@
Parcel *reply = parcelForJavaObject(env, java_reply);
- return service->pullBatteryData(reply);
+ return (jint) service->pullBatteryData(reply);
}
static jint
@@ -772,7 +776,7 @@
jniThrowException(env, "java/lang/IllegalStateException", NULL);
}
- return ret;
+ return (jint) ret;
}
static void
@@ -826,16 +830,19 @@
jstring exclusionListObj = (jstring)env->CallObjectMethod(
proxyProps, fields.proxyConfigGetExclusionList);
- const char *exclusionList =
- env->GetStringUTFChars(exclusionListObj, NULL);
-
if (host != NULL && exclusionListObj != NULL) {
- thisplayer->updateProxyConfig(host, port, exclusionList);
- }
+ const char *exclusionList = env->GetStringUTFChars(exclusionListObj, NULL);
- if (exclusionList != NULL) {
- env->ReleaseStringUTFChars(exclusionListObj, exclusionList);
- exclusionList = NULL;
+ if (exclusionList != NULL) {
+ thisplayer->updateProxyConfig(host, port, exclusionList);
+
+ env->ReleaseStringUTFChars(exclusionListObj, exclusionList);
+ exclusionList = NULL;
+ } else {
+ thisplayer->updateProxyConfig(host, port, "");
+ }
+ } else if (host != NULL) {
+ thisplayer->updateProxyConfig(host, port, "");
}
if (host != NULL) {
diff --git a/media/jni/android_media_MediaProfiles.cpp b/media/jni/android_media_MediaProfiles.cpp
index 3fbb8ba..48a9132 100644
--- a/media/jni/android_media_MediaProfiles.cpp
+++ b/media/jni/android_media_MediaProfiles.cpp
@@ -48,7 +48,7 @@
android_media_MediaProfiles_native_get_num_file_formats(JNIEnv *env, jobject thiz)
{
ALOGV("native_get_num_file_formats");
- return sProfiles->getOutputFileFormats().size();
+ return (jint) sProfiles->getOutputFileFormats().size();
}
static jint
@@ -119,7 +119,7 @@
android_media_MediaProfiles_native_get_num_audio_encoders(JNIEnv *env, jobject thiz)
{
ALOGV("native_get_num_audio_encoders");
- return sProfiles->getAudioEncoders().size();
+ return (jint) sProfiles->getAudioEncoders().size();
}
static jobject
@@ -223,18 +223,18 @@
{
ALOGV("native_has_camcorder_profile: %d %d", id, quality);
if (!isCamcorderQualityKnown(quality)) {
- return false;
+ return JNI_FALSE;
}
camcorder_quality q = static_cast<camcorder_quality>(quality);
- return sProfiles->hasCamcorderProfile(id, q);
+ return sProfiles->hasCamcorderProfile(id, q) ? JNI_TRUE : JNI_FALSE;
}
static jint
android_media_MediaProfiles_native_get_num_video_decoders(JNIEnv *env, jobject thiz)
{
ALOGV("native_get_num_video_decoders");
- return sProfiles->getVideoDecoders().size();
+ return (jint) sProfiles->getVideoDecoders().size();
}
static jint
@@ -255,7 +255,7 @@
android_media_MediaProfiles_native_get_num_audio_decoders(JNIEnv *env, jobject thiz)
{
ALOGV("native_get_num_audio_decoders");
- return sProfiles->getAudioDecoders().size();
+ return (jint) sProfiles->getAudioDecoders().size();
}
static jint
@@ -276,7 +276,7 @@
android_media_MediaProfiles_native_get_num_image_encoding_quality_levels(JNIEnv *env, jobject thiz, jint cameraId)
{
ALOGV("native_get_num_image_encoding_quality_levels");
- return sProfiles->getImageEncodingQualityLevels(cameraId).size();
+ return (jint) sProfiles->getImageEncodingQualityLevels(cameraId).size();
}
static jint
@@ -284,7 +284,7 @@
{
ALOGV("native_get_image_encoding_quality_level");
Vector<int> levels = sProfiles->getImageEncodingQualityLevels(cameraId);
- if (index < 0 || index >= levels.size()) {
+ if (index < 0 || index >= (jint) levels.size()) {
jniThrowException(env, "java/lang/IllegalArgumentException", "out of array boundary");
return -1;
}
diff --git a/media/jni/android_media_MediaRecorder.cpp b/media/jni/android_media_MediaRecorder.cpp
index 9888591..0cfd2ff 100644
--- a/media/jni/android_media_MediaRecorder.cpp
+++ b/media/jni/android_media_MediaRecorder.cpp
@@ -128,21 +128,21 @@
static sp<MediaRecorder> getMediaRecorder(JNIEnv* env, jobject thiz)
{
Mutex::Autolock l(sLock);
- MediaRecorder* const p = (MediaRecorder*)env->GetIntField(thiz, fields.context);
+ MediaRecorder* const p = (MediaRecorder*)env->GetLongField(thiz, fields.context);
return sp<MediaRecorder>(p);
}
static sp<MediaRecorder> setMediaRecorder(JNIEnv* env, jobject thiz, const sp<MediaRecorder>& recorder)
{
Mutex::Autolock l(sLock);
- sp<MediaRecorder> old = (MediaRecorder*)env->GetIntField(thiz, fields.context);
+ sp<MediaRecorder> old = (MediaRecorder*)env->GetLongField(thiz, fields.context);
if (recorder.get()) {
recorder->incStrong(thiz);
}
if (old != 0) {
old->decStrong(thiz);
}
- env->SetIntField(thiz, fields.context, (int)recorder.get());
+ env->SetLongField(thiz, fields.context, (jlong)recorder.get());
return old;
}
@@ -334,14 +334,14 @@
process_media_recorder_call(env, mr->prepare(), "java/io/IOException", "prepare failed.");
}
-static int
+static jint
android_media_MediaRecorder_native_getMaxAmplitude(JNIEnv *env, jobject thiz)
{
ALOGV("getMaxAmplitude");
sp<MediaRecorder> mr = getMediaRecorder(env, thiz);
int result = 0;
process_media_recorder_call(env, mr->getMaxAmplitude(&result), "java/lang/RuntimeException", "getMaxAmplitude failed.");
- return result;
+ return (jint) result;
}
static void
@@ -392,7 +392,7 @@
return;
}
- fields.context = env->GetFieldID(clazz, "mNativeContext", "I");
+ fields.context = env->GetFieldID(clazz, "mNativeContext", "J");
if (fields.context == NULL) {
return;
}
diff --git a/media/jni/android_media_MediaScanner.cpp b/media/jni/android_media_MediaScanner.cpp
index 4e3d14e..84028b7 100644
--- a/media/jni/android_media_MediaScanner.cpp
+++ b/media/jni/android_media_MediaScanner.cpp
@@ -226,12 +226,12 @@
static MediaScanner *getNativeScanner_l(JNIEnv* env, jobject thiz)
{
- return (MediaScanner *) env->GetIntField(thiz, fields.context);
+ return (MediaScanner *) env->GetLongField(thiz, fields.context);
}
static void setNativeScanner_l(JNIEnv* env, jobject thiz, MediaScanner *s)
{
- env->SetIntField(thiz, fields.context, (int)s);
+ env->SetLongField(thiz, fields.context, (jlong)s);
}
static void
@@ -381,7 +381,7 @@
return;
}
- fields.context = env->GetFieldID(clazz, "mNativeContext", "I");
+ fields.context = env->GetFieldID(clazz, "mNativeContext", "J");
if (fields.context == NULL) {
return;
}
@@ -398,7 +398,7 @@
return;
}
- env->SetIntField(thiz, fields.context, (int)mp);
+ env->SetLongField(thiz, fields.context, (jlong)mp);
}
static void
diff --git a/media/jni/android_mtp_MtpDatabase.cpp b/media/jni/android_mtp_MtpDatabase.cpp
index 72ce3cc..8129c0d 100644
--- a/media/jni/android_mtp_MtpDatabase.cpp
+++ b/media/jni/android_mtp_MtpDatabase.cpp
@@ -17,11 +17,12 @@
#define LOG_TAG "MtpDatabaseJNI"
#include "utils/Log.h"
-#include <stdio.h>
#include <assert.h>
-#include <limits.h>
-#include <unistd.h>
#include <fcntl.h>
+#include <inttypes.h>
+#include <limits.h>
+#include <stdio.h>
+#include <unistd.h>
#include "jni.h"
#include "JNIHelp.h"
@@ -388,7 +389,7 @@
// release date is stored internally as just the year
if (property == MTP_PROPERTY_ORIGINAL_RELEASE_DATE) {
char date[20];
- snprintf(date, sizeof(date), "%04lld0101T000000", longValue);
+ snprintf(date, sizeof(date), "%04" PRId64 "0101T000000", longValue);
packet.putString(date);
goto out;
}
@@ -645,7 +646,7 @@
return result;
}
-MtpResponseCode MyMtpDatabase::resetDeviceProperty(MtpDeviceProperty property) {
+MtpResponseCode MyMtpDatabase::resetDeviceProperty(MtpDeviceProperty /*property*/) {
return -1;
}
@@ -1090,7 +1091,7 @@
}
static jstring
-android_mtp_MtpPropertyGroup_format_date_time(JNIEnv *env, jobject thiz, jlong seconds)
+android_mtp_MtpPropertyGroup_format_date_time(JNIEnv *env, jobject /*thiz*/, jlong seconds)
{
char date[20];
formatDateTime(seconds, date, sizeof(date));
diff --git a/media/jni/mediaeditor/Android.mk b/media/jni/mediaeditor/Android.mk
index 6be7fdd..5d2378d 100644
--- a/media/jni/mediaeditor/Android.mk
+++ b/media/jni/mediaeditor/Android.mk
@@ -48,7 +48,6 @@
LOCAL_SHARED_LIBRARIES := \
libandroid_runtime \
- libaudioflinger \
libaudioutils \
libbinder \
libcutils \
diff --git a/media/jni/soundpool/android_media_SoundPool_SoundPoolImpl.cpp b/media/jni/soundpool/android_media_SoundPool_SoundPoolImpl.cpp
index 2604850..9cc55ab 100644
--- a/media/jni/soundpool/android_media_SoundPool_SoundPoolImpl.cpp
+++ b/media/jni/soundpool/android_media_SoundPool_SoundPoolImpl.cpp
@@ -34,11 +34,11 @@
} fields;
static inline SoundPool* MusterSoundPool(JNIEnv *env, jobject thiz) {
- return (SoundPool*)env->GetIntField(thiz, fields.mNativeContext);
+ return (SoundPool*)env->GetLongField(thiz, fields.mNativeContext);
}
// ----------------------------------------------------------------------------
-static int
+static jint
android_media_SoundPool_SoundPoolImpl_load_URL(JNIEnv *env, jobject thiz, jstring path, jint priority)
{
ALOGV("android_media_SoundPool_SoundPoolImpl_load_URL");
@@ -50,29 +50,29 @@
const char* s = env->GetStringUTFChars(path, NULL);
int id = ap->load(s, priority);
env->ReleaseStringUTFChars(path, s);
- return id;
+ return (jint) id;
}
-static int
+static jint
android_media_SoundPool_SoundPoolImpl_load_FD(JNIEnv *env, jobject thiz, jobject fileDescriptor,
jlong offset, jlong length, jint priority)
{
ALOGV("android_media_SoundPool_SoundPoolImpl_load_FD");
SoundPool *ap = MusterSoundPool(env, thiz);
if (ap == NULL) return 0;
- return ap->load(jniGetFDFromFileDescriptor(env, fileDescriptor),
+ return (jint) ap->load(jniGetFDFromFileDescriptor(env, fileDescriptor),
int64_t(offset), int64_t(length), int(priority));
}
-static bool
+static jboolean
android_media_SoundPool_SoundPoolImpl_unload(JNIEnv *env, jobject thiz, jint sampleID) {
ALOGV("android_media_SoundPool_SoundPoolImpl_unload\n");
SoundPool *ap = MusterSoundPool(env, thiz);
- if (ap == NULL) return 0;
- return ap->unload(sampleID);
+ if (ap == NULL) return JNI_FALSE;
+ return ap->unload(sampleID) ? JNI_TRUE : JNI_FALSE;
}
-static int
+static jint
android_media_SoundPool_SoundPoolImpl_play(JNIEnv *env, jobject thiz, jint sampleID,
jfloat leftVolume, jfloat rightVolume, jint priority, jint loop,
jfloat rate)
@@ -80,7 +80,7 @@
ALOGV("android_media_SoundPool_SoundPoolImpl_play\n");
SoundPool *ap = MusterSoundPool(env, thiz);
if (ap == NULL) return 0;
- return ap->play(sampleID, leftVolume, rightVolume, priority, loop, rate);
+ return (jint) ap->play(sampleID, leftVolume, rightVolume, priority, loop, rate);
}
static void
@@ -130,22 +130,22 @@
static void
android_media_SoundPool_SoundPoolImpl_setVolume(JNIEnv *env, jobject thiz, jint channelID,
- float leftVolume, float rightVolume)
+ jfloat leftVolume, jfloat rightVolume)
{
ALOGV("android_media_SoundPool_SoundPoolImpl_setVolume");
SoundPool *ap = MusterSoundPool(env, thiz);
if (ap == NULL) return;
- ap->setVolume(channelID, leftVolume, rightVolume);
+ ap->setVolume(channelID, (float) leftVolume, (float) rightVolume);
}
static void
android_media_SoundPool_SoundPoolImpl_setPriority(JNIEnv *env, jobject thiz, jint channelID,
- int priority)
+ jint priority)
{
ALOGV("android_media_SoundPool_SoundPoolImpl_setPriority");
SoundPool *ap = MusterSoundPool(env, thiz);
if (ap == NULL) return;
- ap->setPriority(channelID, priority);
+ ap->setPriority(channelID, (int) priority);
}
static void
@@ -160,12 +160,12 @@
static void
android_media_SoundPool_SoundPoolImpl_setRate(JNIEnv *env, jobject thiz, jint channelID,
- float rate)
+ jfloat rate)
{
ALOGV("android_media_SoundPool_SoundPoolImpl_setRate");
SoundPool *ap = MusterSoundPool(env, thiz);
if (ap == NULL) return;
- ap->setRate(channelID, rate);
+ ap->setRate(channelID, (float) rate);
}
static void android_media_callback(SoundPoolEvent event, SoundPool* soundPool, void* user)
@@ -185,7 +185,7 @@
}
// save pointer to SoundPool C++ object in opaque field in Java object
- env->SetIntField(thiz, fields.mNativeContext, (int)ap);
+ env->SetLongField(thiz, fields.mNativeContext, (jlong) ap);
// set callback with weak reference
jobject globalWeakRef = env->NewGlobalRef(weakRef);
@@ -208,7 +208,7 @@
// clear callback and native context
ap->setCallback(NULL, NULL);
- env->SetIntField(thiz, fields.mNativeContext, 0);
+ env->SetLongField(thiz, fields.mNativeContext, 0);
delete ap;
}
}
@@ -299,7 +299,7 @@
goto bail;
}
- fields.mNativeContext = env->GetFieldID(clazz, "mNativeContext", "I");
+ fields.mNativeContext = env->GetFieldID(clazz, "mNativeContext", "J");
if (fields.mNativeContext == NULL) {
ALOGE("Can't find SoundPoolImpl.mNativeContext");
goto bail;
diff --git a/media/mca/filterfw/jni/jni_gl_environment.cpp b/media/mca/filterfw/jni/jni_gl_environment.cpp
index 9abf191..6da7b7c 100644
--- a/media/mca/filterfw/jni/jni_gl_environment.cpp
+++ b/media/mca/filterfw/jni/jni_gl_environment.cpp
@@ -119,12 +119,12 @@
return NULL;
}
- jfieldID context = env->GetFieldID(clazz, "mNativeContext", "I");
+ jfieldID context = env->GetFieldID(clazz, "mNativeContext", "J");
if (context == NULL) {
return NULL;
}
- MediaRecorder* const p = (MediaRecorder*)env->GetIntField(jmediarecorder, context);
+ MediaRecorder* const p = (MediaRecorder*)env->GetLongField(jmediarecorder, context);
env->DeleteLocalRef(clazz);
return sp<MediaRecorder>(p);
}
diff --git a/native/android/asset_manager.cpp b/native/android/asset_manager.cpp
index 01db1d3..dee3f8c 100644
--- a/native/android/asset_manager.cpp
+++ b/native/android/asset_manager.cpp
@@ -76,12 +76,12 @@
if (gJNIConfigured == false) {
jclass amClass = env->FindClass("android/content/res/AssetManager");
- gAssetManagerOffsets.mObject = env->GetFieldID(amClass, "mObject", "I");
+ gAssetManagerOffsets.mObject = env->GetFieldID(amClass, "mObject", "J");
gJNIConfigured = true;
}
}
- return (AAssetManager*) env->GetIntField(assetManager, gAssetManagerOffsets.mObject);
+ return (AAssetManager*) env->GetLongField(assetManager, gAssetManagerOffsets.mObject);
}
AAsset* AAssetManager_open(AAssetManager* amgr, const char* filename, int mode)
diff --git a/opengl/java/android/opengl/EGL14.java b/opengl/java/android/opengl/EGL14.java
index b93557d..cf09c58 100644
--- a/opengl/java/android/opengl/EGL14.java
+++ b/opengl/java/android/opengl/EGL14.java
@@ -160,6 +160,13 @@
int display_id
);
+ /**
+ * {@hide}
+ */
+ public static native EGLDisplay eglGetDisplay(
+ long display_id
+ );
+
// C function EGLBoolean eglInitialize ( EGLDisplay dpy, EGLint *major, EGLint *minor )
public static native boolean eglInitialize(
@@ -324,7 +331,7 @@
);
// C function EGLSurface eglCreatePbufferFromClientBuffer ( EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list )
-
+ // TODO Deprecate the below method
public static native EGLSurface eglCreatePbufferFromClientBuffer(
EGLDisplay dpy,
int buftype,
@@ -333,6 +340,18 @@
int[] attrib_list,
int offset
);
+ // TODO Unhide the below method
+ /**
+ * {@hide}
+ */
+ public static native EGLSurface eglCreatePbufferFromClientBuffer(
+ EGLDisplay dpy,
+ int buftype,
+ long buffer,
+ EGLConfig config,
+ int[] attrib_list,
+ int offset
+ );
// C function EGLBoolean eglSurfaceAttrib ( EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value )
diff --git a/opengl/java/android/opengl/EGLConfig.java b/opengl/java/android/opengl/EGLConfig.java
index a7a6bbb..9881070 100644
--- a/opengl/java/android/opengl/EGLConfig.java
+++ b/opengl/java/android/opengl/EGLConfig.java
@@ -22,7 +22,7 @@
*
*/
public class EGLConfig extends EGLObjectHandle {
- private EGLConfig(int handle) {
+ private EGLConfig(long handle) {
super(handle);
}
@@ -32,6 +32,6 @@
if (!(o instanceof EGLConfig)) return false;
EGLConfig that = (EGLConfig) o;
- return getHandle() == that.getHandle();
+ return getNativeHandle() == that.getNativeHandle();
}
}
diff --git a/opengl/java/android/opengl/EGLContext.java b/opengl/java/android/opengl/EGLContext.java
index c93bd6e..f791e7e 100644
--- a/opengl/java/android/opengl/EGLContext.java
+++ b/opengl/java/android/opengl/EGLContext.java
@@ -22,7 +22,7 @@
*
*/
public class EGLContext extends EGLObjectHandle {
- private EGLContext(int handle) {
+ private EGLContext(long handle) {
super(handle);
}
@@ -32,6 +32,6 @@
if (!(o instanceof EGLContext)) return false;
EGLContext that = (EGLContext) o;
- return getHandle() == that.getHandle();
+ return getNativeHandle() == that.getNativeHandle();
}
}
diff --git a/opengl/java/android/opengl/EGLDisplay.java b/opengl/java/android/opengl/EGLDisplay.java
index 5b8043a..e872761 100644
--- a/opengl/java/android/opengl/EGLDisplay.java
+++ b/opengl/java/android/opengl/EGLDisplay.java
@@ -22,7 +22,7 @@
*
*/
public class EGLDisplay extends EGLObjectHandle {
- private EGLDisplay(int handle) {
+ private EGLDisplay(long handle) {
super(handle);
}
@@ -32,6 +32,6 @@
if (!(o instanceof EGLDisplay)) return false;
EGLDisplay that = (EGLDisplay) o;
- return getHandle() == that.getHandle();
+ return getNativeHandle() == that.getNativeHandle();
}
}
diff --git a/opengl/java/android/opengl/EGLObjectHandle.java b/opengl/java/android/opengl/EGLObjectHandle.java
index d2710de..e6e3976 100644
--- a/opengl/java/android/opengl/EGLObjectHandle.java
+++ b/opengl/java/android/opengl/EGLObjectHandle.java
@@ -22,12 +22,20 @@
*
*/
public abstract class EGLObjectHandle {
- private final int mHandle;
+ private final long mHandle;
+ // TODO Deprecate EGLObjectHandle(int) method
protected EGLObjectHandle(int handle) {
mHandle = handle;
}
-
+ // TODO Unhide the EGLObjectHandle(long) method
+ /**
+ * {@hide}
+ */
+ protected EGLObjectHandle(long handle) {
+ mHandle = handle;
+ }
+ // TODO Deprecate getHandle() method in favor of getNativeHandle()
/**
* Returns the native handle of the wrapped EGL object. This handle can be
* cast to the corresponding native type on the native side.
@@ -37,11 +45,27 @@
* @return the native handle of the wrapped EGL object.
*/
public int getHandle() {
- return mHandle;
+ if ((mHandle & 0xffffffffL) != mHandle) {
+ throw new UnsupportedOperationException();
+ }
+ return (int)mHandle;
}
+ // TODO Unhide getNativeHandle() method
+ /**
+ * {@hide}
+ */
+ public long getNativeHandle() {
+ return mHandle;
+ }
@Override
public int hashCode() {
- return getHandle();
+ /*
+ * Based on the algorithm suggested in
+ * http://developer.android.com/reference/java/lang/Object.html
+ */
+ int result = 17;
+ result = 31 * result + (int) (mHandle ^ (mHandle >>> 32));
+ return result;
}
}
diff --git a/opengl/java/android/opengl/EGLSurface.java b/opengl/java/android/opengl/EGLSurface.java
index c379dc9..c200f72 100644
--- a/opengl/java/android/opengl/EGLSurface.java
+++ b/opengl/java/android/opengl/EGLSurface.java
@@ -22,7 +22,7 @@
*
*/
public class EGLSurface extends EGLObjectHandle {
- private EGLSurface(int handle) {
+ private EGLSurface(long handle) {
super(handle);
}
@@ -32,6 +32,6 @@
if (!(o instanceof EGLSurface)) return false;
EGLSurface that = (EGLSurface) o;
- return getHandle() == that.getHandle();
+ return getNativeHandle() == that.getNativeHandle();
}
}
diff --git a/opengl/java/com/google/android/gles_jni/EGLConfigImpl.java b/opengl/java/com/google/android/gles_jni/EGLConfigImpl.java
index c2f4400..1902a40 100644
--- a/opengl/java/com/google/android/gles_jni/EGLConfigImpl.java
+++ b/opengl/java/com/google/android/gles_jni/EGLConfigImpl.java
@@ -19,13 +19,13 @@
import javax.microedition.khronos.egl.*;
public class EGLConfigImpl extends EGLConfig {
- private int mEGLConfig;
+ private long mEGLConfig;
- EGLConfigImpl(int config) {
+ EGLConfigImpl(long config) {
mEGLConfig = config;
}
- int get() {
+ long get() {
return mEGLConfig;
}
}
diff --git a/opengl/java/com/google/android/gles_jni/EGLContextImpl.java b/opengl/java/com/google/android/gles_jni/EGLContextImpl.java
index cd36099..47369ac 100644
--- a/opengl/java/com/google/android/gles_jni/EGLContextImpl.java
+++ b/opengl/java/com/google/android/gles_jni/EGLContextImpl.java
@@ -21,13 +21,13 @@
public class EGLContextImpl extends EGLContext {
private GLImpl mGLContext;
- int mEGLContext;
-
- public EGLContextImpl(int ctx) {
+ long mEGLContext;
+
+ public EGLContextImpl(long ctx) {
mEGLContext = ctx;
mGLContext = new GLImpl();
}
-
+
@Override
public GL getGL() {
return mGLContext;
@@ -45,6 +45,12 @@
@Override
public int hashCode() {
- return mEGLContext;
+ /*
+ * Based on the algorithm suggested in
+ * http://developer.android.com/reference/java/lang/Object.html
+ */
+ int result = 17;
+ result = 31 * result + (int) (mEGLContext ^ (mEGLContext >>> 32));
+ return result;
}
}
diff --git a/opengl/java/com/google/android/gles_jni/EGLDisplayImpl.java b/opengl/java/com/google/android/gles_jni/EGLDisplayImpl.java
index e6c9817..9b932fc 100644
--- a/opengl/java/com/google/android/gles_jni/EGLDisplayImpl.java
+++ b/opengl/java/com/google/android/gles_jni/EGLDisplayImpl.java
@@ -19,9 +19,9 @@
import javax.microedition.khronos.egl.*;
public class EGLDisplayImpl extends EGLDisplay {
- int mEGLDisplay;
+ long mEGLDisplay;
- public EGLDisplayImpl(int dpy) {
+ public EGLDisplayImpl(long dpy) {
mEGLDisplay = dpy;
}
@@ -38,6 +38,12 @@
@Override
public int hashCode() {
- return mEGLDisplay;
+ /*
+ * Based on the algorithm suggested in
+ * http://developer.android.com/reference/java/lang/Object.html
+ */
+ int result = 17;
+ result = 31 * result + (int) (mEGLDisplay ^ (mEGLDisplay >>> 32));
+ return result;
}
}
diff --git a/opengl/java/com/google/android/gles_jni/EGLImpl.java b/opengl/java/com/google/android/gles_jni/EGLImpl.java
index 64a54c2..41fb072 100644
--- a/opengl/java/com/google/android/gles_jni/EGLImpl.java
+++ b/opengl/java/com/google/android/gles_jni/EGLImpl.java
@@ -51,7 +51,7 @@
public static native int getInitCount(EGLDisplay display);
public EGLContext eglCreateContext(EGLDisplay display, EGLConfig config, EGLContext share_context, int[] attrib_list) {
- int eglContextId = _eglCreateContext(display, config, share_context, attrib_list);
+ long eglContextId = _eglCreateContext(display, config, share_context, attrib_list);
if (eglContextId == 0) {
return EGL10.EGL_NO_CONTEXT;
}
@@ -59,7 +59,7 @@
}
public EGLSurface eglCreatePbufferSurface(EGLDisplay display, EGLConfig config, int[] attrib_list) {
- int eglSurfaceId = _eglCreatePbufferSurface(display, config, attrib_list);
+ long eglSurfaceId = _eglCreatePbufferSurface(display, config, attrib_list);
if (eglSurfaceId == 0) {
return EGL10.EGL_NO_SURFACE;
}
@@ -87,7 +87,7 @@
sur = (Surface) native_window;
}
- int eglSurfaceId;
+ long eglSurfaceId;
if (sur != null) {
eglSurfaceId = _eglCreateWindowSurface(display, config, sur, attrib_list);
} else if (native_window instanceof SurfaceTexture) {
@@ -106,7 +106,7 @@
}
public synchronized EGLDisplay eglGetDisplay(Object native_display) {
- int value = _eglGetDisplay(native_display);
+ long value = _eglGetDisplay(native_display);
if (value == 0) {
return EGL10.EGL_NO_DISPLAY;
}
@@ -116,7 +116,7 @@
}
public synchronized EGLContext eglGetCurrentContext() {
- int value = _eglGetCurrentContext();
+ long value = _eglGetCurrentContext();
if (value == 0) {
return EGL10.EGL_NO_CONTEXT;
}
@@ -126,7 +126,7 @@
}
public synchronized EGLDisplay eglGetCurrentDisplay() {
- int value = _eglGetCurrentDisplay();
+ long value = _eglGetCurrentDisplay();
if (value == 0) {
return EGL10.EGL_NO_DISPLAY;
}
@@ -136,7 +136,7 @@
}
public synchronized EGLSurface eglGetCurrentSurface(int readdraw) {
- int value = _eglGetCurrentSurface(readdraw);
+ long value = _eglGetCurrentSurface(readdraw);
if (value == 0) {
return EGL10.EGL_NO_SURFACE;
}
@@ -145,15 +145,15 @@
return mSurface;
}
- private native int _eglCreateContext(EGLDisplay display, EGLConfig config, EGLContext share_context, int[] attrib_list);
- private native int _eglCreatePbufferSurface(EGLDisplay display, EGLConfig config, int[] attrib_list);
+ private native long _eglCreateContext(EGLDisplay display, EGLConfig config, EGLContext share_context, int[] attrib_list);
+ private native long _eglCreatePbufferSurface(EGLDisplay display, EGLConfig config, int[] attrib_list);
private native void _eglCreatePixmapSurface(EGLSurface sur, EGLDisplay display, EGLConfig config, Object native_pixmap, int[] attrib_list);
- private native int _eglCreateWindowSurface(EGLDisplay display, EGLConfig config, Object native_window, int[] attrib_list);
- private native int _eglCreateWindowSurfaceTexture(EGLDisplay display, EGLConfig config, Object native_window, int[] attrib_list);
- private native int _eglGetDisplay(Object native_display);
- private native int _eglGetCurrentContext();
- private native int _eglGetCurrentDisplay();
- private native int _eglGetCurrentSurface(int readdraw);
+ private native long _eglCreateWindowSurface(EGLDisplay display, EGLConfig config, Object native_window, int[] attrib_list);
+ private native long _eglCreateWindowSurfaceTexture(EGLDisplay display, EGLConfig config, Object native_window, int[] attrib_list);
+ private native long _eglGetDisplay(Object native_display);
+ private native long _eglGetCurrentContext();
+ private native long _eglGetCurrentDisplay();
+ private native long _eglGetCurrentSurface(int readdraw);
native private static void _nativeClassInit();
static { _nativeClassInit(); }
diff --git a/opengl/java/com/google/android/gles_jni/EGLSurfaceImpl.java b/opengl/java/com/google/android/gles_jni/EGLSurfaceImpl.java
index e7f15dc..7a3ed24 100644
--- a/opengl/java/com/google/android/gles_jni/EGLSurfaceImpl.java
+++ b/opengl/java/com/google/android/gles_jni/EGLSurfaceImpl.java
@@ -19,13 +19,13 @@
import javax.microedition.khronos.egl.*;
public class EGLSurfaceImpl extends EGLSurface {
- int mEGLSurface;
- private int mNativePixelRef;
+ long mEGLSurface;
+ private long mNativePixelRef;
public EGLSurfaceImpl() {
mEGLSurface = 0;
mNativePixelRef = 0;
}
- public EGLSurfaceImpl(int surface) {
+ public EGLSurfaceImpl(long surface) {
mEGLSurface = surface;
mNativePixelRef = 0;
}
@@ -43,6 +43,12 @@
@Override
public int hashCode() {
- return mEGLSurface;
+ /*
+ * Based on the algorithm suggested in
+ * http://developer.android.com/reference/java/lang/Object.html
+ */
+ int result = 17;
+ result = 31 * result + (int) (mEGLSurface ^ (mEGLSurface >>> 32));
+ return result;
}
}
diff --git a/packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java b/packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java
index 6e34bbb..48ef9db 100644
--- a/packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java
+++ b/packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java
@@ -30,6 +30,7 @@
import android.content.res.ObbInfo;
import android.content.res.ObbScanner;
import android.net.Uri;
+import android.os.Build;
import android.os.Environment;
import android.os.Environment.UserEnvironment;
import android.os.FileUtils;
@@ -39,10 +40,8 @@
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.StatFs;
-import android.os.SystemClock;
import android.provider.Settings;
import android.util.DisplayMetrics;
-import android.util.Log;
import android.util.Slog;
import com.android.internal.app.IMediaContainerService;
@@ -343,11 +342,13 @@
// The .apk file
String codePath = packageURI.getPath();
File codeFile = new File(codePath);
+ NativeLibraryHelper.ApkHandle handle = new NativeLibraryHelper.ApkHandle(codePath);
+ final int abi = NativeLibraryHelper.findSupportedAbi(handle, Build.SUPPORTED_ABIS);
// Calculate size of container needed to hold base APK.
final int sizeMb;
try {
- sizeMb = calculateContainerSize(codeFile, isForwardLocked);
+ sizeMb = calculateContainerSize(handle, codeFile, abi, isForwardLocked);
} catch (IOException e) {
Slog.w(TAG, "Problem when trying to copy " + codeFile.getPath());
return null;
@@ -410,7 +411,14 @@
final File sharedLibraryDir = new File(newCachePath, LIB_DIR_NAME);
if (sharedLibraryDir.mkdir()) {
- int ret = NativeLibraryHelper.copyNativeBinariesIfNeededLI(codeFile, sharedLibraryDir);
+ int ret = PackageManager.INSTALL_SUCCEEDED;
+ if (abi >= 0) {
+ ret = NativeLibraryHelper.copyNativeBinariesIfNeededLI(handle,
+ sharedLibraryDir, Build.SUPPORTED_ABIS[abi]);
+ } else if (abi != PackageManager.NO_NATIVE_LIBRARIES) {
+ ret = abi;
+ }
+
if (ret != PackageManager.INSTALL_SUCCEEDED) {
Slog.e(TAG, "Could not copy native libraries to " + sharedLibraryDir.getPath());
PackageHelper.destroySdDir(newCid);
@@ -824,6 +832,17 @@
return availSdMb > sizeMb;
}
+ private int calculateContainerSize(File apkFile, boolean forwardLocked) throws IOException {
+ NativeLibraryHelper.ApkHandle handle = new NativeLibraryHelper.ApkHandle(apkFile);
+ final int abi = NativeLibraryHelper.findSupportedAbi(handle, Build.SUPPORTED_ABIS);
+
+ try {
+ return calculateContainerSize(handle, apkFile, abi, forwardLocked);
+ } finally {
+ handle.close();
+ }
+ }
+
/**
* Calculate the container size for an APK. Takes into account the
*
@@ -831,7 +850,8 @@
* @return size in megabytes (2^20 bytes)
* @throws IOException when there is a problem reading the file
*/
- private int calculateContainerSize(File apkFile, boolean forwardLocked) throws IOException {
+ private int calculateContainerSize(NativeLibraryHelper.ApkHandle apkHandle,
+ File apkFile, int abiIndex, boolean forwardLocked) throws IOException {
// Calculate size of container needed to hold base APK.
long sizeBytes = apkFile.length();
if (sizeBytes == 0 && !apkFile.exists()) {
@@ -840,7 +860,10 @@
// Check all the native files that need to be copied and add that to the
// container size.
- sizeBytes += NativeLibraryHelper.sumNativeBinariesLI(apkFile);
+ if (abiIndex >= 0) {
+ sizeBytes += NativeLibraryHelper.sumNativeBinariesLI(apkHandle,
+ Build.SUPPORTED_ABIS[abiIndex]);
+ }
if (forwardLocked) {
sizeBytes += PackageHelper.extractPublicFiles(apkFile.getPath(), null);
diff --git a/packages/InputDevices/res/raw/keyboard_layout_arabic.kcm b/packages/InputDevices/res/raw/keyboard_layout_arabic.kcm
new file mode 100644
index 0000000..2a95cfe
--- /dev/null
+++ b/packages/InputDevices/res/raw/keyboard_layout_arabic.kcm
@@ -0,0 +1,319 @@
+# Copyright (C) 2013 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+#
+# Arabic (US-101 keys) keyboard layout.
+#
+
+type OVERLAY
+
+### ROW 1
+
+key GRAVE {
+ label: '`'
+ base, capslock: '\u0630'
+ shift: '\u0651'
+}
+
+key 1 {
+ label: '1'
+ base: '\u0661'
+ shift: '!'
+ capslock: '1'
+}
+
+key 2 {
+ label: '2'
+ base: '\u0662'
+ shift: '@'
+ capslock: '2'
+}
+
+key 3 {
+ label: '3'
+ base: '\u0663'
+ shift: '#'
+ capslock: '3'
+}
+
+key 4 {
+ label: '4'
+ base: '\u0664'
+ shift: '$'
+ capslock: '4'
+}
+
+key 5 {
+ label: '5'
+ base: '\u0665'
+ shift: '%'
+ capslock: '5'
+}
+
+key 6 {
+ label: '6'
+ base: '\u0666'
+ shift: '^'
+ capslock: '6'
+}
+
+key 7 {
+ label: '7'
+ base: '\u0667'
+ shift: '&'
+ capslock: '7'
+}
+
+key 8 {
+ label: '8'
+ base: '\u0668'
+ shift: '*'
+ capslock: '8'
+}
+
+key 9 {
+ label: '9'
+ base: '\u0669'
+ shift: '('
+ capslock: '9'
+}
+
+key 0 {
+ label: '0'
+ base: '\u0660'
+ shift: ')'
+ capslock: '0'
+}
+
+key MINUS {
+ label: '-'
+ base, capslock: '-'
+ shift: '_'
+}
+
+key EQUALS {
+ label: '='
+ base, capslock: '='
+ shift: '+'
+}
+
+### ROW 2
+
+key Q {
+ label: 'Q'
+ base, capslock: '\u0636'
+ shift: '\u064e'
+}
+
+key W {
+ label: 'W'
+ base, capslock: '\u0635'
+ shift: '\u064b'
+}
+
+key E {
+ label: 'E'
+ base, capslock: '\u062b'
+ shift: '\u064f'
+}
+
+key R {
+ label: 'R'
+ base, capslock: '\u0642'
+ shift: '\u064c'
+}
+
+key T {
+ label: 'T'
+ base, capslock: '\u0641'
+ shift: '\ufef9'
+}
+
+key Y {
+ label: 'Y'
+ base, capslock: '\u063a'
+ shift: '\u0625'
+}
+
+key U {
+ label: 'U'
+ base, capslock: '\u0639'
+ shift: '\u2018'
+}
+
+key I {
+ label: 'I'
+ base, capslock: '\u0647'
+ shift: '\u00f7'
+}
+
+key O {
+ label: 'O'
+ base, capslock: '\u062e'
+ shift: '\u00d7'
+}
+
+key P {
+ label: 'P'
+ base, capslock: '\u062d'
+ shift: '\u061b'
+}
+
+key LEFT_BRACKET {
+ label: '['
+ base, capslock: '\u062c'
+ shift: '<'
+}
+
+key RIGHT_BRACKET {
+ label: ']'
+ base, capslock: '\u062f'
+ shift: '>'
+}
+
+key BACKSLASH {
+ label: '\\'
+ base, capslock: '\\'
+ shift: '|'
+}
+
+### ROW 3
+
+key A {
+ label: 'A'
+ base, capslock: '\u0634'
+ shift: '\u0650'
+}
+
+key S {
+ label: 'S'
+ base, capslock: '\u0633'
+ shift: '\u064d'
+}
+
+key D {
+ label: 'D'
+ base, capslock: '\u064a'
+ shift: ']'
+}
+
+key F {
+ label: 'F'
+ base, capslock: '\u0628'
+ shift: '['
+}
+
+key G {
+ label: 'G'
+ base, capslock: '\u0644'
+ shift: '\ufef7'
+}
+
+key H {
+ label: 'H'
+ base, capslock: '\u0627'
+ shift: '\u0623'
+}
+
+key J {
+ label: 'J'
+ base, capslock: '\u062a'
+ shift: '\u0640'
+}
+
+key K {
+ label: 'K'
+ base, capslock: '\u0646'
+ shift: '\u060c'
+}
+
+key L {
+ label: 'L'
+ base, capslock: '\u0645'
+ shift: '/'
+}
+
+key SEMICOLON {
+ label: ';'
+ base, capslock: '\u0643'
+ shift: ':'
+}
+
+key APOSTROPHE {
+ label: '\''
+ base, capslock: '\u0637'
+ shift: '"'
+}
+
+### ROW 4
+
+key Z {
+ label: 'Z'
+ base, capslock: '\u0626'
+ shift: '~'
+}
+
+key X {
+ label: 'X'
+ base, capslock: '\u0621'
+ shift: '\u0652'
+}
+
+key C {
+ label: 'C'
+ base, capslock: '\u0624'
+ shift: '}'
+}
+
+key V {
+ label: 'V'
+ base, capslock: '\u0631'
+ shift: '{'
+}
+
+key B {
+ label: 'B'
+ base, capslock: '\ufefb'
+ shift: '\ufef5'
+}
+
+key N {
+ label: 'N'
+ base, capslock: '\u0649'
+ shift: '\u0622'
+}
+
+key M {
+ label: 'M'
+ base, capslock: '\u0629'
+ shift: '\u2019'
+}
+
+key COMMA {
+ label: ','
+ base, capslock: '\u0648'
+ shift: ','
+}
+
+key PERIOD {
+ label: '.'
+ base, capslock: '\u0632'
+ shift: '.'
+}
+
+key SLASH {
+ label: '/'
+ base, capslock: '\u0638'
+ shift: '\u061f'
+}
diff --git a/packages/InputDevices/res/raw/keyboard_layout_greek.kcm b/packages/InputDevices/res/raw/keyboard_layout_greek.kcm
new file mode 100644
index 0000000..a7684e1
--- /dev/null
+++ b/packages/InputDevices/res/raw/keyboard_layout_greek.kcm
@@ -0,0 +1,338 @@
+# Copyright (C) 2013 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+#
+# Greek (EU based) keyboard layout.
+#
+
+type OVERLAY
+
+map key 86 PLUS
+
+### ROW 1
+
+key GRAVE {
+ label: '`'
+ base, capslock: '`'
+ shift: '~'
+}
+
+key 1 {
+ label: '1'
+ base, capslock: '1'
+ shift: '!'
+}
+
+key 2 {
+ label: '2'
+ base, capslock: '2'
+ shift: '@'
+ ralt: '\u00b2'
+}
+
+key 3 {
+ label: '3'
+ base, capslock: '3'
+ shift: '#'
+ ralt: '\u00b3'
+}
+
+key 4 {
+ label: '4'
+ base, capslock: '4'
+ shift: '$'
+ ralt: '\u00a3'
+}
+
+key 5 {
+ label: '5'
+ base, capslock: '5'
+ shift: '%'
+ ralt: '\u00a7'
+}
+
+key 6 {
+ label: '6'
+ base, capslock: '6'
+ shift: '^'
+ ralt: '\u00b6'
+}
+
+key 7 {
+ label: '7'
+ base, capslock: '7'
+ shift: '&'
+}
+
+key 8 {
+ label: '8'
+ base, capslock: '8'
+ shift: '*'
+ ralt: '\u00a4'
+}
+
+key 9 {
+ label: '9'
+ base, capslock: '9'
+ shift: '('
+ ralt: '\u00a6'
+}
+
+key 0 {
+ label: '0'
+ base, capslock: '0'
+ shift: ')'
+ ralt: '\u00b0'
+}
+
+key MINUS {
+ label: '-'
+ base, capslock: '-'
+ shift: '_'
+ ralt: '\u00b1'
+}
+
+key EQUALS {
+ label: '='
+ base, capslock: '='
+ shift: '+'
+ ralt: '\u00bd'
+}
+
+### ROW 2
+
+key Q {
+ label: 'Q'
+ base, capslock: ';'
+ shift: ':'
+}
+
+key W {
+ label: 'W'
+ base, capslock: '\u03c2'
+ shift: '\u0385'
+}
+
+key E {
+ label: 'E'
+ base: '\u03b5'
+ shift, capslock: '\u0395'
+ ralt: '\u20ac'
+}
+
+key R {
+ label: 'R'
+ base: '\u03c1'
+ shift, capslock: '\u03a1'
+ ralt: '\u00ae'
+}
+
+key T {
+ label: 'T'
+ base: '\u03c4'
+ shift, capslock: '\u03a4'
+}
+
+key Y {
+ label: 'Y'
+ base: '\u03c5'
+ shift, capslock: '\u03a5'
+ ralt: '\u00a5'
+}
+
+key U {
+ label: 'U'
+ base: '\u03b8'
+ shift, capslock: '\u0398'
+}
+
+key I {
+ label: 'I'
+ base: '\u03b9'
+ shift, capslock: '\u0399'
+}
+
+key O {
+ label: 'O'
+ base: '\u03bf'
+ shift, capslock: '\u039f'
+}
+
+key P {
+ label: 'P'
+ base: '\u03c0'
+ shift, capslock: '\u03a0'
+}
+
+key LEFT_BRACKET {
+ label: '['
+ base, capslock: '['
+ shift: '{'
+ ralt: '\u00ab'
+}
+
+key RIGHT_BRACKET {
+ label: ']'
+ base, capslock: ']'
+ shift: '}'
+ ralt: '\u00bb'
+}
+
+### ROW 3
+
+key A {
+ label: 'A'
+ base: '\u03b1'
+ shift, capslock: '\u0391'
+}
+
+key S {
+ label: 'S'
+ base: '\u03c3'
+ shift, capslock: '\u03a3'
+}
+
+key D {
+ label: 'D'
+ base: '\u03b4'
+ shift, capslock: '\u0394'
+}
+
+key F {
+ label: 'F'
+ base: '\u03c6'
+ shift, capslock: '\u03a6'
+}
+
+key G {
+ label: 'G'
+ base: '\u03b3'
+ shift, capslock: '\u0393'
+}
+
+key H {
+ label: 'H'
+ base: '\u03b7'
+ shift, capslock: '\u0397'
+}
+
+key J {
+ label: 'J'
+ base: '\u03be'
+ shift, capslock: '\u039e'
+}
+
+key K {
+ label: 'K'
+ base: '\u03ba'
+ shift, capslock: '\u039a'
+}
+
+key L {
+ label: 'L'
+ base: '\u03bb'
+ shift, capslock: '\u039b'
+}
+
+key SEMICOLON {
+ label: ';'
+ base, capslock: '\u0301'
+#should be \u0384 (greek tonos)
+ shift: '\u0308'
+ ralt: '\u0385'
+}
+
+key APOSTROPHE {
+ label: '\''
+ base, capslock: '\''
+ shift: '"'
+}
+
+key BACKSLASH {
+ label: '\\'
+ base, capslock: '\\'
+ shift: '|'
+ ralt: '\u00ac'
+}
+
+### ROW 4
+
+key PLUS {
+ label: '<'
+ base, capslock: '<'
+ shift: '>'
+ ralt: '\\'
+ shift+ralt: '|'
+}
+
+key Z {
+ label: 'Z'
+ base: '\u03b6'
+ shift, capslock: '\u0396'
+}
+
+key X {
+ label: 'X'
+ base: '\u03c7'
+ shift, capslock: '\u03a7'
+}
+
+key C {
+ label: 'C'
+ base: '\u03c8'
+ shift, capslock: '\u03a8'
+ ralt: '\u00a9'
+}
+
+key V {
+ label: 'V'
+ base: '\u03c9'
+ shift, capslock: '\u03a9'
+}
+
+key B {
+ label: 'B'
+ base: '\u03b2'
+ shift, capslock: '\u0392'
+}
+
+key N {
+ label: 'N'
+ base: '\u03bd'
+ shift, capslock: '\u039d'
+}
+
+key M {
+ label: 'M'
+ base: '\u03bc'
+ shift, capslock: '\u039c'
+}
+
+key COMMA {
+ label: ','
+ base, capslock: ','
+ shift: '<'
+}
+
+key PERIOD {
+ label: '.'
+ base, capslock: '.'
+ shift: '>'
+}
+
+key SLASH {
+ label: '/'
+ base, capslock: '/'
+ shift: '?'
+}
diff --git a/packages/InputDevices/res/raw/keyboard_layout_hebrew.kcm b/packages/InputDevices/res/raw/keyboard_layout_hebrew.kcm
new file mode 100644
index 0000000..cd3a4b9
--- /dev/null
+++ b/packages/InputDevices/res/raw/keyboard_layout_hebrew.kcm
@@ -0,0 +1,341 @@
+# Copyright (C) 2013 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+#
+# Hebrew (based EU) keyboard layout.
+#
+
+type OVERLAY
+
+map key 86 PLUS
+
+### ROW 1
+
+key GRAVE {
+ label: '`'
+ base: ';'
+ shift: '~'
+ shift+capslock: '\u05b0'
+}
+
+key 1 {
+ label: '1'
+ base: '1'
+ shift: '!'
+ shift+capslock: '\u05b1'
+}
+
+key 2 {
+ label: '2'
+ base: '2'
+ shift: '@'
+ shift+capslock: '\u05b2'
+}
+
+key 3 {
+ label: '3'
+ base: '3'
+ shift: '#'
+ shift+capslock: '\u05b3'
+}
+
+key 4 {
+ label: '4'
+ base: '4'
+ shift: '$'
+ ralt: '\u20aa'
+ shift+capslock: '\u05b4'
+}
+
+key 5 {
+ label: '5'
+ base: '5'
+ shift: '%'
+ shift+capslock: '\u05b5'
+}
+
+key 6 {
+ label: '6'
+ base: '6'
+ shift: '^'
+ shift+capslock: '\u05b6'
+}
+
+key 7 {
+ label: '7'
+ base: '7'
+ shift: '&'
+ shift+capslock: '\u05b7'
+}
+
+key 8 {
+ label: '8'
+ base: '8'
+ shift: '*'
+ shift+capslock: '\u05b8'
+}
+
+key 9 {
+ label: '9'
+ base: '9'
+ shift: '('
+ shift+capslock: '\u05c2'
+}
+
+key 0 {
+ label: '0'
+ base: '0'
+ shift: ')'
+ shift+capslock: '\u05c1'
+}
+
+key MINUS {
+ label: '-'
+ base: '-'
+ shift: '_'
+ ralt: '\u05bf'
+ shift+capslock: '\u05b9'
+}
+
+key EQUALS {
+ label: '='
+ base: '='
+ shift: '+'
+ shift+capslock: '\u05bc'
+}
+
+### ROW 2
+
+key Q {
+ label: 'Q'
+ base: '/'
+ shift, capslock: 'Q'
+}
+
+key W {
+ label: 'W'
+ base: '\u0027'
+ shift, capslock: 'W'
+}
+
+key E {
+ label: 'E'
+ base: '\u05e7'
+ shift, capslock: 'E'
+ ralt: '\u20ac'
+}
+
+key R {
+ label: 'R'
+ base: '\u05e8'
+ shift, capslock: 'R'
+}
+
+key T {
+ label: 'T'
+ base: '\u05d0'
+ shift, capslock: 'T'
+}
+
+key Y {
+ label: 'Y'
+ base: '\u05d8'
+ shift, capslock: 'Y'
+}
+
+key U {
+ label: 'U'
+ base: '\u05d5'
+ shift, capslock: 'U'
+ ralt: '\u05f0'
+}
+
+key I {
+ label: 'I'
+ base: '\u05df'
+ shift, capslock: 'I'
+}
+
+key O {
+ label: 'O'
+ base: '\u05dd'
+ shift, capslock: 'O'
+}
+
+key P {
+ label: 'P'
+ base: '\u05e4'
+ shift, capslock: 'P'
+}
+
+key LEFT_BRACKET {
+ label: '['
+ base, capslock: '['
+ shift: '{'
+}
+
+key RIGHT_BRACKET {
+ label: ']'
+ base, capslock: ']'
+ shift: '}'
+}
+
+### ROW 3
+
+key A {
+ label: 'A'
+ base: '\u05e9'
+ shift, capslock: 'A'
+}
+
+key S {
+ label: 'S'
+ base: '\u05d3'
+ shift, capslock: 'S'
+}
+
+key D {
+ label: 'D'
+ base: '\u05d2'
+ shift, capslock: 'D'
+}
+
+key F {
+ label: 'F'
+ base: '\u05db'
+ shift, capslock: 'F'
+}
+
+key G {
+ label: 'G'
+ base: '\u05e2'
+ shift, capslock: 'G'
+}
+
+key H {
+ label: 'H'
+ base: '\u05d9'
+ shift, capslock: 'H'
+ ralt: '\u05f2'
+}
+
+key J {
+ label: 'J'
+ base: '\u05d7'
+ shift, capslock: 'J'
+ ralt: '\u05f1'
+}
+
+key K {
+ label: 'K'
+ base: '\u05dc'
+ shift, capslock: 'K'
+}
+
+key L {
+ label: 'L'
+ base: '\u05da'
+ shift, capslock: 'L'
+}
+
+key SEMICOLON {
+ label: ';'
+ base: '\u05e3'
+ shift: ':'
+ capslock: ';'
+}
+
+key APOSTROPHE {
+ label: '\''
+ base: ','
+ shift: '"'
+ capslock: '\''
+}
+
+key BACKSLASH {
+ label: '\\'
+ base: '\\'
+ shift: '|'
+}
+
+### ROW 4
+
+key PLUS {
+ label: '\\'
+ base, capslock: '\\'
+ shift: '|'
+}
+
+key Z {
+ label: 'Z'
+ base: '\u05d6'
+ shift, capslock: 'Z'
+}
+
+key X {
+ label: 'X'
+ base: '\u05e1'
+ shift, capslock: 'X'
+}
+
+key C {
+ label: 'C'
+ base: '\u05d1'
+ shift, capslock: 'C'
+}
+
+key V {
+ label: 'V'
+ base: '\u05d4'
+ shift, capslock: 'V'
+}
+
+key B {
+ label: 'B'
+ base: '\u05e0'
+ shift, capslock: 'B'
+}
+
+key N {
+ label: 'N'
+ base: '\u05de'
+ shift, capslock: 'N'
+}
+
+key M {
+ label: 'M'
+ base: '\u05e6'
+ shift, capslock: 'M'
+}
+
+key COMMA {
+ label: ','
+ base: '\u05ea'
+ shift: '<'
+ capslock: ','
+}
+
+key PERIOD {
+ label: '.'
+ base: '\u05e5'
+ shift: '>'
+ capslock: '.'
+}
+
+key SLASH {
+ label: '/'
+ base: '.'
+ shift: '?'
+ capslock: '/'
+}
diff --git a/packages/InputDevices/res/raw/keyboard_layout_lithuanian.kcm b/packages/InputDevices/res/raw/keyboard_layout_lithuanian.kcm
new file mode 100644
index 0000000..72ca333
--- /dev/null
+++ b/packages/InputDevices/res/raw/keyboard_layout_lithuanian.kcm
@@ -0,0 +1,338 @@
+# Copyright (C) 2013 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+#
+# Lithuanian (EU based) keyboard layout.
+#
+
+type OVERLAY
+
+map key 86 PLUS
+
+### ROW 1
+
+key GRAVE {
+ label: '`'
+ base: '`'
+ shift: '~'
+}
+
+key 1 {
+ label: '1'
+ base: '\u0105'
+ shift, capslock: '\u0104'
+ ralt: '1'
+ shift+ralt: '!'
+}
+
+key 2 {
+ label: '2'
+ base: '\u010d'
+ shift, capslock: '\u010c'
+ ralt: '2'
+ shift+ralt: '@'
+}
+
+key 3 {
+ label: '3'
+ base: '\u0119'
+ shift, capslock: '\u0118'
+ ralt: '3'
+ shift+ralt: '#'
+}
+
+key 4 {
+ label: '4'
+ base: '\u0117'
+ shift, capslock: '\u0116'
+ ralt: '4'
+ shift+ralt: '$'
+}
+
+key 5 {
+ label: '5'
+ base: '\u012f'
+ shift, capslock: '\u012e'
+ ralt: '5'
+ shift+ralt: '%'
+}
+
+key 6 {
+ label: '6'
+ base: '\u0161'
+ shift, capslock: '\u0160'
+ ralt: '6'
+ shift+ralt: '\u0302'
+}
+
+key 7 {
+ label: '7'
+ base: '\u0173'
+ shift, capslock: '\u0172'
+ ralt: '7'
+ shift+ralt: '&'
+}
+
+key 8 {
+ label: '8'
+ base: '\u016b'
+ shift, capslock: '\u016a'
+ ralt: '8'
+ shift+ralt: '*'
+}
+
+key 9 {
+ label: '9'
+ base: '9'
+ shift: '('
+ ralt: '9'
+}
+
+key 0 {
+ label: '0'
+ base: '0'
+ shift: ')'
+ ralt: '0'
+}
+
+key MINUS {
+ label: '-'
+ base: '-'
+ shift: '_'
+}
+
+key EQUALS {
+ label: '='
+ base: '\u017e'
+ shift, capslock: '\u017d'
+ ralt: '='
+ shift+ralt: '+'
+}
+
+### ROW 2
+
+key Q {
+ label: 'Q'
+ base: 'q'
+ shift, capslock: 'Q'
+}
+
+key W {
+ label: 'W'
+ base: 'w'
+ shift, capslock: 'W'
+}
+
+key E {
+ label: 'E'
+ base: 'e'
+ shift, capslock: 'E'
+ ralt: '\u20ac'
+}
+
+key R {
+ label: 'R'
+ base: 'r'
+ shift, capslock: 'R'
+}
+
+key T {
+ label: 'T'
+ base: 't'
+ shift, capslock: 'T'
+}
+
+key Y {
+ label: 'Y'
+ base: 'y'
+ shift, capslock: 'Y'
+}
+
+key U {
+ label: 'U'
+ base: 'u'
+ shift, capslock: 'U'
+}
+
+key I {
+ label: 'I'
+ base: 'i'
+ shift, capslock: 'I'
+}
+
+key O {
+ label: 'O'
+ base: 'o'
+ shift, capslock: 'O'
+}
+
+key P {
+ label: 'P'
+ base: 'p'
+ shift, capslock: 'P'
+}
+
+key LEFT_BRACKET {
+ label: '['
+ base: '['
+ shift: '{'
+}
+
+key RIGHT_BRACKET {
+ label: ']'
+ base: ']'
+ shift: '}'
+}
+
+### ROW 3
+
+key A {
+ label: 'A'
+ base: 'a'
+ shift, capslock: 'A'
+}
+
+key S {
+ label: 'S'
+ base: 's'
+ shift, capslock: 'S'
+}
+
+key D {
+ label: 'D'
+ base: 'd'
+ shift, capslock: 'D'
+}
+
+key F {
+ label: 'F'
+ base: 'f'
+ shift, capslock: 'F'
+}
+
+key G {
+ label: 'G'
+ base: 'g'
+ shift, capslock: 'G'
+}
+
+key H {
+ label: 'H'
+ base: 'h'
+ shift, capslock: 'H'
+}
+
+key J {
+ label: 'J'
+ base: 'j'
+ shift, capslock: 'J'
+}
+
+key K {
+ label: 'K'
+ base: 'k'
+ shift, capslock: 'K'
+}
+
+key L {
+ label: 'L'
+ base: 'l'
+ shift, capslock: 'L'
+}
+
+key SEMICOLON {
+ label: ';'
+ base: ';'
+ shift: ':'
+}
+
+key APOSTROPHE {
+ label: '\''
+ base: '\''
+ shift: '"'
+}
+
+key BACKSLASH {
+ label: '\\'
+ base: '\\'
+ shift: '|'
+}
+
+### ROW 4
+
+key PLUS {
+ label: '\\'
+ base: '\\'
+ shift: '|'
+}
+
+key Z {
+ label: 'Z'
+ base: 'z'
+ shift, capslock: 'Z'
+}
+
+key X {
+ label: 'X'
+ base: 'x'
+ shift, capslock: 'X'
+}
+
+key C {
+ label: 'C'
+ base: 'c'
+ shift, capslock: 'C'
+}
+
+key V {
+ label: 'V'
+ base: 'v'
+ shift, capslock: 'V'
+}
+
+key B {
+ label: 'B'
+ base: 'b'
+ shift, capslock: 'B'
+}
+
+key N {
+ label: 'N'
+ base: 'n'
+ shift, capslock: 'N'
+}
+
+key M {
+ label: 'M'
+ base: 'm'
+ shift, capslock: 'M'
+}
+
+key COMMA {
+ label: ','
+ base: ','
+ shift: '<'
+}
+
+key PERIOD {
+ label: '.'
+ base: '.'
+ shift: '>'
+}
+
+key SLASH {
+ label: '/'
+ base: '/'
+ shift: '?'
+}
diff --git a/packages/InputDevices/res/raw/keyboard_layout_spanish_latin.kcm b/packages/InputDevices/res/raw/keyboard_layout_spanish_latin.kcm
new file mode 100644
index 0000000..16eb53f
--- /dev/null
+++ b/packages/InputDevices/res/raw/keyboard_layout_spanish_latin.kcm
@@ -0,0 +1,325 @@
+# Copyright (C) 2013 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+#
+# Spanish (Latin) (EU based) keyboard layout.
+#
+
+type OVERLAY
+
+map key 86 PLUS
+
+### ROW 1
+
+key GRAVE {
+ label: '|'
+ base: '|'
+ shift: '\u00ba'
+ ralt: '\u00ac'
+}
+
+key 1 {
+ label: '1'
+ base: '1'
+ shift: '!'
+}
+
+key 2 {
+ label: '2'
+ base: '2'
+ shift: '"'
+}
+
+key 3 {
+ label: '3'
+ base: '3'
+ shift: '#'
+}
+
+key 4 {
+ label: '4'
+ base: '4'
+ shift: '$'
+
+}
+
+key 5 {
+ label: '5'
+ base: '5'
+ shift: '%'
+}
+
+key 6 {
+ label: '6'
+ base: '6'
+ shift: '&'
+}
+
+key 7 {
+ label: '7'
+ base: '7'
+ shift: '/'
+}
+
+key 8 {
+ label: '8'
+ base: '8'
+ shift: '('
+}
+
+key 9 {
+ label: '9'
+ base: '9'
+ shift: ')'
+}
+
+key 0 {
+ label: '0'
+ base: '0'
+ shift: '='
+}
+
+key MINUS {
+ label: '\''
+ base: '\''
+ shift: '?'
+ ralt: '\\'
+}
+
+key EQUALS {
+ label: '\u00bf'
+ base: '\u00bf'
+ shift: '\u00a1'
+}
+
+### ROW 2
+
+key Q {
+ label: 'Q'
+ base: 'q'
+ shift, capslock: 'Q'
+ ralt: '@'
+}
+
+key W {
+ label: 'W'
+ base: 'w'
+ shift, capslock: 'W'
+}
+
+key E {
+ label: 'E'
+ base: 'e'
+ shift, capslock: 'E'
+}
+
+key R {
+ label: 'R'
+ base: 'r'
+ shift, capslock: 'R'
+}
+
+key T {
+ label: 'T'
+ base: 't'
+ shift, capslock: 'T'
+}
+
+key Y {
+ label: 'Y'
+ base: 'y'
+ shift, capslock: 'Y'
+}
+
+key U {
+ label: 'U'
+ base: 'u'
+ shift, capslock: 'U'
+}
+
+key I {
+ label: 'I'
+ base: 'i'
+ shift, capslock: 'I'
+}
+
+key O {
+ label: 'O'
+ base: 'o'
+ shift, capslock: 'O'
+}
+
+key P {
+ label: 'P'
+ base: 'p'
+ shift, capslock: 'P'
+}
+
+key LEFT_BRACKET {
+ label: '\u00b4'
+ base: '\u0301'
+ shift: '\u0308'
+ ralt: '['
+}
+
+key RIGHT_BRACKET {
+ label: '+'
+ base: '+'
+ shift: '*'
+ ralt: '\u0303'
+}
+
+### ROW 3
+
+key A {
+ label: 'A'
+ base: 'a'
+ shift, capslock: 'A'
+}
+
+key S {
+ label: 'S'
+ base: 's'
+ shift, capslock: 'S'
+}
+
+key D {
+ label: 'D'
+ base: 'd'
+ shift, capslock: 'D'
+}
+
+key F {
+ label: 'F'
+ base: 'f'
+ shift, capslock: 'F'
+}
+
+key G {
+ label: 'G'
+ base: 'g'
+ shift, capslock: 'G'
+}
+
+key H {
+ label: 'H'
+ base: 'h'
+ shift, capslock: 'H'
+}
+
+key J {
+ label: 'J'
+ base: 'j'
+ shift, capslock: 'J'
+}
+
+key K {
+ label: 'K'
+ base: 'k'
+ shift, capslock: 'K'
+}
+
+key L {
+ label: 'L'
+ base: 'l'
+ shift, capslock: 'L'
+}
+
+key SEMICOLON {
+ label: '\u00d1'
+ base: '\u00f1'
+ shift, capslock: '\u00d1'
+}
+
+key APOSTROPHE {
+ label: '{'
+ base: '{'
+ shift: '['
+ ralt: '\u0302'
+}
+
+key BACKSLASH {
+ label: '}'
+ base: '}'
+ shift: ']'
+ ralt: '\u0300'
+}
+
+### ROW 4
+
+key PLUS {
+ label: '<'
+ base: '<'
+ shift: '>'
+}
+
+key Z {
+ label: 'Z'
+ base: 'z'
+ shift, capslock: 'Z'
+}
+
+key X {
+ label: 'X'
+ base: 'x'
+ shift, capslock: 'X'
+}
+
+key C {
+ label: 'C'
+ base: 'c'
+ shift, capslock: 'C'
+}
+
+key V {
+ label: 'V'
+ base: 'v'
+ shift, capslock: 'V'
+}
+
+key B {
+ label: 'B'
+ base: 'b'
+ shift, capslock: 'B'
+}
+
+key N {
+ label: 'N'
+ base: 'n'
+ shift, capslock: 'N'
+}
+
+key M {
+ label: 'M'
+ base: 'm'
+ shift, capslock: 'M'
+}
+
+key COMMA {
+ label: ','
+ base: ','
+ shift: ';'
+}
+
+key PERIOD {
+ label: '.'
+ base: '.'
+ shift: ':'
+}
+
+key SLASH {
+ label: '-'
+ base: '-'
+ shift: '_'
+}
diff --git a/packages/InputDevices/res/values/strings.xml b/packages/InputDevices/res/values/strings.xml
index 54c18f1..6239336 100644
--- a/packages/InputDevices/res/values/strings.xml
+++ b/packages/InputDevices/res/values/strings.xml
@@ -98,4 +98,19 @@
<!-- Ukrainian keyboard layout label. [CHAR LIMIT=35] -->
<string name="keyboard_layout_ukrainian">Ukrainian</string>
+
+ <!-- Arabic keyboard layout label. [CHAR LIMIT=35] -->
+ <string name="keyboard_layout_arabic">Arabic</string>
+
+ <!-- Greek keyboard layout label. [CHAR LIMIT=35] -->
+ <string name="keyboard_layout_greek">Greek</string>
+
+ <!-- Hebrew keyboard layout label. [CHAR LIMIT=35] -->
+ <string name="keyboard_layout_hebrew">Hebrew</string>
+
+ <!-- Lithuanian keyboard layout label. [CHAR LIMIT=35] -->
+ <string name="keyboard_layout_lithuanian">Lithuanian</string>
+
+ <!-- Spanish (Latin) keyboard layout label. [CHAR LIMIT=35] -->
+ <string name="keyboard_layout_spanish_latin">Spanish (Latin)</string>
</resources>
diff --git a/packages/InputDevices/res/xml/keyboard_layouts.xml b/packages/InputDevices/res/xml/keyboard_layouts.xml
index 1f48a36..dc1db0b 100644
--- a/packages/InputDevices/res/xml/keyboard_layouts.xml
+++ b/packages/InputDevices/res/xml/keyboard_layouts.xml
@@ -123,4 +123,24 @@
<keyboard-layout android:name="keyboard_layout_ukrainian"
android:label="@string/keyboard_layout_ukrainian"
android:keyboardLayout="@raw/keyboard_layout_ukrainian" />
+
+ <keyboard-layout android:name="keyboard_layout_arabic"
+ android:label="@string/keyboard_layout_arabic"
+ android:keyboardLayout="@raw/keyboard_layout_arabic" />
+
+ <keyboard-layout android:name="keyboard_layout_greek"
+ android:label="@string/keyboard_layout_greek"
+ android:keyboardLayout="@raw/keyboard_layout_greek" />
+
+ <keyboard-layout android:name="keyboard_layout_hebrew"
+ android:label="@string/keyboard_layout_hebrew"
+ android:keyboardLayout="@raw/keyboard_layout_hebrew" />
+
+ <keyboard-layout android:name="keyboard_layout_lithuanian"
+ android:label="@string/keyboard_layout_lithuanian"
+ android:keyboardLayout="@raw/keyboard_layout_lithuanian" />
+
+ <keyboard-layout android:name="keyboard_layout_spanish_latin"
+ android:label="@string/keyboard_layout_spanish_latin"
+ android:keyboardLayout="@raw/keyboard_layout_spanish_latin" />
</keyboard-layouts>
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardSimPukView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardSimPukView.java
index 6e9e83e..d882eca 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardSimPukView.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardSimPukView.java
@@ -274,7 +274,7 @@
private boolean checkPuk() {
// make sure the puk is at least 8 digits long.
- if (mPasswordEntry.getText().length() >= 8) {
+ if (mPasswordEntry.getText().length() == 8) {
mPukText = mPasswordEntry.getText().toString();
return true;
}
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardViewManager.java b/packages/Keyguard/src/com/android/keyguard/KeyguardViewManager.java
index 6aa0a4b..7d0059f 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardViewManager.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardViewManager.java
@@ -388,6 +388,7 @@
} else {
mWindowLayoutParams.flags &= ~WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER;
}
+ mWindowLayoutParams.format = show ? PixelFormat.TRANSLUCENT : PixelFormat.OPAQUE;
mViewManager.updateViewLayout(mKeyguardHost, mWindowLayoutParams);
}
diff --git a/packages/SettingsProvider/res/values/defaults.xml b/packages/SettingsProvider/res/values/defaults.xml
index a1d8f22..da3ca0f 100644
--- a/packages/SettingsProvider/res/values/defaults.xml
+++ b/packages/SettingsProvider/res/values/defaults.xml
@@ -173,4 +173,8 @@
0 means no timeout; battery sounds will always play
>0 is milliseconds of screen-off time after which battery sounds will not play -->
<integer name="def_low_battery_sound_timeout">0</integer>
+
+ <!-- Default for Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE -->
+ <integer name="def_wifi_scan_always_available">0</integer>
+
</resources>
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
index 09c21f3..ed86f42 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
@@ -2274,6 +2274,9 @@
loadIntegerSetting(stmt, Settings.Global.LOW_BATTERY_SOUND_TIMEOUT,
R.integer.def_low_battery_sound_timeout);
+ loadIntegerSetting(stmt, Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE,
+ R.integer.def_wifi_scan_always_available);
+
// --- New global settings start here
} finally {
if (stmt != null) stmt.close();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
index 839016d..9589e8b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
@@ -521,6 +521,11 @@
Log.d(TAG, "reorient(): rot=" + mDisplay.getRotation());
}
+ // swap to x coordinate if orientation is not in vertical
+ if (mDelegateHelper != null) {
+ mDelegateHelper.setSwapXY(!mVertical);
+ }
+
setNavigationIconHints(mNavigationIconHints, true);
}
diff --git a/packages/services/PacProcessor/jni/Android.mk b/packages/services/PacProcessor/jni/Android.mk
index f16c90b..8a60927 100644
--- a/packages/services/PacProcessor/jni/Android.mk
+++ b/packages/services/PacProcessor/jni/Android.mk
@@ -35,6 +35,7 @@
LOCAL_MODULE := libjni_pacprocessor
LOCAL_MODULE_TAGS := optional
+LOCAL_32_BIT_ONLY := true
include external/stlport/libstlport.mk
diff --git a/policy/src/com/android/internal/policy/impl/GlobalActions.java b/policy/src/com/android/internal/policy/impl/GlobalActions.java
index 7c0735b..4db7d4d 100644
--- a/policy/src/com/android/internal/policy/impl/GlobalActions.java
+++ b/policy/src/com/android/internal/policy/impl/GlobalActions.java
@@ -121,13 +121,14 @@
filter.addAction(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED);
context.registerReceiver(mBroadcastReceiver, filter);
+ ConnectivityManager cm = (ConnectivityManager)
+ context.getSystemService(Context.CONNECTIVITY_SERVICE);
+ mHasTelephony = cm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE);
+
// get notified of phone state changes
TelephonyManager telephonyManager =
(TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
telephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_SERVICE_STATE);
- ConnectivityManager cm = (ConnectivityManager)
- context.getSystemService(Context.CONNECTIVITY_SERVICE);
- mHasTelephony = cm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE);
mContext.getContentResolver().registerContentObserver(
Settings.Global.getUriFor(Settings.Global.AIRPLANE_MODE_ON), true,
mAirplaneModeObserver);
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
index c33bd35..aeaa18f 100644
--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -3984,7 +3984,7 @@
telephonyService.silenceRinger();
} else if ((mIncallPowerBehavior
& Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_HANGUP) != 0
- && telephonyService.isOffhook()) {
+ && telephonyService.isOffhook() && isScreenOn) {
// Otherwise, if "Power button ends call" is enabled,
// the Power button will hang up any current active call.
hungUp = telephonyService.endCall();
diff --git a/preloaded-classes b/preloaded-classes
index 342126d..b60a379 100644
--- a/preloaded-classes
+++ b/preloaded-classes
@@ -400,7 +400,6 @@
android.ddm.DdmHandleThread
android.ddm.DdmHandleViewDebug
android.ddm.DdmRegister
-android.debug.JNITest
android.drm.DrmManagerClient
android.emoji.EmojiFactory
android.graphics.AvoidXfermode
@@ -2456,8 +2455,6 @@
org.apache.harmony.security.fortress.Engine$SpiAndProvider
org.apache.harmony.security.fortress.SecurityAccess
org.apache.harmony.security.fortress.Services
-org.apache.harmony.security.provider.cert.DRLCertFactory
-org.apache.harmony.security.provider.cert.X509CertImpl
org.apache.harmony.security.provider.crypto.CryptoProvider
org.apache.harmony.security.utils.AlgNameMapper
org.apache.harmony.security.utils.ObjectIdentifier
diff --git a/graphics/java/android/renderscript/Allocation.java b/rs/java/android/renderscript/Allocation.java
similarity index 85%
rename from graphics/java/android/renderscript/Allocation.java
rename to rs/java/android/renderscript/Allocation.java
index dca934f..c2bab91 100644
--- a/graphics/java/android/renderscript/Allocation.java
+++ b/rs/java/android/renderscript/Allocation.java
@@ -24,7 +24,6 @@
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.view.Surface;
-import android.graphics.SurfaceTexture;
import android.util.Log;
import android.util.TypedValue;
import android.graphics.Canvas;
@@ -78,10 +77,69 @@
int mCurrentDimY;
int mCurrentDimZ;
int mCurrentCount;
- static HashMap<Integer, Allocation> mAllocationMap =
- new HashMap<Integer, Allocation>();
+ static HashMap<Long, Allocation> mAllocationMap =
+ new HashMap<Long, Allocation>();
OnBufferAvailableListener mBufferNotifier;
+ private Element.DataType validateObjectIsPrimitiveArray(Object d, boolean checkType) {
+ final Class c = d.getClass();
+ if (!c.isArray()) {
+ throw new RSIllegalArgumentException("Object passed is not an array of primitives.");
+ }
+ final Class cmp = c.getComponentType();
+ if (!cmp.isPrimitive()) {
+ throw new RSIllegalArgumentException("Object passed is not an Array of primitives.");
+ }
+
+ if (cmp == Long.TYPE) {
+ if (checkType) {
+ validateIsInt64();
+ return mType.mElement.mType;
+ }
+ return Element.DataType.SIGNED_64;
+ }
+
+ if (cmp == Integer.TYPE) {
+ if (checkType) {
+ validateIsInt32();
+ return mType.mElement.mType;
+ }
+ return Element.DataType.SIGNED_32;
+ }
+
+ if (cmp == Short.TYPE) {
+ if (checkType) {
+ validateIsInt16();
+ return mType.mElement.mType;
+ }
+ return Element.DataType.SIGNED_16;
+ }
+
+ if (cmp == Byte.TYPE) {
+ if (checkType) {
+ validateIsInt8();
+ return mType.mElement.mType;
+ }
+ return Element.DataType.SIGNED_8;
+ }
+
+ if (cmp == Float.TYPE) {
+ if (checkType) {
+ validateIsFloat32();
+ }
+ return Element.DataType.FLOAT_32;
+ }
+
+ if (cmp == Double.TYPE) {
+ if (checkType) {
+ validateIsFloat64();
+ }
+ return Element.DataType.FLOAT_64;
+ }
+ return null;
+ }
+
+
/**
* The usage of the Allocation. These signal to RenderScript where to place
* the Allocation in memory.
@@ -127,17 +185,17 @@
public static final int USAGE_GRAPHICS_RENDER_TARGET = 0x0010;
/**
- * The Allocation will be used as a {@link android.graphics.SurfaceTexture}
- * consumer. This usage will cause the Allocation to be created as
- * read-only.
+ * The Allocation will be used as a {@link android.view.Surface}
+ * consumer. This usage will cause the Allocation to be created
+ * as read-only.
*
*/
public static final int USAGE_IO_INPUT = 0x0020;
/**
- * The Allocation will be used as a {@link android.graphics.SurfaceTexture}
+ * The Allocation will be used as a {@link android.view.Surface}
* producer. The dimensions and format of the {@link
- * android.graphics.SurfaceTexture} will be forced to those of the
+ * android.view.Surface} will be forced to those of the
* Allocation.
*
*/
@@ -188,7 +246,7 @@
}
- private int getIDSafe() {
+ private long getIDSafe() {
if (mAdaptedAllocation != null) {
return mAdaptedAllocation.getID(mRS);
}
@@ -224,6 +282,9 @@
*
*/
public int getBytesSize() {
+ if (mType.mDimYuv != 0) {
+ return (int)Math.ceil(mType.getCount() * mType.getElement().getBytesSize() * 1.5);
+ }
return mType.getCount() * mType.getElement().getBytesSize();
}
@@ -244,7 +305,7 @@
mBitmap = b;
}
- Allocation(int id, RenderScript rs, Type t, int usage) {
+ Allocation(long id, RenderScript rs, Type t, int usage) {
super(id, rs);
if ((usage & ~(USAGE_SCRIPT |
USAGE_GRAPHICS_TEXTURE |
@@ -290,6 +351,15 @@
super.finalize();
}
+ private void validateIsInt64() {
+ if ((mType.mElement.mType == Element.DataType.SIGNED_64) ||
+ (mType.mElement.mType == Element.DataType.UNSIGNED_64)) {
+ return;
+ }
+ throw new RSIllegalArgumentException(
+ "64 bit integer source does not match allocation type " + mType.mElement.mType);
+ }
+
private void validateIsInt32() {
if ((mType.mElement.mType == Element.DataType.SIGNED_32) ||
(mType.mElement.mType == Element.DataType.UNSIGNED_32)) {
@@ -325,6 +395,14 @@
"32 bit float source does not match allocation type " + mType.mElement.mType);
}
+ private void validateIsFloat64() {
+ if (mType.mElement.mType == Element.DataType.FLOAT_64) {
+ return;
+ }
+ throw new RSIllegalArgumentException(
+ "64 bit float source does not match allocation type " + mType.mElement.mType);
+ }
+
private void validateIsObject() {
if ((mType.mElement.mType == Element.DataType.RS_ELEMENT) ||
(mType.mElement.mType == Element.DataType.RS_TYPE) ||
@@ -345,7 +423,7 @@
@Override
void updateFromNative() {
super.updateFromNative();
- int typeID = mRS.nAllocationGetType(getID(mRS));
+ long typeID = mRS.nAllocationGetType(getID(mRS));
if(typeID != 0) {
mType = new Type(typeID, mRS);
mType.updateFromNative();
@@ -412,14 +490,6 @@
}
/**
- * Delete once code is updated.
- * @hide
- */
- public void ioSendOutput() {
- ioSend();
- }
-
- /**
* Receive the latest input into the Allocation. This operation
* is only valid if {@link #USAGE_IO_INPUT} is set on the Allocation.
*
@@ -448,9 +518,11 @@
throw new RSIllegalArgumentException("Array size mismatch, allocation sizeX = " +
mCurrentCount + ", array length = " + d.length);
}
+ // FIXME: requires 64-bit path
+
int i[] = new int[d.length];
for (int ct=0; ct < d.length; ct++) {
- i[ct] = d[ct].getID(mRS);
+ i[ct] = (int)d[ct].getID(mRS);
}
copy1DRangeFromUnchecked(0, mCurrentCount, i);
Trace.traceEnd(RenderScript.TRACE_TAG);
@@ -511,6 +583,34 @@
}
}
+ private void copyFromUnchecked(Object array, Element.DataType dt, int arrayLen) {
+ Trace.traceBegin(RenderScript.TRACE_TAG, "copyFromUnchecked");
+ mRS.validate();
+ if (mCurrentDimZ > 0) {
+ copy3DRangeFromUnchecked(0, 0, 0, mCurrentDimX, mCurrentDimY, mCurrentDimZ, array, dt, arrayLen);
+ } else if (mCurrentDimY > 0) {
+ copy2DRangeFromUnchecked(0, 0, mCurrentDimX, mCurrentDimY, array, dt, arrayLen);
+ } else {
+ copy1DRangeFromUnchecked(0, mCurrentCount, array, dt, arrayLen);
+ }
+ Trace.traceEnd(RenderScript.TRACE_TAG);
+ }
+
+ /**
+ * Copy into this Allocation from an array. This method does not guarantee
+ * that the Allocation is compatible with the input buffer; it copies memory
+ * without reinterpretation.
+ *
+ * @param array The source data array
+ * @hide
+ */
+ public void copyFromUnchecked(Object array) {
+ Trace.traceBegin(RenderScript.TRACE_TAG, "copyFromUnchecked");
+ copyFromUnchecked(array, validateObjectIsPrimitiveArray(array, false),
+ java.lang.reflect.Array.getLength(array));
+ Trace.traceEnd(RenderScript.TRACE_TAG);
+ }
+
/**
* Copy into this Allocation from an array. This method does not guarantee
* that the Allocation is compatible with the input buffer; it copies memory
@@ -519,16 +619,7 @@
* @param d the source data array
*/
public void copyFromUnchecked(int[] d) {
- Trace.traceBegin(RenderScript.TRACE_TAG, "copyFromUnchecked");
- mRS.validate();
- if (mCurrentDimZ > 0) {
- copy3DRangeFromUnchecked(0, 0, 0, mCurrentDimX, mCurrentDimY, mCurrentDimZ, d);
- } else if (mCurrentDimY > 0) {
- copy2DRangeFromUnchecked(0, 0, mCurrentDimX, mCurrentDimY, d);
- } else {
- copy1DRangeFromUnchecked(0, mCurrentCount, d);
- }
- Trace.traceEnd(RenderScript.TRACE_TAG);
+ copyFromUnchecked(d, Element.DataType.SIGNED_32, d.length);
}
/**
@@ -539,16 +630,7 @@
* @param d the source data array
*/
public void copyFromUnchecked(short[] d) {
- Trace.traceBegin(RenderScript.TRACE_TAG, "copyFromUnchecked");
- mRS.validate();
- if (mCurrentDimZ > 0) {
- copy3DRangeFromUnchecked(0, 0, 0, mCurrentDimX, mCurrentDimY, mCurrentDimZ, d);
- } else if (mCurrentDimY > 0) {
- copy2DRangeFromUnchecked(0, 0, mCurrentDimX, mCurrentDimY, d);
- } else {
- copy1DRangeFromUnchecked(0, mCurrentCount, d);
- }
- Trace.traceEnd(RenderScript.TRACE_TAG);
+ copyFromUnchecked(d, Element.DataType.SIGNED_16, d.length);
}
/**
@@ -559,16 +641,7 @@
* @param d the source data array
*/
public void copyFromUnchecked(byte[] d) {
- Trace.traceBegin(RenderScript.TRACE_TAG, "copyFromUnchecked");
- mRS.validate();
- if (mCurrentDimZ > 0) {
- copy3DRangeFromUnchecked(0, 0, 0, mCurrentDimX, mCurrentDimY, mCurrentDimZ, d);
- } else if (mCurrentDimY > 0) {
- copy2DRangeFromUnchecked(0, 0, mCurrentDimX, mCurrentDimY, d);
- } else {
- copy1DRangeFromUnchecked(0, mCurrentCount, d);
- }
- Trace.traceEnd(RenderScript.TRACE_TAG);
+ copyFromUnchecked(d, Element.DataType.SIGNED_8, d.length);
}
/**
@@ -579,37 +652,36 @@
* @param d the source data array
*/
public void copyFromUnchecked(float[] d) {
- Trace.traceBegin(RenderScript.TRACE_TAG, "copyFromUnchecked");
- mRS.validate();
- if (mCurrentDimZ > 0) {
- copy3DRangeFromUnchecked(0, 0, 0, mCurrentDimX, mCurrentDimY, mCurrentDimZ, d);
- } else if (mCurrentDimY > 0) {
- copy2DRangeFromUnchecked(0, 0, mCurrentDimX, mCurrentDimY, d);
- } else {
- copy1DRangeFromUnchecked(0, mCurrentCount, d);
- }
- Trace.traceEnd(RenderScript.TRACE_TAG);
+ copyFromUnchecked(d, Element.DataType.FLOAT_32, d.length);
}
/**
* Copy into this Allocation from an array. This variant is type checked
* and will generate exceptions if the Allocation's {@link
+ * android.renderscript.Element} does not match the array's
+ * primitive type.
+ *
+ * @param d the source data array
+ * @hide
+ */
+ public void copyFrom(Object array) {
+ Trace.traceBegin(RenderScript.TRACE_TAG, "copyFrom");
+ copyFromUnchecked(array, validateObjectIsPrimitiveArray(array, true),
+ java.lang.reflect.Array.getLength(array));
+ Trace.traceEnd(RenderScript.TRACE_TAG);
+ }
+
+ /**
+ * Copy into this Allocation from an array. This variant is type checked
+ * and will generate exceptions if the Allocation's {@link
* android.renderscript.Element} is not a 32 bit integer type.
*
* @param d the source data array
*/
public void copyFrom(int[] d) {
- Trace.traceBegin(RenderScript.TRACE_TAG, "copyFrom");
- mRS.validate();
- if (mCurrentDimZ > 0) {
- copy3DRangeFrom(0, 0, 0, mCurrentDimX, mCurrentDimY, mCurrentDimZ, d);
- } else if (mCurrentDimY > 0) {
- copy2DRangeFrom(0, 0, mCurrentDimX, mCurrentDimY, d);
- } else {
- copy1DRangeFrom(0, mCurrentCount, d);
- }
- Trace.traceEnd(RenderScript.TRACE_TAG);
+ validateIsInt32();
+ copyFromUnchecked(d, Element.DataType.SIGNED_32, d.length);
}
/**
@@ -620,16 +692,8 @@
* @param d the source data array
*/
public void copyFrom(short[] d) {
- Trace.traceBegin(RenderScript.TRACE_TAG, "copyFrom");
- mRS.validate();
- if (mCurrentDimZ > 0) {
- copy3DRangeFrom(0, 0, 0, mCurrentDimX, mCurrentDimY, mCurrentDimZ, d);
- } else if (mCurrentDimY > 0) {
- copy2DRangeFrom(0, 0, mCurrentDimX, mCurrentDimY, d);
- } else {
- copy1DRangeFrom(0, mCurrentCount, d);
- }
- Trace.traceEnd(RenderScript.TRACE_TAG);
+ validateIsInt16();
+ copyFromUnchecked(d, Element.DataType.SIGNED_16, d.length);
}
/**
@@ -640,16 +704,8 @@
* @param d the source data array
*/
public void copyFrom(byte[] d) {
- Trace.traceBegin(RenderScript.TRACE_TAG, "copyFrom");
- mRS.validate();
- if (mCurrentDimZ > 0) {
- copy3DRangeFrom(0, 0, 0, mCurrentDimX, mCurrentDimY, mCurrentDimZ, d);
- } else if (mCurrentDimY > 0) {
- copy2DRangeFrom(0, 0, mCurrentDimX, mCurrentDimY, d);
- } else {
- copy1DRangeFrom(0, mCurrentCount, d);
- }
- Trace.traceEnd(RenderScript.TRACE_TAG);
+ validateIsInt8();
+ copyFromUnchecked(d, Element.DataType.SIGNED_8, d.length);
}
/**
@@ -660,16 +716,8 @@
* @param d the source data array
*/
public void copyFrom(float[] d) {
- Trace.traceBegin(RenderScript.TRACE_TAG, "copyFrom");
- mRS.validate();
- if (mCurrentDimZ > 0) {
- copy3DRangeFrom(0, 0, 0, mCurrentDimX, mCurrentDimY, mCurrentDimZ, d);
- } else if (mCurrentDimY > 0) {
- copy2DRangeFrom(0, 0, mCurrentDimX, mCurrentDimY, d);
- } else {
- copy1DRangeFrom(0, mCurrentCount, d);
- }
- Trace.traceEnd(RenderScript.TRACE_TAG);
+ validateIsFloat32();
+ copyFromUnchecked(d, Element.DataType.FLOAT_32, d.length);
}
/**
@@ -798,6 +846,30 @@
mRS.nAllocationGenerateMipmaps(getID(mRS));
}
+ private void copy1DRangeFromUnchecked(int off, int count, Object array,
+ Element.DataType dt, int arrayLen) {
+ Trace.traceBegin(RenderScript.TRACE_TAG, "copy1DRangeFromUnchecked");
+ final int dataSize = mType.mElement.getBytesSize() * count;
+ data1DChecks(off, count, arrayLen * dt.mSize, dataSize);
+ mRS.nAllocationData1D(getIDSafe(), off, mSelectedLOD, count, array, dataSize, dt);
+ Trace.traceEnd(RenderScript.TRACE_TAG);
+ }
+
+ /**
+ * Copy an array into part of this Allocation. This method does not
+ * guarantee that the Allocation is compatible with the input buffer.
+ *
+ * @param off The offset of the first element to be copied.
+ * @param count The number of elements to be copied.
+ * @param array The source data array
+ * @hide
+ */
+ public void copy1DRangeFromUnchecked(int off, int count, Object array) {
+ copy1DRangeFromUnchecked(off, count, array,
+ validateObjectIsPrimitiveArray(array, false),
+ java.lang.reflect.Array.getLength(array));
+ }
+
/**
* Copy an array into part of this Allocation. This method does not
* guarantee that the Allocation is compatible with the input buffer.
@@ -807,11 +879,7 @@
* @param d the source data array
*/
public void copy1DRangeFromUnchecked(int off, int count, int[] d) {
- Trace.traceBegin(RenderScript.TRACE_TAG, "copy1DRangeFromUnchecked");
- int dataSize = mType.mElement.getBytesSize() * count;
- data1DChecks(off, count, d.length * 4, dataSize);
- mRS.nAllocationData1D(getIDSafe(), off, mSelectedLOD, count, d, dataSize);
- Trace.traceEnd(RenderScript.TRACE_TAG);
+ copy1DRangeFromUnchecked(off, count, (Object)d, Element.DataType.SIGNED_32, d.length);
}
/**
@@ -823,11 +891,7 @@
* @param d the source data array
*/
public void copy1DRangeFromUnchecked(int off, int count, short[] d) {
- Trace.traceBegin(RenderScript.TRACE_TAG, "copy1DRangeFromUnchecked");
- int dataSize = mType.mElement.getBytesSize() * count;
- data1DChecks(off, count, d.length * 2, dataSize);
- mRS.nAllocationData1D(getIDSafe(), off, mSelectedLOD, count, d, dataSize);
- Trace.traceEnd(RenderScript.TRACE_TAG);
+ copy1DRangeFromUnchecked(off, count, (Object)d, Element.DataType.SIGNED_16, d.length);
}
/**
@@ -839,11 +903,7 @@
* @param d the source data array
*/
public void copy1DRangeFromUnchecked(int off, int count, byte[] d) {
- Trace.traceBegin(RenderScript.TRACE_TAG, "copy1DRangeFromUnchecked");
- int dataSize = mType.mElement.getBytesSize() * count;
- data1DChecks(off, count, d.length, dataSize);
- mRS.nAllocationData1D(getIDSafe(), off, mSelectedLOD, count, d, dataSize);
- Trace.traceEnd(RenderScript.TRACE_TAG);
+ copy1DRangeFromUnchecked(off, count, (Object)d, Element.DataType.SIGNED_8, d.length);
}
/**
@@ -855,11 +915,24 @@
* @param d the source data array
*/
public void copy1DRangeFromUnchecked(int off, int count, float[] d) {
- Trace.traceBegin(RenderScript.TRACE_TAG, "copy1DRangeFromUnchecked");
- int dataSize = mType.mElement.getBytesSize() * count;
- data1DChecks(off, count, d.length * 4, dataSize);
- mRS.nAllocationData1D(getIDSafe(), off, mSelectedLOD, count, d, dataSize);
- Trace.traceEnd(RenderScript.TRACE_TAG);
+ copy1DRangeFromUnchecked(off, count, (Object)d, Element.DataType.FLOAT_32, d.length);
+ }
+
+
+ /**
+ * Copy an array into part of this Allocation. This variant is type checked
+ * and will generate exceptions if the Allocation type does not
+ * match the component type of the array passed in.
+ *
+ * @param off The offset of the first element to be copied.
+ * @param count The number of elements to be copied.
+ * @param array The source data array.
+ * @hide
+ */
+ public void copy1DRangeFrom(int off, int count, Object array) {
+ copy1DRangeFromUnchecked(off, count, array,
+ validateObjectIsPrimitiveArray(array, true),
+ java.lang.reflect.Array.getLength(array));
}
/**
@@ -872,10 +945,8 @@
* @param d the source data array
*/
public void copy1DRangeFrom(int off, int count, int[] d) {
- Trace.traceBegin(RenderScript.TRACE_TAG, "copy1DRangeFrom");
validateIsInt32();
- copy1DRangeFromUnchecked(off, count, d);
- Trace.traceEnd(RenderScript.TRACE_TAG);
+ copy1DRangeFromUnchecked(off, count, d, Element.DataType.SIGNED_32, d.length);
}
/**
@@ -888,10 +959,8 @@
* @param d the source data array
*/
public void copy1DRangeFrom(int off, int count, short[] d) {
- Trace.traceBegin(RenderScript.TRACE_TAG, "copy1DRangeFrom");
validateIsInt16();
- copy1DRangeFromUnchecked(off, count, d);
- Trace.traceEnd(RenderScript.TRACE_TAG);
+ copy1DRangeFromUnchecked(off, count, d, Element.DataType.SIGNED_16, d.length);
}
/**
@@ -904,10 +973,8 @@
* @param d the source data array
*/
public void copy1DRangeFrom(int off, int count, byte[] d) {
- Trace.traceBegin(RenderScript.TRACE_TAG, "copy1DRangeFrom");
validateIsInt8();
- copy1DRangeFromUnchecked(off, count, d);
- Trace.traceEnd(RenderScript.TRACE_TAG);
+ copy1DRangeFromUnchecked(off, count, d, Element.DataType.SIGNED_8, d.length);
}
/**
@@ -920,11 +987,10 @@
* @param d the source data array.
*/
public void copy1DRangeFrom(int off, int count, float[] d) {
- Trace.traceBegin(RenderScript.TRACE_TAG, "copy1DRangeFrom");
validateIsFloat32();
- copy1DRangeFromUnchecked(off, count, d);
- Trace.traceEnd(RenderScript.TRACE_TAG);
+ copy1DRangeFromUnchecked(off, count, d, Element.DataType.FLOAT_32, d.length);
}
+
/**
* Copy part of an Allocation into this Allocation.
*
@@ -959,39 +1025,32 @@
}
}
- void copy2DRangeFromUnchecked(int xoff, int yoff, int w, int h, byte[] data) {
+ void copy2DRangeFromUnchecked(int xoff, int yoff, int w, int h, Object array,
+ Element.DataType dt, int arrayLen) {
Trace.traceBegin(RenderScript.TRACE_TAG, "copy2DRangeFromUnchecked");
mRS.validate();
validate2DRange(xoff, yoff, w, h);
- mRS.nAllocationData2D(getIDSafe(), xoff, yoff, mSelectedLOD, mSelectedFace.mID,
- w, h, data, data.length);
+ mRS.nAllocationData2D(getIDSafe(), xoff, yoff, mSelectedLOD, mSelectedFace.mID, w, h,
+ array, arrayLen * dt.mSize, dt);
Trace.traceEnd(RenderScript.TRACE_TAG);
}
- void copy2DRangeFromUnchecked(int xoff, int yoff, int w, int h, short[] data) {
- Trace.traceBegin(RenderScript.TRACE_TAG, "copy2DRangeFromUnchecked");
- mRS.validate();
- validate2DRange(xoff, yoff, w, h);
- mRS.nAllocationData2D(getIDSafe(), xoff, yoff, mSelectedLOD, mSelectedFace.mID,
- w, h, data, data.length * 2);
- Trace.traceEnd(RenderScript.TRACE_TAG);
- }
-
- void copy2DRangeFromUnchecked(int xoff, int yoff, int w, int h, int[] data) {
- Trace.traceBegin(RenderScript.TRACE_TAG, "copy2DRangeFromUnchecked");
- mRS.validate();
- validate2DRange(xoff, yoff, w, h);
- mRS.nAllocationData2D(getIDSafe(), xoff, yoff, mSelectedLOD, mSelectedFace.mID,
- w, h, data, data.length * 4);
- Trace.traceEnd(RenderScript.TRACE_TAG);
- }
-
- void copy2DRangeFromUnchecked(int xoff, int yoff, int w, int h, float[] data) {
- Trace.traceBegin(RenderScript.TRACE_TAG, "copy2DRangeFromUnchecked");
- mRS.validate();
- validate2DRange(xoff, yoff, w, h);
- mRS.nAllocationData2D(getIDSafe(), xoff, yoff, mSelectedLOD, mSelectedFace.mID,
- w, h, data, data.length * 4);
+ /**
+ * Copy from an array into a rectangular region in this Allocation. The
+ * array is assumed to be tightly packed.
+ *
+ * @param xoff X offset of the region to update in this Allocation
+ * @param yoff Y offset of the region to update in this Allocation
+ * @param w Width of the region to update
+ * @param h Height of the region to update
+ * @param data to be placed into the Allocation
+ * @hide
+ */
+ public void copy2DRangeFrom(int xoff, int yoff, int w, int h, Object array) {
+ Trace.traceBegin(RenderScript.TRACE_TAG, "copy2DRangeFrom");
+ copy2DRangeFromUnchecked(xoff, yoff, w, h, array,
+ validateObjectIsPrimitiveArray(array, true),
+ java.lang.reflect.Array.getLength(array));
Trace.traceEnd(RenderScript.TRACE_TAG);
}
@@ -1006,10 +1065,9 @@
* @param data to be placed into the Allocation
*/
public void copy2DRangeFrom(int xoff, int yoff, int w, int h, byte[] data) {
- Trace.traceBegin(RenderScript.TRACE_TAG, "copy2DRangeFrom");
validateIsInt8();
- copy2DRangeFromUnchecked(xoff, yoff, w, h, data);
- Trace.traceEnd(RenderScript.TRACE_TAG);
+ copy2DRangeFromUnchecked(xoff, yoff, w, h, data,
+ Element.DataType.SIGNED_8, data.length);
}
/**
@@ -1023,10 +1081,9 @@
* @param data to be placed into the Allocation
*/
public void copy2DRangeFrom(int xoff, int yoff, int w, int h, short[] data) {
- Trace.traceBegin(RenderScript.TRACE_TAG, "copy2DRangeFrom");
validateIsInt16();
- copy2DRangeFromUnchecked(xoff, yoff, w, h, data);
- Trace.traceEnd(RenderScript.TRACE_TAG);
+ copy2DRangeFromUnchecked(xoff, yoff, w, h, data,
+ Element.DataType.SIGNED_16, data.length);
}
/**
@@ -1040,10 +1097,9 @@
* @param data to be placed into the Allocation
*/
public void copy2DRangeFrom(int xoff, int yoff, int w, int h, int[] data) {
- Trace.traceBegin(RenderScript.TRACE_TAG, "copy2DRangeFrom");
validateIsInt32();
- copy2DRangeFromUnchecked(xoff, yoff, w, h, data);
- Trace.traceEnd(RenderScript.TRACE_TAG);
+ copy2DRangeFromUnchecked(xoff, yoff, w, h, data,
+ Element.DataType.SIGNED_32, data.length);
}
/**
@@ -1057,10 +1113,9 @@
* @param data to be placed into the Allocation
*/
public void copy2DRangeFrom(int xoff, int yoff, int w, int h, float[] data) {
- Trace.traceBegin(RenderScript.TRACE_TAG, "copy2DRangeFrom");
validateIsFloat32();
- copy2DRangeFromUnchecked(xoff, yoff, w, h, data);
- Trace.traceEnd(RenderScript.TRACE_TAG);
+ copy2DRangeFromUnchecked(xoff, yoff, w, h, data,
+ Element.DataType.FLOAT_32, data.length);
}
/**
@@ -1133,49 +1188,18 @@
* @hide
*
*/
- void copy3DRangeFromUnchecked(int xoff, int yoff, int zoff, int w, int h, int d, byte[] data) {
+ private void copy3DRangeFromUnchecked(int xoff, int yoff, int zoff, int w, int h, int d,
+ Object array, Element.DataType dt, int arrayLen) {
+ Trace.traceBegin(RenderScript.TRACE_TAG, "copy3DRangeFromUnchecked");
mRS.validate();
validate3DRange(xoff, yoff, zoff, w, h, d);
- mRS.nAllocationData3D(getIDSafe(), xoff, yoff, zoff, mSelectedLOD,
- w, h, d, data, data.length);
+ mRS.nAllocationData3D(getIDSafe(), xoff, yoff, zoff, mSelectedLOD, w, h, d,
+ array, arrayLen * dt.mSize, dt);
+ Trace.traceEnd(RenderScript.TRACE_TAG);
}
/**
* @hide
- *
- */
- void copy3DRangeFromUnchecked(int xoff, int yoff, int zoff, int w, int h, int d, short[] data) {
- mRS.validate();
- validate3DRange(xoff, yoff, zoff, w, h, d);
- mRS.nAllocationData3D(getIDSafe(), xoff, yoff, zoff, mSelectedLOD,
- w, h, d, data, data.length * 2);
- }
-
- /**
- * @hide
- *
- */
- void copy3DRangeFromUnchecked(int xoff, int yoff, int zoff, int w, int h, int d, int[] data) {
- mRS.validate();
- validate3DRange(xoff, yoff, zoff, w, h, d);
- mRS.nAllocationData3D(getIDSafe(), xoff, yoff, zoff, mSelectedLOD,
- w, h, d, data, data.length * 4);
- }
-
- /**
- * @hide
- *
- */
- void copy3DRangeFromUnchecked(int xoff, int yoff, int zoff, int w, int h, int d, float[] data) {
- mRS.validate();
- validate3DRange(xoff, yoff, zoff, w, h, d);
- mRS.nAllocationData3D(getIDSafe(), xoff, yoff, zoff, mSelectedLOD,
- w, h, d, data, data.length * 4);
- }
-
-
- /**
- * @hide
* Copy a rectangular region from the array into the allocation.
* The array is assumed to be tightly packed.
*
@@ -1187,36 +1211,12 @@
* @param d Depth of the region to update
* @param data to be placed into the allocation
*/
- public void copy3DRangeFrom(int xoff, int yoff, int zoff, int w, int h, int d, byte[] data) {
- validateIsInt8();
- copy3DRangeFromUnchecked(xoff, yoff, zoff, w, h, d, data);
- }
-
- /**
- * @hide
- *
- */
- public void copy3DRangeFrom(int xoff, int yoff, int zoff, int w, int h, int d, short[] data) {
- validateIsInt16();
- copy3DRangeFromUnchecked(xoff, yoff, zoff, w, h, d, data);
- }
-
- /**
- * @hide
- *
- */
- public void copy3DRangeFrom(int xoff, int yoff, int zoff, int w, int h, int d, int[] data) {
- validateIsInt32();
- copy3DRangeFromUnchecked(xoff, yoff, zoff, w, h, d, data);
- }
-
- /**
- * @hide
- *
- */
- public void copy3DRangeFrom(int xoff, int yoff, int zoff, int w, int h, int d, float[] data) {
- validateIsFloat32();
- copy3DRangeFromUnchecked(xoff, yoff, zoff, w, h, d, data);
+ public void copy3DRangeFrom(int xoff, int yoff, int zoff, int w, int h, int d, Object array) {
+ Trace.traceBegin(RenderScript.TRACE_TAG, "copy3DRangeFrom");
+ copy3DRangeFromUnchecked(xoff, yoff, zoff, w, h, d, array,
+ validateObjectIsPrimitiveArray(array, true),
+ java.lang.reflect.Array.getLength(array));
+ Trace.traceEnd(RenderScript.TRACE_TAG);
}
/**
@@ -1260,6 +1260,27 @@
Trace.traceEnd(RenderScript.TRACE_TAG);
}
+ private void copyTo(Object array, Element.DataType dt, int arrayLen) {
+ Trace.traceBegin(RenderScript.TRACE_TAG, "copyTo");
+ mRS.validate();
+ mRS.nAllocationRead(getID(mRS), array, dt);
+ Trace.traceEnd(RenderScript.TRACE_TAG);
+ }
+
+ /**
+ * Copy from the Allocation into an array. The array must be at
+ * least as large as the Allocation. The
+ * {@link android.renderscript.Element} must match the component
+ * type of the array passed in.
+ *
+ * @param array The array to be set from the Allocation.
+ * @hide
+ */
+ public void copyTo(Object array) {
+ copyTo(array, validateObjectIsPrimitiveArray(array, true),
+ java.lang.reflect.Array.getLength(array));
+ }
+
/**
* Copy from the Allocation into a byte array. The array must be at least
* as large as the Allocation. The allocation must be of an 8 bit integer
@@ -1268,11 +1289,8 @@
* @param d The array to be set from the Allocation.
*/
public void copyTo(byte[] d) {
- Trace.traceBegin(RenderScript.TRACE_TAG, "copyTo");
validateIsInt8();
- mRS.validate();
- mRS.nAllocationRead(getID(mRS), d);
- Trace.traceEnd(RenderScript.TRACE_TAG);
+ copyTo(d, Element.DataType.SIGNED_8, d.length);
}
/**
@@ -1283,11 +1301,8 @@
* @param d The array to be set from the Allocation.
*/
public void copyTo(short[] d) {
- Trace.traceBegin(RenderScript.TRACE_TAG, "copyTo");
validateIsInt16();
- mRS.validate();
- mRS.nAllocationRead(getID(mRS), d);
- Trace.traceEnd(RenderScript.TRACE_TAG);
+ copyTo(d, Element.DataType.SIGNED_16, d.length);
}
/**
@@ -1298,11 +1313,8 @@
* @param d The array to be set from the Allocation.
*/
public void copyTo(int[] d) {
- Trace.traceBegin(RenderScript.TRACE_TAG, "copyTo");
validateIsInt32();
- mRS.validate();
- mRS.nAllocationRead(getID(mRS), d);
- Trace.traceEnd(RenderScript.TRACE_TAG);
+ copyTo(d, Element.DataType.SIGNED_32, d.length);
}
/**
@@ -1313,11 +1325,8 @@
* @param d The array to be set from the Allocation.
*/
public void copyTo(float[] d) {
- Trace.traceBegin(RenderScript.TRACE_TAG, "copyTo");
validateIsFloat32();
- mRS.validate();
- mRS.nAllocationRead(getID(mRS), d);
- Trace.traceEnd(RenderScript.TRACE_TAG);
+ copyTo(d, Element.DataType.FLOAT_32, d.length);
}
/**
@@ -1342,7 +1351,7 @@
mRS.nAllocationResize1D(getID(mRS), dimX);
mRS.finish(); // Necessary because resize is fifoed and update is async.
- int typeID = mRS.nAllocationGetType(getID(mRS));
+ long typeID = mRS.nAllocationGetType(getID(mRS));
mType = new Type(typeID, mRS);
mType.updateFromNative();
updateCacheInfo(mType);
@@ -1372,7 +1381,7 @@
if (type.getID(rs) == 0) {
throw new RSInvalidStateException("Bad Type");
}
- int id = rs.nAllocationCreateTyped(type.getID(rs), mips.mID, usage, 0);
+ long id = rs.nAllocationCreateTyped(type.getID(rs), mips.mID, usage, 0);
if (id == 0) {
throw new RSRuntimeException("Allocation creation failed.");
}
@@ -1427,7 +1436,7 @@
b.setX(count);
Type t = b.create();
- int id = rs.nAllocationCreateTyped(t.getID(rs), MipmapControl.MIPMAP_NONE.mID, usage, 0);
+ long id = rs.nAllocationCreateTyped(t.getID(rs), MipmapControl.MIPMAP_NONE.mID, usage, 0);
if (id == 0) {
throw new RSRuntimeException("Allocation creation failed.");
}
@@ -1511,7 +1520,7 @@
if (mips == MipmapControl.MIPMAP_NONE &&
t.getElement().isCompatible(Element.RGBA_8888(rs)) &&
usage == (USAGE_SHARED | USAGE_SCRIPT | USAGE_GRAPHICS_TEXTURE)) {
- int id = rs.nAllocationCreateBitmapBackedAllocation(t.getID(rs), mips.mID, b, usage);
+ long id = rs.nAllocationCreateBitmapBackedAllocation(t.getID(rs), mips.mID, b, usage);
if (id == 0) {
throw new RSRuntimeException("Load failed.");
}
@@ -1523,7 +1532,7 @@
}
- int id = rs.nAllocationCreateFromBitmap(t.getID(rs), mips.mID, b, usage);
+ long id = rs.nAllocationCreateFromBitmap(t.getID(rs), mips.mID, b, usage);
if (id == 0) {
throw new RSRuntimeException("Load failed.");
}
@@ -1547,13 +1556,6 @@
}
/**
- * @hide
- */
- public void setSurfaceTexture(SurfaceTexture st) {
- setSurface(new Surface(st));
- }
-
- /**
* Associate a {@link android.view.Surface} with this Allocation. This
* operation is only valid for Allocations with {@link #USAGE_IO_OUTPUT}.
*
@@ -1633,7 +1635,7 @@
tb.setMipmaps(mips == MipmapControl.MIPMAP_FULL);
Type t = tb.create();
- int id = rs.nAllocationCubeCreateFromBitmap(t.getID(rs), mips.mID, b, usage);
+ long id = rs.nAllocationCubeCreateFromBitmap(t.getID(rs), mips.mID, b, usage);
if(id == 0) {
throw new RSRuntimeException("Load failed for bitmap " + b + " element " + e);
}
@@ -1858,14 +1860,14 @@
*/
public void setOnBufferAvailableListener(OnBufferAvailableListener callback) {
synchronized(mAllocationMap) {
- mAllocationMap.put(new Integer(getID(mRS)), this);
+ mAllocationMap.put(new Long(getID(mRS)), this);
mBufferNotifier = callback;
}
}
static void sendBufferNotification(int id) {
synchronized(mAllocationMap) {
- Allocation a = mAllocationMap.get(new Integer(id));
+ Allocation a = mAllocationMap.get(new Long(id));
if ((a != null) && (a.mBufferNotifier != null)) {
a.mBufferNotifier.onBufferAvailable(a);
diff --git a/graphics/java/android/renderscript/AllocationAdapter.java b/rs/java/android/renderscript/AllocationAdapter.java
similarity index 97%
rename from graphics/java/android/renderscript/AllocationAdapter.java
rename to rs/java/android/renderscript/AllocationAdapter.java
index a6645bb..fd20cae 100644
--- a/graphics/java/android/renderscript/AllocationAdapter.java
+++ b/rs/java/android/renderscript/AllocationAdapter.java
@@ -26,12 +26,12 @@
*
**/
public class AllocationAdapter extends Allocation {
- AllocationAdapter(int id, RenderScript rs, Allocation alloc) {
+ AllocationAdapter(long id, RenderScript rs, Allocation alloc) {
super(id, rs, alloc.mType, alloc.mUsage);
mAdaptedAllocation = alloc;
}
- int getID(RenderScript rs) {
+ long getID(RenderScript rs) {
throw new RSInvalidStateException(
"This operation is not supported with adapters at this time.");
}
@@ -224,7 +224,6 @@
}
static public AllocationAdapter create2D(RenderScript rs, Allocation a) {
- android.util.Log.e("rs", "create2d " + a);
rs.validate();
AllocationAdapter aa = new AllocationAdapter(0, rs, a);
aa.mConstrainedLOD = true;
diff --git a/graphics/java/android/renderscript/BaseObj.java b/rs/java/android/renderscript/BaseObj.java
similarity index 81%
rename from graphics/java/android/renderscript/BaseObj.java
rename to rs/java/android/renderscript/BaseObj.java
index e17d79a..1372ab7 100644
--- a/graphics/java/android/renderscript/BaseObj.java
+++ b/rs/java/android/renderscript/BaseObj.java
@@ -16,7 +16,7 @@
package android.renderscript;
-import android.util.Log;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
/**
* BaseObj is the base class for all RenderScript objects owned by a RS context.
@@ -25,14 +25,14 @@
*
**/
public class BaseObj {
- BaseObj(int id, RenderScript rs) {
+ BaseObj(long id, RenderScript rs) {
rs.validate();
mRS = rs;
mID = id;
mDestroyed = false;
}
- void setID(int id) {
+ void setID(long id) {
if (mID != 0) {
throw new RSRuntimeException("Internal Error, reset of object ID.");
}
@@ -46,9 +46,9 @@
* @param rs Context to verify against internal context for
* match.
*
- * @return int
+ * @return long
*/
- int getID(RenderScript rs) {
+ long getID(RenderScript rs) {
mRS.validate();
if (mDestroyed) {
throw new RSInvalidStateException("using a destroyed object.");
@@ -68,7 +68,7 @@
}
}
- private int mID;
+ private long mID;
private boolean mDestroyed;
private String mName;
RenderScript mRS;
@@ -109,17 +109,31 @@
return mName;
}
- protected void finalize() throws Throwable {
- if (!mDestroyed) {
- if(mID != 0 && mRS.isAlive()) {
+ private void helpDestroy() {
+ boolean shouldDestroy = false;
+ synchronized(this) {
+ if (!mDestroyed) {
+ shouldDestroy = true;
+ mDestroyed = true;
+ }
+ }
+
+ if (shouldDestroy) {
+ // must include nObjDestroy in the critical section
+ ReentrantReadWriteLock.ReadLock rlock = mRS.mRWLock.readLock();
+ rlock.lock();
+ // AllocationAdapters are BaseObjs with an ID of 0 but should not be passed to nObjDestroy
+ if(mRS.isAlive() && mID != 0) {
mRS.nObjDestroy(mID);
}
+ rlock.unlock();
mRS = null;
mID = 0;
- mDestroyed = true;
- //Log.v(RenderScript.LOG_TAG, getClass() +
- // " auto finalizing object without having released the RS reference.");
}
+ }
+
+ protected void finalize() throws Throwable {
+ helpDestroy();
super.finalize();
}
@@ -128,12 +142,11 @@
* primary use is to force immediate cleanup of resources when it is
* believed the GC will not respond quickly enough.
*/
- synchronized public void destroy() {
+ public void destroy() {
if(mDestroyed) {
throw new RSInvalidStateException("Object already destroyed.");
}
- mDestroyed = true;
- mRS.nObjDestroy(mID);
+ helpDestroy();
}
/**
@@ -152,7 +165,7 @@
*/
@Override
public int hashCode() {
- return mID;
+ return (int)((mID & 0xfffffff) ^ (mID >> 32));
}
/**
@@ -168,6 +181,10 @@
if (this == obj)
return true;
+ if (obj == null) {
+ return false;
+ }
+
if (getClass() != obj.getClass()) {
return false;
}
diff --git a/graphics/java/android/renderscript/Byte2.java b/rs/java/android/renderscript/Byte2.java
similarity index 100%
rename from graphics/java/android/renderscript/Byte2.java
rename to rs/java/android/renderscript/Byte2.java
diff --git a/graphics/java/android/renderscript/Byte3.java b/rs/java/android/renderscript/Byte3.java
similarity index 100%
rename from graphics/java/android/renderscript/Byte3.java
rename to rs/java/android/renderscript/Byte3.java
diff --git a/graphics/java/android/renderscript/Byte4.java b/rs/java/android/renderscript/Byte4.java
similarity index 100%
rename from graphics/java/android/renderscript/Byte4.java
rename to rs/java/android/renderscript/Byte4.java
diff --git a/graphics/java/android/renderscript/Double2.java b/rs/java/android/renderscript/Double2.java
similarity index 100%
rename from graphics/java/android/renderscript/Double2.java
rename to rs/java/android/renderscript/Double2.java
diff --git a/graphics/java/android/renderscript/Double3.java b/rs/java/android/renderscript/Double3.java
similarity index 100%
rename from graphics/java/android/renderscript/Double3.java
rename to rs/java/android/renderscript/Double3.java
diff --git a/graphics/java/android/renderscript/Double4.java b/rs/java/android/renderscript/Double4.java
similarity index 100%
rename from graphics/java/android/renderscript/Double4.java
rename to rs/java/android/renderscript/Double4.java
diff --git a/graphics/java/android/renderscript/Element.java b/rs/java/android/renderscript/Element.java
similarity index 98%
rename from graphics/java/android/renderscript/Element.java
rename to rs/java/android/renderscript/Element.java
index 68badfa..aa5d687 100644
--- a/graphics/java/android/renderscript/Element.java
+++ b/rs/java/android/renderscript/Element.java
@@ -759,7 +759,7 @@
return rs.mElement_MATRIX_2X2;
}
- Element(int id, RenderScript rs, Element[] e, String[] n, int[] as) {
+ Element(long id, RenderScript rs, Element[] e, String[] n, int[] as) {
super(id, rs);
mSize = 0;
mVectorSize = 1;
@@ -776,7 +776,7 @@
updateVisibleSubElements();
}
- Element(int id, RenderScript rs, DataType dt, DataKind dk, boolean norm, int size) {
+ Element(long id, RenderScript rs, DataType dt, DataKind dk, boolean norm, int size) {
super(id, rs);
if ((dt != DataType.UNSIGNED_5_6_5) &&
(dt != DataType.UNSIGNED_4_4_4_4) &&
@@ -795,7 +795,7 @@
mVectorSize = size;
}
- Element(int id, RenderScript rs) {
+ Element(long id, RenderScript rs) {
super(id, rs);
}
@@ -829,7 +829,7 @@
mArraySizes = new int[numSubElements];
mOffsetInBytes = new int[numSubElements];
- int[] subElementIds = new int[numSubElements];
+ long[] subElementIds = new long[numSubElements];
mRS.nElementGetSubElements(getID(mRS), subElementIds, mElementNames, mArraySizes);
for(int i = 0; i < numSubElements; i ++) {
mElements[i] = new Element(subElementIds[i], mRS);
@@ -853,7 +853,7 @@
DataKind dk = DataKind.USER;
boolean norm = false;
int vecSize = 1;
- int id = rs.nElementCreate(dt.mID, dk.mID, norm, vecSize);
+ long id = rs.nElementCreate(dt.mID, dk.mID, norm, vecSize);
return new Element(id, rs, dt, dk, norm, vecSize);
}
@@ -890,7 +890,7 @@
case BOOLEAN: {
DataKind dk = DataKind.USER;
boolean norm = false;
- int id = rs.nElementCreate(dt.mID, dk.mID, norm, size);
+ long id = rs.nElementCreate(dt.mID, dk.mID, norm, size);
return new Element(id, rs, dt, dk, norm, size);
}
@@ -961,7 +961,7 @@
}
boolean norm = true;
- int id = rs.nElementCreate(dt.mID, dk.mID, norm, size);
+ long id = rs.nElementCreate(dt.mID, dk.mID, norm, size);
return new Element(id, rs, dt, dk, norm, size);
}
@@ -1088,11 +1088,11 @@
java.lang.System.arraycopy(mElementNames, 0, sin, 0, mCount);
java.lang.System.arraycopy(mArraySizes, 0, asin, 0, mCount);
- int[] ids = new int[ein.length];
+ long[] ids = new long[ein.length];
for (int ct = 0; ct < ein.length; ct++ ) {
ids[ct] = ein[ct].getID(mRS);
}
- int id = mRS.nElementCreate2(ids, sin, asin);
+ long id = mRS.nElementCreate2(ids, sin, asin);
return new Element(id, mRS, ein, sin, asin);
}
}
diff --git a/graphics/java/android/renderscript/FieldPacker.java b/rs/java/android/renderscript/FieldPacker.java
similarity index 98%
rename from graphics/java/android/renderscript/FieldPacker.java
rename to rs/java/android/renderscript/FieldPacker.java
index fed97d6..cf20e63 100644
--- a/graphics/java/android/renderscript/FieldPacker.java
+++ b/rs/java/android/renderscript/FieldPacker.java
@@ -232,7 +232,8 @@
public void addObj(BaseObj obj) {
if (obj != null) {
- addI32(obj.getID(null));
+ // FIXME: this is fine for 32-bit but needs a path for 64-bit
+ addI32((int)obj.getID(null));
} else {
addI32(0);
}
diff --git a/graphics/java/android/renderscript/FileA3D.java b/rs/java/android/renderscript/FileA3D.java
similarity index 94%
rename from graphics/java/android/renderscript/FileA3D.java
rename to rs/java/android/renderscript/FileA3D.java
index e41f02d..04bc7c6 100644
--- a/graphics/java/android/renderscript/FileA3D.java
+++ b/rs/java/android/renderscript/FileA3D.java
@@ -80,7 +80,7 @@
public static class IndexEntry {
RenderScript mRS;
int mIndex;
- int mID;
+ long mID;
String mName;
EntryType mEntryType;
BaseObj mLoadedObj;
@@ -141,7 +141,7 @@
return null;
}
- int objectID = rs.nFileA3DGetEntryByIndex(entry.mID, entry.mIndex);
+ long objectID = rs.nFileA3DGetEntryByIndex(entry.mID, entry.mIndex);
if(objectID == 0) {
return null;
}
@@ -156,7 +156,7 @@
return entry.mLoadedObj;
}
- IndexEntry(RenderScript rs, int index, int id, String name, EntryType type) {
+ IndexEntry(RenderScript rs, int index, long id, String name, EntryType type) {
mRS = rs;
mIndex = index;
mID = id;
@@ -169,7 +169,7 @@
IndexEntry[] mFileEntries;
InputStream mInputStream;
- FileA3D(int id, RenderScript rs, InputStream stream) {
+ FileA3D(long id, RenderScript rs, InputStream stream) {
super(id, rs);
mInputStream = stream;
}
@@ -232,7 +232,7 @@
*/
static public FileA3D createFromAsset(RenderScript rs, AssetManager mgr, String path) {
rs.validate();
- int fileId = rs.nFileA3DCreateFromAsset(mgr, path);
+ long fileId = rs.nFileA3DCreateFromAsset(mgr, path);
if(fileId == 0) {
throw new RSRuntimeException("Unable to create a3d file from asset " + path);
@@ -252,7 +252,7 @@
* @return a3d file containing renderscript objects
*/
static public FileA3D createFromFile(RenderScript rs, String path) {
- int fileId = rs.nFileA3DCreateFromFile(path);
+ long fileId = rs.nFileA3DCreateFromFile(path);
if(fileId == 0) {
throw new RSRuntimeException("Unable to create a3d file from " + path);
@@ -295,9 +295,9 @@
throw new RSRuntimeException("Unable to open resource " + id);
}
- int fileId = 0;
+ long fileId = 0;
if (is instanceof AssetManager.AssetInputStream) {
- int asset = ((AssetManager.AssetInputStream) is).getAssetInt();
+ long asset = ((AssetManager.AssetInputStream) is).getNativeAsset();
fileId = rs.nFileA3DCreateFromAssetStream(asset);
} else {
throw new RSRuntimeException("Unsupported asset stream");
diff --git a/graphics/java/android/renderscript/Float2.java b/rs/java/android/renderscript/Float2.java
similarity index 100%
rename from graphics/java/android/renderscript/Float2.java
rename to rs/java/android/renderscript/Float2.java
diff --git a/graphics/java/android/renderscript/Float3.java b/rs/java/android/renderscript/Float3.java
similarity index 100%
rename from graphics/java/android/renderscript/Float3.java
rename to rs/java/android/renderscript/Float3.java
diff --git a/graphics/java/android/renderscript/Float4.java b/rs/java/android/renderscript/Float4.java
similarity index 100%
rename from graphics/java/android/renderscript/Float4.java
rename to rs/java/android/renderscript/Float4.java
diff --git a/graphics/java/android/renderscript/Font.java b/rs/java/android/renderscript/Font.java
similarity index 96%
rename from graphics/java/android/renderscript/Font.java
rename to rs/java/android/renderscript/Font.java
index 0375d2b..cfd11c0 100644
--- a/graphics/java/android/renderscript/Font.java
+++ b/rs/java/android/renderscript/Font.java
@@ -151,7 +151,7 @@
return "DroidSans.ttf";
}
- Font(int id, RenderScript rs) {
+ Font(long id, RenderScript rs) {
super(id, rs);
}
@@ -162,7 +162,7 @@
static public Font createFromFile(RenderScript rs, Resources res, String path, float pointSize) {
rs.validate();
int dpi = res.getDisplayMetrics().densityDpi;
- int fontId = rs.nFontCreateFromFile(path, pointSize, dpi);
+ long fontId = rs.nFontCreateFromFile(path, pointSize, dpi);
if(fontId == 0) {
throw new RSRuntimeException("Unable to create font from file " + path);
@@ -187,7 +187,7 @@
AssetManager mgr = res.getAssets();
int dpi = res.getDisplayMetrics().densityDpi;
- int fontId = rs.nFontCreateFromAsset(mgr, path, pointSize, dpi);
+ long fontId = rs.nFontCreateFromAsset(mgr, path, pointSize, dpi);
if(fontId == 0) {
throw new RSRuntimeException("Unable to create font from asset " + path);
}
@@ -211,9 +211,9 @@
int dpi = res.getDisplayMetrics().densityDpi;
- int fontId = 0;
+ long fontId = 0;
if (is instanceof AssetManager.AssetInputStream) {
- int asset = ((AssetManager.AssetInputStream) is).getAssetInt();
+ long asset = ((AssetManager.AssetInputStream) is).getNativeAsset();
fontId = rs.nFontCreateFromAssetStream(name, pointSize, dpi, asset);
} else {
throw new RSRuntimeException("Unsupported asset stream created");
diff --git a/graphics/java/android/renderscript/Int2.java b/rs/java/android/renderscript/Int2.java
similarity index 100%
rename from graphics/java/android/renderscript/Int2.java
rename to rs/java/android/renderscript/Int2.java
diff --git a/graphics/java/android/renderscript/Int3.java b/rs/java/android/renderscript/Int3.java
similarity index 100%
rename from graphics/java/android/renderscript/Int3.java
rename to rs/java/android/renderscript/Int3.java
diff --git a/graphics/java/android/renderscript/Int4.java b/rs/java/android/renderscript/Int4.java
similarity index 100%
rename from graphics/java/android/renderscript/Int4.java
rename to rs/java/android/renderscript/Int4.java
diff --git a/graphics/java/android/renderscript/Long2.java b/rs/java/android/renderscript/Long2.java
similarity index 100%
rename from graphics/java/android/renderscript/Long2.java
rename to rs/java/android/renderscript/Long2.java
diff --git a/graphics/java/android/renderscript/Long3.java b/rs/java/android/renderscript/Long3.java
similarity index 100%
rename from graphics/java/android/renderscript/Long3.java
rename to rs/java/android/renderscript/Long3.java
diff --git a/graphics/java/android/renderscript/Long4.java b/rs/java/android/renderscript/Long4.java
similarity index 99%
rename from graphics/java/android/renderscript/Long4.java
rename to rs/java/android/renderscript/Long4.java
index 757b910..1a1ad74 100644
--- a/graphics/java/android/renderscript/Long4.java
+++ b/rs/java/android/renderscript/Long4.java
@@ -505,7 +505,7 @@
* @param data
* @param offset
*/
- public void copyTo(Long[] data, int offset) {
+ public void copyTo(long[] data, int offset) {
data[offset] = (long)(x);
data[offset + 1] = (long)(y);
data[offset + 2] = (long)(z);
diff --git a/graphics/java/android/renderscript/Matrix2f.java b/rs/java/android/renderscript/Matrix2f.java
similarity index 100%
rename from graphics/java/android/renderscript/Matrix2f.java
rename to rs/java/android/renderscript/Matrix2f.java
diff --git a/graphics/java/android/renderscript/Matrix3f.java b/rs/java/android/renderscript/Matrix3f.java
similarity index 100%
rename from graphics/java/android/renderscript/Matrix3f.java
rename to rs/java/android/renderscript/Matrix3f.java
diff --git a/graphics/java/android/renderscript/Matrix4f.java b/rs/java/android/renderscript/Matrix4f.java
similarity index 100%
rename from graphics/java/android/renderscript/Matrix4f.java
rename to rs/java/android/renderscript/Matrix4f.java
diff --git a/graphics/java/android/renderscript/Mesh.java b/rs/java/android/renderscript/Mesh.java
similarity index 97%
rename from graphics/java/android/renderscript/Mesh.java
rename to rs/java/android/renderscript/Mesh.java
index bca4aa3..ca0da9d 100644
--- a/graphics/java/android/renderscript/Mesh.java
+++ b/rs/java/android/renderscript/Mesh.java
@@ -91,7 +91,7 @@
Allocation[] mIndexBuffers;
Primitive[] mPrimitives;
- Mesh(int id, RenderScript rs) {
+ Mesh(long id, RenderScript rs) {
super(id, rs);
}
@@ -154,8 +154,8 @@
int vtxCount = mRS.nMeshGetVertexBufferCount(getID(mRS));
int idxCount = mRS.nMeshGetIndexCount(getID(mRS));
- int[] vtxIDs = new int[vtxCount];
- int[] idxIDs = new int[idxCount];
+ long[] vtxIDs = new long[vtxCount];
+ long[] idxIDs = new long[idxCount];
int[] primitives = new int[idxCount];
mRS.nMeshGetVertices(getID(mRS), vtxIDs, vtxCount);
@@ -350,8 +350,8 @@
**/
public Mesh create() {
mRS.validate();
- int[] vtx = new int[mVertexTypeCount];
- int[] idx = new int[mIndexTypes.size()];
+ long[] vtx = new long[mVertexTypeCount];
+ long[] idx = new long[mIndexTypes.size()];
int[] prim = new int[mIndexTypes.size()];
Allocation[] vertexBuffers = new Allocation[mVertexTypeCount];
@@ -378,7 +378,7 @@
} else if(entry.e != null) {
alloc = Allocation.createSized(mRS, entry.e, entry.size, mUsage);
}
- int allocID = (alloc == null) ? 0 : alloc.getID(mRS);
+ long allocID = (alloc == null) ? 0 : alloc.getID(mRS);
indexBuffers[ct] = alloc;
primitives[ct] = entry.prim;
@@ -386,7 +386,7 @@
prim[ct] = entry.prim.mID;
}
- int id = mRS.nMeshCreate(vtx, idx, prim);
+ long id = mRS.nMeshCreate(vtx, idx, prim);
Mesh newMesh = new Mesh(id, mRS);
newMesh.mVertexBuffers = vertexBuffers;
newMesh.mIndexBuffers = indexBuffers;
@@ -506,8 +506,8 @@
public Mesh create() {
mRS.validate();
- int[] vtx = new int[mVertexTypeCount];
- int[] idx = new int[mIndexTypes.size()];
+ long[] vtx = new long[mVertexTypeCount];
+ long[] idx = new long[mIndexTypes.size()];
int[] prim = new int[mIndexTypes.size()];
Allocation[] indexBuffers = new Allocation[mIndexTypes.size()];
@@ -522,7 +522,7 @@
for(int ct = 0; ct < mIndexTypes.size(); ct ++) {
Entry entry = (Entry)mIndexTypes.elementAt(ct);
- int allocID = (entry.a == null) ? 0 : entry.a.getID(mRS);
+ long allocID = (entry.a == null) ? 0 : entry.a.getID(mRS);
indexBuffers[ct] = entry.a;
primitives[ct] = entry.prim;
@@ -530,7 +530,7 @@
prim[ct] = entry.prim.mID;
}
- int id = mRS.nMeshCreate(vtx, idx, prim);
+ long id = mRS.nMeshCreate(vtx, idx, prim);
Mesh newMesh = new Mesh(id, mRS);
newMesh.mVertexBuffers = vertexBuffers;
newMesh.mIndexBuffers = indexBuffers;
diff --git a/graphics/java/android/renderscript/Path.java b/rs/java/android/renderscript/Path.java
similarity index 92%
rename from graphics/java/android/renderscript/Path.java
rename to rs/java/android/renderscript/Path.java
index 9c4d41b..5cc67de 100644
--- a/graphics/java/android/renderscript/Path.java
+++ b/rs/java/android/renderscript/Path.java
@@ -41,7 +41,7 @@
float mQuality;
boolean mCoverageToAlpha;
- Path(int id, RenderScript rs, Primitive p, Allocation vtx, Allocation loop, float q) {
+ Path(long id, RenderScript rs, Primitive p, Allocation vtx, Allocation loop, float q) {
super(id, rs);
mVertexBuffer = vtx;
mLoopBuffer = loop;
@@ -67,7 +67,7 @@
public static Path createStaticPath(RenderScript rs, Primitive p, float quality, Allocation vtx) {
- int id = rs.nPathCreate(p.mID, false, vtx.getID(rs), 0, quality);
+ long id = rs.nPathCreate(p.mID, false, vtx.getID(rs), 0, quality);
Path newPath = new Path(id, rs, p, null, null, quality);
return newPath;
}
diff --git a/graphics/java/android/renderscript/Program.java b/rs/java/android/renderscript/Program.java
similarity index 98%
rename from graphics/java/android/renderscript/Program.java
rename to rs/java/android/renderscript/Program.java
index bc2ca35..3eb9b75 100644
--- a/graphics/java/android/renderscript/Program.java
+++ b/rs/java/android/renderscript/Program.java
@@ -74,7 +74,7 @@
int mTextureCount;
String mShader;
- Program(int id, RenderScript rs) {
+ Program(long id, RenderScript rs) {
super(id, rs);
}
@@ -150,7 +150,7 @@
a.getType().getID(mRS) != mConstants[slot].getID(mRS)) {
throw new IllegalArgumentException("Allocation type does not match slot type.");
}
- int id = a != null ? a.getID(mRS) : 0;
+ long id = a != null ? a.getID(mRS) : 0;
mRS.nProgramBindConstants(getID(mRS), slot, id);
}
@@ -172,7 +172,7 @@
throw new IllegalArgumentException("Cannot bind cubemap to 2d texture slot");
}
- int id = va != null ? va.getID(mRS) : 0;
+ long id = va != null ? va.getID(mRS) : 0;
mRS.nProgramBindTexture(getID(mRS), slot, id);
}
@@ -192,7 +192,7 @@
throw new IllegalArgumentException("Slot ID out of range.");
}
- int id = vs != null ? vs.getID(mRS) : 0;
+ long id = vs != null ? vs.getID(mRS) : 0;
mRS.nProgramBindSampler(getID(mRS), slot, id);
}
diff --git a/graphics/java/android/renderscript/ProgramFragment.java b/rs/java/android/renderscript/ProgramFragment.java
similarity index 93%
rename from graphics/java/android/renderscript/ProgramFragment.java
rename to rs/java/android/renderscript/ProgramFragment.java
index b9ba3fd..4bb527b 100644
--- a/graphics/java/android/renderscript/ProgramFragment.java
+++ b/rs/java/android/renderscript/ProgramFragment.java
@@ -39,7 +39,7 @@
*
**/
public class ProgramFragment extends Program {
- ProgramFragment(int id, RenderScript rs) {
+ ProgramFragment(long id, RenderScript rs) {
super(id, rs);
}
@@ -65,7 +65,7 @@
*/
public ProgramFragment create() {
mRS.validate();
- int[] tmp = new int[(mInputCount + mOutputCount + mConstantCount + mTextureCount) * 2];
+ long[] tmp = new long[(mInputCount + mOutputCount + mConstantCount + mTextureCount) * 2];
String[] texNames = new String[mTextureCount];
int idx = 0;
@@ -87,7 +87,7 @@
texNames[i] = mTextureNames[i];
}
- int id = mRS.nProgramFragmentCreate(mShader, texNames, tmp);
+ long id = mRS.nProgramFragmentCreate(mShader, texNames, tmp);
ProgramFragment pf = new ProgramFragment(id, mRS);
initProgram(pf);
return pf;
diff --git a/graphics/java/android/renderscript/ProgramFragmentFixedFunction.java b/rs/java/android/renderscript/ProgramFragmentFixedFunction.java
similarity index 97%
rename from graphics/java/android/renderscript/ProgramFragmentFixedFunction.java
rename to rs/java/android/renderscript/ProgramFragmentFixedFunction.java
index 8ae1777..2fe68be 100644
--- a/graphics/java/android/renderscript/ProgramFragmentFixedFunction.java
+++ b/rs/java/android/renderscript/ProgramFragmentFixedFunction.java
@@ -31,7 +31,7 @@
*
**/
public class ProgramFragmentFixedFunction extends ProgramFragment {
- ProgramFragmentFixedFunction(int id, RenderScript rs) {
+ ProgramFragmentFixedFunction(long id, RenderScript rs) {
super(id, rs);
}
@@ -52,7 +52,7 @@
*/
public ProgramFragmentFixedFunction create() {
mRS.validate();
- int[] tmp = new int[(mInputCount + mOutputCount + mConstantCount + mTextureCount) * 2];
+ long[] tmp = new long[(mInputCount + mOutputCount + mConstantCount + mTextureCount) * 2];
String[] texNames = new String[mTextureCount];
int idx = 0;
@@ -74,7 +74,7 @@
texNames[i] = mTextureNames[i];
}
- int id = mRS.nProgramFragmentCreate(mShader, texNames, tmp);
+ long id = mRS.nProgramFragmentCreate(mShader, texNames, tmp);
ProgramFragmentFixedFunction pf = new ProgramFragmentFixedFunction(id, mRS);
initProgram(pf);
return pf;
diff --git a/graphics/java/android/renderscript/ProgramRaster.java b/rs/java/android/renderscript/ProgramRaster.java
similarity index 96%
rename from graphics/java/android/renderscript/ProgramRaster.java
rename to rs/java/android/renderscript/ProgramRaster.java
index 216cb4e..e294b05 100644
--- a/graphics/java/android/renderscript/ProgramRaster.java
+++ b/rs/java/android/renderscript/ProgramRaster.java
@@ -54,7 +54,7 @@
boolean mPointSprite;
CullMode mCullMode;
- ProgramRaster(int id, RenderScript rs) {
+ ProgramRaster(long id, RenderScript rs) {
super(id, rs);
mPointSprite = false;
@@ -154,7 +154,7 @@
*/
public ProgramRaster create() {
mRS.validate();
- int id = mRS.nProgramRasterCreate(mPointSprite, mCullMode.mID);
+ long id = mRS.nProgramRasterCreate(mPointSprite, mCullMode.mID);
ProgramRaster programRaster = new ProgramRaster(id, mRS);
programRaster.mPointSprite = mPointSprite;
programRaster.mCullMode = mCullMode;
diff --git a/graphics/java/android/renderscript/ProgramStore.java b/rs/java/android/renderscript/ProgramStore.java
similarity index 98%
rename from graphics/java/android/renderscript/ProgramStore.java
rename to rs/java/android/renderscript/ProgramStore.java
index dac9e76..969cc25 100644
--- a/graphics/java/android/renderscript/ProgramStore.java
+++ b/rs/java/android/renderscript/ProgramStore.java
@@ -146,7 +146,7 @@
BlendDstFunc mBlendDst;
boolean mDither;
- ProgramStore(int id, RenderScript rs) {
+ ProgramStore(long id, RenderScript rs) {
super(id, rs);
}
@@ -421,7 +421,7 @@
*/
public ProgramStore create() {
mRS.validate();
- int id = mRS.nProgramStoreCreate(mColorMaskR, mColorMaskG, mColorMaskB, mColorMaskA,
+ long id = mRS.nProgramStoreCreate(mColorMaskR, mColorMaskG, mColorMaskB, mColorMaskA,
mDepthMask, mDither,
mBlendSrc.mID, mBlendDst.mID, mDepthFunc.mID);
ProgramStore programStore = new ProgramStore(id, mRS);
diff --git a/graphics/java/android/renderscript/ProgramVertex.java b/rs/java/android/renderscript/ProgramVertex.java
similarity index 95%
rename from graphics/java/android/renderscript/ProgramVertex.java
rename to rs/java/android/renderscript/ProgramVertex.java
index 1c5a191..d3a51de 100644
--- a/graphics/java/android/renderscript/ProgramVertex.java
+++ b/rs/java/android/renderscript/ProgramVertex.java
@@ -53,7 +53,7 @@
**/
public class ProgramVertex extends Program {
- ProgramVertex(int id, RenderScript rs) {
+ ProgramVertex(long id, RenderScript rs) {
super(id, rs);
}
@@ -126,7 +126,7 @@
*/
public ProgramVertex create() {
mRS.validate();
- int[] tmp = new int[(mInputCount + mOutputCount + mConstantCount + mTextureCount) * 2];
+ long[] tmp = new long[(mInputCount + mOutputCount + mConstantCount + mTextureCount) * 2];
String[] texNames = new String[mTextureCount];
int idx = 0;
@@ -148,7 +148,7 @@
texNames[i] = mTextureNames[i];
}
- int id = mRS.nProgramVertexCreate(mShader, texNames, tmp);
+ long id = mRS.nProgramVertexCreate(mShader, texNames, tmp);
ProgramVertex pv = new ProgramVertex(id, mRS);
initProgram(pv);
return pv;
diff --git a/graphics/java/android/renderscript/ProgramVertexFixedFunction.java b/rs/java/android/renderscript/ProgramVertexFixedFunction.java
similarity index 97%
rename from graphics/java/android/renderscript/ProgramVertexFixedFunction.java
rename to rs/java/android/renderscript/ProgramVertexFixedFunction.java
index ad486f3..a350154 100644
--- a/graphics/java/android/renderscript/ProgramVertexFixedFunction.java
+++ b/rs/java/android/renderscript/ProgramVertexFixedFunction.java
@@ -31,7 +31,7 @@
**/
public class ProgramVertexFixedFunction extends ProgramVertex {
- ProgramVertexFixedFunction(int id, RenderScript rs) {
+ ProgramVertexFixedFunction(long id, RenderScript rs) {
super(id, rs);
}
@@ -79,7 +79,7 @@
*/
public ProgramVertexFixedFunction create() {
mRS.validate();
- int[] tmp = new int[(mInputCount + mOutputCount + mConstantCount + mTextureCount) * 2];
+ long[] tmp = new long[(mInputCount + mOutputCount + mConstantCount + mTextureCount) * 2];
String[] texNames = new String[mTextureCount];
int idx = 0;
@@ -101,7 +101,7 @@
texNames[i] = mTextureNames[i];
}
- int id = mRS.nProgramVertexCreate(mShader, texNames, tmp);
+ long id = mRS.nProgramVertexCreate(mShader, texNames, tmp);
ProgramVertexFixedFunction pv = new ProgramVertexFixedFunction(id, mRS);
initProgram(pv);
return pv;
diff --git a/graphics/java/android/renderscript/RSDriverException.java b/rs/java/android/renderscript/RSDriverException.java
similarity index 100%
rename from graphics/java/android/renderscript/RSDriverException.java
rename to rs/java/android/renderscript/RSDriverException.java
diff --git a/graphics/java/android/renderscript/RSIllegalArgumentException.java b/rs/java/android/renderscript/RSIllegalArgumentException.java
similarity index 100%
rename from graphics/java/android/renderscript/RSIllegalArgumentException.java
rename to rs/java/android/renderscript/RSIllegalArgumentException.java
diff --git a/graphics/java/android/renderscript/RSInvalidStateException.java b/rs/java/android/renderscript/RSInvalidStateException.java
similarity index 100%
rename from graphics/java/android/renderscript/RSInvalidStateException.java
rename to rs/java/android/renderscript/RSInvalidStateException.java
diff --git a/graphics/java/android/renderscript/RSRuntimeException.java b/rs/java/android/renderscript/RSRuntimeException.java
similarity index 100%
rename from graphics/java/android/renderscript/RSRuntimeException.java
rename to rs/java/android/renderscript/RSRuntimeException.java
diff --git a/graphics/java/android/renderscript/RSSurfaceView.java b/rs/java/android/renderscript/RSSurfaceView.java
similarity index 100%
rename from graphics/java/android/renderscript/RSSurfaceView.java
rename to rs/java/android/renderscript/RSSurfaceView.java
diff --git a/graphics/java/android/renderscript/RSTextureView.java b/rs/java/android/renderscript/RSTextureView.java
similarity index 100%
rename from graphics/java/android/renderscript/RSTextureView.java
rename to rs/java/android/renderscript/RSTextureView.java
diff --git a/graphics/java/android/renderscript/RenderScript.java b/rs/java/android/renderscript/RenderScript.java
similarity index 61%
rename from graphics/java/android/renderscript/RenderScript.java
rename to rs/java/android/renderscript/RenderScript.java
index 7d4a5c4..ea25f58 100644
--- a/graphics/java/android/renderscript/RenderScript.java
+++ b/rs/java/android/renderscript/RenderScript.java
@@ -19,6 +19,7 @@
import java.io.File;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
import android.content.Context;
import android.content.pm.ApplicationInfo;
@@ -91,17 +92,31 @@
}
// Non-threadsafe functions.
- native int nDeviceCreate();
- native void nDeviceDestroy(int dev);
- native void nDeviceSetConfig(int dev, int param, int value);
- native int nContextGetUserMessage(int con, int[] data);
- native String nContextGetErrorMessage(int con);
- native int nContextPeekMessage(int con, int[] subID);
- native void nContextInitToClient(int con);
- native void nContextDeinitToClient(int con);
+ native long nDeviceCreate();
+ native void nDeviceDestroy(long dev);
+ native void nDeviceSetConfig(long dev, int param, int value);
+ native int nContextGetUserMessage(long con, int[] data);
+ native String nContextGetErrorMessage(long con);
+ native int nContextPeekMessage(long con, int[] subID);
+ native void nContextInitToClient(long con);
+ native void nContextDeinitToClient(long con);
static File mCacheDir;
+ // this should be a monotonically increasing ID
+ // used in conjunction with the API version of a device
+ static final long sMinorID = 1;
+
+ /**
+ * Returns an identifier that can be used to identify a particular
+ * minor version of RS.
+ *
+ * @hide
+ */
+ public static long getMinorID() {
+ return sMinorID;
+ }
+
/**
* Sets the directory to use as a persistent storage for the
* renderscript object file cache.
@@ -151,16 +166,17 @@
}
ContextType mContextType;
+ ReentrantReadWriteLock mRWLock;
// Methods below are wrapped to protect the non-threadsafe
// lockless fifo.
- native int rsnContextCreateGL(int dev, int ver, int sdkVer,
+ native long rsnContextCreateGL(long dev, int ver, int sdkVer,
int colorMin, int colorPref,
int alphaMin, int alphaPref,
int depthMin, int depthPref,
int stencilMin, int stencilPref,
int samplesMin, int samplesPref, float samplesQ, int dpi);
- synchronized int nContextCreateGL(int dev, int ver, int sdkVer,
+ synchronized long nContextCreateGL(long dev, int ver, int sdkVer,
int colorMin, int colorPref,
int alphaMin, int alphaPref,
int depthMin, int depthPref,
@@ -171,100 +187,113 @@
stencilMin, stencilPref,
samplesMin, samplesPref, samplesQ, dpi);
}
- native int rsnContextCreate(int dev, int ver, int sdkVer, int contextType);
- synchronized int nContextCreate(int dev, int ver, int sdkVer, int contextType) {
+ native long rsnContextCreate(long dev, int ver, int sdkVer, int contextType);
+ synchronized long nContextCreate(long dev, int ver, int sdkVer, int contextType) {
return rsnContextCreate(dev, ver, sdkVer, contextType);
}
- native void rsnContextDestroy(int con);
+ native void rsnContextDestroy(long con);
synchronized void nContextDestroy() {
validate();
- rsnContextDestroy(mContext);
+
+ // take teardown lock
+ // teardown lock can only be taken when no objects are being destroyed
+ ReentrantReadWriteLock.WriteLock wlock = mRWLock.writeLock();
+ wlock.lock();
+
+ long curCon = mContext;
+ // context is considered dead as of this point
+ mContext = 0;
+
+ wlock.unlock();
+ rsnContextDestroy(curCon);
}
- native void rsnContextSetSurface(int con, int w, int h, Surface sur);
+ native void rsnContextSetSurface(long con, int w, int h, Surface sur);
synchronized void nContextSetSurface(int w, int h, Surface sur) {
validate();
rsnContextSetSurface(mContext, w, h, sur);
}
- native void rsnContextSetSurfaceTexture(int con, int w, int h, SurfaceTexture sur);
+ native void rsnContextSetSurfaceTexture(long con, int w, int h, SurfaceTexture sur);
synchronized void nContextSetSurfaceTexture(int w, int h, SurfaceTexture sur) {
validate();
rsnContextSetSurfaceTexture(mContext, w, h, sur);
}
- native void rsnContextSetPriority(int con, int p);
+ native void rsnContextSetPriority(long con, int p);
synchronized void nContextSetPriority(int p) {
validate();
rsnContextSetPriority(mContext, p);
}
- native void rsnContextDump(int con, int bits);
+ native void rsnContextDump(long con, int bits);
synchronized void nContextDump(int bits) {
validate();
rsnContextDump(mContext, bits);
}
- native void rsnContextFinish(int con);
+ native void rsnContextFinish(long con);
synchronized void nContextFinish() {
validate();
rsnContextFinish(mContext);
}
- native void rsnContextSendMessage(int con, int id, int[] data);
+ native void rsnContextSendMessage(long con, int id, int[] data);
synchronized void nContextSendMessage(int id, int[] data) {
validate();
rsnContextSendMessage(mContext, id, data);
}
- native void rsnContextBindRootScript(int con, int script);
- synchronized void nContextBindRootScript(int script) {
+ native void rsnContextBindRootScript(long con, long script);
+ synchronized void nContextBindRootScript(long script) {
validate();
rsnContextBindRootScript(mContext, script);
}
- native void rsnContextBindSampler(int con, int sampler, int slot);
+ native void rsnContextBindSampler(long con, int sampler, int slot);
synchronized void nContextBindSampler(int sampler, int slot) {
validate();
rsnContextBindSampler(mContext, sampler, slot);
}
- native void rsnContextBindProgramStore(int con, int pfs);
- synchronized void nContextBindProgramStore(int pfs) {
+ native void rsnContextBindProgramStore(long con, long pfs);
+ synchronized void nContextBindProgramStore(long pfs) {
validate();
rsnContextBindProgramStore(mContext, pfs);
}
- native void rsnContextBindProgramFragment(int con, int pf);
- synchronized void nContextBindProgramFragment(int pf) {
+ native void rsnContextBindProgramFragment(long con, long pf);
+ synchronized void nContextBindProgramFragment(long pf) {
validate();
rsnContextBindProgramFragment(mContext, pf);
}
- native void rsnContextBindProgramVertex(int con, int pv);
- synchronized void nContextBindProgramVertex(int pv) {
+ native void rsnContextBindProgramVertex(long con, long pv);
+ synchronized void nContextBindProgramVertex(long pv) {
validate();
rsnContextBindProgramVertex(mContext, pv);
}
- native void rsnContextBindProgramRaster(int con, int pr);
- synchronized void nContextBindProgramRaster(int pr) {
+ native void rsnContextBindProgramRaster(long con, long pr);
+ synchronized void nContextBindProgramRaster(long pr) {
validate();
rsnContextBindProgramRaster(mContext, pr);
}
- native void rsnContextPause(int con);
+ native void rsnContextPause(long con);
synchronized void nContextPause() {
validate();
rsnContextPause(mContext);
}
- native void rsnContextResume(int con);
+ native void rsnContextResume(long con);
synchronized void nContextResume() {
validate();
rsnContextResume(mContext);
}
- native void rsnAssignName(int con, int obj, byte[] name);
- synchronized void nAssignName(int obj, byte[] name) {
+ native void rsnAssignName(long con, long obj, byte[] name);
+ synchronized void nAssignName(long obj, byte[] name) {
validate();
rsnAssignName(mContext, obj, name);
}
- native String rsnGetName(int con, int obj);
- synchronized String nGetName(int obj) {
+ native String rsnGetName(long con, long obj);
+ synchronized String nGetName(long obj) {
validate();
return rsnGetName(mContext, obj);
}
- native void rsnObjDestroy(int con, int id);
- synchronized void nObjDestroy(int id) {
+
+ // nObjDestroy is explicitly _not_ synchronous to prevent crashes in finalizers
+ native void rsnObjDestroy(long con, long id);
+ void nObjDestroy(long id) {
// There is a race condition here. The calling code may be run
// by the gc while teardown is occuring. This protects againts
// deleting dead objects.
@@ -273,156 +302,140 @@
}
}
- native int rsnElementCreate(int con, int type, int kind, boolean norm, int vecSize);
- synchronized int nElementCreate(int type, int kind, boolean norm, int vecSize) {
+ native long rsnElementCreate(long con, long type, int kind, boolean norm, int vecSize);
+ synchronized long nElementCreate(long type, int kind, boolean norm, int vecSize) {
validate();
return rsnElementCreate(mContext, type, kind, norm, vecSize);
}
- native int rsnElementCreate2(int con, int[] elements, String[] names, int[] arraySizes);
- synchronized int nElementCreate2(int[] elements, String[] names, int[] arraySizes) {
+ native long rsnElementCreate2(long con, long[] elements, String[] names, int[] arraySizes);
+ synchronized long nElementCreate2(long[] elements, String[] names, int[] arraySizes) {
validate();
return rsnElementCreate2(mContext, elements, names, arraySizes);
}
- native void rsnElementGetNativeData(int con, int id, int[] elementData);
- synchronized void nElementGetNativeData(int id, int[] elementData) {
+ native void rsnElementGetNativeData(long con, long id, int[] elementData);
+ synchronized void nElementGetNativeData(long id, int[] elementData) {
validate();
rsnElementGetNativeData(mContext, id, elementData);
}
- native void rsnElementGetSubElements(int con, int id,
- int[] IDs, String[] names, int[] arraySizes);
- synchronized void nElementGetSubElements(int id, int[] IDs, String[] names, int[] arraySizes) {
+ native void rsnElementGetSubElements(long con, long id,
+ long[] IDs, String[] names, int[] arraySizes);
+ synchronized void nElementGetSubElements(long id, long[] IDs, String[] names, int[] arraySizes) {
validate();
rsnElementGetSubElements(mContext, id, IDs, names, arraySizes);
}
- native int rsnTypeCreate(int con, int eid, int x, int y, int z, boolean mips, boolean faces, int yuv);
- synchronized int nTypeCreate(int eid, int x, int y, int z, boolean mips, boolean faces, int yuv) {
+ native long rsnTypeCreate(long con, long eid, int x, int y, int z, boolean mips, boolean faces, int yuv);
+ synchronized long nTypeCreate(long eid, int x, int y, int z, boolean mips, boolean faces, int yuv) {
validate();
return rsnTypeCreate(mContext, eid, x, y, z, mips, faces, yuv);
}
- native void rsnTypeGetNativeData(int con, int id, int[] typeData);
- synchronized void nTypeGetNativeData(int id, int[] typeData) {
+ native void rsnTypeGetNativeData(long con, long id, long[] typeData);
+ synchronized void nTypeGetNativeData(long id, long[] typeData) {
validate();
rsnTypeGetNativeData(mContext, id, typeData);
}
- native int rsnAllocationCreateTyped(int con, int type, int mip, int usage, int pointer);
- synchronized int nAllocationCreateTyped(int type, int mip, int usage, int pointer) {
+ native long rsnAllocationCreateTyped(long con, long type, int mip, int usage, long pointer);
+ synchronized long nAllocationCreateTyped(long type, int mip, int usage, long pointer) {
validate();
return rsnAllocationCreateTyped(mContext, type, mip, usage, pointer);
}
- native int rsnAllocationCreateFromBitmap(int con, int type, int mip, Bitmap bmp, int usage);
- synchronized int nAllocationCreateFromBitmap(int type, int mip, Bitmap bmp, int usage) {
+ native long rsnAllocationCreateFromBitmap(long con, long type, int mip, Bitmap bmp, int usage);
+ synchronized long nAllocationCreateFromBitmap(long type, int mip, Bitmap bmp, int usage) {
validate();
return rsnAllocationCreateFromBitmap(mContext, type, mip, bmp, usage);
}
- native int rsnAllocationCreateBitmapBackedAllocation(int con, int type, int mip, Bitmap bmp, int usage);
- synchronized int nAllocationCreateBitmapBackedAllocation(int type, int mip, Bitmap bmp, int usage) {
+ native long rsnAllocationCreateBitmapBackedAllocation(long con, long type, int mip, Bitmap bmp, int usage);
+ synchronized long nAllocationCreateBitmapBackedAllocation(long type, int mip, Bitmap bmp, int usage) {
validate();
return rsnAllocationCreateBitmapBackedAllocation(mContext, type, mip, bmp, usage);
}
-
- native int rsnAllocationCubeCreateFromBitmap(int con, int type, int mip, Bitmap bmp, int usage);
- synchronized int nAllocationCubeCreateFromBitmap(int type, int mip, Bitmap bmp, int usage) {
+ native long rsnAllocationCubeCreateFromBitmap(long con, long type, int mip, Bitmap bmp, int usage);
+ synchronized long nAllocationCubeCreateFromBitmap(long type, int mip, Bitmap bmp, int usage) {
validate();
return rsnAllocationCubeCreateFromBitmap(mContext, type, mip, bmp, usage);
}
- native int rsnAllocationCreateBitmapRef(int con, int type, Bitmap bmp);
- synchronized int nAllocationCreateBitmapRef(int type, Bitmap bmp) {
+ native long rsnAllocationCreateBitmapRef(long con, long type, Bitmap bmp);
+ synchronized long nAllocationCreateBitmapRef(long type, Bitmap bmp) {
validate();
return rsnAllocationCreateBitmapRef(mContext, type, bmp);
}
- native int rsnAllocationCreateFromAssetStream(int con, int mips, int assetStream, int usage);
- synchronized int nAllocationCreateFromAssetStream(int mips, int assetStream, int usage) {
+ native long rsnAllocationCreateFromAssetStream(long con, int mips, int assetStream, int usage);
+ synchronized long nAllocationCreateFromAssetStream(int mips, int assetStream, int usage) {
validate();
return rsnAllocationCreateFromAssetStream(mContext, mips, assetStream, usage);
}
- native void rsnAllocationCopyToBitmap(int con, int alloc, Bitmap bmp);
- synchronized void nAllocationCopyToBitmap(int alloc, Bitmap bmp) {
+ native void rsnAllocationCopyToBitmap(long con, long alloc, Bitmap bmp);
+ synchronized void nAllocationCopyToBitmap(long alloc, Bitmap bmp) {
validate();
rsnAllocationCopyToBitmap(mContext, alloc, bmp);
}
- native void rsnAllocationSyncAll(int con, int alloc, int src);
- synchronized void nAllocationSyncAll(int alloc, int src) {
+ native void rsnAllocationSyncAll(long con, long alloc, int src);
+ synchronized void nAllocationSyncAll(long alloc, int src) {
validate();
rsnAllocationSyncAll(mContext, alloc, src);
}
- native Surface rsnAllocationGetSurface(int con, int alloc);
- synchronized Surface nAllocationGetSurface(int alloc) {
+ native Surface rsnAllocationGetSurface(long con, long alloc);
+ synchronized Surface nAllocationGetSurface(long alloc) {
validate();
return rsnAllocationGetSurface(mContext, alloc);
}
- native void rsnAllocationSetSurface(int con, int alloc, Surface sur);
- synchronized void nAllocationSetSurface(int alloc, Surface sur) {
+ native void rsnAllocationSetSurface(long con, long alloc, Surface sur);
+ synchronized void nAllocationSetSurface(long alloc, Surface sur) {
validate();
rsnAllocationSetSurface(mContext, alloc, sur);
}
- native void rsnAllocationIoSend(int con, int alloc);
- synchronized void nAllocationIoSend(int alloc) {
+ native void rsnAllocationIoSend(long con, long alloc);
+ synchronized void nAllocationIoSend(long alloc) {
validate();
rsnAllocationIoSend(mContext, alloc);
}
- native void rsnAllocationIoReceive(int con, int alloc);
- synchronized void nAllocationIoReceive(int alloc) {
+ native void rsnAllocationIoReceive(long con, long alloc);
+ synchronized void nAllocationIoReceive(long alloc) {
validate();
rsnAllocationIoReceive(mContext, alloc);
}
- native void rsnAllocationGenerateMipmaps(int con, int alloc);
- synchronized void nAllocationGenerateMipmaps(int alloc) {
+ native void rsnAllocationGenerateMipmaps(long con, long alloc);
+ synchronized void nAllocationGenerateMipmaps(long alloc) {
validate();
rsnAllocationGenerateMipmaps(mContext, alloc);
}
- native void rsnAllocationCopyFromBitmap(int con, int alloc, Bitmap bmp);
- synchronized void nAllocationCopyFromBitmap(int alloc, Bitmap bmp) {
+ native void rsnAllocationCopyFromBitmap(long con, long alloc, Bitmap bmp);
+ synchronized void nAllocationCopyFromBitmap(long alloc, Bitmap bmp) {
validate();
rsnAllocationCopyFromBitmap(mContext, alloc, bmp);
}
- native void rsnAllocationData1D(int con, int id, int off, int mip, int count, int[] d, int sizeBytes);
- synchronized void nAllocationData1D(int id, int off, int mip, int count, int[] d, int sizeBytes) {
+ native void rsnAllocationData1D(long con, long id, int off, int mip, int count, Object d, int sizeBytes, int dt);
+ synchronized void nAllocationData1D(long id, int off, int mip, int count, Object d, int sizeBytes, Element.DataType dt) {
validate();
- rsnAllocationData1D(mContext, id, off, mip, count, d, sizeBytes);
- }
- native void rsnAllocationData1D(int con, int id, int off, int mip, int count, short[] d, int sizeBytes);
- synchronized void nAllocationData1D(int id, int off, int mip, int count, short[] d, int sizeBytes) {
- validate();
- rsnAllocationData1D(mContext, id, off, mip, count, d, sizeBytes);
- }
- native void rsnAllocationData1D(int con, int id, int off, int mip, int count, byte[] d, int sizeBytes);
- synchronized void nAllocationData1D(int id, int off, int mip, int count, byte[] d, int sizeBytes) {
- validate();
- rsnAllocationData1D(mContext, id, off, mip, count, d, sizeBytes);
- }
- native void rsnAllocationData1D(int con, int id, int off, int mip, int count, float[] d, int sizeBytes);
- synchronized void nAllocationData1D(int id, int off, int mip, int count, float[] d, int sizeBytes) {
- validate();
- rsnAllocationData1D(mContext, id, off, mip, count, d, sizeBytes);
+ rsnAllocationData1D(mContext, id, off, mip, count, d, sizeBytes, dt.mID);
}
- native void rsnAllocationElementData1D(int con, int id, int xoff, int mip, int compIdx, byte[] d, int sizeBytes);
- synchronized void nAllocationElementData1D(int id, int xoff, int mip, int compIdx, byte[] d, int sizeBytes) {
+ native void rsnAllocationElementData1D(long con,long id, int xoff, int mip, int compIdx, byte[] d, int sizeBytes);
+ synchronized void nAllocationElementData1D(long id, int xoff, int mip, int compIdx, byte[] d, int sizeBytes) {
validate();
rsnAllocationElementData1D(mContext, id, xoff, mip, compIdx, d, sizeBytes);
}
- native void rsnAllocationData2D(int con,
- int dstAlloc, int dstXoff, int dstYoff,
+ native void rsnAllocationData2D(long con,
+ long dstAlloc, int dstXoff, int dstYoff,
int dstMip, int dstFace,
int width, int height,
- int srcAlloc, int srcXoff, int srcYoff,
+ long srcAlloc, int srcXoff, int srcYoff,
int srcMip, int srcFace);
- synchronized void nAllocationData2D(int dstAlloc, int dstXoff, int dstYoff,
+ synchronized void nAllocationData2D(long dstAlloc, int dstXoff, int dstYoff,
int dstMip, int dstFace,
int width, int height,
- int srcAlloc, int srcXoff, int srcYoff,
+ long srcAlloc, int srcXoff, int srcYoff,
int srcMip, int srcFace) {
validate();
rsnAllocationData2D(mContext,
@@ -433,42 +446,30 @@
srcMip, srcFace);
}
- native void rsnAllocationData2D(int con, int id, int xoff, int yoff, int mip, int face, int w, int h, byte[] d, int sizeBytes);
- synchronized void nAllocationData2D(int id, int xoff, int yoff, int mip, int face, int w, int h, byte[] d, int sizeBytes) {
+ native void rsnAllocationData2D(long con, long id, int xoff, int yoff, int mip, int face,
+ int w, int h, Object d, int sizeBytes, int dt);
+ synchronized void nAllocationData2D(long id, int xoff, int yoff, int mip, int face,
+ int w, int h, Object d, int sizeBytes, Element.DataType dt) {
validate();
- rsnAllocationData2D(mContext, id, xoff, yoff, mip, face, w, h, d, sizeBytes);
+ rsnAllocationData2D(mContext, id, xoff, yoff, mip, face, w, h, d, sizeBytes, dt.mID);
}
- native void rsnAllocationData2D(int con, int id, int xoff, int yoff, int mip, int face, int w, int h, short[] d, int sizeBytes);
- synchronized void nAllocationData2D(int id, int xoff, int yoff, int mip, int face, int w, int h, short[] d, int sizeBytes) {
- validate();
- rsnAllocationData2D(mContext, id, xoff, yoff, mip, face, w, h, d, sizeBytes);
- }
- native void rsnAllocationData2D(int con, int id, int xoff, int yoff, int mip, int face, int w, int h, int[] d, int sizeBytes);
- synchronized void nAllocationData2D(int id, int xoff, int yoff, int mip, int face, int w, int h, int[] d, int sizeBytes) {
- validate();
- rsnAllocationData2D(mContext, id, xoff, yoff, mip, face, w, h, d, sizeBytes);
- }
- native void rsnAllocationData2D(int con, int id, int xoff, int yoff, int mip, int face, int w, int h, float[] d, int sizeBytes);
- synchronized void nAllocationData2D(int id, int xoff, int yoff, int mip, int face, int w, int h, float[] d, int sizeBytes) {
- validate();
- rsnAllocationData2D(mContext, id, xoff, yoff, mip, face, w, h, d, sizeBytes);
- }
- native void rsnAllocationData2D(int con, int id, int xoff, int yoff, int mip, int face, Bitmap b);
- synchronized void nAllocationData2D(int id, int xoff, int yoff, int mip, int face, Bitmap b) {
+
+ native void rsnAllocationData2D(long con, long id, int xoff, int yoff, int mip, int face, Bitmap b);
+ synchronized void nAllocationData2D(long id, int xoff, int yoff, int mip, int face, Bitmap b) {
validate();
rsnAllocationData2D(mContext, id, xoff, yoff, mip, face, b);
}
- native void rsnAllocationData3D(int con,
- int dstAlloc, int dstXoff, int dstYoff, int dstZoff,
+ native void rsnAllocationData3D(long con,
+ long dstAlloc, int dstXoff, int dstYoff, int dstZoff,
int dstMip,
int width, int height, int depth,
- int srcAlloc, int srcXoff, int srcYoff, int srcZoff,
+ long srcAlloc, int srcXoff, int srcYoff, int srcZoff,
int srcMip);
- synchronized void nAllocationData3D(int dstAlloc, int dstXoff, int dstYoff, int dstZoff,
+ synchronized void nAllocationData3D(long dstAlloc, int dstXoff, int dstYoff, int dstZoff,
int dstMip,
int width, int height, int depth,
- int srcAlloc, int srcXoff, int srcYoff, int srcZoff,
+ long srcAlloc, int srcXoff, int srcYoff, int srcZoff,
int srcMip) {
validate();
rsnAllocationData3D(mContext,
@@ -477,130 +478,118 @@
srcAlloc, srcXoff, srcYoff, srcZoff, srcMip);
}
- native void rsnAllocationData3D(int con, int id, int xoff, int yoff, int zoff, int mip, int w, int h, int depth, byte[] d, int sizeBytes);
- synchronized void nAllocationData3D(int id, int xoff, int yoff, int zoff, int mip, int w, int h, int depth, byte[] d, int sizeBytes) {
+ native void rsnAllocationData3D(long con, long id, int xoff, int yoff, int zoff, int mip,
+ int w, int h, int depth, Object d, int sizeBytes, int dt);
+ synchronized void nAllocationData3D(long id, int xoff, int yoff, int zoff, int mip,
+ int w, int h, int depth, Object d, int sizeBytes, Element.DataType dt) {
validate();
- rsnAllocationData3D(mContext, id, xoff, yoff, zoff, mip, w, h, depth, d, sizeBytes);
- }
- native void rsnAllocationData3D(int con, int id, int xoff, int yoff, int zoff, int mip, int w, int h, int depth, short[] d, int sizeBytes);
- synchronized void nAllocationData3D(int id, int xoff, int yoff, int zoff, int mip, int w, int h, int depth, short[] d, int sizeBytes) {
- validate();
- rsnAllocationData3D(mContext, id, xoff, yoff, zoff, mip, w, h, depth, d, sizeBytes);
- }
- native void rsnAllocationData3D(int con, int id, int xoff, int yoff, int zoff, int mip, int w, int h, int depth, int[] d, int sizeBytes);
- synchronized void nAllocationData3D(int id, int xoff, int yoff, int zoff, int mip, int w, int h, int depth, int[] d, int sizeBytes) {
- validate();
- rsnAllocationData3D(mContext, id, xoff, yoff, zoff, mip, w, h, depth, d, sizeBytes);
- }
- native void rsnAllocationData3D(int con, int id, int xoff, int yoff, int zoff, int mip, int w, int h, int depth, float[] d, int sizeBytes);
- synchronized void nAllocationData3D(int id, int xoff, int yoff, int zoff, int mip, int w, int h, int depth, float[] d, int sizeBytes) {
- validate();
- rsnAllocationData3D(mContext, id, xoff, yoff, zoff, mip, w, h, depth, d, sizeBytes);
+ rsnAllocationData3D(mContext, id, xoff, yoff, zoff, mip, w, h, depth, d, sizeBytes, dt.mID);
}
+ native void rsnAllocationRead(long con, long id, Object d, int dt);
+ synchronized void nAllocationRead(long id, Object d, Element.DataType dt) {
+ validate();
+ rsnAllocationRead(mContext, id, d, dt.mID);
+ }
- native void rsnAllocationRead(int con, int id, byte[] d);
- synchronized void nAllocationRead(int id, byte[] d) {
+ native void rsnAllocationRead1D(long con, long id, int off, int mip, int count, Object d,
+ int sizeBytes, int dt);
+ synchronized void nAllocationRead1D(long id, int off, int mip, int count, Object d,
+ int sizeBytes, Element.DataType dt) {
validate();
- rsnAllocationRead(mContext, id, d);
+ rsnAllocationRead1D(mContext, id, off, mip, count, d, sizeBytes, dt.mID);
}
- native void rsnAllocationRead(int con, int id, short[] d);
- synchronized void nAllocationRead(int id, short[] d) {
+
+ native void rsnAllocationRead2D(long con, long id, int xoff, int yoff, int mip, int face,
+ int w, int h, Object d, int sizeBytes, int dt);
+ synchronized void nAllocationRead2D(long id, int xoff, int yoff, int mip, int face,
+ int w, int h, Object d, int sizeBytes, Element.DataType dt) {
validate();
- rsnAllocationRead(mContext, id, d);
+ rsnAllocationRead2D(mContext, id, xoff, yoff, mip, face, w, h, d, sizeBytes, dt.mID);
}
- native void rsnAllocationRead(int con, int id, int[] d);
- synchronized void nAllocationRead(int id, int[] d) {
- validate();
- rsnAllocationRead(mContext, id, d);
- }
- native void rsnAllocationRead(int con, int id, float[] d);
- synchronized void nAllocationRead(int id, float[] d) {
- validate();
- rsnAllocationRead(mContext, id, d);
- }
- native int rsnAllocationGetType(int con, int id);
- synchronized int nAllocationGetType(int id) {
+
+ native long rsnAllocationGetType(long con, long id);
+ synchronized long nAllocationGetType(long id) {
validate();
return rsnAllocationGetType(mContext, id);
}
- native void rsnAllocationResize1D(int con, int id, int dimX);
- synchronized void nAllocationResize1D(int id, int dimX) {
+ native void rsnAllocationResize1D(long con, long id, int dimX);
+ synchronized void nAllocationResize1D(long id, int dimX) {
validate();
rsnAllocationResize1D(mContext, id, dimX);
}
- native int rsnFileA3DCreateFromAssetStream(int con, int assetStream);
- synchronized int nFileA3DCreateFromAssetStream(int assetStream) {
+ native long rsnFileA3DCreateFromAssetStream(long con, long assetStream);
+ synchronized long nFileA3DCreateFromAssetStream(long assetStream) {
validate();
return rsnFileA3DCreateFromAssetStream(mContext, assetStream);
}
- native int rsnFileA3DCreateFromFile(int con, String path);
- synchronized int nFileA3DCreateFromFile(String path) {
+ native long rsnFileA3DCreateFromFile(long con, String path);
+ synchronized long nFileA3DCreateFromFile(String path) {
validate();
return rsnFileA3DCreateFromFile(mContext, path);
}
- native int rsnFileA3DCreateFromAsset(int con, AssetManager mgr, String path);
- synchronized int nFileA3DCreateFromAsset(AssetManager mgr, String path) {
+ native long rsnFileA3DCreateFromAsset(long con, AssetManager mgr, String path);
+ synchronized long nFileA3DCreateFromAsset(AssetManager mgr, String path) {
validate();
return rsnFileA3DCreateFromAsset(mContext, mgr, path);
}
- native int rsnFileA3DGetNumIndexEntries(int con, int fileA3D);
- synchronized int nFileA3DGetNumIndexEntries(int fileA3D) {
+ native int rsnFileA3DGetNumIndexEntries(long con, long fileA3D);
+ synchronized int nFileA3DGetNumIndexEntries(long fileA3D) {
validate();
return rsnFileA3DGetNumIndexEntries(mContext, fileA3D);
}
- native void rsnFileA3DGetIndexEntries(int con, int fileA3D, int numEntries, int[] IDs, String[] names);
- synchronized void nFileA3DGetIndexEntries(int fileA3D, int numEntries, int[] IDs, String[] names) {
+ native void rsnFileA3DGetIndexEntries(long con, long fileA3D, int numEntries, int[] IDs, String[] names);
+ synchronized void nFileA3DGetIndexEntries(long fileA3D, int numEntries, int[] IDs, String[] names) {
validate();
rsnFileA3DGetIndexEntries(mContext, fileA3D, numEntries, IDs, names);
}
- native int rsnFileA3DGetEntryByIndex(int con, int fileA3D, int index);
- synchronized int nFileA3DGetEntryByIndex(int fileA3D, int index) {
+ native long rsnFileA3DGetEntryByIndex(long con, long fileA3D, int index);
+ synchronized long nFileA3DGetEntryByIndex(long fileA3D, int index) {
validate();
return rsnFileA3DGetEntryByIndex(mContext, fileA3D, index);
}
- native int rsnFontCreateFromFile(int con, String fileName, float size, int dpi);
- synchronized int nFontCreateFromFile(String fileName, float size, int dpi) {
+ native long rsnFontCreateFromFile(long con, String fileName, float size, int dpi);
+ synchronized long nFontCreateFromFile(String fileName, float size, int dpi) {
validate();
return rsnFontCreateFromFile(mContext, fileName, size, dpi);
}
- native int rsnFontCreateFromAssetStream(int con, String name, float size, int dpi, int assetStream);
- synchronized int nFontCreateFromAssetStream(String name, float size, int dpi, int assetStream) {
+ native long rsnFontCreateFromAssetStream(long con, String name, float size, int dpi, long assetStream);
+ synchronized long nFontCreateFromAssetStream(String name, float size, int dpi, long assetStream) {
validate();
return rsnFontCreateFromAssetStream(mContext, name, size, dpi, assetStream);
}
- native int rsnFontCreateFromAsset(int con, AssetManager mgr, String path, float size, int dpi);
- synchronized int nFontCreateFromAsset(AssetManager mgr, String path, float size, int dpi) {
+ native long rsnFontCreateFromAsset(long con, AssetManager mgr, String path, float size, int dpi);
+ synchronized long nFontCreateFromAsset(AssetManager mgr, String path, float size, int dpi) {
validate();
return rsnFontCreateFromAsset(mContext, mgr, path, size, dpi);
}
- native void rsnScriptBindAllocation(int con, int script, int alloc, int slot);
- synchronized void nScriptBindAllocation(int script, int alloc, int slot) {
+ native void rsnScriptBindAllocation(long con, long script, long alloc, int slot);
+ synchronized void nScriptBindAllocation(long script, long alloc, int slot) {
validate();
rsnScriptBindAllocation(mContext, script, alloc, slot);
}
- native void rsnScriptSetTimeZone(int con, int script, byte[] timeZone);
- synchronized void nScriptSetTimeZone(int script, byte[] timeZone) {
+ native void rsnScriptSetTimeZone(long con, long script, byte[] timeZone);
+ synchronized void nScriptSetTimeZone(long script, byte[] timeZone) {
validate();
rsnScriptSetTimeZone(mContext, script, timeZone);
}
- native void rsnScriptInvoke(int con, int id, int slot);
- synchronized void nScriptInvoke(int id, int slot) {
+ native void rsnScriptInvoke(long con, long id, int slot);
+ synchronized void nScriptInvoke(long id, int slot) {
validate();
rsnScriptInvoke(mContext, id, slot);
}
- native void rsnScriptForEach(int con, int id, int slot, int ain, int aout, byte[] params);
- native void rsnScriptForEach(int con, int id, int slot, int ain, int aout);
- native void rsnScriptForEachClipped(int con, int id, int slot, int ain, int aout, byte[] params,
+ native void rsnScriptForEach(long con, long id, int slot, long ain, long aout, byte[] params);
+ native void rsnScriptForEach(long con, long id, int slot, long ain, long aout);
+ native void rsnScriptForEachClipped(long con, long id, int slot, long ain, long aout, byte[] params,
int xstart, int xend, int ystart, int yend, int zstart, int zend);
- native void rsnScriptForEachClipped(int con, int id, int slot, int ain, int aout,
+ native void rsnScriptForEachClipped(long con, long id, int slot, long ain, long aout,
int xstart, int xend, int ystart, int yend, int zstart, int zend);
- synchronized void nScriptForEach(int id, int slot, int ain, int aout, byte[] params) {
+ synchronized void nScriptForEach(long id, int slot, long ain, long aout, byte[] params) {
validate();
if (params == null) {
rsnScriptForEach(mContext, id, slot, ain, aout);
@@ -609,7 +598,7 @@
}
}
- synchronized void nScriptForEachClipped(int id, int slot, int ain, int aout, byte[] params,
+ synchronized void nScriptForEachClipped(long id, int slot, long ain, long aout, byte[] params,
int xstart, int xend, int ystart, int yend, int zstart, int zend) {
validate();
if (params == null) {
@@ -619,138 +608,138 @@
}
}
- native void rsnScriptInvokeV(int con, int id, int slot, byte[] params);
- synchronized void nScriptInvokeV(int id, int slot, byte[] params) {
+ native void rsnScriptInvokeV(long con, long id, int slot, byte[] params);
+ synchronized void nScriptInvokeV(long id, int slot, byte[] params) {
validate();
rsnScriptInvokeV(mContext, id, slot, params);
}
- native void rsnScriptSetVarI(int con, int id, int slot, int val);
- synchronized void nScriptSetVarI(int id, int slot, int val) {
+ native void rsnScriptSetVarI(long con, long id, int slot, int val);
+ synchronized void nScriptSetVarI(long id, int slot, int val) {
validate();
rsnScriptSetVarI(mContext, id, slot, val);
}
- native int rsnScriptGetVarI(int con, int id, int slot);
- synchronized int nScriptGetVarI(int id, int slot) {
+ native int rsnScriptGetVarI(long con, long id, int slot);
+ synchronized int nScriptGetVarI(long id, int slot) {
validate();
return rsnScriptGetVarI(mContext, id, slot);
}
- native void rsnScriptSetVarJ(int con, int id, int slot, long val);
- synchronized void nScriptSetVarJ(int id, int slot, long val) {
+ native void rsnScriptSetVarJ(long con, long id, int slot, long val);
+ synchronized void nScriptSetVarJ(long id, int slot, long val) {
validate();
rsnScriptSetVarJ(mContext, id, slot, val);
}
- native long rsnScriptGetVarJ(int con, int id, int slot);
- synchronized long nScriptGetVarJ(int id, int slot) {
+ native long rsnScriptGetVarJ(long con, long id, int slot);
+ synchronized long nScriptGetVarJ(long id, int slot) {
validate();
return rsnScriptGetVarJ(mContext, id, slot);
}
- native void rsnScriptSetVarF(int con, int id, int slot, float val);
- synchronized void nScriptSetVarF(int id, int slot, float val) {
+ native void rsnScriptSetVarF(long con, long id, int slot, float val);
+ synchronized void nScriptSetVarF(long id, int slot, float val) {
validate();
rsnScriptSetVarF(mContext, id, slot, val);
}
- native float rsnScriptGetVarF(int con, int id, int slot);
- synchronized float nScriptGetVarF(int id, int slot) {
+ native float rsnScriptGetVarF(long con, long id, int slot);
+ synchronized float nScriptGetVarF(long id, int slot) {
validate();
return rsnScriptGetVarF(mContext, id, slot);
}
- native void rsnScriptSetVarD(int con, int id, int slot, double val);
- synchronized void nScriptSetVarD(int id, int slot, double val) {
+ native void rsnScriptSetVarD(long con, long id, int slot, double val);
+ synchronized void nScriptSetVarD(long id, int slot, double val) {
validate();
rsnScriptSetVarD(mContext, id, slot, val);
}
- native double rsnScriptGetVarD(int con, int id, int slot);
- synchronized double nScriptGetVarD(int id, int slot) {
+ native double rsnScriptGetVarD(long con, long id, int slot);
+ synchronized double nScriptGetVarD(long id, int slot) {
validate();
return rsnScriptGetVarD(mContext, id, slot);
}
- native void rsnScriptSetVarV(int con, int id, int slot, byte[] val);
- synchronized void nScriptSetVarV(int id, int slot, byte[] val) {
+ native void rsnScriptSetVarV(long con, long id, int slot, byte[] val);
+ synchronized void nScriptSetVarV(long id, int slot, byte[] val) {
validate();
rsnScriptSetVarV(mContext, id, slot, val);
}
- native void rsnScriptGetVarV(int con, int id, int slot, byte[] val);
- synchronized void nScriptGetVarV(int id, int slot, byte[] val) {
+ native void rsnScriptGetVarV(long con, long id, int slot, byte[] val);
+ synchronized void nScriptGetVarV(long id, int slot, byte[] val) {
validate();
rsnScriptGetVarV(mContext, id, slot, val);
}
- native void rsnScriptSetVarVE(int con, int id, int slot, byte[] val,
- int e, int[] dims);
- synchronized void nScriptSetVarVE(int id, int slot, byte[] val,
- int e, int[] dims) {
+ native void rsnScriptSetVarVE(long con, long id, int slot, byte[] val,
+ long e, int[] dims);
+ synchronized void nScriptSetVarVE(long id, int slot, byte[] val,
+ long e, int[] dims) {
validate();
rsnScriptSetVarVE(mContext, id, slot, val, e, dims);
}
- native void rsnScriptSetVarObj(int con, int id, int slot, int val);
- synchronized void nScriptSetVarObj(int id, int slot, int val) {
+ native void rsnScriptSetVarObj(long con, long id, int slot, long val);
+ synchronized void nScriptSetVarObj(long id, int slot, long val) {
validate();
rsnScriptSetVarObj(mContext, id, slot, val);
}
- native int rsnScriptCCreate(int con, String resName, String cacheDir,
+ native long rsnScriptCCreate(long con, String resName, String cacheDir,
byte[] script, int length);
- synchronized int nScriptCCreate(String resName, String cacheDir, byte[] script, int length) {
+ synchronized long nScriptCCreate(String resName, String cacheDir, byte[] script, int length) {
validate();
return rsnScriptCCreate(mContext, resName, cacheDir, script, length);
}
- native int rsnScriptIntrinsicCreate(int con, int id, int eid);
- synchronized int nScriptIntrinsicCreate(int id, int eid) {
+ native long rsnScriptIntrinsicCreate(long con, int id, long eid);
+ synchronized long nScriptIntrinsicCreate(int id, long eid) {
validate();
return rsnScriptIntrinsicCreate(mContext, id, eid);
}
- native int rsnScriptKernelIDCreate(int con, int sid, int slot, int sig);
- synchronized int nScriptKernelIDCreate(int sid, int slot, int sig) {
+ native long rsnScriptKernelIDCreate(long con, long sid, int slot, int sig);
+ synchronized long nScriptKernelIDCreate(long sid, int slot, int sig) {
validate();
return rsnScriptKernelIDCreate(mContext, sid, slot, sig);
}
- native int rsnScriptFieldIDCreate(int con, int sid, int slot);
- synchronized int nScriptFieldIDCreate(int sid, int slot) {
+ native long rsnScriptFieldIDCreate(long con, long sid, int slot);
+ synchronized long nScriptFieldIDCreate(long sid, int slot) {
validate();
return rsnScriptFieldIDCreate(mContext, sid, slot);
}
- native int rsnScriptGroupCreate(int con, int[] kernels, int[] src, int[] dstk, int[] dstf, int[] types);
- synchronized int nScriptGroupCreate(int[] kernels, int[] src, int[] dstk, int[] dstf, int[] types) {
+ native long rsnScriptGroupCreate(long con, long[] kernels, long[] src, long[] dstk, long[] dstf, long[] types);
+ synchronized long nScriptGroupCreate(long[] kernels, long[] src, long[] dstk, long[] dstf, long[] types) {
validate();
return rsnScriptGroupCreate(mContext, kernels, src, dstk, dstf, types);
}
- native void rsnScriptGroupSetInput(int con, int group, int kernel, int alloc);
- synchronized void nScriptGroupSetInput(int group, int kernel, int alloc) {
+ native void rsnScriptGroupSetInput(long con, long group, long kernel, long alloc);
+ synchronized void nScriptGroupSetInput(long group, long kernel, long alloc) {
validate();
rsnScriptGroupSetInput(mContext, group, kernel, alloc);
}
- native void rsnScriptGroupSetOutput(int con, int group, int kernel, int alloc);
- synchronized void nScriptGroupSetOutput(int group, int kernel, int alloc) {
+ native void rsnScriptGroupSetOutput(long con, long group, long kernel, long alloc);
+ synchronized void nScriptGroupSetOutput(long group, long kernel, long alloc) {
validate();
rsnScriptGroupSetOutput(mContext, group, kernel, alloc);
}
- native void rsnScriptGroupExecute(int con, int group);
- synchronized void nScriptGroupExecute(int group) {
+ native void rsnScriptGroupExecute(long con, long group);
+ synchronized void nScriptGroupExecute(long group) {
validate();
rsnScriptGroupExecute(mContext, group);
}
- native int rsnSamplerCreate(int con, int magFilter, int minFilter,
+ native long rsnSamplerCreate(long con, int magFilter, int minFilter,
int wrapS, int wrapT, int wrapR, float aniso);
- synchronized int nSamplerCreate(int magFilter, int minFilter,
+ synchronized long nSamplerCreate(int magFilter, int minFilter,
int wrapS, int wrapT, int wrapR, float aniso) {
validate();
return rsnSamplerCreate(mContext, magFilter, minFilter, wrapS, wrapT, wrapR, aniso);
}
- native int rsnProgramStoreCreate(int con, boolean r, boolean g, boolean b, boolean a,
+ native long rsnProgramStoreCreate(long con, boolean r, boolean g, boolean b, boolean a,
boolean depthMask, boolean dither,
int srcMode, int dstMode, int depthFunc);
- synchronized int nProgramStoreCreate(boolean r, boolean g, boolean b, boolean a,
+ synchronized long nProgramStoreCreate(boolean r, boolean g, boolean b, boolean a,
boolean depthMask, boolean dither,
int srcMode, int dstMode, int depthFunc) {
validate();
@@ -758,72 +747,72 @@
dstMode, depthFunc);
}
- native int rsnProgramRasterCreate(int con, boolean pointSprite, int cullMode);
- synchronized int nProgramRasterCreate(boolean pointSprite, int cullMode) {
+ native long rsnProgramRasterCreate(long con, boolean pointSprite, int cullMode);
+ synchronized long nProgramRasterCreate(boolean pointSprite, int cullMode) {
validate();
return rsnProgramRasterCreate(mContext, pointSprite, cullMode);
}
- native void rsnProgramBindConstants(int con, int pv, int slot, int mID);
- synchronized void nProgramBindConstants(int pv, int slot, int mID) {
+ native void rsnProgramBindConstants(long con, long pv, int slot, long mID);
+ synchronized void nProgramBindConstants(long pv, int slot, long mID) {
validate();
rsnProgramBindConstants(mContext, pv, slot, mID);
}
- native void rsnProgramBindTexture(int con, int vpf, int slot, int a);
- synchronized void nProgramBindTexture(int vpf, int slot, int a) {
+ native void rsnProgramBindTexture(long con, long vpf, int slot, long a);
+ synchronized void nProgramBindTexture(long vpf, int slot, long a) {
validate();
rsnProgramBindTexture(mContext, vpf, slot, a);
}
- native void rsnProgramBindSampler(int con, int vpf, int slot, int s);
- synchronized void nProgramBindSampler(int vpf, int slot, int s) {
+ native void rsnProgramBindSampler(long con, long vpf, int slot, long s);
+ synchronized void nProgramBindSampler(long vpf, int slot, long s) {
validate();
rsnProgramBindSampler(mContext, vpf, slot, s);
}
- native int rsnProgramFragmentCreate(int con, String shader, String[] texNames, int[] params);
- synchronized int nProgramFragmentCreate(String shader, String[] texNames, int[] params) {
+ native long rsnProgramFragmentCreate(long con, String shader, String[] texNames, long[] params);
+ synchronized long nProgramFragmentCreate(String shader, String[] texNames, long[] params) {
validate();
return rsnProgramFragmentCreate(mContext, shader, texNames, params);
}
- native int rsnProgramVertexCreate(int con, String shader, String[] texNames, int[] params);
- synchronized int nProgramVertexCreate(String shader, String[] texNames, int[] params) {
+ native long rsnProgramVertexCreate(long con, String shader, String[] texNames, long[] params);
+ synchronized long nProgramVertexCreate(String shader, String[] texNames, long[] params) {
validate();
return rsnProgramVertexCreate(mContext, shader, texNames, params);
}
- native int rsnMeshCreate(int con, int[] vtx, int[] idx, int[] prim);
- synchronized int nMeshCreate(int[] vtx, int[] idx, int[] prim) {
+ native long rsnMeshCreate(long con, long[] vtx, long[] idx, int[] prim);
+ synchronized long nMeshCreate(long[] vtx, long[] idx, int[] prim) {
validate();
return rsnMeshCreate(mContext, vtx, idx, prim);
}
- native int rsnMeshGetVertexBufferCount(int con, int id);
- synchronized int nMeshGetVertexBufferCount(int id) {
+ native int rsnMeshGetVertexBufferCount(long con, long id);
+ synchronized int nMeshGetVertexBufferCount(long id) {
validate();
return rsnMeshGetVertexBufferCount(mContext, id);
}
- native int rsnMeshGetIndexCount(int con, int id);
- synchronized int nMeshGetIndexCount(int id) {
+ native int rsnMeshGetIndexCount(long con, long id);
+ synchronized int nMeshGetIndexCount(long id) {
validate();
return rsnMeshGetIndexCount(mContext, id);
}
- native void rsnMeshGetVertices(int con, int id, int[] vtxIds, int vtxIdCount);
- synchronized void nMeshGetVertices(int id, int[] vtxIds, int vtxIdCount) {
+ native void rsnMeshGetVertices(long con, long id, long[] vtxIds, int vtxIdCount);
+ synchronized void nMeshGetVertices(long id, long[] vtxIds, int vtxIdCount) {
validate();
rsnMeshGetVertices(mContext, id, vtxIds, vtxIdCount);
}
- native void rsnMeshGetIndices(int con, int id, int[] idxIds, int[] primitives, int vtxIdCount);
- synchronized void nMeshGetIndices(int id, int[] idxIds, int[] primitives, int vtxIdCount) {
+ native void rsnMeshGetIndices(long con, long id, long[] idxIds, int[] primitives, int vtxIdCount);
+ synchronized void nMeshGetIndices(long id, long[] idxIds, int[] primitives, int vtxIdCount) {
validate();
rsnMeshGetIndices(mContext, id, idxIds, primitives, vtxIdCount);
}
- native int rsnPathCreate(int con, int prim, boolean isStatic, int vtx, int loop, float q);
- synchronized int nPathCreate(int prim, boolean isStatic, int vtx, int loop, float q) {
+ native long rsnPathCreate(long con, int prim, boolean isStatic, long vtx, long loop, float q);
+ synchronized long nPathCreate(int prim, boolean isStatic, long vtx, long loop, float q) {
validate();
return rsnPathCreate(mContext, prim, isStatic, vtx, loop, q);
}
- int mDev;
- int mContext;
+ long mDev;
+ long mContext;
@SuppressWarnings({"FieldCanBeLocal"})
MessageThread mMessageThread;
@@ -1015,6 +1004,14 @@
}
}
+ void validateObject(BaseObj o) {
+ if (o != null) {
+ if (o.mRS != this) {
+ throw new RSIllegalArgumentException("Attempting to use an object across contexts.");
+ }
+ }
+ }
+
void validate() {
if (mContext == 0) {
throw new RSInvalidStateException("Calling RS with no Context active.");
@@ -1136,6 +1133,7 @@
if (ctx != null) {
mApplicationContext = ctx.getApplicationContext();
}
+ mRWLock = new ReentrantReadWriteLock();
}
/**
@@ -1230,6 +1228,8 @@
*/
public void destroy() {
validate();
+ nContextFinish();
+
nContextDeinitToClient(mContext);
mMessageThread.mRun = false;
try {
@@ -1238,7 +1238,6 @@
}
nContextDestroy();
- mContext = 0;
nDeviceDestroy(mDev);
mDev = 0;
@@ -1248,7 +1247,7 @@
return mContext != 0;
}
- int safeID(BaseObj o) {
+ long safeID(BaseObj o) {
if(o != null) {
return o.getID(this);
}
diff --git a/graphics/java/android/renderscript/RenderScriptGL.java b/rs/java/android/renderscript/RenderScriptGL.java
similarity index 95%
rename from graphics/java/android/renderscript/RenderScriptGL.java
rename to rs/java/android/renderscript/RenderScriptGL.java
index bac9c68..d6841c8 100644
--- a/graphics/java/android/renderscript/RenderScriptGL.java
+++ b/rs/java/android/renderscript/RenderScriptGL.java
@@ -232,9 +232,13 @@
validate();
//android.util.Log.v("rs", "set surface " + sur + " w=" + w + ", h=" + h);
+ Surface s = null;
+ if (sur != null) {
+ s = new Surface(sur);
+ }
mWidth = w;
mHeight = h;
- nContextSetSurfaceTexture(w, h, sur);
+ nContextSetSurface(w, h, s);
}
/**
@@ -286,7 +290,7 @@
*/
public void bindRootScript(Script s) {
validate();
- nContextBindRootScript(safeID(s));
+ nContextBindRootScript((int)safeID(s));
}
/**
@@ -298,7 +302,7 @@
*/
public void bindProgramStore(ProgramStore p) {
validate();
- nContextBindProgramStore(safeID(p));
+ nContextBindProgramStore((int)safeID(p));
}
/**
@@ -310,7 +314,7 @@
*/
public void bindProgramFragment(ProgramFragment p) {
validate();
- nContextBindProgramFragment(safeID(p));
+ nContextBindProgramFragment((int)safeID(p));
}
/**
@@ -322,7 +326,7 @@
*/
public void bindProgramRaster(ProgramRaster p) {
validate();
- nContextBindProgramRaster(safeID(p));
+ nContextBindProgramRaster((int)safeID(p));
}
/**
@@ -334,7 +338,7 @@
*/
public void bindProgramVertex(ProgramVertex p) {
validate();
- nContextBindProgramVertex(safeID(p));
+ nContextBindProgramVertex((int)safeID(p));
}
}
diff --git a/graphics/java/android/renderscript/Sampler.java b/rs/java/android/renderscript/Sampler.java
similarity index 98%
rename from graphics/java/android/renderscript/Sampler.java
rename to rs/java/android/renderscript/Sampler.java
index 623055fe..8d0e29e 100644
--- a/graphics/java/android/renderscript/Sampler.java
+++ b/rs/java/android/renderscript/Sampler.java
@@ -60,7 +60,7 @@
Value mWrapR;
float mAniso;
- Sampler(int id, RenderScript rs) {
+ Sampler(long id, RenderScript rs) {
super(id, rs);
}
@@ -347,7 +347,7 @@
public Sampler create() {
mRS.validate();
- int id = mRS.nSamplerCreate(mMag.mID, mMin.mID,
+ long id = mRS.nSamplerCreate(mMag.mID, mMin.mID,
mWrapS.mID, mWrapT.mID, mWrapR.mID, mAniso);
Sampler sampler = new Sampler(id, mRS);
sampler.mMin = mMin;
diff --git a/graphics/java/android/renderscript/Script.java b/rs/java/android/renderscript/Script.java
similarity index 91%
rename from graphics/java/android/renderscript/Script.java
rename to rs/java/android/renderscript/Script.java
index 0026e0e..0e46f94 100644
--- a/graphics/java/android/renderscript/Script.java
+++ b/rs/java/android/renderscript/Script.java
@@ -36,7 +36,7 @@
Script mScript;
int mSlot;
int mSig;
- KernelID(int id, RenderScript rs, Script s, int slot, int sig) {
+ KernelID(long id, RenderScript rs, Script s, int slot, int sig) {
super(id, rs);
mScript = s;
mSlot = slot;
@@ -54,7 +54,7 @@
return k;
}
- int id = mRS.nScriptKernelIDCreate(getID(mRS), slot, sig);
+ long id = mRS.nScriptKernelIDCreate(getID(mRS), slot, sig);
if (id == 0) {
throw new RSDriverException("Failed to create KernelID");
}
@@ -75,7 +75,7 @@
public static final class FieldID extends BaseObj {
Script mScript;
int mSlot;
- FieldID(int id, RenderScript rs, Script s, int slot) {
+ FieldID(long id, RenderScript rs, Script s, int slot) {
super(id, rs);
mScript = s;
mSlot = slot;
@@ -92,7 +92,7 @@
return f;
}
- int id = mRS.nScriptFieldIDCreate(getID(mRS), slot);
+ long id = mRS.nScriptFieldIDCreate(getID(mRS), slot);
if (id == 0) {
throw new RSDriverException("Failed to create FieldID");
}
@@ -128,15 +128,18 @@
*
*/
protected void forEach(int slot, Allocation ain, Allocation aout, FieldPacker v) {
+ mRS.validate();
+ mRS.validateObject(ain);
+ mRS.validateObject(aout);
if (ain == null && aout == null) {
throw new RSIllegalArgumentException(
"At least one of ain or aout is required to be non-null.");
}
- int in_id = 0;
+ long in_id = 0;
if (ain != null) {
in_id = ain.getID(mRS);
}
- int out_id = 0;
+ long out_id = 0;
if (aout != null) {
out_id = aout.getID(mRS);
}
@@ -152,6 +155,9 @@
*
*/
protected void forEach(int slot, Allocation ain, Allocation aout, FieldPacker v, LaunchOptions sc) {
+ mRS.validate();
+ mRS.validateObject(ain);
+ mRS.validateObject(aout);
if (ain == null && aout == null) {
throw new RSIllegalArgumentException(
"At least one of ain or aout is required to be non-null.");
@@ -161,11 +167,11 @@
forEach(slot, ain, aout, v);
return;
}
- int in_id = 0;
+ long in_id = 0;
if (ain != null) {
in_id = ain.getID(mRS);
}
- int out_id = 0;
+ long out_id = 0;
if (aout != null) {
out_id = aout.getID(mRS);
}
@@ -176,7 +182,7 @@
mRS.nScriptForEachClipped(getID(mRS), slot, in_id, out_id, params, sc.xstart, sc.xend, sc.ystart, sc.yend, sc.zstart, sc.zend);
}
- Script(int id, RenderScript rs) {
+ Script(long id, RenderScript rs) {
super(id, rs);
}
@@ -187,7 +193,15 @@
*/
public void bindAllocation(Allocation va, int slot) {
mRS.validate();
+ mRS.validateObject(va);
if (va != null) {
+ if (mRS.getApplicationContext().getApplicationInfo().targetSdkVersion >= 20) {
+ final Type t = va.mType;
+ if (t.hasMipmaps() || t.hasFaces() || (t.getY() != 0) || (t.getZ() != 0)) {
+ throw new RSIllegalArgumentException(
+ "API 20+ only allows simple 1D allocations to be used with bind.");
+ }
+ }
mRS.nScriptBindAllocation(getID(mRS), va.getID(mRS), slot);
} else {
mRS.nScriptBindAllocation(getID(mRS), 0, slot);
@@ -256,6 +270,8 @@
*
*/
public void setVar(int index, BaseObj o) {
+ mRS.validate();
+ mRS.validateObject(o);
mRS.nScriptSetVarObj(getID(mRS), index, (o == null) ? 0 : o.getID(mRS));
}
diff --git a/graphics/java/android/renderscript/ScriptC.java b/rs/java/android/renderscript/ScriptC.java
similarity index 89%
rename from graphics/java/android/renderscript/ScriptC.java
rename to rs/java/android/renderscript/ScriptC.java
index b0a5759..cdb2b08 100644
--- a/graphics/java/android/renderscript/ScriptC.java
+++ b/rs/java/android/renderscript/ScriptC.java
@@ -45,7 +45,17 @@
protected ScriptC(int id, RenderScript rs) {
super(id, rs);
}
-
+ /**
+ * Only intended for use by the generated derived classes.
+ *
+ * @param id
+ * @param rs
+ *
+ * @hide
+ */
+ protected ScriptC(long id, RenderScript rs) {
+ super(id, rs);
+ }
/**
* Only intended for use by the generated derived classes.
*
@@ -56,7 +66,7 @@
*/
protected ScriptC(RenderScript rs, Resources resources, int resourceID) {
super(0, rs);
- int id = internalCreate(rs, resources, resourceID);
+ long id = internalCreate(rs, resources, resourceID);
if (id == 0) {
throw new RSRuntimeException("Loading of ScriptC script failed.");
}
@@ -70,7 +80,7 @@
static String mCachePath;
- private static synchronized int internalCreate(RenderScript rs, Resources resources, int resourceID) {
+ private static synchronized long internalCreate(RenderScript rs, Resources resources, int resourceID) {
byte[] pgm;
int pgmLength;
InputStream is = resources.openRawResource(resourceID);
diff --git a/graphics/java/android/renderscript/ScriptGroup.java b/rs/java/android/renderscript/ScriptGroup.java
similarity index 97%
rename from graphics/java/android/renderscript/ScriptGroup.java
rename to rs/java/android/renderscript/ScriptGroup.java
index 1416641..1200a66 100644
--- a/graphics/java/android/renderscript/ScriptGroup.java
+++ b/rs/java/android/renderscript/ScriptGroup.java
@@ -89,7 +89,7 @@
}
- ScriptGroup(int id, RenderScript rs) {
+ ScriptGroup(long id, RenderScript rs) {
super(id, rs);
}
@@ -394,7 +394,7 @@
ArrayList<IO> inputs = new ArrayList<IO>();
ArrayList<IO> outputs = new ArrayList<IO>();
- int[] kernels = new int[mKernelCount];
+ long[] kernels = new long[mKernelCount];
int idx = 0;
for (int ct=0; ct < mNodes.size(); ct++) {
Node n = mNodes.get(ct);
@@ -427,10 +427,10 @@
throw new RSRuntimeException("Count mismatch, should not happen.");
}
- int[] src = new int[mLines.size()];
- int[] dstk = new int[mLines.size()];
- int[] dstf = new int[mLines.size()];
- int[] types = new int[mLines.size()];
+ long[] src = new long[mLines.size()];
+ long[] dstk = new long[mLines.size()];
+ long[] dstf = new long[mLines.size()];
+ long[] types = new long[mLines.size()];
for (int ct=0; ct < mLines.size(); ct++) {
ConnectLine cl = mLines.get(ct);
@@ -444,7 +444,7 @@
types[ct] = cl.mAllocationType.getID(mRS);
}
- int id = mRS.nScriptGroupCreate(kernels, src, dstk, dstf, types);
+ long id = mRS.nScriptGroupCreate(kernels, src, dstk, dstf, types);
if (id == 0) {
throw new RSRuntimeException("Object creation error, should not happen.");
}
diff --git a/graphics/java/android/renderscript/ScriptIntrinsic.java b/rs/java/android/renderscript/ScriptIntrinsic.java
similarity index 95%
rename from graphics/java/android/renderscript/ScriptIntrinsic.java
rename to rs/java/android/renderscript/ScriptIntrinsic.java
index 096268a..8719e017 100644
--- a/graphics/java/android/renderscript/ScriptIntrinsic.java
+++ b/rs/java/android/renderscript/ScriptIntrinsic.java
@@ -25,7 +25,7 @@
* Not intended for direct use.
**/
public abstract class ScriptIntrinsic extends Script {
- ScriptIntrinsic(int id, RenderScript rs) {
+ ScriptIntrinsic(long id, RenderScript rs) {
super(id, rs);
}
}
diff --git a/graphics/java/android/renderscript/ScriptIntrinsic3DLUT.java b/rs/java/android/renderscript/ScriptIntrinsic3DLUT.java
similarity index 95%
rename from graphics/java/android/renderscript/ScriptIntrinsic3DLUT.java
rename to rs/java/android/renderscript/ScriptIntrinsic3DLUT.java
index 34540a1..96ec875 100644
--- a/graphics/java/android/renderscript/ScriptIntrinsic3DLUT.java
+++ b/rs/java/android/renderscript/ScriptIntrinsic3DLUT.java
@@ -30,7 +30,7 @@
private Allocation mLUT;
private Element mElement;
- private ScriptIntrinsic3DLUT(int id, RenderScript rs, Element e) {
+ private ScriptIntrinsic3DLUT(long id, RenderScript rs, Element e) {
super(id, rs);
mElement = e;
}
@@ -46,7 +46,7 @@
* @return ScriptIntrinsic3DLUT
*/
public static ScriptIntrinsic3DLUT create(RenderScript rs, Element e) {
- int id = rs.nScriptIntrinsicCreate(8, e.getID(rs));
+ long id = rs.nScriptIntrinsicCreate(8, e.getID(rs));
if (!e.isCompatible(Element.U8_4(rs))) {
throw new RSIllegalArgumentException("Element must be compatible with uchar4.");
diff --git a/graphics/java/android/renderscript/ScriptIntrinsicBlend.java b/rs/java/android/renderscript/ScriptIntrinsicBlend.java
similarity index 98%
rename from graphics/java/android/renderscript/ScriptIntrinsicBlend.java
rename to rs/java/android/renderscript/ScriptIntrinsicBlend.java
index 0e05bc8..40f1a3e 100644
--- a/graphics/java/android/renderscript/ScriptIntrinsicBlend.java
+++ b/rs/java/android/renderscript/ScriptIntrinsicBlend.java
@@ -21,7 +21,7 @@
* Intrinsic kernels for blending two {@link android.renderscript.Allocation} objects.
**/
public class ScriptIntrinsicBlend extends ScriptIntrinsic {
- ScriptIntrinsicBlend(int id, RenderScript rs) {
+ ScriptIntrinsicBlend(long id, RenderScript rs) {
super(id, rs);
}
@@ -35,7 +35,7 @@
*/
public static ScriptIntrinsicBlend create(RenderScript rs, Element e) {
// 7 comes from RS_SCRIPT_INTRINSIC_ID_BLEND in rsDefines.h
- int id = rs.nScriptIntrinsicCreate(7, e.getID(rs));
+ long id = rs.nScriptIntrinsicCreate(7, e.getID(rs));
return new ScriptIntrinsicBlend(id, rs);
}
diff --git a/graphics/java/android/renderscript/ScriptIntrinsicBlur.java b/rs/java/android/renderscript/ScriptIntrinsicBlur.java
similarity index 95%
rename from graphics/java/android/renderscript/ScriptIntrinsicBlur.java
rename to rs/java/android/renderscript/ScriptIntrinsicBlur.java
index aaf5ffc..d1a6fed 100644
--- a/graphics/java/android/renderscript/ScriptIntrinsicBlur.java
+++ b/rs/java/android/renderscript/ScriptIntrinsicBlur.java
@@ -30,7 +30,7 @@
private final float[] mValues = new float[9];
private Allocation mInput;
- private ScriptIntrinsicBlur(int id, RenderScript rs) {
+ private ScriptIntrinsicBlur(long id, RenderScript rs) {
super(id, rs);
}
@@ -49,7 +49,7 @@
if ((!e.isCompatible(Element.U8_4(rs))) && (!e.isCompatible(Element.U8(rs)))) {
throw new RSIllegalArgumentException("Unsuported element type.");
}
- int id = rs.nScriptIntrinsicCreate(5, e.getID(rs));
+ long id = rs.nScriptIntrinsicCreate(5, e.getID(rs));
ScriptIntrinsicBlur sib = new ScriptIntrinsicBlur(id, rs);
sib.setRadius(5.f);
return sib;
diff --git a/graphics/java/android/renderscript/ScriptIntrinsicColorMatrix.java b/rs/java/android/renderscript/ScriptIntrinsicColorMatrix.java
similarity index 98%
rename from graphics/java/android/renderscript/ScriptIntrinsicColorMatrix.java
rename to rs/java/android/renderscript/ScriptIntrinsicColorMatrix.java
index 32c3d15..601db17 100644
--- a/graphics/java/android/renderscript/ScriptIntrinsicColorMatrix.java
+++ b/rs/java/android/renderscript/ScriptIntrinsicColorMatrix.java
@@ -43,7 +43,7 @@
private final Matrix4f mMatrix = new Matrix4f();
private final Float4 mAdd = new Float4();
- private ScriptIntrinsicColorMatrix(int id, RenderScript rs) {
+ private ScriptIntrinsicColorMatrix(long id, RenderScript rs) {
super(id, rs);
}
@@ -75,7 +75,7 @@
* @return ScriptIntrinsicColorMatrix
*/
public static ScriptIntrinsicColorMatrix create(RenderScript rs) {
- int id = rs.nScriptIntrinsicCreate(2, 0);
+ long id = rs.nScriptIntrinsicCreate(2, 0);
return new ScriptIntrinsicColorMatrix(id, rs);
}
diff --git a/graphics/java/android/renderscript/ScriptIntrinsicConvolve3x3.java b/rs/java/android/renderscript/ScriptIntrinsicConvolve3x3.java
similarity index 96%
rename from graphics/java/android/renderscript/ScriptIntrinsicConvolve3x3.java
rename to rs/java/android/renderscript/ScriptIntrinsicConvolve3x3.java
index 5d3c1d3..25f3ee8 100644
--- a/graphics/java/android/renderscript/ScriptIntrinsicConvolve3x3.java
+++ b/rs/java/android/renderscript/ScriptIntrinsicConvolve3x3.java
@@ -26,7 +26,7 @@
private final float[] mValues = new float[9];
private Allocation mInput;
- private ScriptIntrinsicConvolve3x3(int id, RenderScript rs) {
+ private ScriptIntrinsicConvolve3x3(long id, RenderScript rs) {
super(id, rs);
}
@@ -61,7 +61,7 @@
!e.isCompatible(Element.F32_4(rs))) {
throw new RSIllegalArgumentException("Unsuported element type.");
}
- int id = rs.nScriptIntrinsicCreate(1, e.getID(rs));
+ long id = rs.nScriptIntrinsicCreate(1, e.getID(rs));
ScriptIntrinsicConvolve3x3 si = new ScriptIntrinsicConvolve3x3(id, rs);
si.setCoefficients(f);
return si;
diff --git a/graphics/java/android/renderscript/ScriptIntrinsicConvolve5x5.java b/rs/java/android/renderscript/ScriptIntrinsicConvolve5x5.java
similarity index 96%
rename from graphics/java/android/renderscript/ScriptIntrinsicConvolve5x5.java
rename to rs/java/android/renderscript/ScriptIntrinsicConvolve5x5.java
index ad09f95..71ea4cbc 100644
--- a/graphics/java/android/renderscript/ScriptIntrinsicConvolve5x5.java
+++ b/rs/java/android/renderscript/ScriptIntrinsicConvolve5x5.java
@@ -26,7 +26,7 @@
private final float[] mValues = new float[25];
private Allocation mInput;
- private ScriptIntrinsicConvolve5x5(int id, RenderScript rs) {
+ private ScriptIntrinsicConvolve5x5(long id, RenderScript rs) {
super(id, rs);
}
@@ -62,7 +62,7 @@
throw new RSIllegalArgumentException("Unsuported element type.");
}
- int id = rs.nScriptIntrinsicCreate(4, e.getID(rs));
+ long id = rs.nScriptIntrinsicCreate(4, e.getID(rs));
return new ScriptIntrinsicConvolve5x5(id, rs);
}
diff --git a/graphics/java/android/renderscript/ScriptIntrinsicHistogram.java b/rs/java/android/renderscript/ScriptIntrinsicHistogram.java
similarity index 97%
rename from graphics/java/android/renderscript/ScriptIntrinsicHistogram.java
rename to rs/java/android/renderscript/ScriptIntrinsicHistogram.java
index adc2d95..42e4d04 100644
--- a/graphics/java/android/renderscript/ScriptIntrinsicHistogram.java
+++ b/rs/java/android/renderscript/ScriptIntrinsicHistogram.java
@@ -28,7 +28,7 @@
public final class ScriptIntrinsicHistogram extends ScriptIntrinsic {
private Allocation mOut;
- private ScriptIntrinsicHistogram(int id, RenderScript rs) {
+ private ScriptIntrinsicHistogram(long id, RenderScript rs) {
super(id, rs);
}
@@ -52,7 +52,7 @@
(!e.isCompatible(Element.U8(rs)))) {
throw new RSIllegalArgumentException("Unsuported element type.");
}
- int id = rs.nScriptIntrinsicCreate(9, e.getID(rs));
+ long id = rs.nScriptIntrinsicCreate(9, e.getID(rs));
ScriptIntrinsicHistogram sib = new ScriptIntrinsicHistogram(id, rs);
return sib;
}
diff --git a/graphics/java/android/renderscript/ScriptIntrinsicLUT.java b/rs/java/android/renderscript/ScriptIntrinsicLUT.java
similarity index 96%
rename from graphics/java/android/renderscript/ScriptIntrinsicLUT.java
rename to rs/java/android/renderscript/ScriptIntrinsicLUT.java
index 0f7ab38..c45c015 100644
--- a/graphics/java/android/renderscript/ScriptIntrinsicLUT.java
+++ b/rs/java/android/renderscript/ScriptIntrinsicLUT.java
@@ -30,7 +30,7 @@
private final byte mCache[] = new byte[1024];
private boolean mDirty = true;
- private ScriptIntrinsicLUT(int id, RenderScript rs) {
+ private ScriptIntrinsicLUT(long id, RenderScript rs) {
super(id, rs);
mTables = Allocation.createSized(rs, Element.U8(rs), 1024);
for (int ct=0; ct < 256; ct++) {
@@ -53,7 +53,7 @@
* @return ScriptIntrinsicLUT
*/
public static ScriptIntrinsicLUT create(RenderScript rs, Element e) {
- int id = rs.nScriptIntrinsicCreate(3, e.getID(rs));
+ long id = rs.nScriptIntrinsicCreate(3, e.getID(rs));
return new ScriptIntrinsicLUT(id, rs);
}
diff --git a/graphics/java/android/renderscript/ScriptIntrinsicYuvToRGB.java b/rs/java/android/renderscript/ScriptIntrinsicYuvToRGB.java
similarity index 95%
rename from graphics/java/android/renderscript/ScriptIntrinsicYuvToRGB.java
rename to rs/java/android/renderscript/ScriptIntrinsicYuvToRGB.java
index 845625d..f942982 100644
--- a/graphics/java/android/renderscript/ScriptIntrinsicYuvToRGB.java
+++ b/rs/java/android/renderscript/ScriptIntrinsicYuvToRGB.java
@@ -27,7 +27,7 @@
public final class ScriptIntrinsicYuvToRGB extends ScriptIntrinsic {
private Allocation mInput;
- ScriptIntrinsicYuvToRGB(int id, RenderScript rs) {
+ ScriptIntrinsicYuvToRGB(long id, RenderScript rs) {
super(id, rs);
}
@@ -43,7 +43,7 @@
*/
public static ScriptIntrinsicYuvToRGB create(RenderScript rs, Element e) {
// 6 comes from RS_SCRIPT_INTRINSIC_YUV_TO_RGB in rsDefines.h
- int id = rs.nScriptIntrinsicCreate(6, e.getID(rs));
+ long id = rs.nScriptIntrinsicCreate(6, e.getID(rs));
ScriptIntrinsicYuvToRGB si = new ScriptIntrinsicYuvToRGB(id, rs);
return si;
}
diff --git a/graphics/java/android/renderscript/Short2.java b/rs/java/android/renderscript/Short2.java
similarity index 100%
rename from graphics/java/android/renderscript/Short2.java
rename to rs/java/android/renderscript/Short2.java
diff --git a/graphics/java/android/renderscript/Short3.java b/rs/java/android/renderscript/Short3.java
similarity index 100%
rename from graphics/java/android/renderscript/Short3.java
rename to rs/java/android/renderscript/Short3.java
diff --git a/graphics/java/android/renderscript/Short4.java b/rs/java/android/renderscript/Short4.java
similarity index 100%
rename from graphics/java/android/renderscript/Short4.java
rename to rs/java/android/renderscript/Short4.java
diff --git a/graphics/java/android/renderscript/Type.java b/rs/java/android/renderscript/Type.java
similarity index 76%
rename from graphics/java/android/renderscript/Type.java
rename to rs/java/android/renderscript/Type.java
index e023739..ce7f571 100644
--- a/graphics/java/android/renderscript/Type.java
+++ b/rs/java/android/renderscript/Type.java
@@ -190,24 +190,24 @@
}
- Type(int id, RenderScript rs) {
+ Type(long id, RenderScript rs) {
super(id, rs);
}
@Override
void updateFromNative() {
- // We have 6 integer to obtain mDimX; mDimY; mDimZ;
+ // We have 6 integer/long to obtain mDimX; mDimY; mDimZ;
// mDimLOD; mDimFaces; mElement;
- int[] dataBuffer = new int[6];
+ long[] dataBuffer = new long[6];
mRS.nTypeGetNativeData(getID(mRS), dataBuffer);
- mDimX = dataBuffer[0];
- mDimY = dataBuffer[1];
- mDimZ = dataBuffer[2];
+ mDimX = (int)dataBuffer[0];
+ mDimY = (int)dataBuffer[1];
+ mDimZ = (int)dataBuffer[2];
mDimMipmaps = dataBuffer[3] == 1 ? true : false;
mDimFaces = dataBuffer[4] == 1 ? true : false;
- int elementID = dataBuffer[5];
+ long elementID = dataBuffer[5];
if(elementID != 0) {
mElement = new Element(elementID, mRS);
mElement.updateFromNative();
@@ -216,6 +216,84 @@
}
/**
+ * @hide
+ * Utility function for creating basic 1D types. The type is
+ * created without mipmaps enabled.
+ *
+ * @param rs The RenderScript context
+ * @param e The Element for the Type
+ * @param dimX The X dimension, must be > 0
+ *
+ * @return Type
+ */
+ static public Type createX(RenderScript rs, Element e, int dimX) {
+ if (dimX < 1) {
+ throw new RSInvalidStateException("Dimension must be >= 1.");
+ }
+
+ long id = rs.nTypeCreate(e.getID(rs), dimX, 0, 0, false, false, 0);
+ Type t = new Type(id, rs);
+ t.mElement = e;
+ t.mDimX = dimX;
+ t.calcElementCount();
+ return t;
+ }
+
+ /**
+ * @hide
+ * Utility function for creating basic 2D types. The type is
+ * created without mipmaps or cubemaps.
+ *
+ * @param rs The RenderScript context
+ * @param e The Element for the Type
+ * @param dimX The X dimension, must be > 0
+ * @param dimY The Y dimension, must be > 0
+ *
+ * @return Type
+ */
+ static public Type createXY(RenderScript rs, Element e, int dimX, int dimY) {
+ if ((dimX < 1) || (dimY < 1)) {
+ throw new RSInvalidStateException("Dimension must be >= 1.");
+ }
+
+ long id = rs.nTypeCreate(e.getID(rs), dimX, dimY, 0, false, false, 0);
+ Type t = new Type(id, rs);
+ t.mElement = e;
+ t.mDimX = dimX;
+ t.mDimY = dimY;
+ t.calcElementCount();
+ return t;
+ }
+
+ /**
+ * @hide
+ * Utility function for creating basic 3D types. The type is
+ * created without mipmaps.
+ *
+ * @param rs The RenderScript context
+ * @param e The Element for the Type
+ * @param dimX The X dimension, must be > 0
+ * @param dimY The Y dimension, must be > 0
+ * @param dimZ The Z dimension, must be > 0
+ *
+ * @return Type
+ */
+ static public Type createXYZ(RenderScript rs, Element e, int dimX, int dimY, int dimZ) {
+ if ((dimX < 1) || (dimY < 1) || (dimZ < 1)) {
+ throw new RSInvalidStateException("Dimension must be >= 1.");
+ }
+
+ long id = rs.nTypeCreate(e.getID(rs), dimX, dimY, dimZ, false, false, 0);
+ Type t = new Type(id, rs);
+ t.mElement = e;
+ t.mDimX = dimX;
+ t.mDimY = dimY;
+ t.mDimZ = dimZ;
+ t.calcElementCount();
+ return t;
+ }
+
+ /**
* Builder class for Type.
*
*/
@@ -336,7 +414,7 @@
}
}
- int id = mRS.nTypeCreate(mElement.getID(mRS),
+ long id = mRS.nTypeCreate(mElement.getID(mRS),
mDimX, mDimY, mDimZ, mDimMipmaps, mDimFaces, mYuv);
Type t = new Type(id, mRS);
t.mElement = mElement;
diff --git a/graphics/java/android/renderscript/package.html b/rs/java/android/renderscript/package.html
similarity index 100%
rename from graphics/java/android/renderscript/package.html
rename to rs/java/android/renderscript/package.html
diff --git a/graphics/jni/Android.mk b/rs/jni/Android.mk
similarity index 95%
rename from graphics/jni/Android.mk
rename to rs/jni/Android.mk
index e8beae53..cbb5b3b 100644
--- a/graphics/jni/Android.mk
+++ b/rs/jni/Android.mk
@@ -26,7 +26,7 @@
$(rs_generated_include_dir) \
$(call include-path-for, corecg graphics)
-LOCAL_CFLAGS +=
+LOCAL_CFLAGS += -Wno-unused-parameter
LOCAL_LDLIBS := -lpthread
LOCAL_ADDITIONAL_DEPENDENCIES := $(addprefix $(rs_generated_include_dir)/,rsgApiFuncDecl.h)
diff --git a/rs/jni/android_renderscript_RenderScript.cpp b/rs/jni/android_renderscript_RenderScript.cpp
new file mode 100644
index 0000000..9b89eb9
--- /dev/null
+++ b/rs/jni/android_renderscript_RenderScript.cpp
@@ -0,0 +1,1729 @@
+/*
+ * Copyright (C) 2011-2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "libRS_jni"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <math.h>
+#include <utils/misc.h>
+
+#include <core/SkBitmap.h>
+#include <core/SkPixelRef.h>
+#include <core/SkStream.h>
+#include <core/SkTemplates.h>
+
+#include <androidfw/Asset.h>
+#include <androidfw/AssetManager.h>
+#include <androidfw/ResourceTypes.h>
+
+#include "jni.h"
+#include "JNIHelp.h"
+#include "android_runtime/AndroidRuntime.h"
+#include "android_runtime/android_view_Surface.h"
+#include "android_runtime/android_util_AssetManager.h"
+
+#include <rs.h>
+#include <rsEnv.h>
+#include <gui/Surface.h>
+#include <gui/GLConsumer.h>
+#include <gui/Surface.h>
+#include <android_runtime/android_graphics_SurfaceTexture.h>
+
+//#define LOG_API ALOGE
+#define LOG_API(...)
+
+using namespace android;
+
+#define PER_ARRAY_TYPE(flag, fnc, ...) { \
+ jint len = 0; \
+ void *ptr = NULL; \
+ size_t typeBytes = 0; \
+ switch(dataType) { \
+ case RS_TYPE_FLOAT_32: \
+ len = _env->GetArrayLength((jfloatArray)data); \
+ ptr = _env->GetFloatArrayElements((jfloatArray)data, flag); \
+ typeBytes = 4; \
+ fnc(__VA_ARGS__); \
+ _env->ReleaseFloatArrayElements((jfloatArray)data, (jfloat *)ptr, JNI_ABORT); \
+ return; \
+ case RS_TYPE_FLOAT_64: \
+ len = _env->GetArrayLength((jdoubleArray)data); \
+ ptr = _env->GetDoubleArrayElements((jdoubleArray)data, flag); \
+ typeBytes = 8; \
+ fnc(__VA_ARGS__); \
+ _env->ReleaseDoubleArrayElements((jdoubleArray)data, (jdouble *)ptr, JNI_ABORT);\
+ return; \
+ case RS_TYPE_SIGNED_8: \
+ case RS_TYPE_UNSIGNED_8: \
+ len = _env->GetArrayLength((jbyteArray)data); \
+ ptr = _env->GetByteArrayElements((jbyteArray)data, flag); \
+ typeBytes = 1; \
+ fnc(__VA_ARGS__); \
+ _env->ReleaseByteArrayElements((jbyteArray)data, (jbyte*)ptr, JNI_ABORT); \
+ return; \
+ case RS_TYPE_SIGNED_16: \
+ case RS_TYPE_UNSIGNED_16: \
+ len = _env->GetArrayLength((jshortArray)data); \
+ ptr = _env->GetShortArrayElements((jshortArray)data, flag); \
+ typeBytes = 2; \
+ fnc(__VA_ARGS__); \
+ _env->ReleaseShortArrayElements((jshortArray)data, (jshort *)ptr, JNI_ABORT); \
+ return; \
+ case RS_TYPE_SIGNED_32: \
+ case RS_TYPE_UNSIGNED_32: \
+ len = _env->GetArrayLength((jintArray)data); \
+ ptr = _env->GetIntArrayElements((jintArray)data, flag); \
+ typeBytes = 4; \
+ fnc(__VA_ARGS__); \
+ _env->ReleaseIntArrayElements((jintArray)data, (jint *)ptr, JNI_ABORT); \
+ return; \
+ case RS_TYPE_SIGNED_64: \
+ case RS_TYPE_UNSIGNED_64: \
+ len = _env->GetArrayLength((jlongArray)data); \
+ ptr = _env->GetLongArrayElements((jlongArray)data, flag); \
+ typeBytes = 8; \
+ fnc(__VA_ARGS__); \
+ _env->ReleaseLongArrayElements((jlongArray)data, (jlong *)ptr, JNI_ABORT); \
+ return; \
+ default: \
+ break; \
+ } \
+}
+
+
+class AutoJavaStringToUTF8 {
+public:
+ AutoJavaStringToUTF8(JNIEnv* env, jstring str) : fEnv(env), fJStr(str) {
+ fCStr = env->GetStringUTFChars(str, NULL);
+ fLength = env->GetStringUTFLength(str);
+ }
+ ~AutoJavaStringToUTF8() {
+ fEnv->ReleaseStringUTFChars(fJStr, fCStr);
+ }
+ const char* c_str() const { return fCStr; }
+ jsize length() const { return fLength; }
+
+private:
+ JNIEnv* fEnv;
+ jstring fJStr;
+ const char* fCStr;
+ jsize fLength;
+};
+
+class AutoJavaStringArrayToUTF8 {
+public:
+ AutoJavaStringArrayToUTF8(JNIEnv* env, jobjectArray strings, jsize stringsLength)
+ : mEnv(env), mStrings(strings), mStringsLength(stringsLength) {
+ mCStrings = NULL;
+ mSizeArray = NULL;
+ if (stringsLength > 0) {
+ mCStrings = (const char **)calloc(stringsLength, sizeof(char *));
+ mSizeArray = (size_t*)calloc(stringsLength, sizeof(size_t));
+ for (jsize ct = 0; ct < stringsLength; ct ++) {
+ jstring s = (jstring)mEnv->GetObjectArrayElement(mStrings, ct);
+ mCStrings[ct] = mEnv->GetStringUTFChars(s, NULL);
+ mSizeArray[ct] = mEnv->GetStringUTFLength(s);
+ }
+ }
+ }
+ ~AutoJavaStringArrayToUTF8() {
+ for (jsize ct=0; ct < mStringsLength; ct++) {
+ jstring s = (jstring)mEnv->GetObjectArrayElement(mStrings, ct);
+ mEnv->ReleaseStringUTFChars(s, mCStrings[ct]);
+ }
+ free(mCStrings);
+ free(mSizeArray);
+ }
+ const char **c_str() const { return mCStrings; }
+ size_t *c_str_len() const { return mSizeArray; }
+ jsize length() const { return mStringsLength; }
+
+private:
+ JNIEnv *mEnv;
+ jobjectArray mStrings;
+ const char **mCStrings;
+ size_t *mSizeArray;
+ jsize mStringsLength;
+};
+
+// ---------------------------------------------------------------------------
+
+static jfieldID gContextId = 0;
+static jfieldID gNativeBitmapID = 0;
+static jfieldID gTypeNativeCache = 0;
+
+static void _nInit(JNIEnv *_env, jclass _this)
+{
+ gContextId = _env->GetFieldID(_this, "mContext", "J");
+
+ jclass bitmapClass = _env->FindClass("android/graphics/Bitmap");
+ gNativeBitmapID = _env->GetFieldID(bitmapClass, "mNativeBitmap", "J");
+}
+
+// ---------------------------------------------------------------------------
+
+static void
+nContextFinish(JNIEnv *_env, jobject _this, jlong con)
+{
+ LOG_API("nContextFinish, con(%p)", (RsContext)con);
+ rsContextFinish((RsContext)con);
+}
+
+static void
+nAssignName(JNIEnv *_env, jobject _this, jlong con, jlong obj, jbyteArray str)
+{
+ LOG_API("nAssignName, con(%p), obj(%p)", (RsContext)con, (void *)obj);
+ jint len = _env->GetArrayLength(str);
+ jbyte * cptr = (jbyte *) _env->GetPrimitiveArrayCritical(str, 0);
+ rsAssignName((RsContext)con, (void *)obj, (const char *)cptr, len);
+ _env->ReleasePrimitiveArrayCritical(str, cptr, JNI_ABORT);
+}
+
+static jstring
+nGetName(JNIEnv *_env, jobject _this, jlong con, jlong obj)
+{
+ LOG_API("nGetName, con(%p), obj(%p)", (RsContext)con, (void *)obj);
+ const char *name = NULL;
+ rsaGetName((RsContext)con, (void *)obj, &name);
+ if(name == NULL || strlen(name) == 0) {
+ return NULL;
+ }
+ return _env->NewStringUTF(name);
+}
+
+static void
+nObjDestroy(JNIEnv *_env, jobject _this, jlong con, jlong obj)
+{
+ LOG_API("nObjDestroy, con(%p) obj(%p)", (RsContext)con, (void *)obj);
+ rsObjDestroy((RsContext)con, (void *)obj);
+}
+
+// ---------------------------------------------------------------------------
+
+static jlong
+nDeviceCreate(JNIEnv *_env, jobject _this)
+{
+ LOG_API("nDeviceCreate");
+ return (jlong)rsDeviceCreate();
+}
+
+static void
+nDeviceDestroy(JNIEnv *_env, jobject _this, jlong dev)
+{
+ LOG_API("nDeviceDestroy");
+ return rsDeviceDestroy((RsDevice)dev);
+}
+
+static void
+nDeviceSetConfig(JNIEnv *_env, jobject _this, jlong dev, jint p, jint value)
+{
+ LOG_API("nDeviceSetConfig dev(%p), param(%i), value(%i)", (void *)dev, p, value);
+ return rsDeviceSetConfig((RsDevice)dev, (RsDeviceParam)p, value);
+}
+
+static jlong
+nContextCreate(JNIEnv *_env, jobject _this, jlong dev, jint ver, jint sdkVer, jint ct)
+{
+ LOG_API("nContextCreate");
+ return (jlong)rsContextCreate((RsDevice)dev, ver, sdkVer, (RsContextType)ct, 0);
+}
+
+static jlong
+nContextCreateGL(JNIEnv *_env, jobject _this, jlong dev, jint ver, jint sdkVer,
+ jint colorMin, jint colorPref,
+ jint alphaMin, jint alphaPref,
+ jint depthMin, jint depthPref,
+ jint stencilMin, jint stencilPref,
+ jint samplesMin, jint samplesPref, jfloat samplesQ,
+ jint dpi)
+{
+ RsSurfaceConfig sc;
+ sc.alphaMin = alphaMin;
+ sc.alphaPref = alphaPref;
+ sc.colorMin = colorMin;
+ sc.colorPref = colorPref;
+ sc.depthMin = depthMin;
+ sc.depthPref = depthPref;
+ sc.samplesMin = samplesMin;
+ sc.samplesPref = samplesPref;
+ sc.samplesQ = samplesQ;
+
+ LOG_API("nContextCreateGL");
+ return (jlong)rsContextCreateGL((RsDevice)dev, ver, sdkVer, sc, dpi);
+}
+
+static void
+nContextSetPriority(JNIEnv *_env, jobject _this, jlong con, jint p)
+{
+ LOG_API("ContextSetPriority, con(%p), priority(%i)", (RsContext)con, p);
+ rsContextSetPriority((RsContext)con, p);
+}
+
+
+
+static void
+nContextSetSurface(JNIEnv *_env, jobject _this, jlong con, jint width, jint height, jobject wnd)
+{
+ LOG_API("nContextSetSurface, con(%p), width(%i), height(%i), surface(%p)", (RsContext)con, width, height, (Surface *)wnd);
+
+ ANativeWindow * window = NULL;
+ if (wnd == NULL) {
+
+ } else {
+ window = android_view_Surface_getNativeWindow(_env, wnd).get();
+ }
+
+ rsContextSetSurface((RsContext)con, width, height, window);
+}
+
+static void
+nContextDestroy(JNIEnv *_env, jobject _this, jlong con)
+{
+ LOG_API("nContextDestroy, con(%p)", (RsContext)con);
+ rsContextDestroy((RsContext)con);
+}
+
+static void
+nContextDump(JNIEnv *_env, jobject _this, jlong con, jint bits)
+{
+ LOG_API("nContextDump, con(%p) bits(%i)", (RsContext)con, bits);
+ rsContextDump((RsContext)con, bits);
+}
+
+static void
+nContextPause(JNIEnv *_env, jobject _this, jlong con)
+{
+ LOG_API("nContextPause, con(%p)", (RsContext)con);
+ rsContextPause((RsContext)con);
+}
+
+static void
+nContextResume(JNIEnv *_env, jobject _this, jlong con)
+{
+ LOG_API("nContextResume, con(%p)", (RsContext)con);
+ rsContextResume((RsContext)con);
+}
+
+
+static jstring
+nContextGetErrorMessage(JNIEnv *_env, jobject _this, jlong con)
+{
+ LOG_API("nContextGetErrorMessage, con(%p)", (RsContext)con);
+ char buf[1024];
+
+ size_t receiveLen;
+ uint32_t subID;
+ int id = rsContextGetMessage((RsContext)con,
+ buf, sizeof(buf),
+ &receiveLen, sizeof(receiveLen),
+ &subID, sizeof(subID));
+ if (!id && receiveLen) {
+ ALOGV("message receive buffer too small. %i", receiveLen);
+ }
+ return _env->NewStringUTF(buf);
+}
+
+static jint
+nContextGetUserMessage(JNIEnv *_env, jobject _this, jlong con, jintArray data)
+{
+ jint len = _env->GetArrayLength(data);
+ LOG_API("nContextGetMessage, con(%p), len(%i)", (RsContext)con, len);
+ jint *ptr = _env->GetIntArrayElements(data, NULL);
+ size_t receiveLen;
+ uint32_t subID;
+ int id = rsContextGetMessage((RsContext)con,
+ ptr, len * 4,
+ &receiveLen, sizeof(receiveLen),
+ &subID, sizeof(subID));
+ if (!id && receiveLen) {
+ ALOGV("message receive buffer too small. %i", receiveLen);
+ }
+ _env->ReleaseIntArrayElements(data, ptr, 0);
+ return (jint)id;
+}
+
+static jint
+nContextPeekMessage(JNIEnv *_env, jobject _this, jlong con, jintArray auxData)
+{
+ LOG_API("nContextPeekMessage, con(%p)", (RsContext)con);
+ jint *auxDataPtr = _env->GetIntArrayElements(auxData, NULL);
+ size_t receiveLen;
+ uint32_t subID;
+ int id = rsContextPeekMessage((RsContext)con, &receiveLen, sizeof(receiveLen),
+ &subID, sizeof(subID));
+ auxDataPtr[0] = (jint)subID;
+ auxDataPtr[1] = (jint)receiveLen;
+ _env->ReleaseIntArrayElements(auxData, auxDataPtr, 0);
+ return (jint)id;
+}
+
+static void nContextInitToClient(JNIEnv *_env, jobject _this, jlong con)
+{
+ LOG_API("nContextInitToClient, con(%p)", (RsContext)con);
+ rsContextInitToClient((RsContext)con);
+}
+
+static void nContextDeinitToClient(JNIEnv *_env, jobject _this, jlong con)
+{
+ LOG_API("nContextDeinitToClient, con(%p)", (RsContext)con);
+ rsContextDeinitToClient((RsContext)con);
+}
+
+static void
+nContextSendMessage(JNIEnv *_env, jobject _this, jlong con, jint id, jintArray data)
+{
+ jint *ptr = NULL;
+ jint len = 0;
+ if (data) {
+ len = _env->GetArrayLength(data);
+ ptr = _env->GetIntArrayElements(data, NULL);
+ }
+ LOG_API("nContextSendMessage, con(%p), id(%i), len(%i)", (RsContext)con, id, len);
+ rsContextSendMessage((RsContext)con, id, (const uint8_t *)ptr, len * sizeof(int));
+ if (data) {
+ _env->ReleaseIntArrayElements(data, ptr, JNI_ABORT);
+ }
+}
+
+
+
+static jlong
+nElementCreate(JNIEnv *_env, jobject _this, jlong con, jlong type, jint kind, jboolean norm, jint size)
+{
+ LOG_API("nElementCreate, con(%p), type(%i), kind(%i), norm(%i), size(%i)", (RsContext)con, type, kind, norm, size);
+ return (jlong)rsElementCreate((RsContext)con, (RsDataType)type, (RsDataKind)kind, norm, size);
+}
+
+static jlong
+nElementCreate2(JNIEnv *_env, jobject _this, jlong con,
+ jlongArray _ids, jobjectArray _names, jintArray _arraySizes)
+{
+ int fieldCount = _env->GetArrayLength(_ids);
+ LOG_API("nElementCreate2, con(%p)", (RsContext)con);
+
+ jlong *jIds = _env->GetLongArrayElements(_ids, NULL);
+ jint *jArraySizes = _env->GetIntArrayElements(_arraySizes, NULL);
+
+ RsElement *ids = (RsElement*)malloc(fieldCount * sizeof(RsElement));
+ uint32_t *arraySizes = (uint32_t *)malloc(fieldCount * sizeof(uint32_t));
+
+ for(int i = 0; i < fieldCount; i ++) {
+ ids[i] = (RsElement)jIds[i];
+ arraySizes[i] = (uint32_t)jArraySizes[i];
+ }
+
+ AutoJavaStringArrayToUTF8 names(_env, _names, fieldCount);
+
+ const char **nameArray = names.c_str();
+ size_t *sizeArray = names.c_str_len();
+
+ jlong id = (jlong)rsElementCreate2((RsContext)con,
+ (const RsElement *)ids, fieldCount,
+ nameArray, fieldCount * sizeof(size_t), sizeArray,
+ (const uint32_t *)arraySizes, fieldCount);
+
+ free(ids);
+ free(arraySizes);
+ _env->ReleaseLongArrayElements(_ids, jIds, JNI_ABORT);
+ _env->ReleaseIntArrayElements(_arraySizes, jArraySizes, JNI_ABORT);
+
+ return (jlong)id;
+}
+
+static void
+nElementGetNativeData(JNIEnv *_env, jobject _this, jlong con, jlong id, jintArray _elementData)
+{
+ int dataSize = _env->GetArrayLength(_elementData);
+ LOG_API("nElementGetNativeData, con(%p)", (RsContext)con);
+
+ // we will pack mType; mKind; mNormalized; mVectorSize; NumSubElements
+ assert(dataSize == 5);
+
+ uintptr_t elementData[5];
+ rsaElementGetNativeData((RsContext)con, (RsElement)id, elementData, dataSize);
+
+ for(jint i = 0; i < dataSize; i ++) {
+ const jint data = (jint)elementData[i];
+ _env->SetIntArrayRegion(_elementData, i, 1, &data);
+ }
+}
+
+
+static void
+nElementGetSubElements(JNIEnv *_env, jobject _this, jlong con, jlong id,
+ jlongArray _IDs,
+ jobjectArray _names,
+ jintArray _arraySizes)
+{
+ uint32_t dataSize = _env->GetArrayLength(_IDs);
+ LOG_API("nElementGetSubElements, con(%p)", (RsContext)con);
+
+ uintptr_t *ids = (uintptr_t*)malloc(dataSize * sizeof(uintptr_t));
+ const char **names = (const char **)malloc(dataSize * sizeof(const char *));
+ uint32_t *arraySizes = (uint32_t *)malloc(dataSize * sizeof(uint32_t));
+
+ rsaElementGetSubElements((RsContext)con, (RsElement)id, ids, names, arraySizes, (uint32_t)dataSize);
+
+ for(uint32_t i = 0; i < dataSize; i++) {
+ const jlong id = (jlong)ids[i];
+ const jint arraySize = (jint)arraySizes[i];
+ _env->SetObjectArrayElement(_names, i, _env->NewStringUTF(names[i]));
+ _env->SetLongArrayRegion(_IDs, i, 1, &id);
+ _env->SetIntArrayRegion(_arraySizes, i, 1, &arraySize);
+ }
+
+ free(ids);
+ free(names);
+ free(arraySizes);
+}
+
+// -----------------------------------
+
+static jlong
+nTypeCreate(JNIEnv *_env, jobject _this, jlong con, jlong eid,
+ jint dimx, jint dimy, jint dimz, jboolean mips, jboolean faces, jint yuv)
+{
+ LOG_API("nTypeCreate, con(%p) eid(%p), x(%i), y(%i), z(%i), mips(%i), faces(%i), yuv(%i)",
+ (RsContext)con, eid, dimx, dimy, dimz, mips, faces, yuv);
+
+ return (jlong)rsTypeCreate((RsContext)con, (RsElement)eid, dimx, dimy, dimz, mips, faces, yuv);
+}
+
+static void
+nTypeGetNativeData(JNIEnv *_env, jobject _this, jlong con, jlong id, jlongArray _typeData)
+{
+ // We are packing 6 items: mDimX; mDimY; mDimZ;
+ // mDimLOD; mDimFaces; mElement; into typeData
+ int elementCount = _env->GetArrayLength(_typeData);
+
+ assert(elementCount == 6);
+ LOG_API("nTypeGetNativeData, con(%p)", (RsContext)con);
+
+ uintptr_t typeData[6];
+ rsaTypeGetNativeData((RsContext)con, (RsType)id, typeData, 6);
+
+ for(jint i = 0; i < elementCount; i ++) {
+ const jlong data = (jlong)typeData[i];
+ _env->SetLongArrayRegion(_typeData, i, 1, &data);
+ }
+}
+
+// -----------------------------------
+
+static jlong
+nAllocationCreateTyped(JNIEnv *_env, jobject _this, jlong con, jlong type, jint mips, jint usage, jlong pointer)
+{
+ LOG_API("nAllocationCreateTyped, con(%p), type(%p), mip(%i), usage(%i), ptr(%p)", (RsContext)con, (RsElement)type, mips, usage, (void *)pointer);
+ return (jlong) rsAllocationCreateTyped((RsContext)con, (RsType)type, (RsAllocationMipmapControl)mips, (uint32_t)usage, (uintptr_t)pointer);
+}
+
+static void
+nAllocationSyncAll(JNIEnv *_env, jobject _this, jlong con, jlong a, jint bits)
+{
+ LOG_API("nAllocationSyncAll, con(%p), a(%p), bits(0x%08x)", (RsContext)con, (RsAllocation)a, bits);
+ rsAllocationSyncAll((RsContext)con, (RsAllocation)a, (RsAllocationUsageType)bits);
+}
+
+static jobject
+nAllocationGetSurface(JNIEnv *_env, jobject _this, jlong con, jlong a)
+{
+ LOG_API("nAllocationGetSurface, con(%p), a(%p)", (RsContext)con, (RsAllocation)a);
+
+ IGraphicBufferProducer *v = (IGraphicBufferProducer *)rsAllocationGetSurface((RsContext)con, (RsAllocation)a);
+ sp<IGraphicBufferProducer> bp = v;
+ v->decStrong(NULL);
+
+ jobject o = android_view_Surface_createFromIGraphicBufferProducer(_env, bp);
+ return o;
+}
+
+static void
+nAllocationSetSurface(JNIEnv *_env, jobject _this, jlong con, jlong alloc, jobject sur)
+{
+ LOG_API("nAllocationSetSurface, con(%p), alloc(%p), surface(%p)",
+ (RsContext)con, (RsAllocation)alloc, (Surface *)sur);
+
+ sp<Surface> s;
+ if (sur != 0) {
+ s = android_view_Surface_getSurface(_env, sur);
+ }
+
+ rsAllocationSetSurface((RsContext)con, (RsAllocation)alloc, static_cast<ANativeWindow *>(s.get()));
+}
+
+static void
+nAllocationIoSend(JNIEnv *_env, jobject _this, jlong con, jlong alloc)
+{
+ LOG_API("nAllocationIoSend, con(%p), alloc(%p)", (RsContext)con, alloc);
+ rsAllocationIoSend((RsContext)con, (RsAllocation)alloc);
+}
+
+static void
+nAllocationIoReceive(JNIEnv *_env, jobject _this, jlong con, jlong alloc)
+{
+ LOG_API("nAllocationIoReceive, con(%p), alloc(%p)", (RsContext)con, alloc);
+ rsAllocationIoReceive((RsContext)con, (RsAllocation)alloc);
+}
+
+
+static void
+nAllocationGenerateMipmaps(JNIEnv *_env, jobject _this, jlong con, jlong alloc)
+{
+ LOG_API("nAllocationGenerateMipmaps, con(%p), a(%p)", (RsContext)con, (RsAllocation)alloc);
+ rsAllocationGenerateMipmaps((RsContext)con, (RsAllocation)alloc);
+}
+
+static jlong
+nAllocationCreateFromBitmap(JNIEnv *_env, jobject _this, jlong con, jlong type, jint mip, jobject jbitmap, jint usage)
+{
+ SkBitmap const * nativeBitmap =
+ (SkBitmap const *)_env->GetLongField(jbitmap, gNativeBitmapID);
+ const SkBitmap& bitmap(*nativeBitmap);
+
+ bitmap.lockPixels();
+ const void* ptr = bitmap.getPixels();
+ jlong id = (jlong)rsAllocationCreateFromBitmap((RsContext)con,
+ (RsType)type, (RsAllocationMipmapControl)mip,
+ ptr, bitmap.getSize(), usage);
+ bitmap.unlockPixels();
+ return id;
+}
+
+static jlong
+nAllocationCreateBitmapBackedAllocation(JNIEnv *_env, jobject _this, jlong con, jlong type, jint mip, jobject jbitmap, jint usage)
+{
+ SkBitmap const * nativeBitmap =
+ (SkBitmap const *)_env->GetLongField(jbitmap, gNativeBitmapID);
+ const SkBitmap& bitmap(*nativeBitmap);
+
+ bitmap.lockPixels();
+ const void* ptr = bitmap.getPixels();
+ jlong id = (jlong)rsAllocationCreateTyped((RsContext)con,
+ (RsType)type, (RsAllocationMipmapControl)mip,
+ (uint32_t)usage, (uintptr_t)ptr);
+ bitmap.unlockPixels();
+ return id;
+}
+
+static jlong
+nAllocationCubeCreateFromBitmap(JNIEnv *_env, jobject _this, jlong con, jlong type, jint mip, jobject jbitmap, jint usage)
+{
+ SkBitmap const * nativeBitmap =
+ (SkBitmap const *)_env->GetLongField(jbitmap, gNativeBitmapID);
+ const SkBitmap& bitmap(*nativeBitmap);
+
+ bitmap.lockPixels();
+ const void* ptr = bitmap.getPixels();
+ jlong id = (jlong)rsAllocationCubeCreateFromBitmap((RsContext)con,
+ (RsType)type, (RsAllocationMipmapControl)mip,
+ ptr, bitmap.getSize(), usage);
+ bitmap.unlockPixels();
+ return id;
+}
+
+static void
+nAllocationCopyFromBitmap(JNIEnv *_env, jobject _this, jlong con, jlong alloc, jobject jbitmap)
+{
+ SkBitmap const * nativeBitmap =
+ (SkBitmap const *)_env->GetLongField(jbitmap, gNativeBitmapID);
+ const SkBitmap& bitmap(*nativeBitmap);
+ int w = bitmap.width();
+ int h = bitmap.height();
+
+ bitmap.lockPixels();
+ const void* ptr = bitmap.getPixels();
+ rsAllocation2DData((RsContext)con, (RsAllocation)alloc, 0, 0,
+ 0, RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_X,
+ w, h, ptr, bitmap.getSize(), 0);
+ bitmap.unlockPixels();
+}
+
+static void
+nAllocationCopyToBitmap(JNIEnv *_env, jobject _this, jlong con, jlong alloc, jobject jbitmap)
+{
+ SkBitmap const * nativeBitmap =
+ (SkBitmap const *)_env->GetLongField(jbitmap, gNativeBitmapID);
+ const SkBitmap& bitmap(*nativeBitmap);
+
+ bitmap.lockPixels();
+ void* ptr = bitmap.getPixels();
+ rsAllocationCopyToBitmap((RsContext)con, (RsAllocation)alloc, ptr, bitmap.getSize());
+ bitmap.unlockPixels();
+ bitmap.notifyPixelsChanged();
+}
+
+static void ReleaseBitmapCallback(void *bmp)
+{
+ SkBitmap const * nativeBitmap = (SkBitmap const *)bmp;
+ nativeBitmap->unlockPixels();
+}
+
+
+static void
+nAllocationData1D(JNIEnv *_env, jobject _this, jlong con, jlong _alloc, jint offset, jint lod,
+ jint count, jobject data, jint sizeBytes, jint dataType)
+{
+ RsAllocation *alloc = (RsAllocation *)_alloc;
+ LOG_API("nAllocation1DData, con(%p), adapter(%p), offset(%i), count(%i), sizeBytes(%i), dataType(%i)",
+ (RsContext)con, (RsAllocation)alloc, offset, count, sizeBytes, dataType);
+ PER_ARRAY_TYPE(NULL, rsAllocation1DData, (RsContext)con, alloc, offset, lod, count, ptr, sizeBytes);
+}
+
+static void
+// native void rsnAllocationElementData1D(long con, long id, int xoff, int compIdx, byte[] d, int sizeBytes);
+nAllocationElementData1D(JNIEnv *_env, jobject _this, jlong con, jlong alloc, jint offset, jint lod, jint compIdx, jbyteArray data, jint sizeBytes)
+{
+ jint len = _env->GetArrayLength(data);
+ LOG_API("nAllocationElementData1D, con(%p), alloc(%p), offset(%i), comp(%i), len(%i), sizeBytes(%i)", (RsContext)con, (RsAllocation)alloc, offset, compIdx, len, sizeBytes);
+ jbyte *ptr = _env->GetByteArrayElements(data, NULL);
+ rsAllocation1DElementData((RsContext)con, (RsAllocation)alloc, offset, lod, ptr, sizeBytes, compIdx);
+ _env->ReleaseByteArrayElements(data, ptr, JNI_ABORT);
+}
+
+static void
+nAllocationData2D(JNIEnv *_env, jobject _this, jlong con, jlong _alloc, jint xoff, jint yoff, jint lod, jint _face,
+ jint w, jint h, jobject data, jint sizeBytes, jint dataType)
+{
+ RsAllocation *alloc = (RsAllocation *)_alloc;
+ RsAllocationCubemapFace face = (RsAllocationCubemapFace)_face;
+ LOG_API("nAllocation2DData, con(%p), adapter(%p), xoff(%i), yoff(%i), w(%i), h(%i), len(%i) type(%i)",
+ (RsContext)con, alloc, xoff, yoff, w, h, sizeBytes, dataType);
+ PER_ARRAY_TYPE(NULL, rsAllocation2DData, (RsContext)con, alloc, xoff, yoff, lod, face, w, h, ptr, sizeBytes, 0);
+}
+
+static void
+nAllocationData2D_alloc(JNIEnv *_env, jobject _this, jlong con,
+ jlong dstAlloc, jint dstXoff, jint dstYoff,
+ jint dstMip, jint dstFace,
+ jint width, jint height,
+ jlong srcAlloc, jint srcXoff, jint srcYoff,
+ jint srcMip, jint srcFace)
+{
+ LOG_API("nAllocation2DData_s, con(%p), dstAlloc(%p), dstXoff(%i), dstYoff(%i),"
+ " dstMip(%i), dstFace(%i), width(%i), height(%i),"
+ " srcAlloc(%p), srcXoff(%i), srcYoff(%i), srcMip(%i), srcFace(%i)",
+ (RsContext)con, (RsAllocation)dstAlloc, dstXoff, dstYoff, dstMip, dstFace,
+ width, height, (RsAllocation)srcAlloc, srcXoff, srcYoff, srcMip, srcFace);
+
+ rsAllocationCopy2DRange((RsContext)con,
+ (RsAllocation)dstAlloc,
+ dstXoff, dstYoff,
+ dstMip, dstFace,
+ width, height,
+ (RsAllocation)srcAlloc,
+ srcXoff, srcYoff,
+ srcMip, srcFace);
+}
+
+static void
+nAllocationData3D(JNIEnv *_env, jobject _this, jlong con, jlong _alloc, jint xoff, jint yoff, jint zoff, jint lod,
+ jint w, jint h, jint d, jobject data, int sizeBytes, int dataType)
+{
+ RsAllocation *alloc = (RsAllocation *)_alloc;
+ LOG_API("nAllocation3DData, con(%p), alloc(%p), xoff(%i), yoff(%i), zoff(%i), lod(%i), w(%i), h(%i), d(%i), sizeBytes(%i)",
+ (RsContext)con, (RsAllocation)alloc, xoff, yoff, zoff, lod, w, h, d, sizeBytes);
+ PER_ARRAY_TYPE(NULL, rsAllocation3DData, (RsContext)con, alloc, xoff, yoff, zoff, lod, w, h, d, ptr, sizeBytes, 0);
+}
+
+static void
+nAllocationData3D_alloc(JNIEnv *_env, jobject _this, jlong con,
+ jlong dstAlloc, jint dstXoff, jint dstYoff, jint dstZoff,
+ jint dstMip,
+ jint width, jint height, jint depth,
+ jlong srcAlloc, jint srcXoff, jint srcYoff, jint srcZoff,
+ jint srcMip)
+{
+ LOG_API("nAllocationData3D_alloc, con(%p), dstAlloc(%p), dstXoff(%i), dstYoff(%i),"
+ " dstMip(%i), width(%i), height(%i),"
+ " srcAlloc(%p), srcXoff(%i), srcYoff(%i), srcMip(%i)",
+ (RsContext)con, (RsAllocation)dstAlloc, dstXoff, dstYoff, dstMip,
+ width, height, (RsAllocation)srcAlloc, srcXoff, srcYoff, srcMip);
+
+ rsAllocationCopy3DRange((RsContext)con,
+ (RsAllocation)dstAlloc,
+ dstXoff, dstYoff, dstZoff, dstMip,
+ width, height, depth,
+ (RsAllocation)srcAlloc,
+ srcXoff, srcYoff, srcZoff, srcMip);
+}
+
+
+static void
+nAllocationRead(JNIEnv *_env, jobject _this, jlong con, jlong _alloc, jobject data, int dataType)
+{
+ RsAllocation *alloc = (RsAllocation *)_alloc;
+ LOG_API("nAllocationRead, con(%p), alloc(%p)", (RsContext)con, (RsAllocation)alloc);
+ PER_ARRAY_TYPE(0, rsAllocationRead, (RsContext)con, alloc, ptr, len * typeBytes);
+}
+
+static void
+nAllocationRead1D(JNIEnv *_env, jobject _this, jlong con, jlong _alloc, jint offset, jint lod,
+ jint count, jobject data, int sizeBytes, int dataType)
+{
+ RsAllocation *alloc = (RsAllocation *)_alloc;
+ LOG_API("nAllocation1DRead, con(%p), adapter(%p), offset(%i), count(%i), sizeBytes(%i), dataType(%i)",
+ (RsContext)con, alloc, offset, count, sizeBytes, dataType);
+ PER_ARRAY_TYPE(0, rsAllocation1DRead, (RsContext)con, alloc, offset, lod, count, ptr, sizeBytes);
+}
+
+static void
+nAllocationRead2D(JNIEnv *_env, jobject _this, jlong con, jlong _alloc, jint xoff, jint yoff, jint lod, jint _face,
+ jint w, jint h, jobject data, int sizeBytes, int dataType)
+{
+ RsAllocation *alloc = (RsAllocation *)_alloc;
+ RsAllocationCubemapFace face = (RsAllocationCubemapFace)_face;
+ LOG_API("nAllocation2DRead, con(%p), adapter(%p), xoff(%i), yoff(%i), w(%i), h(%i), len(%i) type(%i)",
+ (RsContext)con, alloc, xoff, yoff, w, h, sizeBytes, dataType);
+ PER_ARRAY_TYPE(0, rsAllocation2DRead, (RsContext)con, alloc, xoff, yoff, lod, face, w, h, ptr, sizeBytes, 0);
+}
+
+static jlong
+nAllocationGetType(JNIEnv *_env, jobject _this, jlong con, jlong a)
+{
+ LOG_API("nAllocationGetType, con(%p), a(%p)", (RsContext)con, (RsAllocation)a);
+ return (jlong) rsaAllocationGetType((RsContext)con, (RsAllocation)a);
+}
+
+static void
+nAllocationResize1D(JNIEnv *_env, jobject _this, jlong con, jlong alloc, jint dimX)
+{
+ LOG_API("nAllocationResize1D, con(%p), alloc(%p), sizeX(%i)", (RsContext)con, (RsAllocation)alloc, dimX);
+ rsAllocationResize1D((RsContext)con, (RsAllocation)alloc, dimX);
+}
+
+// -----------------------------------
+
+static jlong
+nFileA3DCreateFromAssetStream(JNIEnv *_env, jobject _this, jlong con, jlong native_asset)
+{
+ Asset* asset = reinterpret_cast<Asset*>(native_asset);
+ ALOGV("______nFileA3D %p", asset);
+
+ jlong id = (jlong)rsaFileA3DCreateFromMemory((RsContext)con, asset->getBuffer(false), asset->getLength());
+ return id;
+}
+
+static jlong
+nFileA3DCreateFromAsset(JNIEnv *_env, jobject _this, jlong con, jobject _assetMgr, jstring _path)
+{
+ AssetManager* mgr = assetManagerForJavaObject(_env, _assetMgr);
+ if (mgr == NULL) {
+ return 0;
+ }
+
+ AutoJavaStringToUTF8 str(_env, _path);
+ Asset* asset = mgr->open(str.c_str(), Asset::ACCESS_BUFFER);
+ if (asset == NULL) {
+ return 0;
+ }
+
+ jlong id = (jlong)rsaFileA3DCreateFromAsset((RsContext)con, asset);
+ return id;
+}
+
+static jlong
+nFileA3DCreateFromFile(JNIEnv *_env, jobject _this, jlong con, jstring fileName)
+{
+ AutoJavaStringToUTF8 fileNameUTF(_env, fileName);
+ jlong id = (jlong)rsaFileA3DCreateFromFile((RsContext)con, fileNameUTF.c_str());
+
+ return id;
+}
+
+static jint
+nFileA3DGetNumIndexEntries(JNIEnv *_env, jobject _this, jlong con, jlong fileA3D)
+{
+ int32_t numEntries = 0;
+ rsaFileA3DGetNumIndexEntries((RsContext)con, &numEntries, (RsFile)fileA3D);
+ return (jint)numEntries;
+}
+
+static void
+nFileA3DGetIndexEntries(JNIEnv *_env, jobject _this, jlong con, jlong fileA3D, jint numEntries, jintArray _ids, jobjectArray _entries)
+{
+ ALOGV("______nFileA3D %p", (RsFile) fileA3D);
+ RsFileIndexEntry *fileEntries = (RsFileIndexEntry*)malloc((uint32_t)numEntries * sizeof(RsFileIndexEntry));
+
+ rsaFileA3DGetIndexEntries((RsContext)con, fileEntries, (uint32_t)numEntries, (RsFile)fileA3D);
+
+ for(jint i = 0; i < numEntries; i ++) {
+ _env->SetObjectArrayElement(_entries, i, _env->NewStringUTF(fileEntries[i].objectName));
+ _env->SetIntArrayRegion(_ids, i, 1, (const jint*)&fileEntries[i].classID);
+ }
+
+ free(fileEntries);
+}
+
+static jlong
+nFileA3DGetEntryByIndex(JNIEnv *_env, jobject _this, jlong con, jlong fileA3D, jint index)
+{
+ ALOGV("______nFileA3D %p", (RsFile) fileA3D);
+ jlong id = (jlong)rsaFileA3DGetEntryByIndex((RsContext)con, (uint32_t)index, (RsFile)fileA3D);
+ return id;
+}
+
+// -----------------------------------
+
+static jlong
+nFontCreateFromFile(JNIEnv *_env, jobject _this, jlong con,
+ jstring fileName, jfloat fontSize, jint dpi)
+{
+ AutoJavaStringToUTF8 fileNameUTF(_env, fileName);
+ jlong id = (jlong)rsFontCreateFromFile((RsContext)con,
+ fileNameUTF.c_str(), fileNameUTF.length(),
+ fontSize, dpi);
+
+ return id;
+}
+
+static jlong
+nFontCreateFromAssetStream(JNIEnv *_env, jobject _this, jlong con,
+ jstring name, jfloat fontSize, jint dpi, jlong native_asset)
+{
+ Asset* asset = reinterpret_cast<Asset*>(native_asset);
+ AutoJavaStringToUTF8 nameUTF(_env, name);
+
+ jlong id = (jlong)rsFontCreateFromMemory((RsContext)con,
+ nameUTF.c_str(), nameUTF.length(),
+ fontSize, dpi,
+ asset->getBuffer(false), asset->getLength());
+ return id;
+}
+
+static jlong
+nFontCreateFromAsset(JNIEnv *_env, jobject _this, jlong con, jobject _assetMgr, jstring _path,
+ jfloat fontSize, jint dpi)
+{
+ AssetManager* mgr = assetManagerForJavaObject(_env, _assetMgr);
+ if (mgr == NULL) {
+ return 0;
+ }
+
+ AutoJavaStringToUTF8 str(_env, _path);
+ Asset* asset = mgr->open(str.c_str(), Asset::ACCESS_BUFFER);
+ if (asset == NULL) {
+ return 0;
+ }
+
+ jlong id = (jlong)rsFontCreateFromMemory((RsContext)con,
+ str.c_str(), str.length(),
+ fontSize, dpi,
+ asset->getBuffer(false), asset->getLength());
+ delete asset;
+ return id;
+}
+
+// -----------------------------------
+
+static void
+nScriptBindAllocation(JNIEnv *_env, jobject _this, jlong con, jlong script, jlong alloc, jint slot)
+{
+ LOG_API("nScriptBindAllocation, con(%p), script(%p), alloc(%p), slot(%i)", (RsContext)con, (RsScript)script, (RsAllocation)alloc, slot);
+ rsScriptBindAllocation((RsContext)con, (RsScript)script, (RsAllocation)alloc, slot);
+}
+
+static void
+nScriptSetVarI(JNIEnv *_env, jobject _this, jlong con, jlong script, jint slot, jint val)
+{
+ LOG_API("nScriptSetVarI, con(%p), s(%p), slot(%i), val(%i)", (RsContext)con, (void *)script, slot, val);
+ rsScriptSetVarI((RsContext)con, (RsScript)script, slot, val);
+}
+
+static jint
+nScriptGetVarI(JNIEnv *_env, jobject _this, jlong con, jlong script, jint slot)
+{
+ LOG_API("nScriptGetVarI, con(%p), s(%p), slot(%i)", (RsContext)con, (void *)script, slot);
+ int value = 0;
+ rsScriptGetVarV((RsContext)con, (RsScript)script, slot, &value, sizeof(value));
+ return value;
+}
+
+static void
+nScriptSetVarObj(JNIEnv *_env, jobject _this, jlong con, jlong script, jint slot, jlong val)
+{
+ LOG_API("nScriptSetVarObj, con(%p), s(%p), slot(%i), val(%i)", (RsContext)con, (void *)script, slot, val);
+ rsScriptSetVarObj((RsContext)con, (RsScript)script, slot, (RsObjectBase)val);
+}
+
+static void
+nScriptSetVarJ(JNIEnv *_env, jobject _this, jlong con, jlong script, jint slot, jlong val)
+{
+ LOG_API("nScriptSetVarJ, con(%p), s(%p), slot(%i), val(%lli)", (RsContext)con, (void *)script, slot, val);
+ rsScriptSetVarJ((RsContext)con, (RsScript)script, slot, val);
+}
+
+static jlong
+nScriptGetVarJ(JNIEnv *_env, jobject _this, jlong con, jlong script, jint slot)
+{
+ LOG_API("nScriptGetVarJ, con(%p), s(%p), slot(%i)", (RsContext)con, (void *)script, slot);
+ jlong value = 0;
+ rsScriptGetVarV((RsContext)con, (RsScript)script, slot, &value, sizeof(value));
+ return value;
+}
+
+static void
+nScriptSetVarF(JNIEnv *_env, jobject _this, jlong con, jlong script, jint slot, float val)
+{
+ LOG_API("nScriptSetVarF, con(%p), s(%p), slot(%i), val(%f)", (RsContext)con, (void *)script, slot, val);
+ rsScriptSetVarF((RsContext)con, (RsScript)script, slot, val);
+}
+
+static jfloat
+nScriptGetVarF(JNIEnv *_env, jobject _this, jlong con, jlong script, jint slot)
+{
+ LOG_API("nScriptGetVarF, con(%p), s(%p), slot(%i)", (RsContext)con, (void *)script, slot);
+ jfloat value = 0;
+ rsScriptGetVarV((RsContext)con, (RsScript)script, slot, &value, sizeof(value));
+ return value;
+}
+
+static void
+nScriptSetVarD(JNIEnv *_env, jobject _this, jlong con, jlong script, jint slot, double val)
+{
+ LOG_API("nScriptSetVarD, con(%p), s(%p), slot(%i), val(%lf)", (RsContext)con, (void *)script, slot, val);
+ rsScriptSetVarD((RsContext)con, (RsScript)script, slot, val);
+}
+
+static jdouble
+nScriptGetVarD(JNIEnv *_env, jobject _this, jlong con, jlong script, jint slot)
+{
+ LOG_API("nScriptGetVarD, con(%p), s(%p), slot(%i)", (RsContext)con, (void *)script, slot);
+ jdouble value = 0;
+ rsScriptGetVarV((RsContext)con, (RsScript)script, slot, &value, sizeof(value));
+ return value;
+}
+
+static void
+nScriptSetVarV(JNIEnv *_env, jobject _this, jlong con, jlong script, jint slot, jbyteArray data)
+{
+ LOG_API("nScriptSetVarV, con(%p), s(%p), slot(%i)", (RsContext)con, (void *)script, slot);
+ jint len = _env->GetArrayLength(data);
+ jbyte *ptr = _env->GetByteArrayElements(data, NULL);
+ rsScriptSetVarV((RsContext)con, (RsScript)script, slot, ptr, len);
+ _env->ReleaseByteArrayElements(data, ptr, JNI_ABORT);
+}
+
+static void
+nScriptGetVarV(JNIEnv *_env, jobject _this, jlong con, jlong script, jint slot, jbyteArray data)
+{
+ LOG_API("nScriptSetVarV, con(%p), s(%p), slot(%i)", (RsContext)con, (void *)script, slot);
+ jint len = _env->GetArrayLength(data);
+ jbyte *ptr = _env->GetByteArrayElements(data, NULL);
+ rsScriptGetVarV((RsContext)con, (RsScript)script, slot, ptr, len);
+ _env->ReleaseByteArrayElements(data, ptr, JNI_ABORT);
+}
+
+static void
+nScriptSetVarVE(JNIEnv *_env, jobject _this, jlong con, jlong script, jint slot, jbyteArray data, jlong elem, jintArray dims)
+{
+ LOG_API("nScriptSetVarVE, con(%p), s(%p), slot(%i)", (RsContext)con, (void *)script, slot);
+ jint len = _env->GetArrayLength(data);
+ jbyte *ptr = _env->GetByteArrayElements(data, NULL);
+ jint dimsLen = _env->GetArrayLength(dims) * sizeof(int);
+ jint *dimsPtr = _env->GetIntArrayElements(dims, NULL);
+ rsScriptSetVarVE((RsContext)con, (RsScript)script, slot, ptr, len, (RsElement)elem,
+ (const size_t*) dimsPtr, dimsLen);
+ _env->ReleaseByteArrayElements(data, ptr, JNI_ABORT);
+ _env->ReleaseIntArrayElements(dims, dimsPtr, JNI_ABORT);
+}
+
+
+static void
+nScriptSetTimeZone(JNIEnv *_env, jobject _this, jlong con, jlong script, jbyteArray timeZone)
+{
+ LOG_API("nScriptCSetTimeZone, con(%p), s(%p)", (RsContext)con, (void *)script);
+
+ jint length = _env->GetArrayLength(timeZone);
+ jbyte* timeZone_ptr;
+ timeZone_ptr = (jbyte *) _env->GetPrimitiveArrayCritical(timeZone, (jboolean *)0);
+
+ rsScriptSetTimeZone((RsContext)con, (RsScript)script, (const char *)timeZone_ptr, length);
+
+ if (timeZone_ptr) {
+ _env->ReleasePrimitiveArrayCritical(timeZone, timeZone_ptr, 0);
+ }
+}
+
+static void
+nScriptInvoke(JNIEnv *_env, jobject _this, jlong con, jlong obj, jint slot)
+{
+ LOG_API("nScriptInvoke, con(%p), script(%p)", (RsContext)con, (void *)obj);
+ rsScriptInvoke((RsContext)con, (RsScript)obj, slot);
+}
+
+static void
+nScriptInvokeV(JNIEnv *_env, jobject _this, jlong con, jlong script, jint slot, jbyteArray data)
+{
+ LOG_API("nScriptInvokeV, con(%p), s(%p), slot(%i)", (RsContext)con, (void *)script, slot);
+ jint len = _env->GetArrayLength(data);
+ jbyte *ptr = _env->GetByteArrayElements(data, NULL);
+ rsScriptInvokeV((RsContext)con, (RsScript)script, slot, ptr, len);
+ _env->ReleaseByteArrayElements(data, ptr, JNI_ABORT);
+}
+
+static void
+nScriptForEach(JNIEnv *_env, jobject _this, jlong con,
+ jlong script, jint slot, jlong ain, jlong aout)
+{
+ LOG_API("nScriptForEach, con(%p), s(%p), slot(%i)", (RsContext)con, (void *)script, slot);
+ rsScriptForEach((RsContext)con, (RsScript)script, slot, (RsAllocation)ain, (RsAllocation)aout, NULL, 0, NULL, 0);
+}
+static void
+nScriptForEachV(JNIEnv *_env, jobject _this, jlong con,
+ jlong script, jint slot, jlong ain, jlong aout, jbyteArray params)
+{
+ LOG_API("nScriptForEach, con(%p), s(%p), slot(%i)", (RsContext)con, (void *)script, slot);
+ jint len = _env->GetArrayLength(params);
+ jbyte *ptr = _env->GetByteArrayElements(params, NULL);
+ rsScriptForEach((RsContext)con, (RsScript)script, slot, (RsAllocation)ain, (RsAllocation)aout, ptr, len, NULL, 0);
+ _env->ReleaseByteArrayElements(params, ptr, JNI_ABORT);
+}
+
+static void
+nScriptForEachClipped(JNIEnv *_env, jobject _this, jlong con,
+ jlong script, jint slot, jlong ain, jlong aout,
+ jint xstart, jint xend,
+ jint ystart, jint yend, jint zstart, jint zend)
+{
+ LOG_API("nScriptForEachClipped, con(%p), s(%p), slot(%i)", (RsContext)con, (void *)script, slot);
+ RsScriptCall sc;
+ sc.xStart = xstart;
+ sc.xEnd = xend;
+ sc.yStart = ystart;
+ sc.yEnd = yend;
+ sc.zStart = zstart;
+ sc.zEnd = zend;
+ sc.strategy = RS_FOR_EACH_STRATEGY_DONT_CARE;
+ sc.arrayStart = 0;
+ sc.arrayEnd = 0;
+ rsScriptForEach((RsContext)con, (RsScript)script, slot, (RsAllocation)ain, (RsAllocation)aout, NULL, 0, &sc, sizeof(sc));
+}
+
+static void
+nScriptForEachClippedV(JNIEnv *_env, jobject _this, jlong con,
+ jlong script, jint slot, jlong ain, jlong aout,
+ jbyteArray params, jint xstart, jint xend,
+ jint ystart, jint yend, jint zstart, jint zend)
+{
+ LOG_API("nScriptForEachClipped, con(%p), s(%p), slot(%i)", (RsContext)con, (void *)script, slot);
+ jint len = _env->GetArrayLength(params);
+ jbyte *ptr = _env->GetByteArrayElements(params, NULL);
+ RsScriptCall sc;
+ sc.xStart = xstart;
+ sc.xEnd = xend;
+ sc.yStart = ystart;
+ sc.yEnd = yend;
+ sc.zStart = zstart;
+ sc.zEnd = zend;
+ sc.strategy = RS_FOR_EACH_STRATEGY_DONT_CARE;
+ sc.arrayStart = 0;
+ sc.arrayEnd = 0;
+ rsScriptForEach((RsContext)con, (RsScript)script, slot, (RsAllocation)ain, (RsAllocation)aout, ptr, len, &sc, sizeof(sc));
+ _env->ReleaseByteArrayElements(params, ptr, JNI_ABORT);
+}
+
+// -----------------------------------
+
+static jlong
+nScriptCCreate(JNIEnv *_env, jobject _this, jlong con,
+ jstring resName, jstring cacheDir,
+ jbyteArray scriptRef, jint length)
+{
+ LOG_API("nScriptCCreate, con(%p)", (RsContext)con);
+
+ AutoJavaStringToUTF8 resNameUTF(_env, resName);
+ AutoJavaStringToUTF8 cacheDirUTF(_env, cacheDir);
+ jlong ret = 0;
+ jbyte* script_ptr = NULL;
+ jint _exception = 0;
+ jint remaining;
+ if (!scriptRef) {
+ _exception = 1;
+ //jniThrowException(_env, "java/lang/IllegalArgumentException", "script == null");
+ goto exit;
+ }
+ if (length < 0) {
+ _exception = 1;
+ //jniThrowException(_env, "java/lang/IllegalArgumentException", "length < 0");
+ goto exit;
+ }
+ remaining = _env->GetArrayLength(scriptRef);
+ if (remaining < length) {
+ _exception = 1;
+ //jniThrowException(_env, "java/lang/IllegalArgumentException",
+ // "length > script.length - offset");
+ goto exit;
+ }
+ script_ptr = (jbyte *)
+ _env->GetPrimitiveArrayCritical(scriptRef, (jboolean *)0);
+
+ //rsScriptCSetText((RsContext)con, (const char *)script_ptr, length);
+
+ ret = (jlong)rsScriptCCreate((RsContext)con,
+ resNameUTF.c_str(), resNameUTF.length(),
+ cacheDirUTF.c_str(), cacheDirUTF.length(),
+ (const char *)script_ptr, length);
+
+exit:
+ if (script_ptr) {
+ _env->ReleasePrimitiveArrayCritical(scriptRef, script_ptr,
+ _exception ? JNI_ABORT: 0);
+ }
+
+ return (jlong)ret;
+}
+
+static jlong
+nScriptIntrinsicCreate(JNIEnv *_env, jobject _this, jlong con, jint id, jlong eid)
+{
+ LOG_API("nScriptIntrinsicCreate, con(%p) id(%i) element(%p)", (RsContext)con, id, (void *)eid);
+ return (jlong)rsScriptIntrinsicCreate((RsContext)con, id, (RsElement)eid);
+}
+
+static jlong
+nScriptKernelIDCreate(JNIEnv *_env, jobject _this, jlong con, jlong sid, jint slot, jint sig)
+{
+ LOG_API("nScriptKernelIDCreate, con(%p) script(%p), slot(%i), sig(%i)", (RsContext)con, (void *)sid, slot, sig);
+ return (jlong)rsScriptKernelIDCreate((RsContext)con, (RsScript)sid, slot, sig);
+}
+
+static jlong
+nScriptFieldIDCreate(JNIEnv *_env, jobject _this, jlong con, jlong sid, jint slot)
+{
+ LOG_API("nScriptFieldIDCreate, con(%p) script(%p), slot(%i)", (RsContext)con, (void *)sid, slot);
+ return (jlong)rsScriptFieldIDCreate((RsContext)con, (RsScript)sid, slot);
+}
+
+static jlong
+nScriptGroupCreate(JNIEnv *_env, jobject _this, jlong con, jlongArray _kernels, jlongArray _src,
+ jlongArray _dstk, jlongArray _dstf, jlongArray _types)
+{
+ LOG_API("nScriptGroupCreate, con(%p)", (RsContext)con);
+
+ jint kernelsLen = _env->GetArrayLength(_kernels);
+ jlong *jKernelsPtr = _env->GetLongArrayElements(_kernels, NULL);
+ RsScriptKernelID* kernelsPtr = (RsScriptKernelID*) malloc(sizeof(RsScriptKernelID) * kernelsLen);
+ for(int i = 0; i < kernelsLen; ++i) {
+ kernelsPtr[i] = (RsScriptKernelID)jKernelsPtr[i];
+ }
+
+ jint srcLen = _env->GetArrayLength(_src);
+ jlong *jSrcPtr = _env->GetLongArrayElements(_src, NULL);
+ RsScriptKernelID* srcPtr = (RsScriptKernelID*) malloc(sizeof(RsScriptKernelID) * srcLen);
+ for(int i = 0; i < srcLen; ++i) {
+ srcPtr[i] = (RsScriptKernelID)jSrcPtr[i];
+ }
+
+ jint dstkLen = _env->GetArrayLength(_dstk);
+ jlong *jDstkPtr = _env->GetLongArrayElements(_dstk, NULL);
+ RsScriptKernelID* dstkPtr = (RsScriptKernelID*) malloc(sizeof(RsScriptKernelID) * dstkLen);
+ for(int i = 0; i < dstkLen; ++i) {
+ dstkPtr[i] = (RsScriptKernelID)jDstkPtr[i];
+ }
+
+ jint dstfLen = _env->GetArrayLength(_dstf);
+ jlong *jDstfPtr = _env->GetLongArrayElements(_dstf, NULL);
+ RsScriptKernelID* dstfPtr = (RsScriptKernelID*) malloc(sizeof(RsScriptKernelID) * dstfLen);
+ for(int i = 0; i < dstfLen; ++i) {
+ dstfPtr[i] = (RsScriptKernelID)jDstfPtr[i];
+ }
+
+ jint typesLen = _env->GetArrayLength(_types);
+ jlong *jTypesPtr = _env->GetLongArrayElements(_types, NULL);
+ RsType* typesPtr = (RsType*) malloc(sizeof(RsType) * typesLen);
+ for(int i = 0; i < typesLen; ++i) {
+ typesPtr[i] = (RsType)jTypesPtr[i];
+ }
+
+ jlong id = (jlong)rsScriptGroupCreate((RsContext)con,
+ (RsScriptKernelID *)kernelsPtr, kernelsLen * sizeof(RsScriptKernelID),
+ (RsScriptKernelID *)srcPtr, srcLen * sizeof(RsScriptKernelID),
+ (RsScriptKernelID *)dstkPtr, dstkLen * sizeof(RsScriptKernelID),
+ (RsScriptFieldID *)dstfPtr, dstfLen * sizeof(RsScriptKernelID),
+ (RsType *)typesPtr, typesLen * sizeof(RsType));
+
+ free(kernelsPtr);
+ free(srcPtr);
+ free(dstkPtr);
+ free(dstfPtr);
+ free(typesPtr);
+ _env->ReleaseLongArrayElements(_kernels, jKernelsPtr, 0);
+ _env->ReleaseLongArrayElements(_src, jSrcPtr, 0);
+ _env->ReleaseLongArrayElements(_dstk, jDstkPtr, 0);
+ _env->ReleaseLongArrayElements(_dstf, jDstfPtr, 0);
+ _env->ReleaseLongArrayElements(_types, jTypesPtr, 0);
+ return id;
+}
+
+static void
+nScriptGroupSetInput(JNIEnv *_env, jobject _this, jlong con, jlong gid, jlong kid, jlong alloc)
+{
+ LOG_API("nScriptGroupSetInput, con(%p) group(%p), kernelId(%p), alloc(%p)", (RsContext)con,
+ (void *)gid, (void *)kid, (void *)alloc);
+ rsScriptGroupSetInput((RsContext)con, (RsScriptGroup)gid, (RsScriptKernelID)kid, (RsAllocation)alloc);
+}
+
+static void
+nScriptGroupSetOutput(JNIEnv *_env, jobject _this, jlong con, jlong gid, jlong kid, jlong alloc)
+{
+ LOG_API("nScriptGroupSetOutput, con(%p) group(%p), kernelId(%p), alloc(%p)", (RsContext)con,
+ (void *)gid, (void *)kid, (void *)alloc);
+ rsScriptGroupSetOutput((RsContext)con, (RsScriptGroup)gid, (RsScriptKernelID)kid, (RsAllocation)alloc);
+}
+
+static void
+nScriptGroupExecute(JNIEnv *_env, jobject _this, jlong con, jlong gid)
+{
+ LOG_API("nScriptGroupSetOutput, con(%p) group(%p)", (RsContext)con, (void *)gid);
+ rsScriptGroupExecute((RsContext)con, (RsScriptGroup)gid);
+}
+
+// ---------------------------------------------------------------------------
+
+static jlong
+nProgramStoreCreate(JNIEnv *_env, jobject _this, jlong con,
+ jboolean colorMaskR, jboolean colorMaskG, jboolean colorMaskB, jboolean colorMaskA,
+ jboolean depthMask, jboolean ditherEnable,
+ jint srcFunc, jint destFunc,
+ jint depthFunc)
+{
+ LOG_API("nProgramStoreCreate, con(%p)", (RsContext)con);
+ return (jlong)rsProgramStoreCreate((RsContext)con, colorMaskR, colorMaskG, colorMaskB, colorMaskA,
+ depthMask, ditherEnable, (RsBlendSrcFunc)srcFunc,
+ (RsBlendDstFunc)destFunc, (RsDepthFunc)depthFunc);
+}
+
+// ---------------------------------------------------------------------------
+
+static void
+nProgramBindConstants(JNIEnv *_env, jobject _this, jlong con, jlong vpv, jint slot, jlong a)
+{
+ LOG_API("nProgramBindConstants, con(%p), vpf(%p), sloat(%i), a(%p)", (RsContext)con, (RsProgramVertex)vpv, slot, (RsAllocation)a);
+ rsProgramBindConstants((RsContext)con, (RsProgram)vpv, slot, (RsAllocation)a);
+}
+
+static void
+nProgramBindTexture(JNIEnv *_env, jobject _this, jlong con, jlong vpf, jint slot, jlong a)
+{
+ LOG_API("nProgramBindTexture, con(%p), vpf(%p), slot(%i), a(%p)", (RsContext)con, (RsProgramFragment)vpf, slot, (RsAllocation)a);
+ rsProgramBindTexture((RsContext)con, (RsProgramFragment)vpf, slot, (RsAllocation)a);
+}
+
+static void
+nProgramBindSampler(JNIEnv *_env, jobject _this, jlong con, jlong vpf, jint slot, jlong a)
+{
+ LOG_API("nProgramBindSampler, con(%p), vpf(%p), slot(%i), a(%p)", (RsContext)con, (RsProgramFragment)vpf, slot, (RsSampler)a);
+ rsProgramBindSampler((RsContext)con, (RsProgramFragment)vpf, slot, (RsSampler)a);
+}
+
+// ---------------------------------------------------------------------------
+
+static jlong
+nProgramFragmentCreate(JNIEnv *_env, jobject _this, jlong con, jstring shader,
+ jobjectArray texNames, jlongArray params)
+{
+ AutoJavaStringToUTF8 shaderUTF(_env, shader);
+ jlong *jParamPtr = _env->GetLongArrayElements(params, NULL);
+ jint paramLen = _env->GetArrayLength(params);
+
+ int texCount = _env->GetArrayLength(texNames);
+ AutoJavaStringArrayToUTF8 names(_env, texNames, texCount);
+ const char ** nameArray = names.c_str();
+ size_t* sizeArray = names.c_str_len();
+
+ LOG_API("nProgramFragmentCreate, con(%p), paramLen(%i)", (RsContext)con, paramLen);
+
+ uintptr_t * paramPtr = (uintptr_t*) malloc(sizeof(uintptr_t) * paramLen);
+ for(int i = 0; i < paramLen; ++i) {
+ paramPtr[i] = (uintptr_t)jParamPtr[i];
+ }
+ jlong ret = (jlong)rsProgramFragmentCreate((RsContext)con, shaderUTF.c_str(), shaderUTF.length(),
+ nameArray, texCount, sizeArray,
+ paramPtr, paramLen);
+
+ free(paramPtr);
+ _env->ReleaseLongArrayElements(params, jParamPtr, JNI_ABORT);
+ return ret;
+}
+
+
+// ---------------------------------------------------------------------------
+
+static jlong
+nProgramVertexCreate(JNIEnv *_env, jobject _this, jlong con, jstring shader,
+ jobjectArray texNames, jlongArray params)
+{
+ AutoJavaStringToUTF8 shaderUTF(_env, shader);
+ jlong *jParamPtr = _env->GetLongArrayElements(params, NULL);
+ jint paramLen = _env->GetArrayLength(params);
+
+ LOG_API("nProgramVertexCreate, con(%p), paramLen(%i)", (RsContext)con, paramLen);
+
+ int texCount = _env->GetArrayLength(texNames);
+ AutoJavaStringArrayToUTF8 names(_env, texNames, texCount);
+ const char ** nameArray = names.c_str();
+ size_t* sizeArray = names.c_str_len();
+
+ uintptr_t * paramPtr = (uintptr_t*) malloc(sizeof(uintptr_t) * paramLen);
+ for(int i = 0; i < paramLen; ++i) {
+ paramPtr[i] = (uintptr_t)jParamPtr[i];
+ }
+
+ jlong ret = (jlong)rsProgramVertexCreate((RsContext)con, shaderUTF.c_str(), shaderUTF.length(),
+ nameArray, texCount, sizeArray,
+ paramPtr, paramLen);
+
+ free(paramPtr);
+ _env->ReleaseLongArrayElements(params, jParamPtr, JNI_ABORT);
+ return ret;
+}
+
+// ---------------------------------------------------------------------------
+
+static jlong
+nProgramRasterCreate(JNIEnv *_env, jobject _this, jlong con, jboolean pointSprite, jint cull)
+{
+ LOG_API("nProgramRasterCreate, con(%p), pointSprite(%i), cull(%i)", (RsContext)con, pointSprite, cull);
+ return (jlong)rsProgramRasterCreate((RsContext)con, pointSprite, (RsCullMode)cull);
+}
+
+
+// ---------------------------------------------------------------------------
+
+static void
+nContextBindRootScript(JNIEnv *_env, jobject _this, jlong con, jlong script)
+{
+ LOG_API("nContextBindRootScript, con(%p), script(%p)", (RsContext)con, (RsScript)script);
+ rsContextBindRootScript((RsContext)con, (RsScript)script);
+}
+
+static void
+nContextBindProgramStore(JNIEnv *_env, jobject _this, jlong con, jlong pfs)
+{
+ LOG_API("nContextBindProgramStore, con(%p), pfs(%p)", (RsContext)con, (RsProgramStore)pfs);
+ rsContextBindProgramStore((RsContext)con, (RsProgramStore)pfs);
+}
+
+static void
+nContextBindProgramFragment(JNIEnv *_env, jobject _this, jlong con, jlong pf)
+{
+ LOG_API("nContextBindProgramFragment, con(%p), pf(%p)", (RsContext)con, (RsProgramFragment)pf);
+ rsContextBindProgramFragment((RsContext)con, (RsProgramFragment)pf);
+}
+
+static void
+nContextBindProgramVertex(JNIEnv *_env, jobject _this, jlong con, jlong pf)
+{
+ LOG_API("nContextBindProgramVertex, con(%p), pf(%p)", (RsContext)con, (RsProgramVertex)pf);
+ rsContextBindProgramVertex((RsContext)con, (RsProgramVertex)pf);
+}
+
+static void
+nContextBindProgramRaster(JNIEnv *_env, jobject _this, jlong con, jlong pf)
+{
+ LOG_API("nContextBindProgramRaster, con(%p), pf(%p)", (RsContext)con, (RsProgramRaster)pf);
+ rsContextBindProgramRaster((RsContext)con, (RsProgramRaster)pf);
+}
+
+
+// ---------------------------------------------------------------------------
+
+static jlong
+nSamplerCreate(JNIEnv *_env, jobject _this, jlong con, jint magFilter, jint minFilter,
+ jint wrapS, jint wrapT, jint wrapR, jfloat aniso)
+{
+ LOG_API("nSamplerCreate, con(%p)", (RsContext)con);
+ return (jlong)rsSamplerCreate((RsContext)con,
+ (RsSamplerValue)magFilter,
+ (RsSamplerValue)minFilter,
+ (RsSamplerValue)wrapS,
+ (RsSamplerValue)wrapT,
+ (RsSamplerValue)wrapR,
+ aniso);
+}
+
+// ---------------------------------------------------------------------------
+
+static jlong
+nPathCreate(JNIEnv *_env, jobject _this, jlong con, jint prim, jboolean isStatic, jlong _vtx, jlong _loop, jfloat q) {
+ LOG_API("nPathCreate, con(%p)", (RsContext)con);
+
+ jlong id = (jlong)rsPathCreate((RsContext)con, (RsPathPrimitive)prim, isStatic,
+ (RsAllocation)_vtx,
+ (RsAllocation)_loop, q);
+ return id;
+}
+
+static jlong
+nMeshCreate(JNIEnv *_env, jobject _this, jlong con, jlongArray _vtx, jlongArray _idx, jintArray _prim)
+{
+ LOG_API("nMeshCreate, con(%p)", (RsContext)con);
+
+ jint vtxLen = _env->GetArrayLength(_vtx);
+ jlong *jVtxPtr = _env->GetLongArrayElements(_vtx, NULL);
+ RsAllocation* vtxPtr = (RsAllocation*) malloc(sizeof(RsAllocation) * vtxLen);
+ for(int i = 0; i < vtxLen; ++i) {
+ vtxPtr[i] = (RsAllocation)(uintptr_t)jVtxPtr[i];
+ }
+
+ jint idxLen = _env->GetArrayLength(_idx);
+ jlong *jIdxPtr = _env->GetLongArrayElements(_idx, NULL);
+ RsAllocation* idxPtr = (RsAllocation*) malloc(sizeof(RsAllocation) * idxLen);
+ for(int i = 0; i < idxLen; ++i) {
+ idxPtr[i] = (RsAllocation)(uintptr_t)jIdxPtr[i];
+ }
+
+ jint primLen = _env->GetArrayLength(_prim);
+ jint *primPtr = _env->GetIntArrayElements(_prim, NULL);
+
+ jlong id = (jlong)rsMeshCreate((RsContext)con,
+ (RsAllocation *)vtxPtr, vtxLen,
+ (RsAllocation *)idxPtr, idxLen,
+ (uint32_t *)primPtr, primLen);
+
+ free(vtxPtr);
+ free(idxPtr);
+ _env->ReleaseLongArrayElements(_vtx, jVtxPtr, 0);
+ _env->ReleaseLongArrayElements(_idx, jIdxPtr, 0);
+ _env->ReleaseIntArrayElements(_prim, primPtr, 0);
+ return id;
+}
+
+static jint
+nMeshGetVertexBufferCount(JNIEnv *_env, jobject _this, jlong con, jlong mesh)
+{
+ LOG_API("nMeshGetVertexBufferCount, con(%p), Mesh(%p)", (RsContext)con, (RsMesh)mesh);
+ jint vtxCount = 0;
+ rsaMeshGetVertexBufferCount((RsContext)con, (RsMesh)mesh, &vtxCount);
+ return vtxCount;
+}
+
+static jint
+nMeshGetIndexCount(JNIEnv *_env, jobject _this, jlong con, jlong mesh)
+{
+ LOG_API("nMeshGetIndexCount, con(%p), Mesh(%p)", (RsContext)con, (RsMesh)mesh);
+ jint idxCount = 0;
+ rsaMeshGetIndexCount((RsContext)con, (RsMesh)mesh, &idxCount);
+ return idxCount;
+}
+
+static void
+nMeshGetVertices(JNIEnv *_env, jobject _this, jlong con, jlong mesh, jlongArray _ids, jint numVtxIDs)
+{
+ LOG_API("nMeshGetVertices, con(%p), Mesh(%p)", (RsContext)con, (RsMesh)mesh);
+
+ RsAllocation *allocs = (RsAllocation*)malloc((uint32_t)numVtxIDs * sizeof(RsAllocation));
+ rsaMeshGetVertices((RsContext)con, (RsMesh)mesh, allocs, (uint32_t)numVtxIDs);
+
+ for(jint i = 0; i < numVtxIDs; i ++) {
+ const jlong alloc = (jlong)allocs[i];
+ _env->SetLongArrayRegion(_ids, i, 1, &alloc);
+ }
+
+ free(allocs);
+}
+
+static void
+nMeshGetIndices(JNIEnv *_env, jobject _this, jlong con, jlong mesh, jlongArray _idxIds, jintArray _primitives, jint numIndices)
+{
+ LOG_API("nMeshGetVertices, con(%p), Mesh(%p)", (RsContext)con, (RsMesh)mesh);
+
+ RsAllocation *allocs = (RsAllocation*)malloc((uint32_t)numIndices * sizeof(RsAllocation));
+ uint32_t *prims= (uint32_t*)malloc((uint32_t)numIndices * sizeof(uint32_t));
+
+ rsaMeshGetIndices((RsContext)con, (RsMesh)mesh, allocs, prims, (uint32_t)numIndices);
+
+ for(jint i = 0; i < numIndices; i ++) {
+ const jlong alloc = (jlong)allocs[i];
+ const jint prim = (jint)prims[i];
+ _env->SetLongArrayRegion(_idxIds, i, 1, &alloc);
+ _env->SetIntArrayRegion(_primitives, i, 1, &prim);
+ }
+
+ free(allocs);
+ free(prims);
+}
+
+// ---------------------------------------------------------------------------
+
+
+static const char *classPathName = "android/renderscript/RenderScript";
+
+static JNINativeMethod methods[] = {
+{"_nInit", "()V", (void*)_nInit },
+
+{"nDeviceCreate", "()J", (void*)nDeviceCreate },
+{"nDeviceDestroy", "(J)V", (void*)nDeviceDestroy },
+{"nDeviceSetConfig", "(JII)V", (void*)nDeviceSetConfig },
+{"nContextGetUserMessage", "(J[I)I", (void*)nContextGetUserMessage },
+{"nContextGetErrorMessage", "(J)Ljava/lang/String;", (void*)nContextGetErrorMessage },
+{"nContextPeekMessage", "(J[I)I", (void*)nContextPeekMessage },
+
+{"nContextInitToClient", "(J)V", (void*)nContextInitToClient },
+{"nContextDeinitToClient", "(J)V", (void*)nContextDeinitToClient },
+
+
+// All methods below are thread protected in java.
+{"rsnContextCreate", "(JIII)J", (void*)nContextCreate },
+{"rsnContextCreateGL", "(JIIIIIIIIIIIIFI)J", (void*)nContextCreateGL },
+{"rsnContextFinish", "(J)V", (void*)nContextFinish },
+{"rsnContextSetPriority", "(JI)V", (void*)nContextSetPriority },
+{"rsnContextSetSurface", "(JIILandroid/view/Surface;)V", (void*)nContextSetSurface },
+{"rsnContextDestroy", "(J)V", (void*)nContextDestroy },
+{"rsnContextDump", "(JI)V", (void*)nContextDump },
+{"rsnContextPause", "(J)V", (void*)nContextPause },
+{"rsnContextResume", "(J)V", (void*)nContextResume },
+{"rsnContextSendMessage", "(JI[I)V", (void*)nContextSendMessage },
+{"rsnAssignName", "(JJ[B)V", (void*)nAssignName },
+{"rsnGetName", "(JJ)Ljava/lang/String;", (void*)nGetName },
+{"rsnObjDestroy", "(JJ)V", (void*)nObjDestroy },
+
+{"rsnFileA3DCreateFromFile", "(JLjava/lang/String;)J", (void*)nFileA3DCreateFromFile },
+{"rsnFileA3DCreateFromAssetStream", "(JJ)J", (void*)nFileA3DCreateFromAssetStream },
+{"rsnFileA3DCreateFromAsset", "(JLandroid/content/res/AssetManager;Ljava/lang/String;)J", (void*)nFileA3DCreateFromAsset },
+{"rsnFileA3DGetNumIndexEntries", "(JJ)I", (void*)nFileA3DGetNumIndexEntries },
+{"rsnFileA3DGetIndexEntries", "(JJI[I[Ljava/lang/String;)V", (void*)nFileA3DGetIndexEntries },
+{"rsnFileA3DGetEntryByIndex", "(JJI)J", (void*)nFileA3DGetEntryByIndex },
+
+{"rsnFontCreateFromFile", "(JLjava/lang/String;FI)J", (void*)nFontCreateFromFile },
+{"rsnFontCreateFromAssetStream", "(JLjava/lang/String;FIJ)J", (void*)nFontCreateFromAssetStream },
+{"rsnFontCreateFromAsset", "(JLandroid/content/res/AssetManager;Ljava/lang/String;FI)J", (void*)nFontCreateFromAsset },
+
+{"rsnElementCreate", "(JJIZI)J", (void*)nElementCreate },
+{"rsnElementCreate2", "(J[J[Ljava/lang/String;[I)J", (void*)nElementCreate2 },
+{"rsnElementGetNativeData", "(JJ[I)V", (void*)nElementGetNativeData },
+{"rsnElementGetSubElements", "(JJ[J[Ljava/lang/String;[I)V", (void*)nElementGetSubElements },
+
+{"rsnTypeCreate", "(JJIIIZZI)J", (void*)nTypeCreate },
+{"rsnTypeGetNativeData", "(JJ[J)V", (void*)nTypeGetNativeData },
+
+{"rsnAllocationCreateTyped", "(JJIIJ)J", (void*)nAllocationCreateTyped },
+{"rsnAllocationCreateFromBitmap", "(JJILandroid/graphics/Bitmap;I)J", (void*)nAllocationCreateFromBitmap },
+{"rsnAllocationCreateBitmapBackedAllocation", "(JJILandroid/graphics/Bitmap;I)J", (void*)nAllocationCreateBitmapBackedAllocation },
+{"rsnAllocationCubeCreateFromBitmap","(JJILandroid/graphics/Bitmap;I)J", (void*)nAllocationCubeCreateFromBitmap },
+
+{"rsnAllocationCopyFromBitmap", "(JJLandroid/graphics/Bitmap;)V", (void*)nAllocationCopyFromBitmap },
+{"rsnAllocationCopyToBitmap", "(JJLandroid/graphics/Bitmap;)V", (void*)nAllocationCopyToBitmap },
+
+{"rsnAllocationSyncAll", "(JJI)V", (void*)nAllocationSyncAll },
+{"rsnAllocationGetSurface", "(JJ)Landroid/view/Surface;", (void*)nAllocationGetSurface },
+{"rsnAllocationSetSurface", "(JJLandroid/view/Surface;)V", (void*)nAllocationSetSurface },
+{"rsnAllocationIoSend", "(JJ)V", (void*)nAllocationIoSend },
+{"rsnAllocationIoReceive", "(JJ)V", (void*)nAllocationIoReceive },
+{"rsnAllocationData1D", "(JJIIILjava/lang/Object;II)V", (void*)nAllocationData1D },
+{"rsnAllocationElementData1D", "(JJIII[BI)V", (void*)nAllocationElementData1D },
+{"rsnAllocationData2D", "(JJIIIIIILjava/lang/Object;II)V", (void*)nAllocationData2D },
+{"rsnAllocationData2D", "(JJIIIIIIJIIII)V", (void*)nAllocationData2D_alloc },
+{"rsnAllocationData3D", "(JJIIIIIIILjava/lang/Object;II)V", (void*)nAllocationData3D },
+{"rsnAllocationData3D", "(JJIIIIIIIJIIII)V", (void*)nAllocationData3D_alloc },
+{"rsnAllocationRead", "(JJLjava/lang/Object;I)V", (void*)nAllocationRead },
+{"rsnAllocationRead1D", "(JJIIILjava/lang/Object;II)V", (void*)nAllocationRead1D },
+{"rsnAllocationRead2D", "(JJIIIIIILjava/lang/Object;II)V", (void*)nAllocationRead2D },
+{"rsnAllocationGetType", "(JJ)J", (void*)nAllocationGetType},
+{"rsnAllocationResize1D", "(JJI)V", (void*)nAllocationResize1D },
+{"rsnAllocationGenerateMipmaps", "(JJ)V", (void*)nAllocationGenerateMipmaps },
+
+{"rsnScriptBindAllocation", "(JJJI)V", (void*)nScriptBindAllocation },
+{"rsnScriptSetTimeZone", "(JJ[B)V", (void*)nScriptSetTimeZone },
+{"rsnScriptInvoke", "(JJI)V", (void*)nScriptInvoke },
+{"rsnScriptInvokeV", "(JJI[B)V", (void*)nScriptInvokeV },
+{"rsnScriptForEach", "(JJIJJ)V", (void*)nScriptForEach },
+{"rsnScriptForEach", "(JJIJJ[B)V", (void*)nScriptForEachV },
+{"rsnScriptForEachClipped", "(JJIJJIIIIII)V", (void*)nScriptForEachClipped },
+{"rsnScriptForEachClipped", "(JJIJJ[BIIIIII)V", (void*)nScriptForEachClippedV },
+{"rsnScriptSetVarI", "(JJII)V", (void*)nScriptSetVarI },
+{"rsnScriptGetVarI", "(JJI)I", (void*)nScriptGetVarI },
+{"rsnScriptSetVarJ", "(JJIJ)V", (void*)nScriptSetVarJ },
+{"rsnScriptGetVarJ", "(JJI)J", (void*)nScriptGetVarJ },
+{"rsnScriptSetVarF", "(JJIF)V", (void*)nScriptSetVarF },
+{"rsnScriptGetVarF", "(JJI)F", (void*)nScriptGetVarF },
+{"rsnScriptSetVarD", "(JJID)V", (void*)nScriptSetVarD },
+{"rsnScriptGetVarD", "(JJI)D", (void*)nScriptGetVarD },
+{"rsnScriptSetVarV", "(JJI[B)V", (void*)nScriptSetVarV },
+{"rsnScriptGetVarV", "(JJI[B)V", (void*)nScriptGetVarV },
+{"rsnScriptSetVarVE", "(JJI[BJ[I)V", (void*)nScriptSetVarVE },
+{"rsnScriptSetVarObj", "(JJIJ)V", (void*)nScriptSetVarObj },
+
+{"rsnScriptCCreate", "(JLjava/lang/String;Ljava/lang/String;[BI)J", (void*)nScriptCCreate },
+{"rsnScriptIntrinsicCreate", "(JIJ)J", (void*)nScriptIntrinsicCreate },
+{"rsnScriptKernelIDCreate", "(JJII)J", (void*)nScriptKernelIDCreate },
+{"rsnScriptFieldIDCreate", "(JJI)J", (void*)nScriptFieldIDCreate },
+{"rsnScriptGroupCreate", "(J[J[J[J[J[J)J", (void*)nScriptGroupCreate },
+{"rsnScriptGroupSetInput", "(JJJJ)V", (void*)nScriptGroupSetInput },
+{"rsnScriptGroupSetOutput", "(JJJJ)V", (void*)nScriptGroupSetOutput },
+{"rsnScriptGroupExecute", "(JJ)V", (void*)nScriptGroupExecute },
+
+{"rsnProgramStoreCreate", "(JZZZZZZIII)J", (void*)nProgramStoreCreate },
+
+{"rsnProgramBindConstants", "(JJIJ)V", (void*)nProgramBindConstants },
+{"rsnProgramBindTexture", "(JJIJ)V", (void*)nProgramBindTexture },
+{"rsnProgramBindSampler", "(JJIJ)V", (void*)nProgramBindSampler },
+
+{"rsnProgramFragmentCreate", "(JLjava/lang/String;[Ljava/lang/String;[J)J", (void*)nProgramFragmentCreate },
+{"rsnProgramRasterCreate", "(JZI)J", (void*)nProgramRasterCreate },
+{"rsnProgramVertexCreate", "(JLjava/lang/String;[Ljava/lang/String;[J)J", (void*)nProgramVertexCreate },
+
+{"rsnContextBindRootScript", "(JJ)V", (void*)nContextBindRootScript },
+{"rsnContextBindProgramStore", "(JJ)V", (void*)nContextBindProgramStore },
+{"rsnContextBindProgramFragment", "(JJ)V", (void*)nContextBindProgramFragment },
+{"rsnContextBindProgramVertex", "(JJ)V", (void*)nContextBindProgramVertex },
+{"rsnContextBindProgramRaster", "(JJ)V", (void*)nContextBindProgramRaster },
+
+{"rsnSamplerCreate", "(JIIIIIF)J", (void*)nSamplerCreate },
+
+{"rsnPathCreate", "(JIZJJF)J", (void*)nPathCreate },
+{"rsnMeshCreate", "(J[J[J[I)J", (void*)nMeshCreate },
+
+{"rsnMeshGetVertexBufferCount", "(JJ)I", (void*)nMeshGetVertexBufferCount },
+{"rsnMeshGetIndexCount", "(JJ)I", (void*)nMeshGetIndexCount },
+{"rsnMeshGetVertices", "(JJ[JI)V", (void*)nMeshGetVertices },
+{"rsnMeshGetIndices", "(JJ[J[II)V", (void*)nMeshGetIndices },
+
+};
+
+static int registerFuncs(JNIEnv *_env)
+{
+ return android::AndroidRuntime::registerNativeMethods(
+ _env, classPathName, methods, NELEM(methods));
+}
+
+// ---------------------------------------------------------------------------
+
+jint JNI_OnLoad(JavaVM* vm, void* reserved)
+{
+ JNIEnv* env = NULL;
+ jint result = -1;
+
+ if (vm->GetEnv((void**) &env, JNI_VERSION_1_4) != JNI_OK) {
+ ALOGE("ERROR: GetEnv failed\n");
+ goto bail;
+ }
+ assert(env != NULL);
+
+ if (registerFuncs(env) < 0) {
+ ALOGE("ERROR: Renderscript native registration failed\n");
+ goto bail;
+ }
+
+ /* success -- return valid version number */
+ result = JNI_VERSION_1_4;
+
+bail:
+ return result;
+}
diff --git a/services/common_time/common_time_server.cpp b/services/common_time/common_time_server.cpp
index 21e706f..3e11987 100644
--- a/services/common_time/common_time_server.cpp
+++ b/services/common_time/common_time_server.cpp
@@ -590,7 +590,7 @@
for (i = 0; (i < src_len) && (offset < dst_len); ++i) {
int res;
if (0 == (i % 16)) {
- res = snprintf(dst + offset, dst_len - offset, "\n%04x :", i);
+ res = snprintf(dst + offset, dst_len - offset, "\n%04zx :", i);
if (res < 0)
break;
offset += res;
diff --git a/services/common_time/utils.cpp b/services/common_time/utils.cpp
index ed2c77d..ddcdfe7 100644
--- a/services/common_time/utils.cpp
+++ b/services/common_time/utils.cpp
@@ -56,7 +56,7 @@
, mHeader(header) {
mRingBuffer = new Entry[mSize];
if (NULL == mRingBuffer)
- ALOGE("Failed to allocate log ring with %u entries.", mSize);
+ ALOGE("Failed to allocate log ring with %zu entries.", mSize);
}
LogRing::~LogRing() {
@@ -150,7 +150,7 @@
localtime_r(&mRingBuffer[ndx].first_ts.tv_sec, &t);
strftime(timebuf, sizeof(timebuf), kTimeFmt, &t);
- res = snprintf(buf, sizeof(buf), "[%2d] %s.%03ld :: %s%s\n",
+ res = snprintf(buf, sizeof(buf), "[%2zu] %s.%03ld :: %s%s\n",
i, timebuf,
mRingBuffer[ndx].first_ts.tv_usec / 1000,
mRingBuffer[ndx].s.string(),
diff --git a/services/input/EventHub.cpp b/services/input/EventHub.cpp
index fc64656..e3a3e17 100644
--- a/services/input/EventHub.cpp
+++ b/services/input/EventHub.cpp
@@ -759,7 +759,7 @@
if (readSize == 0 || (readSize < 0 && errno == ENODEV)) {
// Device was removed before INotify noticed.
ALOGW("could not get event, removed? (fd: %d size: %d bufferSize: %d "
- "capacity: %d errno: %d)\n",
+ "capacity: %zu errno: %d)\n",
device->fd, readSize, bufferSize, capacity, errno);
deviceChanged = true;
closeDeviceLocked(device);
diff --git a/services/input/InputDispatcher.cpp b/services/input/InputDispatcher.cpp
index 10a639e..06a57d5 100644
--- a/services/input/InputDispatcher.cpp
+++ b/services/input/InputDispatcher.cpp
@@ -147,7 +147,7 @@
return false;
}
if (pointerCount < 1 || pointerCount > MAX_POINTERS) {
- ALOGE("Motion event has invalid pointer count %d; value must be between 1 and %d.",
+ ALOGE("Motion event has invalid pointer count %zu; value must be between 1 and %d.",
pointerCount, MAX_POINTERS);
return false;
}
@@ -3107,7 +3107,7 @@
dump.append(INDENT "TouchedWindows:\n");
for (size_t i = 0; i < mTouchState.windows.size(); i++) {
const TouchedWindow& touchedWindow = mTouchState.windows[i];
- dump.appendFormat(INDENT2 "%d: name='%s', pointerIds=0x%0x, targetFlags=0x%x\n",
+ dump.appendFormat(INDENT2 "%zu: name='%s', pointerIds=0x%0x, targetFlags=0x%x\n",
i, touchedWindow.windowHandle->getName().string(),
touchedWindow.pointerIds.value,
touchedWindow.targetFlags);
@@ -3122,7 +3122,7 @@
const sp<InputWindowHandle>& windowHandle = mWindowHandles.itemAt(i);
const InputWindowInfo* windowInfo = windowHandle->getInfo();
- dump.appendFormat(INDENT2 "%d: name='%s', displayId=%d, "
+ dump.appendFormat(INDENT2 "%zu: name='%s', displayId=%d, "
"paused=%s, hasFocus=%s, hasWallpaper=%s, "
"visible=%s, canReceiveKeys=%s, flags=0x%08x, type=0x%08x, layer=%d, "
"frame=[%d,%d][%d,%d], scale=%f, "
@@ -3152,7 +3152,7 @@
dump.append(INDENT "MonitoringChannels:\n");
for (size_t i = 0; i < mMonitoringChannels.size(); i++) {
const sp<InputChannel>& channel = mMonitoringChannels[i];
- dump.appendFormat(INDENT2 "%d: '%s'\n", i, channel->getName().string());
+ dump.appendFormat(INDENT2 "%zu: '%s'\n", i, channel->getName().string());
}
} else {
dump.append(INDENT "MonitoringChannels: <none>\n");
@@ -3201,7 +3201,7 @@
dump.append(INDENT "Connections:\n");
for (size_t i = 0; i < mConnectionsByFd.size(); i++) {
const sp<Connection>& connection = mConnectionsByFd.valueAt(i);
- dump.appendFormat(INDENT2 "%d: channelName='%s', windowName='%s', "
+ dump.appendFormat(INDENT2 "%zu: channelName='%s', windowName='%s', "
"status=%s, monitor=%s, inputPublisherBlocked=%s\n",
i, connection->getInputChannelName(), connection->getWindowName(),
connection->getStatusLabel(), toString(connection->monitor),
diff --git a/services/input/InputReader.cpp b/services/input/InputReader.cpp
index 03852a5..d86fa4f 100644
--- a/services/input/InputReader.cpp
+++ b/services/input/InputReader.cpp
@@ -1992,7 +1992,7 @@
dumpParameters(dump);
dump.appendFormat(INDENT3 "KeyboardType: %d\n", mKeyboardType);
dump.appendFormat(INDENT3 "Orientation: %d\n", mOrientation);
- dump.appendFormat(INDENT3 "KeyDowns: %d keys currently down\n", mKeyDowns.size());
+ dump.appendFormat(INDENT3 "KeyDowns: %zu keys currently down\n", mKeyDowns.size());
dump.appendFormat(INDENT3 "MetaState: 0x%0x\n", mMetaState);
dump.appendFormat(INDENT3 "DownTime: %lld\n", mDownTime);
}
@@ -3372,7 +3372,7 @@
for (size_t i = 0; i < mVirtualKeys.size(); i++) {
const VirtualKey& virtualKey = mVirtualKeys.itemAt(i);
- dump.appendFormat(INDENT4 "%d: scanCode=%d, keyCode=%d, "
+ dump.appendFormat(INDENT4 "%zu: scanCode=%d, keyCode=%d, "
"hitLeft=%d, hitRight=%d, hitTop=%d, hitBottom=%d\n",
i, virtualKey.scanCode, virtualKey.keyCode,
virtualKey.hitLeft, virtualKey.hitRight,
@@ -6119,8 +6119,8 @@
&& mRawPointerAxes.slot.minValue == 0 && mRawPointerAxes.slot.maxValue > 0) {
size_t slotCount = mRawPointerAxes.slot.maxValue + 1;
if (slotCount > MAX_SLOTS) {
- ALOGW("MultiTouch Device %s reported %d slots but the framework "
- "only supports a maximum of %d slots at this time.",
+ ALOGW("MultiTouch Device %s reported %zu slots but the framework "
+ "only supports a maximum of %zu slots at this time.",
getDeviceName().string(), slotCount, MAX_SLOTS);
slotCount = MAX_SLOTS;
}
@@ -6292,7 +6292,7 @@
// If there are too many axes, start dropping them.
// Prefer to keep explicitly mapped axes.
if (mAxes.size() > PointerCoords::MAX_AXES) {
- ALOGI("Joystick '%s' has %d axes but the framework only supports a maximum of %d.",
+ ALOGI("Joystick '%s' has %zu axes but the framework only supports a maximum of %d.",
getDeviceName().string(), mAxes.size(), PointerCoords::MAX_AXES);
pruneAxes(true);
pruneAxes(false);
diff --git a/services/java/com/android/server/AlarmManagerService.java b/services/java/com/android/server/AlarmManagerService.java
index 2e1b0af..defc6ef 100644
--- a/services/java/com/android/server/AlarmManagerService.java
+++ b/services/java/com/android/server/AlarmManagerService.java
@@ -669,12 +669,19 @@
}
}
- public void setTime(long millis) {
+ public boolean setTime(long millis) {
mContext.enforceCallingOrSelfPermission(
"android.permission.SET_TIME",
"setTime");
- SystemClock.setCurrentTimeMillis(millis);
+ if (mNativeData == 0) {
+ Slog.w(TAG, "Not setting time since no alarm driver is available.");
+ return false;
+ }
+
+ synchronized (mLock) {
+ return setKernelTime(mNativeData, millis) == 0;
+ }
}
public void setTimeZone(String tz) {
@@ -1018,6 +1025,7 @@
private native void close(long nativeData);
private native void set(long nativeData, int type, long seconds, long nanoseconds);
private native int waitForAlarm(long nativeData);
+ private native int setKernelTime(long nativeData, long millis);
private native int setKernelTimezone(long nativeData, int minuteswest);
private void triggerAlarmsLocked(ArrayList<Alarm> triggerList, long nowELAPSED, long nowRTC) {
diff --git a/services/java/com/android/server/AssetAtlasService.java b/services/java/com/android/server/AssetAtlasService.java
index 26b4652..fc4838c 100644
--- a/services/java/com/android/server/AssetAtlasService.java
+++ b/services/java/com/android/server/AssetAtlasService.java
@@ -114,12 +114,11 @@
// Describes how bitmaps are placed in the atlas. Each bitmap is
// represented by several entries in the array:
- // int0: SkBitmap*, the native bitmap object
- // int1: x position
- // int2: y position
- // int3: rotated, 1 if the bitmap must be rotated, 0 otherwise
- // NOTE: This will need to be handled differently to support 64 bit pointers
- private int[] mAtlasMap;
+ // long0: SkBitmap*, the native bitmap object
+ // long1: x position
+ // long2: y position
+ // long3: rotated, 1 if the bitmap must be rotated, 0 otherwise
+ private long[] mAtlasMap;
/**
* Creates a new service. Upon creating, the service will gather the list of
@@ -196,7 +195,7 @@
private final ArrayList<Bitmap> mBitmaps;
private final int mPixelCount;
- private int mNativeBitmap;
+ private long mNativeBitmap;
// Used for debugging only
private Bitmap mAtlasBitmap;
@@ -260,8 +259,8 @@
final Atlas.Entry entry = new Atlas.Entry();
- mAtlasMap = new int[packCount * ATLAS_MAP_ENTRY_FIELD_COUNT];
- int[] atlasMap = mAtlasMap;
+ mAtlasMap = new long[packCount * ATLAS_MAP_ENTRY_FIELD_COUNT];
+ long[] atlasMap = mAtlasMap;
int mapIndex = 0;
boolean result = false;
@@ -288,7 +287,6 @@
}
canvas.drawBitmap(bitmap, 0.0f, 0.0f, null);
canvas.restore();
-
atlasMap[mapIndex++] = bitmap.mNativeBitmap;
atlasMap[mapIndex++] = entry.x;
atlasMap[mapIndex++] = entry.y;
@@ -365,9 +363,9 @@
}
}
- private static native int nAcquireAtlasCanvas(Canvas canvas, int width, int height);
- private static native void nReleaseAtlasCanvas(Canvas canvas, int bitmap);
- private static native boolean nUploadAtlas(GraphicBuffer buffer, int bitmap);
+ private static native long nAcquireAtlasCanvas(Canvas canvas, int width, int height);
+ private static native void nReleaseAtlasCanvas(Canvas canvas, long bitmap);
+ private static native boolean nUploadAtlas(GraphicBuffer buffer, long bitmap);
@Override
public boolean isCompatible(int ppid) {
@@ -380,7 +378,7 @@
}
@Override
- public int[] getMap() throws RemoteException {
+ public long[] getMap() throws RemoteException {
return mAtlasReady.get() ? mAtlasMap : null;
}
diff --git a/services/java/com/android/server/ConsumerIrService.java b/services/java/com/android/server/ConsumerIrService.java
index 783dff1..583f1bc 100644
--- a/services/java/com/android/server/ConsumerIrService.java
+++ b/services/java/com/android/server/ConsumerIrService.java
@@ -49,13 +49,13 @@
private static final int MAX_XMIT_TIME = 2000000; /* in microseconds */
- private static native int halOpen();
- private static native int halTransmit(int halObject, int carrierFrequency, int[] pattern);
- private static native int[] halGetCarrierFrequencies(int halObject);
+ private static native long halOpen();
+ private static native int halTransmit(long halObject, int carrierFrequency, int[] pattern);
+ private static native int[] halGetCarrierFrequencies(long halObject);
private final Context mContext;
private final PowerManager.WakeLock mWakeLock;
- private final int mHal;
+ private final long mNativeHal;
private final Object mHalLock = new Object();
ConsumerIrService(Context context) {
@@ -65,23 +65,23 @@
mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG);
mWakeLock.setReferenceCounted(true);
- mHal = halOpen();
+ mNativeHal = halOpen();
if (mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CONSUMER_IR)) {
- if (mHal == 0) {
+ if (mNativeHal == 0) {
throw new RuntimeException("FEATURE_CONSUMER_IR present, but no IR HAL loaded!");
}
- } else if (mHal != 0) {
+ } else if (mNativeHal != 0) {
throw new RuntimeException("IR HAL present, but FEATURE_CONSUMER_IR is not set!");
}
}
@Override
public boolean hasIrEmitter() {
- return mHal != 0;
+ return mNativeHal != 0;
}
private void throwIfNoIrEmitter() {
- if (mHal == 0) {
+ if (mNativeHal == 0) {
throw new UnsupportedOperationException("IR emitter not available");
}
}
@@ -111,7 +111,7 @@
// Right now there is no mechanism to ensure fair queing of IR requests
synchronized (mHalLock) {
- int err = halTransmit(mHal, carrierFrequency, pattern);
+ int err = halTransmit(mNativeHal, carrierFrequency, pattern);
if (err < 0) {
Slog.e(TAG, "Error transmitting: " + err);
@@ -129,7 +129,7 @@
throwIfNoIrEmitter();
synchronized(mHalLock) {
- return halGetCarrierFrequencies(mHal);
+ return halGetCarrierFrequencies(mNativeHal);
}
}
}
diff --git a/services/java/com/android/server/LightsService.java b/services/java/com/android/server/LightsService.java
index a1d655b..e99a3a4 100644
--- a/services/java/com/android/server/LightsService.java
+++ b/services/java/com/android/server/LightsService.java
@@ -96,6 +96,7 @@
synchronized (this) {
if (mColor == 0 && !mFlashing) {
setLightLocked(color, LIGHT_FLASH_HARDWARE, onMS, 1000, BRIGHTNESS_MODE_USER);
+ mColor = 0;
mH.sendMessageDelayed(Message.obtain(mH, 1, this), onMS);
}
}
diff --git a/services/java/com/android/server/LocationManagerService.java b/services/java/com/android/server/LocationManagerService.java
index 8f480dd..b4a982e 100644
--- a/services/java/com/android/server/LocationManagerService.java
+++ b/services/java/com/android/server/LocationManagerService.java
@@ -452,6 +452,9 @@
* @param userId the new active user's UserId
*/
private void switchUser(int userId) {
+ if (mCurrentUserId == userId) {
+ return;
+ }
mBlacklist.switchUser(userId);
mLocationHandler.removeMessages(MSG_LOCATION_CHANGED);
synchronized (mLock) {
diff --git a/services/java/com/android/server/MountService.java b/services/java/com/android/server/MountService.java
index e60231a..f73a92b 100644
--- a/services/java/com/android/server/MountService.java
+++ b/services/java/com/android/server/MountService.java
@@ -91,6 +91,7 @@
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@@ -384,18 +385,37 @@
}
class ShutdownCallBack extends UnmountCallBack {
- IMountShutdownObserver observer;
- ShutdownCallBack(String path, IMountShutdownObserver observer) {
+ MountShutdownLatch mMountShutdownLatch;
+ ShutdownCallBack(String path, final MountShutdownLatch mountShutdownLatch) {
super(path, true, false);
- this.observer = observer;
+ mMountShutdownLatch = mountShutdownLatch;
}
@Override
void handleFinished() {
int ret = doUnmountVolume(path, true, removeEncryption);
- if (observer != null) {
+ Slog.i(TAG, "Unmount completed: " + path + ", result code: " + ret);
+ mMountShutdownLatch.countDown();
+ }
+ }
+
+ static class MountShutdownLatch {
+ private IMountShutdownObserver mObserver;
+ private AtomicInteger mCount;
+
+ MountShutdownLatch(final IMountShutdownObserver observer, int count) {
+ mObserver = observer;
+ mCount = new AtomicInteger(count);
+ }
+
+ void countDown() {
+ boolean sendShutdown = false;
+ if (mCount.decrementAndGet() == 0) {
+ sendShutdown = true;
+ }
+ if (sendShutdown && mObserver != null) {
try {
- observer.onShutDownComplete(ret);
+ mObserver.onShutDownComplete(StorageResultCode.OperationSucceeded);
} catch (RemoteException e) {
Slog.w(TAG, "RemoteException when shutting down");
}
@@ -877,7 +897,7 @@
/* Send the media unmounted event first */
if (DEBUG_EVENTS) Slog.i(TAG, "Sending unmounted event first");
updatePublicVolumeState(volume, Environment.MEDIA_UNMOUNTED);
- sendStorageIntent(Environment.MEDIA_UNMOUNTED, volume, UserHandle.ALL);
+ sendStorageIntent(Intent.ACTION_MEDIA_UNMOUNTED, volume, UserHandle.ALL);
if (DEBUG_EVENTS) Slog.i(TAG, "Sending media removed");
updatePublicVolumeState(volume, Environment.MEDIA_REMOVED);
@@ -1164,6 +1184,7 @@
private void sendStorageIntent(String action, StorageVolume volume, UserHandle user) {
final Intent intent = new Intent(action, Uri.parse("file://" + volume.getPath()));
intent.putExtra(StorageVolume.EXTRA_STORAGE_VOLUME, volume);
+ intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
Slog.d(TAG, "sendStorageIntent " + intent + " to " + user);
mContext.sendBroadcastAsUser(intent, user);
}
@@ -1411,7 +1432,7 @@
public void unregisterListener(IMountServiceListener listener) {
synchronized (mListeners) {
for(MountServiceBinderListener bl : mListeners) {
- if (bl.mListener == listener) {
+ if (bl.mListener.asBinder() == listener.asBinder()) {
mListeners.remove(mListeners.indexOf(bl));
listener.asBinder().unlinkToDeath(bl, 0);
return;
@@ -1425,6 +1446,10 @@
Slog.i(TAG, "Shutting down");
synchronized (mVolumesLock) {
+ // Get all volumes to be unmounted.
+ MountShutdownLatch mountShutdownLatch = new MountShutdownLatch(observer,
+ mVolumeStates.size());
+
for (String path : mVolumeStates.keySet()) {
String state = mVolumeStates.get(path);
@@ -1460,19 +1485,16 @@
if (state.equals(Environment.MEDIA_MOUNTED)) {
// Post a unmount message.
- ShutdownCallBack ucb = new ShutdownCallBack(path, observer);
+ ShutdownCallBack ucb = new ShutdownCallBack(path, mountShutdownLatch);
mHandler.sendMessage(mHandler.obtainMessage(H_UNMOUNT_PM_UPDATE, ucb));
} else if (observer != null) {
/*
- * Observer is waiting for onShutDownComplete when we are done.
- * Since nothing will be done send notification directly so shutdown
- * sequence can continue.
+ * Count down, since nothing will be done. The observer will be
+ * notified when we are done so shutdown sequence can continue.
*/
- try {
- observer.onShutDownComplete(StorageResultCode.OperationSucceeded);
- } catch (RemoteException e) {
- Slog.w(TAG, "RemoteException when shutting down");
- }
+ mountShutdownLatch.countDown();
+ Slog.i(TAG, "Unmount completed: " + path +
+ ", result code: " + StorageResultCode.OperationSucceeded);
}
}
}
diff --git a/services/java/com/android/server/NetworkManagementService.java b/services/java/com/android/server/NetworkManagementService.java
index ad7ec99..e6c5422 100644
--- a/services/java/com/android/server/NetworkManagementService.java
+++ b/services/java/com/android/server/NetworkManagementService.java
@@ -82,6 +82,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.StringTokenizer;
@@ -1022,6 +1023,15 @@
}
}
+ private List<InterfaceAddress> excludeLinkLocal(List<InterfaceAddress> addresses) {
+ ArrayList<InterfaceAddress> filtered = new ArrayList<InterfaceAddress>(addresses.size());
+ for (InterfaceAddress ia : addresses) {
+ if (!ia.getAddress().isLinkLocalAddress())
+ filtered.add(ia);
+ }
+ return filtered;
+ }
+
private void modifyNat(String action, String internalInterface, String externalInterface)
throws SocketException {
final Command cmd = new Command("nat", action, internalInterface, externalInterface);
@@ -1031,8 +1041,10 @@
if (internalNetworkInterface == null) {
cmd.appendArg("0");
} else {
- Collection<InterfaceAddress> interfaceAddresses = internalNetworkInterface
- .getInterfaceAddresses();
+ // Don't touch link-local routes, as link-local addresses aren't routable,
+ // kernel creates link-local routes on all interfaces automatically
+ List<InterfaceAddress> interfaceAddresses = excludeLinkLocal(
+ internalNetworkInterface.getInterfaceAddresses());
cmd.appendArg(interfaceAddresses.size());
for (InterfaceAddress ia : interfaceAddresses) {
InetAddress addr = NetworkUtils.getNetworkPart(
diff --git a/services/java/com/android/server/NsdService.java b/services/java/com/android/server/NsdService.java
index 16d2468..9379955 100644
--- a/services/java/com/android/server/NsdService.java
+++ b/services/java/com/android/server/NsdService.java
@@ -152,25 +152,40 @@
class DefaultState extends State {
@Override
public boolean processMessage(Message msg) {
+ ClientInfo cInfo = null;
switch (msg.what) {
case AsyncChannel.CMD_CHANNEL_HALF_CONNECTED:
if (msg.arg1 == AsyncChannel.STATUS_SUCCESSFUL) {
AsyncChannel c = (AsyncChannel) msg.obj;
if (DBG) Slog.d(TAG, "New client listening to asynchronous messages");
c.sendMessage(AsyncChannel.CMD_CHANNEL_FULLY_CONNECTED);
- ClientInfo cInfo = new ClientInfo(c, msg.replyTo);
+ cInfo = new ClientInfo(c, msg.replyTo);
mClients.put(msg.replyTo, cInfo);
} else {
Slog.e(TAG, "Client connection failure, error=" + msg.arg1);
}
break;
case AsyncChannel.CMD_CHANNEL_DISCONNECTED:
- if (msg.arg1 == AsyncChannel.STATUS_SEND_UNSUCCESSFUL) {
- Slog.e(TAG, "Send failed, client connection lost");
- } else {
- if (DBG) Slog.d(TAG, "Client connection lost with reason: " + msg.arg1);
+ switch (msg.arg1) {
+ case AsyncChannel.STATUS_SEND_UNSUCCESSFUL:
+ Slog.e(TAG, "Send failed, client connection lost");
+ break;
+ case AsyncChannel.STATUS_REMOTE_DISCONNECTION:
+ if (DBG) Slog.d(TAG, "Client disconnected");
+ break;
+ default:
+ if (DBG) Slog.d(TAG, "Client connection lost with reason: " + msg.arg1);
+ break;
}
- mClients.remove(msg.replyTo);
+ cInfo = mClients.get(msg.replyTo);
+ if (cInfo != null) {
+ cInfo.expungeAllRequests();
+ mClients.remove(msg.replyTo);
+ }
+ //Last client
+ if (mClients.size() == 0) {
+ stopMDnsDaemon();
+ }
break;
case AsyncChannel.CMD_CHANNEL_FULL_CONNECTION:
AsyncChannel ac = new AsyncChannel();
@@ -248,13 +263,15 @@
return false;
}
- private void storeRequestMap(int clientId, int globalId, ClientInfo clientInfo) {
+ private void storeRequestMap(int clientId, int globalId, ClientInfo clientInfo, int what) {
clientInfo.mClientIds.put(clientId, globalId);
+ clientInfo.mClientRequests.put(clientId, what);
mIdToClientInfoMap.put(globalId, clientInfo);
}
private void removeRequestMap(int clientId, int globalId, ClientInfo clientInfo) {
clientInfo.mClientIds.remove(clientId);
+ clientInfo.mClientRequests.remove(clientId);
mIdToClientInfoMap.remove(globalId);
}
@@ -274,10 +291,6 @@
result = NOT_HANDLED;
break;
case AsyncChannel.CMD_CHANNEL_DISCONNECTED:
- //Last client
- if (mClients.size() == 1) {
- stopMDnsDaemon();
- }
result = NOT_HANDLED;
break;
case NsdManager.DISABLE:
@@ -301,7 +314,7 @@
Slog.d(TAG, "Discover " + msg.arg2 + " " + id +
servInfo.getServiceType());
}
- storeRequestMap(msg.arg2, id, clientInfo);
+ storeRequestMap(msg.arg2, id, clientInfo, msg.what);
replyToMessage(msg, NsdManager.DISCOVER_SERVICES_STARTED, servInfo);
} else {
stopServiceDiscovery(id);
@@ -340,7 +353,7 @@
id = getUniqueId();
if (registerService(id, (NsdServiceInfo) msg.obj)) {
if (DBG) Slog.d(TAG, "Register " + msg.arg2 + " " + id);
- storeRequestMap(msg.arg2, id, clientInfo);
+ storeRequestMap(msg.arg2, id, clientInfo, msg.what);
// Return success after mDns reports success
} else {
unregisterService(id);
@@ -381,7 +394,7 @@
id = getUniqueId();
if (resolveService(id, servInfo)) {
clientInfo.mResolvedService = new NsdServiceInfo();
- storeRequestMap(msg.arg2, id, clientInfo);
+ storeRequestMap(msg.arg2, id, clientInfo, msg.what);
} else {
replyToMessage(msg, NsdManager.RESOLVE_SERVICE_FAILED,
NsdManager.FAILURE_INTERNAL_ERROR);
@@ -487,7 +500,7 @@
int id2 = getUniqueId();
if (getAddrInfo(id2, cooked[3])) {
- storeRequestMap(clientId, id2, clientInfo);
+ storeRequestMap(clientId, id2, clientInfo, NsdManager.RESOLVE_SERVICE);
} else {
clientInfo.mChannel.sendMessage(NsdManager.RESOLVE_SERVICE_FAILED,
NsdManager.FAILURE_INTERNAL_ERROR, clientId);
@@ -827,6 +840,9 @@
/* A map from client id to unique id sent to mDns */
private SparseArray<Integer> mClientIds = new SparseArray<Integer>();
+ /* A map from client id to the type of the request we had received */
+ private SparseArray<Integer> mClientRequests = new SparseArray<Integer>();
+
private ClientInfo(AsyncChannel c, Messenger m) {
mChannel = c;
mMessenger = m;
@@ -840,10 +856,41 @@
sb.append("mMessenger ").append(mMessenger).append("\n");
sb.append("mResolvedService ").append(mResolvedService).append("\n");
for(int i = 0; i< mClientIds.size(); i++) {
- sb.append("clientId ").append(mClientIds.keyAt(i));
- sb.append(" mDnsId ").append(mClientIds.valueAt(i)).append("\n");
+ int clientID = mClientIds.keyAt(i);
+ sb.append("clientId ").append(clientID).
+ append(" mDnsId ").append(mClientIds.valueAt(i)).
+ append(" type ").append(mClientRequests.get(clientID)).append("\n");
}
return sb.toString();
}
+
+ // Remove any pending requests from the global map when we get rid of a client,
+ // and send cancellations to the daemon.
+ private void expungeAllRequests() {
+ int globalId, clientId, i;
+ for (i = 0; i < mClientIds.size(); i++) {
+ clientId = mClientIds.keyAt(i);
+ globalId = mClientIds.valueAt(i);
+ mIdToClientInfoMap.remove(globalId);
+ if (DBG) Slog.d(TAG, "Terminating client-ID " + clientId +
+ " global-ID " + globalId + " type " + mClientRequests.get(clientId));
+ switch (mClientRequests.get(clientId)) {
+ case NsdManager.DISCOVER_SERVICES:
+ stopServiceDiscovery(globalId);
+ break;
+ case NsdManager.RESOLVE_SERVICE:
+ stopResolveService(globalId);
+ break;
+ case NsdManager.REGISTER_SERVICE:
+ unregisterService(globalId);
+ break;
+ default:
+ break;
+ }
+ }
+ mClientIds.clear();
+ mClientRequests.clear();
+ }
+
}
}
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
index a42cbcf..ade8414 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -46,6 +46,7 @@
import com.android.internal.R;
import com.android.internal.os.BinderInternal;
+import com.android.internal.os.Zygote;
import com.android.internal.os.SamplingProfilerIntegration;
import com.android.server.accessibility.AccessibilityManagerService;
import com.android.server.accounts.AccountManagerService;
@@ -71,7 +72,6 @@
import com.android.server.wm.WindowManagerService;
import dalvik.system.VMRuntime;
-import dalvik.system.Zygote;
import java.io.File;
import java.util.Timer;
@@ -824,7 +824,7 @@
if (safeMode) {
ActivityManagerService.self().enterSafeMode();
// Post the safe mode state in the Zygote class
- Zygote.systemInSafeMode = true;
+ SystemServer.inSafeMode = true;
// Disable the JIT for the system_server process
VMRuntime.getRuntime().disableJitCompilation();
} else {
@@ -1117,6 +1117,11 @@
// give any timezone code room without going into negative time.
private static final long EARLIEST_SUPPORTED_TIME = 86400 * 1000;
+ /**
+ * When set, all subsequent apps will be launched in safe mode.
+ */
+ public static boolean inSafeMode;
+
/**
* Called to initialize native system services.
*/
@@ -1133,7 +1138,7 @@
* running as root and we need to be the system user to set
* the property. http://b/11463182
*/
- SystemProperties.set("persist.sys.dalvik.vm.lib",
+ SystemProperties.set("persist.sys.dalvik.vm.lib.1",
VMRuntime.getRuntime().vmLibrary());
if (System.currentTimeMillis() < EARLIEST_SUPPORTED_TIME) {
diff --git a/services/java/com/android/server/TelephonyRegistry.java b/services/java/com/android/server/TelephonyRegistry.java
index 699d79e..77f5182 100644
--- a/services/java/com/android/server/TelephonyRegistry.java
+++ b/services/java/com/android/server/TelephonyRegistry.java
@@ -37,6 +37,10 @@
import android.telephony.SignalStrength;
import android.telephony.CellInfo;
import android.telephony.TelephonyManager;
+import android.telephony.DisconnectCause;
+import android.telephony.PreciseCallState;
+import android.telephony.PreciseDataConnectionState;
+import android.telephony.PreciseDisconnectCause;
import android.text.TextUtils;
import android.util.Slog;
@@ -125,6 +129,17 @@
private List<CellInfo> mCellInfo = null;
+ private int mRingingCallState = PreciseCallState.PRECISE_CALL_STATE_IDLE;
+
+ private int mForegroundCallState = PreciseCallState.PRECISE_CALL_STATE_IDLE;
+
+ private int mBackgroundCallState = PreciseCallState.PRECISE_CALL_STATE_IDLE;
+
+ private PreciseCallState mPreciseCallState = new PreciseCallState();
+
+ private PreciseDataConnectionState mPreciseDataConnectionState =
+ new PreciseDataConnectionState();
+
static final int PHONE_STATE_PERMISSION_MASK =
PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR |
PhoneStateListener.LISTEN_CALL_STATE |
@@ -132,6 +147,10 @@
PhoneStateListener.LISTEN_DATA_CONNECTION_STATE |
PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR;
+ static final int PRECISE_PHONE_STATE_PERMISSION_MASK =
+ PhoneStateListener.LISTEN_PRECISE_CALL_STATE |
+ PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE;
+
private static final int MSG_USER_SWITCHED = 1;
private final Handler mHandler = new Handler() {
@@ -305,6 +324,21 @@
remove(r.binder);
}
}
+ if ((events & PhoneStateListener.LISTEN_PRECISE_CALL_STATE) != 0) {
+ try {
+ r.callback.onPreciseCallStateChanged(mPreciseCallState);
+ } catch (RemoteException ex) {
+ remove(r.binder);
+ }
+ }
+ if ((events & PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE) != 0) {
+ try {
+ r.callback.onPreciseDataConnectionStateChanged(
+ mPreciseDataConnectionState);
+ } catch (RemoteException ex) {
+ remove(r.binder);
+ }
+ }
}
}
} else {
@@ -533,30 +567,47 @@
}
handleRemoveListLocked();
}
+ mPreciseDataConnectionState = new PreciseDataConnectionState(state, networkType,
+ apnType, apn, reason, linkProperties, "");
+ for (Record r : mRecords) {
+ if ((r.events & PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE) != 0) {
+ try {
+ r.callback.onPreciseDataConnectionStateChanged(mPreciseDataConnectionState);
+ } catch (RemoteException ex) {
+ mRemoveList.add(r.binder);
+ }
+ }
+ }
+ handleRemoveListLocked();
}
broadcastDataConnectionStateChanged(state, isDataConnectivityPossible, reason, apn,
apnType, linkProperties, linkCapabilities, roaming);
+ broadcastPreciseDataConnectionStateChanged(state, networkType, apnType, apn, reason,
+ linkProperties, "");
}
public void notifyDataConnectionFailed(String reason, String apnType) {
if (!checkNotifyPermission("notifyDataConnectionFailed()")) {
return;
}
- /*
- * This is commented out because there is no onDataConnectionFailed callback
- * in PhoneStateListener. There should be.
synchronized (mRecords) {
- mDataConnectionFailedReason = reason;
- final int N = mRecords.size();
- for (int i=N-1; i>=0; i--) {
- Record r = mRecords.get(i);
- if ((r.events & PhoneStateListener.LISTEN_DATA_CONNECTION_FAILED) != 0) {
- // XXX
+ mPreciseDataConnectionState = new PreciseDataConnectionState(
+ TelephonyManager.DATA_UNKNOWN,TelephonyManager.NETWORK_TYPE_UNKNOWN,
+ apnType, "", reason, null, "");
+ for (Record r : mRecords) {
+ if ((r.events & PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE) != 0) {
+ try {
+ r.callback.onPreciseDataConnectionStateChanged(mPreciseDataConnectionState);
+ } catch (RemoteException ex) {
+ mRemoveList.add(r.binder);
+ }
}
}
+ handleRemoveListLocked();
}
- */
broadcastDataConnectionFailed(reason, apnType);
+ broadcastPreciseDataConnectionStateChanged(TelephonyManager.DATA_UNKNOWN,
+ TelephonyManager.NETWORK_TYPE_UNKNOWN, apnType, "", reason, null, "");
}
public void notifyCellLocation(Bundle cellLocation) {
@@ -602,6 +653,81 @@
}
}
+ public void notifyPreciseCallState(int ringingCallState, int foregroundCallState,
+ int backgroundCallState) {
+ if (!checkNotifyPermission("notifyPreciseCallState()")) {
+ return;
+ }
+ synchronized (mRecords) {
+ mRingingCallState = ringingCallState;
+ mForegroundCallState = foregroundCallState;
+ mBackgroundCallState = backgroundCallState;
+ mPreciseCallState = new PreciseCallState(ringingCallState, foregroundCallState,
+ backgroundCallState,
+ DisconnectCause.NOT_VALID,
+ PreciseDisconnectCause.NOT_VALID);
+ for (Record r : mRecords) {
+ if ((r.events & PhoneStateListener.LISTEN_PRECISE_CALL_STATE) != 0) {
+ try {
+ r.callback.onPreciseCallStateChanged(mPreciseCallState);
+ } catch (RemoteException ex) {
+ mRemoveList.add(r.binder);
+ }
+ }
+ }
+ handleRemoveListLocked();
+ }
+ broadcastPreciseCallStateChanged(ringingCallState, foregroundCallState, backgroundCallState,
+ DisconnectCause.NOT_VALID,
+ PreciseDisconnectCause.NOT_VALID);
+ }
+
+ public void notifyDisconnectCause(int disconnectCause, int preciseDisconnectCause) {
+ if (!checkNotifyPermission("notifyDisconnectCause()")) {
+ return;
+ }
+ synchronized (mRecords) {
+ mPreciseCallState = new PreciseCallState(mRingingCallState, mForegroundCallState,
+ mBackgroundCallState, disconnectCause, preciseDisconnectCause);
+ for (Record r : mRecords) {
+ if ((r.events & PhoneStateListener.LISTEN_PRECISE_CALL_STATE) != 0) {
+ try {
+ r.callback.onPreciseCallStateChanged(mPreciseCallState);
+ } catch (RemoteException ex) {
+ mRemoveList.add(r.binder);
+ }
+ }
+ }
+ handleRemoveListLocked();
+ }
+ broadcastPreciseCallStateChanged(mRingingCallState, mForegroundCallState,
+ mBackgroundCallState, disconnectCause, preciseDisconnectCause);
+ }
+
+ public void notifyPreciseDataConnectionFailed(String reason, String apnType,
+ String apn, String failCause) {
+ if (!checkNotifyPermission("notifyPreciseDataConnectionFailed()")) {
+ return;
+ }
+ synchronized (mRecords) {
+ mPreciseDataConnectionState = new PreciseDataConnectionState(
+ TelephonyManager.DATA_UNKNOWN, TelephonyManager.NETWORK_TYPE_UNKNOWN,
+ apnType, apn, reason, null, failCause);
+ for (Record r : mRecords) {
+ if ((r.events & PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE) != 0) {
+ try {
+ r.callback.onPreciseDataConnectionStateChanged(mPreciseDataConnectionState);
+ } catch (RemoteException ex) {
+ mRemoveList.add(r.binder);
+ }
+ }
+ }
+ handleRemoveListLocked();
+ }
+ broadcastPreciseDataConnectionStateChanged(TelephonyManager.DATA_UNKNOWN,
+ TelephonyManager.NETWORK_TYPE_UNKNOWN, apnType, apn, reason, null, failCause);
+ }
+
@Override
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
@@ -738,6 +864,33 @@
mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
}
+ private void broadcastPreciseCallStateChanged(int ringingCallState, int foregroundCallState,
+ int backgroundCallState, int disconnectCause, int preciseDisconnectCause) {
+ Intent intent = new Intent(TelephonyManager.ACTION_PRECISE_CALL_STATE_CHANGED);
+ intent.putExtra(TelephonyManager.EXTRA_RINGING_CALL_STATE, ringingCallState);
+ intent.putExtra(TelephonyManager.EXTRA_FOREGROUND_CALL_STATE, foregroundCallState);
+ intent.putExtra(TelephonyManager.EXTRA_BACKGROUND_CALL_STATE, backgroundCallState);
+ intent.putExtra(TelephonyManager.EXTRA_DISCONNECT_CAUSE, disconnectCause);
+ intent.putExtra(TelephonyManager.EXTRA_PRECISE_DISCONNECT_CAUSE, preciseDisconnectCause);
+ mContext.sendBroadcastAsUser(intent, UserHandle.ALL,
+ android.Manifest.permission.READ_PRECISE_PHONE_STATE);
+ }
+
+ private void broadcastPreciseDataConnectionStateChanged(int state, int networkType,
+ String apnType, String apn, String reason, LinkProperties linkProperties, String failCause) {
+ Intent intent = new Intent(TelephonyManager.ACTION_PRECISE_DATA_CONNECTION_STATE_CHANGED);
+ intent.putExtra(PhoneConstants.STATE_KEY, state);
+ intent.putExtra(PhoneConstants.DATA_NETWORK_TYPE_KEY, networkType);
+ if (reason != null) intent.putExtra(PhoneConstants.STATE_CHANGE_REASON_KEY, reason);
+ if (apnType != null) intent.putExtra(PhoneConstants.DATA_APN_TYPE_KEY, apnType);
+ if (apn != null) intent.putExtra(PhoneConstants.DATA_APN_KEY, apn);
+ if (linkProperties != null) intent.putExtra(PhoneConstants.DATA_LINK_PROPERTIES_KEY, linkProperties);
+ if (failCause != null) intent.putExtra(PhoneConstants.DATA_FAILURE_CAUSE_KEY, failCause);
+
+ mContext.sendBroadcastAsUser(intent, UserHandle.ALL,
+ android.Manifest.permission.READ_PRECISE_PHONE_STATE);
+ }
+
private boolean checkNotifyPermission(String method) {
if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
== PackageManager.PERMISSION_GRANTED) {
@@ -766,6 +919,12 @@
mContext.enforceCallingOrSelfPermission(
android.Manifest.permission.READ_PHONE_STATE, null);
}
+
+ if ((events & PRECISE_PHONE_STATE_PERMISSION_MASK) != 0) {
+ mContext.enforceCallingOrSelfPermission(
+ android.Manifest.permission.READ_PRECISE_PHONE_STATE, null);
+
+ }
}
private void handleRemoveListLocked() {
diff --git a/services/java/com/android/server/am/ActiveServices.java b/services/java/com/android/server/am/ActiveServices.java
old mode 100644
new mode 100755
index 933247e..e06b8c5
--- a/services/java/com/android/server/am/ActiveServices.java
+++ b/services/java/com/android/server/am/ActiveServices.java
@@ -203,6 +203,7 @@
Slog.i(TAG, "Waited long enough for: " + r);
mStartingBackground.remove(i);
N--;
+ i--;
}
}
while (mDelayedStartList.size() > 0
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index fc66e45..16b9963 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -38,6 +38,7 @@
import com.android.internal.os.BatteryStatsImpl;
import com.android.internal.os.ProcessCpuTracker;
import com.android.internal.os.TransferPipe;
+import com.android.internal.os.Zygote;
import com.android.internal.util.FastPrintWriter;
import com.android.internal.util.FastXmlSerializer;
import com.android.internal.util.MemInfoReader;
@@ -57,8 +58,6 @@
import com.google.android.collect.Lists;
import com.google.android.collect.Maps;
-import dalvik.system.Zygote;
-
import libcore.io.IoUtils;
import org.xmlpull.v1.XmlPullParser;
@@ -1058,6 +1057,7 @@
static final int IMMERSIVE_MODE_LOCK_MSG = 37;
static final int PERSIST_URI_GRANTS_MSG = 38;
static final int REQUEST_ALL_PSS_MSG = 39;
+ static final int UPDATE_TIME = 40;
static final int FIRST_ACTIVITY_STACK_MSG = 100;
static final int FIRST_BROADCAST_QUEUE_MSG = 200;
@@ -1668,6 +1668,22 @@
requestPssAllProcsLocked(SystemClock.uptimeMillis(), true, false);
break;
}
+ case UPDATE_TIME: {
+ synchronized (ActivityManagerService.this) {
+ for (int i = mLruProcesses.size() - 1 ; i >= 0 ; i--) {
+ ProcessRecord r = mLruProcesses.get(i);
+ if (r.thread != null) {
+ try {
+ r.thread.updateTimePrefs(msg.arg1 == 0 ? false : true);
+ } catch (RemoteException ex) {
+ Slog.w(TAG, "Failed to update preferences for: " + r.info.processName);
+ }
+ }
+ }
+ }
+
+ break;
+ }
}
}
};
@@ -2751,7 +2767,7 @@
// Run the app in safe mode if its manifest requests so or the
// system is booted in safe mode.
if ((app.info.flags & ApplicationInfo.FLAG_VM_SAFE_MODE) != 0 ||
- Zygote.systemInSafeMode == true) {
+ SystemServer.inSafeMode == true) {
debugFlags |= Zygote.DEBUG_ENABLE_SAFEMODE;
}
if ("1".equals(SystemProperties.get("debug.checkjni"))) {
@@ -2764,11 +2780,16 @@
debugFlags |= Zygote.DEBUG_ENABLE_ASSERT;
}
+ String requiredAbi = app.info.requiredCpuAbi;
+ if (requiredAbi == null) {
+ requiredAbi = Build.SUPPORTED_ABIS[0];
+ }
+
// Start the process. It will either succeed and return a result containing
// the PID of the new process, or else throw a RuntimeException.
Process.ProcessStartResult startResult = Process.start("android.app.ActivityThread",
app.processName, uid, uid, gids, debugFlags, mountExternal,
- app.info.targetSdkVersion, app.info.seinfo, null);
+ app.info.targetSdkVersion, app.info.seinfo, requiredAbi, null);
BatteryStatsImpl bs = mBatteryStatsService.getActiveStatistics();
synchronized (bs) {
@@ -12418,6 +12439,7 @@
app.foregroundActivities = false;
app.hasShownUi = false;
app.hasAboveClient = false;
+ app.hasClientActivities = false;
mServices.killServicesLocked(app, allowRestart);
@@ -13430,11 +13452,20 @@
* of all currently running processes. This message will get queued up before the broadcast
* happens.
*/
- if (intent.ACTION_TIMEZONE_CHANGED.equals(intent.getAction())) {
+ if (Intent.ACTION_TIMEZONE_CHANGED.equals(intent.getAction())) {
mHandler.sendEmptyMessage(UPDATE_TIME_ZONE);
}
- if (intent.ACTION_CLEAR_DNS_CACHE.equals(intent.getAction())) {
+ /*
+ * If the user set the time, let all running processes know.
+ */
+ if (Intent.ACTION_TIME_CHANGED.equals(intent.getAction())) {
+ final int is24Hour = intent.getBooleanExtra(
+ Intent.EXTRA_TIME_PREF_24_HOUR_FORMAT, false) ? 1 : 0;
+ mHandler.sendMessage(mHandler.obtainMessage(UPDATE_TIME, is24Hour, 0));
+ }
+
+ if (Intent.ACTION_CLEAR_DNS_CACHE.equals(intent.getAction())) {
mHandler.sendEmptyMessage(CLEAR_DNS_CACHE_MSG);
}
diff --git a/services/java/com/android/server/am/ActivityRecord.java b/services/java/com/android/server/am/ActivityRecord.java
old mode 100644
new mode 100755
index 49f29fe..63a52e6
--- a/services/java/com/android/server/am/ActivityRecord.java
+++ b/services/java/com/android/server/am/ActivityRecord.java
@@ -942,8 +942,8 @@
// for another app to start, then we have paused dispatching
// for this activity.
ActivityRecord r = this;
- final ActivityStack stack = task.stack;
if (r.waitingVisible) {
+ final ActivityStack stack = mStackSupervisor.getFocusedStack();
// Hmmm, who might we be waiting for?
r = stack.mResumedActivity;
if (r == null) {
diff --git a/services/java/com/android/server/am/ActivityStack.java b/services/java/com/android/server/am/ActivityStack.java
old mode 100644
new mode 100755
index 37f4cd7..07c2201
--- a/services/java/com/android/server/am/ActivityStack.java
+++ b/services/java/com/android/server/am/ActivityStack.java
@@ -1094,6 +1094,7 @@
if (!r.visible) {
if (DEBUG_VISBILITY) Slog.v(
TAG, "Starting and making visible: " + r);
+ r.visible = true;
mWindowManager.setAppVisibility(r.appToken, true);
}
if (r != starting) {
@@ -1141,10 +1142,11 @@
// At this point, nothing else needs to be shown
if (DEBUG_VISBILITY) Slog.v(TAG, "Fullscreen: at " + r);
behindFullscreen = true;
+ showHomeBehindStack = false;
} else if (isActivityOverHome(r)) {
if (DEBUG_VISBILITY) Slog.v(TAG, "Showing home: at " + r);
showHomeBehindStack = true;
- behindFullscreen = !isHomeStack();
+ behindFullscreen = !isHomeStack() && r.frontOfTask && task.mOnTopOfHome;
}
} else {
if (DEBUG_VISBILITY) Slog.v(
@@ -2623,6 +2625,9 @@
if (mResumedActivity == r) {
mResumedActivity = null;
}
+ if (mPausingActivity == r) {
+ mPausingActivity = null;
+ }
if (mService.mFocusedActivity == r) {
mService.mFocusedActivity = null;
}
diff --git a/services/java/com/android/server/am/ActivityStackSupervisor.java b/services/java/com/android/server/am/ActivityStackSupervisor.java
old mode 100644
new mode 100755
index 483b4a0..93de0a6
--- a/services/java/com/android/server/am/ActivityStackSupervisor.java
+++ b/services/java/com/android/server/am/ActivityStackSupervisor.java
@@ -1425,6 +1425,7 @@
r.resultTo = null;
}
+ boolean switchStackFromBg = false;
boolean addingToTask = false;
boolean movedHome = false;
TaskRecord reuseTask = null;
@@ -1486,6 +1487,11 @@
}
options = null;
}
+ } else {
+ switchStackFromBg = lastStack != targetStack;
+ if (DEBUG_TASKS) Slog.d(TAG, "Caller " + sourceRecord
+ + " is not top task, it may not move " + r
+ + " to front, switchStack=" + switchStackFromBg);
}
// If the caller has requested that the target task be
// reset, then do so.
@@ -1593,6 +1599,10 @@
// don't use that intent!) And for paranoia, make
// sure we have correctly resumed the top activity.
if (doResume) {
+ if (switchStackFromBg) {
+ moveHomeStack(lastStack.isHomeStack());
+ targetStack = lastStack;
+ }
targetStack.resumeTopActivityLocked(null, options);
} else {
ActivityOptions.abort(options);
diff --git a/services/java/com/android/server/am/CoreSettingsObserver.java b/services/java/com/android/server/am/CoreSettingsObserver.java
index 10ea67c..4c887dd 100644
--- a/services/java/com/android/server/am/CoreSettingsObserver.java
+++ b/services/java/com/android/server/am/CoreSettingsObserver.java
@@ -37,11 +37,16 @@
private static final String LOG_TAG = CoreSettingsObserver.class.getSimpleName();
// mapping form property name to its type
- private static final Map<String, Class<?>> sCoreSettingToTypeMap = new HashMap<
+ private static final Map<String, Class<?>> sSecureSettingToTypeMap = new HashMap<
+ String, Class<?>>();
+ private static final Map<String, Class<?>> sSystemSettingToTypeMap = new HashMap<
String, Class<?>>();
static {
- sCoreSettingToTypeMap.put(Settings.Secure.LONG_PRESS_TIMEOUT, int.class);
- // add other core settings here...
+ sSecureSettingToTypeMap.put(Settings.Secure.LONG_PRESS_TIMEOUT, int.class);
+ // add other secure settings here...
+
+ sSystemSettingToTypeMap.put(Settings.System.TIME_12_24, String.class);
+ // add other system settings here...
}
private final Bundle mCoreSettings = new Bundle();
@@ -67,39 +72,62 @@
}
private void sendCoreSettings() {
- populateCoreSettings(mCoreSettings);
+ populateSettings(mCoreSettings, sSecureSettingToTypeMap);
+ populateSettings(mCoreSettings, sSystemSettingToTypeMap);
mActivityManagerService.onCoreSettingsChange(mCoreSettings);
}
private void beginObserveCoreSettings() {
- for (String setting : sCoreSettingToTypeMap.keySet()) {
+ for (String setting : sSecureSettingToTypeMap.keySet()) {
Uri uri = Settings.Secure.getUriFor(setting);
mActivityManagerService.mContext.getContentResolver().registerContentObserver(
uri, false, this);
}
+
+ for (String setting : sSystemSettingToTypeMap.keySet()) {
+ Uri uri = Settings.System.getUriFor(setting);
+ mActivityManagerService.mContext.getContentResolver().registerContentObserver(
+ uri, false, this);
+ }
}
- private void populateCoreSettings(Bundle snapshot) {
+ private void populateSettings(Bundle snapshot, Map<String, Class<?>> map) {
Context context = mActivityManagerService.mContext;
- for (Map.Entry<String, Class<?>> entry : sCoreSettingToTypeMap.entrySet()) {
+ for (Map.Entry<String, Class<?>> entry : map.entrySet()) {
String setting = entry.getKey();
Class<?> type = entry.getValue();
try {
if (type == String.class) {
- String value = Settings.Secure.getString(context.getContentResolver(),
- setting);
+ final String value;
+ if (map == sSecureSettingToTypeMap) {
+ value = Settings.Secure.getString(context.getContentResolver(), setting);
+ } else {
+ value = Settings.System.getString(context.getContentResolver(), setting);
+ }
snapshot.putString(setting, value);
} else if (type == int.class) {
- int value = Settings.Secure.getInt(context.getContentResolver(),
- setting);
+ final int value;
+ if (map == sSecureSettingToTypeMap) {
+ value = Settings.Secure.getInt(context.getContentResolver(), setting);
+ } else {
+ value = Settings.System.getInt(context.getContentResolver(), setting);
+ }
snapshot.putInt(setting, value);
} else if (type == float.class) {
- float value = Settings.Secure.getFloat(context.getContentResolver(),
- setting);
+ final float value;
+ if (map == sSecureSettingToTypeMap) {
+ value = Settings.Secure.getFloat(context.getContentResolver(), setting);
+ } else {
+ value = Settings.System.getFloat(context.getContentResolver(), setting);
+ }
snapshot.putFloat(setting, value);
} else if (type == long.class) {
- long value = Settings.Secure.getLong(context.getContentResolver(),
- setting);
+ final long value;
+ if (map == sSecureSettingToTypeMap) {
+ value = Settings.Secure.getLong(context.getContentResolver(), setting);
+ } else {
+ value = Settings.System.getLong(context.getContentResolver(), setting);
+ }
snapshot.putLong(setting, value);
}
} catch (SettingNotFoundException snfe) {
diff --git a/services/java/com/android/server/firewall/IntentFirewall.java b/services/java/com/android/server/firewall/IntentFirewall.java
index aaa0b58..6df1dbd 100644
--- a/services/java/com/android/server/firewall/IntentFirewall.java
+++ b/services/java/com/android/server/firewall/IntentFirewall.java
@@ -268,11 +268,13 @@
}
File[] files = rulesDir.listFiles();
- for (int i=0; i<files.length; i++) {
- File file = files[i];
+ if (files != null) {
+ for (int i=0; i<files.length; i++) {
+ File file = files[i];
- if (file.getName().endsWith(".xml")) {
- readRules(file, resolvers);
+ if (file.getName().endsWith(".xml")) {
+ readRules(file, resolvers);
+ }
}
}
diff --git a/services/java/com/android/server/pm/Installer.java b/services/java/com/android/server/pm/Installer.java
index 0d2b503..8cd9d93 100644
--- a/services/java/com/android/server/pm/Installer.java
+++ b/services/java/com/android/server/pm/Installer.java
@@ -208,6 +208,30 @@
builder.append(' ');
builder.append(uid);
builder.append(isPublic ? " 1" : " 0");
+ builder.append(" *"); // No pkgName arg present
+ return execute(builder.toString());
+ }
+
+ public int dexopt(String apkPath, int uid, boolean isPublic, String pkgName) {
+ StringBuilder builder = new StringBuilder("dexopt");
+ builder.append(' ');
+ builder.append(apkPath);
+ builder.append(' ');
+ builder.append(uid);
+ builder.append(isPublic ? " 1" : " 0");
+ builder.append(' ');
+ builder.append(pkgName);
+ return execute(builder.toString());
+ }
+
+ public int idmap(String targetApkPath, String overlayApkPath, int uid) {
+ StringBuilder builder = new StringBuilder("idmap");
+ builder.append(' ');
+ builder.append(targetApkPath);
+ builder.append(' ');
+ builder.append(overlayApkPath);
+ builder.append(' ');
+ builder.append(uid);
return execute(builder.toString());
}
@@ -372,4 +396,15 @@
return execute(builder.toString());
}
+
+ public boolean restoreconData(String pkgName, String seinfo, int uid) {
+ StringBuilder builder = new StringBuilder("restorecondata");
+ builder.append(' ');
+ builder.append(pkgName);
+ builder.append(' ');
+ builder.append(seinfo != null ? seinfo : "!");
+ builder.append(' ');
+ builder.append(uid);
+ return (execute(builder.toString()) == 0);
+ }
}
diff --git a/services/java/com/android/server/pm/PackageManagerService.java b/services/java/com/android/server/pm/PackageManagerService.java
index 5761f6c..44765a5 100755
--- a/services/java/com/android/server/pm/PackageManagerService.java
+++ b/services/java/com/android/server/pm/PackageManagerService.java
@@ -59,8 +59,8 @@
import android.content.Intent;
import android.content.IntentFilter;
import android.content.IntentSender;
-import android.content.ServiceConnection;
import android.content.IntentSender.SendIntentException;
+import android.content.ServiceConnection;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.ContainerEncryptionParams;
@@ -72,14 +72,15 @@
import android.content.pm.IPackageMoveObserver;
import android.content.pm.IPackageStatsObserver;
import android.content.pm.InstrumentationInfo;
+import android.content.pm.ManifestDigest;
import android.content.pm.PackageCleanItem;
import android.content.pm.PackageInfo;
import android.content.pm.PackageInfoLite;
import android.content.pm.PackageManager;
import android.content.pm.PackageParser;
-import android.content.pm.PackageUserState;
import android.content.pm.PackageParser.ActivityIntentInfo;
import android.content.pm.PackageStats;
+import android.content.pm.PackageUserState;
import android.content.pm.ParceledListSlice;
import android.content.pm.PermissionGroupInfo;
import android.content.pm.PermissionInfo;
@@ -87,7 +88,6 @@
import android.content.pm.ResolveInfo;
import android.content.pm.ServiceInfo;
import android.content.pm.Signature;
-import android.content.pm.ManifestDigest;
import android.content.pm.VerificationParams;
import android.content.pm.VerifierDeviceIdentity;
import android.content.pm.VerifierInfo;
@@ -97,6 +97,7 @@
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
+import android.os.Environment.UserEnvironment;
import android.os.FileObserver;
import android.os.FileUtils;
import android.os.Handler;
@@ -113,7 +114,6 @@
import android.os.SystemClock;
import android.os.SystemProperties;
import android.os.UserHandle;
-import android.os.Environment.UserEnvironment;
import android.os.UserManager;
import android.security.KeyStore;
import android.security.SystemKeyStore;
@@ -217,6 +217,7 @@
static final int SCAN_UPDATE_TIME = 1<<6;
static final int SCAN_DEFER_DEX = 1<<7;
static final int SCAN_BOOTING = 1<<8;
+ static final int SCAN_TRUSTED_OVERLAY = 1<<9;
static final int REMOVE_CHATTY = 1<<16;
@@ -257,8 +258,13 @@
private static final String LIB_DIR_NAME = "lib";
+ private static final String VENDOR_OVERLAY_DIR = "/vendor/overlay";
+
static final String mTempContainerPrefix = "smdl2tmp";
+ private static final String IDMAP_PREFIX = "/data/resource-cache/";
+ private static final String IDMAP_SUFFIX = "@idmap";
+
final HandlerThread mHandlerThread = new HandlerThread("PackageManager",
Process.THREAD_PRIORITY_BACKGROUND);
final PackageHandler mHandler;
@@ -296,6 +302,9 @@
// This is the object monitoring the system app dir.
final FileObserver mVendorInstallObserver;
+ // This is the object monitoring the vendor overlay package dir.
+ final FileObserver mVendorOverlayInstallObserver;
+
// This is the object monitoring mAppInstallDir.
final FileObserver mAppInstallObserver;
@@ -343,6 +352,10 @@
final HashMap<String, PackageParser.Package> mPackages =
new HashMap<String, PackageParser.Package>();
+ // Tracks available target package names -> overlay package paths.
+ final HashMap<String, HashMap<String, PackageParser.Package>> mOverlays =
+ new HashMap<String, HashMap<String, PackageParser.Package>>();
+
final Settings mSettings;
boolean mRestoredSettings;
@@ -380,6 +393,9 @@
// If mac_permissions.xml was found for seinfo labeling.
boolean mFoundPolicyFile;
+ // If a recursive restorecon of /data/data/<pkg> is needed.
+ private boolean mShouldRestoreconData = SELinuxMMAC.shouldRestorecon();
+
// All available activities, for your resolving pleasure.
final ActivityIntentResolver mActivities =
new ActivityIntentResolver();
@@ -1196,7 +1212,7 @@
continue;
}
try {
- if (dalvik.system.DexFile.isDexOptNeeded(lib)) {
+ if (dalvik.system.DexFile.isDexOptNeededInternal(lib, null, false)) {
alreadyDexOpted.add(lib);
mInstaller.dexopt(lib, Process.SYSTEM_UID, true);
didDexOpt = true;
@@ -1240,7 +1256,7 @@
continue;
}
try {
- if (dalvik.system.DexFile.isDexOptNeeded(path)) {
+ if (dalvik.system.DexFile.isDexOptNeededInternal(path, null, false)) {
mInstaller.dexopt(path, Process.SYSTEM_UID, true);
didDexOpt = true;
}
@@ -1273,6 +1289,17 @@
}
}
+ // Collect vendor overlay packages.
+ // (Do this before scanning any apps.)
+ // For security and version matching reason, only consider
+ // overlay packages if they reside in VENDOR_OVERLAY_DIR.
+ File vendorOverlayDir = new File(VENDOR_OVERLAY_DIR);
+ mVendorOverlayInstallObserver = new AppDirObserver(
+ vendorOverlayDir.getPath(), OBSERVER_EVENTS, true, false);
+ mVendorOverlayInstallObserver.startWatching();
+ scanDirLI(vendorOverlayDir, PackageParser.PARSE_IS_SYSTEM
+ | PackageParser.PARSE_IS_SYSTEM_DIR, scanMode | SCAN_TRUSTED_OVERLAY, 0);
+
// Find base frameworks (resource packages without code).
mFrameworkInstallObserver = new AppDirObserver(
frameworkDir.getPath(), OBSERVER_EVENTS, true, false);
@@ -1301,6 +1328,11 @@
// Collect all vendor packages.
File vendorAppDir = new File("/vendor/app");
+ try {
+ vendorAppDir = vendorAppDir.getCanonicalFile();
+ } catch (IOException e) {
+ // failed to look up canonical path, continue with original one
+ }
mVendorInstallObserver = new AppDirObserver(
vendorAppDir.getPath(), OBSERVER_EVENTS, true, false);
mVendorInstallObserver.startWatching();
@@ -1973,6 +2005,7 @@
pkg.applicationInfo.dataDir =
getDataPathForPackage(packageName, 0).getPath();
pkg.applicationInfo.nativeLibraryDir = ps.nativeLibraryPathString;
+ pkg.applicationInfo.requiredCpuAbi = ps.requiredCpuAbiString;
}
return generatePackageInfo(pkg, flags, userId);
}
@@ -3470,6 +3503,56 @@
return finalList;
}
+ private void createIdmapsForPackageLI(PackageParser.Package pkg) {
+ HashMap<String, PackageParser.Package> overlays = mOverlays.get(pkg.packageName);
+ if (overlays == null) {
+ Slog.w(TAG, "Unable to create idmap for " + pkg.packageName + ": no overlay packages");
+ return;
+ }
+ for (PackageParser.Package opkg : overlays.values()) {
+ // Not much to do if idmap fails: we already logged the error
+ // and we certainly don't want to abort installation of pkg simply
+ // because an overlay didn't fit properly. For these reasons,
+ // ignore the return value of createIdmapForPackagePairLI.
+ createIdmapForPackagePairLI(pkg, opkg);
+ }
+ }
+
+ private boolean createIdmapForPackagePairLI(PackageParser.Package pkg,
+ PackageParser.Package opkg) {
+ if (!opkg.mTrustedOverlay) {
+ Slog.w(TAG, "Skipping target and overlay pair " + pkg.mScanPath + " and " +
+ opkg.mScanPath + ": overlay not trusted");
+ return false;
+ }
+ HashMap<String, PackageParser.Package> overlaySet = mOverlays.get(pkg.packageName);
+ if (overlaySet == null) {
+ Slog.e(TAG, "was about to create idmap for " + pkg.mScanPath + " and " +
+ opkg.mScanPath + " but target package has no known overlays");
+ return false;
+ }
+ final int sharedGid = UserHandle.getSharedAppGid(pkg.applicationInfo.uid);
+ if (mInstaller.idmap(pkg.mScanPath, opkg.mScanPath, sharedGid) != 0) {
+ Slog.e(TAG, "Failed to generate idmap for " + pkg.mScanPath + " and " + opkg.mScanPath);
+ return false;
+ }
+ PackageParser.Package[] overlayArray =
+ overlaySet.values().toArray(new PackageParser.Package[0]);
+ Comparator<PackageParser.Package> cmp = new Comparator<PackageParser.Package>() {
+ public int compare(PackageParser.Package p1, PackageParser.Package p2) {
+ return p1.mOverlayPriority - p2.mOverlayPriority;
+ }
+ };
+ Arrays.sort(overlayArray, cmp);
+
+ pkg.applicationInfo.resourceDirs = new String[overlayArray.length];
+ int i = 0;
+ for (PackageParser.Package p : overlayArray) {
+ pkg.applicationInfo.resourceDirs[i++] = p.applicationInfo.sourceDir;
+ }
+ return true;
+ }
+
private void scanDirLI(File dir, int flags, int scanMode, long currentTime) {
String[] files = dir.list();
if (files == null) {
@@ -3567,7 +3650,7 @@
pp.setSeparateProcesses(mSeparateProcesses);
pp.setOnlyCoreApps(mOnlyCore);
final PackageParser.Package pkg = pp.parsePackage(scanFile,
- scanPath, mMetrics, parseFlags);
+ scanPath, mMetrics, parseFlags, (scanMode & SCAN_TRUSTED_OVERLAY) != 0);
if (pkg == null) {
mLastScanError = pp.getParseError();
@@ -3595,6 +3678,7 @@
updatedPkg = mSettings.getDisabledSystemPkgLPr(ps != null ? ps.name : pkg.packageName);
if (DEBUG_INSTALL && updatedPkg != null) Slog.d(TAG, "updatedPkg = " + updatedPkg);
}
+ boolean updatedPkgBetter = false;
// First check if this is a system package that may involve an update
if (updatedPkg != null && (parseFlags&PackageParser.PARSE_IS_SYSTEM) != 0) {
if (ps != null && !ps.codePath.equals(scanFile)) {
@@ -3649,6 +3733,7 @@
synchronized (mPackages) {
mSettings.enableSystemPackageLPw(ps.name);
}
+ updatedPkgBetter = true;
}
}
}
@@ -3657,6 +3742,12 @@
// An updated system app will not have the PARSE_IS_SYSTEM flag set
// initially
parseFlags |= PackageParser.PARSE_IS_SYSTEM;
+
+ // An updated privileged app will not have the PARSE_IS_PRIVILEGED
+ // flag set initially
+ if ((updatedPkg.pkgFlags & ApplicationInfo.FLAG_PRIVILEGED) != 0) {
+ parseFlags |= PackageParser.PARSE_IS_PRIVILEGED;
+ }
}
// Verify certificates against what was last scanned
if (!collectCertificatesLI(pp, ps, pkg, scanFile, parseFlags)) {
@@ -3719,7 +3810,7 @@
String codePath = null;
String resPath = null;
- if ((parseFlags & PackageParser.PARSE_FORWARD_LOCK) != 0) {
+ if ((parseFlags & PackageParser.PARSE_FORWARD_LOCK) != 0 && !updatedPkgBetter) {
if (ps != null && ps.resourcePathString != null) {
resPath = ps.resourcePathString;
} else {
@@ -3733,6 +3824,8 @@
codePath = pkg.mScanPath;
// Set application objects path explicitly.
setApplicationInfoPaths(pkg, codePath, resPath);
+ // Applications can run with the primary Cpu Abi unless otherwise is specified
+ pkg.applicationInfo.requiredCpuAbi = null;
// Note that we invoke the following method only if we are about to unpack an application
PackageParser.Package scannedPkg = scanPackageLI(pkg, parseFlags, scanMode
| SCAN_UPDATE_SIGNATURE, currentTime, user);
@@ -3901,7 +3994,8 @@
String path = pkg.mScanPath;
int ret = 0;
try {
- if (forceDex || dalvik.system.DexFile.isDexOptNeeded(path)) {
+ if (forceDex || dalvik.system.DexFile.isDexOptNeededInternal(path, pkg.packageName,
+ defer)) {
if (!forceDex && defer) {
if (mDeferredDexOpt == null) {
mDeferredDexOpt = new HashSet<PackageParser.Package>();
@@ -3911,7 +4005,8 @@
} else {
Log.i(TAG, "Running dexopt on: " + pkg.applicationInfo.packageName);
final int sharedGid = UserHandle.getSharedAppGid(pkg.applicationInfo.uid);
- ret = mInstaller.dexopt(path, sharedGid, !isForwardLocked(pkg));
+ ret = mInstaller.dexopt(path, sharedGid, !isForwardLocked(pkg),
+ pkg.packageName);
pkg.mDidDexOpt = true;
performed = true;
}
@@ -4303,6 +4398,7 @@
// the PkgSetting exists already and doesn't have to be created.
pkgSetting = mSettings.getPackageLPw(pkg, origPackage, realName, suid, destCodeFile,
destResourceFile, pkg.applicationInfo.nativeLibraryDir,
+ pkg.applicationInfo.requiredCpuAbi,
pkg.applicationInfo.flags, user, false);
if (pkgSetting == null) {
Slog.w(TAG, "Creating application package " + pkg.packageName + " failed");
@@ -4521,6 +4617,11 @@
}
}
pkg.applicationInfo.dataDir = dataPath.getPath();
+ if (mShouldRestoreconData) {
+ Slog.i(TAG, "SELinux relabeling of " + pkg.packageName + " issued.");
+ mInstaller.restoreconData(pkg.packageName, pkg.applicationInfo.seinfo,
+ pkg.applicationInfo.uid);
+ }
} else {
if (DEBUG_PACKAGE_SCANNING) {
if ((parseFlags & PackageParser.PARSE_CHATTY) != 0)
@@ -4603,11 +4704,20 @@
}
try {
- if (copyNativeLibrariesForInternalApp(scanFile, nativeLibraryDir) != PackageManager.INSTALL_SUCCEEDED) {
+ int copyRet = copyNativeLibrariesForInternalApp(scanFile, nativeLibraryDir);
+ if (copyRet < 0 && copyRet != PackageManager.NO_NATIVE_LIBRARIES) {
Slog.e(TAG, "Unable to copy native libraries");
mLastScanError = PackageManager.INSTALL_FAILED_INTERNAL_ERROR;
return null;
}
+
+ // We've successfully copied native libraries across, so we make a
+ // note of what ABI we're using
+ if (copyRet != PackageManager.NO_NATIVE_LIBRARIES) {
+ pkg.applicationInfo.requiredCpuAbi = Build.SUPPORTED_ABIS[copyRet];
+ } else {
+ pkg.applicationInfo.requiredCpuAbi = null;
+ }
} catch (IOException e) {
Slog.e(TAG, "Unable to copy native libraries", e);
mLastScanError = PackageManager.INSTALL_FAILED_INTERNAL_ERROR;
@@ -5070,6 +5180,29 @@
}
pkgSetting.setTimeStamp(scanFileTime);
+
+ // Create idmap files for pairs of (packages, overlay packages).
+ // Note: "android", ie framework-res.apk, is handled by native layers.
+ if (pkg.mOverlayTarget != null) {
+ // This is an overlay package.
+ if (pkg.mOverlayTarget != null && !pkg.mOverlayTarget.equals("android")) {
+ if (!mOverlays.containsKey(pkg.mOverlayTarget)) {
+ mOverlays.put(pkg.mOverlayTarget,
+ new HashMap<String, PackageParser.Package>());
+ }
+ HashMap<String, PackageParser.Package> map = mOverlays.get(pkg.mOverlayTarget);
+ map.put(pkg.packageName, pkg);
+ PackageParser.Package orig = mPackages.get(pkg.mOverlayTarget);
+ if (orig != null && !createIdmapForPackagePairLI(orig, pkg)) {
+ mLastScanError = PackageManager.INSTALL_FAILED_UPDATE_INCOMPATIBLE;
+ return null;
+ }
+ }
+ } else if (mOverlays.containsKey(pkg.packageName) &&
+ !pkg.packageName.equals("android")) {
+ // This is a regular package, with one or more known overlay packages.
+ createIdmapsForPackageLI(pkg);
+ }
}
return pkg;
@@ -5131,7 +5264,21 @@
* If this is an internal application or our nativeLibraryPath points to
* the app-lib directory, unpack the libraries if necessary.
*/
- return NativeLibraryHelper.copyNativeBinariesIfNeededLI(scanFile, nativeLibraryDir);
+ final NativeLibraryHelper.ApkHandle handle = new NativeLibraryHelper.ApkHandle(scanFile);
+ try {
+ int abi = NativeLibraryHelper.findSupportedAbi(handle, Build.SUPPORTED_ABIS);
+ if (abi >= 0) {
+ int copyRet = NativeLibraryHelper.copyNativeBinariesIfNeededLI(handle,
+ nativeLibraryDir, Build.SUPPORTED_ABIS[abi]);
+ if (copyRet != PackageManager.INSTALL_SUCCEEDED) {
+ return copyRet;
+ }
+ }
+
+ return abi;
+ } finally {
+ handle.close();
+ }
}
private void killApplication(String pkgName, int appId, String reason) {
@@ -8017,7 +8164,7 @@
}
try {
int copyRet = copyNativeLibrariesForInternalApp(codeFile, nativeLibraryFile);
- if (copyRet != PackageManager.INSTALL_SUCCEEDED) {
+ if (copyRet < 0 && copyRet != PackageManager.NO_NATIVE_LIBRARIES) {
return copyRet;
}
} catch (IOException e) {
@@ -10943,6 +11090,10 @@
*/
public void scanAvailableAsecs() {
updateExternalMediaStatusInner(true, false, false);
+ if (mShouldRestoreconData) {
+ SELinuxMMAC.setRestoreconDone();
+ mShouldRestoreconData = false;
+ }
}
/*
@@ -11388,8 +11539,17 @@
final File newNativeDir = new File(newNativePath);
if (!isForwardLocked(pkg) && !isExternal(pkg)) {
- NativeLibraryHelper.copyNativeBinariesIfNeededLI(
- new File(newCodePath), newNativeDir);
+ // NOTE: We do not report any errors from the APK scan and library
+ // copy at this point.
+ NativeLibraryHelper.ApkHandle handle =
+ new NativeLibraryHelper.ApkHandle(newCodePath);
+ final int abi = NativeLibraryHelper.findSupportedAbi(
+ handle, Build.SUPPORTED_ABIS);
+ if (abi >= 0) {
+ NativeLibraryHelper.copyNativeBinariesIfNeededLI(
+ handle, newNativeDir, Build.SUPPORTED_ABIS[abi]);
+ }
+ handle.close();
}
final int[] users = sUserManager.getUserIds();
for (int user : users) {
diff --git a/services/java/com/android/server/pm/PackageSetting.java b/services/java/com/android/server/pm/PackageSetting.java
index b447861..15df3d2 100644
--- a/services/java/com/android/server/pm/PackageSetting.java
+++ b/services/java/com/android/server/pm/PackageSetting.java
@@ -30,8 +30,8 @@
SharedUserSetting sharedUser;
PackageSetting(String name, String realName, File codePath, File resourcePath,
- String nativeLibraryPathString, int pVersionCode, int pkgFlags) {
- super(name, realName, codePath, resourcePath, nativeLibraryPathString, pVersionCode,
+ String nativeLibraryPathString, String requiredCpuAbiString, int pVersionCode, int pkgFlags) {
+ super(name, realName, codePath, resourcePath, nativeLibraryPathString, requiredCpuAbiString, pVersionCode,
pkgFlags);
}
diff --git a/services/java/com/android/server/pm/PackageSettingBase.java b/services/java/com/android/server/pm/PackageSettingBase.java
index 7747c8f..ba95b9a 100644
--- a/services/java/com/android/server/pm/PackageSettingBase.java
+++ b/services/java/com/android/server/pm/PackageSettingBase.java
@@ -53,6 +53,7 @@
File resourcePath;
String resourcePathString;
String nativeLibraryPathString;
+ String requiredCpuAbiString;
long timeStamp;
long firstInstallTime;
long lastUpdateTime;
@@ -80,11 +81,11 @@
/* package name of the app that installed this package */
String installerPackageName;
PackageSettingBase(String name, String realName, File codePath, File resourcePath,
- String nativeLibraryPathString, int pVersionCode, int pkgFlags) {
+ String nativeLibraryPathString, String requiredCpuAbiString, int pVersionCode, int pkgFlags) {
super(pkgFlags);
this.name = name;
this.realName = realName;
- init(codePath, resourcePath, nativeLibraryPathString, pVersionCode);
+ init(codePath, resourcePath, nativeLibraryPathString, requiredCpuAbiString, pVersionCode);
}
/**
@@ -101,6 +102,7 @@
resourcePath = base.resourcePath;
resourcePathString = base.resourcePathString;
nativeLibraryPathString = base.nativeLibraryPathString;
+ requiredCpuAbiString = base.requiredCpuAbiString;
timeStamp = base.timeStamp;
firstInstallTime = base.firstInstallTime;
lastUpdateTime = base.lastUpdateTime;
@@ -128,12 +130,13 @@
}
void init(File codePath, File resourcePath, String nativeLibraryPathString,
- int pVersionCode) {
+ String requiredCpuAbiString, int pVersionCode) {
this.codePath = codePath;
this.codePathString = codePath.toString();
this.resourcePath = resourcePath;
this.resourcePathString = resourcePath.toString();
this.nativeLibraryPathString = nativeLibraryPathString;
+ this.requiredCpuAbiString = requiredCpuAbiString;
this.versionCode = pVersionCode;
}
@@ -164,6 +167,7 @@
grantedPermissions = base.grantedPermissions;
gids = base.gids;
+ requiredCpuAbiString = base.requiredCpuAbiString;
timeStamp = base.timeStamp;
firstInstallTime = base.firstInstallTime;
lastUpdateTime = base.lastUpdateTime;
diff --git a/services/java/com/android/server/pm/PendingPackage.java b/services/java/com/android/server/pm/PendingPackage.java
index c17cc46..36c3a34 100644
--- a/services/java/com/android/server/pm/PendingPackage.java
+++ b/services/java/com/android/server/pm/PendingPackage.java
@@ -22,8 +22,8 @@
final int sharedId;
PendingPackage(String name, String realName, File codePath, File resourcePath,
- String nativeLibraryPathString, int sharedId, int pVersionCode, int pkgFlags) {
- super(name, realName, codePath, resourcePath, nativeLibraryPathString, pVersionCode,
+ String nativeLibraryPathString, String requiredCpuAbiString, int sharedId, int pVersionCode, int pkgFlags) {
+ super(name, realName, codePath, resourcePath, nativeLibraryPathString, requiredCpuAbiString, pVersionCode,
pkgFlags);
this.sharedId = sharedId;
}
diff --git a/services/java/com/android/server/pm/SELinuxMMAC.java b/services/java/com/android/server/pm/SELinuxMMAC.java
index 1d68afa..af7153f 100644
--- a/services/java/com/android/server/pm/SELinuxMMAC.java
+++ b/services/java/com/android/server/pm/SELinuxMMAC.java
@@ -25,11 +25,16 @@
import com.android.internal.util.XmlUtils;
+import libcore.io.IoUtils;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
@@ -60,6 +65,13 @@
new File(Environment.getRootDirectory(), "etc/security/mac_permissions.xml"),
null};
+ // Location of seapp_contexts policy file.
+ private static final String SEAPP_CONTEXTS_FILE = "/seapp_contexts";
+
+ // Stores the hash of the last used seapp_contexts file.
+ private static final String SEAPP_HASH_FILE =
+ Environment.getDataDirectory().toString() + "/system/seapp_hash";
+
// Signature policy stanzas
static class Policy {
private String seinfo;
@@ -103,7 +115,6 @@
/**
* Parses an MMAC install policy from a predefined list of locations.
- * @param none
* @return boolean indicating whether an install policy was correctly parsed.
*/
public static boolean readInstallPolicy() {
@@ -113,7 +124,7 @@
/**
* Parses an MMAC install policy given as an argument.
- * @param File object representing the path of the policy.
+ * @param policyFile object representing the path of the policy.
* @return boolean indicating whether the install policy was correctly parsed.
*/
public static boolean readInstallPolicy(File policyFile) {
@@ -345,8 +356,7 @@
/**
* Labels a package based on an seinfo tag from install policy.
* The label is attached to the ApplicationInfo instance of the package.
- * @param PackageParser.Package object representing the package
- * to labeled.
+ * @param pkg object representing the package to be labeled.
* @return boolean which determines whether a non null seinfo label
* was assigned to the package. A null value simply meaning that
* no policy matched.
@@ -391,4 +401,89 @@
return (sDefaultSeinfo != null);
}
+
+ /**
+ * Determines if a recursive restorecon on /data/data and /data/user is needed.
+ * It does this by comparing the SHA-1 of the seapp_contexts file against the
+ * stored hash at /data/system/seapp_hash.
+ *
+ * @return Returns true if the restorecon should occur or false otherwise.
+ */
+ public static boolean shouldRestorecon() {
+ // Any error with the seapp_contexts file should be fatal
+ byte[] currentHash = null;
+ try {
+ currentHash = returnHash(SEAPP_CONTEXTS_FILE);
+ } catch (IOException ioe) {
+ Slog.e(TAG, "Error with hashing seapp_contexts.", ioe);
+ return false;
+ }
+
+ // Push past any error with the stored hash file
+ byte[] storedHash = null;
+ try {
+ storedHash = IoUtils.readFileAsByteArray(SEAPP_HASH_FILE);
+ } catch (IOException ioe) {
+ Slog.w(TAG, "Error opening " + SEAPP_HASH_FILE + ". Assuming first boot.");
+ }
+
+ return (storedHash == null || !MessageDigest.isEqual(storedHash, currentHash));
+ }
+
+ /**
+ * Stores the SHA-1 of the seapp_contexts to /data/system/seapp_hash.
+ */
+ public static void setRestoreconDone() {
+ try {
+ final byte[] currentHash = returnHash(SEAPP_CONTEXTS_FILE);
+ dumpHash(new File(SEAPP_HASH_FILE), currentHash);
+ } catch (IOException ioe) {
+ Slog.e(TAG, "Error with saving hash to " + SEAPP_HASH_FILE, ioe);
+ }
+ }
+
+ /**
+ * Dump the contents of a byte array to a specified file.
+ *
+ * @param file The file that receives the byte array content.
+ * @param content A byte array that will be written to the specified file.
+ * @throws IOException if any failed I/O operation occured.
+ * Included is the failure to atomically rename the tmp
+ * file used in the process.
+ */
+ private static void dumpHash(File file, byte[] content) throws IOException {
+ FileOutputStream fos = null;
+ File tmp = null;
+ try {
+ tmp = File.createTempFile("seapp_hash", ".journal", file.getParentFile());
+ tmp.setReadable(true);
+ fos = new FileOutputStream(tmp);
+ fos.write(content);
+ fos.getFD().sync();
+ if (!tmp.renameTo(file)) {
+ throw new IOException("Failure renaming " + file.getCanonicalPath());
+ }
+ } finally {
+ if (tmp != null) {
+ tmp.delete();
+ }
+ IoUtils.closeQuietly(fos);
+ }
+ }
+
+ /**
+ * Return the SHA-1 of a file.
+ *
+ * @param file The path to the file given as a string.
+ * @return Returns the SHA-1 of the file as a byte array.
+ * @throws IOException if any failed I/O operations occured.
+ */
+ private static byte[] returnHash(String file) throws IOException {
+ try {
+ final byte[] contents = IoUtils.readFileAsByteArray(file);
+ return MessageDigest.getInstance("SHA-1").digest(contents);
+ } catch (NoSuchAlgorithmException nsae) {
+ throw new RuntimeException(nsae); // impossible
+ }
+ }
}
diff --git a/services/java/com/android/server/pm/Settings.java b/services/java/com/android/server/pm/Settings.java
index e599409..a50c689 100644
--- a/services/java/com/android/server/pm/Settings.java
+++ b/services/java/com/android/server/pm/Settings.java
@@ -213,10 +213,10 @@
PackageSetting getPackageLPw(PackageParser.Package pkg, PackageSetting origPackage,
String realName, SharedUserSetting sharedUser, File codePath, File resourcePath,
- String nativeLibraryPathString, int pkgFlags, UserHandle user, boolean add) {
+ String nativeLibraryPathString, String requiredCpuAbiString, int pkgFlags, UserHandle user, boolean add) {
final String name = pkg.packageName;
PackageSetting p = getPackageLPw(name, origPackage, realName, sharedUser, codePath,
- resourcePath, nativeLibraryPathString, pkg.mVersionCode, pkgFlags,
+ resourcePath, nativeLibraryPathString, requiredCpuAbiString, pkg.mVersionCode, pkgFlags,
user, add, true /* allowInstall */);
return p;
}
@@ -298,7 +298,7 @@
p.pkg.applicationInfo.flags &= ~ApplicationInfo.FLAG_UPDATED_SYSTEM_APP;
}
PackageSetting ret = addPackageLPw(name, p.realName, p.codePath, p.resourcePath,
- p.nativeLibraryPathString, p.appId, p.versionCode, p.pkgFlags);
+ p.nativeLibraryPathString, p.requiredCpuAbiString, p.appId, p.versionCode, p.pkgFlags);
mDisabledSysPackages.remove(name);
return ret;
}
@@ -312,7 +312,7 @@
}
PackageSetting addPackageLPw(String name, String realName, File codePath, File resourcePath,
- String nativeLibraryPathString, int uid, int vc, int pkgFlags) {
+ String nativeLibraryPathString, String requiredCpuAbiString, int uid, int vc, int pkgFlags) {
PackageSetting p = mPackages.get(name);
if (p != null) {
if (p.appId == uid) {
@@ -322,7 +322,7 @@
"Adding duplicate package, keeping first: " + name);
return null;
}
- p = new PackageSetting(name, realName, codePath, resourcePath, nativeLibraryPathString,
+ p = new PackageSetting(name, realName, codePath, resourcePath, nativeLibraryPathString, requiredCpuAbiString,
vc, pkgFlags);
p.appId = uid;
if (addUserIdLPw(uid, p, name)) {
@@ -391,10 +391,11 @@
private PackageSetting getPackageLPw(String name, PackageSetting origPackage,
String realName, SharedUserSetting sharedUser, File codePath, File resourcePath,
- String nativeLibraryPathString, int vc, int pkgFlags,
+ String nativeLibraryPathString, String requiredCpuAbiString, int vc, int pkgFlags,
UserHandle installUser, boolean add, boolean allowInstall) {
PackageSetting p = mPackages.get(name);
if (p != null) {
+ p.requiredCpuAbiString = requiredCpuAbiString;
if (!p.codePath.equals(codePath)) {
// Check to see if its a disabled system app
if ((p.pkgFlags & ApplicationInfo.FLAG_SYSTEM) != 0) {
@@ -438,7 +439,7 @@
if (origPackage != null) {
// We are consuming the data from an existing package.
p = new PackageSetting(origPackage.name, name, codePath, resourcePath,
- nativeLibraryPathString, vc, pkgFlags);
+ nativeLibraryPathString, requiredCpuAbiString, vc, pkgFlags);
if (PackageManagerService.DEBUG_UPGRADE) Log.v(PackageManagerService.TAG, "Package "
+ name + " is adopting original package " + origPackage.name);
// Note that we will retain the new package's signature so
@@ -455,7 +456,7 @@
p.setTimeStamp(codePath.lastModified());
} else {
p = new PackageSetting(name, realName, codePath, resourcePath,
- nativeLibraryPathString, vc, pkgFlags);
+ nativeLibraryPathString, requiredCpuAbiString, vc, pkgFlags);
p.setTimeStamp(codePath.lastModified());
p.sharedUser = sharedUser;
// If this is not a system app, it starts out stopped.
@@ -581,6 +582,8 @@
&& !nativeLibraryPath.equalsIgnoreCase(p.nativeLibraryPathString)) {
p.nativeLibraryPathString = nativeLibraryPath;
}
+ // Update the required Cpu Abi
+ p.requiredCpuAbiString = pkg.applicationInfo.requiredCpuAbi;
// Update version code if needed
if (pkg.mVersionCode != p.versionCode) {
p.versionCode = pkg.mVersionCode;
@@ -1427,6 +1430,7 @@
// FROM NATIVE CODE. AT THE MOMENT, LOOK AT THE FOLLOWING SOURCES:
// system/core/run-as/run-as.c
// system/core/sdcard/sdcard.c
+ // external/libselinux/src/android.c:package_info_init()
//
sb.setLength(0);
sb.append(ai.packageName);
@@ -1497,6 +1501,9 @@
if (pkg.nativeLibraryPathString != null) {
serializer.attribute(null, "nativeLibraryPath", pkg.nativeLibraryPathString);
}
+ if (pkg.requiredCpuAbiString != null) {
+ serializer.attribute(null, "requiredCpuAbi", pkg.requiredCpuAbiString);
+ }
if (pkg.sharedUser == null) {
serializer.attribute(null, "userId", Integer.toString(pkg.appId));
} else {
@@ -1539,6 +1546,9 @@
if (pkg.nativeLibraryPathString != null) {
serializer.attribute(null, "nativeLibraryPath", pkg.nativeLibraryPathString);
}
+ if (pkg.requiredCpuAbiString != null) {
+ serializer.attribute(null, "requiredCpuAbi", pkg.requiredCpuAbiString);
+ }
serializer.attribute(null, "flags", Integer.toString(pkg.pkgFlags));
serializer.attribute(null, "ft", Long.toHexString(pkg.timeStamp));
serializer.attribute(null, "it", Long.toHexString(pkg.firstInstallTime));
@@ -1803,7 +1813,7 @@
if (idObj != null && idObj instanceof SharedUserSetting) {
PackageSetting p = getPackageLPw(pp.name, null, pp.realName,
(SharedUserSetting) idObj, pp.codePath, pp.resourcePath,
- pp.nativeLibraryPathString, pp.versionCode, pp.pkgFlags,
+ pp.nativeLibraryPathString, pp.requiredCpuAbiString, pp.versionCode, pp.pkgFlags,
null, true /* add */, false /* allowInstall */);
if (p == null) {
PackageManagerService.reportSettingsProblem(Log.WARN,
@@ -2223,6 +2233,8 @@
String codePathStr = parser.getAttributeValue(null, "codePath");
String resourcePathStr = parser.getAttributeValue(null, "resourcePath");
String nativeLibraryPathStr = parser.getAttributeValue(null, "nativeLibraryPath");
+ String requiredCpuAbiString = parser.getAttributeValue(null, "requiredCpuAbi");
+
if (resourcePathStr == null) {
resourcePathStr = codePathStr;
}
@@ -2242,7 +2254,7 @@
pkgFlags |= ApplicationInfo.FLAG_PRIVILEGED;
}
PackageSetting ps = new PackageSetting(name, realName, codePathFile,
- new File(resourcePathStr), nativeLibraryPathStr, versionCode, pkgFlags);
+ new File(resourcePathStr), nativeLibraryPathStr, requiredCpuAbiString, versionCode, pkgFlags);
String timeStampStr = parser.getAttributeValue(null, "ft");
if (timeStampStr != null) {
try {
@@ -2309,6 +2321,7 @@
String codePathStr = null;
String resourcePathStr = null;
String nativeLibraryPathStr = null;
+ String requiredCpuAbiString = null;
String systemStr = null;
String installerPackageName = null;
String uidError = null;
@@ -2328,6 +2341,8 @@
codePathStr = parser.getAttributeValue(null, "codePath");
resourcePathStr = parser.getAttributeValue(null, "resourcePath");
nativeLibraryPathStr = parser.getAttributeValue(null, "nativeLibraryPath");
+ requiredCpuAbiString = parser.getAttributeValue(null, "requiredCpuAbi");
+
version = parser.getAttributeValue(null, "version");
if (version != null) {
try {
@@ -2404,7 +2419,7 @@
+ parser.getPositionDescription());
} else if (userId > 0) {
packageSetting = addPackageLPw(name.intern(), realName, new File(codePathStr),
- new File(resourcePathStr), nativeLibraryPathStr, userId, versionCode,
+ new File(resourcePathStr), nativeLibraryPathStr, requiredCpuAbiString, userId, versionCode,
pkgFlags);
if (PackageManagerService.DEBUG_SETTINGS)
Log.i(PackageManagerService.TAG, "Reading package " + name + ": userId="
@@ -2422,7 +2437,7 @@
userId = sharedIdStr != null ? Integer.parseInt(sharedIdStr) : 0;
if (userId > 0) {
packageSetting = new PendingPackage(name.intern(), realName, new File(
- codePathStr), new File(resourcePathStr), nativeLibraryPathStr, userId,
+ codePathStr), new File(resourcePathStr), nativeLibraryPathStr, requiredCpuAbiString, userId,
versionCode, pkgFlags);
packageSetting.setTimeStamp(timeStamp);
packageSetting.firstInstallTime = firstInstallTime;
@@ -2451,6 +2466,7 @@
packageSetting.uidError = "true".equals(uidError);
packageSetting.installerPackageName = installerPackageName;
packageSetting.nativeLibraryPathString = nativeLibraryPathStr;
+ packageSetting.requiredCpuAbiString = requiredCpuAbiString;
// Handle legacy string here for single-user mode
final String enabledStr = parser.getAttributeValue(null, ATTR_ENABLED);
if (enabledStr != null) {
@@ -2914,6 +2930,7 @@
pw.print(prefix); pw.print(" codePath="); pw.println(ps.codePathString);
pw.print(prefix); pw.print(" resourcePath="); pw.println(ps.resourcePathString);
pw.print(prefix); pw.print(" nativeLibraryPath="); pw.println(ps.nativeLibraryPathString);
+ pw.print(prefix); pw.print(" requiredCpuAbi="); pw.println(ps.requiredCpuAbiString);
pw.print(prefix); pw.print(" versionCode="); pw.print(ps.versionCode);
if (ps.pkg != null) {
pw.print(" targetSdk="); pw.print(ps.pkg.applicationInfo.targetSdkVersion);
diff --git a/services/java/com/android/server/usb/UsbDeviceManager.java b/services/java/com/android/server/usb/UsbDeviceManager.java
index 5a60de0..5f07517 100644
--- a/services/java/com/android/server/usb/UsbDeviceManager.java
+++ b/services/java/com/android/server/usb/UsbDeviceManager.java
@@ -573,14 +573,19 @@
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
intent.putExtra("state", (enabled ? 1 : 0));
if (enabled) {
+ Scanner scanner = null;
try {
- Scanner scanner = new Scanner(new File(AUDIO_SOURCE_PCM_PATH));
+ scanner = new Scanner(new File(AUDIO_SOURCE_PCM_PATH));
int card = scanner.nextInt();
int device = scanner.nextInt();
intent.putExtra("card", card);
intent.putExtra("device", device);
} catch (FileNotFoundException e) {
Slog.e(TAG, "could not open audio source PCM file", e);
+ } finally {
+ if (scanner != null) {
+ scanner.close();
+ }
}
}
mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
diff --git a/services/java/com/android/server/wm/ScreenRotationAnimation.java b/services/java/com/android/server/wm/ScreenRotationAnimation.java
index e630737..f79896b 100644
--- a/services/java/com/android/server/wm/ScreenRotationAnimation.java
+++ b/services/java/com/android/server/wm/ScreenRotationAnimation.java
@@ -199,7 +199,8 @@
}
public ScreenRotationAnimation(Context context, DisplayContent displayContent,
- SurfaceSession session, boolean inTransaction, boolean forceDefaultOrientation) {
+ SurfaceSession session, boolean inTransaction, boolean forceDefaultOrientation,
+ boolean isSecure) {
mContext = context;
mDisplayContent = displayContent;
displayContent.getLogicalDisplayRect(mOriginalDisplayRect);
@@ -241,16 +242,21 @@
try {
try {
+ int flags = SurfaceControl.HIDDEN;
+ if (isSecure) {
+ flags |= SurfaceControl.SECURE;
+ }
+
if (WindowManagerService.DEBUG_SURFACE_TRACE) {
mSurfaceControl = new SurfaceTrace(session, "ScreenshotSurface",
mWidth, mHeight,
- PixelFormat.OPAQUE, SurfaceControl.HIDDEN);
+ PixelFormat.OPAQUE, flags);
Slog.w(TAG, "ScreenRotationAnimation ctor: displayOffset="
+ mOriginalDisplayRect.toShortString());
} else {
mSurfaceControl = new SurfaceControl(session, "ScreenshotSurface",
mWidth, mHeight,
- PixelFormat.OPAQUE, SurfaceControl.HIDDEN);
+ PixelFormat.OPAQUE, flags);
}
// capture a screenshot into the surface we just created
Surface sur = new Surface();
diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java
index 6d47fcf..b6c6770 100644
--- a/services/java/com/android/server/wm/WindowManagerService.java
+++ b/services/java/com/android/server/wm/WindowManagerService.java
@@ -2373,6 +2373,11 @@
}
public void removeWindowLocked(Session session, WindowState win) {
+ removeWindowLocked(session, win, false);
+ }
+
+ private void removeWindowLocked(Session session, WindowState win,
+ boolean forceRemove) {
if (win.mAttrs.type == TYPE_APPLICATION_STARTING) {
if (DEBUG_STARTING_WINDOW) Slog.d(TAG, "Starting window removed " + win);
removeStartingWindowTimeout(win.mAppToken);
@@ -2423,7 +2428,7 @@
mDisplayMagnifier.onWindowTransitionLocked(win, transit);
}
}
- if (win.mExiting || win.mWinAnimator.isAnimating()) {
+ if (!forceRemove && (win.mExiting || win.mWinAnimator.isAnimating())) {
// The exit animation is running... wait for it!
//Slog.i(TAG, "*** Running exit animation...");
win.mExiting = true;
@@ -3480,8 +3485,9 @@
Task newTask = mTaskIdToTask.get(groupId);
if (newTask == null) {
newTask = createTask(groupId, oldTask.mStack.mStackId, oldTask.mUserId, atoken);
+ } else {
+ newTask.mAppTokens.add(atoken);
}
- newTask.mAppTokens.add(atoken);
}
}
@@ -9920,9 +9926,21 @@
screenRotationAnimation.kill();
}
+ // Check whether the current screen contains any secure content.
+ boolean isSecure = false;
+ final WindowList windows = getDefaultWindowListLocked();
+ final int N = windows.size();
+ for (int i = 0; i < N; i++) {
+ WindowState ws = windows.get(i);
+ if (ws.isOnScreen() && (ws.mAttrs.flags & FLAG_SECURE) != 0) {
+ isSecure = true;
+ break;
+ }
+ }
+
// TODO(multidisplay): rotation on main screen only.
screenRotationAnimation = new ScreenRotationAnimation(mContext, displayContent,
- mFxSession, inTransaction, mPolicy.isDefaultOrientationForced());
+ mFxSession, inTransaction, mPolicy.isDefaultOrientationForced(), isSecure);
mAnimator.setScreenRotationAnimationLocked(displayId, screenRotationAnimation);
}
}
@@ -10839,7 +10857,7 @@
WindowList windows = displayContent.getWindowList();
while (!windows.isEmpty()) {
final WindowState win = windows.get(windows.size() - 1);
- removeWindowLocked(win.mSession, win);
+ removeWindowLocked(win.mSession, win, true);
}
}
mAnimator.removeDisplayLocked(displayId);
diff --git a/services/jni/com_android_server_AlarmManagerService.cpp b/services/jni/com_android_server_AlarmManagerService.cpp
index 342515b..a58b00bce 100644
--- a/services/jni/com_android_server_AlarmManagerService.cpp
+++ b/services/jni/com_android_server_AlarmManagerService.cpp
@@ -36,6 +36,7 @@
#include <unistd.h>
#include <linux/ioctl.h>
#include <linux/android_alarm.h>
+#include <linux/rtc.h>
namespace android {
@@ -58,6 +59,7 @@
virtual ~AlarmImpl();
virtual int set(int type, struct timespec *ts) = 0;
+ virtual int setTime(struct timeval *tv) = 0;
virtual int waitForAlarm() = 0;
protected:
@@ -71,6 +73,7 @@
AlarmImplAlarmDriver(int fd) : AlarmImpl(&fd, 1) { }
int set(int type, struct timespec *ts);
+ int setTime(struct timeval *tv);
int waitForAlarm();
};
@@ -82,6 +85,7 @@
~AlarmImplTimerFd();
int set(int type, struct timespec *ts);
+ int setTime(struct timeval *tv);
int waitForAlarm();
private:
@@ -107,6 +111,19 @@
return ioctl(fds[0], ANDROID_ALARM_SET(type), ts);
}
+int AlarmImplAlarmDriver::setTime(struct timeval *tv)
+{
+ struct timespec ts;
+ int res;
+
+ ts.tv_sec = tv->tv_sec;
+ ts.tv_nsec = tv->tv_usec * 1000;
+ res = ioctl(fds[0], ANDROID_ALARM_SET_RTC, &ts);
+ if (res < 0)
+ ALOGV("ANDROID_ALARM_SET_RTC ioctl failed: %s\n", strerror(errno));
+ return res;
+}
+
int AlarmImplAlarmDriver::waitForAlarm()
{
return ioctl(fds[0], ANDROID_ALARM_WAIT);
@@ -140,6 +157,50 @@
return timerfd_settime(fds[type], TFD_TIMER_ABSTIME, &spec, NULL);
}
+int AlarmImplTimerFd::setTime(struct timeval *tv)
+{
+ struct rtc_time rtc;
+ struct tm tm, *gmtime_res;
+ int fd;
+ int res;
+
+ res = settimeofday(tv, NULL);
+ if (res < 0) {
+ ALOGV("settimeofday() failed: %s\n", strerror(errno));
+ return -1;
+ }
+
+ fd = open("/dev/rtc0", O_RDWR);
+ if (fd < 0) {
+ ALOGV("Unable to open RTC driver: %s\n", strerror(errno));
+ return res;
+ }
+
+ gmtime_res = gmtime_r(&tv->tv_sec, &tm);
+ if (!gmtime_res) {
+ ALOGV("gmtime_r() failed: %s\n", strerror(errno));
+ res = -1;
+ goto done;
+ }
+
+ memset(&rtc, 0, sizeof(rtc));
+ rtc.tm_sec = tm.tm_sec;
+ rtc.tm_min = tm.tm_min;
+ rtc.tm_hour = tm.tm_hour;
+ rtc.tm_mday = tm.tm_mday;
+ rtc.tm_mon = tm.tm_mon;
+ rtc.tm_year = tm.tm_year;
+ rtc.tm_wday = tm.tm_wday;
+ rtc.tm_yday = tm.tm_yday;
+ rtc.tm_isdst = tm.tm_isdst;
+ res = ioctl(fd, RTC_SET_TIME, &rtc);
+ if (res < 0)
+ ALOGV("RTC_SET_TIME ioctl failed: %s\n", strerror(errno));
+done:
+ close(fd);
+ return res;
+}
+
int AlarmImplTimerFd::waitForAlarm()
{
epoll_event events[N_ANDROID_TIMERFDS];
@@ -168,6 +229,30 @@
return result;
}
+static jint android_server_AlarmManagerService_setKernelTime(JNIEnv*, jobject, jlong nativeData, jlong millis)
+{
+ AlarmImpl *impl = reinterpret_cast<AlarmImpl *>(nativeData);
+ struct timeval tv;
+ int ret;
+
+ if (millis <= 0 || millis / 1000LL >= INT_MAX) {
+ return -1;
+ }
+
+ tv.tv_sec = (time_t) (millis / 1000LL);
+ tv.tv_usec = (suseconds_t) ((millis % 1000LL) * 1000LL);
+
+ ALOGD("Setting time of day to sec=%d\n", (int) tv.tv_sec);
+
+ ret = impl->setTime(&tv);
+
+ if(ret < 0) {
+ ALOGW("Unable to set rtc to %ld: %s\n", tv.tv_sec, strerror(errno));
+ ret = -1;
+ }
+ return ret;
+}
+
static jint android_server_AlarmManagerService_setKernelTimezone(JNIEnv*, jobject, jlong, jint minswest)
{
struct timezone tz;
@@ -280,7 +365,9 @@
int result = impl->set(type, &ts);
if (result < 0)
{
- ALOGE("Unable to set alarm to %lld.%09lld: %s\n", seconds, nanoseconds, strerror(errno));
+ ALOGE("Unable to set alarm to %lld.%09lld: %s\n",
+ static_cast<long long>(seconds),
+ static_cast<long long>(nanoseconds), strerror(errno));
}
}
@@ -309,6 +396,7 @@
{"close", "(J)V", (void*)android_server_AlarmManagerService_close},
{"set", "(JIJJ)V", (void*)android_server_AlarmManagerService_set},
{"waitForAlarm", "(J)I", (void*)android_server_AlarmManagerService_waitForAlarm},
+ {"setKernelTime", "(JJ)I", (void*)android_server_AlarmManagerService_setKernelTime},
{"setKernelTimezone", "(JI)I", (void*)android_server_AlarmManagerService_setKernelTimezone},
};
diff --git a/services/jni/com_android_server_AssetAtlasService.cpp b/services/jni/com_android_server_AssetAtlasService.cpp
index 885d21e..163692b 100644
--- a/services/jni/com_android_server_AssetAtlasService.cpp
+++ b/services/jni/com_android_server_AssetAtlasService.cpp
@@ -54,11 +54,11 @@
jfieldID mNativeCanvas;
} gCanvasFinalizerClassInfo;
-#define GET_INT(object, field) \
- env->GetIntField(object, field)
+#define GET_LONG(object, field) \
+ env->GetLongField(object, field)
-#define SET_INT(object, field, value) \
- env->SetIntField(object, field, value)
+#define SET_LONG(object, field, value) \
+ env->SetLongField(object, field, value)
// ----------------------------------------------------------------------------
// Canvas management
@@ -67,13 +67,13 @@
static inline void swapCanvasPtr(JNIEnv* env, jobject canvasObj, SkCanvas* newCanvas) {
jobject canvasFinalizerObj = env->GetObjectField(canvasObj, gCanvasClassInfo.mFinalizer);
SkCanvas* previousCanvas = reinterpret_cast<SkCanvas*>(
- GET_INT(canvasObj, gCanvasClassInfo.mNativeCanvas));
- SET_INT(canvasObj, gCanvasClassInfo.mNativeCanvas, (int) newCanvas);
- SET_INT(canvasFinalizerObj, gCanvasFinalizerClassInfo.mNativeCanvas, (int) newCanvas);
+ GET_LONG(canvasObj, gCanvasClassInfo.mNativeCanvas));
+ SET_LONG(canvasObj, gCanvasClassInfo.mNativeCanvas, (long) newCanvas);
+ SET_LONG(canvasFinalizerObj, gCanvasFinalizerClassInfo.mNativeCanvas, (long) newCanvas);
SkSafeUnref(previousCanvas);
}
-static SkBitmap* com_android_server_AssetAtlasService_acquireCanvas(JNIEnv* env, jobject,
+static jlong com_android_server_AssetAtlasService_acquireCanvas(JNIEnv* env, jobject,
jobject canvas, jint width, jint height) {
SkBitmap* bitmap = new SkBitmap;
@@ -84,12 +84,13 @@
SkCanvas* nativeCanvas = SkNEW_ARGS(SkCanvas, (*bitmap));
swapCanvasPtr(env, canvas, nativeCanvas);
- return bitmap;
+ return reinterpret_cast<jlong>(bitmap);
}
static void com_android_server_AssetAtlasService_releaseCanvas(JNIEnv* env, jobject,
- jobject canvas, SkBitmap* bitmap) {
+ jobject canvas, jlong bitmapHandle) {
+ SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
SkCanvas* nativeCanvas = SkNEW(SkCanvas);
swapCanvasPtr(env, canvas, nativeCanvas);
@@ -108,21 +109,22 @@
return result;
static jboolean com_android_server_AssetAtlasService_upload(JNIEnv* env, jobject,
- jobject graphicBuffer, SkBitmap* bitmap) {
+ jobject graphicBuffer, jlong bitmapHandle) {
+ SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
// The goal of this method is to copy the bitmap into the GraphicBuffer
// using the GPU to swizzle the texture content
sp<GraphicBuffer> buffer(graphicBufferForJavaObject(env, graphicBuffer));
if (buffer != NULL) {
EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
- if (display == EGL_NO_DISPLAY) return false;
+ if (display == EGL_NO_DISPLAY) return JNI_FALSE;
EGLint major;
EGLint minor;
if (!eglInitialize(display, &major, &minor)) {
ALOGW("Could not initialize EGL");
- return false;
+ return JNI_FALSE;
}
// We're going to use a 1x1 pbuffer surface later on
@@ -143,13 +145,13 @@
ALOGW("Could not select EGL configuration");
eglReleaseThread();
eglTerminate(display);
- return false;
+ return JNI_FALSE;
}
if (configCount <= 0) {
ALOGW("Could not find EGL configuration");
eglReleaseThread();
eglTerminate(display);
- return false;
+ return JNI_FALSE;
}
// These objects are initialized below but the default "null"
@@ -164,7 +166,7 @@
EGLContext context = eglCreateContext(display, configs[0], EGL_NO_CONTEXT, attrs);
if (context == EGL_NO_CONTEXT) {
ALOGW("Could not create EGL context");
- CLEANUP_GL_AND_RETURN(false);
+ CLEANUP_GL_AND_RETURN(JNI_FALSE);
}
// Create the 1x1 pbuffer
@@ -172,12 +174,12 @@
surface = eglCreatePbufferSurface(display, configs[0], surfaceAttrs);
if (surface == EGL_NO_SURFACE) {
ALOGW("Could not create EGL surface");
- CLEANUP_GL_AND_RETURN(false);
+ CLEANUP_GL_AND_RETURN(JNI_FALSE);
}
if (!eglMakeCurrent(display, surface, surface, context)) {
ALOGW("Could not change current EGL context");
- CLEANUP_GL_AND_RETURN(false);
+ CLEANUP_GL_AND_RETURN(JNI_FALSE);
}
// We use an EGLImage to access the content of the GraphicBuffer
@@ -188,7 +190,7 @@
EGL_NATIVE_BUFFER_ANDROID, clientBuffer, imageAttrs);
if (image == EGL_NO_IMAGE_KHR) {
ALOGW("Could not create EGL image");
- CLEANUP_GL_AND_RETURN(false);
+ CLEANUP_GL_AND_RETURN(JNI_FALSE);
}
glGenTextures(1, &texture);
@@ -196,7 +198,7 @@
glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image);
if (glGetError() != GL_NO_ERROR) {
ALOGW("Could not create/bind texture");
- CLEANUP_GL_AND_RETURN(false);
+ CLEANUP_GL_AND_RETURN(JNI_FALSE);
}
// Upload the content of the bitmap in the GraphicBuffer
@@ -205,7 +207,7 @@
GL_RGBA, GL_UNSIGNED_BYTE, bitmap->getPixels());
if (glGetError() != GL_NO_ERROR) {
ALOGW("Could not upload to texture");
- CLEANUP_GL_AND_RETURN(false);
+ CLEANUP_GL_AND_RETURN(JNI_FALSE);
}
// The fence is used to wait for the texture upload to finish
@@ -214,7 +216,7 @@
fence = eglCreateSyncKHR(display, EGL_SYNC_FENCE_KHR, NULL);
if (fence == EGL_NO_SYNC_KHR) {
ALOGW("Could not create sync fence %#x", eglGetError());
- CLEANUP_GL_AND_RETURN(false);
+ CLEANUP_GL_AND_RETURN(JNI_FALSE);
}
// The flag EGL_SYNC_FLUSH_COMMANDS_BIT_KHR will trigger a
@@ -223,13 +225,13 @@
EGL_SYNC_FLUSH_COMMANDS_BIT_KHR, FENCE_TIMEOUT);
if (waitStatus != EGL_CONDITION_SATISFIED_KHR) {
ALOGW("Failed to wait for the fence %#x", eglGetError());
- CLEANUP_GL_AND_RETURN(false);
+ CLEANUP_GL_AND_RETURN(JNI_FALSE);
}
- CLEANUP_GL_AND_RETURN(true);
+ CLEANUP_GL_AND_RETURN(JNI_TRUE);
}
- return false;
+ return JNI_FALSE;
}
// ----------------------------------------------------------------------------
@@ -247,11 +249,11 @@
const char* const kClassPathName = "com/android/server/AssetAtlasService";
static JNINativeMethod gMethods[] = {
- { "nAcquireAtlasCanvas", "(Landroid/graphics/Canvas;II)I",
+ { "nAcquireAtlasCanvas", "(Landroid/graphics/Canvas;II)J",
(void*) com_android_server_AssetAtlasService_acquireCanvas },
- { "nReleaseAtlasCanvas", "(Landroid/graphics/Canvas;I)V",
+ { "nReleaseAtlasCanvas", "(Landroid/graphics/Canvas;J)V",
(void*) com_android_server_AssetAtlasService_releaseCanvas },
- { "nUploadAtlas", "(Landroid/view/GraphicBuffer;I)Z",
+ { "nUploadAtlas", "(Landroid/view/GraphicBuffer;J)Z",
(void*) com_android_server_AssetAtlasService_upload },
};
@@ -261,10 +263,10 @@
FIND_CLASS(clazz, "android/graphics/Canvas");
GET_FIELD_ID(gCanvasClassInfo.mFinalizer, clazz, "mFinalizer",
"Landroid/graphics/Canvas$CanvasFinalizer;");
- GET_FIELD_ID(gCanvasClassInfo.mNativeCanvas, clazz, "mNativeCanvas", "I");
+ GET_FIELD_ID(gCanvasClassInfo.mNativeCanvas, clazz, "mNativeCanvas", "J");
FIND_CLASS(clazz, "android/graphics/Canvas$CanvasFinalizer");
- GET_FIELD_ID(gCanvasFinalizerClassInfo.mNativeCanvas, clazz, "mNativeCanvas", "I");
+ GET_FIELD_ID(gCanvasFinalizerClassInfo.mNativeCanvas, clazz, "mNativeCanvas", "J");
return jniRegisterNativeMethods(env, kClassPathName, gMethods, NELEM(gMethods));
}
diff --git a/services/jni/com_android_server_ConsumerIrService.cpp b/services/jni/com_android_server_ConsumerIrService.cpp
index 004c0aa..3a50ff7 100644
--- a/services/jni/com_android_server_ConsumerIrService.cpp
+++ b/services/jni/com_android_server_ConsumerIrService.cpp
@@ -29,7 +29,7 @@
namespace android {
-static jint halOpen(JNIEnv *env, jobject obj) {
+static jlong halOpen(JNIEnv *env, jobject obj) {
hw_module_t const* module;
consumerir_device_t *dev;
int err;
@@ -47,10 +47,10 @@
return 0;
}
- return reinterpret_cast<jint>(dev);
+ return reinterpret_cast<jlong>(dev);
}
-static jint halTransmit(JNIEnv *env, jobject obj, jint halObject,
+static jint halTransmit(JNIEnv *env, jobject obj, jlong halObject,
jint carrierFrequency, jintArray pattern) {
int ret;
@@ -67,8 +67,8 @@
}
static jintArray halGetCarrierFrequencies(JNIEnv *env, jobject obj,
- jint halObject) {
- consumerir_device_t *dev = (consumerir_device_t *) halObject;
+ jlong halObject) {
+ consumerir_device_t *dev = reinterpret_cast<consumerir_device_t*>(halObject);
consumerir_freq_range_t *ranges;
int len;
@@ -101,9 +101,9 @@
}
static JNINativeMethod method_table[] = {
- { "halOpen", "()I", (void *)halOpen },
- { "halTransmit", "(II[I)I", (void *)halTransmit },
- { "halGetCarrierFrequencies", "(I)[I", (void *)halGetCarrierFrequencies},
+ { "halOpen", "()J", (void *)halOpen },
+ { "halTransmit", "(JI[I)I", (void *)halTransmit },
+ { "halGetCarrierFrequencies", "(J)[I", (void *)halGetCarrierFrequencies},
};
int register_android_server_ConsumerIrService(JNIEnv *env) {
diff --git a/services/jni/com_android_server_UsbHostManager.cpp b/services/jni/com_android_server_UsbHostManager.cpp
index f1fa6cf..fc6de60 100644
--- a/services/jni/com_android_server_UsbHostManager.cpp
+++ b/services/jni/com_android_server_UsbHostManager.cpp
@@ -163,8 +163,10 @@
return NULL;
int fd = usb_device_get_fd(device);
- if (fd < 0)
+ if (fd < 0) {
+ usb_device_close(device);
return NULL;
+ }
int newFD = dup(fd);
usb_device_close(device);
diff --git a/telephony/java/android/telephony/CellSignalStrengthCdma.java b/telephony/java/android/telephony/CellSignalStrengthCdma.java
index c945094..46d09f6 100644
--- a/telephony/java/android/telephony/CellSignalStrengthCdma.java
+++ b/telephony/java/android/telephony/CellSignalStrengthCdma.java
@@ -21,7 +21,7 @@
import android.telephony.Rlog;
/**
- * LTE signal strength related information.
+ * Signal strength related information.
*/
public final class CellSignalStrengthCdma extends CellSignalStrength implements Parcelable {
@@ -136,7 +136,7 @@
}
/**
- * Get the LTE signal level as an asu value between 0..97, 99 is unknown
+ * Get the signal level as an asu value between 0..97, 99 is unknown
* Asu is calculated based on 3GPP RSRP. Refer to 3GPP 27.007 (Ver 10.3.0) Sec 8.69
*/
@Override
diff --git a/telephony/java/android/telephony/DisconnectCause.java b/telephony/java/android/telephony/DisconnectCause.java
new file mode 100644
index 0000000..1c75658
--- /dev/null
+++ b/telephony/java/android/telephony/DisconnectCause.java
@@ -0,0 +1,193 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.telephony;
+
+/**
+ * Contains disconnect call causes generated by the
+ * framework and the RIL.
+ *
+ * @hide
+ */
+public class DisconnectCause {
+
+ /** The disconnect cause is not valid (Not received a disconnect cause) */
+ public static final int NOT_VALID = -1;
+ /** Has not yet disconnected */
+ public static final int NOT_DISCONNECTED = 0;
+ /** An incoming call that was missed and never answered */
+ public static final int INCOMING_MISSED = 1;
+ /** Normal; Remote hangup*/
+ public static final int NORMAL = 2;
+ /** Normal; Local hangup */
+ public static final int LOCAL = 3;
+ /** Outgoing call to busy line */
+ public static final int BUSY = 4;
+ /** Outgoing call to congested network */
+ public static final int CONGESTION = 5;
+ /** Not presently used */
+ public static final int MMI = 6;
+ /** Invalid dial string */
+ public static final int INVALID_NUMBER = 7;
+ /** Cannot reach the peer */
+ public static final int NUMBER_UNREACHABLE = 8;
+ /** Cannot reach the server */
+ public static final int SERVER_UNREACHABLE = 9;
+ /** Invalid credentials */
+ public static final int INVALID_CREDENTIALS = 10;
+ /** Calling from out of network is not allowed */
+ public static final int OUT_OF_NETWORK = 11;
+ /** Server error */
+ public static final int SERVER_ERROR = 12;
+ /** Client timed out */
+ public static final int TIMED_OUT = 13;
+ /** Client went out of network range */
+ public static final int LOST_SIGNAL = 14;
+ /** GSM or CDMA ACM limit exceeded */
+ public static final int LIMIT_EXCEEDED = 15;
+ /** An incoming call that was rejected */
+ public static final int INCOMING_REJECTED = 16;
+ /** Radio is turned off explicitly */
+ public static final int POWER_OFF = 17;
+ /** Out of service */
+ public static final int OUT_OF_SERVICE = 18;
+ /** No ICC, ICC locked, or other ICC error */
+ public static final int ICC_ERROR = 19;
+ /** Call was blocked by call barring */
+ public static final int CALL_BARRED = 20;
+ /** Call was blocked by fixed dial number */
+ public static final int FDN_BLOCKED = 21;
+ /** Call was blocked by restricted all voice access */
+ public static final int CS_RESTRICTED = 22;
+ /** Call was blocked by restricted normal voice access */
+ public static final int CS_RESTRICTED_NORMAL = 23;
+ /** Call was blocked by restricted emergency voice access */
+ public static final int CS_RESTRICTED_EMERGENCY = 24;
+ /** Unassigned number */
+ public static final int UNOBTAINABLE_NUMBER = 25;
+ /** MS is locked until next power cycle */
+ public static final int CDMA_LOCKED_UNTIL_POWER_CYCLE = 26;
+ /** Drop call*/
+ public static final int CDMA_DROP = 27;
+ /** INTERCEPT order received, MS state idle entered */
+ public static final int CDMA_INTERCEPT = 28;
+ /** MS has been redirected, call is cancelled */
+ public static final int CDMA_REORDER = 29;
+ /** Service option rejection */
+ public static final int CDMA_SO_REJECT = 30;
+ /** Requested service is rejected, retry delay is set */
+ public static final int CDMA_RETRY_ORDER = 31;
+ /** Unable to obtain access to the CDMA system */
+ public static final int CDMA_ACCESS_FAILURE = 32;
+ /** Not a preempted call */
+ public static final int CDMA_PREEMPTED = 33;
+ /** Not an emergency call */
+ public static final int CDMA_NOT_EMERGENCY = 34;
+ /** Access Blocked by CDMA network */
+ public static final int CDMA_ACCESS_BLOCKED = 35;
+ /** Unknown error or not specified */
+ public static final int ERROR_UNSPECIFIED = 36;
+
+ /** Smallest valid value for call disconnect codes. */
+ public static final int MINIMUM_VALID_VALUE = NOT_DISCONNECTED;
+ /** Largest valid value for call disconnect codes. */
+ public static final int MAXIMUM_VALID_VALUE = ERROR_UNSPECIFIED;
+
+ /** Private constructor to avoid class instantiation. */
+ private DisconnectCause() {
+ // Do nothing.
+ }
+
+ /** Returns descriptive string for the specified disconnect cause. */
+ public static String toString(int cause) {
+ switch (cause) {
+ case NOT_DISCONNECTED:
+ return "NOT_DISCONNECTED";
+ case INCOMING_MISSED:
+ return "INCOMING_MISSED";
+ case NORMAL:
+ return "NORMAL";
+ case LOCAL:
+ return "LOCAL";
+ case BUSY:
+ return "BUSY";
+ case CONGESTION:
+ return "CONGESTION";
+ case INVALID_NUMBER:
+ return "INVALID_NUMBER";
+ case NUMBER_UNREACHABLE:
+ return "NUMBER_UNREACHABLE";
+ case SERVER_UNREACHABLE:
+ return "SERVER_UNREACHABLE";
+ case INVALID_CREDENTIALS:
+ return "INVALID_CREDENTIALS";
+ case OUT_OF_NETWORK:
+ return "OUT_OF_NETWORK";
+ case SERVER_ERROR:
+ return "SERVER_ERROR";
+ case TIMED_OUT:
+ return "TIMED_OUT";
+ case LOST_SIGNAL:
+ return "LOST_SIGNAL";
+ case LIMIT_EXCEEDED:
+ return "LIMIT_EXCEEDED";
+ case INCOMING_REJECTED:
+ return "INCOMING_REJECTED";
+ case POWER_OFF:
+ return "POWER_OFF";
+ case OUT_OF_SERVICE:
+ return "OUT_OF_SERVICE";
+ case ICC_ERROR:
+ return "ICC_ERROR";
+ case CALL_BARRED:
+ return "CALL_BARRED";
+ case FDN_BLOCKED:
+ return "FDN_BLOCKED";
+ case CS_RESTRICTED:
+ return "CS_RESTRICTED";
+ case CS_RESTRICTED_NORMAL:
+ return "CS_RESTRICTED_NORMAL";
+ case CS_RESTRICTED_EMERGENCY:
+ return "CS_RESTRICTED_EMERGENCY";
+ case UNOBTAINABLE_NUMBER:
+ return "UNOBTAINABLE_NUMBER";
+ case CDMA_LOCKED_UNTIL_POWER_CYCLE:
+ return "CDMA_LOCKED_UNTIL_POWER_CYCLE";
+ case CDMA_DROP:
+ return "CDMA_DROP";
+ case CDMA_INTERCEPT:
+ return "CDMA_INTERCEPT";
+ case CDMA_REORDER:
+ return "CDMA_REORDER";
+ case CDMA_SO_REJECT:
+ return "CDMA_SO_REJECT";
+ case CDMA_RETRY_ORDER:
+ return "CDMA_RETRY_ORDER";
+ case CDMA_ACCESS_FAILURE:
+ return "CDMA_ACCESS_FAILURE";
+ case CDMA_PREEMPTED:
+ return "CDMA_PREEMPTED";
+ case CDMA_NOT_EMERGENCY:
+ return "CDMA_NOT_EMERGENCY";
+ case CDMA_ACCESS_BLOCKED:
+ return "CDMA_ACCESS_BLOCKED";
+ case ERROR_UNSPECIFIED:
+ return "ERROR_UNSPECIFIED";
+ default:
+ return "INVALID";
+ }
+ }
+}
diff --git a/telephony/java/android/telephony/PhoneStateListener.java b/telephony/java/android/telephony/PhoneStateListener.java
index ff77fc0..538548d 100644
--- a/telephony/java/android/telephony/PhoneStateListener.java
+++ b/telephony/java/android/telephony/PhoneStateListener.java
@@ -24,6 +24,8 @@
import android.telephony.CellLocation;
import android.telephony.CellInfo;
import android.telephony.Rlog;
+import android.telephony.PreciseCallState;
+import android.telephony.PreciseDataConnectionState;
import com.android.internal.telephony.IPhoneStateListener;
@@ -165,6 +167,27 @@
*/
public static final int LISTEN_CELL_INFO = 0x00000400;
+ /**
+ * Listen for precise changes and fails to the device calls (cellular).
+ * {@more}
+ * Requires Permission: {@link android.Manifest.permission#READ_PRECISE_PHONE_STATE
+ * READ_PRECISE_PHONE_STATE}
+ *
+ * @hide
+ */
+ public static final int LISTEN_PRECISE_CALL_STATE = 0x00000800;
+
+ /**
+ * Listen for precise changes and fails on the data connection (cellular).
+ * {@more}
+ * Requires Permission: {@link android.Manifest.permission#READ_PRECISE_PHONE_STATE
+ * READ_PRECISE_PHONE_STATE}
+ *
+ * @see #onPreciseDataConnectionStateChanged
+ * @hide
+ */
+ public static final int LISTEN_PRECISE_DATA_CONNECTION_STATE = 0x00001000;
+
public PhoneStateListener() {
}
@@ -293,6 +316,25 @@
}
/**
+ * Callback invoked when precise device call state changes.
+ *
+ * @hide
+ */
+ public void onPreciseCallStateChanged(PreciseCallState callState) {
+ // default implementation empty
+ }
+
+ /**
+ * Callback invoked when data connection state changes with precise information.
+ *
+ * @hide
+ */
+ public void onPreciseDataConnectionStateChanged(
+ PreciseDataConnectionState dataConnectionState) {
+ // default implementation empty
+ }
+
+ /**
* The callback methods need to be called on the handler thread where
* this object was created. If the binder did that for us it'd be nice.
*/
@@ -344,6 +386,16 @@
public void onCellInfoChanged(List<CellInfo> cellInfo) {
Message.obtain(mHandler, LISTEN_CELL_INFO, 0, 0, cellInfo).sendToTarget();
}
+
+ public void onPreciseCallStateChanged(PreciseCallState callState) {
+ Message.obtain(mHandler, LISTEN_PRECISE_CALL_STATE, 0, 0, callState).sendToTarget();
+ }
+
+ public void onPreciseDataConnectionStateChanged(
+ PreciseDataConnectionState dataConnectionState) {
+ Message.obtain(mHandler, LISTEN_PRECISE_DATA_CONNECTION_STATE, 0, 0,
+ dataConnectionState).sendToTarget();
+ }
};
Handler mHandler = new Handler() {
@@ -383,6 +435,12 @@
break;
case LISTEN_CELL_INFO:
PhoneStateListener.this.onCellInfoChanged((List<CellInfo>)msg.obj);
+ break;
+ case LISTEN_PRECISE_CALL_STATE:
+ PhoneStateListener.this.onPreciseCallStateChanged((PreciseCallState)msg.obj);
+ break;
+ case LISTEN_PRECISE_DATA_CONNECTION_STATE:
+ PhoneStateListener.this.onPreciseDataConnectionStateChanged((PreciseDataConnectionState)msg.obj);
}
}
};
diff --git a/telephony/java/android/telephony/PreciseCallState.aidl b/telephony/java/android/telephony/PreciseCallState.aidl
new file mode 100644
index 0000000..447f29b
--- /dev/null
+++ b/telephony/java/android/telephony/PreciseCallState.aidl
@@ -0,0 +1,20 @@
+/*
+**
+** Copyright 2014, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+
+package android.telephony;
+
+parcelable PreciseCallState;
\ No newline at end of file
diff --git a/telephony/java/android/telephony/PreciseCallState.java b/telephony/java/android/telephony/PreciseCallState.java
new file mode 100644
index 0000000..a85df15
--- /dev/null
+++ b/telephony/java/android/telephony/PreciseCallState.java
@@ -0,0 +1,311 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.telephony;
+
+import android.os.Bundle;
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.telephony.Rlog;
+import android.telephony.DisconnectCause;
+import android.telephony.PreciseDisconnectCause;
+
+/**
+ * Contains precise call state and call fail causes generated by the
+ * framework and the RIL.
+ *
+ * The following call information is included in returned PreciseCallState:
+ *
+ * <ul>
+ * <li>Ringing call state.
+ * <li>Foreground call state.
+ * <li>Background call state.
+ * <li>Disconnect cause; generated by the framework.
+ * <li>Precise disconnect cause; generated by the RIL.
+ * </ul>
+ *
+ * @hide
+ */
+public class PreciseCallState implements Parcelable {
+
+ /** Call state is not valid (Not received a call state). */
+ public static final int PRECISE_CALL_STATE_NOT_VALID = -1;
+ /** Call state: No activity. */
+ public static final int PRECISE_CALL_STATE_IDLE = 0;
+ /** Call state: Active. */
+ public static final int PRECISE_CALL_STATE_ACTIVE = 1;
+ /** Call state: On hold. */
+ public static final int PRECISE_CALL_STATE_HOLDING = 2;
+ /** Call state: Dialing. */
+ public static final int PRECISE_CALL_STATE_DIALING = 3;
+ /** Call state: Alerting. */
+ public static final int PRECISE_CALL_STATE_ALERTING = 4;
+ /** Call state: Incoming. */
+ public static final int PRECISE_CALL_STATE_INCOMING = 5;
+ /** Call state: Waiting. */
+ public static final int PRECISE_CALL_STATE_WAITING = 6;
+ /** Call state: Disconnected. */
+ public static final int PRECISE_CALL_STATE_DISCONNECTED = 7;
+ /** Call state: Disconnecting. */
+ public static final int PRECISE_CALL_STATE_DISCONNECTING = 8;
+
+ private int mRingingCallState = PRECISE_CALL_STATE_NOT_VALID;
+ private int mForegroundCallState = PRECISE_CALL_STATE_NOT_VALID;
+ private int mBackgroundCallState = PRECISE_CALL_STATE_NOT_VALID;
+ private int mDisconnectCause = DisconnectCause.NOT_VALID;
+ private int mPreciseDisconnectCause = PreciseDisconnectCause.NOT_VALID;
+
+ /**
+ * Constructor
+ *
+ * @hide
+ */
+ public PreciseCallState(int ringingCall, int foregroundCall, int backgroundCall,
+ int disconnectCause, int preciseDisconnectCause) {
+ mRingingCallState = ringingCall;
+ mForegroundCallState = foregroundCall;
+ mBackgroundCallState = backgroundCall;
+ mDisconnectCause = disconnectCause;
+ mPreciseDisconnectCause = preciseDisconnectCause;
+ }
+
+ /**
+ * Empty Constructor
+ *
+ * @hide
+ */
+ public PreciseCallState() {
+ }
+
+ /**
+ * Construct a PreciseCallState object from the given parcel.
+ */
+ private PreciseCallState(Parcel in) {
+ mRingingCallState = in.readInt();
+ mForegroundCallState = in.readInt();
+ mBackgroundCallState = in.readInt();
+ mDisconnectCause = in.readInt();
+ mPreciseDisconnectCause = in.readInt();
+ }
+
+ /**
+ * Get precise ringing call state
+ *
+ * @see PreciseCallState#PRECISE_CALL_STATE_NOT_VALID
+ * @see PreciseCallState#PRECISE_CALL_STATE_IDLE
+ * @see PreciseCallState#PRECISE_CALL_STATE_ACTIVE
+ * @see PreciseCallState#PRECISE_CALL_STATE_HOLDING
+ * @see PreciseCallState#PRECISE_CALL_STATE_DIALING
+ * @see PreciseCallState#PRECISE_CALL_STATE_ALERTING
+ * @see PreciseCallState#PRECISE_CALL_STATE_INCOMING
+ * @see PreciseCallState#PRECISE_CALL_STATE_WAITING
+ * @see PreciseCallState#PRECISE_CALL_STATE_DISCONNECTED
+ * @see PreciseCallState#PRECISE_CALL_STATE_DISCONNECTING
+ */
+ public int getRingingCallState() {
+ return mRingingCallState;
+ }
+
+ /**
+ * Get precise foreground call state
+ *
+ * @see PreciseCallState#PRECISE_CALL_STATE_NOT_VALID
+ * @see PreciseCallState#PRECISE_CALL_STATE_IDLE
+ * @see PreciseCallState#PRECISE_CALL_STATE_ACTIVE
+ * @see PreciseCallState#PRECISE_CALL_STATE_HOLDING
+ * @see PreciseCallState#PRECISE_CALL_STATE_DIALING
+ * @see PreciseCallState#PRECISE_CALL_STATE_ALERTING
+ * @see PreciseCallState#PRECISE_CALL_STATE_INCOMING
+ * @see PreciseCallState#PRECISE_CALL_STATE_WAITING
+ * @see PreciseCallState#PRECISE_CALL_STATE_DISCONNECTED
+ * @see PreciseCallState#PRECISE_CALL_STATE_DISCONNECTING
+ */
+ public int getForegroundCallState() {
+ return mForegroundCallState;
+ }
+
+ /**
+ * Get precise background call state
+ *
+ * @see PreciseCallState#PRECISE_CALL_STATE_NOT_VALID
+ * @see PreciseCallState#PRECISE_CALL_STATE_IDLE
+ * @see PreciseCallState#PRECISE_CALL_STATE_ACTIVE
+ * @see PreciseCallState#PRECISE_CALL_STATE_HOLDING
+ * @see PreciseCallState#PRECISE_CALL_STATE_DIALING
+ * @see PreciseCallState#PRECISE_CALL_STATE_ALERTING
+ * @see PreciseCallState#PRECISE_CALL_STATE_INCOMING
+ * @see PreciseCallState#PRECISE_CALL_STATE_WAITING
+ * @see PreciseCallState#PRECISE_CALL_STATE_DISCONNECTED
+ * @see PreciseCallState#PRECISE_CALL_STATE_DISCONNECTING
+ */
+ public int getBackgroundCallState() {
+ return mBackgroundCallState;
+ }
+
+ /**
+ * Get disconnect cause generated by the framework
+ *
+ * @see DisconnectCause#NOT_VALID
+ * @see DisconnectCause#NOT_DISCONNECTED
+ * @see DisconnectCause#INCOMING_MISSED
+ * @see DisconnectCause#NORMAL
+ * @see DisconnectCause#LOCAL
+ * @see DisconnectCause#BUSY
+ * @see DisconnectCause#CONGESTION
+ * @see DisconnectCause#MMI
+ * @see DisconnectCause#INVALID_NUMBER
+ * @see DisconnectCause#NUMBER_UNREACHABLE
+ * @see DisconnectCause#SERVER_UNREACHABLE
+ * @see DisconnectCause#INVALID_CREDENTIALS
+ * @see DisconnectCause#OUT_OF_NETWORK
+ * @see DisconnectCause#SERVER_ERROR
+ * @see DisconnectCause#TIMED_OUT
+ * @see DisconnectCause#LOST_SIGNAL
+ * @see DisconnectCause#LIMIT_EXCEEDED
+ * @see DisconnectCause#INCOMING_REJECTED
+ * @see DisconnectCause#POWER_OFF
+ * @see DisconnectCause#OUT_OF_SERVICE
+ * @see DisconnectCause#ICC_ERROR
+ * @see DisconnectCause#CALL_BARRED
+ * @see DisconnectCause#FDN_BLOCKED
+ * @see DisconnectCause#CS_RESTRICTED
+ * @see DisconnectCause#CS_RESTRICTED_NORMAL
+ * @see DisconnectCause#CS_RESTRICTED_EMERGENCY
+ * @see DisconnectCause#UNOBTAINABLE_NUMBER
+ * @see DisconnectCause#CDMA_LOCKED_UNTIL_POWER_CYCLE
+ * @see DisconnectCause#CDMA_DROP
+ * @see DisconnectCause#CDMA_INTERCEPT
+ * @see DisconnectCause#CDMA_REORDER
+ * @see DisconnectCause#CDMA_SO_REJECT
+ * @see DisconnectCause#CDMA_RETRY_ORDER
+ * @see DisconnectCause#CDMA_ACCESS_FAILURE
+ * @see DisconnectCause#CDMA_PREEMPTED
+ * @see DisconnectCause#CDMA_NOT_EMERGENCY
+ * @see DisconnectCause#CDMA_ACCESS_BLOCKED
+ * @see DisconnectCause#ERROR_UNSPECIFIED
+ */
+ public int getDisconnectCause() {
+ return mDisconnectCause;
+ }
+
+ /**
+ * Get disconnect cause generated by the RIL
+ *
+ * @see PreciseDisconnectCause#NOT_VALID
+ * @see PreciseDisconnectCause#NO_DISCONNECT_CAUSE_AVAILABLE
+ * @see PreciseDisconnectCause#UNOBTAINABLE_NUMBER
+ * @see PreciseDisconnectCause#NORMAL
+ * @see PreciseDisconnectCause#BUSY
+ * @see PreciseDisconnectCause#NUMBER_CHANGED
+ * @see PreciseDisconnectCause#STATUS_ENQUIRY
+ * @see PreciseDisconnectCause#NORMAL_UNSPECIFIED
+ * @see PreciseDisconnectCause#NO_CIRCUIT_AVAIL
+ * @see PreciseDisconnectCause#TEMPORARY_FAILURE
+ * @see PreciseDisconnectCause#SWITCHING_CONGESTION
+ * @see PreciseDisconnectCause#CHANNEL_NOT_AVAIL
+ * @see PreciseDisconnectCause#QOS_NOT_AVAIL
+ * @see PreciseDisconnectCause#BEARER_NOT_AVAIL
+ * @see PreciseDisconnectCause#ACM_LIMIT_EXCEEDED
+ * @see PreciseDisconnectCause#CALL_BARRED
+ * @see PreciseDisconnectCause#FDN_BLOCKED
+ * @see PreciseDisconnectCause#IMSI_UNKNOWN_IN_VLR
+ * @see PreciseDisconnectCause#IMEI_NOT_ACCEPTED
+ * @see PreciseDisconnectCause#CDMA_LOCKED_UNTIL_POWER_CYCLE
+ * @see PreciseDisconnectCause#CDMA_DROP
+ * @see PreciseDisconnectCause#CDMA_INTERCEPT
+ * @see PreciseDisconnectCause#CDMA_REORDER
+ * @see PreciseDisconnectCause#CDMA_SO_REJECT
+ * @see PreciseDisconnectCause#CDMA_RETRY_ORDER
+ * @see PreciseDisconnectCause#CDMA_ACCESS_FAILURE
+ * @see PreciseDisconnectCause#CDMA_PREEMPTED
+ * @see PreciseDisconnectCause#CDMA_NOT_EMERGENCY
+ * @see PreciseDisconnectCause#CDMA_ACCESS_BLOCKED
+ * @see PreciseDisconnectCause#ERROR_UNSPECIFIED
+ */
+ public int getPreciseDisconnectCause() {
+ return mPreciseDisconnectCause;
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel out, int flags) {
+ out.writeInt(mRingingCallState);
+ out.writeInt(mForegroundCallState);
+ out.writeInt(mBackgroundCallState);
+ out.writeInt(mDisconnectCause);
+ out.writeInt(mPreciseDisconnectCause);
+ }
+
+ public static final Parcelable.Creator<PreciseCallState> CREATOR
+ = new Parcelable.Creator<PreciseCallState>() {
+
+ public PreciseCallState createFromParcel(Parcel in) {
+ return new PreciseCallState(in);
+ }
+
+ public PreciseCallState[] newArray(int size) {
+ return new PreciseCallState[size];
+ }
+ };
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + mRingingCallState;
+ result = prime * result + mForegroundCallState;
+ result = prime * result + mBackgroundCallState;
+ result = prime * result + mDisconnectCause;
+ result = prime * result + mPreciseDisconnectCause;
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ PreciseCallState other = (PreciseCallState) obj;
+ return (mRingingCallState != other.mRingingCallState &&
+ mForegroundCallState != other.mForegroundCallState &&
+ mBackgroundCallState != other.mBackgroundCallState &&
+ mDisconnectCause != other.mDisconnectCause &&
+ mPreciseDisconnectCause != other.mPreciseDisconnectCause);
+ }
+
+ @Override
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+
+ sb.append("Ringing call state: " + mRingingCallState);
+ sb.append(", Foreground call state: " + mForegroundCallState);
+ sb.append(", Background call state: " + mBackgroundCallState);
+ sb.append(", Disconnect cause: " + mDisconnectCause);
+ sb.append(", Precise disconnect cause: " + mPreciseDisconnectCause);
+
+ return sb.toString();
+ }
+}
diff --git a/telephony/java/android/telephony/PreciseDataConnectionState.aidl b/telephony/java/android/telephony/PreciseDataConnectionState.aidl
new file mode 100644
index 0000000..07ad762
--- /dev/null
+++ b/telephony/java/android/telephony/PreciseDataConnectionState.aidl
@@ -0,0 +1,20 @@
+/*
+**
+** Copyright 2014, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+
+package android.telephony;
+
+parcelable PreciseDataConnectionState;
\ No newline at end of file
diff --git a/telephony/java/android/telephony/PreciseDataConnectionState.java b/telephony/java/android/telephony/PreciseDataConnectionState.java
new file mode 100644
index 0000000..87529fe
--- /dev/null
+++ b/telephony/java/android/telephony/PreciseDataConnectionState.java
@@ -0,0 +1,275 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.telephony;
+
+import android.os.Bundle;
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.telephony.Rlog;
+import android.telephony.TelephonyManager;
+import android.net.LinkProperties;
+
+/**
+ * Contains precise data connection state.
+ *
+ * The following data connection information is included in returned PreciseDataConnectionState:
+ *
+ * <ul>
+ * <li>Data connection state.
+ * <li>Network type of the connection.
+ * <li>APN type.
+ * <li>APN.
+ * <li>Data connection change reason.
+ * <li>The properties of the network link.
+ * <li>Data connection fail cause.
+ * </ul>
+ *
+ * @hide
+ */
+public class PreciseDataConnectionState implements Parcelable {
+
+ private int mState = TelephonyManager.DATA_UNKNOWN;
+ private int mNetworkType = TelephonyManager.NETWORK_TYPE_UNKNOWN;
+ private String mAPNType = "";
+ private String mAPN = "";
+ private String mReason = "";
+ private LinkProperties mLinkProperties = null;
+ private String mFailCause = "";
+
+ /**
+ * Constructor
+ *
+ * @hide
+ */
+ public PreciseDataConnectionState(int state, int networkType,
+ String apnType, String apn, String reason,
+ LinkProperties linkProperties, String failCause) {
+ mState = state;
+ mNetworkType = networkType;
+ mAPNType = apnType;
+ mAPN = apn;
+ mReason = reason;
+ mLinkProperties = linkProperties;
+ mFailCause = failCause;
+ }
+
+ /**
+ * Empty Constructor
+ *
+ * @hide
+ */
+ public PreciseDataConnectionState() {
+ }
+
+ /**
+ * Construct a PreciseDataConnectionState object from the given parcel.
+ */
+ private PreciseDataConnectionState(Parcel in) {
+ mState = in.readInt();
+ mNetworkType = in.readInt();
+ mAPNType = in.readString();
+ mAPN = in.readString();
+ mReason = in.readString();
+ mLinkProperties = (LinkProperties)in.readParcelable(null);
+ mFailCause = in.readString();
+ }
+
+ /**
+ * Get data connection state
+ *
+ * @see TelephonyManager#DATA_UNKNOWN
+ * @see TelephonyManager#DATA_DISCONNECTED
+ * @see TelephonyManager#DATA_CONNECTING
+ * @see TelephonyManager#DATA_CONNECTED
+ * @see TelephonyManager#DATA_SUSPENDED
+ */
+ public int getDataConnectionState() {
+ return mState;
+ }
+
+ /**
+ * Get data connection network type
+ *
+ * @see TelephonyManager#NETWORK_TYPE_UNKNOWN
+ * @see TelephonyManager#NETWORK_TYPE_GPRS
+ * @see TelephonyManager#NETWORK_TYPE_EDGE
+ * @see TelephonyManager#NETWORK_TYPE_UMTS
+ * @see TelephonyManager#NETWORK_TYPE_CDMA
+ * @see TelephonyManager#NETWORK_TYPE_EVDO_0
+ * @see TelephonyManager#NETWORK_TYPE_EVDO_A
+ * @see TelephonyManager#NETWORK_TYPE_1xRTT
+ * @see TelephonyManager#NETWORK_TYPE_HSDPA
+ * @see TelephonyManager#NETWORK_TYPE_HSUPA
+ * @see TelephonyManager#NETWORK_TYPE_HSPA
+ * @see TelephonyManager#NETWORK_TYPE_IDEN
+ * @see TelephonyManager#NETWORK_TYPE_EVDO_B
+ * @see TelephonyManager#NETWORK_TYPE_LTE
+ * @see TelephonyManager#NETWORK_TYPE_EHRPD
+ * @see TelephonyManager#NETWORK_TYPE_HSPAP
+ */
+ public int getDataConnectionNetworkType() {
+ return mNetworkType;
+ }
+
+ /**
+ * Get data connection APN type
+ */
+ public String getDataConnectionAPNType() {
+ return mAPNType;
+ }
+
+ /**
+ * Get data connection APN.
+ */
+ public String getDataConnectionAPN() {
+ return mAPN;
+ }
+
+ /**
+ * Get data connection change reason.
+ */
+ public String getDataConnectionChangeReason() {
+ return mReason;
+ }
+
+ /**
+ * Get the properties of the network link.
+ */
+ public LinkProperties getDataConnectionLinkProperties() {
+ return mLinkProperties;
+ }
+
+ /**
+ * Get data connection fail cause, in case there was a failure.
+ */
+ public String getDataConnectionFailCause() {
+ return mFailCause;
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel out, int flags) {
+ out.writeInt(mState);
+ out.writeInt(mNetworkType);
+ out.writeString(mAPNType);
+ out.writeString(mAPN);
+ out.writeString(mReason);
+ out.writeParcelable(mLinkProperties, flags);
+ out.writeString(mFailCause);
+ }
+
+ public static final Parcelable.Creator<PreciseDataConnectionState> CREATOR
+ = new Parcelable.Creator<PreciseDataConnectionState>() {
+
+ public PreciseDataConnectionState createFromParcel(Parcel in) {
+ return new PreciseDataConnectionState(in);
+ }
+
+ public PreciseDataConnectionState[] newArray(int size) {
+ return new PreciseDataConnectionState[size];
+ }
+ };
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + mState;
+ result = prime * result + mNetworkType;
+ result = prime * result + ((mAPNType == null) ? 0 : mAPNType.hashCode());
+ result = prime * result + ((mAPN == null) ? 0 : mAPN.hashCode());
+ result = prime * result + ((mReason == null) ? 0 : mReason.hashCode());
+ result = prime * result + ((mLinkProperties == null) ? 0 : mLinkProperties.hashCode());
+ result = prime * result + ((mFailCause == null) ? 0 : mFailCause.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ PreciseDataConnectionState other = (PreciseDataConnectionState) obj;
+ if (mAPN == null) {
+ if (other.mAPN != null) {
+ return false;
+ }
+ } else if (!mAPN.equals(other.mAPN)) {
+ return false;
+ }
+ if (mAPNType == null) {
+ if (other.mAPNType != null) {
+ return false;
+ }
+ } else if (!mAPNType.equals(other.mAPNType)) {
+ return false;
+ }
+ if (mFailCause == null) {
+ if (other.mFailCause != null) {
+ return false;
+ }
+ } else if (!mFailCause.equals(other.mFailCause)) {
+ return false;
+ }
+ if (mLinkProperties == null) {
+ if (other.mLinkProperties != null) {
+ return false;
+ }
+ } else if (!mLinkProperties.equals(other.mLinkProperties)) {
+ return false;
+ }
+ if (mNetworkType != other.mNetworkType) {
+ return false;
+ }
+ if (mReason == null) {
+ if (other.mReason != null) {
+ return false;
+ }
+ } else if (!mReason.equals(other.mReason)) {
+ return false;
+ }
+ if (mState != other.mState) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+
+ sb.append("Data Connection state: " + mState);
+ sb.append(", Network type: " + mNetworkType);
+ sb.append(", APN type: " + mAPNType);
+ sb.append(", APN: " + mAPN);
+ sb.append(", Change reason: " + mReason);
+ sb.append(", Link properties: " + mLinkProperties);
+ sb.append(", Fail cause: " + mFailCause);
+
+ return sb.toString();
+ }
+}
diff --git a/telephony/java/android/telephony/PreciseDisconnectCause.java b/telephony/java/android/telephony/PreciseDisconnectCause.java
new file mode 100644
index 0000000..54ab19d
--- /dev/null
+++ b/telephony/java/android/telephony/PreciseDisconnectCause.java
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.telephony;
+
+/**
+ * Contains precise disconnect call causes generated by the
+ * framework and the RIL.
+ *
+ * @hide
+ */
+public class PreciseDisconnectCause {
+
+ /** The disconnect cause is not valid (Not received a disconnect cause)*/
+ public static final int NOT_VALID = -1;
+ /** No disconnect cause provided. Generally a local disconnect or an incoming missed call */
+ public static final int NO_DISCONNECT_CAUSE_AVAILABLE = 0;
+ /**
+ * The destination cannot be reached because the number, although valid,
+ * is not currently assigned
+ */
+ public static final int UNOBTAINABLE_NUMBER = 1;
+ /** One of the users involved in the call has requested that the call is cleared */
+ public static final int NORMAL = 16;
+ /** The called user is unable to accept another call */
+ public static final int BUSY = 17;
+ /** The called number is no longer assigned */
+ public static final int NUMBER_CHANGED = 22;
+ /** Provided in response to a STATUS ENQUIRY message */
+ public static final int STATUS_ENQUIRY = 30;
+ /** Reports a normal disconnect only when no other normal cause applies */
+ public static final int NORMAL_UNSPECIFIED = 31;
+ /** There is no channel presently available to handle the call */
+ public static final int NO_CIRCUIT_AVAIL = 34;
+ /**
+ * The network is not functioning correctly and the condition is not likely to last
+ * a long period of time
+ */
+ public static final int TEMPORARY_FAILURE = 41;
+ /** The switching equipment is experiencing a period of high traffic */
+ public static final int SWITCHING_CONGESTION = 42;
+ /** The channel cannot be provided */
+ public static final int CHANNEL_NOT_AVAIL = 44;
+ /** The requested quality of service (ITU-T X.213) cannot be provided */
+ public static final int QOS_NOT_AVAIL = 49;
+ /** The requested bearer capability is not available at this time */
+ public static final int BEARER_NOT_AVAIL = 58;
+ /** The call clearing is due to ACM being greater than or equal to ACMmax */
+ public static final int ACM_LIMIT_EXCEEDED = 68;
+ /** The call is restricted */
+ public static final int CALL_BARRED = 240;
+ /** The call is blocked by the Fixed Dialing Number list */
+ public static final int FDN_BLOCKED = 241;
+ /** The given IMSI is not known at the VLR */
+ /** TS 24.008 cause 4 */
+ public static final int IMSI_UNKNOWN_IN_VLR = 242;
+ /**
+ * The network does not accept emergency call establishment using an IMEI or not accept attach
+ * procedure for emergency services using an IMEI
+ */
+ public static final int IMEI_NOT_ACCEPTED = 243;
+ /** MS is locked until next power cycle */
+ public static final int CDMA_LOCKED_UNTIL_POWER_CYCLE = 1000;
+ /** Drop call*/
+ public static final int CDMA_DROP = 1001;
+ /** INTERCEPT order received, MS state idle entered */
+ public static final int CDMA_INTERCEPT = 1002;
+ /** MS has been redirected, call is cancelled */
+ public static final int CDMA_REORDER = 1003;
+ /** Service option rejection */
+ public static final int CDMA_SO_REJECT = 1004;
+ /** Requested service is rejected, retry delay is set */
+ public static final int CDMA_RETRY_ORDER = 1005;
+ /** Unable to obtain access to the CDMA system */
+ public static final int CDMA_ACCESS_FAILURE = 1006;
+ /** Not a preempted call */
+ public static final int CDMA_PREEMPTED = 1007;
+ /** Not an emergency call */
+ public static final int CDMA_NOT_EMERGENCY = 1008;
+ /** Access Blocked by CDMA network */
+ public static final int CDMA_ACCESS_BLOCKED = 1009;
+ /** Disconnected due to unspecified reasons */
+ public static final int ERROR_UNSPECIFIED = 0xffff;
+
+ /** Private constructor to avoid class instantiation. */
+ private PreciseDisconnectCause() {
+ // Do nothing.
+ }
+}
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index 8f17e72..ea22bc4 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -211,6 +211,267 @@
*/
public static final String EXTRA_INCOMING_NUMBER = "incoming_number";
+ /**
+ * Broadcast intent action indicating that a precise call state
+ * (cellular) on the device has changed.
+ *
+ * <p>
+ * The {@link #EXTRA_RINGING_CALL_STATE} extra indicates the ringing call state.
+ * The {@link #EXTRA_FOREGROUND_CALL_STATE} extra indicates the foreground call state.
+ * The {@link #EXTRA_BACKGROUND_CALL_STATE} extra indicates the background call state.
+ * The {@link #EXTRA_DISCONNECT_CAUSE} extra indicates the disconnect cause.
+ * The {@link #EXTRA_PRECISE_DISCONNECT_CAUSE} extra indicates the precise disconnect cause.
+ *
+ * <p class="note">
+ * Requires the READ_PRECISE_PHONE_STATE permission.
+ *
+ * @see #EXTRA_RINGING_CALL_STATE
+ * @see #EXTRA_FOREGROUND_CALL_STATE
+ * @see #EXTRA_BACKGROUND_CALL_STATE
+ * @see #EXTRA_DISCONNECT_CAUSE
+ * @see #EXTRA_PRECISE_DISCONNECT_CAUSE
+ *
+ * <p class="note">
+ * Requires the READ_PRECISE_PHONE_STATE permission.
+ *
+ * @hide
+ */
+ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
+ public static final String ACTION_PRECISE_CALL_STATE_CHANGED =
+ "android.intent.action.PRECISE_CALL_STATE";
+
+ /**
+ * The lookup key used with the {@link #ACTION_PRECISE_CALL_STATE_CHANGED} broadcast
+ * for an integer containing the state of the current ringing call.
+ *
+ * @see PreciseCallState#PRECISE_CALL_STATE_NOT_VALID
+ * @see PreciseCallState#PRECISE_CALL_STATE_IDLE
+ * @see PreciseCallState#PRECISE_CALL_STATE_ACTIVE
+ * @see PreciseCallState#PRECISE_CALL_STATE_HOLDING
+ * @see PreciseCallState#PRECISE_CALL_STATE_DIALING
+ * @see PreciseCallState#PRECISE_CALL_STATE_ALERTING
+ * @see PreciseCallState#PRECISE_CALL_STATE_INCOMING
+ * @see PreciseCallState#PRECISE_CALL_STATE_WAITING
+ * @see PreciseCallState#PRECISE_CALL_STATE_DISCONNECTED
+ * @see PreciseCallState#PRECISE_CALL_STATE_DISCONNECTING
+ *
+ * <p class="note">
+ * Retrieve with
+ * {@link android.content.Intent#getIntExtra(String name, int defaultValue)}.
+ *
+ * @hide
+ */
+ public static final String EXTRA_RINGING_CALL_STATE = "ringing_state";
+
+ /**
+ * The lookup key used with the {@link #ACTION_PRECISE_CALL_STATE_CHANGED} broadcast
+ * for an integer containing the state of the current foreground call.
+ *
+ * @see PreciseCallState#PRECISE_CALL_STATE_NOT_VALID
+ * @see PreciseCallState#PRECISE_CALL_STATE_IDLE
+ * @see PreciseCallState#PRECISE_CALL_STATE_ACTIVE
+ * @see PreciseCallState#PRECISE_CALL_STATE_HOLDING
+ * @see PreciseCallState#PRECISE_CALL_STATE_DIALING
+ * @see PreciseCallState#PRECISE_CALL_STATE_ALERTING
+ * @see PreciseCallState#PRECISE_CALL_STATE_INCOMING
+ * @see PreciseCallState#PRECISE_CALL_STATE_WAITING
+ * @see PreciseCallState#PRECISE_CALL_STATE_DISCONNECTED
+ * @see PreciseCallState#PRECISE_CALL_STATE_DISCONNECTING
+ *
+ * <p class="note">
+ * Retrieve with
+ * {@link android.content.Intent#getIntExtra(String name, int defaultValue)}.
+ *
+ * @hide
+ */
+ public static final String EXTRA_FOREGROUND_CALL_STATE = "foreground_state";
+
+ /**
+ * The lookup key used with the {@link #ACTION_PRECISE_CALL_STATE_CHANGED} broadcast
+ * for an integer containing the state of the current background call.
+ *
+ * @see PreciseCallState#PRECISE_CALL_STATE_NOT_VALID
+ * @see PreciseCallState#PRECISE_CALL_STATE_IDLE
+ * @see PreciseCallState#PRECISE_CALL_STATE_ACTIVE
+ * @see PreciseCallState#PRECISE_CALL_STATE_HOLDING
+ * @see PreciseCallState#PRECISE_CALL_STATE_DIALING
+ * @see PreciseCallState#PRECISE_CALL_STATE_ALERTING
+ * @see PreciseCallState#PRECISE_CALL_STATE_INCOMING
+ * @see PreciseCallState#PRECISE_CALL_STATE_WAITING
+ * @see PreciseCallState#PRECISE_CALL_STATE_DISCONNECTED
+ * @see PreciseCallState#PRECISE_CALL_STATE_DISCONNECTING
+ *
+ * <p class="note">
+ * Retrieve with
+ * {@link android.content.Intent#getIntExtra(String name, int defaultValue)}.
+ *
+ * @hide
+ */
+ public static final String EXTRA_BACKGROUND_CALL_STATE = "background_state";
+
+ /**
+ * The lookup key used with the {@link #ACTION_PRECISE_CALL_STATE_CHANGED} broadcast
+ * for an integer containing the disconnect cause.
+ *
+ * @see DisconnectCause
+ *
+ * <p class="note">
+ * Retrieve with
+ * {@link android.content.Intent#getIntExtra(String name, int defaultValue)}.
+ *
+ * @hide
+ */
+ public static final String EXTRA_DISCONNECT_CAUSE = "disconnect_cause";
+
+ /**
+ * The lookup key used with the {@link #ACTION_PRECISE_CALL_STATE_CHANGED} broadcast
+ * for an integer containing the disconnect cause provided by the RIL.
+ *
+ * @see PreciseDisconnectCause
+ *
+ * <p class="note">
+ * Retrieve with
+ * {@link android.content.Intent#getIntExtra(String name, int defaultValue)}.
+ *
+ * @hide
+ */
+ public static final String EXTRA_PRECISE_DISCONNECT_CAUSE = "precise_disconnect_cause";
+
+ /**
+ * Broadcast intent action indicating a data connection has changed,
+ * providing precise information about the connection.
+ *
+ * <p>
+ * The {@link #EXTRA_DATA_STATE} extra indicates the connection state.
+ * The {@link #EXTRA_DATA_NETWORK_TYPE} extra indicates the connection network type.
+ * The {@link #EXTRA_DATA_APN_TYPE} extra indicates the APN type.
+ * The {@link #EXTRA_DATA_APN} extra indicates the APN.
+ * The {@link #EXTRA_DATA_CHANGE_REASON} extra indicates the connection change reason.
+ * The {@link #EXTRA_DATA_IFACE_PROPERTIES} extra indicates the connection interface.
+ * The {@link #EXTRA_DATA_FAILURE_CAUSE} extra indicates the connection fail cause.
+ *
+ * <p class="note">
+ * Requires the READ_PRECISE_PHONE_STATE permission.
+ *
+ * @see #EXTRA_DATA_STATE
+ * @see #EXTRA_DATA_NETWORK_TYPE
+ * @see #EXTRA_DATA_APN_TYPE
+ * @see #EXTRA_DATA_APN
+ * @see #EXTRA_DATA_CHANGE_REASON
+ * @see #EXTRA_DATA_IFACE
+ * @see #EXTRA_DATA_FAILURE_CAUSE
+ * @hide
+ */
+ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
+ public static final String ACTION_PRECISE_DATA_CONNECTION_STATE_CHANGED =
+ "android.intent.action.PRECISE_DATA_CONNECTION_STATE_CHANGED";
+
+ /**
+ * The lookup key used with the {@link #ACTION_PRECISE_DATA_CONNECTION_STATE_CHANGED} broadcast
+ * for an integer containing the state of the current data connection.
+ *
+ * @see TelephonyManager#DATA_UNKNOWN
+ * @see TelephonyManager#DATA_DISCONNECTED
+ * @see TelephonyManager#DATA_CONNECTING
+ * @see TelephonyManager#DATA_CONNECTED
+ * @see TelephonyManager#DATA_SUSPENDED
+ *
+ * <p class="note">
+ * Retrieve with
+ * {@link android.content.Intent#getIntExtra(String name, int defaultValue)}.
+ *
+ * @hide
+ */
+ public static final String EXTRA_DATA_STATE = PhoneConstants.STATE_KEY;
+
+ /**
+ * The lookup key used with the {@link #ACTION_PRECISE_DATA_CONNECTION_STATE_CHANGED} broadcast
+ * for an integer containing the network type.
+ *
+ * @see TelephonyManager#NETWORK_TYPE_UNKNOWN
+ * @see TelephonyManager#NETWORK_TYPE_GPRS
+ * @see TelephonyManager#NETWORK_TYPE_EDGE
+ * @see TelephonyManager#NETWORK_TYPE_UMTS
+ * @see TelephonyManager#NETWORK_TYPE_CDMA
+ * @see TelephonyManager#NETWORK_TYPE_EVDO_0
+ * @see TelephonyManager#NETWORK_TYPE_EVDO_A
+ * @see TelephonyManager#NETWORK_TYPE_1xRTT
+ * @see TelephonyManager#NETWORK_TYPE_HSDPA
+ * @see TelephonyManager#NETWORK_TYPE_HSUPA
+ * @see TelephonyManager#NETWORK_TYPE_HSPA
+ * @see TelephonyManager#NETWORK_TYPE_IDEN
+ * @see TelephonyManager#NETWORK_TYPE_EVDO_B
+ * @see TelephonyManager#NETWORK_TYPE_LTE
+ * @see TelephonyManager#NETWORK_TYPE_EHRPD
+ * @see TelephonyManager#NETWORK_TYPE_HSPAP
+ *
+ * <p class="note">
+ * Retrieve with
+ * {@link android.content.Intent#getIntExtra(String name, int defaultValue)}.
+ *
+ * @hide
+ */
+ public static final String EXTRA_DATA_NETWORK_TYPE = PhoneConstants.DATA_NETWORK_TYPE_KEY;
+
+ /**
+ * The lookup key used with the {@link #ACTION_PRECISE_DATA_CONNECTION_STATE_CHANGED} broadcast
+ * for an String containing the data APN type.
+ *
+ * <p class="note">
+ * Retrieve with
+ * {@link android.content.Intent#getStringExtra(String name)}.
+ *
+ * @hide
+ */
+ public static final String EXTRA_DATA_APN_TYPE = PhoneConstants.DATA_APN_TYPE_KEY;
+
+ /**
+ * The lookup key used with the {@link #ACTION_PRECISE_DATA_CONNECTION_STATE_CHANGED} broadcast
+ * for an String containing the data APN.
+ *
+ * <p class="note">
+ * Retrieve with
+ * {@link android.content.Intent#getStringExtra(String name)}.
+ *
+ * @hide
+ */
+ public static final String EXTRA_DATA_APN = PhoneConstants.DATA_APN_KEY;
+
+ /**
+ * The lookup key used with the {@link #ACTION_PRECISE_DATA_CONNECTION_STATE_CHANGED} broadcast
+ * for an String representation of the change reason.
+ *
+ * <p class="note">
+ * Retrieve with
+ * {@link android.content.Intent#getStringExtra(String name)}.
+ *
+ * @hide
+ */
+ public static final String EXTRA_DATA_CHANGE_REASON = PhoneConstants.STATE_CHANGE_REASON_KEY;
+
+ /**
+ * The lookup key used with the {@link #ACTION_PRECISE_DATA_CONNECTION_STATE_CHANGED} broadcast
+ * for an String representation of the data interface.
+ *
+ * <p class="note">
+ * Retrieve with
+ * {@link android.content.Intent#getParcelableExtra(String name)}.
+ *
+ * @hide
+ */
+ public static final String EXTRA_DATA_LINK_PROPERTIES_KEY = PhoneConstants.DATA_LINK_PROPERTIES_KEY;
+
+ /**
+ * The lookup key used with the {@link #ACTION_PRECISE_DATA_CONNECTION_STATE_CHANGED} broadcast
+ * for the data connection fail cause.
+ *
+ * <p class="note">
+ * Retrieve with
+ * {@link android.content.Intent#getStringExtra(String name)}.
+ *
+ * @hide
+ */
+ public static final String EXTRA_DATA_FAILURE_CAUSE = PhoneConstants.DATA_FAILURE_CAUSE_KEY;
//
//
diff --git a/telephony/java/com/android/internal/telephony/DctConstants.java b/telephony/java/com/android/internal/telephony/DctConstants.java
index 4be11b8..59bdf64 100644
--- a/telephony/java/com/android/internal/telephony/DctConstants.java
+++ b/telephony/java/com/android/internal/telephony/DctConstants.java
@@ -97,6 +97,7 @@
public static final int CMD_ENABLE_MOBILE_PROVISIONING = BASE + 37;
public static final int CMD_IS_PROVISIONING_APN = BASE + 38;
public static final int EVENT_PROVISIONING_APN_ALARM = BASE + 39;
+ public static final int CMD_NET_STAT_POLL = BASE + 40;
/***** Constants *****/
diff --git a/telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl b/telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl
index 3a04ceb..f228d4e 100644
--- a/telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl
+++ b/telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl
@@ -20,6 +20,8 @@
import android.telephony.ServiceState;
import android.telephony.SignalStrength;
import android.telephony.CellInfo;
+import android.telephony.PreciseCallState;
+import android.telephony.PreciseDataConnectionState;
oneway interface IPhoneStateListener {
void onServiceStateChanged(in ServiceState serviceState);
@@ -35,5 +37,7 @@
void onSignalStrengthsChanged(in SignalStrength signalStrength);
void onOtaspChanged(in int otaspMode);
void onCellInfoChanged(in List<CellInfo> cellInfo);
+ void onPreciseCallStateChanged(in PreciseCallState callState);
+ void onPreciseDataConnectionStateChanged(in PreciseDataConnectionState dataConnectionState);
}
diff --git a/telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl b/telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl
index 59c8472..546ce17 100644
--- a/telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl
+++ b/telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl
@@ -41,4 +41,9 @@
void notifyCellLocation(in Bundle cellLocation);
void notifyOtaspChanged(in int otaspMode);
void notifyCellInfo(in List<CellInfo> cellInfo);
+ void notifyPreciseCallState(int ringingCallState, int foregroundCallState,
+ int backgroundCallState);
+ void notifyDisconnectCause(int disconnectCause, int preciseDisconnectCause);
+ void notifyPreciseDataConnectionFailed(String reason, String apnType, String apn,
+ String failCause);
}
diff --git a/telephony/java/com/android/internal/telephony/PhoneConstants.java b/telephony/java/com/android/internal/telephony/PhoneConstants.java
index 4163255..1fed417d 100644
--- a/telephony/java/com/android/internal/telephony/PhoneConstants.java
+++ b/telephony/java/com/android/internal/telephony/PhoneConstants.java
@@ -73,6 +73,8 @@
public static final String PHONE_NAME_KEY = "phoneName";
public static final String FAILURE_REASON_KEY = "reason";
public static final String STATE_CHANGE_REASON_KEY = "reason";
+ public static final String DATA_NETWORK_TYPE_KEY = "networkType";
+ public static final String DATA_FAILURE_CAUSE_KEY = "failCause";
public static final String DATA_APN_TYPE_KEY = "apnType";
public static final String DATA_APN_KEY = "apn";
public static final String DATA_LINK_PROPERTIES_KEY = "linkProperties";
diff --git a/tests/SmokeTest/tests/AndroidManifest.xml b/tests/SmokeTest/tests/AndroidManifest.xml
index cad37c5..f1a0a4c 100644
--- a/tests/SmokeTest/tests/AndroidManifest.xml
+++ b/tests/SmokeTest/tests/AndroidManifest.xml
@@ -27,15 +27,6 @@
</application>
<!--
- This declares that this app uses the instrumentation test runner targeting the package of
- com.android.smoketest. To run the tests use the command:
- `adb shell am instrument -w com.android.smoketest.tests/android.test.InstrumentationTestRunner`
- -->
- <instrumentation android:name="android.test.InstrumentationTestRunner"
- android:targetPackage="com.android.smoketest"
- android:label="System Smoke Tests"/>
-
- <!--
This declares a method to run the instrumentation with a special runner, which will run each
app as a separate testcase. To do so, use the command:
`adb shell am instrument -w com.android.smoketest.tests/com.android.smoketest.SmokeTestRunner`
diff --git a/tests/SmokeTest/tests/src/com/android/smoketest/ProcessErrorsTest.java b/tests/SmokeTest/tests/src/com/android/smoketest/ProcessErrorsTest.java
index 03c2923..946299b 100644
--- a/tests/SmokeTest/tests/src/com/android/smoketest/ProcessErrorsTest.java
+++ b/tests/SmokeTest/tests/src/com/android/smoketest/ProcessErrorsTest.java
@@ -154,6 +154,11 @@
// launch app, and wait 7 seconds for it to start/settle
final Intent intent = intentForActivity(app);
+ if (intent == null) {
+ Log.i(TAG, String.format("Activity %s/%s is disabled, skipping",
+ app.activityInfo.packageName, app.activityInfo.name));
+ return Collections.EMPTY_LIST;
+ }
getContext().startActivity(intent);
try {
Thread.sleep(appLaunchWait);
@@ -238,10 +243,16 @@
/**
* A helper function to create an {@link Intent} to run, given a {@link ResolveInfo} specifying
* an activity to be launched.
+ *
+ * @return the {@link Intent} or <code>null</code> if given app is disabled
*/
- static Intent intentForActivity(ResolveInfo app) {
+ Intent intentForActivity(ResolveInfo app) {
final ComponentName component = new ComponentName(app.activityInfo.packageName,
app.activityInfo.name);
+ if (getContext().getPackageManager().getComponentEnabledSetting(component) ==
+ PackageManager.COMPONENT_ENABLED_STATE_DISABLED) {
+ return null;
+ }
final Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setComponent(component);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
diff --git a/tests/SystemUIDemoModeController/Android.mk b/tests/SystemUIDemoModeController/Android.mk
new file mode 100644
index 0000000..64ea63c
--- /dev/null
+++ b/tests/SystemUIDemoModeController/Android.mk
@@ -0,0 +1,10 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_SRC_FILES := $(call all-subdir-java-files)
+
+LOCAL_PACKAGE_NAME := DemoModeController
+
+include $(BUILD_PACKAGE)
diff --git a/tests/SystemUIDemoModeController/AndroidManifest.xml b/tests/SystemUIDemoModeController/AndroidManifest.xml
new file mode 100644
index 0000000..2e97932
--- /dev/null
+++ b/tests/SystemUIDemoModeController/AndroidManifest.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.example.android.demomodecontroller"
+ android:versionCode="1"
+ android:versionName="0.1" >
+
+ <uses-sdk
+ android:minSdkVersion="19"
+ android:targetSdkVersion="19" />
+
+ <application
+ android:allowBackup="false"
+ android:label="@string/app_name" >
+ <activity
+ android:name=".DemoModeController" >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+
+</manifest>
diff --git a/tests/SystemUIDemoModeController/res/values/strings.xml b/tests/SystemUIDemoModeController/res/values/strings.xml
new file mode 100644
index 0000000..257a353
--- /dev/null
+++ b/tests/SystemUIDemoModeController/res/values/strings.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<resources>
+
+ <string name="app_name">Demo Mode Controller</string>
+ <string name="help_text">"Drag: control icon states\nLong-press + drag: control background color\nDouble-tap: toggle bar mode</string>
+
+</resources>
diff --git a/tests/SystemUIDemoModeController/src/com/example/android/demomodecontroller/DemoModeController.java b/tests/SystemUIDemoModeController/src/com/example/android/demomodecontroller/DemoModeController.java
new file mode 100644
index 0000000..b177d7e
--- /dev/null
+++ b/tests/SystemUIDemoModeController/src/com/example/android/demomodecontroller/DemoModeController.java
@@ -0,0 +1,340 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.android.demomodecontroller;
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.Intent;
+import android.graphics.Color;
+import android.graphics.PointF;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.HandlerThread;
+import android.os.SystemClock;
+import android.util.Log;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.View.OnTouchListener;
+import android.view.ViewConfiguration;
+import android.view.WindowManager;
+import android.widget.Toast;
+
+public class DemoModeController extends Activity implements OnTouchListener {
+ private static final String TAG = DemoModeController.class.getSimpleName();
+ private static final boolean DEBUG = false;
+
+ private final Context mContext = this;
+ private final Handler mHandler = new Handler();
+ private final PointF mLastDown = new PointF();
+
+ private View mContent;
+ private Handler mBackground;
+ private int mTouchSlop;
+ private long mLastDownTime;
+ private boolean mControllingColor;
+ private Toast mToast;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
+ | WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS // so WM gives us enough room
+ | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
+ getActionBar().hide();
+ mContent = new View(mContext);
+ mContent.setBackgroundColor(0xff33b5e5);
+ mContent.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
+ | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
+ | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
+ mContent.setOnTouchListener(this);
+ setContentView(mContent);
+ mTouchSlop = ViewConfiguration.get(mContext).getScaledTouchSlop();
+
+ final HandlerThread background = new HandlerThread("background");
+ background.start();
+ mBackground = new Handler(background.getLooper());
+ updateMode();
+ }
+
+ @Override
+ protected void onPause() {
+ super.onPause();
+ exitDemoMode();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ exitDemoMode();
+ mToast = Toast.makeText(mContext, R.string.help_text, Toast.LENGTH_LONG);
+ mToast.show();
+ }
+
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ if (mToast != null) {
+ mToast.cancel();
+ mToast = null;
+ }
+ final int action = event.getAction();
+ if (action == MotionEvent.ACTION_DOWN) {
+ if (DEBUG) Log.d(TAG, "down");
+ mHandler.postDelayed(mLongPressCheck, 500);
+ final long now = SystemClock.uptimeMillis();
+ if (now - mLastDownTime < 200) {
+ toggleMode();
+ }
+ mLastDownTime = now;
+ mLastDown.x = event.getX();
+ mLastDown.y = event.getY();
+ return true;
+ }
+ if (action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_UP) {
+ if (DEBUG) Log.d(TAG, "upOrCancel");
+ mControllingColor = false;
+ mHandler.removeCallbacks(mLongPressCheck);
+ }
+ if (action != MotionEvent.ACTION_MOVE) return false;
+
+ float x = event.getX();
+ float y = event.getY();
+ if (Math.abs(mLastDown.x - x) > mTouchSlop || Math.abs(mLastDown.y - y) > mTouchSlop) {
+ mHandler.removeCallbacks(mLongPressCheck);
+ }
+ x = Math.max(x, 0);
+ y = Math.max(y, 0);
+ final int h = mContent.getMeasuredHeight();
+ final int w = mContent.getMeasuredWidth();
+ x = Math.min(x, w);
+ y = Math.min(y, h);
+
+ y = h - y;
+ x = w - x;
+
+ if (mControllingColor) {
+ final float hue = y / (h / 360);
+ final float sat = 1 - (x / (float)w);
+ final float val = x / (float)w;
+ final int color = Color.HSVToColor(new float[]{hue, sat, val});
+ if (DEBUG) Log.d(TAG, String.format("hsv=(%s,%s,%s) argb=#%08x", hue, sat, val, color));
+ mContent.setBackgroundColor(color);
+ return true;
+ }
+
+ final int hh = (int)x / (w / 12);
+ if (hh != mHH) {
+ mHH = hh;
+ mBackground.removeCallbacks(mUpdateClock);
+ mBackground.post(mUpdateClock);
+ }
+
+ final int mm = (int)y / (h / 60);
+ if (mm != mMM) {
+ mMM = mm;
+ mBackground.removeCallbacks(mUpdateClock);
+ mBackground.post(mUpdateClock);
+ }
+
+ final int batteryLevel = (int)y / (h / 101);
+ if (batteryLevel != mBatteryLevel) {
+ mBatteryLevel = batteryLevel;
+ mBackground.removeCallbacks(mUpdateBattery);
+ mBackground.post(mUpdateBattery);
+ }
+
+ final boolean batteryPlugged = x >= w / 2;
+ if (batteryPlugged != mBatteryPlugged) {
+ mBatteryPlugged = batteryPlugged;
+ mBackground.removeCallbacks(mUpdateBattery);
+ mBackground.post(mUpdateBattery);
+ }
+
+ final int mobileLevel = (int)y / (h / 10);
+ if (mobileLevel != mMobileLevel) {
+ mMobileLevel = mobileLevel;
+ mBackground.removeCallbacks(mUpdateMobile);
+ mBackground.post(mUpdateMobile);
+ }
+
+ final int wifiLevel = (int)y / (h / 10);
+ if (wifiLevel != mWifiLevel) {
+ mWifiLevel = wifiLevel;
+ mBackground.removeCallbacks(mUpdateWifi);
+ mBackground.post(mUpdateWifi);
+ }
+
+ final int statusSlots = (int)x / (w / 13);
+ if (statusSlots != mStatusSlots) {
+ mStatusSlots = statusSlots;
+ mBackground.removeCallbacks(mUpdateStatus);
+ mBackground.post(mUpdateStatus);
+ }
+
+ final int networkIcons = (int)x / (w / 4);
+ if (networkIcons != mNetworkIcons) {
+ mNetworkIcons = networkIcons;
+ mBackground.removeCallbacks(mUpdateNetwork);
+ mBackground.post(mUpdateNetwork);
+ }
+
+ final int mobileDataType = (int)y / (h / 9);
+ if (mobileDataType != mMobileDataType) {
+ mMobileDataType = mobileDataType;
+ mBackground.removeCallbacks(mUpdateMobile);
+ mBackground.post(mUpdateMobile);
+ }
+ return true;
+ }
+
+ private void toggleMode() {
+ if (DEBUG) Log.d(TAG, "toggleMode");
+ mBarMode = (mBarMode + 1) % 3;
+ updateMode();
+ }
+
+ private void updateMode() {
+ mBackground.removeCallbacks(mUpdateBarMode);
+ mBackground.post(mUpdateBarMode);
+ }
+
+ private final Runnable mLongPressCheck = new Runnable() {
+ @Override
+ public void run() {
+ if (DEBUG) Log.d(TAG, "mControllingColor = true");
+ mControllingColor = true;
+
+ }
+ };
+
+ private void exitDemoMode() {
+ if (DEBUG) Log.d(TAG, "exitDemoMode");
+ final Intent intent = new Intent("com.android.systemui.demo");
+ intent.putExtra("command", "exit");
+ mContext.sendBroadcast(intent);
+ }
+
+ private int mStatusSlots; // 0 - 12
+ private final Runnable mUpdateStatus = new Runnable() {
+ @Override
+ public void run() {
+ final Intent intent = new Intent("com.android.systemui.demo");
+ intent.putExtra("command", "status");
+ intent.putExtra("volume", mStatusSlots < 1 ? "hide"
+ : mStatusSlots < 2 ? "silent" : "vibrate");
+ intent.putExtra("bluetooth", mStatusSlots < 3 ? "hide"
+ : mStatusSlots < 4 ? "disconnected" : "connected");
+ intent.putExtra("location", mStatusSlots < 5 ? "hide" : "show");
+ intent.putExtra("alarm", mStatusSlots < 6 ? "hide" : "show");
+ intent.putExtra("sync", mStatusSlots < 7 ? "hide" : "show");
+ intent.putExtra("tty", mStatusSlots < 8 ? "hide" : "show");
+ intent.putExtra("eri", mStatusSlots < 9 ? "hide" : "show");
+ intent.putExtra("secure", mStatusSlots < 10 ? "hide" : "show");
+ intent.putExtra("mute", mStatusSlots < 11 ? "hide" : "show");
+ intent.putExtra("speakerphone", mStatusSlots < 12 ? "hide" : "show");
+ mContext.sendBroadcast(intent);
+ }
+ };
+
+ private int mNetworkIcons; // 0:airplane 1:mobile 2:airplane+wifi 3:mobile+wifi
+ private final Runnable mUpdateNetwork = new Runnable() {
+ @Override
+ public void run() {
+ final Intent intent = new Intent("com.android.systemui.demo");
+ intent.putExtra("command", "network");
+ intent.putExtra("airplane", mNetworkIcons % 2 == 0 ? "show" : "hide");
+ intent.putExtra("wifi", mNetworkIcons >= 2 ? "show" : "hide");
+ intent.putExtra("mobile", mNetworkIcons % 2 == 1 ? "show" : "hide");
+ mContext.sendBroadcast(intent);
+ }
+ };
+
+ private int mWifiLevel; // 0 - 4, 5 - 9, fully
+ private final Runnable mUpdateWifi = new Runnable() {
+ @Override
+ public void run() {
+ final Intent intent = new Intent("com.android.systemui.demo");
+ intent.putExtra("command", "network");
+ intent.putExtra("wifi", mNetworkIcons >= 2 ? "show" : "hide");
+ intent.putExtra("level", Integer.toString(mWifiLevel % 5));
+ intent.putExtra("fully", Boolean.toString(mWifiLevel > 4));
+ mContext.sendBroadcast(intent);
+ }
+ };
+
+ private int mMobileLevel; // 0 - 4, 5 - 9, fully
+ private int mMobileDataType; // 0 - 8
+ private static final String getDataType(int dataType) {
+ if (dataType == 1) return "1x";
+ if (dataType == 2) return "3g";
+ if (dataType == 3) return "4g";
+ if (dataType == 4) return "e";
+ if (dataType == 5) return "g";
+ if (dataType == 6) return "h";
+ if (dataType == 7) return "lte";
+ if (dataType == 8) return "roam";
+ return "";
+ }
+ private final Runnable mUpdateMobile = new Runnable() {
+ @Override
+ public void run() {
+ final Intent intent = new Intent("com.android.systemui.demo");
+ intent.putExtra("command", "network");
+ intent.putExtra("mobile", mNetworkIcons % 2 == 1 ? "show" : "hide");
+ intent.putExtra("level", Integer.toString(mMobileLevel % 5));
+ intent.putExtra("fully", Boolean.toString(mMobileLevel > 4));
+ intent.putExtra("datatype", getDataType(mMobileDataType));
+ mContext.sendBroadcast(intent);
+ }
+ };
+
+ private boolean mBatteryPlugged;
+ private int mBatteryLevel; // 0 - 100
+ private final Runnable mUpdateBattery = new Runnable() {
+ @Override
+ public void run() {
+ final Intent intent = new Intent("com.android.systemui.demo");
+ intent.putExtra("command", "battery");
+ intent.putExtra("level", Integer.toString(mBatteryLevel));
+ intent.putExtra("plugged", Boolean.toString(mBatteryPlugged));
+ mContext.sendBroadcast(intent);
+ }
+ };
+
+ private int mHH; // 0 - 11
+ private int mMM; // 0 - 59
+ private final Runnable mUpdateClock = new Runnable() {
+ @Override
+ public void run() {
+ final Intent intent = new Intent("com.android.systemui.demo");
+ intent.putExtra("command", "clock");
+ intent.putExtra("hhmm", String.format("%02d%02d", mHH + 1, mMM));
+ mContext.sendBroadcast(intent);
+ }
+ };
+
+ private int mBarMode; // 0 - 2 (opaque, semi-transparent, translucent)
+ private final Runnable mUpdateBarMode = new Runnable() {
+ @Override
+ public void run() {
+ final Intent intent = new Intent("com.android.systemui.demo");
+ intent.putExtra("command", "bars");
+ intent.putExtra("mode", mBarMode == 1 ? "semi-transparent"
+ : mBarMode == 2 ? "translucent" : "opaque");
+ mContext.sendBroadcast(intent);
+ }
+ };
+}
diff --git a/tools/aapt/AaptAssets.cpp b/tools/aapt/AaptAssets.cpp
index d8e113a..19532e8 100644
--- a/tools/aapt/AaptAssets.cpp
+++ b/tools/aapt/AaptAssets.cpp
@@ -149,205 +149,506 @@
// =========================================================================
// =========================================================================
-status_t
-AaptGroupEntry::parseNamePart(const String8& part, int* axis, uint32_t* value)
+/* static */ void AaptLocaleValue::splitAndLowerCase(const char* const chars,
+ Vector<String8>* parts, const char separator) {
+ const char *p = chars;
+ const char *q;
+ while (NULL != (q = strchr(p, separator))) {
+ String8 val(p, q - p);
+ val.toLower();
+ parts->add(val);
+ p = q+1;
+ }
+
+ if (p < chars + strlen(chars)) {
+ String8 val(p);
+ val.toLower();
+ parts->add(val);
+ }
+}
+
+/* static */
+inline bool isAlpha(const String8& string) {
+ const size_t length = string.length();
+ for (size_t i = 0; i < length; ++i) {
+ if (!isalpha(string[i])) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+/* static */
+inline bool isNumber(const String8& string) {
+ const size_t length = string.length();
+ for (size_t i = 0; i < length; ++i) {
+ if (!isdigit(string[i])) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+void AaptLocaleValue::setLanguage(const char* languageChars) {
+ size_t i = 0;
+ while ((*languageChars) != '\0') {
+ language[i++] = tolower(*languageChars);
+ languageChars++;
+ }
+}
+
+void AaptLocaleValue::setRegion(const char* regionChars) {
+ size_t i = 0;
+ while ((*regionChars) != '\0') {
+ region[i++] = toupper(*regionChars);
+ regionChars++;
+ }
+}
+
+void AaptLocaleValue::setScript(const char* scriptChars) {
+ size_t i = 0;
+ while ((*scriptChars) != '\0') {
+ if (i == 0) {
+ script[i++] = toupper(*scriptChars);
+ } else {
+ script[i++] = tolower(*scriptChars);
+ }
+ scriptChars++;
+ }
+}
+
+void AaptLocaleValue::setVariant(const char* variantChars) {
+ size_t i = 0;
+ while ((*variantChars) != '\0') {
+ variant[i++] = *variantChars;
+ variantChars++;
+ }
+}
+
+bool AaptLocaleValue::initFromFilterString(const String8& str) {
+ // A locale (as specified in the filter) is an underscore separated name such
+ // as "en_US", "en_Latn_US", or "en_US_POSIX".
+ Vector<String8> parts;
+ splitAndLowerCase(str.string(), &parts, '_');
+
+ const int numTags = parts.size();
+ bool valid = false;
+ if (numTags >= 1) {
+ const String8& lang = parts[0];
+ if (isAlpha(lang) && (lang.length() == 2 || lang.length() == 3)) {
+ setLanguage(lang.string());
+ valid = true;
+ }
+ }
+
+ if (!valid || numTags == 1) {
+ return valid;
+ }
+
+ // At this point, valid == true && numTags > 1.
+ const String8& part2 = parts[1];
+ if ((part2.length() == 2 && isAlpha(part2)) ||
+ (part2.length() == 3 && isNumber(part2))) {
+ setRegion(part2.string());
+ } else if (part2.length() == 4 && isAlpha(part2)) {
+ setScript(part2.string());
+ } else if (part2.length() >= 5 && part2.length() <= 8) {
+ setVariant(part2.string());
+ } else {
+ valid = false;
+ }
+
+ if (!valid || numTags == 2) {
+ return valid;
+ }
+
+ // At this point, valid == true && numTags > 1.
+ const String8& part3 = parts[2];
+ if (((part3.length() == 2 && isAlpha(part3)) ||
+ (part3.length() == 3 && isNumber(part3))) && script[0]) {
+ setRegion(part3.string());
+ } else if (part3.length() >= 5 && part3.length() <= 8) {
+ setVariant(part3.string());
+ } else {
+ valid = false;
+ }
+
+ if (!valid || numTags == 3) {
+ return valid;
+ }
+
+ const String8& part4 = parts[3];
+ if (part4.length() >= 5 && part4.length() <= 8) {
+ setVariant(part4.string());
+ } else {
+ valid = false;
+ }
+
+ if (!valid || numTags > 4) {
+ return false;
+ }
+
+ return true;
+}
+
+int AaptLocaleValue::initFromDirName(const Vector<String8>& parts, const int startIndex) {
+ const int size = parts.size();
+ int currentIndex = startIndex;
+
+ String8 part = parts[currentIndex];
+ if (part[0] == 'b' && part[1] == '+') {
+ // This is a "modified" BCP-47 language tag. Same semantics as BCP-47 tags,
+ // except that the separator is "+" and not "-".
+ Vector<String8> subtags;
+ AaptLocaleValue::splitAndLowerCase(part.string(), &subtags, '+');
+ subtags.removeItemsAt(0);
+ if (subtags.size() == 1) {
+ setLanguage(subtags[0]);
+ } else if (subtags.size() == 2) {
+ setLanguage(subtags[0]);
+
+ // The second tag can either be a region, a variant or a script.
+ switch (subtags[1].size()) {
+ case 2:
+ case 3:
+ setRegion(subtags[1]);
+ break;
+ case 4:
+ setScript(subtags[1]);
+ break;
+ case 5:
+ case 6:
+ case 7:
+ case 8:
+ setVariant(subtags[1]);
+ break;
+ default:
+ fprintf(stderr, "ERROR: Invalid BCP-47 tag in directory name %s\n",
+ part.string());
+ return -1;
+ }
+ } else if (subtags.size() == 3) {
+ // The language is always the first subtag.
+ setLanguage(subtags[0]);
+
+ // The second subtag can either be a script or a region code.
+ // If its size is 4, it's a script code, else it's a region code.
+ bool hasRegion = false;
+ if (subtags[1].size() == 4) {
+ setScript(subtags[1]);
+ } else if (subtags[1].size() == 2 || subtags[1].size() == 3) {
+ setRegion(subtags[1]);
+ hasRegion = true;
+ } else {
+ fprintf(stderr, "ERROR: Invalid BCP-47 tag in directory name %s\n", part.string());
+ return -1;
+ }
+
+ // The third tag can either be a region code (if the second tag was
+ // a script), else a variant code.
+ if (subtags[2].size() > 4) {
+ setVariant(subtags[2]);
+ } else {
+ setRegion(subtags[2]);
+ }
+ } else if (subtags.size() == 4) {
+ setLanguage(subtags[0]);
+ setScript(subtags[1]);
+ setRegion(subtags[2]);
+ setVariant(subtags[3]);
+ } else {
+ fprintf(stderr, "ERROR: Invalid BCP-47 tag in directory name: %s\n", part.string());
+ return -1;
+ }
+
+ return ++currentIndex;
+ } else {
+ if ((part.length() == 2 || part.length() == 3) && isAlpha(part)) {
+ setLanguage(part);
+ if (++currentIndex == size) {
+ return size;
+ }
+ } else {
+ return currentIndex;
+ }
+
+ part = parts[currentIndex];
+ if (part.string()[0] == 'r' && part.length() == 3) {
+ setRegion(part.string() + 1);
+ if (++currentIndex == size) {
+ return size;
+ }
+ }
+ }
+
+ return currentIndex;
+}
+
+
+String8 AaptLocaleValue::toDirName() const {
+ String8 dirName("");
+ if (language[0]) {
+ dirName += language;
+ } else {
+ return dirName;
+ }
+
+ if (script[0]) {
+ dirName += "-s";
+ dirName += script;
+ }
+
+ if (region[0]) {
+ dirName += "-r";
+ dirName += region;
+ }
+
+ if (variant[0]) {
+ dirName += "-v";
+ dirName += variant;
+ }
+
+ return dirName;
+}
+
+void AaptLocaleValue::initFromResTable(const ResTable_config& config) {
+ config.unpackLanguage(language);
+ config.unpackRegion(region);
+ if (config.localeScript[0]) {
+ memcpy(script, config.localeScript, sizeof(config.localeScript));
+ }
+
+ if (config.localeVariant[0]) {
+ memcpy(variant, config.localeVariant, sizeof(config.localeVariant));
+ }
+}
+
+void AaptLocaleValue::writeTo(ResTable_config* out) const {
+ out->packLanguage(language);
+ out->packRegion(region);
+
+ if (script[0]) {
+ memcpy(out->localeScript, script, sizeof(out->localeScript));
+ }
+
+ if (variant[0]) {
+ memcpy(out->localeVariant, variant, sizeof(out->localeVariant));
+ }
+}
+
+
+/* static */ bool
+AaptGroupEntry::parseFilterNamePart(const String8& part, int* axis, AxisValue* value)
{
ResTable_config config;
+ memset(&config, 0, sizeof(ResTable_config));
// IMSI - MCC
if (getMccName(part.string(), &config)) {
*axis = AXIS_MCC;
- *value = config.mcc;
- return 0;
+ value->intValue = config.mcc;
+ return true;
}
// IMSI - MNC
if (getMncName(part.string(), &config)) {
*axis = AXIS_MNC;
- *value = config.mnc;
- return 0;
+ value->intValue = config.mnc;
+ return true;
}
// locale - language
- if (part.length() == 2 && isalpha(part[0]) && isalpha(part[1])) {
- *axis = AXIS_LANGUAGE;
- *value = part[1] << 8 | part[0];
- return 0;
- }
-
- // locale - language_REGION
- if (part.length() == 5 && isalpha(part[0]) && isalpha(part[1])
- && part[2] == '_' && isalpha(part[3]) && isalpha(part[4])) {
- *axis = AXIS_LANGUAGE;
- *value = (part[4] << 24) | (part[3] << 16) | (part[1] << 8) | (part[0]);
- return 0;
+ if (value->localeValue.initFromFilterString(part)) {
+ *axis = AXIS_LOCALE;
+ return true;
}
// layout direction
if (getLayoutDirectionName(part.string(), &config)) {
*axis = AXIS_LAYOUTDIR;
- *value = (config.screenLayout&ResTable_config::MASK_LAYOUTDIR);
- return 0;
+ value->intValue = (config.screenLayout&ResTable_config::MASK_LAYOUTDIR);
+ return true;
}
// smallest screen dp width
if (getSmallestScreenWidthDpName(part.string(), &config)) {
*axis = AXIS_SMALLESTSCREENWIDTHDP;
- *value = config.smallestScreenWidthDp;
- return 0;
+ value->intValue = config.smallestScreenWidthDp;
+ return true;
}
// screen dp width
if (getScreenWidthDpName(part.string(), &config)) {
*axis = AXIS_SCREENWIDTHDP;
- *value = config.screenWidthDp;
- return 0;
+ value->intValue = config.screenWidthDp;
+ return true;
}
// screen dp height
if (getScreenHeightDpName(part.string(), &config)) {
*axis = AXIS_SCREENHEIGHTDP;
- *value = config.screenHeightDp;
- return 0;
+ value->intValue = config.screenHeightDp;
+ return true;
}
// screen layout size
if (getScreenLayoutSizeName(part.string(), &config)) {
*axis = AXIS_SCREENLAYOUTSIZE;
- *value = (config.screenLayout&ResTable_config::MASK_SCREENSIZE);
- return 0;
+ value->intValue = (config.screenLayout&ResTable_config::MASK_SCREENSIZE);
+ return true;
}
// screen layout long
if (getScreenLayoutLongName(part.string(), &config)) {
*axis = AXIS_SCREENLAYOUTLONG;
- *value = (config.screenLayout&ResTable_config::MASK_SCREENLONG);
- return 0;
+ value->intValue = (config.screenLayout&ResTable_config::MASK_SCREENLONG);
+ return true;
}
// orientation
if (getOrientationName(part.string(), &config)) {
*axis = AXIS_ORIENTATION;
- *value = config.orientation;
- return 0;
+ value->intValue = config.orientation;
+ return true;
}
// ui mode type
if (getUiModeTypeName(part.string(), &config)) {
*axis = AXIS_UIMODETYPE;
- *value = (config.uiMode&ResTable_config::MASK_UI_MODE_TYPE);
- return 0;
+ value->intValue = (config.uiMode&ResTable_config::MASK_UI_MODE_TYPE);
+ return true;
}
// ui mode night
if (getUiModeNightName(part.string(), &config)) {
*axis = AXIS_UIMODENIGHT;
- *value = (config.uiMode&ResTable_config::MASK_UI_MODE_NIGHT);
- return 0;
+ value->intValue = (config.uiMode&ResTable_config::MASK_UI_MODE_NIGHT);
+ return true;
}
// density
if (getDensityName(part.string(), &config)) {
*axis = AXIS_DENSITY;
- *value = config.density;
- return 0;
+ value->intValue = config.density;
+ return true;
}
// touchscreen
if (getTouchscreenName(part.string(), &config)) {
*axis = AXIS_TOUCHSCREEN;
- *value = config.touchscreen;
- return 0;
+ value->intValue = config.touchscreen;
+ return true;
}
// keyboard hidden
if (getKeysHiddenName(part.string(), &config)) {
*axis = AXIS_KEYSHIDDEN;
- *value = config.inputFlags;
- return 0;
+ value->intValue = config.inputFlags;
+ return true;
}
// keyboard
if (getKeyboardName(part.string(), &config)) {
*axis = AXIS_KEYBOARD;
- *value = config.keyboard;
- return 0;
+ value->intValue = config.keyboard;
+ return true;
}
// navigation hidden
if (getNavHiddenName(part.string(), &config)) {
*axis = AXIS_NAVHIDDEN;
- *value = config.inputFlags;
+ value->intValue = config.inputFlags;
return 0;
}
// navigation
if (getNavigationName(part.string(), &config)) {
*axis = AXIS_NAVIGATION;
- *value = config.navigation;
- return 0;
+ value->intValue = config.navigation;
+ return true;
}
// screen size
if (getScreenSizeName(part.string(), &config)) {
*axis = AXIS_SCREENSIZE;
- *value = config.screenSize;
- return 0;
+ value->intValue = config.screenSize;
+ return true;
}
// version
if (getVersionName(part.string(), &config)) {
*axis = AXIS_VERSION;
- *value = config.version;
- return 0;
+ value->intValue = config.version;
+ return true;
}
- return 1;
+ return false;
}
-uint32_t
+AxisValue
AaptGroupEntry::getConfigValueForAxis(const ResTable_config& config, int axis)
{
+ AxisValue value;
switch (axis) {
case AXIS_MCC:
- return config.mcc;
+ value.intValue = config.mcc;
+ break;
case AXIS_MNC:
- return config.mnc;
- case AXIS_LANGUAGE:
- return (((uint32_t)config.country[1]) << 24) | (((uint32_t)config.country[0]) << 16)
- | (((uint32_t)config.language[1]) << 8) | (config.language[0]);
+ value.intValue = config.mnc;
+ break;
+ case AXIS_LOCALE:
+ value.localeValue.initFromResTable(config);
+ break;
case AXIS_LAYOUTDIR:
- return config.screenLayout&ResTable_config::MASK_LAYOUTDIR;
+ value.intValue = config.screenLayout&ResTable_config::MASK_LAYOUTDIR;
+ break;
case AXIS_SCREENLAYOUTSIZE:
- return config.screenLayout&ResTable_config::MASK_SCREENSIZE;
+ value.intValue = config.screenLayout&ResTable_config::MASK_SCREENSIZE;
+ break;
case AXIS_ORIENTATION:
- return config.orientation;
+ value.intValue = config.orientation;
+ break;
case AXIS_UIMODETYPE:
- return (config.uiMode&ResTable_config::MASK_UI_MODE_TYPE);
+ value.intValue = (config.uiMode&ResTable_config::MASK_UI_MODE_TYPE);
+ break;
case AXIS_UIMODENIGHT:
- return (config.uiMode&ResTable_config::MASK_UI_MODE_NIGHT);
+ value.intValue = (config.uiMode&ResTable_config::MASK_UI_MODE_NIGHT);
+ break;
case AXIS_DENSITY:
- return config.density;
+ value.intValue = config.density;
+ break;
case AXIS_TOUCHSCREEN:
- return config.touchscreen;
+ value.intValue = config.touchscreen;
+ break;
case AXIS_KEYSHIDDEN:
- return config.inputFlags;
+ value.intValue = config.inputFlags;
+ break;
case AXIS_KEYBOARD:
- return config.keyboard;
+ value.intValue = config.keyboard;
+ break;
case AXIS_NAVIGATION:
- return config.navigation;
+ value.intValue = config.navigation;
+ break;
case AXIS_SCREENSIZE:
- return config.screenSize;
+ value.intValue = config.screenSize;
+ break;
case AXIS_SMALLESTSCREENWIDTHDP:
- return config.smallestScreenWidthDp;
+ value.intValue = config.smallestScreenWidthDp;
+ break;
case AXIS_SCREENWIDTHDP:
- return config.screenWidthDp;
+ value.intValue = config.screenWidthDp;
+ break;
case AXIS_SCREENHEIGHTDP:
- return config.screenHeightDp;
+ value.intValue = config.screenHeightDp;
+ break;
case AXIS_VERSION:
- return config.version;
+ value.intValue = config.version;
+ break;
}
- return 0;
+
+ return value;
}
bool
@@ -371,24 +672,14 @@
mParamsChanged = true;
Vector<String8> parts;
+ AaptLocaleValue::splitAndLowerCase(dir, &parts, '-');
- String8 mcc, mnc, loc, layoutsize, layoutlong, orient, den;
+ String8 mcc, mnc, layoutsize, layoutlong, orient, den;
String8 touch, key, keysHidden, nav, navHidden, size, layoutDir, vers;
String8 uiModeType, uiModeNight, smallestwidthdp, widthdp, heightdp;
- const char *p = dir;
- const char *q;
- while (NULL != (q = strchr(p, '-'))) {
- String8 val(p, q-p);
- val.toLower();
- parts.add(val);
- //printf("part: %s\n", parts[parts.size()-1].string());
- p = q+1;
- }
- String8 val(p);
- val.toLower();
- parts.add(val);
- //printf("part: %s\n", parts[parts.size()-1].string());
+ AaptLocaleValue locale;
+ int numLocaleComponents = 0;
const int N = parts.size();
int index = 0;
@@ -429,38 +720,18 @@
}
part = parts[index];
} else {
- //printf("not mcc: %s\n", part.string());
+ //printf("not mnc: %s\n", part.string());
}
- // locale - language
- if (part.length() == 2 && isalpha(part[0]) && isalpha(part[1])) {
- loc = part;
-
- index++;
- if (index == N) {
- goto success;
- }
- part = parts[index];
- } else {
- //printf("not language: %s\n", part.string());
+ index = locale.initFromDirName(parts, index);
+ if (index == -1) {
+ return false;
+ }
+ if (index >= N){
+ goto success;
}
- // locale - region
- if (loc.length() > 0
- && part.length() == 3 && part[0] == 'r' && part[0] && part[1]) {
- loc += "-";
- part.toUpper();
- loc += part.string() + 1;
-
- index++;
- if (index == N) {
- goto success;
- }
- part = parts[index];
- } else {
- //printf("not region: %s\n", part.string());
- }
-
+ part = parts[index];
if (getLayoutDirectionName(part.string())) {
layoutDir = part;
@@ -679,7 +950,7 @@
success:
this->mcc = mcc;
this->mnc = mnc;
- this->locale = loc;
+ this->locale = locale;
this->screenLayoutSize = layoutsize;
this->screenLayoutLong = layoutlong;
this->smallestScreenWidthDp = smallestwidthdp;
@@ -711,7 +982,7 @@
s += ",";
s += this->mnc;
s += ",";
- s += this->locale;
+ s += locale.toDirName();
s += ",";
s += layoutDirection;
s += ",";
@@ -765,12 +1036,15 @@
}
s += mnc;
}
- if (this->locale != "") {
- if (s.length() > 0) {
- s += "-";
- }
- s += locale;
+
+ const String8 localeComponent = locale.toDirName();
+ if (localeComponent != "") {
+ if (s.length() > 0) {
+ s += "-";
+ }
+ s += localeComponent;
}
+
if (this->layoutDirection != "") {
if (s.length() > 0) {
s += "-";
@@ -942,55 +1216,6 @@
return true;
}
-/*
- * Does this directory name fit the pattern of a locale dir ("en-rUS" or
- * "default")?
- *
- * TODO: Should insist that the first two letters are lower case, and the
- * second two are upper.
- */
-bool AaptGroupEntry::getLocaleName(const char* fileName,
- ResTable_config* out)
-{
- if (strcmp(fileName, kWildcardName) == 0
- || strcmp(fileName, kDefaultLocale) == 0) {
- if (out) {
- out->language[0] = 0;
- out->language[1] = 0;
- out->country[0] = 0;
- out->country[1] = 0;
- }
- return true;
- }
-
- if (strlen(fileName) == 2 && isalpha(fileName[0]) && isalpha(fileName[1])) {
- if (out) {
- out->language[0] = fileName[0];
- out->language[1] = fileName[1];
- out->country[0] = 0;
- out->country[1] = 0;
- }
- return true;
- }
-
- if (strlen(fileName) == 5 &&
- isalpha(fileName[0]) &&
- isalpha(fileName[1]) &&
- fileName[2] == '-' &&
- isalpha(fileName[3]) &&
- isalpha(fileName[4])) {
- if (out) {
- out->language[0] = fileName[0];
- out->language[1] = fileName[1];
- out->country[0] = fileName[3];
- out->country[1] = fileName[4];
- }
- return true;
- }
-
- return false;
-}
-
bool AaptGroupEntry::getLayoutDirectionName(const char* name, ResTable_config* out)
{
if (strcmp(name, kWildcardName) == 0) {
@@ -1496,18 +1721,18 @@
return v;
}
-const ResTable_config& AaptGroupEntry::toParams() const
+const ResTable_config AaptGroupEntry::toParams() const
{
if (!mParamsChanged) {
return mParams;
}
mParamsChanged = false;
- ResTable_config& params(mParams);
- memset(¶ms, 0, sizeof(params));
+ ResTable_config& params = mParams;
+ memset(¶ms, 0, sizeof(ResTable_config));
getMccName(mcc.string(), ¶ms);
getMncName(mnc.string(), ¶ms);
- getLocaleName(locale.string(), ¶ms);
+ locale.writeTo(¶ms);
getLayoutDirectionName(layoutDirection.string(), ¶ms);
getSmallestScreenWidthDpName(smallestScreenWidthDp.string(), ¶ms);
getScreenWidthDpName(screenWidthDp.string(), ¶ms);
@@ -1982,7 +2207,9 @@
AaptAssets::AaptAssets()
: AaptDir(String8(), String8()),
- mChanged(false), mHaveIncludedAssets(false), mRes(NULL)
+ mHavePrivateSymbols(false),
+ mChanged(false), mHaveIncludedAssets(false),
+ mRes(NULL)
{
}
@@ -2491,9 +2718,9 @@
// If our preferred density is hdpi but we only have mdpi and xhdpi resources, we
// pick xhdpi.
uint32_t preferredDensity = 0;
- const SortedVector<uint32_t>* preferredConfigs = prefFilter.configsForAxis(AXIS_DENSITY);
+ const SortedVector<AxisValue>* preferredConfigs = prefFilter.configsForAxis(AXIS_DENSITY);
if (preferredConfigs != NULL && preferredConfigs->size() > 0) {
- preferredDensity = (*preferredConfigs)[0];
+ preferredDensity = (*preferredConfigs)[0].intValue;
}
// Now deal with preferred configurations.
@@ -2651,7 +2878,7 @@
{
const ResTable& res = getIncludedResources();
// XXX dirty!
- return const_cast<ResTable&>(res).add(file->getData(), file->getSize(), NULL);
+ return const_cast<ResTable&>(res).add(file->getData(), file->getSize());
}
const ResTable& AaptAssets::getIncludedResources() const
diff --git a/tools/aapt/AaptAssets.h b/tools/aapt/AaptAssets.h
index 5cfa913..9733b6d 100644
--- a/tools/aapt/AaptAssets.h
+++ b/tools/aapt/AaptAssets.h
@@ -13,7 +13,6 @@
#include <utils/RefBase.h>
#include <utils/SortedVector.h>
#include <utils/String8.h>
-#include <utils/String8.h>
#include <utils/Vector.h>
#include "ZipFile.h"
@@ -34,8 +33,7 @@
AXIS_NONE = 0,
AXIS_MCC = 1,
AXIS_MNC,
- AXIS_LANGUAGE,
- AXIS_REGION,
+ AXIS_LOCALE,
AXIS_SCREENLAYOUTSIZE,
AXIS_SCREENLAYOUTLONG,
AXIS_ORIENTATION,
@@ -58,6 +56,73 @@
AXIS_END = AXIS_VERSION,
};
+struct AaptLocaleValue {
+ char language[4];
+ char region[4];
+ char script[4];
+ char variant[8];
+
+ AaptLocaleValue() {
+ memset(this, 0, sizeof(AaptLocaleValue));
+ }
+
+ // Initialize this AaptLocaleValue from a config string.
+ bool initFromFilterString(const String8& config);
+
+ int initFromDirName(const Vector<String8>& parts, const int startIndex);
+
+ // Initialize this AaptLocaleValue from a ResTable_config.
+ void initFromResTable(const ResTable_config& config);
+
+ void writeTo(ResTable_config* out) const;
+
+ String8 toDirName() const;
+
+ int compare(const AaptLocaleValue& other) const {
+ return memcmp(this, &other, sizeof(AaptLocaleValue));
+ }
+
+ static void splitAndLowerCase(const char* const chars, Vector<String8>* parts,
+ const char separator);
+
+ inline bool operator<(const AaptLocaleValue& o) const { return compare(o) < 0; }
+ inline bool operator<=(const AaptLocaleValue& o) const { return compare(o) <= 0; }
+ inline bool operator==(const AaptLocaleValue& o) const { return compare(o) == 0; }
+ inline bool operator!=(const AaptLocaleValue& o) const { return compare(o) != 0; }
+ inline bool operator>=(const AaptLocaleValue& o) const { return compare(o) >= 0; }
+ inline bool operator>(const AaptLocaleValue& o) const { return compare(o) > 0; }
+private:
+ void setLanguage(const char* language);
+ void setRegion(const char* language);
+ void setScript(const char* script);
+ void setVariant(const char* variant);
+};
+
+struct AxisValue {
+ // Used for all axes except AXIS_LOCALE, which is represented
+ // as a AaptLocaleValue value.
+ int intValue;
+ AaptLocaleValue localeValue;
+
+ AxisValue() : intValue(0) {
+ }
+
+ inline int compare(const AxisValue &other) const {
+ if (intValue != other.intValue) {
+ return intValue - other.intValue;
+ }
+
+ return localeValue.compare(other.localeValue);
+ }
+
+ inline bool operator<(const AxisValue& o) const { return compare(o) < 0; }
+ inline bool operator<=(const AxisValue& o) const { return compare(o) <= 0; }
+ inline bool operator==(const AxisValue& o) const { return compare(o) == 0; }
+ inline bool operator!=(const AxisValue& o) const { return compare(o) != 0; }
+ inline bool operator>=(const AxisValue& o) const { return compare(o) >= 0; }
+ inline bool operator>(const AxisValue& o) const { return compare(o) > 0; }
+};
+
/**
* This structure contains a specific variation of a single file out
* of all the variations it can have that we can have.
@@ -65,22 +130,38 @@
struct AaptGroupEntry
{
public:
- AaptGroupEntry() : mParamsChanged(true) { }
- AaptGroupEntry(const String8& _locale, const String8& _vendor)
- : locale(_locale), vendor(_vendor), mParamsChanged(true) { }
+ AaptGroupEntry() : mParamsChanged(true) {
+ memset(&mParams, 0, sizeof(ResTable_config));
+ }
bool initFromDirName(const char* dir, String8* resType);
- static status_t parseNamePart(const String8& part, int* axis, uint32_t* value);
+ static bool parseFilterNamePart(const String8& part, int* axis, AxisValue* value);
- static uint32_t getConfigValueForAxis(const ResTable_config& config, int axis);
+ static AxisValue getConfigValueForAxis(const ResTable_config& config, int axis);
static bool configSameExcept(const ResTable_config& config,
const ResTable_config& otherConfig, int axis);
+ int compare(const AaptGroupEntry& o) const;
+
+ const ResTable_config toParams() const;
+
+ inline bool operator<(const AaptGroupEntry& o) const { return compare(o) < 0; }
+ inline bool operator<=(const AaptGroupEntry& o) const { return compare(o) <= 0; }
+ inline bool operator==(const AaptGroupEntry& o) const { return compare(o) == 0; }
+ inline bool operator!=(const AaptGroupEntry& o) const { return compare(o) != 0; }
+ inline bool operator>=(const AaptGroupEntry& o) const { return compare(o) >= 0; }
+ inline bool operator>(const AaptGroupEntry& o) const { return compare(o) > 0; }
+
+ String8 toString() const;
+ String8 toDirName(const String8& resType) const;
+
+ const String8& getVersionString() const { return version; }
+
+private:
static bool getMccName(const char* name, ResTable_config* out = NULL);
static bool getMncName(const char* name, ResTable_config* out = NULL);
- static bool getLocaleName(const char* name, ResTable_config* out = NULL);
static bool getScreenLayoutSizeName(const char* name, ResTable_config* out = NULL);
static bool getScreenLayoutLongName(const char* name, ResTable_config* out = NULL);
static bool getOrientationName(const char* name, ResTable_config* out = NULL);
@@ -99,26 +180,9 @@
static bool getLayoutDirectionName(const char* name, ResTable_config* out = NULL);
static bool getVersionName(const char* name, ResTable_config* out = NULL);
- int compare(const AaptGroupEntry& o) const;
-
- const ResTable_config& toParams() const;
-
- inline bool operator<(const AaptGroupEntry& o) const { return compare(o) < 0; }
- inline bool operator<=(const AaptGroupEntry& o) const { return compare(o) <= 0; }
- inline bool operator==(const AaptGroupEntry& o) const { return compare(o) == 0; }
- inline bool operator!=(const AaptGroupEntry& o) const { return compare(o) != 0; }
- inline bool operator>=(const AaptGroupEntry& o) const { return compare(o) >= 0; }
- inline bool operator>(const AaptGroupEntry& o) const { return compare(o) > 0; }
-
- String8 toString() const;
- String8 toDirName(const String8& resType) const;
-
- const String8& getVersionString() const { return version; }
-
-private:
String8 mcc;
String8 mnc;
- String8 locale;
+ AaptLocaleValue locale;
String8 vendor;
String8 smallestScreenWidthDp;
String8 screenWidthDp;
diff --git a/tools/aapt/Command.cpp b/tools/aapt/Command.cpp
index 632efe0..c7cce96 100644
--- a/tools/aapt/Command.cpp
+++ b/tools/aapt/Command.cpp
@@ -505,7 +505,7 @@
const char* filename = bundle->getFileSpecEntry(1);
AssetManager assets;
- void* assetsCookie;
+ int32_t assetsCookie;
if (!assets.addAssetPath(String8(filename), &assetsCookie)) {
fprintf(stderr, "ERROR: dump failed because assets could not be loaded\n");
return 1;
@@ -517,6 +517,7 @@
// the API version because key resources like icons will have an implicit
// version if they are using newer config types like density.
ResTable_config config;
+ memset(&config, 0, sizeof(ResTable_config));
config.language[0] = 'e';
config.language[1] = 'n';
config.country[0] = 'U';
diff --git a/tools/aapt/Images.cpp b/tools/aapt/Images.cpp
index 25a948d..db74831 100644
--- a/tools/aapt/Images.cpp
+++ b/tools/aapt/Images.cpp
@@ -35,7 +35,9 @@
// This holds an image as 8bpp RGBA.
struct image_info
{
- image_info() : rows(NULL), is9Patch(false), allocRows(NULL) { }
+ image_info() : rows(NULL), is9Patch(false),
+ xDivs(NULL), yDivs(NULL), colors(NULL), allocRows(NULL) { }
+
~image_info() {
if (rows && rows != allocRows) {
free(rows);
@@ -46,9 +48,15 @@
}
free(allocRows);
}
- free(info9Patch.xDivs);
- free(info9Patch.yDivs);
- free(info9Patch.colors);
+ free(xDivs);
+ free(yDivs);
+ free(colors);
+ }
+
+ void* serialize9patch() {
+ void* serialized = Res_png_9patch::serialize(info9Patch, xDivs, yDivs, colors);
+ reinterpret_cast<Res_png_9patch*>(serialized)->deviceToFile();
+ return serialized;
}
png_uint_32 width;
@@ -58,6 +66,9 @@
// 9-patch info.
bool is9Patch;
Res_png_9patch info9Patch;
+ int32_t* xDivs;
+ int32_t* yDivs;
+ uint32_t* colors;
// Layout padding, if relevant
bool haveLayoutBounds;
@@ -430,10 +441,10 @@
{
int left, right, top, bottom;
select_patch(
- hpatch, image->info9Patch.xDivs[0], image->info9Patch.xDivs[1],
+ hpatch, image->xDivs[0], image->xDivs[1],
image->width, &left, &right);
select_patch(
- vpatch, image->info9Patch.yDivs[0], image->info9Patch.yDivs[1],
+ vpatch, image->yDivs[0], image->yDivs[1],
image->height, &top, &bottom);
//printf("Selecting h=%d v=%d: (%d,%d)-(%d,%d)\n",
// hpatch, vpatch, left, top, right, bottom);
@@ -452,8 +463,8 @@
int maxSizeXDivs = W * sizeof(int32_t);
int maxSizeYDivs = H * sizeof(int32_t);
- int32_t* xDivs = image->info9Patch.xDivs = (int32_t*) malloc(maxSizeXDivs);
- int32_t* yDivs = image->info9Patch.yDivs = (int32_t*) malloc(maxSizeYDivs);
+ int32_t* xDivs = image->xDivs = (int32_t*) malloc(maxSizeXDivs);
+ int32_t* yDivs = image->yDivs = (int32_t*) malloc(maxSizeYDivs);
uint8_t numXDivs = 0;
uint8_t numYDivs = 0;
@@ -609,7 +620,7 @@
numColors = numRows * numCols;
image->info9Patch.numColors = numColors;
- image->info9Patch.colors = (uint32_t*)malloc(numColors * sizeof(uint32_t));
+ image->colors = (uint32_t*)malloc(numColors * sizeof(uint32_t));
// Fill in color information for each patch.
@@ -652,7 +663,7 @@
right = xDivs[i];
}
c = get_color(image->rows, left, top, right - 1, bottom - 1);
- image->info9Patch.colors[colorIndex++] = c;
+ image->colors[colorIndex++] = c;
NOISY(if (c != Res_png_9patch::NO_COLOR) hasColor = true);
left = right;
}
@@ -664,14 +675,10 @@
for (i=0; i<numColors; i++) {
if (hasColor) {
if (i == 0) printf("Colors in %s:\n ", imageName);
- printf(" #%08x", image->info9Patch.colors[i]);
+ printf(" #%08x", image->colors[i]);
if (i == numColors - 1) printf("\n");
}
}
-
- image->is9Patch = true;
- image->info9Patch.deviceToFile();
-
getout:
if (errorMsg) {
fprintf(stderr,
@@ -691,14 +698,10 @@
return NO_ERROR;
}
-static void checkNinePatchSerialization(Res_png_9patch* inPatch, void * data)
+static void checkNinePatchSerialization(Res_png_9patch* inPatch, void* data)
{
- if (sizeof(void*) != sizeof(int32_t)) {
- // can't deserialize on a non-32 bit system
- return;
- }
size_t patchSize = inPatch->serializedSize();
- void * newData = malloc(patchSize);
+ void* newData = malloc(patchSize);
memcpy(newData, data, patchSize);
Res_png_9patch* outPatch = inPatch->deserialize(newData);
// deserialization is done in place, so outPatch == newData
@@ -721,34 +724,6 @@
free(newData);
}
-static bool patch_equals(Res_png_9patch& patch1, Res_png_9patch& patch2) {
- if (!(patch1.numXDivs == patch2.numXDivs &&
- patch1.numYDivs == patch2.numYDivs &&
- patch1.numColors == patch2.numColors &&
- patch1.paddingLeft == patch2.paddingLeft &&
- patch1.paddingRight == patch2.paddingRight &&
- patch1.paddingTop == patch2.paddingTop &&
- patch1.paddingBottom == patch2.paddingBottom)) {
- return false;
- }
- for (int i = 0; i < patch1.numColors; i++) {
- if (patch1.colors[i] != patch2.colors[i]) {
- return false;
- }
- }
- for (int i = 0; i < patch1.numXDivs; i++) {
- if (patch1.xDivs[i] != patch2.xDivs[i]) {
- return false;
- }
- }
- for (int i = 0; i < patch1.numYDivs; i++) {
- if (patch1.yDivs[i] != patch2.yDivs[i]) {
- return false;
- }
- }
- return true;
-}
-
static void dump_image(int w, int h, png_bytepp rows, int color_type)
{
int i, j, rr, gg, bb, aa;
@@ -1061,7 +1036,7 @@
: (png_byte*)"npTc";
NOISY(printf("Adding 9-patch info...\n"));
strcpy((char*)unknowns[p_index].name, "npTc");
- unknowns[p_index].data = (png_byte*)imageInfo.info9Patch.serialize();
+ unknowns[p_index].data = (png_byte*)imageInfo.serialize9patch();
unknowns[p_index].size = imageInfo.info9Patch.serializedSize();
// TODO: remove the check below when everything works
checkNinePatchSerialization(&imageInfo.info9Patch, unknowns[p_index].data);
diff --git a/tools/aapt/Resource.cpp b/tools/aapt/Resource.cpp
index 386888b..4d29ff7 100644
--- a/tools/aapt/Resource.cpp
+++ b/tools/aapt/Resource.cpp
@@ -80,6 +80,7 @@
ResourceDirIterator(const sp<ResourceTypeSet>& set, const String8& resType)
: mResType(resType), mSet(set), mSetPos(0), mGroupPos(0)
{
+ memset(&mParams, 0, sizeof(ResTable_config));
}
inline const sp<AaptGroup>& getGroup() const { return mGroup; }
@@ -1320,8 +1321,7 @@
}
// Read resources back in,
- finalResTable.add(resFile->getData(), resFile->getSize(), NULL);
-
+ finalResTable.add(resFile->getData(), resFile->getSize());
#if 0
NOISY(
printf("Generated resources:\n");
diff --git a/tools/aapt/ResourceFilter.cpp b/tools/aapt/ResourceFilter.cpp
index 8cfd2a5..e8a2be4 100644
--- a/tools/aapt/ResourceFilter.cpp
+++ b/tools/aapt/ResourceFilter.cpp
@@ -28,8 +28,8 @@
mContainsPseudo = true;
}
int axis;
- uint32_t value;
- if (AaptGroupEntry::parseNamePart(part, &axis, &value)) {
+ AxisValue value;
+ if (!AaptGroupEntry::parseFilterNamePart(part, &axis, &value)) {
fprintf(stderr, "Invalid configuration: %s\n", arg);
fprintf(stderr, " ");
for (int i=0; i<p-arg; i++) {
@@ -44,15 +44,20 @@
ssize_t index = mData.indexOfKey(axis);
if (index < 0) {
- mData.add(axis, SortedVector<uint32_t>());
+ mData.add(axis, SortedVector<AxisValue>());
}
- SortedVector<uint32_t>& sv = mData.editValueFor(axis);
+ SortedVector<AxisValue>& sv = mData.editValueFor(axis);
sv.add(value);
- // if it's a locale with a region, also match an unmodified locale of the
- // same language
- if (axis == AXIS_LANGUAGE) {
- if (value & 0xffff0000) {
- sv.add(value & 0x0000ffff);
+
+ // If it's a locale with a region, script or variant, we should also match an
+ // unmodified locale of the same language
+ if (axis == AXIS_LOCALE) {
+ if (value.localeValue.region[0] || value.localeValue.script[0] ||
+ value.localeValue.variant[0]) {
+ AxisValue copy;
+ memcpy(copy.localeValue.language, value.localeValue.language,
+ sizeof(value.localeValue.language));
+ sv.add(copy);
}
}
p = q;
@@ -70,9 +75,9 @@
}
bool
-ResourceFilter::match(int axis, uint32_t value) const
+ResourceFilter::match(int axis, const AxisValue& value) const
{
- if (value == 0) {
+ if (value.intValue == 0 && (value.localeValue.language[0] == 0)) {
// they didn't specify anything so take everything
return true;
}
@@ -81,7 +86,7 @@
// we didn't request anything on this axis so take everything
return true;
}
- const SortedVector<uint32_t>& sv = mData.valueAt(index);
+ const SortedVector<AxisValue>& sv = mData.valueAt(index);
return sv.indexOf(value) >= 0;
}
@@ -102,7 +107,7 @@
return true;
}
-const SortedVector<uint32_t>* ResourceFilter::configsForAxis(int axis) const
+const SortedVector<AxisValue>* ResourceFilter::configsForAxis(int axis) const
{
ssize_t index = mData.indexOfKey(axis);
if (index < 0) {
diff --git a/tools/aapt/ResourceFilter.h b/tools/aapt/ResourceFilter.h
index 647b7bb..0d127ba 100644
--- a/tools/aapt/ResourceFilter.h
+++ b/tools/aapt/ResourceFilter.h
@@ -19,14 +19,15 @@
ResourceFilter() : mData(), mContainsPseudo(false) {}
status_t parse(const char* arg);
bool isEmpty() const;
- bool match(int axis, uint32_t value) const;
bool match(int axis, const ResTable_config& config) const;
bool match(const ResTable_config& config) const;
- const SortedVector<uint32_t>* configsForAxis(int axis) const;
+ const SortedVector<AxisValue>* configsForAxis(int axis) const;
inline bool containsPseudo() const { return mContainsPseudo; }
private:
- KeyedVector<int,SortedVector<uint32_t> > mData;
+ bool match(int axis, const AxisValue& value) const;
+
+ KeyedVector<int,SortedVector<AxisValue> > mData;
bool mContainsPseudo;
};
diff --git a/tools/aapt/ResourceIdCache.h b/tools/aapt/ResourceIdCache.h
index 65f7781..e6bcda2 100644
--- a/tools/aapt/ResourceIdCache.h
+++ b/tools/aapt/ResourceIdCache.h
@@ -7,7 +7,6 @@
#define RESOURCE_ID_CACHE_H
namespace android {
-class android::String16;
class ResourceIdCache {
public:
diff --git a/tools/aapt/ResourceTable.cpp b/tools/aapt/ResourceTable.cpp
index 6ced8b3..0b1f985 100644
--- a/tools/aapt/ResourceTable.cpp
+++ b/tools/aapt/ResourceTable.cpp
@@ -1292,8 +1292,8 @@
curIsStyled = true;
} else if (strcmp16(block.getElementName(&len), string16.string()) == 0) {
// Note the existence and locale of every string we process
- char rawLocale[16];
- curParams.getLocale(rawLocale);
+ char rawLocale[RESTABLE_MAX_LOCALE_LEN];
+ curParams.getBcp47Locale(rawLocale);
String8 locale(rawLocale);
String16 name;
String16 translatable;
@@ -1317,9 +1317,9 @@
curIsFormatted = false;
// Untranslatable strings must only exist in the default [empty] locale
if (locale.size() > 0) {
- fprintf(stderr, "aapt: warning: string '%s' in %s marked untranslatable but exists"
- " in locale '%s'\n", String8(name).string(),
- bundle->getResourceSourceDirs()[0],
+ SourcePos(in->getPrintableSource(), block.getLineNumber()).warning(
+ "string '%s' marked untranslatable but exists in locale '%s'\n",
+ String8(name).string(),
locale.string());
// hasErrors = localHasErrors = true;
} else {
@@ -1330,7 +1330,10 @@
// having no default translation.
}
} else {
- outTable->addLocalization(name, locale);
+ outTable->addLocalization(
+ name,
+ locale,
+ SourcePos(in->getPrintableSource(), block.getLineNumber()));
}
if (formatted == false16) {
@@ -2570,9 +2573,9 @@
void
-ResourceTable::addLocalization(const String16& name, const String8& locale)
+ResourceTable::addLocalization(const String16& name, const String8& locale, const SourcePos& src)
{
- mLocalizations[name].insert(locale);
+ mLocalizations[name][locale] = src;
}
@@ -2592,21 +2595,22 @@
const String8 defaultLocale;
// For all strings...
- for (map<String16, set<String8> >::iterator nameIter = mLocalizations.begin();
+ for (map<String16, map<String8, SourcePos> >::iterator nameIter = mLocalizations.begin();
nameIter != mLocalizations.end();
nameIter++) {
- const set<String8>& configSet = nameIter->second; // naming convenience
+ const map<String8, SourcePos>& configSrcMap = nameIter->second;
// Look for strings with no default localization
- if (configSet.count(defaultLocale) == 0) {
- fprintf(stdout, "aapt: warning: string '%s' has no default translation in %s; found:",
- String8(nameIter->first).string(), mBundle->getResourceSourceDirs()[0]);
- for (set<String8>::const_iterator locales = configSet.begin();
- locales != configSet.end();
- locales++) {
- fprintf(stdout, " %s", (*locales).string());
+ if (configSrcMap.count(defaultLocale) == 0) {
+ SourcePos().warning("string '%s' has no default translation.",
+ String8(nameIter->first).string());
+ if (mBundle->getVerbose()) {
+ for (map<String8, SourcePos>::const_iterator locales = configSrcMap.begin();
+ locales != configSrcMap.end();
+ locales++) {
+ locales->second.printf("locale %s found", locales->first.string());
+ }
}
- fprintf(stdout, "\n");
// !!! TODO: throw an error here in some circumstances
}
@@ -2616,6 +2620,8 @@
const char* start = allConfigs;
const char* comma;
+ set<String8> missingConfigs;
+ AaptLocaleValue locale;
do {
String8 config;
comma = strchr(start, ',');
@@ -2626,27 +2632,38 @@
config.setTo(start);
}
+ if (!locale.initFromFilterString(config)) {
+ continue;
+ }
+
// don't bother with the pseudolocale "zz_ZZ"
if (config != "zz_ZZ") {
- if (configSet.find(config) == configSet.end()) {
+ if (configSrcMap.find(config) == configSrcMap.end()) {
// okay, no specific localization found. it's possible that we are
// requiring a specific regional localization [e.g. de_DE] but there is an
// available string in the generic language localization [e.g. de];
// consider that string to have fulfilled the localization requirement.
String8 region(config.string(), 2);
- if (configSet.find(region) == configSet.end()) {
- if (configSet.count(defaultLocale) == 0) {
- fprintf(stdout, "aapt: warning: "
- "**** string '%s' has no default or required localization "
- "for '%s' in %s\n",
- String8(nameIter->first).string(),
- config.string(),
- mBundle->getResourceSourceDirs()[0]);
- }
+ if (configSrcMap.find(region) == configSrcMap.end() &&
+ configSrcMap.count(defaultLocale) == 0) {
+ missingConfigs.insert(config);
}
}
}
- } while (comma != NULL);
+ } while (comma != NULL);
+
+ if (!missingConfigs.empty()) {
+ String8 configStr;
+ for (set<String8>::iterator iter = missingConfigs.begin();
+ iter != missingConfigs.end();
+ iter++) {
+ configStr.appendFormat(" %s", iter->string());
+ }
+ SourcePos().warning("string '%s' is missing %u required localizations:%s",
+ String8(nameIter->first).string(),
+ (unsigned int)missingConfigs.size(),
+ configStr.string());
+ }
}
}
diff --git a/tools/aapt/ResourceTable.h b/tools/aapt/ResourceTable.h
index a3e0666..75005cd 100644
--- a/tools/aapt/ResourceTable.h
+++ b/tools/aapt/ResourceTable.h
@@ -220,7 +220,7 @@
status_t assignResourceIds();
status_t addSymbols(const sp<AaptSymbols>& outSymbols = NULL);
- void addLocalization(const String16& name, const String8& locale);
+ void addLocalization(const String16& name, const String8& locale, const SourcePos& src);
status_t validateLocalizations(void);
status_t flatten(Bundle*, const sp<AaptFile>& dest);
@@ -551,7 +551,7 @@
Bundle* mBundle;
// key = string resource name, value = set of locales in which that name is defined
- map<String16, set<String8> > mLocalizations;
+ map<String16, map<String8, SourcePos> > mLocalizations;
};
#endif
diff --git a/tools/aapt/SourcePos.cpp b/tools/aapt/SourcePos.cpp
index e2a921c..ae25047 100644
--- a/tools/aapt/SourcePos.cpp
+++ b/tools/aapt/SourcePos.cpp
@@ -10,17 +10,20 @@
// =============================================================================
struct ErrorPos
{
+ enum Level {
+ NOTE,
+ WARNING,
+ ERROR
+ };
+
String8 file;
int line;
String8 error;
- bool fatal;
+ Level level;
ErrorPos();
ErrorPos(const ErrorPos& that);
- ErrorPos(const String8& file, int line, const String8& error, bool fatal);
- ~ErrorPos();
- bool operator<(const ErrorPos& rhs) const;
- bool operator==(const ErrorPos& rhs) const;
+ ErrorPos(const String8& file, int line, const String8& error, Level level);
ErrorPos& operator=(const ErrorPos& rhs);
void print(FILE* to) const;
@@ -29,7 +32,7 @@
static vector<ErrorPos> g_errors;
ErrorPos::ErrorPos()
- :line(-1), fatal(false)
+ :line(-1), level(NOTE)
{
}
@@ -37,61 +40,52 @@
:file(that.file),
line(that.line),
error(that.error),
- fatal(that.fatal)
+ level(that.level)
{
}
-ErrorPos::ErrorPos(const String8& f, int l, const String8& e, bool fat)
+ErrorPos::ErrorPos(const String8& f, int l, const String8& e, Level lev)
:file(f),
line(l),
error(e),
- fatal(fat)
+ level(lev)
{
}
-ErrorPos::~ErrorPos()
-{
-}
-
-bool
-ErrorPos::operator<(const ErrorPos& rhs) const
-{
- if (this->file < rhs.file) return true;
- if (this->file == rhs.file) {
- if (this->line < rhs.line) return true;
- if (this->line == rhs.line) {
- if (this->error < rhs.error) return true;
- }
- }
- return false;
-}
-
-bool
-ErrorPos::operator==(const ErrorPos& rhs) const
-{
- return this->file == rhs.file
- && this->line == rhs.line
- && this->error == rhs.error;
-}
-
ErrorPos&
ErrorPos::operator=(const ErrorPos& rhs)
{
this->file = rhs.file;
this->line = rhs.line;
this->error = rhs.error;
+ this->level = rhs.level;
return *this;
}
void
ErrorPos::print(FILE* to) const
{
- const char* type = fatal ? "error:" : "warning:";
+ const char* type = "";
+ switch (level) {
+ case NOTE:
+ type = "note: ";
+ break;
+ case WARNING:
+ type = "warning: ";
+ break;
+ case ERROR:
+ type = "error: ";
+ break;
+ }
- if (this->line >= 0) {
- fprintf(to, "%s:%d: %s %s\n", this->file.string(), this->line, type, this->error.string());
+ if (!this->file.isEmpty()) {
+ if (this->line >= 0) {
+ fprintf(to, "%s:%d: %s%s\n", this->file.string(), this->line, type, this->error.string());
+ } else {
+ fprintf(to, "%s: %s%s\n", this->file.string(), type, this->error.string());
+ }
} else {
- fprintf(to, "%s: %s %s\n", this->file.string(), type, this->error.string());
+ fprintf(to, "%s%s\n", type, this->error.string());
}
}
@@ -116,40 +110,34 @@
{
}
-int
+void
SourcePos::error(const char* fmt, ...) const
{
- int retval=0;
- char buf[1024];
va_list ap;
va_start(ap, fmt);
- retval = vsnprintf(buf, sizeof(buf), fmt, ap);
+ String8 msg = String8::formatV(fmt, ap);
va_end(ap);
- char* p = buf + retval - 1;
- while (p > buf && *p == '\n') {
- *p = '\0';
- p--;
- }
- g_errors.push_back(ErrorPos(this->file, this->line, String8(buf), true));
- return retval;
+ g_errors.push_back(ErrorPos(this->file, this->line, msg, ErrorPos::ERROR));
}
-int
+void
SourcePos::warning(const char* fmt, ...) const
{
- int retval=0;
- char buf[1024];
va_list ap;
va_start(ap, fmt);
- retval = vsnprintf(buf, sizeof(buf), fmt, ap);
+ String8 msg = String8::formatV(fmt, ap);
va_end(ap);
- char* p = buf + retval - 1;
- while (p > buf && *p == '\n') {
- *p = '\0';
- p--;
- }
- ErrorPos(this->file, this->line, String8(buf), false).print(stderr);
- return retval;
+ ErrorPos(this->file, this->line, msg, ErrorPos::WARNING).print(stderr);
+}
+
+void
+SourcePos::printf(const char* fmt, ...) const
+{
+ va_list ap;
+ va_start(ap, fmt);
+ String8 msg = String8::formatV(fmt, ap);
+ va_end(ap);
+ ErrorPos(this->file, this->line, msg, ErrorPos::NOTE).print(stderr);
}
bool
diff --git a/tools/aapt/SourcePos.h b/tools/aapt/SourcePos.h
index 33f72a9..4ce817f 100644
--- a/tools/aapt/SourcePos.h
+++ b/tools/aapt/SourcePos.h
@@ -17,8 +17,9 @@
SourcePos();
~SourcePos();
- int error(const char* fmt, ...) const;
- int warning(const char* fmt, ...) const;
+ void error(const char* fmt, ...) const;
+ void warning(const char* fmt, ...) const;
+ void printf(const char* fmt, ...) const;
static bool hasErrors();
static void printErrors(FILE* to);
diff --git a/tools/aidl/Type.cpp b/tools/aidl/Type.cpp
index d572af6..2267750 100644
--- a/tools/aidl/Type.cpp
+++ b/tools/aidl/Type.cpp
@@ -1,5 +1,7 @@
#include "Type.h"
+#include <sys/types.h>
+
Namespace NAMES;
Type* VOID_TYPE;
diff --git a/tools/layoutlib/bridge/src/android/animation/PropertyValuesHolder_Delegate.java b/tools/layoutlib/bridge/src/android/animation/PropertyValuesHolder_Delegate.java
index 7b444aa..224eac6 100644
--- a/tools/layoutlib/bridge/src/android/animation/PropertyValuesHolder_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/animation/PropertyValuesHolder_Delegate.java
@@ -36,24 +36,24 @@
/*package*/ class PropertyValuesHolder_Delegate {
@LayoutlibDelegate
- /*package*/ static int nGetIntMethod(Class<?> targetClass, String methodName) {
+ /*package*/ static long nGetIntMethod(Class<?> targetClass, String methodName) {
// return 0 to force PropertyValuesHolder to use Java reflection.
return 0;
}
@LayoutlibDelegate
- /*package*/ static int nGetFloatMethod(Class<?> targetClass, String methodName) {
+ /*package*/ static long nGetFloatMethod(Class<?> targetClass, String methodName) {
// return 0 to force PropertyValuesHolder to use Java reflection.
return 0;
}
@LayoutlibDelegate
- /*package*/ static void nCallIntMethod(Object target, int methodID, int arg) {
+ /*package*/ static void nCallIntMethod(Object target, long methodID, int arg) {
// do nothing
}
@LayoutlibDelegate
- /*package*/ static void nCallFloatMethod(Object target, int methodID, float arg) {
+ /*package*/ static void nCallFloatMethod(Object target, long methodID, float arg) {
// do nothing
}
}
diff --git a/tools/layoutlib/bridge/src/android/graphics/AvoidXfermode_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/AvoidXfermode_Delegate.java
index a50a2bd..34ae825 100644
--- a/tools/layoutlib/bridge/src/android/graphics/AvoidXfermode_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/AvoidXfermode_Delegate.java
@@ -61,7 +61,7 @@
// ---- native methods ----
@LayoutlibDelegate
- /*package*/ static int nativeCreate(int opColor, int tolerance, int nativeMode) {
+ /*package*/ static long nativeCreate(int opColor, int tolerance, int nativeMode) {
AvoidXfermode_Delegate newDelegate = new AvoidXfermode_Delegate();
return sManager.addNewDelegate(newDelegate);
}
diff --git a/tools/layoutlib/bridge/src/android/graphics/BitmapFactory_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/BitmapFactory_Delegate.java
index 04ce9d0..06673c1 100644
--- a/tools/layoutlib/bridge/src/android/graphics/BitmapFactory_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/BitmapFactory_Delegate.java
@@ -44,62 +44,13 @@
*/
/*package*/ class BitmapFactory_Delegate {
- // ------ Java delegates ------
-
- @LayoutlibDelegate
- /*package*/ static Bitmap finishDecode(Bitmap bm, Rect outPadding, Options opts) {
- if (bm == null || opts == null) {
- return bm;
- }
-
- final int density = opts.inDensity;
- if (density == 0) {
- return bm;
- }
-
- bm.setDensity(density);
- final int targetDensity = opts.inTargetDensity;
- if (targetDensity == 0 || density == targetDensity || density == opts.inScreenDensity) {
- return bm;
- }
-
- byte[] np = bm.getNinePatchChunk();
- final boolean isNinePatch = np != null && NinePatch.isNinePatchChunk(np);
- // DELEGATE CHANGE: never scale 9-patch
- if (opts.inScaled && isNinePatch == false) {
- float scale = targetDensity / (float)density;
- // TODO: This is very inefficient and should be done in native by Skia
- final Bitmap oldBitmap = bm;
- bm = Bitmap.createScaledBitmap(oldBitmap, (int) (bm.getWidth() * scale + 0.5f),
- (int) (bm.getHeight() * scale + 0.5f), true);
- oldBitmap.recycle();
-
- if (isNinePatch) {
- np = nativeScaleNinePatch(np, scale, outPadding);
- bm.setNinePatchChunk(np);
- }
- bm.setDensity(targetDensity);
- }
-
- return bm;
- }
-
-
// ------ Native Delegates ------
@LayoutlibDelegate
/*package*/ static Bitmap nativeDecodeStream(InputStream is, byte[] storage,
Rect padding, Options opts) {
- return nativeDecodeStream(is, storage, padding, opts, false, 1.f);
- }
-
- @LayoutlibDelegate
- /*package*/ static Bitmap nativeDecodeStream(InputStream is, byte[] storage,
- Rect padding, Options opts, boolean applyScale, float scale) {
Bitmap bm = null;
- //TODO support rescaling
-
Density density = Density.MEDIUM;
Set<BitmapCreateFlags> bitmapCreateFlags = EnumSet.of(BitmapCreateFlags.MUTABLE);
if (opts != null) {
@@ -151,14 +102,7 @@
}
@LayoutlibDelegate
- /*package*/ static Bitmap nativeDecodeAsset(int asset, Rect padding, Options opts) {
- opts.inBitmap = null;
- return null;
- }
-
- @LayoutlibDelegate
- /*package*/ static Bitmap nativeDecodeAsset(int asset, Rect padding, Options opts,
- boolean applyScale, float scale) {
+ /*package*/ static Bitmap nativeDecodeAsset(long asset, Rect padding, Options opts) {
opts.inBitmap = null;
return null;
}
@@ -171,13 +115,6 @@
}
@LayoutlibDelegate
- /*package*/ static byte[] nativeScaleNinePatch(byte[] chunk, float scale, Rect pad) {
- // don't scale for now. This should not be called anyway since we re-implement
- // BitmapFactory.finishDecode();
- return chunk;
- }
-
- @LayoutlibDelegate
/*package*/ static boolean nativeIsSeekable(FileDescriptor fd) {
return true;
}
diff --git a/tools/layoutlib/bridge/src/android/graphics/BitmapShader_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/BitmapShader_Delegate.java
index 65a75b0..cdbbe46 100644
--- a/tools/layoutlib/bridge/src/android/graphics/BitmapShader_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/BitmapShader_Delegate.java
@@ -65,7 +65,7 @@
// ---- native methods ----
@LayoutlibDelegate
- /*package*/ static int nativeCreate(int native_bitmap, int shaderTileModeX,
+ /*package*/ static long nativeCreate(long native_bitmap, int shaderTileModeX,
int shaderTileModeY) {
Bitmap_Delegate bitmap = Bitmap_Delegate.getDelegate(native_bitmap);
if (bitmap == null) {
@@ -80,7 +80,7 @@
}
@LayoutlibDelegate
- /*package*/ static int nativePostCreate(int native_shader, int native_bitmap,
+ /*package*/ static long nativePostCreate(long native_shader, long native_bitmap,
int shaderTileModeX, int shaderTileModeY) {
// pass, not needed.
return 0;
diff --git a/tools/layoutlib/bridge/src/android/graphics/Bitmap_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Bitmap_Delegate.java
index 93284db..89d7e23 100644
--- a/tools/layoutlib/bridge/src/android/graphics/Bitmap_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/Bitmap_Delegate.java
@@ -83,7 +83,7 @@
/**
* Returns the native delegate associated to a given an int referencing a {@link Bitmap} object.
*/
- public static Bitmap_Delegate getDelegate(int native_bitmap) {
+ public static Bitmap_Delegate getDelegate(long native_bitmap) {
return sManager.getDelegate(native_bitmap);
}
@@ -274,7 +274,7 @@
}
@LayoutlibDelegate
- /*package*/ static Bitmap nativeCopy(int srcBitmap, int nativeConfig, boolean isMutable) {
+ /*package*/ static Bitmap nativeCopy(long srcBitmap, int nativeConfig, boolean isMutable) {
Bitmap_Delegate srcBmpDelegate = sManager.getDelegate(srcBitmap);
if (srcBmpDelegate == null) {
return null;
@@ -303,18 +303,25 @@
}
@LayoutlibDelegate
- /*package*/ static void nativeDestructor(int nativeBitmap) {
+ /*package*/ static void nativeDestructor(long nativeBitmap) {
sManager.removeJavaReferenceFor(nativeBitmap);
}
@LayoutlibDelegate
- /*package*/ static boolean nativeRecycle(int nativeBitmap) {
+ /*package*/ static boolean nativeRecycle(long nativeBitmap) {
sManager.removeJavaReferenceFor(nativeBitmap);
return true;
}
@LayoutlibDelegate
- /*package*/ static boolean nativeCompress(int nativeBitmap, int format, int quality,
+ /*package*/ static void nativeReconfigure(long nativeBitmap, int width, int height,
+ int config, int allocSize) {
+ Bridge.getLog().error(LayoutLog.TAG_UNSUPPORTED,
+ "Bitmap.reconfigure() is not supported", null /*data*/);
+ }
+
+ @LayoutlibDelegate
+ /*package*/ static boolean nativeCompress(long nativeBitmap, int format, int quality,
OutputStream stream, byte[] tempStorage) {
Bridge.getLog().error(LayoutLog.TAG_UNSUPPORTED,
"Bitmap.compress() is not supported", null /*data*/);
@@ -322,7 +329,7 @@
}
@LayoutlibDelegate
- /*package*/ static void nativeErase(int nativeBitmap, int color) {
+ /*package*/ static void nativeErase(long nativeBitmap, int color) {
// get the delegate from the native int.
Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap);
if (delegate == null) {
@@ -342,7 +349,7 @@
}
@LayoutlibDelegate
- /*package*/ static int nativeWidth(int nativeBitmap) {
+ /*package*/ static int nativeRowBytes(long nativeBitmap) {
// get the delegate from the native int.
Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap);
if (delegate == null) {
@@ -353,29 +360,7 @@
}
@LayoutlibDelegate
- /*package*/ static int nativeHeight(int nativeBitmap) {
- // get the delegate from the native int.
- Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap);
- if (delegate == null) {
- return 0;
- }
-
- return delegate.mImage.getHeight();
- }
-
- @LayoutlibDelegate
- /*package*/ static int nativeRowBytes(int nativeBitmap) {
- // get the delegate from the native int.
- Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap);
- if (delegate == null) {
- return 0;
- }
-
- return delegate.mImage.getWidth();
- }
-
- @LayoutlibDelegate
- /*package*/ static int nativeConfig(int nativeBitmap) {
+ /*package*/ static int nativeConfig(long nativeBitmap) {
// get the delegate from the native int.
Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap);
if (delegate == null) {
@@ -386,7 +371,7 @@
}
@LayoutlibDelegate
- /*package*/ static boolean nativeHasAlpha(int nativeBitmap) {
+ /*package*/ static boolean nativeHasAlpha(long nativeBitmap) {
// get the delegate from the native int.
Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap);
if (delegate == null) {
@@ -397,7 +382,7 @@
}
@LayoutlibDelegate
- /*package*/ static boolean nativeHasMipMap(int nativeBitmap) {
+ /*package*/ static boolean nativeHasMipMap(long nativeBitmap) {
// get the delegate from the native int.
Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap);
if (delegate == null) {
@@ -408,19 +393,21 @@
}
@LayoutlibDelegate
- /*package*/ static int nativeGetPixel(int nativeBitmap, int x, int y) {
+ /*package*/ static int nativeGetPixel(long nativeBitmap, int x, int y,
+ boolean isPremultiplied) {
// get the delegate from the native int.
Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap);
if (delegate == null) {
return 0;
}
+ // TODO: Support isPremultiplied.
return delegate.mImage.getRGB(x, y);
}
@LayoutlibDelegate
- /*package*/ static void nativeGetPixels(int nativeBitmap, int[] pixels, int offset,
- int stride, int x, int y, int width, int height) {
+ /*package*/ static void nativeGetPixels(long nativeBitmap, int[] pixels, int offset,
+ int stride, int x, int y, int width, int height, boolean isPremultiplied) {
Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap);
if (delegate == null) {
return;
@@ -431,7 +418,8 @@
@LayoutlibDelegate
- /*package*/ static void nativeSetPixel(int nativeBitmap, int x, int y, int color) {
+ /*package*/ static void nativeSetPixel(long nativeBitmap, int x, int y, int color,
+ boolean isPremultiplied) {
Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap);
if (delegate == null) {
return;
@@ -441,8 +429,8 @@
}
@LayoutlibDelegate
- /*package*/ static void nativeSetPixels(int nativeBitmap, int[] colors, int offset,
- int stride, int x, int y, int width, int height) {
+ /*package*/ static void nativeSetPixels(long nativeBitmap, int[] colors, int offset,
+ int stride, int x, int y, int width, int height, boolean isPremultiplied) {
Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap);
if (delegate == null) {
return;
@@ -452,21 +440,21 @@
}
@LayoutlibDelegate
- /*package*/ static void nativeCopyPixelsToBuffer(int nativeBitmap, Buffer dst) {
+ /*package*/ static void nativeCopyPixelsToBuffer(long nativeBitmap, Buffer dst) {
// FIXME implement native delegate
Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED,
"Bitmap.copyPixelsToBuffer is not supported.", null, null /*data*/);
}
@LayoutlibDelegate
- /*package*/ static void nativeCopyPixelsFromBuffer(int nb, Buffer src) {
+ /*package*/ static void nativeCopyPixelsFromBuffer(long nb, Buffer src) {
// FIXME implement native delegate
Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED,
"Bitmap.copyPixelsFromBuffer is not supported.", null, null /*data*/);
}
@LayoutlibDelegate
- /*package*/ static int nativeGenerationId(int nativeBitmap) {
+ /*package*/ static int nativeGenerationId(long nativeBitmap) {
Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap);
if (delegate == null) {
return 0;
@@ -486,7 +474,7 @@
}
@LayoutlibDelegate
- /*package*/ static boolean nativeWriteToParcel(int nativeBitmap, boolean isMutable,
+ /*package*/ static boolean nativeWriteToParcel(long nativeBitmap, boolean isMutable,
int density, Parcel p) {
// This is only called when sending a bitmap through aidl, so really this should not
// be called.
@@ -497,7 +485,7 @@
}
@LayoutlibDelegate
- /*package*/ static Bitmap nativeExtractAlpha(int nativeBitmap, int nativePaint,
+ /*package*/ static Bitmap nativeExtractAlpha(long nativeBitmap, long nativePaint,
int[] offsetXY) {
Bitmap_Delegate bitmap = sManager.getDelegate(nativeBitmap);
if (bitmap == null) {
@@ -525,12 +513,12 @@
}
@LayoutlibDelegate
- /*package*/ static void nativePrepareToDraw(int nativeBitmap) {
+ /*package*/ static void nativePrepareToDraw(long nativeBitmap) {
// nothing to be done here.
}
@LayoutlibDelegate
- /*package*/ static void nativeSetHasAlpha(int nativeBitmap, boolean hasAlpha) {
+ /*package*/ static void nativeSetHasAlpha(long nativeBitmap, boolean hasAlpha) {
// get the delegate from the native int.
Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap);
if (delegate == null) {
@@ -541,7 +529,7 @@
}
@LayoutlibDelegate
- /*package*/ static void nativeSetHasMipMap(int nativeBitmap, boolean hasMipMap) {
+ /*package*/ static void nativeSetHasMipMap(long nativeBitmap, boolean hasMipMap) {
// get the delegate from the native int.
Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap);
if (delegate == null) {
@@ -552,7 +540,7 @@
}
@LayoutlibDelegate
- /*package*/ static boolean nativeSameAs(int nb0, int nb1) {
+ /*package*/ static boolean nativeSameAs(long nb0, long nb1) {
Bitmap_Delegate delegate1 = sManager.getDelegate(nb0);
if (delegate1 == null) {
return false;
@@ -605,7 +593,7 @@
private static Bitmap createBitmap(Bitmap_Delegate delegate,
Set<BitmapCreateFlags> createFlags, int density) {
// get its native_int
- int nativeInt = sManager.addNewDelegate(delegate);
+ long nativeInt = sManager.addNewDelegate(delegate);
int width = delegate.mImage.getWidth();
int height = delegate.mImage.getHeight();
diff --git a/tools/layoutlib/bridge/src/android/graphics/BlurMaskFilter_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/BlurMaskFilter_Delegate.java
index 4becba1..d2569c7 100644
--- a/tools/layoutlib/bridge/src/android/graphics/BlurMaskFilter_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/BlurMaskFilter_Delegate.java
@@ -55,7 +55,7 @@
// ---- native methods ----
@LayoutlibDelegate
- /*package*/ static int nativeConstructor(float radius, int style) {
+ /*package*/ static long nativeConstructor(float radius, int style) {
BlurMaskFilter_Delegate newDelegate = new BlurMaskFilter_Delegate();
return sManager.addNewDelegate(newDelegate);
}
diff --git a/tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java
index 62b47bd..3111f0d 100644
--- a/tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java
@@ -77,7 +77,7 @@
/**
* Returns the native delegate associated to a given an int referencing a {@link Canvas} object.
*/
- public static Canvas_Delegate getDelegate(int native_canvas) {
+ public static Canvas_Delegate getDelegate(long native_canvas) {
return sManager.getDelegate(native_canvas);
}
@@ -310,7 +310,7 @@
}
@LayoutlibDelegate
- /*package*/ static int initRaster(int nativeBitmapOrZero) {
+ /*package*/ static long initRaster(long nativeBitmapOrZero) {
if (nativeBitmapOrZero > 0) {
// get the Bitmap from the int
Bitmap_Delegate bitmapDelegate = Bitmap_Delegate.getDelegate(nativeBitmapOrZero);
@@ -328,7 +328,7 @@
}
@LayoutlibDelegate
- /*package*/ static void copyNativeCanvasState(int srcCanvas, int dstCanvas) {
+ /*package*/ static void copyNativeCanvasState(long srcCanvas, long dstCanvas) {
// get the delegate from the native int.
Canvas_Delegate srcCanvasDelegate = sManager.getDelegate(srcCanvas);
if (srcCanvasDelegate == null) {
@@ -344,8 +344,8 @@
}
@LayoutlibDelegate
- /*package*/ static int native_saveLayer(int nativeCanvas, RectF bounds,
- int paint, int layerFlags) {
+ /*package*/ static long native_saveLayer(long nativeCanvas, RectF bounds,
+ long paint, int layerFlags) {
// get the delegate from the native int.
Canvas_Delegate canvasDelegate = sManager.getDelegate(nativeCanvas);
if (canvasDelegate == null) {
@@ -361,9 +361,9 @@
}
@LayoutlibDelegate
- /*package*/ static int native_saveLayer(int nativeCanvas, float l,
+ /*package*/ static long native_saveLayer(long nativeCanvas, float l,
float t, float r, float b,
- int paint, int layerFlags) {
+ long paint, int layerFlags) {
// get the delegate from the native int.
Canvas_Delegate canvasDelegate = sManager.getDelegate(nativeCanvas);
if (canvasDelegate == null) {
@@ -380,7 +380,7 @@
}
@LayoutlibDelegate
- /*package*/ static int native_saveLayerAlpha(int nativeCanvas,
+ /*package*/ static long native_saveLayerAlpha(long nativeCanvas,
RectF bounds, int alpha,
int layerFlags) {
// get the delegate from the native int.
@@ -393,7 +393,7 @@
}
@LayoutlibDelegate
- /*package*/ static int native_saveLayerAlpha(int nativeCanvas, float l,
+ /*package*/ static long native_saveLayerAlpha(long nativeCanvas, float l,
float t, float r, float b,
int alpha, int layerFlags) {
// get the delegate from the native int.
@@ -407,7 +407,7 @@
@LayoutlibDelegate
- /*package*/ static void native_concat(int nCanvas, int nMatrix) {
+ /*package*/ static void native_concat(long nCanvas, long nMatrix) {
// get the delegate from the native int.
Canvas_Delegate canvasDelegate = sManager.getDelegate(nCanvas);
if (canvasDelegate == null) {
@@ -435,7 +435,7 @@
}
@LayoutlibDelegate
- /*package*/ static void native_setMatrix(int nCanvas, int nMatrix) {
+ /*package*/ static void native_setMatrix(long nCanvas, long nMatrix) {
// get the delegate from the native int.
Canvas_Delegate canvasDelegate = sManager.getDelegate(nCanvas);
if (canvasDelegate == null) {
@@ -465,7 +465,7 @@
}
@LayoutlibDelegate
- /*package*/ static boolean native_clipRect(int nCanvas,
+ /*package*/ static boolean native_clipRect(long nCanvas,
float left, float top,
float right, float bottom,
int regionOp) {
@@ -480,8 +480,8 @@
}
@LayoutlibDelegate
- /*package*/ static boolean native_clipPath(int nativeCanvas,
- int nativePath,
+ /*package*/ static boolean native_clipPath(long nativeCanvas,
+ long nativePath,
int regionOp) {
Canvas_Delegate canvasDelegate = sManager.getDelegate(nativeCanvas);
if (canvasDelegate == null) {
@@ -497,8 +497,8 @@
}
@LayoutlibDelegate
- /*package*/ static boolean native_clipRegion(int nativeCanvas,
- int nativeRegion,
+ /*package*/ static boolean native_clipRegion(long nativeCanvas,
+ long nativeRegion,
int regionOp) {
Canvas_Delegate canvasDelegate = sManager.getDelegate(nativeCanvas);
if (canvasDelegate == null) {
@@ -514,7 +514,7 @@
}
@LayoutlibDelegate
- /*package*/ static void nativeSetDrawFilter(int nativeCanvas, int nativeFilter) {
+ /*package*/ static void nativeSetDrawFilter(long nativeCanvas, long nativeFilter) {
Canvas_Delegate canvasDelegate = sManager.getDelegate(nativeCanvas);
if (canvasDelegate == null) {
return;
@@ -530,7 +530,7 @@
}
@LayoutlibDelegate
- /*package*/ static boolean native_getClipBounds(int nativeCanvas,
+ /*package*/ static boolean native_getClipBounds(long nativeCanvas,
Rect bounds) {
// get the delegate from the native int.
Canvas_Delegate canvasDelegate = sManager.getDelegate(nativeCanvas);
@@ -551,7 +551,7 @@
}
@LayoutlibDelegate
- /*package*/ static void native_getCTM(int canvas, int matrix) {
+ /*package*/ static void native_getCTM(long canvas, long matrix) {
// get the delegate from the native int.
Canvas_Delegate canvasDelegate = sManager.getDelegate(canvas);
if (canvasDelegate == null) {
@@ -568,21 +568,21 @@
}
@LayoutlibDelegate
- /*package*/ static boolean native_quickReject(int nativeCanvas,
+ /*package*/ static boolean native_quickReject(long nativeCanvas,
RectF rect) {
// FIXME properly implement quickReject
return false;
}
@LayoutlibDelegate
- /*package*/ static boolean native_quickReject(int nativeCanvas,
- int path) {
+ /*package*/ static boolean native_quickReject(long nativeCanvas,
+ long path) {
// FIXME properly implement quickReject
return false;
}
@LayoutlibDelegate
- /*package*/ static boolean native_quickReject(int nativeCanvas,
+ /*package*/ static boolean native_quickReject(long nativeCanvas,
float left, float top,
float right, float bottom) {
// FIXME properly implement quickReject
@@ -590,25 +590,25 @@
}
@LayoutlibDelegate
- /*package*/ static void native_drawRGB(int nativeCanvas, int r, int g, int b) {
+ /*package*/ static void native_drawRGB(long nativeCanvas, int r, int g, int b) {
native_drawColor(nativeCanvas, 0xFF000000 | r << 16 | (g&0xFF) << 8 | (b&0xFF),
PorterDuff.Mode.SRC_OVER.nativeInt);
}
@LayoutlibDelegate
- /*package*/ static void native_drawARGB(int nativeCanvas, int a, int r, int g, int b) {
+ /*package*/ static void native_drawARGB(long nativeCanvas, int a, int r, int g, int b) {
native_drawColor(nativeCanvas, a << 24 | (r&0xFF) << 16 | (g&0xFF) << 8 | (b&0xFF),
PorterDuff.Mode.SRC_OVER.nativeInt);
}
@LayoutlibDelegate
- /*package*/ static void native_drawColor(int nativeCanvas, int color) {
+ /*package*/ static void native_drawColor(long nativeCanvas, int color) {
native_drawColor(nativeCanvas, color, PorterDuff.Mode.SRC_OVER.nativeInt);
}
@LayoutlibDelegate
- /*package*/ static void native_drawColor(int nativeCanvas, final int color, final int mode) {
+ /*package*/ static void native_drawColor(long nativeCanvas, final int color, final int mode) {
// get the delegate from the native int.
Canvas_Delegate canvasDelegate = sManager.getDelegate(nativeCanvas);
if (canvasDelegate == null) {
@@ -639,16 +639,16 @@
}
@LayoutlibDelegate
- /*package*/ static void native_drawPaint(int nativeCanvas, int paint) {
+ /*package*/ static void native_drawPaint(long nativeCanvas, long paint) {
// FIXME
Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED,
"Canvas.drawPaint is not supported.", null, null /*data*/);
}
@LayoutlibDelegate
- /*package*/ static void native_drawLine(int nativeCanvas,
+ /*package*/ static void native_drawLine(long nativeCanvas,
final float startX, final float startY, final float stopX, final float stopY,
- int paint) {
+ long paint) {
draw(nativeCanvas, paint, false /*compositeOnly*/, false /*forceSrcMode*/,
new GcSnapshot.Drawable() {
@@ -660,14 +660,13 @@
}
@LayoutlibDelegate
- /*package*/ static void native_drawRect(int nativeCanvas, RectF rect,
- int paint) {
+ /*package*/ static void native_drawRect(long nativeCanvas, RectF rect, long paint) {
native_drawRect(nativeCanvas, rect.left, rect.top, rect.right, rect.bottom, paint);
}
@LayoutlibDelegate
- /*package*/ static void native_drawRect(int nativeCanvas,
- final float left, final float top, final float right, final float bottom, int paint) {
+ /*package*/ static void native_drawRect(long nativeCanvas,
+ final float left, final float top, final float right, final float bottom, long paint) {
draw(nativeCanvas, paint, false /*compositeOnly*/, false /*forceSrcMode*/,
new GcSnapshot.Drawable() {
@@ -692,7 +691,7 @@
}
@LayoutlibDelegate
- /*package*/ static void native_drawOval(int nativeCanvas, final RectF oval, int paint) {
+ /*package*/ static void native_drawOval(long nativeCanvas, final RectF oval, long paint) {
if (oval.right > oval.left && oval.bottom > oval.top) {
draw(nativeCanvas, paint, false /*compositeOnly*/, false /*forceSrcMode*/,
new GcSnapshot.Drawable() {
@@ -718,17 +717,17 @@
}
@LayoutlibDelegate
- /*package*/ static void native_drawCircle(int nativeCanvas,
- float cx, float cy, float radius, int paint) {
+ /*package*/ static void native_drawCircle(long nativeCanvas,
+ float cx, float cy, float radius, long paint) {
native_drawOval(nativeCanvas,
new RectF(cx - radius, cy - radius, cx + radius, cy + radius),
paint);
}
@LayoutlibDelegate
- /*package*/ static void native_drawArc(int nativeCanvas,
+ /*package*/ static void native_drawArc(long nativeCanvas,
final RectF oval, final float startAngle, final float sweep,
- final boolean useCenter, int paint) {
+ final boolean useCenter, long paint) {
if (oval.right > oval.left && oval.bottom > oval.top) {
draw(nativeCanvas, paint, false /*compositeOnly*/, false /*forceSrcMode*/,
new GcSnapshot.Drawable() {
@@ -757,8 +756,8 @@
}
@LayoutlibDelegate
- /*package*/ static void native_drawRoundRect(int nativeCanvas,
- final RectF rect, final float rx, final float ry, int paint) {
+ /*package*/ static void native_drawRoundRect(long nativeCanvas,
+ final RectF rect, final float rx, final float ry, long paint) {
draw(nativeCanvas, paint, false /*compositeOnly*/, false /*forceSrcMode*/,
new GcSnapshot.Drawable() {
@@ -787,7 +786,7 @@
}
@LayoutlibDelegate
- /*package*/ static void native_drawPath(int nativeCanvas, int path, int paint) {
+ /*package*/ static void native_drawPath(long nativeCanvas, long path, long paint) {
final Path_Delegate pathDelegate = Path_Delegate.getDelegate(path);
if (pathDelegate == null) {
return;
@@ -814,9 +813,9 @@
}
@LayoutlibDelegate
- /*package*/ static void native_drawBitmap(Canvas thisCanvas, int nativeCanvas, int bitmap,
+ /*package*/ static void native_drawBitmap(Canvas thisCanvas, long nativeCanvas, long bitmap,
float left, float top,
- int nativePaintOrZero,
+ long nativePaintOrZero,
int canvasDensity,
int screenDensity,
int bitmapDensity) {
@@ -836,9 +835,9 @@
}
@LayoutlibDelegate
- /*package*/ static void native_drawBitmap(Canvas thisCanvas, int nativeCanvas, int bitmap,
+ /*package*/ static void native_drawBitmap(Canvas thisCanvas, long nativeCanvas, long bitmap,
Rect src, RectF dst,
- int nativePaintOrZero,
+ long nativePaintOrZero,
int screenDensity,
int bitmapDensity) {
// get the delegate from the native int.
@@ -861,9 +860,9 @@
}
@LayoutlibDelegate
- /*package*/ static void native_drawBitmap(int nativeCanvas, int bitmap,
+ /*package*/ static void native_drawBitmap(long nativeCanvas, long bitmap,
Rect src, Rect dst,
- int nativePaintOrZero,
+ long nativePaintOrZero,
int screenDensity,
int bitmapDensity) {
// get the delegate from the native int.
@@ -886,11 +885,11 @@
}
@LayoutlibDelegate
- /*package*/ static void native_drawBitmap(int nativeCanvas, int[] colors,
+ /*package*/ static void native_drawBitmap(long nativeCanvas, int[] colors,
int offset, int stride, final float x,
final float y, int width, int height,
boolean hasAlpha,
- int nativePaintOrZero) {
+ long nativePaintOrZero) {
// create a temp BufferedImage containing the content.
final BufferedImage image = new BufferedImage(width, height,
@@ -912,8 +911,8 @@
}
@LayoutlibDelegate
- /*package*/ static void nativeDrawBitmapMatrix(int nCanvas, int nBitmap,
- int nMatrix, int nPaint) {
+ /*package*/ static void nativeDrawBitmapMatrix(long nCanvas, long nBitmap,
+ long nMatrix, long nPaint) {
// get the delegate from the native int.
Canvas_Delegate canvasDelegate = sManager.getDelegate(nCanvas);
if (canvasDelegate == null) {
@@ -953,30 +952,30 @@
}
@LayoutlibDelegate
- /*package*/ static void nativeDrawBitmapMesh(int nCanvas, int nBitmap,
+ /*package*/ static void nativeDrawBitmapMesh(long nCanvas, long nBitmap,
int meshWidth, int meshHeight, float[] verts, int vertOffset, int[] colors,
- int colorOffset, int nPaint) {
+ int colorOffset, long nPaint) {
// FIXME
Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED,
"Canvas.drawBitmapMesh is not supported.", null, null /*data*/);
}
@LayoutlibDelegate
- /*package*/ static void nativeDrawVertices(int nCanvas, int mode, int n,
+ /*package*/ static void nativeDrawVertices(long nCanvas, int mode, int n,
float[] verts, int vertOffset,
float[] texs, int texOffset,
int[] colors, int colorOffset,
short[] indices, int indexOffset,
- int indexCount, int nPaint) {
+ int indexCount, long nPaint) {
// FIXME
Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED,
"Canvas.drawVertices is not supported.", null, null /*data*/);
}
@LayoutlibDelegate
- /*package*/ static void native_drawText(int nativeCanvas,
+ /*package*/ static void native_drawText(long nativeCanvas,
final char[] text, final int index, final int count,
- final float startX, final float startY, final int flags, int paint) {
+ final float startX, final float startY, final int flags, long paint) {
draw(nativeCanvas, paint, false /*compositeOnly*/, false /*forceSrcMode*/,
new GcSnapshot.Drawable() {
@@ -1005,8 +1004,8 @@
}
@LayoutlibDelegate
- /*package*/ static void native_drawText(int nativeCanvas, String text,
- int start, int end, float x, float y, final int flags, int paint) {
+ /*package*/ static void native_drawText(long nativeCanvas, String text,
+ int start, int end, float x, float y, final int flags, long paint) {
int count = end - start;
char[] buffer = TemporaryBuffer.obtain(count);
TextUtils.getChars(text, start, end, buffer, 0);
@@ -1015,9 +1014,9 @@
}
@LayoutlibDelegate
- /*package*/ static void native_drawTextRun(int nativeCanvas, String text,
+ /*package*/ static void native_drawTextRun(long nativeCanvas, String text,
int start, int end, int contextStart, int contextEnd,
- float x, float y, int flags, int paint) {
+ float x, float y, int flags, long paint) {
int count = end - start;
char[] buffer = TemporaryBuffer.obtain(count);
TextUtils.getChars(text, start, end, buffer, 0);
@@ -1026,56 +1025,56 @@
}
@LayoutlibDelegate
- /*package*/ static void native_drawTextRun(int nativeCanvas, char[] text,
+ /*package*/ static void native_drawTextRun(long nativeCanvas, char[] text,
int start, int count, int contextStart, int contextCount,
- float x, float y, int flags, int paint) {
+ float x, float y, int flags, long paint) {
native_drawText(nativeCanvas, text, start, count, x, y, flags, paint);
}
@LayoutlibDelegate
- /*package*/ static void native_drawPosText(int nativeCanvas,
+ /*package*/ static void native_drawPosText(long nativeCanvas,
char[] text, int index,
int count, float[] pos,
- int paint) {
+ long paint) {
// FIXME
Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED,
"Canvas.drawPosText is not supported.", null, null /*data*/);
}
@LayoutlibDelegate
- /*package*/ static void native_drawPosText(int nativeCanvas,
+ /*package*/ static void native_drawPosText(long nativeCanvas,
String text, float[] pos,
- int paint) {
+ long paint) {
// FIXME
Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED,
"Canvas.drawPosText is not supported.", null, null /*data*/);
}
@LayoutlibDelegate
- /*package*/ static void native_drawTextOnPath(int nativeCanvas,
+ /*package*/ static void native_drawTextOnPath(long nativeCanvas,
char[] text, int index,
- int count, int path,
+ int count, long path,
float hOffset,
float vOffset, int bidiFlags,
- int paint) {
+ long paint) {
// FIXME
Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED,
"Canvas.drawTextOnPath is not supported.", null, null /*data*/);
}
@LayoutlibDelegate
- /*package*/ static void native_drawTextOnPath(int nativeCanvas,
- String text, int path,
+ /*package*/ static void native_drawTextOnPath(long nativeCanvas,
+ String text, long path,
float hOffset,
float vOffset,
- int flags, int paint) {
+ int flags, long paint) {
// FIXME
Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED,
"Canvas.drawTextOnPath is not supported.", null, null /*data*/);
}
@LayoutlibDelegate
- /*package*/ static void finalizer(int nativeCanvas) {
+ /*package*/ static void finalizer(long nativeCanvas) {
// get the delegate from the native int so that it can be disposed.
Canvas_Delegate canvasDelegate = sManager.getDelegate(nativeCanvas);
if (canvasDelegate == null) {
@@ -1095,7 +1094,7 @@
* <p>Note that the drawable may actually be executed several times if there are
* layers involved (see {@link #saveLayer(RectF, int, int)}.
*/
- private static void draw(int nCanvas, int nPaint, boolean compositeOnly, boolean forceSrcMode,
+ private static void draw(long nCanvas, long nPaint, boolean compositeOnly, boolean forceSrcMode,
GcSnapshot.Drawable drawable) {
// get the delegate from the native int.
Canvas_Delegate canvasDelegate = sManager.getDelegate(nCanvas);
@@ -1115,7 +1114,7 @@
* <p>Note that the drawable may actually be executed several times if there are
* layers involved (see {@link #saveLayer(RectF, int, int)}.
*/
- private static void draw(int nCanvas, GcSnapshot.Drawable drawable) {
+ private static void draw(long nCanvas, GcSnapshot.Drawable drawable) {
// get the delegate from the native int.
Canvas_Delegate canvasDelegate = sManager.getDelegate(nCanvas);
if (canvasDelegate == null) {
@@ -1193,9 +1192,9 @@
}
private static void drawBitmap(
- int nativeCanvas,
+ long nativeCanvas,
Bitmap_Delegate bitmap,
- int nativePaintOrZero,
+ long nativePaintOrZero,
final int sleft, final int stop, final int sright, final int sbottom,
final int dleft, final int dtop, final int dright, final int dbottom) {
// get the delegate from the native int.
diff --git a/tools/layoutlib/bridge/src/android/graphics/ColorFilter_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/ColorFilter_Delegate.java
index e5a7ab6..d6b3da1 100644
--- a/tools/layoutlib/bridge/src/android/graphics/ColorFilter_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/ColorFilter_Delegate.java
@@ -46,7 +46,7 @@
// ---- Public Helper methods ----
- public static ColorFilter_Delegate getDelegate(int nativeShader) {
+ public static ColorFilter_Delegate getDelegate(long nativeShader) {
return sManager.getDelegate(nativeShader);
}
@@ -56,7 +56,7 @@
// ---- native methods ----
@LayoutlibDelegate
- /*package*/ static void finalizer(int native_instance, int nativeColorFilter) {
+ /*package*/ static void finalizer(long native_instance, long nativeColorFilter) {
sManager.removeJavaReferenceFor(native_instance);
}
diff --git a/tools/layoutlib/bridge/src/android/graphics/ColorMatrixColorFilter_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/ColorMatrixColorFilter_Delegate.java
index 2de344b..ca8f450 100644
--- a/tools/layoutlib/bridge/src/android/graphics/ColorMatrixColorFilter_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/ColorMatrixColorFilter_Delegate.java
@@ -55,13 +55,13 @@
// ---- native methods ----
@LayoutlibDelegate
- /*package*/ static int nativeColorMatrixFilter(float[] array) {
+ /*package*/ static long nativeColorMatrixFilter(float[] array) {
ColorMatrixColorFilter_Delegate newDelegate = new ColorMatrixColorFilter_Delegate();
return sManager.addNewDelegate(newDelegate);
}
@LayoutlibDelegate
- /*package*/ static int nColorMatrixFilter(int nativeFilter, float[] array) {
+ /*package*/ static long nColorMatrixFilter(long nativeFilter, float[] array) {
// pass
return 0;
}
diff --git a/tools/layoutlib/bridge/src/android/graphics/ComposePathEffect_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/ComposePathEffect_Delegate.java
index 7c04a87..bc3df7d 100644
--- a/tools/layoutlib/bridge/src/android/graphics/ComposePathEffect_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/ComposePathEffect_Delegate.java
@@ -62,7 +62,7 @@
// ---- native methods ----
@LayoutlibDelegate
- /*package*/ static int nativeCreate(int outerpe, int innerpe) {
+ /*package*/ static long nativeCreate(long outerpe, long innerpe) {
ComposePathEffect_Delegate newDelegate = new ComposePathEffect_Delegate();
return sManager.addNewDelegate(newDelegate);
}
diff --git a/tools/layoutlib/bridge/src/android/graphics/ComposeShader_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/ComposeShader_Delegate.java
index f6e1d00..fae8aef 100644
--- a/tools/layoutlib/bridge/src/android/graphics/ComposeShader_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/ComposeShader_Delegate.java
@@ -63,15 +63,15 @@
// ---- native methods ----
@LayoutlibDelegate
- /*package*/ static int nativeCreate1(int native_shaderA, int native_shaderB,
- int native_mode) {
+ /*package*/ static long nativeCreate1(long native_shaderA, long native_shaderB,
+ long native_mode) {
// FIXME not supported yet.
ComposeShader_Delegate newDelegate = new ComposeShader_Delegate();
return sManager.addNewDelegate(newDelegate);
}
@LayoutlibDelegate
- /*package*/ static int nativeCreate2(int native_shaderA, int native_shaderB,
+ /*package*/ static long nativeCreate2(long native_shaderA, long native_shaderB,
int porterDuffMode) {
// FIXME not supported yet.
ComposeShader_Delegate newDelegate = new ComposeShader_Delegate();
@@ -79,15 +79,15 @@
}
@LayoutlibDelegate
- /*package*/ static int nativePostCreate1(int native_shader, int native_skiaShaderA,
- int native_skiaShaderB, int native_mode) {
+ /*package*/ static long nativePostCreate1(long native_shader, long native_skiaShaderA,
+ long native_skiaShaderB, long native_mode) {
// pass, not needed.
return 0;
}
@LayoutlibDelegate
- /*package*/ static int nativePostCreate2(int native_shader, int native_skiaShaderA,
- int native_skiaShaderB, int porterDuffMode) {
+ /*package*/ static long nativePostCreate2(long native_shader, long native_skiaShaderA,
+ long native_skiaShaderB, int porterDuffMode) {
// pass, not needed.
return 0;
}
diff --git a/tools/layoutlib/bridge/src/android/graphics/CornerPathEffect_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/CornerPathEffect_Delegate.java
index b0f8168..73745c3 100644
--- a/tools/layoutlib/bridge/src/android/graphics/CornerPathEffect_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/CornerPathEffect_Delegate.java
@@ -62,7 +62,7 @@
// ---- native methods ----
@LayoutlibDelegate
- /*package*/ static int nativeCreate(float radius) {
+ /*package*/ static long nativeCreate(float radius) {
CornerPathEffect_Delegate newDelegate = new CornerPathEffect_Delegate();
return sManager.addNewDelegate(newDelegate);
}
diff --git a/tools/layoutlib/bridge/src/android/graphics/DashPathEffect_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/DashPathEffect_Delegate.java
index d97c2ec..881afde 100644
--- a/tools/layoutlib/bridge/src/android/graphics/DashPathEffect_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/DashPathEffect_Delegate.java
@@ -73,7 +73,7 @@
// ---- native methods ----
@LayoutlibDelegate
- /*package*/ static int nativeCreate(float intervals[], float phase) {
+ /*package*/ static long nativeCreate(float intervals[], float phase) {
DashPathEffect_Delegate newDelegate = new DashPathEffect_Delegate(intervals, phase);
return sManager.addNewDelegate(newDelegate);
}
diff --git a/tools/layoutlib/bridge/src/android/graphics/DiscretePathEffect_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/DiscretePathEffect_Delegate.java
index ec4a810..46109f3 100644
--- a/tools/layoutlib/bridge/src/android/graphics/DiscretePathEffect_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/DiscretePathEffect_Delegate.java
@@ -62,7 +62,7 @@
// ---- native methods ----
@LayoutlibDelegate
- /*package*/ static int nativeCreate(float length, float deviation) {
+ /*package*/ static long nativeCreate(float length, float deviation) {
DiscretePathEffect_Delegate newDelegate = new DiscretePathEffect_Delegate();
return sManager.addNewDelegate(newDelegate);
}
diff --git a/tools/layoutlib/bridge/src/android/graphics/DrawFilter_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/DrawFilter_Delegate.java
index 870c46b..2e10740 100644
--- a/tools/layoutlib/bridge/src/android/graphics/DrawFilter_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/DrawFilter_Delegate.java
@@ -46,7 +46,7 @@
// ---- Public Helper methods ----
- public static DrawFilter_Delegate getDelegate(int nativeDrawFilter) {
+ public static DrawFilter_Delegate getDelegate(long nativeDrawFilter) {
return sManager.getDelegate(nativeDrawFilter);
}
@@ -56,7 +56,7 @@
// ---- native methods ----
@LayoutlibDelegate
- /*package*/ static void nativeDestructor(int nativeDrawFilter) {
+ /*package*/ static void nativeDestructor(long nativeDrawFilter) {
sManager.removeJavaReferenceFor(nativeDrawFilter);
}
diff --git a/tools/layoutlib/bridge/src/android/graphics/EmbossMaskFilter_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/EmbossMaskFilter_Delegate.java
index ebc1c1d..e5040cc 100644
--- a/tools/layoutlib/bridge/src/android/graphics/EmbossMaskFilter_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/EmbossMaskFilter_Delegate.java
@@ -55,7 +55,7 @@
// ---- native methods ----
@LayoutlibDelegate
- /*package*/ static int nativeConstructor(float[] direction, float ambient,
+ /*package*/ static long nativeConstructor(float[] direction, float ambient,
float specular, float blurRadius) {
EmbossMaskFilter_Delegate newDelegate = new EmbossMaskFilter_Delegate();
return sManager.addNewDelegate(newDelegate);
diff --git a/tools/layoutlib/bridge/src/android/graphics/LayerRasterizer_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/LayerRasterizer_Delegate.java
index 51e0576..10cc572 100644
--- a/tools/layoutlib/bridge/src/android/graphics/LayerRasterizer_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/LayerRasterizer_Delegate.java
@@ -55,13 +55,13 @@
// ---- native methods ----
@LayoutlibDelegate
- /*package*/ static int nativeConstructor() {
+ /*package*/ static long nativeConstructor() {
LayerRasterizer_Delegate newDelegate = new LayerRasterizer_Delegate();
return sManager.addNewDelegate(newDelegate);
}
@LayoutlibDelegate
- /*package*/ static void nativeAddLayer(int native_layer, int native_paint, float dx, float dy) {
+ /*package*/ static void nativeAddLayer(long native_layer, long native_paint, float dx, float dy) {
}
diff --git a/tools/layoutlib/bridge/src/android/graphics/LightingColorFilter_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/LightingColorFilter_Delegate.java
index 0ee883d..defaac3 100644
--- a/tools/layoutlib/bridge/src/android/graphics/LightingColorFilter_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/LightingColorFilter_Delegate.java
@@ -55,13 +55,13 @@
// ---- native methods ----
@LayoutlibDelegate
- /*package*/ static int native_CreateLightingFilter(int mul, int add) {
+ /*package*/ static long native_CreateLightingFilter(int mul, int add) {
LightingColorFilter_Delegate newDelegate = new LightingColorFilter_Delegate();
return sManager.addNewDelegate(newDelegate);
}
@LayoutlibDelegate
- /*package*/ static int nCreateLightingFilter(int nativeFilter, int mul, int add) {
+ /*package*/ static int nCreateLightingFilter(long nativeFilter, int mul, int add) {
// pass
return 0;
}
diff --git a/tools/layoutlib/bridge/src/android/graphics/LinearGradient_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/LinearGradient_Delegate.java
index f117fca..ac77377 100644
--- a/tools/layoutlib/bridge/src/android/graphics/LinearGradient_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/LinearGradient_Delegate.java
@@ -54,7 +54,7 @@
// ---- native methods ----
@LayoutlibDelegate
- /*package*/ static int nativeCreate1(LinearGradient thisGradient,
+ /*package*/ static long nativeCreate1(LinearGradient thisGradient,
float x0, float y0, float x1, float y1,
int colors[], float positions[], int tileMode) {
LinearGradient_Delegate newDelegate = new LinearGradient_Delegate(x0, y0, x1, y1,
@@ -63,7 +63,7 @@
}
@LayoutlibDelegate
- /*package*/ static int nativeCreate2(LinearGradient thisGradient,
+ /*package*/ static long nativeCreate2(LinearGradient thisGradient,
float x0, float y0, float x1, float y1,
int color0, int color1, int tileMode) {
return nativeCreate1(thisGradient,
@@ -72,16 +72,16 @@
}
@LayoutlibDelegate
- /*package*/ static int nativePostCreate1(LinearGradient thisGradient,
- int native_shader, float x0, float y0, float x1, float y1,
+ /*package*/ static long nativePostCreate1(LinearGradient thisGradient,
+ long native_shader, float x0, float y0, float x1, float y1,
int colors[], float positions[], int tileMode) {
// nothing to be done here.
return 0;
}
@LayoutlibDelegate
- /*package*/ static int nativePostCreate2(LinearGradient thisGradient,
- int native_shader, float x0, float y0, float x1, float y1,
+ /*package*/ static long nativePostCreate2(LinearGradient thisGradient,
+ long native_shader, float x0, float y0, float x1, float y1,
int color0, int color1, int tileMode) {
// nothing to be done here.
return 0;
diff --git a/tools/layoutlib/bridge/src/android/graphics/MaskFilter_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/MaskFilter_Delegate.java
index c2f27e4..e726c59 100644
--- a/tools/layoutlib/bridge/src/android/graphics/MaskFilter_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/MaskFilter_Delegate.java
@@ -46,7 +46,7 @@
// ---- Public Helper methods ----
- public static MaskFilter_Delegate getDelegate(int nativeShader) {
+ public static MaskFilter_Delegate getDelegate(long nativeShader) {
return sManager.getDelegate(nativeShader);
}
@@ -56,7 +56,7 @@
// ---- native methods ----
@LayoutlibDelegate
- /*package*/ static void nativeDestructor(int native_filter) {
+ /*package*/ static void nativeDestructor(long native_filter) {
sManager.removeJavaReferenceFor(native_filter);
}
diff --git a/tools/layoutlib/bridge/src/android/graphics/Matrix_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Matrix_Delegate.java
index 5df2a21..ebfe9bc 100644
--- a/tools/layoutlib/bridge/src/android/graphics/Matrix_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/Matrix_Delegate.java
@@ -53,7 +53,7 @@
// ---- Public Helper methods ----
- public static Matrix_Delegate getDelegate(int native_instance) {
+ public static Matrix_Delegate getDelegate(long native_instance) {
return sManager.getDelegate(native_instance);
}
@@ -174,7 +174,7 @@
// ---- native methods ----
@LayoutlibDelegate
- /*package*/ static int native_create(int native_src_or_zero) {
+ /*package*/ static long native_create(long native_src_or_zero) {
// create the delegate
Matrix_Delegate newDelegate = new Matrix_Delegate();
@@ -193,7 +193,7 @@
}
@LayoutlibDelegate
- /*package*/ static boolean native_isIdentity(int native_object) {
+ /*package*/ static boolean native_isIdentity(long native_object) {
Matrix_Delegate d = sManager.getDelegate(native_object);
if (d == null) {
return false;
@@ -203,7 +203,7 @@
}
@LayoutlibDelegate
- /*package*/ static boolean native_rectStaysRect(int native_object) {
+ /*package*/ static boolean native_rectStaysRect(long native_object) {
Matrix_Delegate d = sManager.getDelegate(native_object);
if (d == null) {
return true;
@@ -213,7 +213,7 @@
}
@LayoutlibDelegate
- /*package*/ static void native_reset(int native_object) {
+ /*package*/ static void native_reset(long native_object) {
Matrix_Delegate d = sManager.getDelegate(native_object);
if (d == null) {
return;
@@ -223,7 +223,7 @@
}
@LayoutlibDelegate
- /*package*/ static void native_set(int native_object, int other) {
+ /*package*/ static void native_set(long native_object, long other) {
Matrix_Delegate d = sManager.getDelegate(native_object);
if (d == null) {
return;
@@ -238,7 +238,7 @@
}
@LayoutlibDelegate
- /*package*/ static void native_setTranslate(int native_object, float dx, float dy) {
+ /*package*/ static void native_setTranslate(long native_object, float dx, float dy) {
Matrix_Delegate d = sManager.getDelegate(native_object);
if (d == null) {
return;
@@ -248,7 +248,7 @@
}
@LayoutlibDelegate
- /*package*/ static void native_setScale(int native_object, float sx, float sy,
+ /*package*/ static void native_setScale(long native_object, float sx, float sy,
float px, float py) {
Matrix_Delegate d = sManager.getDelegate(native_object);
if (d == null) {
@@ -259,7 +259,7 @@
}
@LayoutlibDelegate
- /*package*/ static void native_setScale(int native_object, float sx, float sy) {
+ /*package*/ static void native_setScale(long native_object, float sx, float sy) {
Matrix_Delegate d = sManager.getDelegate(native_object);
if (d == null) {
return;
@@ -277,7 +277,7 @@
}
@LayoutlibDelegate
- /*package*/ static void native_setRotate(int native_object, float degrees, float px, float py) {
+ /*package*/ static void native_setRotate(long native_object, float degrees, float px, float py) {
Matrix_Delegate d = sManager.getDelegate(native_object);
if (d == null) {
return;
@@ -287,7 +287,7 @@
}
@LayoutlibDelegate
- /*package*/ static void native_setRotate(int native_object, float degrees) {
+ /*package*/ static void native_setRotate(long native_object, float degrees) {
Matrix_Delegate d = sManager.getDelegate(native_object);
if (d == null) {
return;
@@ -297,7 +297,7 @@
}
@LayoutlibDelegate
- /*package*/ static void native_setSinCos(int native_object, float sinValue, float cosValue,
+ /*package*/ static void native_setSinCos(long native_object, float sinValue, float cosValue,
float px, float py) {
Matrix_Delegate d = sManager.getDelegate(native_object);
if (d == null) {
@@ -316,7 +316,7 @@
}
@LayoutlibDelegate
- /*package*/ static void native_setSinCos(int native_object, float sinValue, float cosValue) {
+ /*package*/ static void native_setSinCos(long native_object, float sinValue, float cosValue) {
Matrix_Delegate d = sManager.getDelegate(native_object);
if (d == null) {
return;
@@ -326,7 +326,7 @@
}
@LayoutlibDelegate
- /*package*/ static void native_setSkew(int native_object, float kx, float ky,
+ /*package*/ static void native_setSkew(long native_object, float kx, float ky,
float px, float py) {
Matrix_Delegate d = sManager.getDelegate(native_object);
if (d == null) {
@@ -337,7 +337,7 @@
}
@LayoutlibDelegate
- /*package*/ static void native_setSkew(int native_object, float kx, float ky) {
+ /*package*/ static void native_setSkew(long native_object, float kx, float ky) {
Matrix_Delegate d = sManager.getDelegate(native_object);
if (d == null) {
return;
@@ -355,7 +355,7 @@
}
@LayoutlibDelegate
- /*package*/ static boolean native_setConcat(int native_object, int a, int b) {
+ /*package*/ static boolean native_setConcat(long native_object, long a, long b) {
if (a == native_object) {
return native_preConcat(native_object, b);
} else if (b == native_object) {
@@ -383,7 +383,7 @@
}
@LayoutlibDelegate
- /*package*/ static boolean native_preTranslate(int native_object, float dx, float dy) {
+ /*package*/ static boolean native_preTranslate(long native_object, float dx, float dy) {
Matrix_Delegate d = sManager.getDelegate(native_object);
if (d == null) {
return false;
@@ -394,7 +394,7 @@
}
@LayoutlibDelegate
- /*package*/ static boolean native_preScale(int native_object, float sx, float sy,
+ /*package*/ static boolean native_preScale(long native_object, float sx, float sy,
float px, float py) {
Matrix_Delegate d = sManager.getDelegate(native_object);
if (d == null) {
@@ -406,7 +406,7 @@
}
@LayoutlibDelegate
- /*package*/ static boolean native_preScale(int native_object, float sx, float sy) {
+ /*package*/ static boolean native_preScale(long native_object, float sx, float sy) {
Matrix_Delegate d = sManager.getDelegate(native_object);
if (d == null) {
return false;
@@ -417,7 +417,7 @@
}
@LayoutlibDelegate
- /*package*/ static boolean native_preRotate(int native_object, float degrees,
+ /*package*/ static boolean native_preRotate(long native_object, float degrees,
float px, float py) {
Matrix_Delegate d = sManager.getDelegate(native_object);
if (d == null) {
@@ -429,7 +429,7 @@
}
@LayoutlibDelegate
- /*package*/ static boolean native_preRotate(int native_object, float degrees) {
+ /*package*/ static boolean native_preRotate(long native_object, float degrees) {
Matrix_Delegate d = sManager.getDelegate(native_object);
if (d == null) {
return false;
@@ -444,7 +444,7 @@
}
@LayoutlibDelegate
- /*package*/ static boolean native_preSkew(int native_object, float kx, float ky,
+ /*package*/ static boolean native_preSkew(long native_object, float kx, float ky,
float px, float py) {
Matrix_Delegate d = sManager.getDelegate(native_object);
if (d == null) {
@@ -456,7 +456,7 @@
}
@LayoutlibDelegate
- /*package*/ static boolean native_preSkew(int native_object, float kx, float ky) {
+ /*package*/ static boolean native_preSkew(long native_object, float kx, float ky) {
Matrix_Delegate d = sManager.getDelegate(native_object);
if (d == null) {
return false;
@@ -467,7 +467,7 @@
}
@LayoutlibDelegate
- /*package*/ static boolean native_preConcat(int native_object, int other_matrix) {
+ /*package*/ static boolean native_preConcat(long native_object, long other_matrix) {
Matrix_Delegate d = sManager.getDelegate(native_object);
if (d == null) {
return false;
@@ -483,7 +483,7 @@
}
@LayoutlibDelegate
- /*package*/ static boolean native_postTranslate(int native_object, float dx, float dy) {
+ /*package*/ static boolean native_postTranslate(long native_object, float dx, float dy) {
Matrix_Delegate d = sManager.getDelegate(native_object);
if (d == null) {
return false;
@@ -494,7 +494,7 @@
}
@LayoutlibDelegate
- /*package*/ static boolean native_postScale(int native_object, float sx, float sy,
+ /*package*/ static boolean native_postScale(long native_object, float sx, float sy,
float px, float py) {
Matrix_Delegate d = sManager.getDelegate(native_object);
if (d == null) {
@@ -506,7 +506,7 @@
}
@LayoutlibDelegate
- /*package*/ static boolean native_postScale(int native_object, float sx, float sy) {
+ /*package*/ static boolean native_postScale(long native_object, float sx, float sy) {
Matrix_Delegate d = sManager.getDelegate(native_object);
if (d == null) {
return false;
@@ -517,7 +517,7 @@
}
@LayoutlibDelegate
- /*package*/ static boolean native_postRotate(int native_object, float degrees,
+ /*package*/ static boolean native_postRotate(long native_object, float degrees,
float px, float py) {
Matrix_Delegate d = sManager.getDelegate(native_object);
if (d == null) {
@@ -529,7 +529,7 @@
}
@LayoutlibDelegate
- /*package*/ static boolean native_postRotate(int native_object, float degrees) {
+ /*package*/ static boolean native_postRotate(long native_object, float degrees) {
Matrix_Delegate d = sManager.getDelegate(native_object);
if (d == null) {
return false;
@@ -540,7 +540,7 @@
}
@LayoutlibDelegate
- /*package*/ static boolean native_postSkew(int native_object, float kx, float ky,
+ /*package*/ static boolean native_postSkew(long native_object, float kx, float ky,
float px, float py) {
Matrix_Delegate d = sManager.getDelegate(native_object);
if (d == null) {
@@ -552,7 +552,7 @@
}
@LayoutlibDelegate
- /*package*/ static boolean native_postSkew(int native_object, float kx, float ky) {
+ /*package*/ static boolean native_postSkew(long native_object, float kx, float ky) {
Matrix_Delegate d = sManager.getDelegate(native_object);
if (d == null) {
return false;
@@ -563,7 +563,7 @@
}
@LayoutlibDelegate
- /*package*/ static boolean native_postConcat(int native_object, int other_matrix) {
+ /*package*/ static boolean native_postConcat(long native_object, long other_matrix) {
Matrix_Delegate d = sManager.getDelegate(native_object);
if (d == null) {
return false;
@@ -579,7 +579,7 @@
}
@LayoutlibDelegate
- /*package*/ static boolean native_setRectToRect(int native_object, RectF src,
+ /*package*/ static boolean native_setRectToRect(long native_object, RectF src,
RectF dst, int stf) {
Matrix_Delegate d = sManager.getDelegate(native_object);
if (d == null) {
@@ -644,7 +644,7 @@
}
@LayoutlibDelegate
- /*package*/ static boolean native_setPolyToPoly(int native_object, float[] src, int srcIndex,
+ /*package*/ static boolean native_setPolyToPoly(long native_object, float[] src, int srcIndex,
float[] dst, int dstIndex, int pointCount) {
// FIXME
Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED,
@@ -654,7 +654,7 @@
}
@LayoutlibDelegate
- /*package*/ static boolean native_invert(int native_object, int inverse) {
+ /*package*/ static boolean native_invert(long native_object, long inverse) {
Matrix_Delegate d = sManager.getDelegate(native_object);
if (d == null) {
return false;
@@ -682,7 +682,7 @@
}
@LayoutlibDelegate
- /*package*/ static void native_mapPoints(int native_object, float[] dst, int dstIndex,
+ /*package*/ static void native_mapPoints(long native_object, float[] dst, int dstIndex,
float[] src, int srcIndex, int ptCount, boolean isPts) {
Matrix_Delegate d = sManager.getDelegate(native_object);
if (d == null) {
@@ -697,7 +697,7 @@
}
@LayoutlibDelegate
- /*package*/ static boolean native_mapRect(int native_object, RectF dst, RectF src) {
+ /*package*/ static boolean native_mapRect(long native_object, RectF dst, RectF src) {
Matrix_Delegate d = sManager.getDelegate(native_object);
if (d == null) {
return false;
@@ -707,7 +707,7 @@
}
@LayoutlibDelegate
- /*package*/ static float native_mapRadius(int native_object, float radius) {
+ /*package*/ static float native_mapRadius(long native_object, float radius) {
Matrix_Delegate d = sManager.getDelegate(native_object);
if (d == null) {
return 0.f;
@@ -723,7 +723,7 @@
}
@LayoutlibDelegate
- /*package*/ static void native_getValues(int native_object, float[] values) {
+ /*package*/ static void native_getValues(long native_object, float[] values) {
Matrix_Delegate d = sManager.getDelegate(native_object);
if (d == null) {
return;
@@ -733,7 +733,7 @@
}
@LayoutlibDelegate
- /*package*/ static void native_setValues(int native_object, float[] values) {
+ /*package*/ static void native_setValues(long native_object, float[] values) {
Matrix_Delegate d = sManager.getDelegate(native_object);
if (d == null) {
return;
@@ -743,7 +743,7 @@
}
@LayoutlibDelegate
- /*package*/ static boolean native_equals(int native_a, int native_b) {
+ /*package*/ static boolean native_equals(long native_a, long native_b) {
Matrix_Delegate a = sManager.getDelegate(native_a);
if (a == null) {
return false;
@@ -764,7 +764,7 @@
}
@LayoutlibDelegate
- /*package*/ static void finalizer(int native_instance) {
+ /*package*/ static void finalizer(long native_instance) {
sManager.removeJavaReferenceFor(native_instance);
}
diff --git a/tools/layoutlib/bridge/src/android/graphics/NinePatch_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/NinePatch_Delegate.java
index fa68796..38745ce 100644
--- a/tools/layoutlib/bridge/src/android/graphics/NinePatch_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/NinePatch_Delegate.java
@@ -158,7 +158,7 @@
}
@LayoutlibDelegate
- /*package*/ static int validateNinePatchChunk(int bitmap, byte[] chunk) {
+ /*package*/ static long validateNinePatchChunk(long bitmap, byte[] chunk) {
// the default JNI implementation only checks that the byte[] has the same
// size as the C struct it represent. Since we cannot do the same check (serialization
// will return different size depending on content), we do nothing.
@@ -167,13 +167,14 @@
return sManager.addNewDelegate(newDelegate);
}
- /*package*/ static void nativeFinalize(int chunk) {
+ @LayoutlibDelegate
+ /*package*/ static void nativeFinalize(long chunk) {
sManager.removeJavaReferenceFor(chunk);
}
@LayoutlibDelegate
- /*package*/ static void nativeDraw(int canvas_instance, RectF loc, int bitmap_instance,
- int chunk, int paint_instance_or_null, int destDensity, int srcDensity) {
+ /*package*/ static void nativeDraw(long canvas_instance, RectF loc, long bitmap_instance,
+ long chunk, long paint_instance_or_null, int destDensity, int srcDensity) {
draw(canvas_instance,
(int) loc.left, (int) loc.top, (int) loc.width(), (int) loc.height(),
bitmap_instance, chunk, paint_instance_or_null,
@@ -181,8 +182,8 @@
}
@LayoutlibDelegate
- /*package*/ static void nativeDraw(int canvas_instance, Rect loc, int bitmap_instance,
- int chunk, int paint_instance_or_null, int destDensity, int srcDensity) {
+ /*package*/ static void nativeDraw(long canvas_instance, Rect loc, long bitmap_instance,
+ long chunk, long paint_instance_or_null, int destDensity, int srcDensity) {
draw(canvas_instance,
loc.left, loc.top, loc.width(), loc.height(),
bitmap_instance, chunk, paint_instance_or_null,
@@ -190,15 +191,15 @@
}
@LayoutlibDelegate
- /*package*/ static int nativeGetTransparentRegion(int bitmap, int chunk, Rect location) {
+ /*package*/ static long nativeGetTransparentRegion(long bitmap, long chunk, Rect location) {
return 0;
}
// ---- Private Helper methods ----
- private static void draw(int canvas_instance,
+ private static void draw(long canvas_instance,
final int left, final int top, final int right, final int bottom,
- int bitmap_instance, int chunk, int paint_instance_or_null,
+ long bitmap_instance, long chunk, long paint_instance_or_null,
final int destDensity, final int srcDensity) {
// get the delegate from the native int.
final Bitmap_Delegate bitmap_delegate = Bitmap_Delegate.getDelegate(bitmap_instance);
diff --git a/tools/layoutlib/bridge/src/android/graphics/PaintFlagsDrawFilter_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/PaintFlagsDrawFilter_Delegate.java
index 71d346a..fa20746 100644
--- a/tools/layoutlib/bridge/src/android/graphics/PaintFlagsDrawFilter_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/PaintFlagsDrawFilter_Delegate.java
@@ -55,7 +55,7 @@
// ---- native methods ----
@LayoutlibDelegate
- /*package*/ static int nativeConstructor(int clearBits, int setBits) {
+ /*package*/ static long nativeConstructor(int clearBits, int setBits) {
PaintFlagsDrawFilter_Delegate newDelegate = new PaintFlagsDrawFilter_Delegate();
return sManager.addNewDelegate(newDelegate);
}
diff --git a/tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java
index 41953ed..ca8e8aa 100644
--- a/tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java
@@ -96,7 +96,7 @@
// ---- Public Helper methods ----
- public static Paint_Delegate getDelegate(int native_paint) {
+ public static Paint_Delegate getDelegate(long native_paint) {
return sManager.getDelegate(native_paint);
}
@@ -640,13 +640,13 @@
}
@LayoutlibDelegate
- /*package*/ static int native_init() {
+ /*package*/ static long native_init() {
Paint_Delegate newDelegate = new Paint_Delegate();
return sManager.addNewDelegate(newDelegate);
}
@LayoutlibDelegate
- /*package*/ static int native_initWithPaint(int paint) {
+ /*package*/ static long native_initWithPaint(long paint) {
// get the delegate from the native int.
Paint_Delegate delegate = sManager.getDelegate(paint);
if (delegate == null) {
@@ -658,7 +658,7 @@
}
@LayoutlibDelegate
- /*package*/ static void native_reset(int native_object) {
+ /*package*/ static void native_reset(long native_object) {
// get the delegate from the native int.
Paint_Delegate delegate = sManager.getDelegate(native_object);
if (delegate == null) {
@@ -669,7 +669,7 @@
}
@LayoutlibDelegate
- /*package*/ static void native_set(int native_dst, int native_src) {
+ /*package*/ static void native_set(long native_dst, long native_src) {
// get the delegate from the native int.
Paint_Delegate delegate_dst = sManager.getDelegate(native_dst);
if (delegate_dst == null) {
@@ -686,7 +686,7 @@
}
@LayoutlibDelegate
- /*package*/ static int native_getStyle(int native_object) {
+ /*package*/ static long native_getStyle(long native_object) {
// get the delegate from the native int.
Paint_Delegate delegate = sManager.getDelegate(native_object);
if (delegate == null) {
@@ -697,7 +697,7 @@
}
@LayoutlibDelegate
- /*package*/ static void native_setStyle(int native_object, int style) {
+ /*package*/ static void native_setStyle(long native_object, int style) {
// get the delegate from the native int.
Paint_Delegate delegate = sManager.getDelegate(native_object);
if (delegate == null) {
@@ -708,7 +708,7 @@
}
@LayoutlibDelegate
- /*package*/ static int native_getStrokeCap(int native_object) {
+ /*package*/ static long native_getStrokeCap(long native_object) {
// get the delegate from the native int.
Paint_Delegate delegate = sManager.getDelegate(native_object);
if (delegate == null) {
@@ -719,7 +719,7 @@
}
@LayoutlibDelegate
- /*package*/ static void native_setStrokeCap(int native_object, int cap) {
+ /*package*/ static void native_setStrokeCap(long native_object, int cap) {
// get the delegate from the native int.
Paint_Delegate delegate = sManager.getDelegate(native_object);
if (delegate == null) {
@@ -730,7 +730,7 @@
}
@LayoutlibDelegate
- /*package*/ static int native_getStrokeJoin(int native_object) {
+ /*package*/ static long native_getStrokeJoin(long native_object) {
// get the delegate from the native int.
Paint_Delegate delegate = sManager.getDelegate(native_object);
if (delegate == null) {
@@ -741,7 +741,7 @@
}
@LayoutlibDelegate
- /*package*/ static void native_setStrokeJoin(int native_object, int join) {
+ /*package*/ static void native_setStrokeJoin(long native_object, int join) {
// get the delegate from the native int.
Paint_Delegate delegate = sManager.getDelegate(native_object);
if (delegate == null) {
@@ -752,7 +752,7 @@
}
@LayoutlibDelegate
- /*package*/ static boolean native_getFillPath(int native_object, int src, int dst) {
+ /*package*/ static boolean native_getFillPath(long native_object, long src, long dst) {
Paint_Delegate paint = sManager.getDelegate(native_object);
if (paint == null) {
return false;
@@ -778,7 +778,7 @@
}
@LayoutlibDelegate
- /*package*/ static int native_setShader(int native_object, int shader) {
+ /*package*/ static long native_setShader(long native_object, long shader) {
// get the delegate from the native int.
Paint_Delegate delegate = sManager.getDelegate(native_object);
if (delegate == null) {
@@ -791,7 +791,7 @@
}
@LayoutlibDelegate
- /*package*/ static int native_setColorFilter(int native_object, int filter) {
+ /*package*/ static long native_setColorFilter(long native_object, long filter) {
// get the delegate from the native int.
Paint_Delegate delegate = sManager.getDelegate(native_object);
if (delegate == null) {
@@ -810,7 +810,7 @@
}
@LayoutlibDelegate
- /*package*/ static int native_setXfermode(int native_object, int xfermode) {
+ /*package*/ static long native_setXfermode(long native_object, long xfermode) {
// get the delegate from the native int.
Paint_Delegate delegate = sManager.getDelegate(native_object);
if (delegate == null) {
@@ -823,7 +823,7 @@
}
@LayoutlibDelegate
- /*package*/ static int native_setPathEffect(int native_object, int effect) {
+ /*package*/ static long native_setPathEffect(long native_object, long effect) {
// get the delegate from the native int.
Paint_Delegate delegate = sManager.getDelegate(native_object);
if (delegate == null) {
@@ -836,7 +836,7 @@
}
@LayoutlibDelegate
- /*package*/ static int native_setMaskFilter(int native_object, int maskfilter) {
+ /*package*/ static long native_setMaskFilter(long native_object, long maskfilter) {
// get the delegate from the native int.
Paint_Delegate delegate = sManager.getDelegate(native_object);
if (delegate == null) {
@@ -855,7 +855,7 @@
}
@LayoutlibDelegate
- /*package*/ static int native_setTypeface(int native_object, int typeface) {
+ /*package*/ static long native_setTypeface(long native_object, long typeface) {
// get the delegate from the native int.
Paint_Delegate delegate = sManager.getDelegate(native_object);
if (delegate == null) {
@@ -868,7 +868,7 @@
}
@LayoutlibDelegate
- /*package*/ static int native_setRasterizer(int native_object, int rasterizer) {
+ /*package*/ static long native_setRasterizer(long native_object, long rasterizer) {
// get the delegate from the native int.
Paint_Delegate delegate = sManager.getDelegate(native_object);
if (delegate == null) {
@@ -887,7 +887,7 @@
}
@LayoutlibDelegate
- /*package*/ static int native_getTextAlign(int native_object) {
+ /*package*/ static long native_getTextAlign(long native_object) {
// get the delegate from the native int.
Paint_Delegate delegate = sManager.getDelegate(native_object);
if (delegate == null) {
@@ -898,7 +898,7 @@
}
@LayoutlibDelegate
- /*package*/ static void native_setTextAlign(int native_object, int align) {
+ /*package*/ static void native_setTextAlign(long native_object, int align) {
// get the delegate from the native int.
Paint_Delegate delegate = sManager.getDelegate(native_object);
if (delegate == null) {
@@ -909,7 +909,7 @@
}
@LayoutlibDelegate
- /*package*/ static void native_setTextLocale(int native_object, String locale) {
+ /*package*/ static void native_setTextLocale(long native_object, String locale) {
// get the delegate from the native int.
Paint_Delegate delegate = sManager.getDelegate(native_object);
if (delegate == null) {
@@ -920,7 +920,7 @@
}
@LayoutlibDelegate
- /*package*/ static int native_getTextWidths(int native_object, char[] text, int index,
+ /*package*/ static long native_getTextWidths(long native_object, char[] text, int index,
int count, int bidiFlags, float[] widths) {
// get the delegate from the native int.
Paint_Delegate delegate = sManager.getDelegate(native_object);
@@ -962,21 +962,21 @@
}
@LayoutlibDelegate
- /*package*/ static int native_getTextWidths(int native_object, String text, int start,
+ /*package*/ static long native_getTextWidths(long native_object, String text, int start,
int end, int bidiFlags, float[] widths) {
return native_getTextWidths(native_object, text.toCharArray(), start, end - start,
bidiFlags, widths);
}
@LayoutlibDelegate
- /* package */static int native_getTextGlyphs(int native_object, String text, int start,
+ /* package */static long native_getTextGlyphs(long native_object, String text, int start,
int end, int contextStart, int contextEnd, int flags, char[] glyphs) {
// FIXME
return 0;
}
@LayoutlibDelegate
- /*package*/ static float native_getTextRunAdvances(int native_object,
+ /*package*/ static float native_getTextRunAdvances(long native_object,
char[] text, int index, int count, int contextIndex, int contextCount,
int flags, float[] advances, int advancesIndex) {
@@ -996,7 +996,7 @@
}
@LayoutlibDelegate
- /*package*/ static float native_getTextRunAdvances(int native_object,
+ /*package*/ static float native_getTextRunAdvances(long native_object,
String text, int start, int end, int contextStart, int contextEnd,
int flags, float[] advances, int advancesIndex) {
// FIXME: support contextStart and contextEnd
@@ -1009,7 +1009,7 @@
}
@LayoutlibDelegate
- /*package*/ static int native_getTextRunCursor(Paint thisPaint, int native_object, char[] text,
+ /*package*/ static long native_getTextRunCursor(Paint thisPaint, long native_object, char[] text,
int contextStart, int contextLength, int flags, int offset, int cursorOpt) {
// FIXME
Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED,
@@ -1018,7 +1018,7 @@
}
@LayoutlibDelegate
- /*package*/ static int native_getTextRunCursor(Paint thisPaint, int native_object, String text,
+ /*package*/ static long native_getTextRunCursor(Paint thisPaint, long native_object, String text,
int contextStart, int contextEnd, int flags, int offset, int cursorOpt) {
// FIXME
Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED,
@@ -1027,30 +1027,30 @@
}
@LayoutlibDelegate
- /*package*/ static void native_getTextPath(int native_object, int bidiFlags,
- char[] text, int index, int count, float x, float y, int path) {
+ /*package*/ static void native_getTextPath(long native_object, int bidiFlags,
+ char[] text, int index, int count, float x, float y, long path) {
// FIXME
Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED,
"Paint.getTextPath is not supported.", null, null /*data*/);
}
@LayoutlibDelegate
- /*package*/ static void native_getTextPath(int native_object, int bidiFlags,
- String text, int start, int end, float x, float y, int path) {
+ /*package*/ static void native_getTextPath(long native_object, int bidiFlags,
+ String text, int start, int end, float x, float y, long path) {
// FIXME
Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED,
"Paint.getTextPath is not supported.", null, null /*data*/);
}
@LayoutlibDelegate
- /*package*/ static void nativeGetStringBounds(int nativePaint, String text, int start,
+ /*package*/ static void nativeGetStringBounds(long nativePaint, String text, int start,
int end, int bidiFlags, Rect bounds) {
nativeGetCharArrayBounds(nativePaint, text.toCharArray(), start, end - start, bidiFlags,
bounds);
}
@LayoutlibDelegate
- /*package*/ static void nativeGetCharArrayBounds(int nativePaint, char[] text, int index,
+ /*package*/ static void nativeGetCharArrayBounds(long nativePaint, char[] text, int index,
int count, int bidiFlags, Rect bounds) {
// get the delegate from the native int.
@@ -1064,7 +1064,7 @@
}
@LayoutlibDelegate
- /*package*/ static void finalizer(int nativePaint) {
+ /*package*/ static void finalizer(long nativePaint) {
sManager.removeJavaReferenceFor(nativePaint);
}
diff --git a/tools/layoutlib/bridge/src/android/graphics/PathDashPathEffect_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/PathDashPathEffect_Delegate.java
index c448f0e..fd9ba62 100644
--- a/tools/layoutlib/bridge/src/android/graphics/PathDashPathEffect_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/PathDashPathEffect_Delegate.java
@@ -62,7 +62,7 @@
// ---- native methods ----
@LayoutlibDelegate
- /*package*/ static int nativeCreate(int native_path, float advance, float phase,
+ /*package*/ static long nativeCreate(long native_path, float advance, float phase,
int native_style) {
PathDashPathEffect_Delegate newDelegate = new PathDashPathEffect_Delegate();
return sManager.addNewDelegate(newDelegate);
diff --git a/tools/layoutlib/bridge/src/android/graphics/PathEffect_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/PathEffect_Delegate.java
index bd2b6de..000481e 100644
--- a/tools/layoutlib/bridge/src/android/graphics/PathEffect_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/PathEffect_Delegate.java
@@ -48,7 +48,7 @@
// ---- Public Helper methods ----
- public static PathEffect_Delegate getDelegate(int nativeShader) {
+ public static PathEffect_Delegate getDelegate(long nativeShader) {
return sManager.getDelegate(nativeShader);
}
@@ -60,7 +60,7 @@
// ---- native methods ----
@LayoutlibDelegate
- /*package*/ static void nativeDestructor(int native_patheffect) {
+ /*package*/ static void nativeDestructor(long native_patheffect) {
sManager.removeJavaReferenceFor(native_patheffect);
}
diff --git a/tools/layoutlib/bridge/src/android/graphics/Path_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Path_Delegate.java
index 64f19d3..6f6ef20 100644
--- a/tools/layoutlib/bridge/src/android/graphics/Path_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/Path_Delegate.java
@@ -63,7 +63,7 @@
// ---- Public Helper methods ----
- public static Path_Delegate getDelegate(int nPath) {
+ public static Path_Delegate getDelegate(long nPath) {
return sManager.getDelegate(nPath);
}
@@ -88,7 +88,7 @@
// ---- native methods ----
@LayoutlibDelegate
- /*package*/ static int init1() {
+ /*package*/ static long init1() {
// create the delegate
Path_Delegate newDelegate = new Path_Delegate();
@@ -96,7 +96,7 @@
}
@LayoutlibDelegate
- /*package*/ static int init2(int nPath) {
+ /*package*/ static long init2(long nPath) {
// create the delegate
Path_Delegate newDelegate = new Path_Delegate();
@@ -110,7 +110,7 @@
}
@LayoutlibDelegate
- /*package*/ static void native_reset(int nPath) {
+ /*package*/ static void native_reset(long nPath) {
Path_Delegate pathDelegate = sManager.getDelegate(nPath);
if (pathDelegate == null) {
return;
@@ -120,14 +120,14 @@
}
@LayoutlibDelegate
- /*package*/ static void native_rewind(int nPath) {
+ /*package*/ static void native_rewind(long nPath) {
// call out to reset since there's nothing to optimize in
// terms of data structs.
native_reset(nPath);
}
@LayoutlibDelegate
- /*package*/ static void native_set(int native_dst, int native_src) {
+ /*package*/ static void native_set(long native_dst, long native_src) {
Path_Delegate pathDstDelegate = sManager.getDelegate(native_dst);
if (pathDstDelegate == null) {
return;
@@ -142,7 +142,7 @@
}
@LayoutlibDelegate
- /*package*/ static int native_getFillType(int nPath) {
+ /*package*/ static long native_getFillType(long nPath) {
Path_Delegate pathDelegate = sManager.getDelegate(nPath);
if (pathDelegate == null) {
return 0;
@@ -152,7 +152,7 @@
}
@LayoutlibDelegate
- /*package*/ static void native_setFillType(int nPath, int ft) {
+ /*package*/ static void native_setFillType(long nPath, int ft) {
Path_Delegate pathDelegate = sManager.getDelegate(nPath);
if (pathDelegate == null) {
return;
@@ -162,7 +162,7 @@
}
@LayoutlibDelegate
- /*package*/ static boolean native_isEmpty(int nPath) {
+ /*package*/ static boolean native_isEmpty(long nPath) {
Path_Delegate pathDelegate = sManager.getDelegate(nPath);
if (pathDelegate == null) {
return true;
@@ -172,7 +172,7 @@
}
@LayoutlibDelegate
- /*package*/ static boolean native_isRect(int nPath, RectF rect) {
+ /*package*/ static boolean native_isRect(long nPath, RectF rect) {
Path_Delegate pathDelegate = sManager.getDelegate(nPath);
if (pathDelegate == null) {
return false;
@@ -192,7 +192,7 @@
}
@LayoutlibDelegate
- /*package*/ static void native_computeBounds(int nPath, RectF bounds) {
+ /*package*/ static void native_computeBounds(long nPath, RectF bounds) {
Path_Delegate pathDelegate = sManager.getDelegate(nPath);
if (pathDelegate == null) {
return;
@@ -202,13 +202,13 @@
}
@LayoutlibDelegate
- /*package*/ static void native_incReserve(int nPath, int extraPtCount) {
+ /*package*/ static void native_incReserve(long nPath, int extraPtCount) {
// since we use a java2D path, there's no way to pre-allocate new points,
// so we do nothing.
}
@LayoutlibDelegate
- /*package*/ static void native_moveTo(int nPath, float x, float y) {
+ /*package*/ static void native_moveTo(long nPath, float x, float y) {
Path_Delegate pathDelegate = sManager.getDelegate(nPath);
if (pathDelegate == null) {
return;
@@ -218,7 +218,7 @@
}
@LayoutlibDelegate
- /*package*/ static void native_rMoveTo(int nPath, float dx, float dy) {
+ /*package*/ static void native_rMoveTo(long nPath, float dx, float dy) {
Path_Delegate pathDelegate = sManager.getDelegate(nPath);
if (pathDelegate == null) {
return;
@@ -228,7 +228,7 @@
}
@LayoutlibDelegate
- /*package*/ static void native_lineTo(int nPath, float x, float y) {
+ /*package*/ static void native_lineTo(long nPath, float x, float y) {
Path_Delegate pathDelegate = sManager.getDelegate(nPath);
if (pathDelegate == null) {
return;
@@ -238,7 +238,7 @@
}
@LayoutlibDelegate
- /*package*/ static void native_rLineTo(int nPath, float dx, float dy) {
+ /*package*/ static void native_rLineTo(long nPath, float dx, float dy) {
Path_Delegate pathDelegate = sManager.getDelegate(nPath);
if (pathDelegate == null) {
return;
@@ -248,7 +248,7 @@
}
@LayoutlibDelegate
- /*package*/ static void native_quadTo(int nPath, float x1, float y1, float x2, float y2) {
+ /*package*/ static void native_quadTo(long nPath, float x1, float y1, float x2, float y2) {
Path_Delegate pathDelegate = sManager.getDelegate(nPath);
if (pathDelegate == null) {
return;
@@ -258,7 +258,7 @@
}
@LayoutlibDelegate
- /*package*/ static void native_rQuadTo(int nPath, float dx1, float dy1, float dx2, float dy2) {
+ /*package*/ static void native_rQuadTo(long nPath, float dx1, float dy1, float dx2, float dy2) {
Path_Delegate pathDelegate = sManager.getDelegate(nPath);
if (pathDelegate == null) {
return;
@@ -268,7 +268,7 @@
}
@LayoutlibDelegate
- /*package*/ static void native_cubicTo(int nPath, float x1, float y1,
+ /*package*/ static void native_cubicTo(long nPath, float x1, float y1,
float x2, float y2, float x3, float y3) {
Path_Delegate pathDelegate = sManager.getDelegate(nPath);
if (pathDelegate == null) {
@@ -279,7 +279,7 @@
}
@LayoutlibDelegate
- /*package*/ static void native_rCubicTo(int nPath, float x1, float y1,
+ /*package*/ static void native_rCubicTo(long nPath, float x1, float y1,
float x2, float y2, float x3, float y3) {
Path_Delegate pathDelegate = sManager.getDelegate(nPath);
if (pathDelegate == null) {
@@ -290,7 +290,7 @@
}
@LayoutlibDelegate
- /*package*/ static void native_arcTo(int nPath, RectF oval,
+ /*package*/ static void native_arcTo(long nPath, RectF oval,
float startAngle, float sweepAngle, boolean forceMoveTo) {
Path_Delegate pathDelegate = sManager.getDelegate(nPath);
if (pathDelegate == null) {
@@ -301,7 +301,7 @@
}
@LayoutlibDelegate
- /*package*/ static void native_close(int nPath) {
+ /*package*/ static void native_close(long nPath) {
Path_Delegate pathDelegate = sManager.getDelegate(nPath);
if (pathDelegate == null) {
return;
@@ -311,7 +311,7 @@
}
@LayoutlibDelegate
- /*package*/ static void native_addRect(int nPath, RectF rect, int dir) {
+ /*package*/ static void native_addRect(long nPath, RectF rect, int dir) {
Path_Delegate pathDelegate = sManager.getDelegate(nPath);
if (pathDelegate == null) {
return;
@@ -321,7 +321,7 @@
}
@LayoutlibDelegate
- /*package*/ static void native_addRect(int nPath,
+ /*package*/ static void native_addRect(long nPath,
float left, float top, float right, float bottom, int dir) {
Path_Delegate pathDelegate = sManager.getDelegate(nPath);
if (pathDelegate == null) {
@@ -332,7 +332,7 @@
}
@LayoutlibDelegate
- /*package*/ static void native_addOval(int nPath, RectF oval, int dir) {
+ /*package*/ static void native_addOval(long nPath, RectF oval, int dir) {
Path_Delegate pathDelegate = sManager.getDelegate(nPath);
if (pathDelegate == null) {
return;
@@ -343,7 +343,7 @@
}
@LayoutlibDelegate
- /*package*/ static void native_addCircle(int nPath, float x, float y, float radius, int dir) {
+ /*package*/ static void native_addCircle(long nPath, float x, float y, float radius, int dir) {
Path_Delegate pathDelegate = sManager.getDelegate(nPath);
if (pathDelegate == null) {
return;
@@ -355,7 +355,7 @@
}
@LayoutlibDelegate
- /*package*/ static void native_addArc(int nPath, RectF oval,
+ /*package*/ static void native_addArc(long nPath, RectF oval,
float startAngle, float sweepAngle) {
Path_Delegate pathDelegate = sManager.getDelegate(nPath);
if (pathDelegate == null) {
@@ -370,7 +370,7 @@
@LayoutlibDelegate
/*package*/ static void native_addRoundRect(
- int nPath, RectF rect, float rx, float ry, int dir) {
+ long nPath, RectF rect, float rx, float ry, int dir) {
Path_Delegate pathDelegate = sManager.getDelegate(nPath);
if (pathDelegate == null) {
@@ -382,7 +382,7 @@
}
@LayoutlibDelegate
- /*package*/ static void native_addRoundRect(int nPath, RectF rect, float[] radii, int dir) {
+ /*package*/ static void native_addRoundRect(long nPath, RectF rect, float[] radii, int dir) {
// Java2D doesn't support different rounded corners in each corner, so just use the
// first value.
native_addRoundRect(nPath, rect, radii[0], radii[1], dir);
@@ -401,17 +401,17 @@
}
@LayoutlibDelegate
- /*package*/ static void native_addPath(int nPath, int src, float dx, float dy) {
+ /*package*/ static void native_addPath(long nPath, long src, float dx, float dy) {
addPath(nPath, src, AffineTransform.getTranslateInstance(dx, dy));
}
@LayoutlibDelegate
- /*package*/ static void native_addPath(int nPath, int src) {
+ /*package*/ static void native_addPath(long nPath, long src) {
addPath(nPath, src, null /*transform*/);
}
@LayoutlibDelegate
- /*package*/ static void native_addPath(int nPath, int src, int matrix) {
+ /*package*/ static void native_addPath(long nPath, long src, long matrix) {
Matrix_Delegate matrixDelegate = Matrix_Delegate.getDelegate(matrix);
if (matrixDelegate == null) {
return;
@@ -421,7 +421,7 @@
}
@LayoutlibDelegate
- /*package*/ static void native_offset(int nPath, float dx, float dy, int dst_path) {
+ /*package*/ static void native_offset(long nPath, float dx, float dy, long dst_path) {
Path_Delegate pathDelegate = sManager.getDelegate(nPath);
if (pathDelegate == null) {
return;
@@ -434,12 +434,12 @@
}
@LayoutlibDelegate
- /*package*/ static void native_offset(int nPath, float dx, float dy) {
+ /*package*/ static void native_offset(long nPath, float dx, float dy) {
native_offset(nPath, dx, dy, 0);
}
@LayoutlibDelegate
- /*package*/ static void native_setLastPoint(int nPath, float dx, float dy) {
+ /*package*/ static void native_setLastPoint(long nPath, float dx, float dy) {
Path_Delegate pathDelegate = sManager.getDelegate(nPath);
if (pathDelegate == null) {
return;
@@ -450,8 +450,8 @@
}
@LayoutlibDelegate
- /*package*/ static void native_transform(int nPath, int matrix,
- int dst_path) {
+ /*package*/ static void native_transform(long nPath, long matrix,
+ long dst_path) {
Path_Delegate pathDelegate = sManager.getDelegate(nPath);
if (pathDelegate == null) {
return;
@@ -469,12 +469,18 @@
}
@LayoutlibDelegate
- /*package*/ static void native_transform(int nPath, int matrix) {
+ /*package*/ static void native_transform(long nPath, long matrix) {
native_transform(nPath, matrix, 0);
}
@LayoutlibDelegate
- /*package*/ static void finalizer(int nPath) {
+ /*package*/ static boolean native_op(long nPath1, long nPath2, int op, long result) {
+ Bridge.getLog().error(LayoutLog.TAG_UNSUPPORTED, "Path.op() not supported", null);
+ return false;
+ }
+
+ @LayoutlibDelegate
+ /*package*/ static void finalizer(long nPath) {
sManager.removeJavaReferenceFor(nPath);
}
@@ -522,7 +528,7 @@
return null;
}
- private static void addPath(int destPath, int srcPath, AffineTransform transform) {
+ private static void addPath(long destPath, long srcPath, AffineTransform transform) {
Path_Delegate destPathDelegate = sManager.getDelegate(destPath);
if (destPathDelegate == null) {
return;
diff --git a/tools/layoutlib/bridge/src/android/graphics/PixelXorXfermode_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/PixelXorXfermode_Delegate.java
index 4ab044b..f27144f 100644
--- a/tools/layoutlib/bridge/src/android/graphics/PixelXorXfermode_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/PixelXorXfermode_Delegate.java
@@ -61,7 +61,7 @@
// ---- native methods ----
@LayoutlibDelegate
- /*package*/ static int nativeCreate(int opColor) {
+ /*package*/ static long nativeCreate(int opColor) {
PixelXorXfermode_Delegate newDelegate = new PixelXorXfermode_Delegate();
return sManager.addNewDelegate(newDelegate);
}
diff --git a/tools/layoutlib/bridge/src/android/graphics/PorterDuffColorFilter_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/PorterDuffColorFilter_Delegate.java
index c45dbaa..6049919 100644
--- a/tools/layoutlib/bridge/src/android/graphics/PorterDuffColorFilter_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/PorterDuffColorFilter_Delegate.java
@@ -55,13 +55,13 @@
// ---- native methods ----
@LayoutlibDelegate
- /*package*/ static int native_CreatePorterDuffFilter(int srcColor, int porterDuffMode) {
+ /*package*/ static long native_CreatePorterDuffFilter(int srcColor, int porterDuffMode) {
PorterDuffColorFilter_Delegate newDelegate = new PorterDuffColorFilter_Delegate();
return sManager.addNewDelegate(newDelegate);
}
@LayoutlibDelegate
- /*package*/ static int nCreatePorterDuffFilter(int nativeFilter, int srcColor,
+ /*package*/ static long nCreatePorterDuffFilter(long nativeFilter, int srcColor,
int porterDuffMode) {
// pass
return 0;
diff --git a/tools/layoutlib/bridge/src/android/graphics/PorterDuffXfermode_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/PorterDuffXfermode_Delegate.java
index 4301c1a..a89fd57 100644
--- a/tools/layoutlib/bridge/src/android/graphics/PorterDuffXfermode_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/PorterDuffXfermode_Delegate.java
@@ -127,7 +127,7 @@
// ---- native methods ----
@LayoutlibDelegate
- /*package*/ static int nativeCreateXfermode(int mode) {
+ /*package*/ static long nativeCreateXfermode(int mode) {
PorterDuffXfermode_Delegate newDelegate = new PorterDuffXfermode_Delegate(mode);
return sManager.addNewDelegate(newDelegate);
}
diff --git a/tools/layoutlib/bridge/src/android/graphics/RadialGradient_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/RadialGradient_Delegate.java
index 3fe45fa..4f16dcf 100644
--- a/tools/layoutlib/bridge/src/android/graphics/RadialGradient_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/RadialGradient_Delegate.java
@@ -54,7 +54,7 @@
// ---- native methods ----
@LayoutlibDelegate
- /*package*/ static int nativeCreate1(float x, float y, float radius,
+ /*package*/ static long nativeCreate1(float x, float y, float radius,
int colors[], float positions[], int tileMode) {
RadialGradient_Delegate newDelegate = new RadialGradient_Delegate(x, y, radius,
colors, positions, Shader_Delegate.getTileMode(tileMode));
@@ -62,21 +62,21 @@
}
@LayoutlibDelegate
- /*package*/ static int nativeCreate2(float x, float y, float radius,
+ /*package*/ static long nativeCreate2(float x, float y, float radius,
int color0, int color1, int tileMode) {
return nativeCreate1(x, y, radius, new int[] { color0, color1 }, null /*positions*/,
tileMode);
}
@LayoutlibDelegate
- /*package*/ static int nativePostCreate1(int native_shader, float x, float y, float radius,
+ /*package*/ static long nativePostCreate1(long native_shader, float x, float y, float radius,
int colors[], float positions[], int tileMode) {
// nothing to be done here.
return 0;
}
@LayoutlibDelegate
- /*package*/ static int nativePostCreate2(int native_shader, float x, float y, float radius,
+ /*package*/ static long nativePostCreate2(long native_shader, float x, float y, float radius,
int color0, int color1, int tileMode) {
// nothing to be done here.
return 0;
diff --git a/tools/layoutlib/bridge/src/android/graphics/Rasterizer_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Rasterizer_Delegate.java
index 2812b6b..a742840 100644
--- a/tools/layoutlib/bridge/src/android/graphics/Rasterizer_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/Rasterizer_Delegate.java
@@ -46,7 +46,7 @@
// ---- Public Helper methods ----
- public static Rasterizer_Delegate getDelegate(int nativeShader) {
+ public static Rasterizer_Delegate getDelegate(long nativeShader) {
return sManager.getDelegate(nativeShader);
}
@@ -56,7 +56,7 @@
// ---- native methods ----
@LayoutlibDelegate
- /*package*/ static void finalizer(int native_instance) {
+ /*package*/ static void finalizer(long native_instance) {
sManager.removeJavaReferenceFor(native_instance);
}
diff --git a/tools/layoutlib/bridge/src/android/graphics/Region_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Region_Delegate.java
index cb31b8f..ea23649 100644
--- a/tools/layoutlib/bridge/src/android/graphics/Region_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/Region_Delegate.java
@@ -57,7 +57,7 @@
// ---- Public Helper methods ----
- public static Region_Delegate getDelegate(int nativeShader) {
+ public static Region_Delegate getDelegate(long nativeShader) {
return sManager.getDelegate(nativeShader);
}
@@ -264,18 +264,18 @@
}
@LayoutlibDelegate
- /*package*/ static int nativeConstructor() {
+ /*package*/ static long nativeConstructor() {
Region_Delegate newDelegate = new Region_Delegate();
return sManager.addNewDelegate(newDelegate);
}
@LayoutlibDelegate
- /*package*/ static void nativeDestructor(int native_region) {
+ /*package*/ static void nativeDestructor(long native_region) {
sManager.removeJavaReferenceFor(native_region);
}
@LayoutlibDelegate
- /*package*/ static boolean nativeSetRegion(int native_dst, int native_src) {
+ /*package*/ static boolean nativeSetRegion(long native_dst, long native_src) {
Region_Delegate dstRegion = sManager.getDelegate(native_dst);
if (dstRegion == null) {
return true;
@@ -293,7 +293,7 @@
}
@LayoutlibDelegate
- /*package*/ static boolean nativeSetRect(int native_dst,
+ /*package*/ static boolean nativeSetRect(long native_dst,
int left, int top, int right, int bottom) {
Region_Delegate dstRegion = sManager.getDelegate(native_dst);
if (dstRegion == null) {
@@ -305,7 +305,7 @@
}
@LayoutlibDelegate
- /*package*/ static boolean nativeSetPath(int native_dst, int native_path, int native_clip) {
+ /*package*/ static boolean nativeSetPath(long native_dst, long native_path, long native_clip) {
Region_Delegate dstRegion = sManager.getDelegate(native_dst);
if (dstRegion == null) {
return true;
@@ -327,7 +327,7 @@
}
@LayoutlibDelegate
- /*package*/ static boolean nativeGetBounds(int native_region, Rect rect) {
+ /*package*/ static boolean nativeGetBounds(long native_region, Rect rect) {
Region_Delegate region = sManager.getDelegate(native_region);
if (region == null) {
return true;
@@ -347,7 +347,7 @@
}
@LayoutlibDelegate
- /*package*/ static boolean nativeGetBoundaryPath(int native_region, int native_path) {
+ /*package*/ static boolean nativeGetBoundaryPath(long native_region, long native_path) {
Region_Delegate region = sManager.getDelegate(native_region);
if (region == null) {
return false;
@@ -368,7 +368,7 @@
}
@LayoutlibDelegate
- /*package*/ static boolean nativeOp(int native_dst,
+ /*package*/ static boolean nativeOp(long native_dst,
int left, int top, int right, int bottom, int op) {
Region_Delegate region = sManager.getDelegate(native_dst);
if (region == null) {
@@ -387,7 +387,7 @@
}
@LayoutlibDelegate
- /*package*/ static boolean nativeOp(int native_dst, Rect rect, int native_region, int op) {
+ /*package*/ static boolean nativeOp(long native_dst, Rect rect, long native_region, int op) {
Region_Delegate region = sManager.getDelegate(native_dst);
if (region == null) {
return false;
@@ -405,8 +405,8 @@
}
@LayoutlibDelegate
- /*package*/ static boolean nativeOp(int native_dst,
- int native_region1, int native_region2, int op) {
+ /*package*/ static boolean nativeOp(long native_dst,
+ long native_region1, long native_region2, int op) {
Region_Delegate dstRegion = sManager.getDelegate(native_dst);
if (dstRegion == null) {
return true;
@@ -434,7 +434,7 @@
}
@LayoutlibDelegate
- /*package*/ static int nativeCreateFromParcel(Parcel p) {
+ /*package*/ static long nativeCreateFromParcel(Parcel p) {
// This is only called by Region.CREATOR (Parcelable.Creator<Region>), which is only
// used during aidl call so really this should not be called.
Bridge.getLog().error(LayoutLog.TAG_UNSUPPORTED,
@@ -444,7 +444,7 @@
}
@LayoutlibDelegate
- /*package*/ static boolean nativeWriteToParcel(int native_region,
+ /*package*/ static boolean nativeWriteToParcel(long native_region,
Parcel p) {
// This is only called when sending a region through aidl, so really this should not
// be called.
@@ -455,7 +455,7 @@
}
@LayoutlibDelegate
- /*package*/ static boolean nativeEquals(int native_r1, int native_r2) {
+ /*package*/ static boolean nativeEquals(long native_r1, long native_r2) {
Region_Delegate region1 = sManager.getDelegate(native_r1);
if (region1 == null) {
return false;
@@ -470,7 +470,7 @@
}
@LayoutlibDelegate
- /*package*/ static String nativeToString(int native_region) {
+ /*package*/ static String nativeToString(long native_region) {
Region_Delegate region = sManager.getDelegate(native_region);
if (region == null) {
return "not found";
diff --git a/tools/layoutlib/bridge/src/android/graphics/Shader_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Shader_Delegate.java
index 368c0384..70a0a43 100644
--- a/tools/layoutlib/bridge/src/android/graphics/Shader_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/Shader_Delegate.java
@@ -49,7 +49,7 @@
// ---- Public Helper methods ----
- public static Shader_Delegate getDelegate(int nativeShader) {
+ public static Shader_Delegate getDelegate(long nativeShader) {
return sManager.getDelegate(nativeShader);
}
@@ -76,13 +76,13 @@
// ---- native methods ----
@LayoutlibDelegate
- /*package*/ static void nativeDestructor(int native_shader, int native_skiaShader) {
+ /*package*/ static void nativeDestructor(long native_shader, long native_skiaShader) {
sManager.removeJavaReferenceFor(native_shader);
}
@LayoutlibDelegate
- /*package*/ static void nativeSetLocalMatrix(int native_shader, int native_skiaShader,
- int matrix_instance) {
+ /*package*/ static void nativeSetLocalMatrix(long native_shader, long native_skiaShader,
+ long matrix_instance) {
// get the delegate from the native int.
Shader_Delegate shaderDelegate = sManager.getDelegate(native_shader);
if (shaderDelegate == null) {
diff --git a/tools/layoutlib/bridge/src/android/graphics/SumPathEffect_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/SumPathEffect_Delegate.java
index 410df0c..6d2e9b4 100644
--- a/tools/layoutlib/bridge/src/android/graphics/SumPathEffect_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/SumPathEffect_Delegate.java
@@ -62,7 +62,7 @@
// ---- native methods ----
@LayoutlibDelegate
- /*package*/ static int nativeCreate(int first, int second) {
+ /*package*/ static long nativeCreate(long first, long second) {
SumPathEffect_Delegate newDelegate = new SumPathEffect_Delegate();
return sManager.addNewDelegate(newDelegate);
}
diff --git a/tools/layoutlib/bridge/src/android/graphics/SweepGradient_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/SweepGradient_Delegate.java
index 13ae12e..f2b3e8d 100644
--- a/tools/layoutlib/bridge/src/android/graphics/SweepGradient_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/SweepGradient_Delegate.java
@@ -52,25 +52,25 @@
// ---- native methods ----
@LayoutlibDelegate
- /*package*/ static int nativeCreate1(float x, float y, int colors[], float positions[]) {
+ /*package*/ static long nativeCreate1(float x, float y, int colors[], float positions[]) {
SweepGradient_Delegate newDelegate = new SweepGradient_Delegate(x, y, colors, positions);
return sManager.addNewDelegate(newDelegate);
}
@LayoutlibDelegate
- /*package*/ static int nativeCreate2(float x, float y, int color0, int color1) {
+ /*package*/ static long nativeCreate2(float x, float y, int color0, int color1) {
return nativeCreate1(x, y, new int[] { color0, color1 }, null /*positions*/);
}
@LayoutlibDelegate
- /*package*/ static int nativePostCreate1(int native_shader, float cx, float cy,
+ /*package*/ static long nativePostCreate1(long native_shader, float cx, float cy,
int[] colors, float[] positions) {
// nothing to be done here.
return 0;
}
@LayoutlibDelegate
- /*package*/ static int nativePostCreate2(int native_shader, float cx, float cy,
+ /*package*/ static long nativePostCreate2(long native_shader, float cx, float cy,
int color0, int color1) {
// nothing to be done here.
return 0;
diff --git a/tools/layoutlib/bridge/src/android/graphics/Typeface_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Typeface_Delegate.java
index 8701cc8..a25fb59 100644
--- a/tools/layoutlib/bridge/src/android/graphics/Typeface_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/Typeface_Delegate.java
@@ -75,7 +75,7 @@
sPostInitDelegate.clear();
}
- public static Typeface_Delegate getDelegate(int nativeTypeface) {
+ public static Typeface_Delegate getDelegate(long nativeTypeface) {
return sManager.getDelegate(nativeTypeface);
}
@@ -83,7 +83,7 @@
return getFonts(typeface.native_instance);
}
- public static List<Font> getFonts(int native_int) {
+ public static List<Font> getFonts(long native_int) {
Typeface_Delegate delegate = sManager.getDelegate(native_int);
if (delegate == null) {
return null;
@@ -99,7 +99,7 @@
// ---- native methods ----
@LayoutlibDelegate
- /*package*/ static synchronized int nativeCreate(String familyName, int style) {
+ /*package*/ static synchronized long nativeCreate(String familyName, int style) {
if (familyName == null) {
familyName = DEFAULT_FAMILY;
}
@@ -118,7 +118,7 @@
}
@LayoutlibDelegate
- /*package*/ static synchronized int nativeCreateFromTypeface(int native_instance, int style) {
+ /*package*/ static synchronized long nativeCreateFromTypeface(long native_instance, int style) {
Typeface_Delegate delegate = sManager.getDelegate(native_instance);
if (delegate == null) {
return 0;
@@ -138,14 +138,14 @@
}
@LayoutlibDelegate
- /*package*/ static synchronized int nativeCreateFromAsset(AssetManager mgr, String path) {
+ /*package*/ static synchronized long nativeCreateFromAsset(AssetManager mgr, String path) {
Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED,
"Typeface.createFromAsset() is not supported.", null /*throwable*/, null /*data*/);
return 0;
}
@LayoutlibDelegate
- /*package*/ static synchronized int nativeCreateFromFile(String path) {
+ /*package*/ static synchronized long nativeCreateFromFile(String path) {
if (path.startsWith(SYSTEM_FONTS) ) {
String relativePath = path.substring(SYSTEM_FONTS.length());
File f = new File(sFontLoader.getOsFontsLocation(), relativePath);
@@ -174,12 +174,12 @@
}
@LayoutlibDelegate
- /*package*/ static void nativeUnref(int native_instance) {
+ /*package*/ static void nativeUnref(long native_instance) {
sManager.removeJavaReferenceFor(native_instance);
}
@LayoutlibDelegate
- /*package*/ static int nativeGetStyle(int native_instance) {
+ /*package*/ static int nativeGetStyle(long native_instance) {
Typeface_Delegate delegate = sManager.getDelegate(native_instance);
if (delegate == null) {
return 0;
diff --git a/tools/layoutlib/bridge/src/android/graphics/Xfermode_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Xfermode_Delegate.java
index 962d69c..94a6d76 100644
--- a/tools/layoutlib/bridge/src/android/graphics/Xfermode_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/Xfermode_Delegate.java
@@ -48,7 +48,7 @@
// ---- Public Helper methods ----
- public static Xfermode_Delegate getDelegate(int native_instance) {
+ public static Xfermode_Delegate getDelegate(long native_instance) {
return sManager.getDelegate(native_instance);
}
@@ -60,7 +60,7 @@
// ---- native methods ----
@LayoutlibDelegate
- /*package*/ static void finalizer(int native_instance) {
+ /*package*/ static void finalizer(long native_instance) {
sManager.removeJavaReferenceFor(native_instance);
}
diff --git a/tools/layoutlib/bridge/src/android/os/SystemClock_Delegate.java b/tools/layoutlib/bridge/src/android/os/SystemClock_Delegate.java
index fd594f7..5f0d98b 100644
--- a/tools/layoutlib/bridge/src/android/os/SystemClock_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/os/SystemClock_Delegate.java
@@ -33,11 +33,6 @@
private static long sBootTime = System.currentTimeMillis();
private static long sBootTimeNano = System.nanoTime();
- @LayoutlibDelegate
- /*package*/ static boolean setCurrentTimeMillis(long millis) {
- return true;
- }
-
/**
* Returns milliseconds since boot, not counting time spent in deep sleep.
* <b>Note:</b> This value may get reset occasionally (before it would
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/DelegateManager.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/DelegateManager.java
index ae1217d..261cc98 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/DelegateManager.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/DelegateManager.java
@@ -94,7 +94,7 @@
* @param native_object the native int.
* @return the delegate or null if not found.
*/
- public T getDelegate(int native_object) {
+ public T getDelegate(long native_object) {
if (native_object > 0) {
T delegate = mDelegates.get(native_object);
@@ -116,8 +116,8 @@
* @param newDelegate the delegate to add
* @return a unique native int to identify the delegate
*/
- public int addNewDelegate(T newDelegate) {
- int native_object = ++mDelegateCounter;
+ public long addNewDelegate(T newDelegate) {
+ long native_object = ++mDelegateCounter;
mDelegates.put(native_object, newDelegate);
assert !mJavaReferences.contains(newDelegate);
mJavaReferences.add(newDelegate);
@@ -133,7 +133,7 @@
* Removes the main reference on the given delegate.
* @param native_object the native integer representing the delegate.
*/
- public void removeJavaReferenceFor(int native_object) {
+ public void removeJavaReferenceFor(long native_object) {
T delegate = getDelegate(native_object);
if (Debug.DEBUG) {
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/util/SparseWeakArray.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/util/SparseWeakArray.java
index 4d0c9ce..53e1640 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/util/SparseWeakArray.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/util/SparseWeakArray.java
@@ -30,13 +30,14 @@
*
* The code is taken from {@link SparseArray} directly and adapted to use weak references.
*
- * Because our usage means that we never actually call {@link #remove(int)} or {@link #delete(int)},
- * we must manually check if there are reclaimed references to trigger an internal compact step
- * (which is normally only triggered when an item is manually removed).
+ * Because our usage means that we never actually call {@link #remove(long)} or
+ * {@link #delete(long)}, we must manually check if there are reclaimed references to
+ * trigger an internal compact step (which is normally only triggered when an item is manually
+ * removed).
*
- * SparseArrays map integers to Objects. Unlike a normal array of Objects,
+ * SparseArrays map integral values to Objects. Unlike a normal array of Objects,
* there can be gaps in the indices. It is intended to be more efficient
- * than using a HashMap to map Integers to Objects.
+ * than using a HashMap to map Integers (or Longs) to Objects.
*/
@SuppressWarnings("unchecked")
public class SparseWeakArray<E> {
@@ -58,9 +59,9 @@
* number of mappings.
*/
public SparseWeakArray(int initialCapacity) {
- initialCapacity = ArrayUtils.idealIntArraySize(initialCapacity);
+ initialCapacity = ArrayUtils.idealLongArraySize(initialCapacity);
- mKeys = new int[initialCapacity];
+ mKeys = new long[initialCapacity];
mValues = new WeakReference[initialCapacity];
mSize = 0;
}
@@ -69,7 +70,7 @@
* Gets the Object mapped from the specified key, or <code>null</code>
* if no such mapping has been made.
*/
- public E get(int key) {
+ public E get(long key) {
return get(key, null);
}
@@ -77,7 +78,7 @@
* Gets the Object mapped from the specified key, or the specified Object
* if no such mapping has been made.
*/
- public E get(int key, E valueIfKeyNotFound) {
+ public E get(long key, E valueIfKeyNotFound) {
int i = binarySearch(mKeys, 0, mSize, key);
if (i < 0 || mValues[i] == DELETED || mValues[i].get() == null) {
@@ -90,7 +91,7 @@
/**
* Removes the mapping from the specified key, if there was any.
*/
- public void delete(int key) {
+ public void delete(long key) {
int i = binarySearch(mKeys, 0, mSize, key);
if (i >= 0) {
@@ -102,9 +103,9 @@
}
/**
- * Alias for {@link #delete(int)}.
+ * Alias for {@link #delete(long)}.
*/
- public void remove(int key) {
+ public void remove(long key) {
delete(key);
}
@@ -121,7 +122,7 @@
private void gc() {
int n = mSize;
int o = 0;
- int[] keys = mKeys;
+ long[] keys = mKeys;
WeakReference<?>[] values = mValues;
for (int i = 0; i < n; i++) {
@@ -142,9 +143,9 @@
mGarbage = false;
mSize = o;
- int newSize = ArrayUtils.idealIntArraySize(mSize);
+ int newSize = ArrayUtils.idealLongArraySize(mSize);
if (newSize < mKeys.length) {
- int[] nkeys = new int[newSize];
+ long[] nkeys = new long[newSize];
WeakReference<?>[] nvalues = new WeakReference[newSize];
System.arraycopy(mKeys, 0, nkeys, 0, newSize);
@@ -160,7 +161,7 @@
* replacing the previous mapping from the specified key if there
* was one.
*/
- public void put(int key, E value) {
+ public void put(long key, E value) {
int i = binarySearch(mKeys, 0, mSize, key);
if (i >= 0) {
@@ -182,9 +183,9 @@
}
if (mSize >= mKeys.length) {
- int n = ArrayUtils.idealIntArraySize(mSize + 1);
+ int n = ArrayUtils.idealLongArraySize(mSize + 1);
- int[] nkeys = new int[n];
+ long[] nkeys = new long[n];
WeakReference<?>[] nvalues = new WeakReference[n];
// Log.e("SparseArray", "grow " + mKeys.length + " to " + n);
@@ -224,7 +225,7 @@
* the key from the <code>index</code>th key-value mapping that this
* SparseArray stores.
*/
- public int keyAt(int index) {
+ public long keyAt(int index) {
if (mGarbage) {
gc();
}
@@ -263,7 +264,7 @@
* specified key, or a negative number if the specified
* key is not mapped.
*/
- public int indexOfKey(int key) {
+ public int indexOfKey(long key) {
if (mGarbage) {
gc();
}
@@ -310,7 +311,7 @@
* Puts a key/value pair into the array, optimizing for the case where
* the key is greater than all existing keys in the array.
*/
- public void append(int key, E value) {
+ public void append(long key, E value) {
if (mSize != 0 && key <= mKeys[mSize - 1]) {
put(key, value);
return;
@@ -322,9 +323,9 @@
int pos = mSize;
if (pos >= mKeys.length) {
- int n = ArrayUtils.idealIntArraySize(pos + 1);
+ int n = ArrayUtils.idealLongArraySize(pos + 1);
- int[] nkeys = new int[n];
+ long[] nkeys = new long[n];
WeakReference<?>[] nvalues = new WeakReference[n];
// Log.e("SparseArray", "grow " + mKeys.length + " to " + n);
@@ -350,7 +351,7 @@
return false;
}
- private static int binarySearch(int[] a, int start, int len, int key) {
+ private static int binarySearch(long[] a, int start, int len, long key) {
int high = start + len, low = start - 1, guess;
while (high - low > 1) {
@@ -370,7 +371,7 @@
return ~high;
}
- private int[] mKeys;
+ private long[] mKeys;
private WeakReference<?>[] mValues;
private int mSize;
}
diff --git a/tools/layoutlib/bridge/src/libcore/icu/DateIntervalFormat_Delegate.java b/tools/layoutlib/bridge/src/libcore/icu/DateIntervalFormat_Delegate.java
index a773d93..d94c205 100644
--- a/tools/layoutlib/bridge/src/libcore/icu/DateIntervalFormat_Delegate.java
+++ b/tools/layoutlib/bridge/src/libcore/icu/DateIntervalFormat_Delegate.java
@@ -21,6 +21,7 @@
import com.android.ide.common.rendering.api.LayoutLog;
import com.android.layoutlib.bridge.Bridge;
import com.android.layoutlib.bridge.impl.DelegateManager;
+import com.android.tools.layoutlib.annotations.LayoutlibDelegate;
import com.ibm.icu.text.DateIntervalFormat;
import com.ibm.icu.util.DateInterval;
import com.ibm.icu.util.TimeZone;
@@ -38,6 +39,7 @@
// ---- native methods ----
+ @LayoutlibDelegate
/*package*/static String formatDateInterval(long address, long fromDate, long toDate) {
DateIntervalFormat_Delegate delegate = sManager.getDelegate((int)address);
if (delegate == null) {
@@ -52,6 +54,7 @@
return sb.toString();
}
+ @LayoutlibDelegate
/*package*/ static long createDateIntervalFormat(String skeleton, String localeName,
String tzName) {
TimeZone prevDefaultTz = TimeZone.getDefault();
@@ -63,6 +66,7 @@
return sManager.addNewDelegate(newDelegate);
}
+ @LayoutlibDelegate
/*package*/ static void destroyDateIntervalFormat(long address) {
sManager.removeJavaReferenceFor((int)address);
}
diff --git a/tools/layoutlib/bridge/src/libcore/icu/ICU_Delegate.java b/tools/layoutlib/bridge/src/libcore/icu/ICU_Delegate.java
index 06ae804..998b08b 100644
--- a/tools/layoutlib/bridge/src/libcore/icu/ICU_Delegate.java
+++ b/tools/layoutlib/bridge/src/libcore/icu/ICU_Delegate.java
@@ -46,7 +46,7 @@
// --- Native methods accessing ICU's database.
@LayoutlibDelegate
- /*package*/ static String getBestDateTimePattern(String skeleton, String localeName) {
+ /*package*/ static String getBestDateTimePatternNative(String skeleton, String localeName) {
return DateTimePatternGenerator.getInstance(new ULocale(localeName))
.getBestPattern(skeleton);
}
@@ -137,6 +137,11 @@
}
@LayoutlibDelegate
+ /*package*/ static String getDisplayScriptNative(String variantCode, String locale) {
+ return "";
+ }
+
+ @LayoutlibDelegate
/*package*/ static String getISO3CountryNative(String locale) {
return "";
}
@@ -166,8 +171,19 @@
return Locale.getISOCountries();
}
+
@LayoutlibDelegate
- /*package*/ static boolean initLocaleDataImpl(String locale, LocaleData result) {
+ /*package*/ static String localeForLanguageTag(String languageTag, boolean strict) {
+ return "";
+ }
+
+ @LayoutlibDelegate
+ /*package*/ static String languageTagForLocale(String locale) {
+ return "";
+ }
+
+ @LayoutlibDelegate
+ /*package*/ static boolean initLocaleDataNative(String locale, LocaleData result) {
// Used by Calendar.
result.firstDayOfWeek = Integer.valueOf(1);
@@ -215,7 +231,7 @@
result.percent = '%';
result.perMill = '\u2030';
result.monetarySeparator = ' ';
- result.minusSign = '-';
+ result.minusSign = "-";
result.exponentSeparator = "e";
result.infinity = "\u221E";
result.NaN = "NaN";
diff --git a/tools/preload/Android.mk b/tools/preload/Android.mk
index f325870..14a4547 100644
--- a/tools/preload/Android.mk
+++ b/tools/preload/Android.mk
@@ -20,4 +20,4 @@
include $(BUILD_HOST_JAVA_LIBRARY)
-include $(call all-subdir-makefiles)
+include $(call all-makefiles-under,$(LOCAL_PATH))