Ubuntu OS应用Runtime Enviroment
在这篇文章中。我们将介绍Ubuntu OS的Runtime Environment。在文章“App confinement: Security policy for click packages”中,我们看见它里面有介绍一个应用的runtime环境。这里,我们通过一个样例来显示一个应用的runtime环境究竟是如何的。
在这里我们能够參阅我曾经的文章“在Ubuntu上的C++及QML混合编程”,我们下载文章中的例程:
bzr branch lp:~liu-xiao-guo/debiantrial/readenv
在一个Terminal中打入上述的句子,就能够下载例程中的软件。
同一时候,我们对我们的主程序文件“ReadEnv.qml”做例如以下的改动:
import QtQuick 2.0
import Ubuntu.Components 0.1
import Ubuntu.Components.ListItems 0.1 as ListItem
import ReadEnv 1.0
import "ui" /*!
\brief MainView with Tabs element.
First Tab has a single Label and
second Tab has a single ToolbarAction.
*/ MainView {
id: root // objectName for functional testing purposes (autopilot-qt5)
objectName: "mainView" // Note! applicationName needs to match the "name" field of the click manifest
applicationName: "com.ubuntu.developer.liu-xiao-guo.ReadEnv" anchorToKeyboard: true /*
This property enables the application to change orientation
when the device is rotated. The default is false.
*/
//automaticOrientation: true width: units.gu(50)
height: units.gu(75) property string app_pkgname ReadEnv {
id: readEnv
} Flickable {
id: scrollWidget
anchors.fill: parent
contentHeight: contentItem.childrenRect.height
boundsBehavior: (contentHeight > root.height) ? Flickable.DragAndOvershootBounds : Flickable.StopAtBounds
/* Set the direction to workaround https://bugreports.qt-project.org/browse/QTBUG-31905
otherwise the UI might end up in a situation where scrolling doesn't work */
flickableDirection: Flickable.VerticalFlick Column {
anchors.left: parent.left
anchors.right: parent.right ListItem.Base {
height: ubuntuLabel.height + runtime.height + units.gu(6) Column {
anchors.left: parent.left
anchors.right: parent.right
anchors.centerIn: parent
spacing: units.gu(2)
Label {
id: ubuntuLabel
anchors.horizontalCenter: parent.horizontalCenter
text: ""
fontSize: "x-large"
}
Label {
id: runtime
anchors.horizontalCenter: parent.horizontalCenter
text: "Runtime Environment"
}
}
} ListItem.Subtitled {
text: i18n.tr("UBUNTU_APPLICATION_ISOLATION")
subText: readEnv.getenv("UBUNTU_APPLICATION_ISOLATION")
} ListItem.Subtitled {
text: i18n.tr("APP_ID")
subText: readEnv.getenv("APP_ID")
} ListItem.Subtitled {
text: i18n.tr("XDG_CACHE_HOME")
subText: readEnv.getenv("XDG_CACHE_HOME")
} ListItem.Subtitled {
text: i18n.tr("XDG_CONFIG_HOME")
subText: readEnv.getenv("XDG_CONFIG_HOME")
} ListItem.Subtitled {
text: i18n.tr("XDG_DATA_HOME")
subText: readEnv.getenv("XDG_DATA_HOME")
} ListItem.Subtitled {
text: i18n.tr("XDG_RUNTIME_DIR")
subText: readEnv.getenv("XDG_RUNTIME_DIR")
} ListItem.Subtitled {
text: i18n.tr("TMPDIR")
subText: readEnv.getenv("TMPDIR")
} ListItem.Subtitled {
text: i18n.tr("PWD")
subText: readEnv.getenv("PWD")
} ListItem.Subtitled {
text: i18n.tr("APP_PKGNAME")
subText: app_pkgname
} ListItem.Subtitled {
text: i18n.tr("PATH")
subText: readEnv.getenv("PATH")
} ListItem.Subtitled {
text: i18n.tr("LD_LIBRARY_PATH")
subText: readEnv.getenv("LD_LIBRARY_PATH")
} ListItem.Subtitled {
text: i18n.tr("QML2_IMPORT_PATH")
subText: readEnv.getenv("QML2_IMPORT_PATH")
}
}
} Component.onCompleted: {
var APP_ID = readEnv.getenv("APP_ID"); console.log("APP_ID: " + APP_ID );
app_pkgname = APP_ID.split('_')[0]
console.log("APP_PKGNAME: " + app_pkgname);
}
}
我们能够通过我们设计的ReadEnv库来读取该应用的环境变量。
执行我们的程序。显演示样例如以下:
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvVWJ1bnR1VG91Y2g=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" width="200" height="300" alt="">
在文章中,它提到例如以下的文件夹,该应具有读和写的权限:
- XDG_CACHE_HOME/<APP_PKGNAME>
- XDG_CONFIG_HOME/<APP_PKGNAME>
- XDG_DATA_HOME/<APP_PKGNAME>
- XDG_RUNTIME_DIR/<APP_PKGNAME>
- XDG_RUNTIME_DIR/confined/<APP_PKGNAME> (for TMPDIR)
针对我们的应用来说。也即例如以下的文件夹具有读写的权限:
- /home/phablet/.cache/com.ubuntu.developer.liu-xiao-guo.readenv
- /home/phablet/.config/com.ubuntu.developer.liu-xiao-guo.readenv
- /home/phablet/.local/share/com.ubuntu.developer.liu-xiao-guo.readenv
- /run/user/32011/confined/com.ubuntu.developer.liu-xiao-guo.readenv
Ubuntu OS应用Runtime Enviroment的更多相关文章
- Windows 7 bug: nonexistent Java Runtime Enviroment
When I tried installing atunes and TED, I got the message “The registry refers to a nonexistent Java ...
- compile openjdk7 in ubuntu OS
success: openjdk version "1.7.0-internal"OpenJDK Runtime Environment (build 1.7.0-internal ...
- Packages on Ubuntu OS
openSSH https://help.ubuntu.com/lts/serverguide/openssh-server.html
- 多个 git ssh key 配置 Ubuntu os
1.生成ssh key: ssh-keygen -t rsa -C “email@sss.com” 此时,在~/.ssh/文件夹下会有两个文件, id_rsa 和 id_rsa.pub.分别保存ssh ...
- eduroam WIFI on Ubuntu OS
- extract a page from a multiple pages pdf on Ubuntu OS
extract a page from a multiple pages pdf 1 extract a page from a multiple pages pdf use pdftk packag ...
- Ubuntu OS 打开端口命令
直接执行命令:ufw allow 80 再去修改对应功能配置文件的端口号
- 怎样在Ubuntu手机应用中得到全部的环境变量值
我们在先前的例程中已经通过一些方法得到我们应用的一些环境变量值.这些值有的很实用.比方我们能够得到我们应用所仅仅能訪问的文件夹.在今天的例程中,我们来展示一种方法能够得到应用全部的环境变量.在我们的实 ...
- VMWare 虚拟化 Ubuntu 64 (16.04)-- docker 无法链接 pull 镜像 ?(solved)
背景 根据项目的需要,虚拟化一个Ubuntu OS 来玩 docker,虚拟机选择的是WMWare (VMware-player-14.0.0-6661328); Ubuntu的镜像来自于官网(ubu ...
随机推荐
- 数据分析python应用到的ggplot
数据分析中应用到python中的ggplot库,可以用来画图 数据之类的用优达学院中课程七中的数据为例 数据是:https://s3.amazonaws.com/content.udacity-dat ...
- Linux 基础——常用的Linux网络命令
一.学Linux网络命令有什么好处 网络的出现,我们的生活更方便了,处理事情的效率也越来越高,也可以看到全世界文化的差异.同时我们接受新事物的信息越来越来强,新事物的信息也越来越来多.网络对于我们尔等 ...
- Spring MVC数据绑定(一)
1.数据绑定介绍 在执行程序时,Spring MVC会根据客户端请求参数的不同,将请求消息中的信息以一定的方式转换并绑定到控制器类的方法参数中.这种将请求消息数据与后台方法参数建立连接的过程就是Spr ...
- 向SD卡写入树莓派的操作系统
这是 meelo 原创的 玩转树莓派 系列文章 用到的工具: Win32 Disk Imager: sd卡读卡器 Raspbian操作系统镜像:下载地址 步骤1:下载操作系统的镜像 树莓派基金会的网 ...
- 借助Visual Studio Code提高基于ActionScript的LayaAir HTML5游戏的调试效率
借助Visual Studio Code提高基于ActionScript的LayaAir HTML5游戏的调试效率 使用Visual Studio Code(VS Code)调试的优势 借助VS Co ...
- (转)Where与Having的总结
Where 是一个约束声明,使用Where来约束来之数据库的数据,Where是在结果返回之前起作用的,且Where中不能使用聚合函数. Having 是一个过滤声明,是在查询返回结果集以后对查询结果进 ...
- python并发编程-线程池
from concurrent.futures import ThreadPoolExecutor import time def func(n): time.sleep(2) print(n) re ...
- 简述HttpSession的作用、使用方法,可用代码说明
HttpSession中可以跟踪并储存用户信息,把值设置到属性中,有2个方法:setAttribute(),getAttrribute(): 例如:在一个方法中用session.setAttribut ...
- django添加REST_FRAMEWORK 接口浏览
1.安装rest_framework pip install djangorestframework 2.配置rest_framework ## 将rest_framework加入项目app列表 I ...
- property staticmathod classmethod 反射
使用@property 在绑定属性时,如果我们直接把属性暴露出去,虽然写起来很简单,但是,没办法检查参数,导致可以把成绩随便改: s = Student() s.score = 9999 这显然不合逻 ...