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
This commit is contained in:
wescande
2021-09-03 12:57:46 +02:00
committed by William Escande
parent 730b6cfbc1
commit 29dbede144
4 changed files with 40 additions and 0 deletions

View File

@@ -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);
}

View File

@@ -40,4 +40,9 @@ interface ISystemConfig {
* @see SystemConfigManager#getSystemPermissionUids
*/
int[] getSystemPermissionUids(String permissionName);
/**
* @see SystemConfigManager#getEnabledComponentOverrides
*/
List<String> getEnabledComponentOverrides(String packageName);
}

View File

@@ -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();
}
}
}

View File

@@ -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) {