what’s the best way for OEM to organize it’s own resources?

http://groups.google.com/group/android-framework/browse_thread/thread/e9974bd5a42af10a/61dc12b2bd0eadde

make their own resource apk like "framework-res.apk", it can
separate their own resources from android's original res,  but i don't
kown how to implements it, and i don't kown whether it is feasible.

This would be best, but currently we don't support shared libraries with
resources so you can't really do it.

In cupcake you can define PRODUCT_PACKAGE_OVERLAYS in your product makefile
to specify one or more directories that will be merged in with the base
platform directories.  For example:

PRODUCT_PACKAGE_OVERLAYS := vendor/mycompany/prod_overlay
vendor/mycompany/base_overlay

Now you can replace or add framework resources by putting them in either of
these:

vendor/mycompany/base_overlay/frameworks/base/core/res/res/
vendor/mycompany/prod_overlay/frameworks/base/core/res/res/

You can use this to replace any resource in the tree, both in the framework
and in specific packages, by just putting them in a directory corresponding
to the same path where you find them in the platform tree.

Also when adding new resources to the frameworks that you want to use in
your own apps that are built into the system image, you can use the magic
syntax "@*android:type/name" to reference them without having to make them
public.  You can likewise find private resources in Java at
com.android.internal.R.

Glad to see this overlay mechanism.  Very nice.
How can I test this?
I created a vendor/mycompany/mycompany.mk
————
PRODUCT_PACKAGES := \
    VoiceDialer

# Try adding a product with VoiceDialer

# Superclass
$(call inherit-product, build/target/product/generic.mk)

# Overrides
PRODUCT_BRAND := mybrand
PRODUCT_NAME := myproduct
PRODUCT_DEVICE := mydevice
PRODUCT_MANUFACTURER := me
————

and a AndroidProducts.mk at the same location
————

PRODUCT_MAKEFILES := \
    $(LOCAL_DIR)/mycompany.mk
————

But before adding overlays, I tried to do a build but I am not sure
whats the correct target.

make myproduct
make PRODUCT-myproduct-eng

all fails with msg: "No rule to make target"

Is there an example product makefile?
documents/pointers/tips would help.

thanks
Jey

i find that attrs.xml files can not be overlayed
it will make an error
attrs.xml  error atribute "direction" has already benn difiend.

i test the overlay on Launcher app
any other file types can be overlayed successfully.

i define the overlay path in my own product file
and copy the original Launcher app to the corresponding overlay path
the attrs.xml file failed,
delete the attrs.xml file it works.

i want to know if the attrs.xml files can be overlayed?

You are redefining the direction attribute, which is already defined by the
base framework.  You need to use a different name.

 and another problem

i put some res files in the framework res overlay dir
vendor/mycompany/base/frameworks/base/core/res/res/

when i make the framework-res module on the command line , it faild
"make: [out/target/common/obj/apps/framework-res_intermediates/pachage-
export.apk] segmentation fault"

the framework res  can not be overlayed???

————————————————————————————
hi Nik
just like Dianne Hackborn reply to my first post
i make a dir for my overlay res under the android source root dir
the path looks like:
android_root/vendor/mycompany/base
android_root/vendor/mycompany/product

and just for test we define PRODUCT_PACKAGE_OVERLAYS := vendor/
mycompany/base vendor/mycompany/product
in the build/target/product/generic.mk

if you test Launcher app
put the Launcher app under
vendor/mycompany/base/packages/apps/
on the command line >make Launcher

if you test framework res
put the overlay res under rvendor/mycompany/base/frameworks/base/core/
res/res/ path
>make framework-res

but it faild

——————————————————————-
hi Dianne Hackborn
the  direction attribute is defined is not defined by framework
it is defined by the original Laucnher app which under pachages/apps/
Laucher
and i copy the Launcher app to my overlay path
you said it will replace the original files, it is that?
i find that, image files will be replaced, but attrs.xml file will be
merged not replace, is it?

Yes it can be overlayed, we use that for doing different builds for
different devices, such as setting up default configurations for hard vs.
soft keyboard devices.  The aapt shouldn't outright crash, so somebody will
need to debug that — if you want, just change the build system to run it
with "gdb" and you can get a stack crawl to see what happened.  (Look for
$(APPT) in build/core/definitions.mk for the place where it is invoked.)

Posted via email from feinan’s posterous

How to Create or Edit Themes

http://forum.android-dev.it/android-themes-t192.html

