Commit 595ee0d0 authored by Michael van Ouwerkerk's avatar Michael van Ouwerkerk Committed by Commit Bot

Update dynamic module AIDL interfaces.

* Some reordering.
* Move view getters to host and make them setters.
* Add IModuleEntryPoint.onDestroy (not called yet)

This is a backwards incompatible change in the
AIDL but that's ok as we have not released yet.

Bug: 843161
Change-Id: I2a705f5b51c9c3ffdf36dec6746578f2dd3e42a0
Reviewed-on: https://chromium-review.googlesource.com/1112008Reviewed-by: default avatarChris Palmer <palmer@chromium.org>
Reviewed-by: default avatarBernhard Bauer <bauerb@chromium.org>
Commit-Queue: Michael van Ouwerkerk <mvanouwerkerk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#570718}
parent 16a17d68
......@@ -158,6 +158,7 @@ public class CustomTabActivity extends ChromeActivity {
private WebappCustomTabTimeSpentLogger mWebappTimeSpentLogger;
@Nullable private ActivityDelegate mActivityDelegate;
private boolean mHasSetOverlayView;
private static class PageLoadMetricsObserver implements PageLoadMetrics.Observer {
private final CustomTabsConnection mConnection;
......@@ -365,16 +366,22 @@ public class CustomTabActivity extends ChromeActivity {
mConnection.loadModule(packageName, mIntentDataProvider.getModuleClassName());
if (entryPoint == null) return;
mActivityDelegate = entryPoint.createActivityDelegate(new ActivityHostImpl(this));
mActivityDelegate = entryPoint.createActivityDelegate(
new ActivityHostImpl(this), getIntent().getExtras());
mActivityDelegate.onCreate(getSavedInstanceState());
if (mBottomBarDelegate != null) {
mBottomBarDelegate.setBottomBarContentView(mActivityDelegate.getBottomBarView());
mBottomBarDelegate.showBottomBarIfNecessary();
}
}
public void setBottomBarContentView(View view) {
mBottomBarDelegate.setBottomBarContentView(view);
mBottomBarDelegate.showBottomBarIfNecessary();
}
public void setOverlayView(View view) {
assert !mHasSetOverlayView;
mHasSetOverlayView = true;
ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
addContentView(mActivityDelegate.getOverlayView(), layoutParams);
addContentView(view, layoutParams);
}
@Override
......
......@@ -79,6 +79,14 @@ class CustomTabBottomBarDelegate implements FullscreenListener {
if (mBottomBarContentView != null) {
getBottomBarView().addView(mBottomBarContentView);
mBottomBarContentView.addOnLayoutChangeListener(new OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom,
int oldLeft, int oldTop, int oldRight, int oldBottom) {
mBottomBarContentView.removeOnLayoutChangeListener(this);
mFullscreenManager.setBottomControlsHeight(v.getHeight());
}
});
return;
}
......
......@@ -6,7 +6,6 @@ package org.chromium.chrome.browser.customtabs.dynamicmodule;
import android.os.Bundle;
import android.os.RemoteException;
import android.view.View;
/**
* A wrapper around a {@link IActivityDelegate}.
......@@ -108,22 +107,4 @@ public class ActivityDelegate {
}
return false;
}
public View getBottomBarView() {
try {
return ObjectWrapper.unwrap(mActivityDelegate.getBottomBarView(), View.class);
} catch (RemoteException e) {
assert false;
}
return null;
}
public View getOverlayView() {
try {
return ObjectWrapper.unwrap(mActivityDelegate.getOverlayView(), View.class);
} catch (RemoteException e) {
assert false;
}
return null;
}
}
......@@ -4,20 +4,32 @@
package org.chromium.chrome.browser.customtabs.dynamicmodule;
import android.content.Context;
import android.view.View;
import org.chromium.chrome.browser.customtabs.CustomTabActivity;
/**
* The implementation of {@link IActivityHost}.
*/
public class ActivityHostImpl extends IActivityHost.Stub {
private final Context mActivityContext;
private final CustomTabActivity mActivity;
public ActivityHostImpl(Context activityContext) {
mActivityContext = activityContext;
public ActivityHostImpl(CustomTabActivity activity) {
mActivity = activity;
}
@Override
public IObjectWrapper getActivityContext() {
return ObjectWrapper.wrap(mActivityContext);
return ObjectWrapper.wrap(mActivity);
}
@Override
public void setBottomBarView(IObjectWrapper bottomBarView) {
mActivity.setBottomBarContentView(ObjectWrapper.unwrap(bottomBarView, View.class));
}
@Override
public void setOverlayView(IObjectWrapper overlayView) {
mActivity.setOverlayView(ObjectWrapper.unwrap(overlayView, View.class));
}
}
......@@ -4,8 +4,6 @@
package org.chromium.chrome.browser.customtabs.dynamicmodule;
import org.chromium.chrome.browser.customtabs.dynamicmodule.IObjectWrapper;
interface IActivityDelegate {
void onCreate(in Bundle savedInstanceState) = 0;
......@@ -28,8 +26,4 @@ interface IActivityDelegate {
void onDestroy(boolean isChangingConfigurations) = 9;
boolean onBackPressed() = 10;
IObjectWrapper /* View */ getBottomBarView() = 11;
IObjectWrapper /* View */ getOverlayView() = 12;
}
......@@ -8,4 +8,8 @@ import org.chromium.chrome.browser.customtabs.dynamicmodule.IObjectWrapper;
interface IActivityHost {
IObjectWrapper /* Context */ getActivityContext() = 0;
void setBottomBarView(in IObjectWrapper /* View */ bottomBarView) = 1;
void setOverlayView(in IObjectWrapper /* View */ overlayView) = 2;
}
......@@ -10,7 +10,8 @@ import org.chromium.chrome.browser.customtabs.dynamicmodule.IModuleHost;
interface IModuleEntryPoint {
void init(in IModuleHost moduleHost) = 0;
IActivityDelegate createActivityDelegate(in IActivityHost activityHost) = 1;
int getVersion() = 2;
int getMinimumHostVersion() = 3;
int getModuleVersion() = 1;
int getMinimumHostVersion() = 2;
IActivityDelegate createActivityDelegate(in IActivityHost activityHost, in Bundle data) = 3;
void onDestroy() = 4;
}
......@@ -9,6 +9,6 @@ import org.chromium.chrome.browser.customtabs.dynamicmodule.IObjectWrapper;
interface IModuleHost {
IObjectWrapper /* Context */ getHostApplicationContext() = 0;
IObjectWrapper /* Context */ getModuleContext() = 1;
int getVersion() = 2;
int getHostVersion() = 2;
int getMinimumModuleVersion() = 3;
}
......@@ -4,6 +4,7 @@
package org.chromium.chrome.browser.customtabs.dynamicmodule;
import android.os.Bundle;
import android.os.RemoteException;
/**
......@@ -26,30 +27,38 @@ public class ModuleEntryPoint {
}
}
public ActivityDelegate createActivityDelegate(ActivityHostImpl activityHost) {
public int getModuleVersion() {
try {
return new ActivityDelegate(mEntryPoint.createActivityDelegate(activityHost));
return mEntryPoint.getModuleVersion();
} catch (RemoteException e) {
assert false;
}
return null;
return -1;
}
public int getVersion() {
public int getMinimumHostVersion() {
try {
return mEntryPoint.getVersion();
return mEntryPoint.getMinimumHostVersion();
} catch (RemoteException e) {
assert false;
}
return -1;
}
public int getMinimumHostVersion() {
public ActivityDelegate createActivityDelegate(ActivityHostImpl activityHost, Bundle data) {
try {
return mEntryPoint.getMinimumHostVersion();
return new ActivityDelegate(mEntryPoint.createActivityDelegate(activityHost, data));
} catch (RemoteException e) {
assert false;
}
return null;
}
public void onDestroy() {
try {
mEntryPoint.onDestroy();
} catch (RemoteException e) {
assert false;
}
return -1;
}
}
......@@ -32,7 +32,7 @@ public class ModuleHostImpl extends IModuleHost.Stub {
}
@Override
public int getVersion() {
public int getHostVersion() {
return VERSION;
}
......
......@@ -46,10 +46,10 @@ public final class ModuleLoader {
if (!isCompatible(moduleHost, entryPoint)) {
Log.w(TAG, "Incompatible module due to version mismatch: host version %s, "
+ "minimum required host version %s, entry point version %s, minimum "
+ "required entry point version %s.",
moduleHost.getVersion(), entryPoint.getMinimumHostVersion(),
entryPoint.getVersion(), moduleHost.getMinimumModuleVersion());
+ "minimum required host version %s, entry point version %s, "
+ "minimum required entry point version %s.",
moduleHost.getHostVersion(), entryPoint.getMinimumHostVersion(),
entryPoint.getModuleVersion(), moduleHost.getMinimumModuleVersion());
return null;
}
......@@ -77,7 +77,7 @@ public final class ModuleLoader {
}
private static boolean isCompatible(ModuleHostImpl moduleHost, ModuleEntryPoint entryPoint) {
return entryPoint.getVersion() >= moduleHost.getMinimumModuleVersion()
&& moduleHost.getVersion() >= entryPoint.getMinimumHostVersion();
return entryPoint.getModuleVersion() >= moduleHost.getMinimumModuleVersion()
&& moduleHost.getHostVersion() >= entryPoint.getMinimumHostVersion();
}
}
}
\ No newline at end of file
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