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

Commit 5a594828 authored by Alex Stetson's avatar Alex Stetson
Browse files

Allow system services to be optional

Some Android systems may not have certain system services (particularly the VirtualMachineManager). If this is the case, disable the preference rather than requiring the service and crashing the Settings app.

Bug: 388221800
Change-Id: I761054caebe3e846f5c6c76e2818662aad2cb511
Test: manual
Flag: NONE bugfix
parent 5f63dd0f
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -34,8 +34,6 @@ import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;

import java.util.Objects;

/** Preference controller for Linux terminal option in developers option */
public class LinuxTerminalPreferenceController extends DeveloperOptionsPreferenceController
        implements PreferenceControllerMixin {
@@ -59,13 +57,15 @@ public class LinuxTerminalPreferenceController extends DeveloperOptionsPreferenc
        mTerminalPackageName =
                isPackageInstalled(context.getPackageManager(), packageName) ? packageName : null;

        StorageManager storageManager =
                Objects.requireNonNull(context.getSystemService(StorageManager.class));
        StorageManager storageManager = context.getSystemService(StorageManager.class);
        VirtualMachineManager virtualMachineManager =
                Objects.requireNonNull(context.getSystemService(VirtualMachineManager.class));
                context.getSystemService(VirtualMachineManager.class);

        mIsDeviceCapable =
                getTotalMemory() >= MEMORY_MIN_BYTES
                        && storageManager != null
                        && storageManager.getPrimaryStorageSize() >= STORAGE_MIN_BYTES
                        && virtualMachineManager != null
                        && ((virtualMachineManager.getCapabilities() & CAPABILITY_NON_PROTECTED_VM)
                                != 0);
    }