Exemplo n.º 1
0
def main(argv):
    """Respond to command mode of the mapping permission list."""
    parser = optparse.OptionParser()
    info = ('The input json-format file name. Such as: '
            '--jsonfile=manifest.json')
    parser.add_option('-j',
                      '--jsonfile',
                      action='store',
                      dest='jsonfile',
                      help=info)
    info = ('The destination android manifest file name. Such as: '
            '--manifest=AndroidManifest.xml')
    parser.add_option('-m',
                      '--manifest',
                      action='store',
                      dest='manifest',
                      help=info)
    options, _ = parser.parse_args()
    if len(argv) == 1:
        parser.print_help()
        return 0
    if not options.jsonfile:
        print 'Please set the manifest.json file.'
        return 1
    if not options.manifest:
        print 'Please set the AndroidManifest.xml file.'
        return 1
    try:
        json_parser = ManifestJsonParser(os.path.expanduser(options.jsonfile))
        if json_parser.GetPermissions():
            options.permissions = json_parser.GetPermissions()
    except SystemExit, ec:
        print 'Exiting with error code: %d' % ec.code
        return ec.code
def main(argv):
    """Respond to command mode of the mapping permission list."""
    parser = optparse.OptionParser()
    info = ('The input json-format file name. Such as: '
            '--jsonfile=manifest.json')
    parser.add_option('-j',
                      '--jsonfile',
                      action='store',
                      dest='jsonfile',
                      help=info)
    info = ('The destination android manifest file name. Such as: '
            '--manifest=AndroidManifest.xml')
    parser.add_option('-m',
                      '--manifest',
                      action='store',
                      dest='manifest',
                      help=info)
    options, _ = parser.parse_args()
    if len(argv) == 1:
        parser.print_help()
        return 0
    if not options.jsonfile:
        print('Please set the manifest.json file.')
        return 1
    if not options.manifest:
        print('Please set the AndroidManifest.xml file.')
        return 1
    try:
        json_parser = ManifestJsonParser(os.path.expanduser(options.jsonfile))
        if json_parser.GetPermissions():
            options.permissions = json_parser.GetPermissions()
    except SystemExit as ec:
        print('Exiting with error code: %d' % ec.code)
        return ec.code
    try:
        xmldoc = minidom.parse(options.manifest)
        HandlePermissions(options.permissions, xmldoc)
        file_handle = open(options.manifest, 'wb')
        xmldoc.writexml(file_handle)
        file_handle.close()
    except (ExpatError, IOError):
        print('There is an error in AndroidManifest.xml.')
        return 1
    return 0
Exemplo n.º 3
0
def CustomizeLaunchScreen(app_manifest, sanitized_name):
    if not app_manifest:
        return False
    parser = ManifestJsonParser(os.path.expanduser(app_manifest))
    app_root = os.path.dirname(app_manifest)
    default = CustomizeByOrientation(parser, 'default', sanitized_name,
                                     app_root)
    portrait = CustomizeByOrientation(parser, 'portrait', sanitized_name,
                                      app_root)
    landscape = CustomizeByOrientation(parser, 'landscape', sanitized_name,
                                       app_root)
    return default or portrait or landscape
Exemplo n.º 4
0
def ParseManifest(options):
  parser = ManifestJsonParser(os.path.expanduser(options.manifest))
  if not options.package:
    options.package = 'org.xwalk.' + parser.GetAppName().lower()
  if not options.name:
    options.name = parser.GetAppName()
  if not options.app_version:
    options.app_version = parser.GetVersion()
  if not options.app_versionCode and not options.app_versionCodeBase:
    options.app_versionCode = 1
  if parser.GetDescription():
    options.description = parser.GetDescription()
  if parser.GetPermissions():
    options.permissions = parser.GetPermissions()
  if parser.GetAppUrl():
    options.app_url = parser.GetAppUrl()
  elif parser.GetAppLocalPath():
    options.app_local_path = parser.GetAppLocalPath()
  else:
    print('Error: there is no app launch path defined in manifest.json.')
    sys.exit(9)
  if parser.GetAppRoot():
    options.app_root = parser.GetAppRoot()
    temp_dict = parser.GetIcons()
    try:
      icon_dict = dict((int(k), v) for k, v in temp_dict.items())
    except ValueError:
      print('The key of icon in the manifest file should be a number.')
    # TODO(junmin): add multiple icons support.
    if icon_dict:
      icon_file = max(iter(icon_dict.items()), key=operator.itemgetter(0))[1]
      options.icon = os.path.join(options.app_root, icon_file)
  if parser.GetFullScreenFlag().lower() == 'true':
    options.fullscreen = True
  elif parser.GetFullScreenFlag().lower() == 'false':
    options.fullscreen = False
  if parser.GetLaunchScreenImg():
    options.launch_screen_img  = os.path.join(options.app_root,
                                              parser.GetLaunchScreenImg())