How to Create or Edit Themes
Written by Stericson
Tuesday, 10 February 2009 21:14

Taken from xda-developers.com and many thanks to Stericson for his excellent explanation. Please try this at your own risk we at Android Evolve are not responsible for any damaged that maybe caused during any part of this process.

To create themes, or to edit themes to your liking, you will need a working knowledge of android, adb, how to resign apk's, knowledge of your own O/S.

Things you will need:

You will need JF's RC30, RC8, or ADP1 V1.3, depending on what version you intend to create for.

Here is the link to these: http://forum.xda-developers.com/showthread.php?t=466174

You will also want to get the dev bootloader installed on your phone and to HIGHLY suggest everyone trying your theme to install it as well.

Link to dev bootloader: http://forum.xda-developers.com/showthread.php?t=455860

Link to Java: http://java.sun.com/javase/downloads/index.jsp

Downloading SDK: http://code.google.com/android/intro/installing.html

You can also use any zipping archive to extract files from and to the update.zips. I believe there are links below to some of these.

You will also need to resign all the apks located in /system/app and framework-res.apk located in /system/framework.

However, the easiest way to do it, although not always the best and safest way, is to take another update and edit it to your liking.

You will however have to sign your update.zip files and you SHOULD get in the practice of signing every apk that you edit. Sometimes you can get away with not signing the apks.

JesusFreke was kind enough to build a custom signing tool for me that would allow me to right click on an apk and resign it from there. I am posting it here for others to use as well. Note that this is a courtesy of JF, so thank him for it. I cannot stress how much time this has saved me and will save you.

Automatic version!

Note, this will not work if your SDK or the path that you place this in has any spaces in the dir name!
An Example of this is c:\users\Nikki and Stephen\sdk\tools
Try to put the SDK and the contents of the zip in a dir where the names are all together and not like the one above.

I have made a batch file that will automate the entire process of setting up to use the signing tool made by JF. This batch file will set the CLASSPATH, set the PATH, install the registries, and will even allow you to sign files manually if you wish. I plan on building onto this batch file to include other things. However, for the moment, it will only include what you see here.

In order to use this you should have downloaded the sdk already. Simply extract all of the files into the tools dir of your sdk, and run autosign.bat follow the instructions and go through the options one by one, starting with 1 working through 4. You can however, put the contents of this zip anywhere on your computer and it will work. It is just better to put them into the tools dir of your SDK. Especially for the consideration of future versions.

Autosign .zip: http://www.relentlessaddictions.com/Androidstuff/signing.zip

Want to set up the signing tool manually?

Here is the link for the signing tool: Http://www.FightForthePits.com/testsign(2).zip

Before using this you need to know how to set this up:

Now you will need to add the tools dir of your sdk to the environment variable CLASSPATH.

FOR XP:

Right click on My Computer click properties, then choose the tab that says advanced.
Click the button that says environmental variables.
Go to system variables find the one that says CLASSPATH
double click it
go to the end of variable value.
There should be a semicolon ; at the end, type in the path to the testsign.jar located in the tools directory of your SDK

for example the path to my testsign.jar was c:\sdk\android-sdk-windows-1.0_r1\tools\testsign.jar

If CLASSPATH is not in your system variables then create it.
Secondly, Find the system variable called PATH and add to the end of it, the full path to your sdk directory.

For example, mine was c:\sdk\android-sdk-windows-1.0_r2\tools

FOR VISTA:

Open a cmd prompt.

Replace THEEXACTPATHTO-TESTSIGN with the path to the dir that holds the file testsign.jar.

Type:
echo %CLASSPATH%

If it is returns %CLASSPATH%
Type the following:
set CLASSPATH=THEXACTPATHTO-TESTSIGN\testsign.jar

If it comes back with something else then
Type the following:
set CLASSPATH=%CLASSPATH%;.;THEXACTPATHTO-TESTSIGN\testsign.jar

For Example, when I type this it looks like:
set CLASSPATH=%CLASSPATH%;.;c:\Android\SDK\tools\tests ign.jar

To set the PATH

Replace THEEXACTPATHTO-SDK with the path to the tools dir of your SDK.

Now type:

set PATH=%PATH%;.;THEXACTPATHTO-SDK\tools

For example, when I type this out it looks like this:

path-%PATH%;.;c:\Android\SDK\tools

Now through doing this you have done two things, first off you have made the resigning process extremely easy, secondly you will not have to cd to the tools dir of the sdk to use adb or any other tool in the sdk.

Signing the Files:

