ForceDozeService.java 文件源码

java
阅读 24 收藏 0 点赞 0 评论 0

项目:ForceDoze 作者:
public void setMobileNetwork(Context context, int targetState) {

        if (!Utils.isReadPhoneStatePermissionGranted(context)) {
            grantReadPhoneStatePermission();
        }

        String command;
        try {
            String transactionCode = getTransactionCode(context);
            SubscriptionManager mSubscriptionManager = (SubscriptionManager) context.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE);
            for (int i = 0; i < mSubscriptionManager.getActiveSubscriptionInfoCountMax(); i++) {
                if (transactionCode != null && transactionCode.length() > 0) {
                    int subscriptionId = mSubscriptionManager.getActiveSubscriptionInfoList().get(i).getSubscriptionId();
                    command = "service call phone " + transactionCode + " i32 " + subscriptionId + " i32 " + targetState;
                    List<String> output = Shell.SU.run(command);
                    if (output != null) {
                        for (String s : output) {
                            Log.i(TAG, s);
                        }
                    } else {
                        Log.i(TAG, "Error occurred while executing command (" + command + ")");
                    }
                }
            }
        } catch (Exception e) {
            Log.i(TAG, "Failed to toggle mobile data: " + e.getMessage());
        }
    }
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号