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

Commit 633ea28c authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "replace hidden api call to SystemConfig"

parents 0b75bd6a 082f20d7
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;
@@ -47,11 +48,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";
@@ -131,8 +130,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) {
@@ -218,25 +216,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());
    }
}