Now right click the reg file that you extracted and choose to install it, or merge.

Now, right click an apk, do you see an option that says ResignApk? That's how you will resign your .apks and .zips.

When you choose it a cmd window should open for a few seconds and then close. the file you signed will be overwritten with the new resigned file.

If you find the right click menu not working for some reason you can type the following in cmd to sign your files: java testsign whateverfiletosign

General Info:

You will need to be specific in addressing what version your theme is for, RC8, RC30, or ADP1. Make sure every file gets signed. Make sure you test the update.zip before you release it.

Every .apk contains the images relating to itself. However, every apk has the ability to use the images in framework-res.apk. The images for every apk is located inside of itself. To find these images open up the apk, you can rename it to .zip or open it with an archiver of your choice, winrar, winace, etc. Then after opening the apk open the folder called res and inside of that there are folders that are named Drawable, drawable-land, drawable-port, etc. This is where the images are stored.

There are some things you cannot edit unless you rebuild the entire apk from source, which we will not go into here.(another tutorial, another time) Just know that at this time you SHOULD NOT edit, or even open images with the extension .9.png.

If you do you can have serious problems…Trust me….if your still gonna do it, proceed with caution!

These are special images called ninepatch images and android resizes these images to fit wherever android, or any other apk, needs it to. if you do open them or edit them they will no longer render correctly when resized. I believe that in order to edit these you must do so and then put them into the source and rebuild the entire apk.

If your going to build your own update.zip from scratch:

Before getting started you must also realize that you cannot simply resign one or two apk's and stick them in your phone and expect them to work. You must resign every apk inside of /system/app and framework-res.apk and put them on your phone at the same time.

To simplify this process for you though, I have provided an empty update.zip which you can place all of your resigned apps into and use to update your phone to your custom theme. You can also download someonelses theme and use there files, since they are resigned already. It may also be easier to see what files do what and go where since they have already been edited and are easy to point out.

Now, your ready to start changing things up.

You will now need to open the apk, which you can do by adding .zip after .apk, effectively changing it to a zip. or you can use your favorite archive opener.

I dont use the archive process because it can lead to very aggravating problems such as things not getting signed correctly and have heard reports of it interfering with the signing tool above. Anyways I just add zip and it works great for me.

For those renaming the .apk's to .zips

Note that if you are using windows you will need to unhide known file extension types. you can also use your favorite archiver such as winrar, winzip, etc.

See here to unhide known file extension types for Xp: http://www.mediacollege.com/microsof…on-change.html

See here to unhide file extension types for Vista: http://maximumpcguides.com/windows-v…ile-extension/

Tips:

After opening the apk copy the folder called res.
Go to your desktop, or wherever, create a new folder called Images, or whatever.
Open the folder, paste the res in there.
Now you can see what the files look like without opening them, by using thumbnails to see what they are.
Btw, you may also want to add -frame, or -launcher, to the end of the res folder you copy over to keep them separated from others.

Almost Done

So now your theme is done and your ready to make an update.zip for others to install your theme.

I have created a template for you to make your own update.zip. Just download, add the system apps to app, and framework to framework. Zip it up, SIGN IT, TEST IT YOURSELF, and then distribute it!

Empty update.zip template: Http://www.FightForthePits.com/Andro…date_empty.zip

Update script

The update script is in a Unix format, while you do not need linux you must save it in a Unix format. I suggest using Textpad to edit this script and saving it in the Unix format.

Link to Textpad: ftp://download.textpad.com/pub/textpad5.2/txpeng520.exe

Final Notes:

If anyone has any questions please try asking for help in this thread before emailing me for help Usually I will respond to questions in this forum.

I hope this Tutorial has been helpful. I will add on to it as needed.

Any questions can be directed to me at Stericson.G1@gmail.com

Stericson

Links of interest:

Using ADB: http://code.google.com/android/reference/adb.html

Posted via email from feinan’s posterous

Share Point:How to make another framework-res.apk for OEM to share resource.

http://groups.google.com/group/android-platform/browse_thread/thread/d7016b891fbabcea

