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

Commit 38f522ed authored by weichinweng's avatar weichinweng
Browse files

Use component flag to configure profile support flag.

Previously, the profile support flag is configure by the overlay final
value. This CL is add the logic to load system config value to configure
the profile support flag.

Bug: 135048762
Bug: 143265752
Test: Check whether the SAP feature is working fine.

Change-Id: If85812a44f6c791c3256d675d5b9be5c93d8e160
parent 06ce8359
Loading
Loading
Loading
Loading
+14 −0
Original line number Original line Diff line number Diff line
@@ -21,6 +21,7 @@ import android.content.ContentResolver;
import android.content.Context;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.Resources;
import android.provider.Settings;
import android.provider.Settings;
import android.util.ArrayMap;
import android.util.FeatureFlagUtils;
import android.util.FeatureFlagUtils;
import android.util.Log;
import android.util.Log;


@@ -42,6 +43,7 @@ import com.android.bluetooth.pan.PanService;
import com.android.bluetooth.pbap.BluetoothPbapService;
import com.android.bluetooth.pbap.BluetoothPbapService;
import com.android.bluetooth.pbapclient.PbapClientService;
import com.android.bluetooth.pbapclient.PbapClientService;
import com.android.bluetooth.sap.SapService;
import com.android.bluetooth.sap.SapService;
import com.android.server.SystemConfig;


import java.util.ArrayList;
import java.util.ArrayList;


@@ -112,6 +114,11 @@ public class Config {
        if (resources == null) {
        if (resources == null) {
            return;
            return;
        }
        }
        SystemConfig systemConfig = SystemConfig.getInstance();
        ArrayMap<String, Boolean> componentEnabledStates = null;
        if (systemConfig != null) {
            componentEnabledStates = systemConfig.getComponentsEnabledStates(ctx.getPackageName());
        }


        ArrayList<Class> profiles = new ArrayList<>(PROFILE_SERVICES_AND_FLAGS.length);
        ArrayList<Class> profiles = new ArrayList<>(PROFILE_SERVICES_AND_FLAGS.length);
        for (ProfileConfig config : PROFILE_SERVICES_AND_FLAGS) {
        for (ProfileConfig config : PROFILE_SERVICES_AND_FLAGS) {
@@ -123,6 +130,13 @@ public class Config {
                supported = true;
                supported = true;
            }
            }


            if (componentEnabledStates != null
                    && componentEnabledStates.containsKey(config.mClass.getName())) {
                supported = componentEnabledStates.get(config.mClass.getName());
                Log.v(TAG, config.mClass.getSimpleName() + " Feature Flag set to " + supported
                        + " by components configuration");
            }

            if (supported && !isProfileDisabled(ctx, config.mMask)) {
            if (supported && !isProfileDisabled(ctx, config.mMask)) {
                Log.v(TAG, "Adding " + config.mClass.getSimpleName());
                Log.v(TAG, "Adding " + config.mClass.getSimpleName());
                profiles.add(config.mClass);
                profiles.add(config.mClass);