Example #1
0
def install_apk(serial_number):
    """
    if GET -- display upload form
    if POST -- do upload of apk
    upload file to web server, xfer to rpc server, then install, and display success
    1. resolve rpc server that hosts this device
    2. sanitize filename
    3. save
    4. base64 file and send to adb rpc server
        a. rpc server names file randomly and returns this name
    5. send install cmd to rpc server with the random file name it chose

    TODO check if install returnd err and report msg into install_error.html
    """
    adb, rpc_ip_addr, rpc_port = util.get_jsonrpc_server_instance_device(serial_number)
    if util.is_valid_jsonrpc_instance(adb):
        #if POST (sending data from form) -- upload file to appropriate Container
        if request.method == 'POST':
            file = request.files['file']
            if file and util.allowed_file(file.filename):
                filename = secure_filename(util.get_filename_with_ts(file.filename))
                file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
                apk_name_on_container = adb.upload_apk(util.get_base64_from_binary_file(filename))
                #send install cmd
                #todo: come up with workaround that allows me to keep optional parameters in rpc
                adb.install(serial_number, apk_name_on_container, False, True, False, True, True)
                return render_template('install_success.html', filename=file.filename, serial_number=serial_number)
            else:
                return render_template('upload_error.html', filename=file.filename)
        #if GET -- just render the upload page
        return render_template('upload.html')
    else:
       return render_template('device_or_container_not_found.html', serial_number=serial_number)
Example #2
0
def display_app_detailed(serial_number, package_name):
    adb, rpc_ip_addr, rpc_port = util.get_jsonrpc_server_instance_device(serial_number)
    if util.is_valid_jsonrpc_instance(adb):
        package_detail_dict = adb.get_detailed_package_info(serial_number, package_name)
        return render_template('app_detailed.html', package_detail_dict=package_detail_dict, package_name=package_name, serial_number=serial_number)
    else:
        return render_template('device_or_container_not_found.html', serial_number=serial_number)
Example #3
0
def uninstall_apk(serial_number, package_name):
    """
    send name of package name you want to be uninstalled
    TODO check if uninstall returnd error and report msg into uninstalll_error.html
    """
    adb, rpc_ip_addr, rpc_port = util.get_jsonrpc_server_instance_device(serial_number)
    if util.is_valid_jsonrpc_instance(adb):
        adb.uninstall(serial_number, package_name)
        return render_template('uninstall_success.html', serial_number=serial_number, package_name=package_name)
    else:
        return render_template('device_or_container_not_found.html', serial_number=serial_number)
Example #4
0
def display_all_apps_detailed(serial_number):
    """
    as it stands, this is a lengthy and intense function
    """
    adb, rpc_ip_addr, rpc_port = util.get_jsonrpc_server_instance_device(serial_number)
    if util.is_valid_jsonrpc_instance(adb):
        #package_detail_list_dict = adb.get_all_detailed_package_info(serial_number)
        package_list = adb.get_list_installed_packages(serial_number)[0]
        #return render_template('all_app_detailed.html', package_detail_list_dict=package_detail_list_dict, serial_number=serial_number)
        return render_template('all_app_detailed.html', package_list=package_list, serial_number=serial_number)

    else:
        return render_template('device_or_container_not_found.html', serial_number=serial_number)
Example #5
0
def device_detail(serial_number):
    adb, rpc_ip_addr, rpc_port = util.get_jsonrpc_server_instance_device(serial_number)
    if util.is_valid_jsonrpc_instance(adb):
        details = {'container_ip':rpc_ip_addr,
                   'container_port':rpc_port,
                   'serial_number':serial_number,
                   'model':adb.get_model(serial_number)[0],
                   'wlan0_ip':adb.get_wlan0_ip(serial_number)[0],
                   'wlan0_mac':adb.get_interface_mac(serial_number, 'wlan0')[0],
                   'cpu_type':adb.get_cpu_type(serial_number)[0],
                   'locale_region':adb.get_locale_region(serial_number)[0],
                   'brand':adb.get_device_brand(serial_number)[0],
                   'os_version':adb.get_os_version(serial_number)[0],
                   'bluetooth_mac':adb.get_bluetooth_mac(serial_number)[0],
                   'installed_packages':adb.get_list_installed_packages(serial_number)[0]}
        return render_template('detail.html', **details)
    else:
        return render_template('device_or_container_not_found.html', serial_number=serial_number)