Commit 5dc28900 authored by Bo Liu's avatar Bo Liu Committed by Commit Bot

android: LinkerParams no longer Parceable

This is partial revert of r457679. Some old thirdparty android devices
do not deal well with bindService intent with a Parceable. So make
LinkerParams explicitly set fields in a Bundle rather than pass it as a
Parceable.

BUG=740653

Change-Id: I0ad409a20c638ec4ff91c4331a189aee381edf7b
Reviewed-on: https://chromium-review.googlesource.com/565165Reviewed-by: default avatarJay Civelli <jcivelli@chromium.org>
Commit-Queue: Bo Liu <boliu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#485448}
parent 6bdb9f48
...@@ -4,8 +4,7 @@ ...@@ -4,8 +4,7 @@
package org.chromium.content.app; package org.chromium.content.app;
import android.os.Parcel; import android.os.Bundle;
import android.os.Parcelable;
import java.util.Locale; import java.util.Locale;
...@@ -17,7 +16,7 @@ import javax.annotation.concurrent.Immutable; ...@@ -17,7 +16,7 @@ import javax.annotation.concurrent.Immutable;
* technical notes in Linker.java. * technical notes in Linker.java.
*/ */
@Immutable @Immutable
public class ChromiumLinkerParams implements Parcelable { public class ChromiumLinkerParams {
// Use this base address to load native shared libraries. If 0, ignore other members. // Use this base address to load native shared libraries. If 0, ignore other members.
public final long mBaseLoadAddress; public final long mBaseLoadAddress;
...@@ -32,6 +31,18 @@ public class ChromiumLinkerParams implements Parcelable { ...@@ -32,6 +31,18 @@ public class ChromiumLinkerParams implements Parcelable {
// to force for testing. // to force for testing.
public final int mLinkerImplementationForTesting; public final int mLinkerImplementationForTesting;
private static final String EXTRA_LINKER_PARAMS_BASE_LOAD_ADDRESS =
"org.chromium.content.common.linker_params.base_load_address";
private static final String EXTRA_LINKER_PARAMS_WAIT_FOR_SHARED_RELRO =
"org.chromium.content.common.linker_params.wait_for_shared_relro";
private static final String EXTRA_LINKER_PARAMS_TEST_RUNNER_CLASS_NAME =
"org.chromium.content.common.linker_params.test_runner_class_name";
private static final String EXTRA_LINKER_PARAMS_LINKER_IMPLEMENTATION =
"org.chromium.content.common.linker_params.linker_implementation";
public ChromiumLinkerParams(long baseLoadAddress, boolean waitForSharedRelro) { public ChromiumLinkerParams(long baseLoadAddress, boolean waitForSharedRelro) {
mBaseLoadAddress = baseLoadAddress; mBaseLoadAddress = baseLoadAddress;
mWaitForSharedRelro = waitForSharedRelro; mWaitForSharedRelro = waitForSharedRelro;
...@@ -52,39 +63,45 @@ public class ChromiumLinkerParams implements Parcelable { ...@@ -52,39 +63,45 @@ public class ChromiumLinkerParams implements Parcelable {
mLinkerImplementationForTesting = linkerImplementation; mLinkerImplementationForTesting = linkerImplementation;
} }
ChromiumLinkerParams(Parcel in) { /**
mBaseLoadAddress = in.readLong(); * Use this method to recreate a LinkerParams instance from a Bundle.
mWaitForSharedRelro = in.readInt() != 0; *
mTestRunnerClassNameForTesting = in.readString(); * @param bundle A Bundle, its content must have been populated by a previous
mLinkerImplementationForTesting = in.readInt(); * call to populateBundle().
* @return params instance or possibly null if params was not put into bundle.
*/
public static ChromiumLinkerParams create(Bundle bundle) {
if (!bundle.containsKey(EXTRA_LINKER_PARAMS_BASE_LOAD_ADDRESS)
|| !bundle.containsKey(EXTRA_LINKER_PARAMS_WAIT_FOR_SHARED_RELRO)
|| !bundle.containsKey(EXTRA_LINKER_PARAMS_TEST_RUNNER_CLASS_NAME)
|| !bundle.containsKey(EXTRA_LINKER_PARAMS_LINKER_IMPLEMENTATION)) {
return null;
}
return new ChromiumLinkerParams(bundle);
} }
@Override private ChromiumLinkerParams(Bundle bundle) {
public int describeContents() { mBaseLoadAddress = bundle.getLong(EXTRA_LINKER_PARAMS_BASE_LOAD_ADDRESS, 0);
return 0; mWaitForSharedRelro = bundle.getBoolean(EXTRA_LINKER_PARAMS_WAIT_FOR_SHARED_RELRO, false);
mTestRunnerClassNameForTesting =
bundle.getString(EXTRA_LINKER_PARAMS_TEST_RUNNER_CLASS_NAME);
mLinkerImplementationForTesting =
bundle.getInt(EXTRA_LINKER_PARAMS_LINKER_IMPLEMENTATION, 0);
} }
@Override /**
public void writeToParcel(Parcel dest, int flags) { * Save data in this LinkerParams instance in a bundle, to be sent to a service process.
dest.writeLong(mBaseLoadAddress); *
dest.writeInt(mWaitForSharedRelro ? 1 : 0); * @param bundle An bundle to be passed to the child service process.
dest.writeString(mTestRunnerClassNameForTesting); */
dest.writeInt(mLinkerImplementationForTesting); public void populateBundle(Bundle bundle) {
bundle.putLong(EXTRA_LINKER_PARAMS_BASE_LOAD_ADDRESS, mBaseLoadAddress);
bundle.putBoolean(EXTRA_LINKER_PARAMS_WAIT_FOR_SHARED_RELRO, mWaitForSharedRelro);
bundle.putString(
EXTRA_LINKER_PARAMS_TEST_RUNNER_CLASS_NAME, mTestRunnerClassNameForTesting);
bundle.putInt(EXTRA_LINKER_PARAMS_LINKER_IMPLEMENTATION, mLinkerImplementationForTesting);
} }
public static final Parcelable.Creator<ChromiumLinkerParams> CREATOR =
new Parcelable.Creator<ChromiumLinkerParams>() {
@Override
public ChromiumLinkerParams createFromParcel(Parcel in) {
return new ChromiumLinkerParams(in);
}
@Override
public ChromiumLinkerParams[] newArray(int size) {
return new ChromiumLinkerParams[size];
}
};
// For debugging traces only. // For debugging traces only.
@Override @Override
public String toString() { public String toString() {
......
...@@ -64,8 +64,7 @@ public class ContentChildProcessServiceDelegate implements ChildProcessServiceDe ...@@ -64,8 +64,7 @@ public class ContentChildProcessServiceDelegate implements ChildProcessServiceDe
@Override @Override
public void onServiceBound(Intent intent) { public void onServiceBound(Intent intent) {
mLinkerParams = (ChromiumLinkerParams) intent.getParcelableExtra( mLinkerParams = ChromiumLinkerParams.create(intent.getExtras());
ContentChildProcessConstants.EXTRA_LINKER_PARAMS);
mLibraryProcessType = ChildProcessCreationParams.getLibraryProcessType(intent); mLibraryProcessType = ChildProcessCreationParams.getLibraryProcessType(intent);
} }
......
...@@ -515,8 +515,8 @@ public class ChildProcessLauncherHelper { ...@@ -515,8 +515,8 @@ public class ChildProcessLauncherHelper {
boolean bindToCallerCheck = boolean bindToCallerCheck =
creationParams == null ? false : creationParams.getBindToCallerCheck(); creationParams == null ? false : creationParams.getBindToCallerCheck();
bundle.putBoolean(ChildProcessConstants.EXTRA_BIND_TO_CALLER, bindToCallerCheck); bundle.putBoolean(ChildProcessConstants.EXTRA_BIND_TO_CALLER, bindToCallerCheck);
bundle.putParcelable(ContentChildProcessConstants.EXTRA_LINKER_PARAMS, ChromiumLinkerParams linkerParams = getLinkerParamsForNewConnection();
getLinkerParamsForNewConnection()); if (linkerParams != null) linkerParams.populateBundle(bundle);
return bundle; return bundle;
} }
......
...@@ -12,10 +12,6 @@ public interface ContentChildProcessConstants { ...@@ -12,10 +12,6 @@ public interface ContentChildProcessConstants {
// Note that because that intent maybe reused if a service is restarted, none should be process // Note that because that intent maybe reused if a service is restarted, none should be process
// specific. // specific.
// Key in the binding Intent's Bundle for the ChromiumLinkerParams.
public static final String EXTRA_LINKER_PARAMS =
"com.google.android.apps.chrome.extra.linker_params";
// Below are the names for the items placed in the Bundle passed in the // Below are the names for the items placed in the Bundle passed in the
// IChildProcessService.setupConnection call, once the connection has been established. // IChildProcessService.setupConnection call, once the connection has been established.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment