SlideShare uma empresa Scribd logo
1 de 14
Baixar para ler offline
Power Manager Service

        송형주
Service를 분석하기 위해 필요한 지식?

•   Thread
•   Looper – In-process message passing
              In process
•   Intent – 시스템 전체 범위의 IPC
•   Broadcast Receiver
•   Manager와 Service의 관계
Threads and Loopers
                       APK Package
                        Process
              Thread                  Local
                                      L     l
    Intent
              Looper                 Service
   Receiver
                                       Call
                             UI
   Activity                Events    Thread
                                     External
              Message                Service
   Activity    Queue       System     Calls
                           Events
HandlerThread
•   Looper를 가진 스레드를 생성하기 위한 클래스
    L     를

•   Looper를 이용하기 위해서는 핸들러를 생성해야함
                           생성해야함.
looper란?
class LooperThread extends Thread {

     p
     public Handler mHandler;
                            ;

     public void run() {
       Looper.prepare();             // 현재 스레드의 looper 초기화

         mHandler = new Handler() {
           public void handleMessage(Message msg) {
                  // process incoming messages here
              }
         };                                            핸들러 코드
         Looper.loop();         // 메시지큐 실행
     }
 }
Looper, Handler,
Looper Handler MessageQueue
                               Thread
                                                    Message Queue

                         Looper
                                         3. deque

                               4. Dispatch
1. 메시지 수신
(message, Runnable)                            2. Enque
                                               2 E
                         Handler
                       handleMessage()



                      5. 메시지 처리
Android Power Management
• S
  Support
        t
  –   screen on/off
  –   screen backlight on/off
  –   keyboard backlight on/off
  –   button backlight on/off
  –   adjust screen brightness

• Not Support
        pp
  – Sleep or Standby mode to fully use CPU’s
    capability.
Power Manager Service
           Sequence Flow
        초기화
                        power = new PowerManagerService();

                        ServiceManager.addService(Context.
PowerMangerService 등록   POWER_SERVICE, power);



                        p
                        power.init(context, hardware, 
                                  (       ,         ,
  PowerMangerService    ActivityManagerService.getDefault(
  (HandlerThread)생성     ), battery);



    System Ready
WakeLock?




PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
                                 getSystemService(Context POWER SERVICE);
PowerManager.WakeLock wl =
                 pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "My Tag");

wl.acquire();
wl acquire();
  ..screen will stay on during this section..
wl.release();
Power Management Framework
Power Manger Service 구조
                    Java Side




                     C++ Side
참고
• frameworks/base/core/jni
  – 안드로이드 런타임 관련 소스
  – Android.mk : 안드로이드 런타임 Makefile
    • output : libandroid runtime 생성
               libandroid_runtime


• A d idR ti
  AndroidRuntime::startReg(JNIEnv* env)
                   t tR (JNIE         )
  – 일반적인 JNI로 연결되는 네이티브 함수를 등
    록하는 함수
AIDL
• 데이터 마샬링/언마샬링
 – 일부 안드로이드 문서는 flattened 라는 표현
   사용

Mais conteúdo relacionado

Destaque

Taking Flight AgileDC 2014
Taking Flight AgileDC 2014Taking Flight AgileDC 2014
Taking Flight AgileDC 2014Paul Boos
 
Survey Monkey Survey Results
Survey Monkey   Survey ResultsSurvey Monkey   Survey Results
Survey Monkey Survey ResultsStephanie White
 
Copia De Loba
Copia De LobaCopia De Loba
Copia De Lobaamezola
 
Congres Duurzame Stedenbouw 7 Dec
Congres Duurzame Stedenbouw 7 DecCongres Duurzame Stedenbouw 7 Dec
Congres Duurzame Stedenbouw 7 Decolgavanderlinden
 
Hand Painted Presentation
Hand Painted PresentationHand Painted Presentation
Hand Painted Presentationkausarh
 
Econ775PP1
Econ775PP1Econ775PP1
Econ775PP1liangtfm
 
Freelance Robotics Company ProfileV1_4
Freelance Robotics Company ProfileV1_4Freelance Robotics Company ProfileV1_4
Freelance Robotics Company ProfileV1_4William Pagnon
 
Econ635 uk pres
Econ635 uk presEcon635 uk pres
Econ635 uk presliangtfm
 
In the age of good – how good is your organisation? by Stephen Pain
In the age of good – how good is your organisation? by Stephen PainIn the age of good – how good is your organisation? by Stephen Pain
In the age of good – how good is your organisation? by Stephen PainAddison Group
 
