android应用层相关设置及命令(二)

本文详细介绍了在Android应用层进行的各种定制,包括USB枚举事件处理、长按关机键行为、接收到APK关机广播后的响应、adb调试开关调整、GPS和屏幕亮度设置、root权限获取、APN设置权限开放、系统默认开启agps、白名单机制实现、EPO配置以及移动数据默认开启等。这些操作涉及系统服务、广播接收器、权限管理和配置文件修改等多个方面。
摘要由CSDN通过智能技术生成
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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值