1. 接收客户发送的USB枚举事件通知,并做出枚举或退出
frameworks/base/services/java/com/android/server/MountService.java
在handleSystemReady函数中,添加
if (mStorageManager == null) {
mStorageManager = (StorageManager) mContext.getSystemService(Context.STORAGE_SERVICE);
if (mStorageManager == null) {
Slog.e(TAG, "Failed to get StorageManager");
}
}
final IntentFilter usbfilter = new IntentFilter();
usbfilter.addAction("com.cld.action.OPEN_UMS");
usbfilter.addAction("com.cld.action.CLOSE_UMS");
mContext.registerReceiver(UsbBroadcastReceiver, usbfilter);
添加消息处理函数UsbBroadcastReceiver
final BroadcastReceiver UsbBroadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
final String action = intent.getAction();
if ("com.cld.action.OPEN_UMS".equals(action)) {
if (mStorageManager != null) {
mStorageManager.enableUsbMassStorage();
}
}
else if ("com.cld.action.CLOSE_UMS".equals(action)) {
if (mStorageManager != null) {
mStorageManager.disableUsbMassStorage();
}
}
}
};
2. 长按关机键时,不弹出关机类型选择框,改为发送事件通知
frameworks/base/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS);
//showGlobalActionsDialog();
Intent intent = new Intent("com.android.power.longpress");
mContext.sendBroadcast(intent);
break;
3. 接收apk的关机广播并关机
frameworks/base/services/java/com/android/server/wm/WindowManagerService.java
WindowManagerService 函数中注册消息接收
// Track changes to DevicePolicyManager state so we can enable/disable keyguard.
IntentFilter filter = new IntentFilter();
filter.addAction("com.android.power.poweroff");
mContext.registerReceiver(BroadcastReceiver, filter);
final BroadcastReceiver BroadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
final String action = intent.getAction();
if ("com.android.power.poweroff".equals(action)) {
shutdown(false);
}
}
};
4. 去掉关机提示框,改为发送广播
frameworks/base/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
private final Runnable mPowerLongPress = new Runnable()函数
case LONG_PRESS_POWER_GLOBAL_ACTIONS:
mPowerKeyHandled = true;
if (!performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false)) {
performAuditoryFeedbackForAccessibilityIfNeed();
}
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS);
//showGlobalActionsDialog();
Intent inten
frameworks/base/services/java/com/android/server/MountService.java
在handleSystemReady函数中,添加
if (mStorageManager == null) {
mStorageManager = (StorageManager) mContext.getSystemService(Context.STORAGE_SERVICE);
if (mStorageManager == null) {
Slog.e(TAG, "Failed to get StorageManager");
}
}
final IntentFilter usbfilter = new IntentFilter();
usbfilter.addAction("com.cld.action.OPEN_UMS");
usbfilter.addAction("com.cld.action.CLOSE_UMS");
mContext.registerReceiver(UsbBroadcastReceiver, usbfilter);
添加消息处理函数UsbBroadcastReceiver
final BroadcastReceiver UsbBroadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
final String action = intent.getAction();
if ("com.cld.action.OPEN_UMS".equals(action)) {
if (mStorageManager != null) {
mStorageManager.enableUsbMassStorage();
}
}
else if ("com.cld.action.CLOSE_UMS".equals(action)) {
if (mStorageManager != null) {
mStorageManager.disableUsbMassStorage();
}
}
}
};
2. 长按关机键时,不弹出关机类型选择框,改为发送事件通知
frameworks/base/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS);
//showGlobalActionsDialog();
Intent intent = new Intent("com.android.power.longpress");
mContext.sendBroadcast(intent);
break;
3. 接收apk的关机广播并关机
frameworks/base/services/java/com/android/server/wm/WindowManagerService.java
WindowManagerService 函数中注册消息接收
// Track changes to DevicePolicyManager state so we can enable/disable keyguard.
IntentFilter filter = new IntentFilter();
filter.addAction("com.android.power.poweroff");
mContext.registerReceiver(BroadcastReceiver, filter);
final BroadcastReceiver BroadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
final String action = intent.getAction();
if ("com.android.power.poweroff".equals(action)) {
shutdown(false);
}
}
};
4. 去掉关机提示框,改为发送广播
frameworks/base/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
private final Runnable mPowerLongPress = new Runnable()函数
case LONG_PRESS_POWER_GLOBAL_ACTIONS:
mPowerKeyHandled = true;
if (!performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false)) {
performAuditoryFeedbackForAccessibilityIfNeed();
}
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS);
//showGlobalActionsDialog();
Intent inten