Fix NPE in MtpDocumentsProviderTests
Previous patch ag/2250238 broke MtpDocumentsProviderTests since
ServiceIntentSender's constructor refers the context argument which is
null in the tests.
The CL adds a test version of the constructor which does not use the
context argument in it.
Bug: 38363487
Test: MtpDocumentsProviderTests
Change-Id: I68a1d8cb6997499e5069c33f70fd0f675aaad77c
(cherry picked from commit c5949bd39c)
This commit is contained in:
@@ -23,6 +23,7 @@ import android.app.NotificationManager;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.internal.util.Preconditions;
|
||||
|
||||
/**
|
||||
@@ -30,7 +31,7 @@ import com.android.internal.util.Preconditions;
|
||||
*/
|
||||
class ServiceIntentSender {
|
||||
private final static String CHANNEL_ID = "device_notification_channel";
|
||||
private Context mContext;
|
||||
private final Context mContext;
|
||||
|
||||
ServiceIntentSender(Context context) {
|
||||
mContext = context;
|
||||
@@ -46,6 +47,11 @@ class ServiceIntentSender {
|
||||
notificationManager.createNotificationChannel(mChannel);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
protected ServiceIntentSender() {
|
||||
mContext = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify the change of opened device set.
|
||||
* @param records List of opened devices. Can be empty.
|
||||
|
||||
@@ -17,10 +17,6 @@
|
||||
package com.android.mtp;
|
||||
|
||||
class TestServiceIntentSender extends ServiceIntentSender {
|
||||
TestServiceIntentSender() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
void sendUpdateNotificationIntent(MtpDeviceRecord[] record) {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user