Show location settings for managed profiles
Location settings for managed profiles are managed by user restriction DISALLOW_SHARE_LOCATION Change-Id: I76a64def18de7502ee118e03a699d1a05d9a6ce9
This commit is contained in:
committed by
Michael Bestas
parent
6059326b6d
commit
8e8329a05c
@@ -21,6 +21,10 @@
|
|||||||
wizard:firstAction="welcome">
|
wizard:firstAction="welcome">
|
||||||
|
|
||||||
<WizardAction wizard:uri="intent:#Intent;action=org.lineageos.setupwizard.LINEAGE_WELCOME;end" id="welcome">
|
<WizardAction wizard:uri="intent:#Intent;action=org.lineageos.setupwizard.LINEAGE_WELCOME;end" id="welcome">
|
||||||
|
<result wizard:action="location_settings" />
|
||||||
|
</WizardAction>
|
||||||
|
|
||||||
|
<WizardAction wizard:uri="intent:#Intent;action=org.lineageos.setupwizard.LINEAGE_LOCATION_SETTINGS;end" id="location_settings">
|
||||||
<result wizard:action="restore" />
|
<result wizard:action="restore" />
|
||||||
</WizardAction>
|
</WizardAction>
|
||||||
|
|
||||||
|
@@ -19,7 +19,8 @@ package org.lineageos.setupwizard;
|
|||||||
|
|
||||||
import android.location.LocationManager;
|
import android.location.LocationManager;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.UserHandle;
|
import android.os.Process;
|
||||||
|
import android.os.UserManager;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
|
|
||||||
@@ -32,6 +33,8 @@ public class LocationSettingsActivity extends BaseSetupWizardActivity {
|
|||||||
|
|
||||||
private LocationManager mLocationManager;
|
private LocationManager mLocationManager;
|
||||||
|
|
||||||
|
private UserManager mUserManager;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@@ -39,18 +42,27 @@ public class LocationSettingsActivity extends BaseSetupWizardActivity {
|
|||||||
|
|
||||||
mLocationAccess = (CheckBox) findViewById(R.id.location_checkbox);
|
mLocationAccess = (CheckBox) findViewById(R.id.location_checkbox);
|
||||||
mLocationManager = getSystemService(LocationManager.class);
|
mLocationManager = getSystemService(LocationManager.class);
|
||||||
|
mUserManager = getSystemService(UserManager.class);
|
||||||
View locationAccessView = findViewById(R.id.location);
|
View locationAccessView = findViewById(R.id.location);
|
||||||
locationAccessView.setOnClickListener(v -> {
|
locationAccessView.setOnClickListener(v -> {
|
||||||
mLocationManager.setLocationEnabledForUser(!mLocationAccess.isChecked(),
|
|
||||||
new UserHandle(UserHandle.USER_CURRENT));
|
|
||||||
mLocationAccess.setChecked(!mLocationAccess.isChecked());
|
mLocationAccess.setChecked(!mLocationAccess.isChecked());
|
||||||
|
mLocationManager.setLocationEnabledForUser(mLocationAccess.isChecked(),
|
||||||
|
Process.myUserHandle());
|
||||||
|
if (mUserManager.isManagedProfile()) {
|
||||||
|
mUserManager.setUserRestriction(UserManager.DISALLOW_SHARE_LOCATION,
|
||||||
|
!mLocationAccess.isChecked());
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
mLocationAccess.setChecked(mLocationManager.isLocationEnabled());
|
boolean checked = mLocationManager.isLocationEnabled();
|
||||||
|
if (mUserManager.isManagedProfile()) {
|
||||||
|
checked &= mUserManager.hasUserRestriction(UserManager.DISALLOW_SHARE_LOCATION);
|
||||||
|
}
|
||||||
|
mLocationAccess.setChecked(checked);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Reference in New Issue
Block a user