diff options
Diffstat (limited to 'cmds')
| -rw-r--r-- | cmds/am/src/com/android/commands/am/Am.java | 22 | ||||
| -rw-r--r-- | cmds/app_process/Android.mk | 92 | ||||
| -rw-r--r-- | cmds/app_process/app_main.cpp | 58 | ||||
| -rw-r--r-- | cmds/bmgr/Android.mk | 15 | ||||
| -rw-r--r-- | cmds/bootanimation/BootAnimation.cpp | 1 | ||||
| -rw-r--r-- | cmds/ime/Android.mk | 15 | ||||
| -rw-r--r-- | cmds/input/Android.mk | 13 | ||||
| -rw-r--r-- | cmds/pm/Android.mk | 15 | ||||
| -rw-r--r-- | cmds/requestsync/src/com/android/commands/requestsync/RequestSync.java | 6 | ||||
| -rw-r--r-- | cmds/svc/Android.mk | 15 | ||||
| -rw-r--r-- | cmds/svc/src/com/android/commands/svc/UsbCommand.java | 2 | ||||
| -rw-r--r-- | cmds/uiautomator/library/Android.mk | 8 | ||||
| -rw-r--r-- | cmds/webview_zygote/Android.mk | 49 | ||||
| -rw-r--r-- | cmds/webview_zygote/webview_zygote.cpp | 76 | ||||
| -rw-r--r-- | cmds/webview_zygote/webview_zygote32.rc | 22 | ||||
| -rw-r--r-- | cmds/webview_zygote/webview_zygote64.rc | 22 |
16 files changed, 307 insertions, 124 deletions
diff --git a/cmds/am/src/com/android/commands/am/Am.java b/cmds/am/src/com/android/commands/am/Am.java index c460b048a3b7..d6c00589e7c2 100644 --- a/cmds/am/src/com/android/commands/am/Am.java +++ b/cmds/am/src/com/android/commands/am/Am.java @@ -48,9 +48,7 @@ import android.content.pm.InstrumentationInfo; import android.content.pm.ParceledListSlice; import android.content.pm.ResolveInfo; import android.content.pm.UserInfo; -import android.content.res.AssetManager; import android.content.res.Configuration; -import android.content.res.Resources; import android.graphics.Rect; import android.os.Binder; import android.os.Build; @@ -66,7 +64,6 @@ import android.os.UserHandle; import android.text.TextUtils; import android.util.AndroidException; import android.util.ArrayMap; -import android.util.DisplayMetrics; import android.view.IWindowManager; import com.android.internal.os.BaseCommand; @@ -364,8 +361,6 @@ public class Am extends BaseCommand { "am send-trim-memory: send a memory trim event to a <PROCESS>.\n" + "\n" + "am get-current-user: returns id of the current foreground user.\n" + - "\n" + - "am supports-multiwindow: returns true if the device supports multiwindow.\n" + "\n" ); Intent.printIntentArgsHelp(pw, ""); @@ -463,8 +458,6 @@ public class Am extends BaseCommand { runSendTrimMemory(); } else if (op.equals("get-current-user")) { runGetCurrentUser(); - } else if (op.equals("supports-multiwindow")) { - runSupportsMultiwindow(); } else { showError("Error: unknown command '" + op + "'"); } @@ -2541,21 +2534,6 @@ public class Am extends BaseCommand { System.out.println(currentUser.id); } - private void runSupportsMultiwindow() throws Exception { - // system resources does not contain all the device configuration, construct it manually. - Configuration config = mAm.getConfiguration(); - if (config == null) { - throw new AndroidException("Activity manager has no configuration"); - } - - final DisplayMetrics metrics = new DisplayMetrics(); - metrics.setToDefaults(); - - Resources res = new Resources(AssetManager.getSystem(), metrics, config); - - System.out.println(res.getBoolean(com.android.internal.R.bool.config_supportsMultiWindow)); - } - /** * Open the given file for sending into the system process. This verifies * with SELinux that the system will have access to the file. diff --git a/cmds/app_process/Android.mk b/cmds/app_process/Android.mk index fae0400a1212..eaad3a7ec529 100644 --- a/cmds/app_process/Android.mk +++ b/cmds/app_process/Android.mk @@ -1,77 +1,67 @@ LOCAL_PATH:= $(call my-dir) -# This is a list of libraries that need to be included in order to avoid -# bad apps. This prevents a library from having a mismatch when resolving -# new/delete from an app shared library. -# See b/21032018 for more details. app_process_common_shared_libs := \ - libwilhelm \ - -include $(CLEAR_VARS) - -LOCAL_SRC_FILES:= \ - app_main.cpp - -LOCAL_LDFLAGS := -Wl,--version-script,art/sigchainlib/version-script.txt -Wl,--export-dynamic - -LOCAL_SHARED_LIBRARIES := \ - libdl \ + libandroid_runtime \ + libbinder \ libcutils \ - libutils \ + libdl \ liblog \ - libbinder \ libnativeloader \ - libandroid_runtime \ - $(app_process_common_shared_libs) \ - -LOCAL_WHOLE_STATIC_LIBRARIES := libsigchain + libutils \ -LOCAL_MODULE:= app_process -LOCAL_MULTILIB := both -LOCAL_MODULE_STEM_32 := app_process32 -LOCAL_MODULE_STEM_64 := app_process64 +# This is a list of libraries that need to be included in order to avoid +# bad apps. This prevents a library from having a mismatch when resolving +# new/delete from an app shared library. +# See b/21032018 for more details. +app_process_common_shared_libs += \ + libwilhelm \ -LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code +app_process_common_static_libs := \ + libsigchain \ -include $(BUILD_EXECUTABLE) +app_process_src_files := \ + app_main.cpp \ -# Create a symlink from app_process to app_process32 or 64 -# depending on the target configuration. -include $(BUILD_SYSTEM)/executable_prefer_symlink.mk +app_process_cflags := \ + -Wall -Werror -Wunused -Wunreachable-code -# Build a variant of app_process binary linked with ASan runtime. -# ARM-only at the moment. -ifeq ($(TARGET_ARCH),arm) +app_process_ldflags_32 := \ + -Wl,--version-script,art/sigchainlib/version-script32.txt -Wl,--export-dynamic +app_process_ldflags_64 := \ + -Wl,--version-script,art/sigchainlib/version-script64.txt -Wl,--export-dynamic include $(CLEAR_VARS) -LOCAL_SRC_FILES:= \ - app_main.cpp +LOCAL_SRC_FILES:= $(app_process_src_files) -LOCAL_SHARED_LIBRARIES := \ - libcutils \ - libutils \ - liblog \ - libbinder \ - libandroid_runtime \ - $(app_process_common_shared_libs) \ +LOCAL_LDFLAGS_32 := $(app_process_ldflags_32) +LOCAL_LDFLAGS_64 := $(app_process_ldflags_64) -LOCAL_WHOLE_STATIC_LIBRARIES := libsigchain +LOCAL_SHARED_LIBRARIES := $(app_process_common_shared_libs) -LOCAL_LDFLAGS := -ldl -Wl,--version-script,art/sigchainlib/version-script.txt -Wl,--export-dynamic -LOCAL_CPPFLAGS := -std=c++11 +LOCAL_WHOLE_STATIC_LIBRARIES := $(app_process_common_static_libs) -LOCAL_MODULE := app_process__asan +LOCAL_MODULE:= app_process LOCAL_MULTILIB := both LOCAL_MODULE_STEM_32 := app_process32 LOCAL_MODULE_STEM_64 := app_process64 -LOCAL_SANITIZE := address -LOCAL_CLANG := true -LOCAL_MODULE_PATH := $(TARGET_OUT_EXECUTABLES)/asan +LOCAL_CFLAGS += $(app_process_cflags) -LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code +# In SANITIZE_LITE mode, we create the sanitized binary in a separate location (but reuse +# the same module). Using the same module also works around an issue with make: binaries +# that depend on sanitized libraries will be relinked, even if they set LOCAL_SANITIZE := never. +# +# Also pull in the asanwrapper helper. +ifeq ($(SANITIZE_LITE),true) +LOCAL_MODULE_PATH := $(TARGET_OUT_EXECUTABLES)/asan +LOCAL_REQUIRED_MODULES := asanwrapper +endif include $(BUILD_EXECUTABLE) -endif # ifeq($(TARGET_ARCH),arm) +# Create a symlink from app_process to app_process32 or 64 +# depending on the target configuration. +ifneq ($(SANITIZE_LITE),true) +include $(BUILD_SYSTEM)/executable_prefer_symlink.mk +endif diff --git a/cmds/app_process/app_main.cpp b/cmds/app_process/app_main.cpp index 2e023825a219..d5580acce4f8 100644 --- a/cmds/app_process/app_main.cpp +++ b/cmds/app_process/app_main.cpp @@ -17,7 +17,6 @@ #include <binder/ProcessState.h> #include <utils/Log.h> #include <cutils/memory.h> -#include <cutils/process_name.h> #include <cutils/properties.h> #include <cutils/trace.h> #include <android_runtime/AndroidRuntime.h> @@ -186,12 +185,17 @@ static const char ZYGOTE_NICE_NAME[] = "zygote"; int main(int argc, char* const argv[]) { if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0) < 0) { - // Older kernels don't understand PR_SET_NO_NEW_PRIVS and return - // EINVAL. Don't die on such kernels. - if (errno != EINVAL) { - LOG_ALWAYS_FATAL("PR_SET_NO_NEW_PRIVS failed: %s", strerror(errno)); - return 12; - } + LOG_ALWAYS_FATAL("PR_SET_NO_NEW_PRIVS failed: %s", strerror(errno)); + } + + if (!LOG_NDEBUG) { + String8 argv_String; + for (int i = 0; i < argc; ++i) { + argv_String.append("\""); + argv_String.append(argv[i]); + argv_String.append("\" "); + } + ALOGV("app_process main with argv: %s", argv_String.string()); } AppRuntime runtime(argv[0], computeArgBlockSize(argc, argv)); @@ -222,9 +226,31 @@ int main(int argc, char* const argv[]) // // Note that we must copy argument string values since we will rewrite the // entire argument block when we apply the nice name to argv0. + // + // As an exception to the above rule, anything in "spaced commands" + // goes to the vm even though it has a space in it. + const char* spaced_commands[] = { "-cp", "-classpath" }; + // Allow "spaced commands" to be succeeded by exactly 1 argument (regardless of -s). + bool known_command = false; int i; for (i = 0; i < argc; i++) { + if (known_command == true) { + runtime.addOption(strdup(argv[i])); + ALOGV("app_process main add known option '%s'", argv[i]); + known_command = false; + continue; + } + + for (int j = 0; + j < static_cast<int>(sizeof(spaced_commands) / sizeof(spaced_commands[0])); + ++j) { + if (strcmp(argv[i], spaced_commands[j]) == 0) { + known_command = true; + ALOGV("app_process main found known command '%s'", argv[i]); + } + } + if (argv[i][0] != '-') { break; } @@ -232,7 +258,9 @@ int main(int argc, char* const argv[]) ++i; // Skip --. break; } + runtime.addOption(strdup(argv[i])); + ALOGV("app_process main add option '%s'", argv[i]); } // Parse runtime arguments. Stop at first unrecognized option. @@ -272,6 +300,18 @@ int main(int argc, char* const argv[]) // 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); + + if (!LOG_NDEBUG) { + String8 restOfArgs; + char* const* argv_new = argv + i; + int argc_new = argc - i; + for (int k = 0; k < argc_new; ++k) { + restOfArgs.append("\""); + restOfArgs.append(argv_new[k]); + restOfArgs.append("\" "); + } + ALOGV("Class name = %s, args = %s", className.string(), restOfArgs.string()); + } } else { // We're in zygote mode. maybeCreateDalvikCache(); @@ -299,8 +339,7 @@ int main(int argc, char* const argv[]) } if (!niceName.isEmpty()) { - runtime.setArgv0(niceName.string()); - set_process_name(niceName.string()); + runtime.setArgv0(niceName.string(), true /* setProcName */); } if (zygote) { @@ -311,6 +350,5 @@ int main(int argc, char* const argv[]) fprintf(stderr, "Error: no class name or --zygote supplied.\n"); app_usage(); LOG_ALWAYS_FATAL("app_process: no class name or --zygote supplied."); - return 10; } } diff --git a/cmds/bmgr/Android.mk b/cmds/bmgr/Android.mk index 8a1670b2ccff..d520cf2143ee 100644 --- a/cmds/bmgr/Android.mk +++ b/cmds/bmgr/Android.mk @@ -1,15 +1,16 @@ # Copyright 2007 The Android Open Source Project # LOCAL_PATH:= $(call my-dir) -include $(CLEAR_VARS) +include $(CLEAR_VARS) LOCAL_SRC_FILES := $(call all-subdir-java-files) -LOCAL_MODULE := bmgr +LOCAL_MODULE := bmgrlib +LOCAL_MODULE_STEM := bmgr include $(BUILD_JAVA_LIBRARY) - include $(CLEAR_VARS) -ALL_PREBUILT += $(TARGET_OUT)/bin/bmgr -$(TARGET_OUT)/bin/bmgr : $(LOCAL_PATH)/bmgr | $(ACP) - $(transform-prebuilt-to-target) - +LOCAL_MODULE := bmgr +LOCAL_MODULE_CLASS := EXECUTABLES +LOCAL_SRC_FILES := bmgr +LOCAL_REQUIRED_MODULES := bmgrlib +include $(BUILD_PREBUILT) diff --git a/cmds/bootanimation/BootAnimation.cpp b/cmds/bootanimation/BootAnimation.cpp index 10fabcfb735f..9cfef47b2ea1 100644 --- a/cmds/bootanimation/BootAnimation.cpp +++ b/cmds/bootanimation/BootAnimation.cpp @@ -348,6 +348,7 @@ bool BootAnimation::threadLoop() mFlingerSurface.clear(); mFlingerSurfaceControl.clear(); eglTerminate(mDisplay); + eglReleaseThread(); IPCThreadState::self()->stopProcess(); return r; } diff --git a/cmds/ime/Android.mk b/cmds/ime/Android.mk index 90b1c9106cbc..6803fc01154c 100644 --- a/cmds/ime/Android.mk +++ b/cmds/ime/Android.mk @@ -1,15 +1,16 @@ # Copyright 2007 The Android Open Source Project # LOCAL_PATH:= $(call my-dir) -include $(CLEAR_VARS) +include $(CLEAR_VARS) LOCAL_SRC_FILES := $(call all-subdir-java-files) -LOCAL_MODULE := ime +LOCAL_MODULE := imelib +LOCAL_MODULE_STEM := ime include $(BUILD_JAVA_LIBRARY) - include $(CLEAR_VARS) -ALL_PREBUILT += $(TARGET_OUT)/bin/ime -$(TARGET_OUT)/bin/ime : $(LOCAL_PATH)/ime | $(ACP) - $(transform-prebuilt-to-target) - +LOCAL_MODULE := ime +LOCAL_MODULE_CLASS := EXECUTABLES +LOCAL_SRC_FILES := ime +LOCAL_REQUIRED_MODULES := imelib +include $(BUILD_PREBUILT) diff --git a/cmds/input/Android.mk b/cmds/input/Android.mk index 3d5653328c40..4e983e398ccb 100644 --- a/cmds/input/Android.mk +++ b/cmds/input/Android.mk @@ -1,13 +1,16 @@ # Copyright 2008 The Android Open Source Project # LOCAL_PATH:= $(call my-dir) -include $(CLEAR_VARS) +include $(CLEAR_VARS) LOCAL_SRC_FILES := $(call all-subdir-java-files) -LOCAL_MODULE := input +LOCAL_MODULE := inputlib +LOCAL_MODULE_STEM := input include $(BUILD_JAVA_LIBRARY) include $(CLEAR_VARS) -ALL_PREBUILT += $(TARGET_OUT)/bin/input -$(TARGET_OUT)/bin/input : $(LOCAL_PATH)/input | $(ACP) - $(transform-prebuilt-to-target) +LOCAL_MODULE := input +LOCAL_MODULE_CLASS := EXECUTABLES +LOCAL_SRC_FILES := input +LOCAL_REQUIRED_MODULES := inputlib +include $(BUILD_PREBUILT) diff --git a/cmds/pm/Android.mk b/cmds/pm/Android.mk index 7911d629ed8b..6a03defc9e2c 100644 --- a/cmds/pm/Android.mk +++ b/cmds/pm/Android.mk @@ -1,15 +1,16 @@ # Copyright 2007 The Android Open Source Project # LOCAL_PATH:= $(call my-dir) -include $(CLEAR_VARS) +include $(CLEAR_VARS) LOCAL_SRC_FILES := $(call all-subdir-java-files) -LOCAL_MODULE := pm +LOCAL_MODULE := pmlib +LOCAL_MODULE_STEM := pm include $(BUILD_JAVA_LIBRARY) - include $(CLEAR_VARS) -ALL_PREBUILT += $(TARGET_OUT)/bin/pm -$(TARGET_OUT)/bin/pm : $(LOCAL_PATH)/pm | $(ACP) - $(transform-prebuilt-to-target) - +LOCAL_MODULE := pm +LOCAL_MODULE_CLASS := EXECUTABLES +LOCAL_SRC_FILES := pm +LOCAL_REQUIRED_MODULES := pmlib +include $(BUILD_PREBUILT) diff --git a/cmds/requestsync/src/com/android/commands/requestsync/RequestSync.java b/cmds/requestsync/src/com/android/commands/requestsync/RequestSync.java index 808618f28666..50ee56455b48 100644 --- a/cmds/requestsync/src/com/android/commands/requestsync/RequestSync.java +++ b/cmds/requestsync/src/com/android/commands/requestsync/RequestSync.java @@ -128,15 +128,15 @@ public class RequestSync { } else if (opt.equals("--el") || opt.equals("--extra-long")) { final String key = nextArgRequired(); final String value = nextArgRequired(); - mExtras.putLong(key, Long.valueOf(value)); + mExtras.putLong(key, Long.parseLong(value)); } else if (opt.equals("--ef") || opt.equals("--extra-float")) { final String key = nextArgRequired(); final String value = nextArgRequired(); - mExtras.putFloat(key, Long.valueOf(value)); + mExtras.putFloat(key, Long.parseLong(value)); } else if (opt.equals("--ed") || opt.equals("--extra-double")) { final String key = nextArgRequired(); final String value = nextArgRequired(); - mExtras.putFloat(key, Long.valueOf(value)); + mExtras.putFloat(key, Long.parseLong(value)); } else if (opt.equals("--ez") || opt.equals("--extra-bool")) { final String key = nextArgRequired(); final String value = nextArgRequired(); diff --git a/cmds/svc/Android.mk b/cmds/svc/Android.mk index 198efb2d6d14..a4824c70f979 100644 --- a/cmds/svc/Android.mk +++ b/cmds/svc/Android.mk @@ -1,15 +1,16 @@ # Copyright 2007 The Android Open Source Project # LOCAL_PATH:= $(call my-dir) -include $(CLEAR_VARS) +include $(CLEAR_VARS) LOCAL_SRC_FILES := $(call all-subdir-java-files) -LOCAL_MODULE := svc +LOCAL_MODULE := svclib +LOCAL_MODULE_STEM := svc include $(BUILD_JAVA_LIBRARY) - include $(CLEAR_VARS) -ALL_PREBUILT += $(TARGET_OUT)/bin/svc -$(TARGET_OUT)/bin/svc : $(LOCAL_PATH)/svc | $(ACP) - $(transform-prebuilt-to-target) - +LOCAL_MODULE := svc +LOCAL_MODULE_CLASS := EXECUTABLES +LOCAL_SRC_FILES := svc +LOCAL_REQUIRED_MODULES := svclib +include $(BUILD_PREBUILT) diff --git a/cmds/svc/src/com/android/commands/svc/UsbCommand.java b/cmds/svc/src/com/android/commands/svc/UsbCommand.java index a6ef25fc4479..4dcb05e4f85d 100644 --- a/cmds/svc/src/com/android/commands/svc/UsbCommand.java +++ b/cmds/svc/src/com/android/commands/svc/UsbCommand.java @@ -50,7 +50,7 @@ public class UsbCommand extends Svc.Command { IUsbManager usbMgr = IUsbManager.Stub.asInterface(ServiceManager.getService( Context.USB_SERVICE)); try { - usbMgr.setCurrentFunction((args.length >=3 ? args[2] : null)); + usbMgr.setCurrentFunction((args.length >=3 ? args[2] : null), false); } catch (RemoteException e) { System.err.println("Error communicating with UsbManager: " + e); } diff --git a/cmds/uiautomator/library/Android.mk b/cmds/uiautomator/library/Android.mk index ea77fbc69662..af2e25a99ad5 100644 --- a/cmds/uiautomator/library/Android.mk +++ b/cmds/uiautomator/library/Android.mk @@ -18,7 +18,7 @@ LOCAL_PATH:= $(call my-dir) uiautomator.core_src_files := $(call all-java-files-under, core-src) \ $(call all-java-files-under, testrunner-src) -uiautomator.core_java_libraries := android.test.runner core-junit +uiautomator.core_java_libraries := android.test.runner junit uiautomator_internal_api_file := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/uiautomator_api.txt uiautomator_internal_removed_api_file := \ @@ -116,11 +116,11 @@ $(eval $(call check-api, \ .PHONY: update-uiautomator-api update-uiautomator-api: PRIVATE_API_DIR := $(uiautomator_api_dir) update-uiautomator-api: PRIVATE_REMOVED_API_FILE := $(uiautomator_internal_removed_api_file) -update-uiautomator-api: $(uiautomator_internal_api_file) | $(ACP) +update-uiautomator-api: $(uiautomator_internal_api_file) @echo Copying uiautomator current.txt - $(hide) $(ACP) $< $(PRIVATE_API_DIR)/current.txt + $(hide) cp $< $(PRIVATE_API_DIR)/current.txt @echo Copying uiautomator removed.txt - $(hide) $(ACP) $(PRIVATE_REMOVED_API_FILE) $(PRIVATE_API_DIR)/removed.txt + $(hide) cp $(PRIVATE_REMOVED_API_FILE) $(PRIVATE_API_DIR)/removed.txt ############################################### # clean up temp vars uiautomator.core_src_files := diff --git a/cmds/webview_zygote/Android.mk b/cmds/webview_zygote/Android.mk new file mode 100644 index 000000000000..66e762c0558b --- /dev/null +++ b/cmds/webview_zygote/Android.mk @@ -0,0 +1,49 @@ +# +# Copyright (C) 2016 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_MODULE := webview_zygote + +LOCAL_SRC_FILES := webview_zygote.cpp + +LOCAL_SHARED_LIBRARIES := \ + libandroid_runtime \ + libbinder \ + liblog \ + libcutils \ + libutils + +LOCAL_LDFLAGS_32 := -Wl,--version-script,art/sigchainlib/version-script32.txt -Wl,--export-dynamic +LOCAL_LDFLAGS_64 := -Wl,--version-script,art/sigchainlib/version-script64.txt -Wl,--export-dynamic + +LOCAL_WHOLE_STATIC_LIBRARIES := libsigchain + +LOCAL_INIT_RC := webview_zygote32.rc + +# Always include the 32-bit version of webview_zygote. If the target is 64-bit, +# also include the 64-bit webview_zygote. +ifeq ($(TARGET_SUPPORTS_64_BIT_APPS),true) + LOCAL_INIT_RC += webview_zygote64.rc +endif + +LOCAL_MULTILIB := both + +LOCAL_MODULE_STEM_32 := webview_zygote32 +LOCAL_MODULE_STEM_64 := webview_zygote64 + +include $(BUILD_EXECUTABLE) diff --git a/cmds/webview_zygote/webview_zygote.cpp b/cmds/webview_zygote/webview_zygote.cpp new file mode 100644 index 000000000000..88fee645b3ee --- /dev/null +++ b/cmds/webview_zygote/webview_zygote.cpp @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2016 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 "WebViewZygote" + +#include <sys/prctl.h> + +#include <android_runtime/AndroidRuntime.h> +#include <binder/IPCThreadState.h> +#include <binder/ProcessState.h> +#include <utils/Log.h> +#include <utils/String8.h> +#include <utils/Vector.h> + +namespace android { + +class WebViewRuntime : public AndroidRuntime { +public: + WebViewRuntime(char* argBlockStart, size_t argBlockSize) + : AndroidRuntime(argBlockStart, argBlockSize) {} + + ~WebViewRuntime() override {} + + void onStarted() override { + // Nothing to do since this is a zygote server. + } + + void onVmCreated(JNIEnv*) override { + // Nothing to do when the VM is created in the zygote. + } + + void onZygoteInit() override { + // Called after a new process is forked. + sp<ProcessState> proc = ProcessState::self(); + proc->startThreadPool(); + } + + void onExit(int code) override { + IPCThreadState::self()->stopProcess(); + AndroidRuntime::onExit(code); + } +}; + +} // namespace android + +int main(int argc, char* const argv[]) { + if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0) < 0) { + LOG_ALWAYS_FATAL("PR_SET_NO_NEW_PRIVS failed: %s", strerror(errno)); + return 12; + } + + size_t argBlockSize = 0; + for (int i = 0; i < argc; ++i) { + argBlockSize += strlen(argv[i]) + 1; + } + + android::WebViewRuntime runtime(argv[0], argBlockSize); + runtime.addOption("-Xzygote"); + + android::Vector<android::String8> args; + runtime.start("com.android.internal.os.WebViewZygoteInit", args, /*zygote=*/ true); +} diff --git a/cmds/webview_zygote/webview_zygote32.rc b/cmds/webview_zygote/webview_zygote32.rc new file mode 100644 index 000000000000..b7decc8eba3b --- /dev/null +++ b/cmds/webview_zygote/webview_zygote32.rc @@ -0,0 +1,22 @@ +# +# Copyright (C) 2016 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. +# + +service webview_zygote32 /system/bin/webview_zygote32 + user webview_zygote + socket webview_zygote stream 660 webview_zygote system + +on property:init.svc.zygote=stopped + stop webview_zygote32 diff --git a/cmds/webview_zygote/webview_zygote64.rc b/cmds/webview_zygote/webview_zygote64.rc new file mode 100644 index 000000000000..2935b28cff55 --- /dev/null +++ b/cmds/webview_zygote/webview_zygote64.rc @@ -0,0 +1,22 @@ +# +# Copyright (C) 2016 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. +# + +service webview_zygote64 /system/bin/webview_zygote64 + user webview_zygote + socket webview_zygote stream 660 webview_zygote system + +on property:init.svc.zygote=stopped + stop webview_zygote64 |