| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
package android.os; |
| 17 |
|
| 18 |
import android.Manifest; |
| 19 |
import android.annotation.NonNull; |
| 20 |
import android.annotation.RequiresPermission; |
| 21 |
import android.annotation.SystemApi; |
| 22 |
import android.annotation.SystemService; |
| 23 |
import android.content.ComponentName; |
| 24 |
import android.content.Context; |
| 25 |
import android.util.ArraySet; |
| 26 |
import android.util.Log; |
| 27 |
|
| 28 |
import java.util.Collections; |
| 29 |
import java.util.List; |
| 30 |
import java.util.Map; |
| 31 |
import java.util.Set; |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
@SystemApi |
| 43 |
@SystemService(Context.SYSTEM_CONFIG_SERVICE) |
| 44 |
public class SystemConfigManager { |
| 45 |
private static final String TAG = SystemConfigManager.class.getSimpleName(); |
| 46 |
|
| 47 |
private final ISystemConfig mInterface; |
| 48 |
|
| 49 |
|
| 50 |
public SystemConfigManager() { |
| 51 |
mInterface = ISystemConfig.Stub.asInterface( |
| 52 |
ServiceManager.getService(Context.SYSTEM_CONFIG_SERVICE)); |
| 53 |
} |
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
@RequiresPermission(Manifest.permission.READ_CARRIER_APP_INFO) |
| 61 |
public @NonNull Set<String> getDisabledUntilUsedPreinstalledCarrierApps() { |
| 62 |
try { |
| 63 |
List<String> apps = mInterface.getDisabledUntilUsedPreinstalledCarrierApps(); |
| 64 |
return new ArraySet<>(apps); |
| 65 |
} catch (RemoteException e) { |
| 66 |
Log.e(TAG, "Caught remote exception"); |
| 67 |
return Collections.emptySet(); |
| 68 |
} |
| 69 |
} |
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
@RequiresPermission(Manifest.permission.READ_CARRIER_APP_INFO) |
| 80 |
public @NonNull Map<String, List<String>> |
| 81 |
getDisabledUntilUsedPreinstalledCarrierAssociatedApps() { |
| 82 |
try { |
| 83 |
return (Map<String, List<String>>) |
| 84 |
mInterface.getDisabledUntilUsedPreinstalledCarrierAssociatedApps(); |
| 85 |
} catch (RemoteException e) { |
| 86 |
Log.e(TAG, "Caught remote exception"); |
| 87 |
return Collections.emptyMap(); |
| 88 |
} |
| 89 |
} |
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
@RequiresPermission(Manifest.permission.READ_CARRIER_APP_INFO) |
| 105 |
public @NonNull Map<String, List<CarrierAssociatedAppEntry>> |
| 106 |
getDisabledUntilUsedPreinstalledCarrierAssociatedAppEntries() { |
| 107 |
try { |
| 108 |
return (Map<String, List<CarrierAssociatedAppEntry>>) |
| 109 |
mInterface.getDisabledUntilUsedPreinstalledCarrierAssociatedAppEntries(); |
| 110 |
} catch (RemoteException e) { |
| 111 |
Log.e(TAG, "Caught remote exception", e); |
| 112 |
return Collections.emptyMap(); |
| 113 |
} |
| 114 |
} |
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
@RequiresPermission(Manifest.permission.GET_RUNTIME_PERMISSIONS) |
| 125 |
@NonNull |
| 126 |
public int[] getSystemPermissionUids(@NonNull String permissionName) { |
| 127 |
try { |
| 128 |
return mInterface.getSystemPermissionUids(permissionName); |
| 129 |
} catch (RemoteException e) { |
| 130 |
throw e.rethrowFromSystemServer(); |
| 131 |
} |
| 132 |
} |
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
@SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) |
| 142 |
@NonNull |
| 143 |
public List<ComponentName> getEnabledComponentOverrides(@NonNull String packageName) { |
| 144 |
try { |
| 145 |
return mInterface.getEnabledComponentOverrides(packageName); |
| 146 |
} catch (RemoteException e) { |
| 147 |
throw e.rethrowFromSystemServer(); |
| 148 |
} |
| 149 |
} |
| 150 |
} |