Fix NPE if default supervisor is not defined

* Checking for null does not work sadly. This fixes NPE at
   calling who.compareTo(supervisorComponent).

Change-Id: Ie49df625b1514b1d1e5f8063db66dce4a5050039
This commit is contained in:
Wang Han
2020-05-15 09:20:39 +00:00
parent 8683e38068
commit 719b573173

View File

@@ -288,7 +288,7 @@ public class DeviceAdminAdd extends Activity {
// setup. // setup.
final String supervisor = getString( final String supervisor = getString(
com.android.internal.R.string.config_defaultSupervisionProfileOwnerComponent); com.android.internal.R.string.config_defaultSupervisionProfileOwnerComponent);
if (supervisor == null) { if (TextUtils.isEmpty(supervisor)) {
Log.w(TAG, "Unable to set profile owner post-setup, no default supervisor" Log.w(TAG, "Unable to set profile owner post-setup, no default supervisor"
+ "profile owner defined"); + "profile owner defined");
finish(); finish();
@@ -297,7 +297,7 @@ public class DeviceAdminAdd extends Activity {
final ComponentName supervisorComponent = ComponentName.unflattenFromString( final ComponentName supervisorComponent = ComponentName.unflattenFromString(
supervisor); supervisor);
if (who.compareTo(supervisorComponent) != 0) { if (supervisorComponent == null || who.compareTo(supervisorComponent) != 0) {
Log.w(TAG, "Unable to set non-default profile owner post-setup " + who); Log.w(TAG, "Unable to set non-default profile owner post-setup " + who);
finish(); finish();
return; return;