On the Ubuntu platform, we can use the history API to read the contents of the phone book and the text message, and use the ListView to display it. Let's show you how to do it.
1) Create a basic QML application we use QT Creator to create a basic QML application. We chose to use the app with simple UI template to create our app.
In order to use the history API, we must introduce
Import Ubuntu.history 0.1
To enable us to read different history, let's start with a Combobutton. It is designed as follows:
Combobutton {id:type expanded:false text: "Voice" ListView {Model:typemodel Delegate:ListItem.Standard { Text:modeldata onclicked: {console.log ("Item is clicked!" + Index + " "+ name"); type.expanded = false; Type.text = text; Console.log ("type is:" + type.text); if (name = = = "Voice") {historyeventmodel.type = Historythreadmodel.eventtypevoice; Listview.model = Historyeventmodel} else if (name = = = "Text") { Historyeventmodel.type = Historythreadmodel.eventtypetext; Listview.model = Historyeventmodel} else if (Name = = = "Thread") {Listview.model = Historythreadmodel} } } } }
Here we can refer to Combobutton to learn more about how to use this control. Here, we offer three options "
Voice", "
Textand
Thread"。 We also created two different history model.
Historyeventmodel { Id:historyeventmodel filter:historyfilter {} Type: Historythreadmodel.eventtypevoice sort:historysort { SortField: "Timestamp" SortOrder: Historysort.descendingorder } } sortproxymodel { id:sortproxy sortrole: Historyeventmodel.timestamprole sourcemodel:historyeventmodel ascending:false } Historythreadmodel { Id:historythreadmodel <pre name= "code" class= "JavaScript" ><span style= " White-space:pre "></span>filter:historyfilter {}
Sort:historysort {sortfield: "Lasteventtimestamp" SortOrder:HistorySort.DescendingOrder}}
For some performance reasons, we must now set the filter to NULL, namely:
Filter:historyfilter {}
We also connect the model defined above with our ListView:
ListView { id:listview width:parent.width height:parent.height-type.height Component { ID: Sectiondelegate Text { text:section } } model:historyeventmodel delegate: ... }
Everything seems to be all right at the moment. Next we'll run our app on the phone. We will find nothing in the phone that shows the history of anything. Where does the problem arise?
We open a terminal and then enter the following command:
$ADB Shell
Then enter the command line in the phone:
[Email protected]:~# grep "DENIED"/var/log/syslog
We can see the following images:
Obviously, we're having a security problem. In order to answer this question, we must add the required policy to the application.
We re-run the program again. On the phone, we can see the following screen:
We have no more security issues. The source code of the whole project can be downloaded at the following address:
BZR Branchlp:~liu-xiao-guo/debiantrial/history
How to read phone and SMS records on Ubuntu platform (history API)