| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chromecast.shell; | 5 package org.chromium.chromecast.shell; |
| 6 | 6 |
| 7 import android.os.Build; | 7 import android.os.Build; |
| 8 import android.util.Log; | 8 import android.util.Log; |
| 9 | 9 |
| 10 import org.chromium.base.CommandLine; | 10 import org.chromium.base.CommandLine; |
| 11 import org.chromium.base.PathUtils; | 11 import org.chromium.base.PathUtils; |
| 12 import org.chromium.base.ResourceExtractor; | 12 import org.chromium.base.ResourceExtractor; |
| 13 import org.chromium.content.app.ContentApplication; | 13 import org.chromium.content.app.ContentApplication; |
| 14 | 14 |
| 15 /** | 15 /** |
| 16 * Entry point for the Android cast shell application. Handles initialization o
f information that | 16 * Entry point for the Android cast shell application. Handles initialization o
f information that |
| 17 * needs to be shared across the main activity and the child services created. | 17 * needs to be shared across the main activity and the child services created. |
| 18 * | 18 * |
| 19 * Note that this gets run for each process, including sandboxed child render pr
ocesses. Child | 19 * Note that this gets run for each process, including sandboxed child render pr
ocesses. Child |
| 20 * processes don't need most of the full "setup" performed in CastBrowserHelper.
java, but they do | 20 * processes don't need most of the full "setup" performed in CastBrowserHelper.
java, but they do |
| 21 * require a few basic pieces (found here). | 21 * require a few basic pieces (found here). |
| 22 */ | 22 */ |
| 23 public class CastApplication extends ContentApplication { | 23 public class CastApplication extends ContentApplication { |
| 24 private static final String TAG = "CastApplication"; | 24 private static final String TAG = "CastApplication"; |
| 25 | 25 |
| 26 private static final String[] MANDATORY_PAK_FILES = new String[] {"cast_shel
l.pak"}; | 26 private static final String[] MANDATORY_PAK_FILES = |
| 27 new String[] {"cast_shell.pak", "icudtl.dat"}; |
| 27 private static final String PRIVATE_DATA_DIRECTORY_SUFFIX = "cast_shell"; | 28 private static final String PRIVATE_DATA_DIRECTORY_SUFFIX = "cast_shell"; |
| 28 private static final String COMMAND_LINE_FILE = "/data/local/tmp/castshell-c
ommand-line"; | 29 private static final String COMMAND_LINE_FILE = "/data/local/tmp/castshell-c
ommand-line"; |
| 29 | 30 |
| 30 @Override | 31 @Override |
| 31 public void onCreate() { | 32 public void onCreate() { |
| 32 super.onCreate(); | 33 super.onCreate(); |
| 33 initializeApplicationParameters(); | 34 initializeApplicationParameters(); |
| 34 } | 35 } |
| 35 | 36 |
| 36 public static void initializeApplicationParameters() { | 37 public static void initializeApplicationParameters() { |
| 37 ResourceExtractor.setMandatoryPaksToExtract(MANDATORY_PAK_FILES); | 38 ResourceExtractor.setMandatoryPaksToExtract(MANDATORY_PAK_FILES); |
| 38 PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX); | 39 PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX); |
| 39 } | 40 } |
| 40 | 41 |
| 41 @Override | 42 @Override |
| 42 public void initCommandLine() { | 43 public void initCommandLine() { |
| 43 if (allowCommandLineImport()) { | 44 if (allowCommandLineImport()) { |
| 44 Log.d(TAG, "Initializing command line from " + COMMAND_LINE_FILE); | 45 Log.d(TAG, "Initializing command line from " + COMMAND_LINE_FILE); |
| 45 CommandLine.initFromFile(COMMAND_LINE_FILE); | 46 CommandLine.initFromFile(COMMAND_LINE_FILE); |
| 46 } else { | 47 } else { |
| 47 CommandLine.init(null); | 48 CommandLine.init(null); |
| 48 } | 49 } |
| 49 } | 50 } |
| 50 | 51 |
| 51 private static boolean allowCommandLineImport() { | 52 private static boolean allowCommandLineImport() { |
| 52 return !Build.TYPE.equals("user"); | 53 return !Build.TYPE.equals("user"); |
| 53 } | 54 } |
| 54 } | 55 } |
| OLD | NEW |