December 2009
November 2009
October 2009
September 2009
June 2009
April 2009
March 2009
February 2009
January 2009
December 2008
November 2008
October 2008
July 2008
June 2008
October 2007
September 2007
With the announcement of the Android Scripting Engine, I had to check it out, what with the ability to code python on the G1. It has one large inconvenience at the moment. There is no built in way to use scripts on the SD card. I have a workaround for the time being. With the following script, which runs with ASE, you will be able to import scripts from the ase folder of your SD card into ASE's normal script directory.
import android import os import shutil src = '/sdcard/ase' dst = '/data/data/com.google.ase/scripts' droid = android.Android() for file in os.listdir(src): shutil.copy(os.path.join(src, file), dst) # Interesting permissions on Android os.chmod(os.path.join(dst, file), 0666) droid.makeToast('Import Complete')
Note that you will be typing this into your Android device through ASE. The last script you will have to do that way. You will have to close and reopen ASE before the scripts appear.
Zimbra has a way of developing unusable share permissions and the only way to fix this is to strip all of the permissions are start fresh. In earlier releases, you could use this script, but the parsing is broken in version 5.0.x. I have written a script to handle this. I could have written it in bash, but shell scripts have a hard time with many characters, like backslashes and quotes. This python script requires simplejson and should be ran as the zimbra user, just like zmmailbox. Usage is as such:
Usage: fixgrants.py -u user [-t] folder ... -u user = account to which the folders belong -f = strip flags, this will fix inheritance problems. -t = test_mode, just show commands, nothing will be executed
And here is the script:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | #!/usr/bin/env python """ fixgrants is a utility script for maintaining Zimbra's mailbox sharing permissions. Zimbra has a tendency to develop unusable permission sets and this script will strip all permissions from specified folders of a specified account. It also will strip the folder flags, which will fix permission inheritance issues. """ import getopt import os import simplejson import sys def get_flagged_list(folder): """ Parse getFolder JSON to get a dictionary of folders with flags """ if 'flags' in folder: # Double escape backslashes folders = {folder['path'].replace('\\', '\\\\'): folder['flags'],} else: folders = {} if folder['children']: for child in folder['children']: folders.update(get_flagged_list(child)) return folders def get_grants_list(folder): """ Parse getFolder JSON to get a dictionary of folders with grants """ if folder['grants']: # Double escape backslashes folders = {folder['path'].replace('\\', '\\\\'): folder['grants'],} else: folders = {} if folder['children']: for child in folder['children']: folders.update(get_grants_list(child)) return folders def rm_folder_grants(user, folder, test_mode=False): """ Remove grants recursively rm_folder_grants(user, folder, test_mode=False) user is a zimbra account. folder is a getFolder JSON parsed by simplejson. test_mode determine if any commands will actually be executed. """ print "Removing Grants" for folder, grants in get_grants_list(folder).iteritems(): print "Processing", folder for grant in grants: grant['account'] = user grant['folder'] = folder cmd = "zmmailbox -z -m %(account)s mfg \"%(folder)s\" account %(name)s none" % grant print cmd if not test_mode is True: os.popen(cmd) def rm_folder_flags(user, folder, test_mode=False): """ Remove folder flags recursively rm_folder_flags(user, folder, test_mode=False) user is a zimbra account. folder is a getFolder JSON parsed by simplejson. test_mode determine if any commands will actually be executed. """ print "Removing Flags" for folder in get_flagged_list(folder): print "Processing", folder args = {'account': user, 'folder': folder} cmd = "zmmailbox -z -m %(account)s mff \"%(folder)s\" ''" % args print cmd if not test_mode is True: os.popen(cmd) def print_usage(): sys.stderr.write(""" Usage: %s -u user [-t] folder ... -u user = account to which the folders belong -f = strip flags, this will fix inheritance problems. -t = test_mode, just show commands, nothing will be executed """ % sys.argv[0]) if __name__ == '__main__': optlist, args = getopt.getopt(sys.argv[1:], 'ftu:') if not args: sys.stderr.write("You must specify folders to alter\n") print_usage() raise SystemExit, 1 optd = dict(optlist) if '-u' not in optd: sys.stderr.write("You must specify a user\n") print_usage() raise SystemExit, 1 test_mode = False if '-t' in optd: test_mode = True strip_flags = False if '-f' in optd: strip_flags = True user = optd['-u'] for folder in args: output = os.popen("zmmailbox -z -m \"%s\" gf \"%s\"" % (user, folder)) folders = simplejson.load(output) rm_folder_grants(user, folders, test_mode=test_mode) if strip_flags is True: rm_folder_flags(user, folders, test_mode=test_mode) |
Google has put a lot of work into their Android platform, but their non-Eclipse development instructions could use some work. Just trying to build their Hello, Android fails if you follow their notes to the letter. You'll get this error or similar:
[tlesmann@kimiko HelloAndroid]$ ant
Buildfile: build.xml
dirs:
[echo] Creating output directories if needed...
resource-src:
[echo] Generating R.java / Manifest.java from the resources...
aidl:
[echo] Compiling aidl files into Java classes...
compile:
[javac] Compiling 2 source files to /home/lethal/src/android/HelloAndroid/bin/classes
[javac] Compliance level '1.4' is incompatible with target level '1.5'. A compliance level '1.5' or better is required
BUILD FAILED
/home/tlesmann/src/android/HelloAndroid/build.xml:140: Compile failed; see the compiler error output for details.
Total time: 1 second
I was completely at a loss with this error and all the pages I found on Google were worthless. I'm hoping to change that with this post. The problem is that Sun's javac has a compliance level of 1.4 by default. This can be changed with a command-line argument of -1.5. To get ant to use this argument when compiling, you have to edit the build.xml like so:
<!-- Compile this project's .java files into .class files. --> <target name="compile" depends="dirs, resource-src, aidl"> <javac encoding="ascii" target="1.5" debug="true" extdirs="" srcdir="." destdir="${outdir-classes}" bootclasspath="${android-jar}"> <compilerarg value="-1.5"/> <classpath> <fileset dir="${external-libs}" includes="*.jar"/> </classpath> </javac> </target>
Add the line, <compilerarg value="-1.5"/>, within the javac element and ant will properly build the Hello, Android application. I'm surprised that the activitycreator program does not do this for you as Google advises you to use Sun's JDK.
I hope I've helped you avoid the frustration I suffered solving this silly issue.
NOTE: You no longer have to do this with the release of the 1.5 SDK! Just install Sun's Java and it will build without a problem.
Configuring X for functionality with an HDTV and any nVidia card is quite a frustrating adventure. This is the procedure I took to configure X for my nVidia 8800 GTS ( g80 ) connected to my Sharp Aquos LC-32GP1U through DVI-D. This Aquos is a 1080p monitor, so I am configuring it to run at 1920x1080.
When I first start X, I get a display. The resolution is only 1280x1024. So the first step is to see what X's problem is. The easiest way is to first enter runlevel 3 and start X from there with added switches for verbosity.
Use Ctrl+Alt+F1 to switch to the first virtual terminal. Login and run telinit 3 to enter runlevel 3. Start X with startx -- -verbose 6 -logverbose 6 2> /tmp/startx.log As soon as X displays the screen, press Ctrl+Alt+Backspace to kill X.
Now, we look at /tmp/startx.log. We are looking for the mode validation checking for possible resolutions, specifically 1920x1080. In this output, X tells us that 1920x1080 is to large for DFP, which it isn't because this is a 1080p monitor. We need to tell X to not worry about DFP. Insert the following line in the Device section:
Option "ModeValidation" "NoDFPNativeResolutionCheck"
Now start X with startx -- -verbose 6 -logverbose 6 2> /tmp/startx.log. We'll see nothing has changed. Kill X and look at /tmp/startx.log. Look at the mode validation. X is now complaining about timings. We need to tell X to use exact timings, which we do by adding this line to our Device section:
Option "ExactModeTimingsDVI" "True"
Now start X with startx -- -verbose 6 -logverbose 6 2> /tmp/startx.log. We'll see that the screen is deformed. Kill X and look at /tmp/startx.log. Nothing will scream out the problem unfortunately. The resolution is actually correct, 1920x1080. However, the image is not correctly scaled. It took me many frustrating google searches to find a solution for this. We need to add this line to our Device section to have the video card use the monitor's native scaling.
Option "FlatPanelProperties" "Scaling=Native"
Start X and voila. Beautiful 1080p resolution, perfectly scaled. Here is the entire /etc/X11/xorg.conf from my machine:
Section "ServerLayout"
Identifier "single head configuration"
Screen 0 "Screen0" 0 0
InputDevice "Keyboard0" "CoreKeyboard"
EndSection
Section "Files"
ModulePath "/usr/lib64/xorg/modules/extensions/nvidia"
ModulePath "/usr/lib64/xorg/modules"
EndSection
Section "ServerFlags"
Option "AIGLX" "on"
EndSection
Section "InputDevice"
Identifier "Keyboard0"
Driver "kbd"
Option "XkbModel" "pc105"
Option "XkbLayout" "us"
EndSection
Section "Monitor"
Identifier "Monitor0"
EndSection
Section "Device"
Identifier "Videocard0"
Driver "nvidia"
Option "ExactModeTimingsDVI" "True"
Option "ModeValidation" "NoDFPNativeResolutionCheck"
Option "FlatPanelProperties" "Scaling=Native"
Option "AddARGBGLXVisuals" "True"
Option "DisableGLXRootClipping" "True"
EndSection
Section "Screen"
Identifier "Screen0"
Device "Videocard0"
Monitor "Monitor0"
DefaultDepth 24
SubSection "Display"
Viewport 0 0
Depth 24
Modes "1920x1080"
EndSubSection
EndSection
Section "Extensions"
Option "Composite" "Enable"
EndSection