Exemplo n.º 5
0
def ParseManifest(options):
    parser = ManifestJsonParser(os.path.expanduser(options.manifest))
    if not options.name:
        options.name = parser.GetAppName()
    if not options.app_version:
        options.app_version = parser.GetVersion()
    if parser.GetDescription():
        options.description = parser.GetDescription()
    if parser.GetPermissions():
        options.permissions = parser.GetPermissions()
    if parser.GetAppUrl():
        options.app_url = parser.GetAppUrl()
    elif parser.GetAppLocalPath():
        options.app_local_path = parser.GetAppLocalPath()
    else:
        print('Error: there is no app launch path defined in manifest.json.')
        sys.exit(9)
    options.icon_dict = {}
    if parser.GetAppRoot():
        options.app_root = parser.GetAppRoot()
        options.icon_dict = parser.GetIcons()
    if parser.GetOrientation():
        options.orientation = parser.GetOrientation()
    if parser.GetFullScreenFlag().lower() == 'true':
        options.fullscreen = True
    elif parser.GetFullScreenFlag().lower() == 'false':
        options.fullscreen = False
    return parser
Exemplo n.º 6
0
def ParseManifest(options):
    parser = ManifestJsonParser(os.path.expanduser(options.manifest))
    if not options.package:
        options.package = 'org.xwalk.' + parser.GetAppName().lower()
    if not options.name:
        options.name = parser.GetAppName()
    if not options.app_version:
        options.app_version = parser.GetVersion()
    if parser.GetDescription():
        options.description = parser.GetDescription()
    if parser.GetPermissions():
        options.permissions = parser.GetPermissions()
    if parser.GetAppUrl():
        options.app_url = parser.GetAppUrl()
    if parser.GetAppRoot():
        options.app_root = parser.GetAppRoot()
        temp_dict = parser.GetIcons()
        try:
            icon_dict = dict((int(k), v) for k, v in temp_dict.iteritems())
        except ValueError:
            print 'The key of icon in the manifest file should be a number.'
        # TODO(junmin): add multiple icons support.
        if icon_dict:
            icon_file = max(icon_dict.iteritems(),
                            key=operator.itemgetter(0))[1]
            options.icon = os.path.join(options.app_root, icon_file)
    if parser.GetAppLocalPath():
        options.app_local_path = parser.GetAppLocalPath()
    options.enable_remote_debugging = False
    if parser.GetFullScreenFlag().lower() == 'true':
        options.fullscreen = True
    elif parser.GetFullScreenFlag().lower() == 'false':
        options.fullscreen = False
Exemplo n.º 7
0
def ParseManifest(options):
  parser = ManifestJsonParser(os.path.expanduser(options.manifest))
  app_name = parser.GetAppName()
  if options.package:
    VerifyAppName(options.package, 'packagename')
  else:
    VerifyAppName(app_name)
    options.package = 'org.xwalk.' + app_name.lower()
  if options.name:
    VerifyAppName(options.name)
  else:
    VerifyAppName(app_name)
    options.name = app_name
  if not options.app_version:
    options.app_version = parser.GetVersion()
  if not options.app_versionCode and not options.app_versionCodeBase:
    options.app_versionCode = 1
  if parser.GetDescription():
    options.description = parser.GetDescription()
  if parser.GetPermissions():
    options.permissions = parser.GetPermissions()
  if parser.GetAppUrl():
    options.app_url = parser.GetAppUrl()
  elif parser.GetAppLocalPath():
    options.app_local_path = parser.GetAppLocalPath()
  else:
    print('Error: there is no app launch path defined in manifest.json.')
    sys.exit(9)
  if parser.GetAppRoot():
    options.app_root = parser.GetAppRoot()
    options.icon_dict = parser.GetIcons()
  if parser.GetFullScreenFlag().lower() == 'true':
    options.fullscreen = True
  elif parser.GetFullScreenFlag().lower() == 'false':
    options.fullscreen = False