Fix the crash while tapping "app data usage" as second user

Second user or guest is limited some mobile network access. We need to check current user
is admin or not to decide the preferece page will be found in search or not.

Bug: 133466016
Fixes: 133466016
Test: Manual test & make RunSettingsRoboTests -j56 ROBOTEST_FILTER=com.android.settings.network

Change-Id: I48d3064a8aa28ac1f2ac699b42a999b9682b1b52
This commit is contained in:
Sunny Shao
2019-05-27 11:55:34 +08:00
parent f010cb4034
commit bddf5149e5
4 changed files with 124 additions and 0 deletions

View File

@@ -18,6 +18,7 @@ package com.android.settings.network;
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.os.UserManager;
import android.provider.SearchIndexableResource;
import com.android.settings.R;
@@ -66,5 +67,10 @@ public class MobileNetworkListFragment extends DashboardFragment {
result.add(sir);
return result;
}
@Override
protected boolean isPageSearchEnabled(Context context) {
return context.getSystemService(UserManager.class).isAdminUser();
}
};
}

View File

@@ -277,5 +277,11 @@ public class MobileNetworkSettings extends RestrictedDashboardFragment {
result.add(sir);
return result;
}
/** suppress full page if user is not admin */
@Override
protected boolean isPageSearchEnabled(Context context) {
return context.getSystemService(UserManager.class).isAdminUser();
}
};
}