ACCESS Linux Platform—whether in the Simulator or on a real device—contains a basic Linux shell that can be accessed from a terminal window. When working with Scratchbox, simply enter commands into the Terminal window you used to launch Scratchbox from (be sure to log in as "root" first). If you have a real ACCESS Linux Platform device that is connected (typically via USB) to your desktop computer, you can telnet to that device (the IP address is often 192.168.2.101) and enter commands through the telnet session.
Application Launching and Debugging
The alp_app command-line tool can be used to launch and/or command-line debug your ACCESS Linux Platform applications. It can also be used to manipulate the application and various parts of the system. Typing alp_app on the command line with no options will display basic help text.
When using alp_app, if the supplied application name does not include a ":", then the string "bar:com.access.apps." is automatically prepended. Thus, the command:
alp_app --exit test
will terminate the application named "bar:com.access.apps.test".
Exploring and Manipulating Global Settings
Occasionally it can be helpful to explore the current values of various global settings, and even to alter those values. ACCESS Linux Platform includes the alp_settings command-line tool for just this purpose. It runs in the Simulator or on a real device (use it from a telnet session).
alp_settings options...
--install file_name
--base-dir base_directory
--crypto
--set key_name --value value --type type
When using the --set option, the "--type type" clause is optional and can be omitted. Valid types are: "int", "integer", "bool", "boolean", and "string".
--delete-tree directory
--delete key_name
--get key_name
--Get key_name
--uid user_id
--list pattern
--mode mode
--no-notify
--quiet
As an example, here is a sample alp_settings command:
alp_settings --set /alp/input_methods/soft_keyboard/override_qwerty --value TRUE
Working with Alerts
In the Simulator or on an ACCESS Linux Platform device to which you are connected using telnet you can use the alp_alert command to exercise the Attention Manager. You can use it to post alerts, display the contents of the alert database, remove all alerts from the database, and the like.
The basic syntax of the alp_alert command is as follows:
alp_alert [OPTION...] prop1=value1, ..., propN=valueN
The specific format of the alp_alert command when used to list, post, update, and delete alerts is discussed in the following sections.
Listing Alerts
You can list the contents of the alert database, formatted for easy readability, with the -l (or --list) option.
~ # alp_alert --list Alert Id:รพรพรพรพรพรพ 2 รพรพรพรพรพ Source:รพรพ bar:com.access.apps.alarmtest รพรพรพรพรพรพรพ Type:รพรพ alp/alarmtest/alarm รพรพรพรพรพ Handle:รพรพ aUniqueString รพรพรพรพรพ Metric:รพรพ 0 รพรพรพรพรพรพ State:รพรพ 00000005 <TBD> รพรพรพรพรพรพรพ Attr:รพรพ 000700ff <TBD> รพ Prio Class:รพรพ 2 รพรพรพรพรพรพรพ User:รพรพ 0 รพรพรพรพรพรพ Group:รพรพ 0 รพรพรพรพ Created:รพรพ Tue Oct 30 17:29:39 2007 รพรพรพรพ Updated:รพรพ Wed Oct 31 11:46:12 2007 รพรพรพรพรพรพ Start:รพรพ Tue Oct 30 17:29:39 2007 รพ Properties: รพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพ image:รพรพรพ 'alp-stock-telephony-app' รพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพ text-6:รพรพรพ 'text-6' รพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพ text-5:รพรพรพ 'text-5' รพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพ text-4:รพรพรพ 'text-4' รพรพรพรพรพรพรพรพรพรพรพรพรพรพรพ smarttext-3:รพรพรพ 'http://www.google.com' รพรพรพรพรพรพรพรพรพรพรพรพรพรพรพ smarttext-2:รพรพรพ '(650) 555-1212' รพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพ markup-1:รพรพรพ 'mark<u>up</u>-1' รพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพ title:รพรพรพ 'title' Alert Id:รพรพรพรพรพรพ 3 รพรพรพรพรพ Source:รพรพ bar:com.access.apps.worldclock รพรพรพรพรพรพรพ Type:รพรพ /alp/alarm/clock รพรพรพรพรพ Handle:รพรพ 0 รพรพรพรพรพ Metric:รพรพ 0 รพรพรพรพรพรพ State:รพรพ 00000007 <TBD> รพรพรพรพรพรพรพ Attr:รพรพ 000700ff <TBD> รพ Prio Class:รพรพ 2 รพรพรพรพรพรพรพ User:รพรพ 0 รพรพรพรพรพรพ Group:รพรพ 0 รพรพรพรพ Created:รพรพ Wed Oct 31 11:49:01 2007 รพรพรพรพ Updated:รพรพ Wed Oct 31 11:49:01 2007 รพรพรพรพรพรพ Start:รพรพ Wed Oct 31 11:49:01 2007 รพ Properties: รพรพรพรพรพรพรพรพรพรพรพ action-button-3:รพรพรพ 'goto' รพรพรพรพรพรพรพรพรพรพรพ action-button-2:รพรพรพ 'snooze 9' รพรพรพรพรพรพรพรพรพรพรพ action-button-1:รพรพรพ 'clear' รพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพ button-1:รพรพรพ 'Off' รพรพรพรพรพรพรพรพรพรพรพรพรพรพรพ smarttext-4:รพรพรพ 'Alarmรพ 1' รพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพ text-3:รพรพรพ 'Los Angeles' รพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพ text-2:รพรพรพ 'Wednesday 10/31/07' รพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพ text-1:รพรพรพ '11:49 am' รพรพรพรพรพรพรพรพรพรพรพรพรพรพ nag-interval:รพรพรพ '300' รพรพรพรพรพรพรพรพรพรพรพ vibrate-pattern:รพรพรพ 'alp-stock-off' รพรพรพรพรพรพรพ alert-tone-repeat-count:รพรพรพรพรพรพรพ '5' รพรพรพรพรพรพรพรพรพรพรพรพ alert-tone-url:รพรพรพ 'file:///usr/share/sounds/ system/Alarm.mp3' รพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพ image:รพรพรพ 'alp-stock-clock-app' รพรพรพรพรพรพรพรพรพรพรพรพ action-default:รพรพรพ 'snooze 9' รพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพ icon:รพรพรพ 'alp-stock-clock-app' รพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพรพ title:รพรพรพ 'Alarm'
You can list a specific alert by indicating the application ID (for example, bar:com.access.apps.worldclock), like this:
alp_alert -l bar:com.access.apps.worldclock
If there is more than one alert in the list with the same application ID, you can further narrow the listing by including the all or part (always starting from the beginning) of the alert type, separating this from the application ID by a comma, like this:
alp_alert -l bar:com.access.apps.worldclock,alp/alarm
Finally, you can "dump" the contents of the alert database with the ---dump option.This presents the contents of the database in a more concise format; one that is a little less readable but is in fact formatted as if you were posting them to the database using the alp_alert command (and, in fact, you can cut and paste the result of the --dump option to repost an alert). Listing 4.2 shows a dump of the alert database. Note that the contents of the database in this listing are the same as in Listing 4.1.
IMPORTANT: The
--dump option cannot be shortened to -d; the -d option is the short form of --delete, which deletes entries from the alert database.
Listing 4.2 A more concise alert listing
~ # alp_alert --dump alp_alert -p bar:com.access.apps.alarmtest,alp/alarmtest/alarm,aUniqueString -P 2รพ image='alp-stock-telephony-app' text-6='text-6' text-5='text-5' text- 4='text-4' smarttext-3='http://www.google.com' smarttext-2='(650) 555-1212' markup-1='mark<u>up</u>-1' title='title' alp_alert -p bar:com.access.apps.worldclock,/alp/alarm/clock,0 -P 2รพ action- button-3='goto' action-button-2='snooze 9' action-button-1='clear' button- 1='Off' smarttext-4='Alarmรพ 1' text-3='Los Angeles' text-2='Wednesday 10/31/07' text-1='11:49 am' nag-interval='300' vibrate-pattern='alp-stock-off' alert- tone-repeat-count='5' alert-tone-url='file:///usr/share/sounds/system/ Alarm.mp3' image='alp-stock-clock-app' action-default='snooze 9' icon='alp- stock-clock-app' title='Alarm'
Posting Alerts
To post an alert to the database (which, depending upon the options you specify will usually cause the alert to be displayed on-screen), you use the --post (or -p) command. This command takes the following general form:
alp_alert -p source,alert-type,handle [options...] prop1=value1, ..., propN=valueN
The various parameters to this command are as follows:
-
source - The ID of the application posting the alert. More importantly, this is the ID of the application that will be launched if the user elects to "Go To" the application from the alert dialog. For example,
bar:com.access.apps.worldclock. -
alert-type - The event name. This is an application-defined string that names the event type.
-
handle - An application-defined string intended to help the application associate the alert with the actual event's data.
-
options - Zero or more options that affect the way that the alert is posted. These options are:
-
--interface - (or
-I) The alert interface to use. Follow this with the interface name; for example: -
-I my-interface -
--priority - (or
-P) The alert priority, as an integer. Omitting this option or supplying a value of zero causes the alert to be posted with a priority ofALP_ATTN_PRIORITY_DEFAULT. Other values are: 1=ALP_ATTN_PRIORITY_CRITICAL, 2=ALP_ATTN_PRIORITY_IMPORTANT, 3=ALP_ATTN_PRIORITY_NOTICE, 4=ALP_ATTN_PRIORITY_LIST, 5=ALP_ATTN_PRIORITY_SOUND. -
--callback - (or
-C) Wait for a callback response. -
--timeout - (or
-T) Used to specify a timeout when waiting for a callback response. Follow this option with an integer value indicating the timeout interval, in seconds. -
--userdata - Used to specify an argument to be passed to the callback function. Follow this option with the argument, as a string, enclosed in double-quotes.
-
--user - (or
-U) Specifies the user ID to run as. Follow this option with a numeric value indicating the user ID. -
--group - (or
-G) Specifies the group ID to run as. Follow this option with a numeric value indicating the group ID. -
properties - Specify values for the alert's properties (title, text fields, buttons, and the like) by specifying the property name, followed by an equals sign, followed by the property value. Note that the property values usually are strings and should therefore be enclosed in quotes (unless the string contains no spaces or other special characters that might be misconstrued by the command-line interpreter. Examples include:
- title
- image
- animated-image
- icon
- text-1, text-2, text-3, text-4, text-5, text-6
- markup-1, markup-2, markup-3, markup-4, markup-5, markup-6
- smarttext-1, smarttext-2, smarttext-3, smarttext-4, smarttext-5, smarttext-6
- button-1, button-2, button-3, button-4
- action-1, action-2, action-3, action-4
- alert-tone-url
- ring-tone-url
- repeat-tone
- dialog-url
These properties, along with the values that each can accept, are discussed in ACCESS Linux Platform Programming; see the discussion of the Attention Manager in the "Improving Usability" chapter.
title=Alert title="My Alert" icon="bar:com.access.apps.phone/AppIcon_Large-216-8.png" text-1="Michel (W)" text-2="400-3000" dialog="bar:com.access.apps.test/attn_alert_incoming.glade" action-1="launch bar:com.access.apps.phone answer" image-2="bar:com.access.apps.test/photo-70786.png"
The complete list of properties that can be set for an alert dialog is as follows:
See Listing 4.2 for complete examples of how to post alerts.
Updating Alerts
The process of updating an alert mirrors that used when posting an alert. The only differences are:
- Use the --update (or -U) command, rather than --post.
- Supply the source, alert type, and handle for an existing alert.
- Only specify those properties that you wish to change.
For instance, to change the title of the first alert listed in Listing 4.1, use the following command (all on one line):
alp_alert -u bar:com.access.apps.alarmtest,alp/ alarmtest/alarm,aUniqueString title='new title'
In addition to properties, you can update any of the options discussed under "Posting Alerts." You can also update multiple properties and options with a single update command.
Deleting Alerts
You can delete individual alerts with the --delete (or -d) command, or you can erase the entire alerts database with the --wipe command. The --wipe command takes no parameters. The --delete command must be followed by the source, alert type, and handle that together uniquely identify the alert to be deleted, like this (enter the command all on one line):
alp_alert -d bar:com.access.apps.alarmtest,alp/ alarmtest/alarm,aUniqueString
Application Signing
The ACCESS Linux Platform SDK includes the Sign Tool, which creates a digital signature and applies it to a bundle. Signatures on ACCESS Linux Platform bundles are used to verify that the contents of a bundle have been in the physical presence of someone who controls the signing key pair, and that the contents have not been modified since that time. Note that a signature applied to an executable in an installed bundle does not automatically imply that the code itself is more or less trusted. It does, however, provide a high degree of assurance as to the integrity of a bundle's contents and in some cases, a high degree of confidence in the identity of the signer. These two components, the identity of the signer and the integrity of the bundle's contents, are used by the Security Policy Framework to determine the degree to which a bundle is signed.
The Sign Tool requires the following to exist before it can function:
The following section discusses the use of the signtool command. For more information on the ACCESS Linux Platform security architecture and the reasons why you might or might not want to sign an ACCESS Linux Platform application, see the Security chapter of ACCESS Linux Platform Application Programming.
The Sign Tool Command Line Interface
The Sign Tool runs from within Scratchbox. Its basic usage is:
signtool bundle_directory root_certificate_hash certificate_file private_key_file passphrase app_name
-
bundle_directory - The directory path of where the bundle to be signed resides.For instance,
~/myApps/MiniPlayer/build/alp-device/com.access.apps.miniplayer. -
root_certificate_hash - A hash of the root certificate. To get this hash you would run the following command on the root certificate:
- Supply the output of the above command as the Sign Tool root_certificate_hash parameter. Note that if the root certificate changes, you'll need to supply the hash of the new root certificate when signing bundles.
openssl dgst -sha1 -binaryรพroot_certificate |รพopenssl enc -base64
NOTE: For testing purposes, you can supply the hash of the test certificate supplied with the ACCESS Linux Platform SDK.
-
certificate_file - The file containing the X.509 certificate.
-
private_key_file - The file containing the private key.
-
passphrase - The passphrase of the private key.
-
app_name - The name of the application (i.e. calendar, memo, etc.).
Signing With the Test Certificate and Key
ACCESS Linux Platform applications created using the templates provided with the ACCESS Development Suite are automatically signed using the test certificate (which acts as the root certificate for testing purposes) and key when the application is built; the template makefiles contain a step that does this for you. This certificate and key is provided for testing purposes only, and can be found in the samples directory:
NOTE: The above paths assume that you are within Scratchbox. From outside of Scratchbox, you can find the key and certificate in the
/opt/alp-dev/sdk/samples/ directory.
In addition to the private key and certificate, Sign Tool needs the path to the directory containing your bundle, the name of your application, and a passphrase. The passphrase used with the self-signed test private key and certificate is "accesstest" (without the quotes).
As an example of how signtool is used, the following command would be used to sign the MiniPlayer application:
signtool build/alp-device/com.access.apps.miniplayer `openssl dgst -sha1 - binary /scratchbox/ALP/samples/certificate | openssl enc -base64` /scratchbox/ ALP/samples/certificate /scratchbox/ALP/samples/key accesstest miniplayer
If you prefer, you can precompute the root hash value and pass that in instead of recalculating it every time you run signtool. But be mindful of the fact that if the root certificate changes, you'll need to precompute and then supply the hash of the new root certificate.
Note that the above command should be entered all on one line, and that "backquotes," rather than single quotes, should be used to surround the portion that generates the root certificate hash. As well, you need to be in the directory containing the MiniPlayer application (such as ~/myApps/MiniPlayer) before issuing the above command.
Creating Bundles
ACCESS Linux Platform applications are packaged into "bundles." Bundles are very easy to pass around as a single file, while still allowing their contents to be explored without costly overhead. ACCESS Linux Platform bundles are packaged using the ".bar" file is the format.
The ACCESS Linux Platform SDK includes bartender, a Perl script that packs a folder into the .bar package format, or unpacks a .bar file into a folder. This script is a thin layer of argument checking around a few Cramfs commands. (Cramfs is a compressed ROM filesystem.)
Invoke the bartender command from within Scratchbox. In Scratchbox, it is located in the /scratchbox/tools/bin/ directory. Its basic usage is:
bartender [pack | unpack] directory .bar-file
Creating a Bundle
Before you can invoke the bartender command, you must prepare a directory that contains the files that make up your bundle. This directory must contain a manifest file named Manifest.xml (see ACCESS Linux Platform Application Programming for more on manifest files and the structure of bundles). As well, the name of the directory must match the name specified by the name parameter of the manifest element. That is, if the manifest looks like this:
<manifest name="com.access.apps.sample"> <application> <name>Sample</name> <icon>icon_sample.png</icon> </application> </manifest>
The directory in which the manifest file (and all of the other files that will be wrapped up into the bundle) must be named com.access.apps.sample.
Once you have created the directory, simply enter the following command (substituting the path to your directory for myfolder, and providing a proper name for your bundle in place of mypackage.bar):
bartender pack myfolder mypackage.bar
This will use the /usr/bin/mkcramfs command to put the contents of myfolder into the bundle file mypackage.bar.
Unpacking a Bundle
Unpacking a bundle is as simple as creating one. Given an existing bundle named mypackage.bar, you can unpack it into a directory named myfolder with the following command:
bartender unpack myfolder mypackage.bar
The above command uses the /usr/bin/cramfsck command to extract the contents of mypackage.bar into the directory named myfolder. Note that if the named directory already exists, it will not be overwritten.










