[DO NOT MERGE] Fix potential NPE in Trampoline.requestBackup().
Before it was returning null in case the service was not initialized, but as the method signature has int as the return type, this was boxed and unboxed which would cause NPE. Now it will return BackupManager.ERROR_BACKUP_NOT_ALLOWED instead. This doesn't include fix for the test, because it's going to be cherry-picked into oc-dev, which doesn't have the tests. Test: manually ran unit tests Bug: 37535747 Change-Id: I186cf812a4ec67be943b5c4334c82e9af5320b7a
This commit is contained in:
committed by
Anton Philippov
parent
4b76d33968
commit
e42c8416b0
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.server.backup;
|
||||
|
||||
import android.app.backup.BackupManager;
|
||||
import android.app.backup.IBackupManager;
|
||||
import android.app.backup.IBackupObserver;
|
||||
import android.app.backup.IBackupManagerMonitor;
|
||||
@@ -361,7 +362,10 @@ public class Trampoline extends IBackupManager.Stub {
|
||||
public int requestBackup(String[] packages, IBackupObserver observer,
|
||||
IBackupManagerMonitor monitor, int flags) throws RemoteException {
|
||||
BackupManagerService svc = mService;
|
||||
return (svc != null) ? svc.requestBackup(packages, observer, monitor, flags) : null;
|
||||
if (svc == null) {
|
||||
return BackupManager.ERROR_BACKUP_NOT_ALLOWED;
|
||||
}
|
||||
return svc.requestBackup(packages, observer, monitor, flags);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user