`
helpbs
  • 浏览: 1163032 次
文章分类
社区版块
存档分类
最新评论

android中对服务的应用管理

 
阅读更多

在android的组织结构图中,可以看到,在service的上一层为manager层,包括activitymanager, windowmanager, packagemanager, telephonymanager, resourcemanager, locationmanager, notificationmanager.

至于这个结构图中的manager和实际中的service是否一一对应,还要看。

现在一个个的来找对应。

1 statusbarservice 对应statusbarmanager

/frameworks/base/core/java/android/app/StatusBarManager.java

在statusbarmanager的构造函数中,会实例化一个IStatusBar mService,同时向外暴露几个接口,

disable, expand, collapse, toggle, addIcon, updateIcon ,removeIcon,这几个向外暴露的方法都是通过调用mService的方法,也即是statusbarservice中的方法来实现。

SDK中并没有找到该类,可见该类并没有暴露给用户使用,只是给android内部使用。

2. powermanagerservice与powermanager对应

通过powermanager向外暴露接口。具体的接口用法,用途可以看响应的方法注释。

SDK中可以看到其类 android.os.PowerManager

其中说明用途的一句:This class gives you control of the power state of the device.

具体的使用可以看SDK的说明。

3. ActivityManagerService这里的对应实现方法有区别,ActivityManagerService是通过继承binder的类ActivityManagerNative来实现的。

ActivityManagerService与ActivityManager相对应。ActivityManager向外暴露接口方法。

SDK中有其类 , android.app.ActivityManager 提供给用户使用。

说明 :Interact with the overall activities running in the system. 具体的用法参见SDK。

4.TelephonyRegistry对应暴露的接口的manager没有找到,也许没有暴露,也许通过其他的方法。

5.PackageManagerService.java 与PackageManager.java

/frameworks/base/core/java/android/content/pm/PackageManager.java

SDK:android.content.pm.PackageManager 抽象类

SDK中注释:

Class for retrieving various kinds of information related to the application packages that are currently installed on the device. You can find this class throughgetPackageManager().

6.ContentService

没有找到对应的manager,可能由provider提供接口。

7.BatteryService 对应BatteryManager

SDK:android.os.BatteryManager

SDK中注释:

The BatteryManager class contains strings and constants used for values in theACTION_BATTERY_CHANGEDIntent.

8.HardwareService 没有找到对应的类来暴露其接口,可能没有做

9.AlarmManagerService对应AlarmManager.java

/frameworks/base/core/java/android/app/AlarmManager.java

SDK:android.app.AlarmManager

SDK中注释:This class provides access to the system alarm services. These allow you to schedule your application to be run at some point in the future.

10.SensorService 对应 SensorManager.java

/frameworks/base/core/java/android/hardware/SensorManager.java

SDK:android.hardware.SensorManager

SDK中注释:Class that lets you access the device's sensors. Get an instance of this class by callingContext.getSystemService()with an argument ofSENSOR_SERVICE.

11.WindowManagerService 对应 WindowManager.java

/frameworks/base/core/java/android/view/WindowManager.java

SDK:android.view.WindowManager 接口

SDK中注释:

The interface that apps use to talk to the window manager.

UseContext.getSystemService(Context.WINDOW_SERVICE)to get one of these.

12. BluetoothDeviceService对应 BluetoothDevice(待验证)

13.StatusBarService对应StatusBarManager

SDK中没有

14.ClipboardService 对应ClipboardManager.java

/frameworks/base/core/java/android/text/ClipboardManager.java

SDK: android.text.ClipboardManager

SDK中注释:

Interface to the clipboard service, for placing and retrieving text in the global clipboard.

You do not instantiate this class directly; instead, retrieve it throughgetSystemService(String).

15.InputMethodManagerService对应InputMethodManager

frameworks/base/core/java/android/view/inputmethod/InputMethodManager.java

SDK中居然没有!!

16.NetStatService NetStat.java

frameworks/base/core/java/android/os/NetStat.java

SDK中没有。

17.ConnectivityService ConnectivityManager.java

/frameworks/base/core/java/android/net/ConnectivityManager.java

SDK: android.net.ConnectivityManager

SDK中注释:

Class that answers queries about the state of network connectivity. It also notifies applications when network connectivity changes. Get an instance of this class by callingContext.getSystemService(Context.CONNECTIVITY_SERVICE).

The primary responsibilities of this class are to:

  1. Monitor network connections (Wi-Fi, GPRS, UMTS, etc.)
  2. Send broadcast intents when network connectivity changes
  3. Attempt to "fail over" to another network when connectivity to a network is lost
  4. Provide an API that allows applications to query the coarse-grained or fine-grained state of the available networks

18.AccessibilityManagerService AccessibilityManager.java

/frameworks/base/core/java/android/view/accessibility/AccessibilityManager.java

SDK中没有。

19. NotificationManagerService NotificationManage

SDK: android.app.NotificationManager

SDK中注释:

Class to notify the user of events that happen. This is how you tell the user that something has happened in the background.

Notifications can take different forms:

  • A persistent icon that goes in the status bar and is accessible through the launcher, (when the user selects it, a designated Intent can be launched),
  • Turning on or flashing LEDs on the device, or
  • Alerting the user by flashing the backlight, playing a sound, or vibrating.

20.MountService 没有找到对应

21.DeviceStorageMonitorService 没有找到对应

22. LocationManagerService 没有对应,自身就是一个manager

23.SearchManagerService SearchManager.java

SDK:android.app.SearchManager

SDK中注释:

This class provides access to the system search services.

In practice, you won't interact with this class directly, as search services are provided through methods inActivitymethods and the theACTION_SEARCHIntent. This class does provide a basic overview of search services and how to integrate them with your activities. If you do require direct access to the SearchManager, do not instantiate this class directly; instead, retrieve it throughcontext.getSystemService(Context.SEARCH_SERVICE).

24.WallpaperService

25.AudioService

26.BackupManagerService

27. AppWidgetService 对应 AppWidgetManager.java

SDK中没有

以上为android提供的基本service,也许有对应的manager向外暴露接口,也许有对应的provider提供数据,也许没有暴露,需要用到的时候进一步查看。

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics