Merge "Protect getPersistentDataPackageName with ACCESS_PDB_STATE"

This commit is contained in:
Antoan Angelov
2022-01-28 14:32:07 +00:00
committed by Android (Google) Code Review
5 changed files with 18 additions and 13 deletions

View File

@@ -11197,7 +11197,7 @@ package android.service.persistentdata {
method @android.service.persistentdata.PersistentDataBlockManager.FlashLockState @RequiresPermission(anyOf={android.Manifest.permission.READ_OEM_UNLOCK_STATE, "android.permission.OEM_UNLOCK_STATE"}) public int getFlashLockState();
method public long getMaximumDataBlockSize();
method @Deprecated @RequiresPermission(anyOf={android.Manifest.permission.READ_OEM_UNLOCK_STATE, "android.permission.OEM_UNLOCK_STATE"}) public boolean getOemUnlockEnabled();
method @NonNull public String getPersistentDataPackageName();
method @NonNull @RequiresPermission(android.Manifest.permission.ACCESS_PDB_STATE) public String getPersistentDataPackageName();
method public byte[] read();
method @Deprecated @RequiresPermission("android.permission.OEM_UNLOCK_STATE") public void setOemUnlockEnabled(boolean);
method @RequiresPermission("android.permission.OEM_UNLOCK_STATE") public void wipe();

View File

@@ -1034,15 +1034,14 @@ public final class SystemServiceRegistry {
}});
registerService(Context.PERSISTENT_DATA_BLOCK_SERVICE, PersistentDataBlockManager.class,
new CachedServiceFetcher<PersistentDataBlockManager>() {
new StaticServiceFetcher<PersistentDataBlockManager>() {
@Override
public PersistentDataBlockManager createService(ContextImpl ctx)
throws ServiceNotFoundException {
public PersistentDataBlockManager createService() throws ServiceNotFoundException {
IBinder b = ServiceManager.getServiceOrThrow(Context.PERSISTENT_DATA_BLOCK_SERVICE);
IPersistentDataBlockService persistentDataBlockService =
IPersistentDataBlockService.Stub.asInterface(b);
if (persistentDataBlockService != null) {
return new PersistentDataBlockManager(ctx, persistentDataBlockService);
return new PersistentDataBlockManager(persistentDataBlockService);
} else {
// not supported
return null;

View File

@@ -37,5 +37,6 @@ interface IPersistentDataBlockService {
boolean getOemUnlockEnabled();
int getFlashLockState();
boolean hasFrpCredentialHandle();
String getPersistentDataPackageName();
}

View File

@@ -26,8 +26,6 @@ import android.content.Context;
import android.os.RemoteException;
import android.service.oemlock.OemLockManager;
import com.android.internal.R;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -53,7 +51,6 @@ import java.lang.annotation.RetentionPolicy;
@SystemService(Context.PERSISTENT_DATA_BLOCK_SERVICE)
public class PersistentDataBlockManager {
private static final String TAG = PersistentDataBlockManager.class.getSimpleName();
private final Context mContext;
private IPersistentDataBlockService sService;
/**
@@ -78,10 +75,7 @@ public class PersistentDataBlockManager {
public @interface FlashLockState {}
/** @hide */
public PersistentDataBlockManager(
Context context,
IPersistentDataBlockService service) {
mContext = context;
public PersistentDataBlockManager(IPersistentDataBlockService service) {
sService = service;
}
@@ -219,7 +213,12 @@ public class PersistentDataBlockManager {
*/
@SystemApi
@NonNull
@RequiresPermission(android.Manifest.permission.ACCESS_PDB_STATE)
public String getPersistentDataPackageName() {
return mContext.getString(R.string.config_persistentDataPackageName);
try {
return sService.getPersistentDataPackageName();
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
}

View File

@@ -673,6 +673,12 @@ public class PersistentDataBlockService extends SystemService {
throw new UnsupportedOperationException("cannot read frp credential");
}
}
@Override
public String getPersistentDataPackageName() {
enforcePersistentDataBlockAccess();
return mContext.getString(R.string.config_persistentDataPackageName);
}
};
private PersistentDataBlockManagerInternal mInternalService =