Merge "Create returns null when resource strings are empty" into udc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
2a5d645b1d
@@ -35,6 +35,7 @@ import android.os.Binder;
|
||||
import android.os.IBinder;
|
||||
import android.os.IInterface;
|
||||
import android.os.RemoteException;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.internal.R;
|
||||
@@ -173,10 +174,15 @@ public class SharedConnectivityManager {
|
||||
R.string.config_sharedConnectivityServicePackage);
|
||||
String serviceIntentAction = resources.getString(
|
||||
R.string.config_sharedConnectivityServiceIntentAction);
|
||||
if (TextUtils.isEmpty(servicePackageName) || TextUtils.isEmpty(serviceIntentAction)) {
|
||||
Log.e(TAG, "To support shared connectivity service on this device, the"
|
||||
+ " service's package name and intent action strings must not be empty");
|
||||
return null;
|
||||
}
|
||||
return new SharedConnectivityManager(context, servicePackageName, serviceIntentAction);
|
||||
} catch (Resources.NotFoundException e) {
|
||||
Log.e(TAG, "To support shared connectivity service on this device, the service's"
|
||||
+ " package name and intent action string must be defined");
|
||||
+ " package name and intent action strings must be defined");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -104,6 +104,13 @@ public class SharedConnectivityManagerTest {
|
||||
assertThat(SharedConnectivityManager.create(mContext)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resourceStringsAreEmpty_createShouldReturnNull() {
|
||||
when(mResources.getString(anyInt())).thenReturn("");
|
||||
|
||||
assertThat(SharedConnectivityManager.create(mContext)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bindingToServiceOnFirstCallbackRegistration() {
|
||||
SharedConnectivityManager manager = SharedConnectivityManager.create(mContext);
|
||||
|
||||
Reference in New Issue
Block a user