调试Telephony过程中搜集和积累的一些资料

这些是在调试Telephony过程中搜集和积累的一些资料,希望对想接触这部分功能的人有所帮助。

一、深入理解 Android Telephony原理剖析与最佳实践_13151646.pdf

(http://elastos.org/redmine/projects/elastosrdk5/files) 的Android Telephony目录下

这本书是以android 4.0.3版本进行讲解的,虽然telephony这部分的实现发生了很大变化,但是

总体的实现结构还是一致的,所以对于入门熟悉Telephony这块是有很大帮助的。

二、拨出电话(MO)在java层的流程图:  这个图是根据5.0.2整理的,可以帮助和熟悉和调试MO的主流程

参加附件MO_call_process.png mo.jpeg

三、Sim Card牵扯到的类及初始化过程:

SIM Card相关的类,及他们的关系可以参考UiccController文件,其中的注释有详细的说明,初始化

过程的流程图参看附件:simcard_init.png

四、Telephony的调试

1. 在android中RIL相关的debug 信息输出到一块单独的buffer,在使用logcat时需要指定:

logcat -b radio   (我们系统中现在的实现没有遵循这个实现,可能需要调整)

2. 在android 虚拟机中可以通过以下命令模拟来电或者发短信等操作。

telenet localhost 5554
gsm call 1111
sms send 1111 hello android

3. 在查看android调试信息时,以下命令可以帮助增加信息的输出。

setprop log.tag.InCall VERBOSE
setprop log.tag.Telecom VERBOSE
(与铃声相关)
setprop log.tag.AudioService.VOL VERBOSE
setprop log.tag.AudioService.MOD VERBOSE

4. 手动修改来电铃声: 需要修改数据库
(查询可用的铃声,记住选取的id)

sqlite3 /data/data/Elastos.Droid.Providers.Media/databases/internal.db

select _id, _display_name, duration,is_ringtone from audio where is_ringtone=1;
(设置铃声,id为上面查询的结果)
sqlite3 /data/data/Elastos.Droid.SettingsProvider/databases/settings.db
update system set value = “content://media/internal/audio/media/id” where name = “ringtone”;
update system set value = “content://media/internal/audio/media/id” where name = “ringtone_default”;

五、网络资源

http://blog.csdn.net/xiashaohua/article/category/2091261      (Telephony相关流程分析)

http://blog.csdn.net/yihongyuelan/article/details/24640819     (以Android 4.4为参考版本)

http://blog.csdn.net/u010961631/article/category/1662625

六、Telephony相关的参考文档

1.  3GPP相关            http://www.3gpp.org/

[3GPP TS 27.007]       AT command set for User Equipment (UE)

[3GPP TS 22.030]      Man-Machine Interface (MMI) of the User Equipment (UE)

[3GPP TS 23.040]      Technical realization of the Short Message Service (SMS)

[3GPP TS 23.060]      General Packet Radio Service (GPRS)

2.  RIL相关  看附件

how_to_use_android_ril.pdf

AndroidRIL-SourceCode_AppNote_(UBX-13002041).pdf

 | 246 views | 5 comments | 0 flags | 

How-to-use-ubus

Just study the ubus for job, and the example in the project is a good start(http://git.openwrt.org/?p=project/ubus.git;a=summary), but three different usage in one file is hard to read and understand, so I split it.

one for sync method invoke:server_method_invoke  client_method_invoke

one for async method invoke:server_async client_async

one for subscribe:server_subscribe      client_subscribe

 | 155,683 views | 4,418 comments | 0 flags | 

how to download/compile/run(emulator) the source code of android5.0

curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo

https://www.googlesource.com/new-password

repo init -u https://android.googlesource.com/platform/manifest/ -b android-5.0.1_r1

repo sync
——-for auto restart when repo sync fail—
#!/bin/bash
FAIL_COUNTS=0
echo “begin to repo sync”
repo sync -f -j4

while [ $? -ne 0 ]; do
((FAIL_COUNTS++))
echo “repo sync fail $FAIL_COUNTS times”
sleep 3
echo “repo sync retry”
repo sync -f -j4
#if [ $FAIL_COUNTS -ge 4 ]; then
#        break;
#    fi
done

echo “repo sync faild $FAIL_COUNTS times”
————-

source build/envsetup.sh

lunch //select the target  aosp_arm-eng

make -j8
—–start the emulator———
emulator -partition-size 1024

 | 357,232 views | 6,838 comments | 0 flags | 

Java jni invoke process under android5.0

android_webview_native_webview_native_gyp.a

external/chromium_org/android_webview/Android.mk(responsible for the java compile)
JNI_Invoke process
external/chromium_org/android_webview/lib/main/webview_entry_point.cc
	JNI_OnLoad
		->base::android::RegisterLibraryLoaderEntryHook
		->content::EnsureJniRegistered
		->RegisterNativeMethods
		->android_webview::RegisterJni
			->android_webview/native/android_webview_jni_registrar.cc
				->RegisterNativeMethods
				->android_webview/native/aw_contents.cc
					->RegisterNativesImpl[AwContents_jni.h]
					->
		->base::android::InitReplacementClassLoader
		->content::SetContentMainDelegate
		->url::Initialize
external/chromium_org/GypAndroid.linux-arm.mk
	[
		AwContents.java
		{
			// Return true if the GeolocationPermissionAPI should be used.
			@CalledByNative
			private boolean useLegacyGeolocationPermissionAPI() {
			    // Always return true since we are not ready to swap the geolocation yet.
			    // TODO: If we decide not to migrate tarm-linux-androideabi-objdump -tT libwebviewchromium.so | grep Java_com_android_org_chromium_android_1webview_AwContents_nativeInit
001d2834 g    DF .text	000000ec Java_com_android_org_chromium_android_1webview_AwContents_nativeInit

refer the autogenerated xxx_jni.h to create the interface(c++ -> native, native -> c++)he geolocation, there are some unreachable
			    // code need to remove. http://crbug.com/396184.
			    return true;
			}
			private static native long nativeInit(AwBrowserContext browserContext);
		}
		//--------------------------------------------
		aw_contents.cc
		{
			static jlong Init(JNIEnv* env, jclass, jobject browser_context) {
			  // TODO(joth): Use |browser_context| to get the native BrowserContext, rather
			  // than hard-code the default instance lookup here.
			  scoped_ptr<WebContents> web_contents(content::WebContents::Create(
			      content::WebContents::CreateParams(AwBrowserContext::GetDefault())));
			  // Return an 'uninitialized' instance; most work is deferred until the
			  // subsequent SetJavaPeers() call.
			  return reinterpret_cast<intptr_t>(new AwContents(web_contents.Pass()));
			}
			//====================================
			void AwContents::RequestGeolocationPermission(
			    const GURL& origin,
			    const base::Callback<void(bool)>& callback) {
			  JNIEnv* env = AttachCurrentThread();
			  ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
			  if (obj.is_null())
			    return;

			  if (Java_AwContents_useLegacyGeolocarm-linux-androideabi-objdump -tT libwebviewchromium.so | grep Java_com_android_org_chromium_android_1webview_AwContents_nativeInit
001d2834 g    DF .text	000000ec Java_com_android_org_chromium_android_1webview_AwContents_nativeInit

refer the autogenerated xxx_jni.h to create the interface(c++ -> native, native -> c++)ationPermissionAPI(env, obj.obj())) {
			    ShowGeolocationPrompt(origin, callback);
			    return;
			  }
			  permission_request_handler_->SendRequest(
			      scoped_ptr<AwPermissionRequestDelegate>(new SimplePermissionRequest(
				  origin, AwPermissionRequest::Geolocation, callback)));
			}

		}
		//--------------------------------------------
		AwContents_jni.h
		{
		extern "C" {
			static jlong Init(JNIEnv* env, jclass jcaller,
			    jobject browserContext);

			__attribute__((visibility("default")))
			jlong
			    Java_com_android_org_chromium_android_1webview_AwContents_nativeInit(JNIEnv*
			    env, jclass jcaller,
			    jobject browserContext) {arm-linux-androideabi-objdump -tT libwebviewchromium.so | grep Java_com_android_org_chromium_android_1webview_AwContents_nativeInit
001d2834 g    DF .text	000000ec Java_com_android_org_chromium_android_1webview_AwContents_nativeInit

refer the autogenerated xxx_jni.h to create the interface(c++ -> native, native -> c++)
			  return Init(env, jcaller, browserContext);
			}
			//==================================================//
			static base::subtle::AtomicWord g_AwContents_useLegacyGeolocationPermissionAPI =
			    0;
			static jboolean Java_AwContents_useLegacyGeolocationPermissionAPI(JNIEnv* env,
			    jobject obj) {
			  /* Must call RegisterNativesImpl()  */
			  CHECK_CLAZZ(env, obj,
			      AwContents_clazz(env), false);
			  jmethodID method_id =
			      base::android::MethodID::LazyGet<
			      base::android::MethodID::TYPE_INSTANCE>(
			      env, AwContents_clazz(env),
			      "useLegacyGeolocationPermissionAPI",

			"("
			")"
			"Z",
			      &g_AwContents_useLegacyGeolocationPermissionAPI);

			  jboolean ret =
			      env->CallBooleanMethod(obj,arm-linux-androideabi-objdump -tT libwebviewchromium.so | grep Java_com_android_org_chromium_android_1webview_AwContents_nativeInit
001d2834 g    DF .text	000000ec Java_com_android_org_chromium_android_1webview_AwContents_nativeInit

refer the autogenerated xxx_jni.h to create the interface(c++ -> native, native -> c++)
				  method_id);
			  jni_generator::CheckException(env);
			  return ret;
			}
			//==================================
			static bool RegisterNativesImpl(JNIEnv* env) {
			//??????????????????should invoke env->RegisterNatives
			  return true;
			}

		}
		}
	]
	base/android/jni_generator/jni_generator.py
	../../base/android/jni_generator/jni_generator.py 
		--input_file ../java/src/org/chromium/android_webview/AwContents.java 
		--output_dir "/home/leliang/work/android/sourcecode/out/target/product/generic/obj/GYP/shared_intermediates/android_webview/jni" 
		--includes base/android/jni_generator/jni_generator_helper.h 
		--optimize_generation 0       
		--jarjar ../../android_webview/build/jarjar-rules.txt 
		--ptr_type long --native_exports
	out/target/product/generic/obj/GYP/shared_intermediates/android_webview/jni
		[dynamic generate callback&registar native]
		android_webview_jni_registrar.cc
===============================================================================================
GYP_HOST_MULTILIB = 32
GYP_HOST_VAR_PREFIX = 2ND_
====external/chromium_org/GypAndroid.linux-arm.mk===============================
arm-linux-androideabi-objdump -tT libwebviewchromium.so | grep Java_com_android_org_chromium_android_1webview_AwContents_nativeInit
001d2834 g    DF .text	000000ec Java_com_android_org_chromium_android_1webview_AwContents_nativeInit

refer the autogenerated xxx_jni.h to create the interface(c++ -> native, native -> c++)
=========================

https://chromium.googlesource.com/android_tools/+/master/ndk/sources/android/crazy_linker/README.TXT

The first time you call a native method like:
    'mypackage.MyClass.myNativeMethod()'
  The VM will look into existing native libraries with dlsym() for a
  function symbol named like:
    Java_mypackage_MyClass_myNativeMethod

 

 | 106,910 views | 1,006 comments | 0 flags | 

Android 5.0 WebView initialize process

下面是WebView的初始化过程,从WebView constructor 到 AwContents的constructor结束,
列出了主要类的创建,和相关库(.so)的加载过程 (base on Android 5.0.1_r1)

 | 167,401 views | 4,633 comments | 0 flags | 

学习Chromium的一点总结

学习了chromium一段时间,下面是自己的一点学习过程.

Process Model,:http://dev.chromium.org/developers/design-documents/process-models
one process for all instances of a web site, one process for each group of connected tabs, or everything in a single process.
Multi-process Architecture:
http://dev.chromium.org/developers/design-documents/multi-process-architecture

Multi-process Resource Loading:
http://dev.chromium.org/developers/design-documents/multi-process-resource-loading

Displaying a web page in chrome:
http://dev.chromium.org/developers/design-documents/displaying-a-web-page-in-chrome
the render process, Chromium’s render process embeds our WebKit port using the glue interface. It does not contain very much code: its job is primarily to be the renderer side of the IPC channel to the browser.

the Browser process,
 Note:
pay your attention to the below two part, which will help you understand how the messages handling between browser and render process.
Life of a “set cursor” message
Life of a “mouse click” message

Inter-process Communication (IPC)
http://dev.chromium.org/developers/design-documents/inter-process-communication

Content/Browser component
http://dev.chromium.org/developers/content-module
http://dev.chromium.org/developers/design-documents/browser-components

Plugin Architecture

Pepper plugin implementation
http://dev.chromium.org/developers/design-documents/pepper-plugin-implementation

pepper(PPAPI) concepts
https://code.google.com/p/ppapi/wiki/Concepts

 | 500,567 views | 11,513 comments | 0 flags | 

如何学习Android5.0 下 新的 webview 的实现。

我们知道从Android4.4开始, WebView的实现开始使用chromium,但是对外API并没有改变,但是内部的实现已经彻底改变。本文总结一下个人学习中接触的资料。

主要的资料都是来源于官网:
http://dev.chromium.org/developers
http://dev.chromium.org/developers/design-documents
相信看完官网的资料应该对新的实现很了解了,但是资料众多,总结一下入门步骤。 

了解一下chromium project的开发过程(Life of a Chromium Developer), 仅仅知道开发中用到工具即可,比如gclient, ninja…
 https://docs.google.com/presentation/d/1owPEVVzP0rLJrxSff4ncucy9G2yZ7Goxz9SJbfEBEHc/preview?slide=id.p

学习一下chromium project各个目录的介绍,
http://dev.chromium.org/developers/how-tos/getting-around-the-chrome-source-code
看完我们需要知道在chromium中有很好的分层组织结构,下层的代码决定不可以依赖上层代码(编译依赖),如果上层要调用下层的实现可以通过嵌入API(embedder API),也就是回调的方式。

重点我们还是学习Android相关Code的组织(Organization of code for Android WebView):

https://docs.google.com/document/d/1a_cUP1dGIlRQFUSic8bhAOxfclj4Xzw-yRDljVk1wB0/edit#heading=h.kpg68p8kaepe

在看完这个文档后对下图就能看懂了,也需要记住这张图,是后面学习的的必须。
下面这个链接是对这个文档的翻译,
http://blog.csdn.net/typename/article/details/40896627

 

为了有针对性的学习,现在应该是我们进一步学习一下重要类的时候了,下面这个链接里面介绍的每一个类,每一个流程都是非常重要的,多看,以便牢记于心。
http://www.it165.net/pro/html/201406/15259.html
为了做个提示,将内部重要的图摘录在下面(注意图中有些地方关系错误,不影响总体):

AwContents 的创建过程:
\" data-mce-src=
AwContents的java层和native层的结构
\" data-mce-src= WebContentsImpl 创建过程:
\" data-mce-src=
WebContentsImpl 类图:

RenderViewHostImpl与RenderViewImpl是一一对应的,他们分别对应于Browser进程和Render进程中的View表示.
Render 创建过程:
\" data-mce-src=

RenderViewImpl 通过webkit glue层实现与WebKit的连接:
\" data-mce-src=

在掌握上面的知识后,基本就入门了,这个时候就可以根据WebView的创建过程和loadUrl的流程,从源码级别学习了。

 

 

 

 

 

 

 | 633,921 views | 11,603 comments | 0 flags |