The Role Of Furniture In Higher Education Collaborative Environments
The Role Of Furniture In Higher Education Collaborative EnvironmentsThe Role Of Furniture In Higher Education Collaborative Environments
The Role Of Furniture In Higher Education Collaborative Environmentsbretfordmarketing
 
Ruby and Rails Basics
Ruby and Rails BasicsRuby and Rails Basics
Ruby and Rails BasicsArrrrCamp
 
Effective Networking for Professional Success
Effective Networking for Professional SuccessEffective Networking for Professional Success
Effective Networking for Professional SuccessBusiness Book Summaries
 
Sotsiaalse evolutsiooni teooria
Sotsiaalse evolutsiooni teooriaSotsiaalse evolutsiooni teooria
Sotsiaalse evolutsiooni teooriaHedi T
 

Destaque (20)

Languages test
Languages testLanguages test
Languages test
 
Taking Flight AgileDC 2014
Taking Flight AgileDC 2014Taking Flight AgileDC 2014
Taking Flight AgileDC 2014
 
Survey Monkey Survey Results
Survey Monkey   Survey ResultsSurvey Monkey   Survey Results
Survey Monkey Survey Results
 
Languages test
Languages testLanguages test
Languages test
 
Solicitud de vih en atencion primaria
Solicitud de vih en atencion primariaSolicitud de vih en atencion primaria
Solicitud de vih en atencion primaria
 
Copia De Loba
Copia De LobaCopia De Loba
Copia De Loba
 
Congres Duurzame Stedenbouw 7 Dec
Congres Duurzame Stedenbouw 7 DecCongres Duurzame Stedenbouw 7 Dec
Congres Duurzame Stedenbouw 7 Dec
 
Ecoglobalangusmrobinson
EcoglobalangusmrobinsonEcoglobalangusmrobinson
Ecoglobalangusmrobinson
 
Hand Painted Presentation
Hand Painted PresentationHand Painted Presentation
Hand Painted Presentation
 
Movie
MovieMovie
Movie
 
Mr t2 candida
Mr t2 candidaMr t2 candida
Mr t2 candida
 
Say no to_quit_smoking
Say no to_quit_smokingSay no to_quit_smoking
Say no to_quit_smoking
 
Econ775PP1
Econ775PP1Econ775PP1
Econ775PP1
 
Freelance Robotics Company ProfileV1_4
Freelance Robotics Company ProfileV1_4Freelance Robotics Company ProfileV1_4
Freelance Robotics Company ProfileV1_4
 
Econ635 uk pres
Econ635 uk presEcon635 uk pres
Econ635 uk pres
 
In the age of good – how good is your organisation? by Stephen Pain
In the age of good – how good is your organisation? by Stephen PainIn the age of good – how good is your organisation? by Stephen Pain
In the age of good – how good is your organisation? by Stephen Pain
 
The Role Of Furniture In Higher Education Collaborative Environments
The Role Of Furniture In Higher Education Collaborative EnvironmentsThe Role Of Furniture In Higher Education Collaborative Environments
The Role Of Furniture In Higher Education Collaborative Environments
 
Ruby and Rails Basics
Ruby and Rails BasicsRuby and Rails Basics
Ruby and Rails Basics
 
Effective Networking for Professional Success
Effective Networking for Professional SuccessEffective Networking for Professional Success
Effective Networking for Professional Success
 
Sotsiaalse evolutsiooni teooria
Sotsiaalse evolutsiooni teooriaSotsiaalse evolutsiooni teooria
Sotsiaalse evolutsiooni teooria
 

Semelhante a Power Manager Service 송형주 Rev02

Implementing remote procedure calls rev2
Implementing remote procedure calls rev2Implementing remote procedure calls rev2
Implementing remote procedure calls rev2Sung-jae Park
 
[E6]2012. netty internals
[E6]2012. netty internals[E6]2012. netty internals
[E6]2012. netty internalsNAVER D2
 
Going asynchronous with netty - SOSCON 2015
Going asynchronous with netty - SOSCON 2015Going asynchronous with netty - SOSCON 2015
Going asynchronous with netty - SOSCON 2015Kris Jeong
 
[네이버오픈소스세미나] Pinpoint를 이용해서 서버리스 플랫폼 Apache Openwhisk 트레이싱하기 - 오승현
[네이버오픈소스세미나] Pinpoint를 이용해서 서버리스 플랫폼 Apache Openwhisk 트레이싱하기 - 오승현[네이버오픈소스세미나] Pinpoint를 이용해서 서버리스 플랫폼 Apache Openwhisk 트레이싱하기 - 오승현
[네이버오픈소스세미나] Pinpoint를 이용해서 서버리스 플랫폼 Apache Openwhisk 트레이싱하기 - 오승현NAVER Engineering
 