I have asked a question "how is framework-res.apk loaded?"(http://
groups.google.com/group/android-porting/browse_thread/thread/
730a22ab62d76c24/b07c2e7d54e98f79#b07c2e7d54e98f79) and got some
suggestions from Dianne.

My colleague got the solution about how to make resource apk of our
own self and I am sharing it with others and want some expert can tell
me whether there is any risk. ( Dianne suggested :D on't do it)

1. Make an apk project for your resource: AppRes
   write Android.mk as others and add command below to it:
#tell aapt to generate resource ID from 0×20
LOCAL_AAPT_FLAGS := -x

LOCAL_EXPORT_PACKAGE_RESOURCES := true

2. create an apk to use resource apk APP1
add command below to its Android.mk
{{{
# include R.java of resource apk
LOCAL_INTERMEDIATE_SOURCES := $(framework-res-source-path)/my/own/
resource/apk/R.java

}}}

3. modify Android build script
modify build/target/product/core.mk like below:

PRODUCT_PACKAGES := \
    framework-res \
    AppRes \                  <– our resource apk name, created under
system/framework

 modify build/target/product/generic.mk

PRODUCT_PACKAGES := \
    AlarmClock \
    ……
    SyncProvider \
    App1                    <– apk to use resouce, created under
system/app

4. modify frameworks/base/libs/utils/AssetManager.cpp
let android load both frame-res.apk and our resource apk.

//our resource apk path
static const char* kMyAssets = "framework/appres.apk";

//修改下面的方法
bool AssetManager::addDefaultAssets()
{
    const char* root = getenv("ANDROID_ROOT");
    LOG_ALWAYS_FATAL_IF(root == NULL, "ANDROID_ROOT not set");
/* This is original code
    String8 path(root);
    path.appendPath(kSystemAssets);

    return addAssetPath(path, NULL);
*/
//add code below
        bool isOK1 = false;
        bool isOK2 = false;
        { // load framework-res.apk
                String8 path(root);
                path.appendPath(kSystemAssets);
                isOK1 = addAssetPath(path, NULL);
        }
        { // load our resource apk
                String8 path(root);
                path.appendPath(kMyAssets);
                isOK2 = addAssetPath(path, NULL);
        }
        return isOK1 && isOK2;
}
}}}

5. how to use it.

We can write code like below:

tv1 = (TextView) findViewById(R.id.tvWelcome1);
tv1.setText(my.own.resource.apk.R.string.welcome);

6. compile

>make clean
>make

if you got any error message complaining about needing resource apk,
do next:

>source build/envsetup.sh
>mmm packages/apps/AppRes/
>make

My colleague tell me we even can add class to resource apk to share
it.

Any suggestion and question is welcome.

James

Posted via email from feinan’s posterous

Push New Framework Resource framework-res.apk to Android Emulator

adb shell
su
mount -o remount,rw /dev/mtdblock4 /system
dd if=/sdcard/framework-res.apk of=/system/framework/framework-res.apk

When you do these commands, you're replacing a file in use, and android doesn't like that so it'll auto-reboot, but its the way I've always used. Also the if=/sdcard/framework-res.apk just refers to wherever your framework is (this assumes it's on the root of the sdcard).

Posted via email from feinan’s posterous

Upload Files to SD Card in Android Emulator

1. mksdcard 2147483648 sdcard.img
2. Addition Emulator Options "-sdcard sdcard.img"
3. adb push <file> /sdcard/<path>

Posted via email from feinan’s posterous

grep on all the files in a directory

grep -r -i PATTERN /usr/include 2>err.out

'-i' means ignore case.
'-r' means recursive search.
'2>err.out' means to redirect stderr to err.out at local directory since grep will follow symbolic links.

List Word Occurrence for A Given Document

cat nautilus-debug-log.txt | tr -cs A-Za-z '\012' | tr A-Z a-z | sort
| uniq -c | sort -r -n | sed 25q

  2660 x
  2659 user
  2659 to
  2659 signal
  2659 log
  2659 dumped
  2659 due
  2659 debug
     1 milestones
     1 begin
     1

Posted via email from feinan’s posterous

how do you list all users in linux

We’ll start by
1.cat /etc/passwd

2.As we all know that by default all the users created will have their
home directories in /home share
so we’ll modify our command a bit by using grep.
Now it’ll be
cat /etc/passwd | grep “/home”

3. Now we’ll get all the user accounts which have their home share in /home.
But the only output we need is the list of users & nothing else.

4. So we’ll modify our command again
cat /etc/passwd | grep “/home” |cut -d: -f1
Now what we have done is that we have piped the output of previous
command to another variable “cut”
What we have done here is we have added
cut -d: -f1
-d: means delimiter :
-f1 means display first field of line i.e. username.

So final command is
Cat /etc/passwd |grep “/home” |cut -d: -f1

This works until all your users have their home share in /home. If you
have defined their home share to some other destination. Modify the
above command.