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 @@
package org.chromium.content.app;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.Bundle;
import java.util.Locale;
......@@ -17,7 +16,7 @@ import javax.annotation.concurrent.Immutable;
* technical notes in Linker.java.
*/
@Immutable
public class ChromiumLinkerParams implements Parcelable {
public class ChromiumLinkerParams {
// Use this base address to load native shared libraries. If 0, ignore other members.
public final long mBaseLoadAddress;
......@@ -32,6 +31,18 @@ public class ChromiumLinkerParams implements Parcelable {
// to force for testing.
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) {
mBaseLoadAddress = baseLoadAddress;
mWaitForSharedRelro = waitForSharedRelro;
......@@ -52,39 +63,45 @@ public class ChromiumLinkerParams implements Parcelable {
mLinkerImplementationForTesting = linkerImplementation;
}
ChromiumLinkerParams(Parcel in) {
mBaseLoadAddress = in.readLong();
mWaitForSharedRelro = in.readInt() != 0;
mTestRunnerClassNameForTesting = in.readString();
mLinkerImplementationForTesting = in.readInt();
/**
* Use this method to recreate a LinkerParams instance from a Bundle.
*
* @param bundle A Bundle, its content must have been populated by a previous
* 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
public int describeContents() {
return 0;
private ChromiumLinkerParams(Bundle bundle) {
mBaseLoadAddress = bundle.getLong(EXTRA_LINKER_PARAMS_BASE_LOAD_ADDRESS, 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) {
dest.writeLong(mBaseLoadAddress);
dest.writeInt(mWaitForSharedRelro ? 1 : 0);
dest.writeString(mTestRunnerClassNameForTesting);
dest.writeInt(mLinkerImplementationForTesting);
/**
* Save data in this LinkerParams instance in a bundle, to be sent to a service process.
*
* @param bundle An bundle to be passed to the child service process.
*/
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.
@Override
public String toString() {
......
......@@ -64,8 +64,7 @@ public class ContentChildProcessServiceDelegate implements ChildProcessServiceDe
@Override
public void onServiceBound(Intent intent) {
mLinkerParams = (ChromiumLinkerParams) intent.getParcelableExtra(
ContentChildProcessConstants.EXTRA_LINKER_PARAMS);
mLinkerParams = ChromiumLinkerParams.create(intent.getExtras());
mLibraryProcessType = ChildProcessCreationParams.getLibraryProcessType(intent);
}
......
......@@ -515,8 +515,8 @@ public class ChildProcessLauncherHelper {
boolean bindToCallerCheck =
creationParams == null ? false : creationParams.getBindToCallerCheck();
bundle.putBoolean(ChildProcessConstants.EXTRA_BIND_TO_CALLER, bindToCallerCheck);
bundle.putParcelable(ContentChildProcessConstants.EXTRA_LINKER_PARAMS,
getLinkerParamsForNewConnection());
ChromiumLinkerParams linkerParams = getLinkerParamsForNewConnection();
if (linkerParams != null) linkerParams.populateBundle(bundle);
return bundle;
}
......
......@@ -12,10 +12,6 @@ public interface ContentChildProcessConstants {
// Note that because that intent maybe reused if a service is restarted, none should be process
// 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
// 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