Skip to content

Commit 07ba2ae

Browse files
committed
Throw RemoteException when MountService is not yet up
Instead of throwing NullPointerException when getMountService() returns null, simply throw RemoteException so the code calling getMountService() can fail gracefully. Bug: 6461657 Change-Id: Ibefc17de3e0024eb73bbd24914759c0a404f538e
1 parent 2f4b10e commit 07ba2ae

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

core/java/com/android/internal/content/PackageHelper.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,25 +57,25 @@ public class PackageHelper {
5757
public static final int APP_INSTALL_INTERNAL = 1;
5858
public static final int APP_INSTALL_EXTERNAL = 2;
5959

60-
public static IMountService getMountService() {
60+
public static IMountService getMountService() throws RemoteException {
6161
IBinder service = ServiceManager.getService("mount");
6262
if (service != null) {
6363
return IMountService.Stub.asInterface(service);
6464
} else {
6565
Log.e(TAG, "Can't get mount service");
66+
throw new RemoteException("Could not contact mount service");
6667
}
67-
return null;
6868
}
6969

7070
public static String createSdDir(int sizeMb, String cid, String sdEncKey, int uid,
7171
boolean isExternal) {
7272
// Create mount point via MountService
73-
IMountService mountService = getMountService();
73+
try {
74+
IMountService mountService = getMountService();
7475

75-
if (localLOGV)
76-
Log.i(TAG, "Size of container " + sizeMb + " MB");
76+
if (localLOGV)
77+
Log.i(TAG, "Size of container " + sizeMb + " MB");
7778

78-
try {
7979
int rc = mountService.createSecureContainer(cid, sizeMb, "ext4", sdEncKey, uid,
8080
isExternal);
8181
if (rc != StorageResultCode.OperationSucceeded) {

0 commit comments

Comments
 (0)