Performance Testing using Loadrunner
Performance Testingusing LoadrunnerPerformance Testingusing Loadrunner
Performance Testing using Loadrunnerhmfive
 
Startup JavaScript 8 - NPM, Express.JS
Startup JavaScript 8 - NPM, Express.JSStartup JavaScript 8 - NPM, Express.JS
Startup JavaScript 8 - NPM, Express.JSCirculus
 
이기종 멀티코어 프로세서를 위한 프로그래밍 언어 및 영상처리 오픈소스
이기종 멀티코어 프로세서를 위한 프로그래밍 언어 및 영상처리 오픈소스이기종 멀티코어 프로세서를 위한 프로그래밍 언어 및 영상처리 오픈소스
이기종 멀티코어 프로세서를 위한 프로그래밍 언어 및 영상처리 오픈소스Seunghwa Song
 
[Hello world 오픈세미나]open api client개발
[Hello world 오픈세미나]open api client개발[Hello world 오픈세미나]open api client개발
[Hello world 오픈세미나]open api client개발NAVER D2
 
Concurrent Programming (Java thread 다루기)
Concurrent Programming (Java thread 다루기)Concurrent Programming (Java thread 다루기)
Concurrent Programming (Java thread 다루기)JungGeun Lee
 
[OpenStack Days Korea 2016] Track1 - Monasca를 이용한 Cloud 모니터링
[OpenStack Days Korea 2016] Track1 - Monasca를 이용한 Cloud 모니터링[OpenStack Days Korea 2016] Track1 - Monasca를 이용한 Cloud 모니터링
[OpenStack Days Korea 2016] Track1 - Monasca를 이용한 Cloud 모니터링OpenStack Korea Community
 
Monasca 를 이용한 cloud 모니터링 final
Monasca 를 이용한 cloud 모니터링 finalMonasca 를 이용한 cloud 모니터링 final
Monasca 를 이용한 cloud 모니터링 finalSangWook Byun
 
Nodejs, PhantomJS, casperJs, YSlow, expressjs
Nodejs, PhantomJS, casperJs, YSlow, expressjsNodejs, PhantomJS, casperJs, YSlow, expressjs
Nodejs, PhantomJS, casperJs, YSlow, expressjs기동 이
 
SQL-on-Hadoop with Apache Tajo, and application case of SK Telecom
SQL-on-Hadoop with Apache Tajo,  and application case of SK TelecomSQL-on-Hadoop with Apache Tajo,  and application case of SK Telecom
SQL-on-Hadoop with Apache Tajo, and application case of SK TelecomGruter
 
11st Legacy Application의 Spring Cloud 기반 MicroServices로 전환 개발 사례
11st Legacy Application의 Spring Cloud 기반 MicroServices로 전환 개발 사례11st Legacy Application의 Spring Cloud 기반 MicroServices로 전환 개발 사례
11st Legacy Application의 Spring Cloud 기반 MicroServices로 전환 개발 사례YongSung Yoon
 
Introduction to Fork Join Framework_SYS4U I&C
Introduction to Fork Join Framework_SYS4U I&CIntroduction to Fork Join Framework_SYS4U I&C
Introduction to Fork Join Framework_SYS4U I&Csys4u
 
Fluentd with MySQL
Fluentd with MySQLFluentd with MySQL
Fluentd with MySQLI Goo Lee
 
Easy gameserver
Easy gameserverEasy gameserver
Easy gameserver진상 문
 

Semelhante a Power Manager Service 송형주 Rev02 (20)

Implementing remote procedure calls rev2
Implementing remote procedure calls rev2Implementing remote procedure calls rev2
Implementing remote procedure calls rev2
 
[E6]2012. netty internals
[E6]2012. netty internals[E6]2012. netty internals
[E6]2012. netty internals
 
Clean code appendix 1
Clean code appendix 1Clean code appendix 1
Clean code appendix 1
 
Going asynchronous with netty - SOSCON 2015
Going asynchronous with netty - SOSCON 2015Going asynchronous with netty - SOSCON 2015
Going asynchronous with netty - SOSCON 2015
 
[네이버오픈소스세미나] Pinpoint를 이용해서 서버리스 플랫폼 Apache Openwhisk 트레이싱하기 - 오승현
[네이버오픈소스세미나] Pinpoint를 이용해서 서버리스 플랫폼 Apache Openwhisk 트레이싱하기 - 오승현[네이버오픈소스세미나] Pinpoint를 이용해서 서버리스 플랫폼 Apache Openwhisk 트레이싱하기 - 오승현
[네이버오픈소스세미나] Pinpoint를 이용해서 서버리스 플랫폼 Apache Openwhisk 트레이싱하기 - 오승현
 
