OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 package org.chromium.mojo.shell; |
| 6 |
| 7 import android.app.Activity; |
| 8 import android.app.UiModeManager; |
| 9 import android.content.Intent; |
| 10 import android.content.res.Configuration; |
| 11 import android.os.Bundle; |
| 12 import android.view.WindowManager; |
| 13 |
| 14 import org.chromium.mojo.PlatformViewportAndroid; |
| 15 |
| 16 /** |
| 17 * Activity for displaying on the screen from the NativeViewportService. |
| 18 */ |
| 19 public class ViewportActivity extends Activity { |
| 20 private static final String TAG = "ViewportActivity"; |
| 21 private PlatformViewportAndroid mPlatformViewport; |
| 22 |
| 23 @Override |
| 24 protected void onCreate(final Bundle savedInstanceState) { |
| 25 super.onCreate(savedInstanceState); |
| 26 |
| 27 if (!PlatformViewportAndroid.newActivityStarted(this)) { |
| 28 // We have not attached to a viewport, so there's no point continuin
g. |
| 29 finishAndRemoveTask(); |
| 30 } |
| 31 |
| 32 // TODO(tonyg): Watch activities go back to the home screen within a |
| 33 // couple of seconds of detaching from adb. So for demonstration purpose
s, |
| 34 // we just keep the screen on. Eventually we'll want a solution for |
| 35 // allowing the screen to sleep without quitting the shell. |
| 36 // TODO(etiennej): Verify the above is still true after the switch to a
Service model. |
| 37 UiModeManager uiModeManager = (UiModeManager) getSystemService(UI_MODE_S
ERVICE); |
| 38 if (uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_WAT
CH) { |
| 39 getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
; |
| 40 } |
| 41 } |
| 42 |
| 43 @Override |
| 44 public void onNewIntent(Intent intent) { |
| 45 super.onNewIntent(intent); |
| 46 new RuntimeException("This activity instance should only ever receive on
e intent."); |
| 47 } |
| 48 } |
OLD | NEW |