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

Commit 082f20d7 authored by wescande's avatar wescande
Browse files

replace hidden api call to SystemConfig

Use SystemConfigManager instead, and create associated api

Bug: 190440540
Test: Manual
Tag: #refactor
Change-Id: I62dd1a6afa698e0e30a6232223dfcc47cff82341
parent 7d644700
Loading
Loading
Loading
Loading
+6 −22
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.bluetooth.BluetoothProfile;
import android.content.ContentResolver;
import android.content.Context;
import android.content.res.Resources;
import android.os.SystemConfigManager;
import android.os.SystemProperties;
import android.provider.Settings;
import android.text.TextUtils;
@@ -46,11 +47,9 @@ import com.android.bluetooth.pbap.BluetoothPbapService;
import com.android.bluetooth.pbapclient.PbapClientService;
import com.android.bluetooth.sap.SapService;
import com.android.bluetooth.vc.VolumeControlService;
import com.android.server.SystemConfig;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class Config {
    private static final String TAG = "AdapterServiceConfig";
@@ -127,8 +126,7 @@ public class Config {
        if (resources == null) {
            return;
        }
        List<String> enabledProfiles =
                getSystemConfigEnabledProfilesForPackage(ctx.getPackageName());
        List<String> enabledProfiles = getSystemConfigEnabledProfilesForPackage(ctx);

        ArrayList<Class> profiles = new ArrayList<>(PROFILE_SERVICES_AND_FLAGS.length);
        for (ProfileConfig config : PROFILE_SERVICES_AND_FLAGS) {
@@ -214,25 +212,11 @@ public class Config {
        return false;
    }

    private static List<String> getSystemConfigEnabledProfilesForPackage(String packageName) {
        SystemConfig systemConfig = SystemConfig.getInstance();
        if (systemConfig == null) {
    private static List<String> getSystemConfigEnabledProfilesForPackage(Context ctx) {
        SystemConfigManager systemConfigManager = ctx.getSystemService(SystemConfigManager.class);
        if (systemConfigManager == null) {
            return null;
        }

        android.util.ArrayMap<String, Boolean> componentEnabledStates =
                systemConfig.getComponentsEnabledStates(packageName);
        if (componentEnabledStates == null) {
            return null;
        }

        ArrayList enabledProfiles = new ArrayList<String>();
        for (Map.Entry<String, Boolean> entry : componentEnabledStates.entrySet()) {
            if (entry.getValue()) {
                enabledProfiles.add(entry.getKey());
            }
        }

        return enabledProfiles;
        return systemConfigManager.getEnabledComponentOverrides(ctx.getPackageName());
    }
}