Index: base/test/android/java/src/org/chromium/base/MultiprocessTestClientLauncher.java |
diff --git a/base/test/android/java/src/org/chromium/base/MultiprocessTestClientLauncher.java b/base/test/android/java/src/org/chromium/base/MultiprocessTestClientLauncher.java |
index 71eadb2ce00779b878f1f05174877c8244d18521..9cdf524201799a9d0656f7535a052dba9b9f84c8 100644 |
--- a/base/test/android/java/src/org/chromium/base/MultiprocessTestClientLauncher.java |
+++ b/base/test/android/java/src/org/chromium/base/MultiprocessTestClientLauncher.java |
@@ -180,13 +180,12 @@ public final class MultiprocessTestClientLauncher { |
* Spawns and connects to a child process. |
* May not be called from the main thread. |
* |
- * @param context context used to obtain the application context. |
* @param commandLine the child process command line argv. |
* @return the PID of the started process or 0 if the process could not be started. |
*/ |
@CalledByNative |
- private static int launchClient(final Context context, final String[] commandLine, |
- final FileDescriptorInfo[] filesToMap) { |
+ private static int launchClient( |
+ final String[] commandLine, final FileDescriptorInfo[] filesToMap) { |
if (ThreadUtils.runningOnUiThread()) { |
// This can't be called on the main thread as the native side will block until |
// onServiceConnected above is called, which cannot happen if the main thread is |
@@ -198,10 +197,11 @@ public final class MultiprocessTestClientLauncher { |
sConnectionAllocator.allocateConnection(commandLine, filesToMap); |
Intent intent = new Intent(); |
String className = connection.getServiceClassName(); |
- intent.setComponent(new ComponentName(context.getPackageName(), className)); |
- if (!context.bindService( |
+ String packageName = ContextUtils.getApplicationContext().getPackageName(); |
+ intent.setComponent(new ComponentName(packageName, className)); |
+ if (!ContextUtils.getApplicationContext().bindService( |
intent, connection, Context.BIND_AUTO_CREATE | Context.BIND_IMPORTANT)) { |
- Log.e(TAG, "Failed to bind service: " + context.getPackageName() + "." + className); |
+ Log.e(TAG, "Failed to bind service: " + packageName + "." + className); |
sConnectionAllocator.freeConnection(connection); |
return 0; |
} |
@@ -215,15 +215,13 @@ public final class MultiprocessTestClientLauncher { |
* Blocks until the main method invoked by a previous call to launchClient terminates or until |
* the specified time-out expires. |
* Returns immediately if main has already returned. |
- * @param context context used to obtain the application context. |
* @param pid the process ID that was returned by the call to launchClient |
* @param timeoutMs the timeout in milliseconds after which the method returns even if main has |
* not returned. |
* @return the return code returned by the main method or whether it timed-out. |
*/ |
@CalledByNative |
- private static MainReturnCodeResult waitForMainToReturn( |
- Context context, int pid, int timeoutMs) { |
+ private static MainReturnCodeResult waitForMainToReturn(int pid, int timeoutMs) { |
ClientServiceConnection connection = sConnectionAllocator.getConnectionByPid(pid); |
if (connection == null) { |
Log.e(TAG, "waitForMainToReturn called on unknown connection for pid " + pid); |
@@ -235,12 +233,12 @@ public final class MultiprocessTestClientLauncher { |
Log.e(TAG, "Remote call to waitForMainToReturn failed."); |
return null; |
} finally { |
- freeConnection(context, connection); |
+ freeConnection(connection); |
} |
} |
@CalledByNative |
- private static boolean terminate(Context context, int pid, int exitCode, boolean wait) { |
+ private static boolean terminate(int pid, int exitCode, boolean wait) { |
ClientServiceConnection connection = sConnectionAllocator.getConnectionByPid(pid); |
if (connection == null) { |
Log.e(TAG, "terminate called on unknown connection for pid " + pid); |
@@ -256,13 +254,13 @@ public final class MultiprocessTestClientLauncher { |
// We expect this failure, since the forceStop's service implementation calls |
// System.exit(). |
} finally { |
- freeConnection(context, connection); |
+ freeConnection(connection); |
} |
return true; |
} |
- private static void freeConnection(Context context, ClientServiceConnection connection) { |
- context.unbindService(connection); |
+ private static void freeConnection(ClientServiceConnection connection) { |
+ ContextUtils.getApplicationContext().unbindService(connection); |
sConnectionAllocator.freeConnection(connection); |
} |