Performance Testing using Loadrunner
Performance Testingusing LoadrunnerPerformance Testingusing Loadrunner
Performance Testing using Loadrunner
 
Startup JavaScript 8 - NPM, Express.JS
Startup JavaScript 8 - NPM, Express.JSStartup JavaScript 8 - NPM, Express.JS
Startup JavaScript 8 - NPM, Express.JS
 
이기종 멀티코어 프로세서를 위한 프로그래밍 언어 및 영상처리 오픈소스
이기종 멀티코어 프로세서를 위한 프로그래밍 언어 및 영상처리 오픈소스이기종 멀티코어 프로세서를 위한 프로그래밍 언어 및 영상처리 오픈소스
이기종 멀티코어 프로세서를 위한 프로그래밍 언어 및 영상처리 오픈소스
 
[Hello world 오픈세미나]open api client개발
[Hello world 오픈세미나]open api client개발[Hello world 오픈세미나]open api client개발
[Hello world 오픈세미나]open api client개발
 
Concurrent Programming (Java thread 다루기)
Concurrent Programming (Java thread 다루기)Concurrent Programming (Java thread 다루기)
Concurrent Programming (Java thread 다루기)
 
[OpenStack Days Korea 2016] Track1 - Monasca를 이용한 Cloud 모니터링
[OpenStack Days Korea 2016] Track1 - Monasca를 이용한 Cloud 모니터링[OpenStack Days Korea 2016] Track1 - Monasca를 이용한 Cloud 모니터링
[OpenStack Days Korea 2016] Track1 - Monasca를 이용한 Cloud 모니터링
 
Monasca 를 이용한 cloud 모니터링 final
Monasca 를 이용한 cloud 모니터링 finalMonasca 를 이용한 cloud 모니터링 final
Monasca 를 이용한 cloud 모니터링 final
 
Nodejs, PhantomJS, casperJs, YSlow, expressjs
Nodejs, PhantomJS, casperJs, YSlow, expressjsNodejs, PhantomJS, casperJs, YSlow, expressjs
Nodejs, PhantomJS, casperJs, YSlow, expressjs
 
SQL-on-Hadoop with Apache Tajo, and application case of SK Telecom
SQL-on-Hadoop with Apache Tajo,  and application case of SK TelecomSQL-on-Hadoop with Apache Tajo,  and application case of SK Telecom
SQL-on-Hadoop with Apache Tajo, and application case of SK Telecom
 
11st Legacy Application의 Spring Cloud 기반 MicroServices로 전환 개발 사례
11st Legacy Application의 Spring Cloud 기반 MicroServices로 전환 개발 사례11st Legacy Application의 Spring Cloud 기반 MicroServices로 전환 개발 사례
11st Legacy Application의 Spring Cloud 기반 MicroServices로 전환 개발 사례
 
YARN overview
YARN overviewYARN overview
YARN overview
 
Introduction to Fork Join Framework_SYS4U I&C
Introduction to Fork Join Framework_SYS4U I&CIntroduction to Fork Join Framework_SYS4U I&C
Introduction to Fork Join Framework_SYS4U I&C
 
Fluentd with MySQL
Fluentd with MySQLFluentd with MySQL
Fluentd with MySQL
 
L4교육자료
L4교육자료L4교육자료
L4교육자료
 
Easy gameserver
Easy gameserverEasy gameserver
Easy gameserver
 

Mais de iamhjoo (송형주)

AR/VR 기술 트렌드와 Immersive Web 동향
AR/VR 기술 트렌드와 Immersive Web 동향AR/VR 기술 트렌드와 Immersive Web 동향
AR/VR 기술 트렌드와 Immersive Web 동향iamhjoo (송형주)
 
안드로이드 멀티스레딩 입문 송형주
안드로이드 멀티스레딩 입문 송형주안드로이드 멀티스레딩 입문 송형주
안드로이드 멀티스레딩 입문 송형주iamhjoo (송형주)
 
Kernel 2.6 makefile_분석(송형주)
Kernel 2.6 makefile_분석(송형주)Kernel 2.6 makefile_분석(송형주)
Kernel 2.6 makefile_분석(송형주)iamhjoo (송형주)
 
