4.3
状态来对外提供:
1>:展开状态栏的下拉通知栏
2>:展开状态栏的下拉快捷设置
3>:收起状态栏的下拉栏
具体:
1:
frameworks/base/core/java/android/app/StatusBarManager.java
/**
* Allows an app to control the status bar.
*
* @hide
*/
public class StatusBarManager {
.........................................................
private Context mContext;
private IStatusBarService mService;
private IBinder mToken = new Binder();
StatusBarManager(Context context) {
mContext = context;
}
private synchronized IStatusBarService getService() {
if (mService == null) {
mService = IStatusBarService.Stub.asInterface(
ServiceManager.getService(Context.STATUS_BAR_SERVICE));
if (mService == null) {
Slog.w("StatusBarManager", "warning: no STATUS_BAR_SERVICE");
}
}
return mService;
}
public void disable(int what) {
try {
final IStatusBarService svc = getService();
if (svc != null) {
svc.disable(what, mToken, mContext.getPackageName());
}
} catch (RemoteException ex) {
// system process is dead anyway.
throw new RuntimeException(ex);
}
}
/**
*1>
*/
public void expandNotificationsPanel() {
try {
final IStatusBarService svc = getService();
if (svc != null) {
svc.expandNotificationsPanel();
}
} catch (RemoteException ex) {
// system process is dead anyway.
throw new RuntimeException(ex);
}
}
/**
*2>
*/
public void collapsePanels() {
try {
final IStatusBarService svc = getService();
if (svc != null) {
svc.collapsePanels();
}
} catch (RemoteException ex) {
// system process is dead anyway.
throw new RuntimeException(ex);
}
}
/**
*3>
*/
public void expandSettingsPanel() {
try {
final IStatusBarService svc = getService();
if (svc != null) {
svc.expandSettingsPanel();
}
} catch (RemoteException ex) {
// system process is dead anyway.
throw new RuntimeException(ex);
}
}
public void setIcon(String slot, int iconId, int iconLevel, String contentDescription) {
try {
final IStatusBarService svc = getService();
if (svc != null) {
svc.setIcon(slot, mContext.getPackageName(), iconId, iconLevel,
contentDescription);
}
} catch (RemoteException ex) {
// system process is dead anyway.
throw new RuntimeException(ex);
}
}
public void removeIcon(String slot) {
try {
final IStatusBarService svc = getService();
if (svc != null) {
svc.removeIcon(slot);
}
} catch (RemoteException ex) {
// system process is dead anyway.
throw new RuntimeException(ex);
}
}
public void setIconVisibility(String slot, boolean visible) {
try {
final IStatusBarService svc = getService();
if (svc != null) {
svc.setIconVisibility(slot, visible);
}
} catch (RemoteException ex) {
// system process is dead anyway.
throw new RuntimeException(ex);
}
}
}
2:调用
frameworks/base/services/java/com/android/server
public class StatusBarManagerService extends IStatusBarService.Stub
implements WindowManagerService.OnHardKeyboardStatusChangeListener
{
volatile IStatusBar mBar;
..................................................
// ================================================================================
// From IStatusBarService
// ================================================================================
public void expandNotificationsPanel() {
enforceExpandStatusBar();
if (mBar != null) {
try {
mBar.animateExpandNotificationsPanel();
} catch (RemoteException ex) {
}
}
}
public void collapsePanels() {
enforceExpandStatusBar();
if (mBar != null) {
try {
mBar.animateCollapsePanels();
} catch (RemoteException ex) {
}
}
}
public void expandSettingsPanel() {
enforceExpandStatusBar();
if (mBar != null) {
try {
mBar.animateExpandSettingsPanel();
} catch (RemoteException ex) {
}
}
}
........................................................................
}
3:实际调用
frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/
public class PhoneStatusBar extends BaseStatusBar {
......
animateExpandNotificationsPanel()
.............
animateExpandSettingsPanel()
..........
}
4:外部使用方式
1>:
StatusBarManager statusBarManager = (StatusBarManager) mContext.getSystemService(
android.app.Service.STATUS_BAR_SERVICE);
statusBarManager.expandNotificationsPanel();