2012年10月29日星期一

backtrace显示调用栈层次

代码摘自man backtrace
#include <execinfo.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

void
       myfunc3(void)
       {
           int j, nptrs;
       #define SIZE 100
           void *buffer[100];
           char **strings;

           nptrs = backtrace(buffer, SIZE);
           printf("backtrace() returned %d addresses\n", nptrs);

           /* The call backtrace_symbols_fd(buffer, nptrs, STDOUT_FILENO)
              would produce similar output to the following: */

           strings = backtrace_symbols(buffer, nptrs);
           if (strings == NULL) {
               perror("backtrace_symbols");
               exit(EXIT_FAILURE);
           }

           for (j = 0; j < nptrs; j++)
               printf("%s\n", strings[j]);

           free(strings);
       }

       static void   /* "static" means don't export the symbol... */
       myfunc2(void)
       {
           myfunc3();
       }

static void   /* "static" means don't export the symbol... */
       myfunc2(void)
       {
           myfunc3();
       }

       void
       myfunc(int ncalls)
       {
           if (ncalls > 1)
               myfunc(ncalls - 1);
           else
               myfunc2();
       }

       int
       main(int argc, char *argv[])
       {
           if (argc != 2) {
               fprintf(stderr, "%s num-calls\n", argv[0]);
               exit(EXIT_FAILURE);
           }

           myfunc(atoi(argv[1]));
           exit(EXIT_SUCCESS);
       }

2012年7月8日星期日

电话相关缩略语

AAA
Authentication, Authorization and Accounting 认证 授权和计费
AN-AAA 
Access Network AAA 接入网络认证的AAA
AT 
Access Terminal 接入终端
CAVE
Cellular Authentication and Voice Encryption algorithm 蜂窝鉴权和语音加密算法
CHAP 
Challenge Handshake Authentication Protocol 查询握手认证协议
IMSI 
International Mobile Subscriber Identity 国际移动用户识别码
IOS 
Inter-Operability Specification 互操作规范
MEI 
Mobility Event Indicator 移动性事件指示
MS 
Mobility Station 移动台,本文指双模手机
SIP 
Session Initiation Protocol 会话初始化协议
UDP 
User Datagram Protocol 用户数据报协议
UIM 
User Identity Model 用户识别模块
WAG 
WLAN Access Gateway WLAN 接入网关
WLAN 
Wireless Local Area Network 无线局域网
wPDIF 
WiFi Packet Data Interworking Function WiFi 分组数据互联网关

2012年7月5日星期四

Android模拟器命令行使用

telnet localhost <port>
然后就可以执行相关命令。
例如gsm call 1234

2012年5月6日星期日

admob代码一例

import com.google.ads.AdRequest;
import com.google.ads.AdSize;
import com.google.ads.AdView;

AdView adView = new AdView(GAEProxy.this, AdSize.BANNER, "a14d8be8a284afc");
FrameLayout layout = (FrameLayout) findViewById(R.id.ad);
layout.addView(adView);
AdRequest aq = new AdRequest();
adView.loadAd(aq);
......
adView.destroy(); //结束时销毁

2012年3月27日星期二

【转】手机制式的解释

Preferred Network Types change the type of frequency the phone searches for.
Android is used on several devices that can gain access to different cell carriers. The 'Testing' menu that contains the 'preferred network types' you are referring you to is used for all of those Android devices as far as I can tell. 

For simplicity, there are two main types of cell carriers, GSM and CDMA.
The following popular data communication technology is associated with each cell carrier type:
GSM = GPRS (2g), EDGE(2g), UMTS(3g), WCDMA(3g), HSDPA(3g) {Cell Carrier examples: AT&T and T-Mobile}
CDMA = CDMA*(2/3g) EV-DO(3g) WiMax(3/4g) {Cell Carrier examples: Verizon and Sprint}

Now that the general stuff is out of the way, here's my take on the Preferred Network types:

WCDMA preferred - The GSM phone is capable of using both 2G and 3G data communication and when signal strength is low 3G is favored more.
GSM only - The GSM phone is capable of using only 2G data communication. When the 2G signal is too low you get nothing at all.
WCDMA only - The GSM phone is capable of using only 3G data communication. When the 3G signal is too low you get nothing at all.
GSM auto (PRL) - The GSM phone is capable of using both 2G and 3G data communication and when signal strength is low 2G is favored more. This one is a bit confusing to me since PRL is associated mostly with CDMA technology and not GSM technology.
CDMA auto (PRL) - The CDMA phone is capable of using both 2G and 3G data communication and when signal strength is low 2G is favored more.
CDMA only - The CDMA phone is capable of using only 2G data communication. When the 2G signal is too low you get nothing at all.
EvDo only - The CDMA phone is capable of using only 3G data communication. When the 3G signal is too low you get nothing at all.
GSM/CDMA auto (PRL) - Some phones are equipped with both GSM and CDMA capabilities. This setting appears to just have the phone attempt to stay connected to the data communication type that works the best. (Maybe the Samsung Galaxy S will take advantage of this???)
Unknown - If none of the above fit or the phone is acting weird as far as connecting to the carrier, you will see your preferred network type is set to this

When using the 'only' options you should still be able to make calls.

To put things into perspective, The Nexus One is set to WCDMA preferred as default and the Droid Incredible is set to CDMA auto (PRL).

Some References:
http://www.google.com/support/forum/p/android/thread?tid=34f1f0c3bc7affe1&hl=en
http://en.wikipedia.org/wiki/3G
http://en.wikipedia.org/wiki/Preferred_Roaming_List
http://ncare.com/2010/03/29/how-to-update-your-phones-with-the-newest-towers/

2012年3月19日星期一

关于declare-styleable

http://stackoverflow.com/questions/3441396/defining-custom-attrs

ERROR: In XXX, unable to find attribute yyy

Android 中定义declare-styleable时碰到这个错误,折腾了3个小时,才发现是<attr>这个tag只写了name,而没有写format。。。
正确的写法是
<attr name="some name" format="string" />

2012年3月14日星期三

[转]如何忽略Android资源编译错误 Error: this attribute must be localized.

http://blog.csdn.net/forlong401/article/details/7218204

这个错误是由于强制要求应用程序按照多国语言的模式开发,避免死的字符串。

但有的时候你发现导入别人的代码,改这些字符串太麻烦,那么可以在Android.mk中添加

LOCAL_MODULE_TAGS := tests 

2012年2月15日星期三

调用注释有@hide的方法编译出错

编译Android时,如果Android.mk中有LOCAL_SDK_VERSION,调用注释有@hide的方法会导致编译通不过,
必须把LOCAL_SDK_VERSION去掉。原因不明 �

2012年2月10日星期五

64位linux下安装Beyond Compare

==========================================================
I just got Beyond Compare 3.0.2 for Linux to run on 64-bit Kubuntu 8.04.1. It is pretty painful to setup.

Here are the steps:
1. Install 32-bit compatibility library.
Using the graphical package manager, install the package "ia32-libs". You can also install from a terminal using the command "sudo apt-get install ia32-libs".

2. Install 32-bit version of QT3.
(On older versions of Kubuntu/Ubuntu, you may be able to install the
package "ia32-libs-kde", this package isn't available for Kubuntu 8.04.1 AMD64)

Download the 32-bit .deb package for QT3 from http://packages.ubuntu.com/hardy/i38...t3-mt/download.

Extract the contents of the .deb package.
dpkg-deb --extract libqt3-mt_3.3.8-b-0ubuntu3_i386.deb libqt3-mt

Copy the QT3 libraries to Kubuntu's folder for 32-bit libraries.
sudo cp -R libqt3-mt/usr/lib/* /usr/lib32

3. Install Beyond Compare 3 for Linux deb package.
sudo dpkg -i --force-architecture BCompareLinux_080814.deb

4. Run Beyond Compare by typing "bcompare" in a terminal.