Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 265c692c authored by yuemingw's avatar yuemingw Committed by Yueming Wang
Browse files

Turn off airplane mode when DISALLOW_AIRPLANE_MODE is set.

Test: run cts --module DevicePolicyManager --test com.android.cts.devicepolicy.DeviceOwnerTest#testAirplaneModeRestriction
Bug: 67675441

Change-Id: I94b6c985fe76cc9601ac6a481beca17966102109
parent 8eb75d3d
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -1584,6 +1584,11 @@ public class SettingsProvider extends ContentProvider {
                restriction = UserManager.DISALLOW_SAFE_BOOT;
                break;

            case Settings.Global.AIRPLANE_MODE_ON:
                if ("0".equals(value)) return false;
                restriction = UserManager.DISALLOW_AIRPLANE_MODE;
                break;

            default:
                if (setting != null && setting.startsWith(Settings.Global.DATA_ROAMING)) {
                    if ("0".equals(value)) return false;
+18 −0
Original line number Diff line number Diff line
@@ -25,12 +25,14 @@ import android.annotation.Nullable;
import android.app.ActivityManager;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.os.Binder;
import android.os.Bundle;
import android.os.RemoteException;
import android.os.UserHandle;
import android.os.UserManager;
import android.os.UserManagerInternal;
import android.provider.Settings;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.util.Log;
@@ -543,6 +545,22 @@ public class UserRestrictionsUtils {
                            android.provider.Settings.Global.SAFE_BOOT_DISALLOWED,
                            newValue ? 1 : 0);
                    break;
                case UserManager.DISALLOW_AIRPLANE_MODE:
                    if (newValue) {
                        final boolean airplaneMode = Settings.Global.getInt(
                                context.getContentResolver(),
                                Settings.Global.AIRPLANE_MODE_ON, 0) == 1;
                        if (airplaneMode) {
                            android.provider.Settings.Global.putInt(
                                    context.getContentResolver(),
                                    android.provider.Settings.Global.AIRPLANE_MODE_ON, 0);
                            // Post the intent.
                            Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
                            intent.putExtra("state", 0);
                            context.sendBroadcastAsUser(intent, UserHandle.ALL);
                        }
                    }
                    break;
            }
        } finally {
            Binder.restoreCallingIdentity(id);