안드로이드 스터디 Jni 발표 자료 Rev05 송형주
안드로이드 스터디 Jni 발표 자료 Rev05 송형주안드로이드 스터디 Jni 발표 자료 Rev05 송형주
안드로이드 스터디 Jni 발표 자료 Rev05 송형주iamhjoo (송형주)
 
About Init In Android By Andstudy
About Init In Android By AndstudyAbout Init In Android By Andstudy
About Init In Android By Andstudyiamhjoo (송형주)
 

Mais de iamhjoo (송형주) (9)

AR/VR 기술 트렌드와 Immersive Web 동향
AR/VR 기술 트렌드와 Immersive Web 동향AR/VR 기술 트렌드와 Immersive Web 동향
AR/VR 기술 트렌드와 Immersive Web 동향
 
안드로이드 멀티스레딩 입문 송형주
안드로이드 멀티스레딩 입문 송형주안드로이드 멀티스레딩 입문 송형주
안드로이드 멀티스레딩 입문 송형주
 
Second.s 분석 by_송형주
Second.s 분석 by_송형주Second.s 분석 by_송형주
Second.s 분석 by_송형주
 
Kernel 2.6 makefile_분석(송형주)
Kernel 2.6 makefile_분석(송형주)Kernel 2.6 makefile_분석(송형주)
Kernel 2.6 makefile_분석(송형주)
 
Flow control in node.js
Flow control in node.jsFlow control in node.js
Flow control in node.js
 
Flow Control in Node.js
Flow Control in Node.jsFlow Control in Node.js
Flow Control in Node.js
 
안드로이드 스터디 Jni 발표 자료 Rev05 송형주
안드로이드 스터디 Jni 발표 자료 Rev05 송형주안드로이드 스터디 Jni 발표 자료 Rev05 송형주
안드로이드 스터디 Jni 발표 자료 Rev05 송형주
 
Bootchart 송형주
Bootchart 송형주Bootchart 송형주
Bootchart 송형주
 
About Init In Android By Andstudy
About Init In Android By AndstudyAbout Init In Android By Andstudy
About Init In Android By Andstudy
 

Power Manager Service 송형주 Rev02

  • 2. Service를 분석하기 위해 필요한 지식? • Thread • Looper – In-process message passing In process • Intent – 시스템 전체 범위의 IPC • Broadcast Receiver • Manager와 Service의 관계
  • 3. Threads and Loopers APK Package Process Thread Local L l Intent Looper Service Receiver Call UI Activity Events Thread External Message Service Activity Queue System Calls Events
  • 4. HandlerThread • Looper를 가진 스레드를 생성하기 위한 클래스 L 를 • Looper를 이용하기 위해서는 핸들러를 생성해야함 생성해야함.
  • 5. looper란? class LooperThread extends Thread { p public Handler mHandler; ; public void run() { Looper.prepare(); // 현재 스레드의 looper 초기화 mHandler = new Handler() { public void handleMessage(Message msg) { // process incoming messages here } }; 핸들러 코드 Looper.loop(); // 메시지큐 실행 } }
  • 6. Looper, Handler, Looper Handler MessageQueue Thread Message Queue Looper 3. deque 4. Dispatch 1. 메시지 수신 (message, Runnable) 2. Enque 2 E Handler handleMessage() 5. 메시지 처리
  • 7.
  • 8. Android Power Management • S Support t – screen on/off – screen backlight on/off – keyboard backlight on/off – button backlight on/off – adjust screen brightness • Not Support pp – Sleep or Standby mode to fully use CPU’s capability.
  • 9. Power Manager Service Sequence Flow 초기화 power = new PowerManagerService(); ServiceManager.addService(Context. PowerMangerService 등록 POWER_SERVICE, power); p power.init(context, hardware,  ( , , PowerMangerService ActivityManagerService.getDefault( (HandlerThread)생성 ), battery); System Ready
  • 10. WakeLock? PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); getSystemService(Context POWER SERVICE); PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "My Tag"); wl.acquire(); wl acquire(); ..screen will stay on during this section.. wl.release();
  • 12. Power Manger Service 구조 Java Side C++ Side
  • 13. 참고 • frameworks/base/core/jni – 안드로이드 런타임 관련 소스 – Android.mk : 안드로이드 런타임 Makefile • output : libandroid runtime 생성 libandroid_runtime • A d idR ti AndroidRuntime::startReg(JNIEnv* env) t tR (JNIE ) – 일반적인 JNI로 연결되는 네이티브 함수를 등 록하는 함수
  • 14. AIDL • 데이터 마샬링/언마샬링 – 일부 안드로이드 문서는 flattened 라는 표현 사용