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

Commit 29dbede1 authored by wescande's avatar wescande Committed by William Escande
Browse files

New API for getting enabledcomponent

Bluetooth can no longer call SystemConfig and need to use the manager.

Bug: 190440540
Bug: 199279027
Test: Manual
Tag: #refactor
Change-Id: I065ab407c83cd2edf2244e4170496b0979ac562c
parent 730b6cfb
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -7241,6 +7241,7 @@ package android.os {
  public class SystemConfigManager {
    method @NonNull @RequiresPermission(android.Manifest.permission.READ_CARRIER_APP_INFO) public java.util.Set<java.lang.String> getDisabledUntilUsedPreinstalledCarrierApps();
    method @NonNull @RequiresPermission(android.Manifest.permission.READ_CARRIER_APP_INFO) public java.util.Map<java.lang.String,java.util.List<java.lang.String>> getDisabledUntilUsedPreinstalledCarrierAssociatedApps();
    method @NonNull public java.util.List<java.lang.String> getEnabledComponentOverrides(@NonNull String);
    method @NonNull @RequiresPermission(android.Manifest.permission.GET_RUNTIME_PERMISSIONS) public int[] getSystemPermissionUids(@NonNull String);
  }
+5 −0
Original line number Diff line number Diff line
@@ -40,4 +40,9 @@ interface ISystemConfig {
     * @see SystemConfigManager#getSystemPermissionUids
     */
    int[] getSystemPermissionUids(String permissionName);

    /**
     * @see SystemConfigManager#getEnabledComponentOverrides
     */
    List<String> getEnabledComponentOverrides(String packageName);
}
+18 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ package android.os;

import android.Manifest;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
import android.annotation.SystemService;
@@ -129,4 +130,21 @@ public class SystemConfigManager {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Get enabled component for a specific package
     *
     * @param packageName The target package.
     * @return The enabled component
     * {@hide}
     */
    @SystemApi
    @NonNull
    public List<String> getEnabledComponentOverrides(@NonNull String packageName) {
        try {
            return mInterface.getEnabledComponentOverrides(packageName);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }
}
+16 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import static java.util.stream.Collectors.toMap;
import android.Manifest;
import android.content.Context;
import android.os.ISystemConfig;
import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.SparseArray;

@@ -84,6 +85,21 @@ public class SystemConfigService extends SystemService {
            }
            return ArrayUtils.convertToIntArray(uids);
        }

        @Override
        public List<String> getEnabledComponentOverrides(String packageName) {
            ArrayMap<String, Boolean> systemComponents = SystemConfig.getInstance()
                    .getComponentsEnabledStates(packageName);
            List<String> enabledComponent = new ArrayList<>();
            if (systemComponents != null) {
                for (Map.Entry<String, Boolean> entry : systemComponents.entrySet()) {
                    if (Boolean.TRUE.equals(entry.getValue())) {
                        enabledComponent.add(entry.getKey());
                    }
                }
            }
            return enabledComponent;
        }
    };

    public SystemConfigService(Context context) {