一种屏蔽系统下拉菜单的方式
导语
Android操作系统下禁用通知栏下拉功能一般使用反射调用StatusBarManager类中函数实现,但该方式需应用具有系统权限。本文介绍的方式采用修改framework层,绕过系统权限检查的方式实现。
一、禁用通知栏下拉功能
查看系统源码: /frameworks/base/core/java/android/app/StatusBarManager.java
/**
* Disable some features in the status bar. Pass the bitwise-or of the DISABLE_flags.
* To re-enable everything, pass {@link #DISABLE_NONE}.
*/
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);
}
}
根据其中 disable 函数,采用反射方式禁用下拉菜单,源码如下:
public static final int STATUS_BAR_DISAB