Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1124)

Unified Diff: shell/android/apk/src/org/chromium/mojo/shell/MojoShellActivity.java

Issue 1280613003: Allow native_viewport to create new native windows on demand on Android. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: shell/android/apk/src/org/chromium/mojo/shell/MojoShellActivity.java
diff --git a/shell/android/apk/src/org/chromium/mojo/shell/MojoShellActivity.java b/shell/android/apk/src/org/chromium/mojo/shell/MojoShellActivity.java
index 1481b75eacc14a954c73c72eaeb2407d58d4db02..c5f5bf39dc9d169908afa1dc52cbd290a9bd91c8 100644
--- a/shell/android/apk/src/org/chromium/mojo/shell/MojoShellActivity.java
+++ b/shell/android/apk/src/org/chromium/mojo/shell/MojoShellActivity.java
@@ -5,19 +5,16 @@
package org.chromium.mojo.shell;
import android.app.Activity;
-import android.app.UiModeManager;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
-import android.content.res.Configuration;
import android.net.Uri;
import android.os.Bundle;
-import android.view.WindowManager;
import java.util.ArrayDeque;
/**
- * Activity for managing the Mojo Shell.
+ * Entry point for the Mojo Shell application.
*/
public class MojoShellActivity extends Activity implements ShellService.IShellBindingActivity {
private static final String TAG = "MojoShellActivity";
@@ -33,45 +30,11 @@ public class MojoShellActivity extends Activity implements ShellService.IShellBi
// Copy potential startup arguments.
serviceIntent.putExtras(getIntent());
startService(serviceIntent);
- bindShellService(serviceIntent);
- onNewIntent(getIntent());
+ mShellServiceConnection = new ShellService.ShellServiceConnection(this);
+ bindService(serviceIntent, mShellServiceConnection, Context.BIND_AUTO_CREATE);
- // TODO(tonyg): Watch activities go back to the home screen within a
- // couple of seconds of detaching from adb. So for demonstration purposes,
- // we just keep the screen on. Eventually we'll want a solution for
- // allowing the screen to sleep without quitting the shell.
- // TODO(etiennej): Verify the above is still true after the switch to a Service model.
- UiModeManager uiModeManager = (UiModeManager) getSystemService(UI_MODE_SERVICE);
- if (uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_WATCH) {
- getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
- }
- }
-
- private void bindShellService(Intent serviceIntent) {
- if (mShellServiceConnection == null) {
- mShellServiceConnection = new ShellService.ShellServiceConnection(this);
- bindService(serviceIntent, mShellServiceConnection, Context.BIND_AUTO_CREATE);
- }
- }
-
- private void unbindShellService() {
- if (mShellServiceConnection != null) {
- unbindService(mShellServiceConnection);
- mShellServiceConnection = null;
- }
- }
-
- @Override
- protected void onRestart() {
- super.onRestart();
- bindShellService(new Intent(this, ShellService.class));
- }
-
- @Override
- protected void onStop() {
- super.onStop();
- unbindShellService();
+ onNewIntent(getIntent());
}
@Override
@@ -79,21 +42,20 @@ public class MojoShellActivity extends Activity implements ShellService.IShellBi
super.onNewIntent(intent);
setIntent(intent);
mPendingIntents.add(intent);
-
- if (mShellService != null) {
- communicateWithShell();
- }
}
@Override
public void onShellBound(ShellService shellService) {
mShellService = shellService;
+ finish();
communicateWithShell();
+ unbindService(mShellServiceConnection);
}
@Override
public void onShellUnbound() {
mShellService = null;
+ mShellServiceConnection = null;
}
/**

Powered by Google App Engine
This is Rietveld 408576698