Merge "Check EnforcedAdmin to see if location is locked down by device policy."

This commit is contained in:
TreeHugger Robot
2018-06-09 01:23:26 +00:00
committed by Android (Google) Code Review
3 changed files with 78 additions and 10 deletions

View File

@@ -25,6 +25,7 @@ import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceScreen;
import android.util.Log;
import com.android.settings.Utils;
import com.android.settings.widget.RestrictedAppPreference;
import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
@@ -130,8 +131,11 @@ public class LocationServicePreferenceController extends LocationBasePreferenceC
private List<Preference> getLocationServices() {
// If location access is locked down by device policy then we only show injected settings
// for the primary profile.
final int profileUserId = Utils.getManagedProfileId(mUserManager, UserHandle.myUserId());
return mInjector.getInjectedSettings(mFragment.getPreferenceManager().getContext(),
mLocationEnabler.isManagedProfileRestrictedByBase()
(profileUserId != UserHandle.USER_NULL
&& mLocationEnabler.getShareLocationEnforcedAdmin(profileUserId) != null)
? UserHandle.myUserId() : UserHandle.USER_CURRENT);
}
}