Merge "Launch DO/PO sepecific settings when parental are enabled."
This commit is contained in:
@@ -23,6 +23,7 @@ import android.util.FeatureFlagUtils;
|
||||
|
||||
import com.android.settings.core.FeatureFlags;
|
||||
import com.android.settings.enterprise.EnterprisePrivacySettings;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
|
||||
/**
|
||||
* Top-level Settings activity
|
||||
@@ -213,7 +214,11 @@ public class Settings extends SettingsActivity {
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (!EnterprisePrivacySettings.isPageEnabled(this)) {
|
||||
if (FeatureFactory.getFactory(this)
|
||||
.getEnterprisePrivacyFeatureProvider(this)
|
||||
.showParentalControls()) {
|
||||
finish();
|
||||
} else if (!EnterprisePrivacySettings.isPageEnabled(this)) {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
@@ -137,4 +137,10 @@ public interface EnterprisePrivacyFeatureProvider {
|
||||
* info" page. Returns {@code true} if the activity has indeed been launched.
|
||||
*/
|
||||
boolean showWorkPolicyInfo();
|
||||
|
||||
/**
|
||||
* Launches the parental controls settings page. Returns {@code true} if the activity has
|
||||
* been launched.
|
||||
*/
|
||||
boolean showParentalControls();
|
||||
}
|
||||
|
@@ -40,6 +40,9 @@ import java.util.List;
|
||||
|
||||
public class EnterprisePrivacyFeatureProviderImpl implements EnterprisePrivacyFeatureProvider {
|
||||
|
||||
public static final String ACTION_PARENTAL_CONTROLS =
|
||||
"android.settings.SHOW_PARENTAL_CONTROLS";
|
||||
|
||||
private final Context mContext;
|
||||
private final DevicePolicyManager mDpm;
|
||||
private final PackageManager mPm;
|
||||
@@ -246,6 +249,34 @@ public class EnterprisePrivacyFeatureProviderImpl implements EnterprisePrivacyFe
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showParentalControls() {
|
||||
Intent intent = getParentalControlsIntent();
|
||||
if (intent != null) {
|
||||
mContext.startActivity(intent);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private Intent getParentalControlsIntent() {
|
||||
final ComponentName componentName =
|
||||
mDpm.getProfileOwnerOrDeviceOwnerSupervisionComponent(new UserHandle(MY_USER_ID));
|
||||
if (componentName == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final Intent intent = new Intent(ACTION_PARENTAL_CONTROLS)
|
||||
.setPackage(componentName.getPackageName())
|
||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
final List<ResolveInfo> activities = mPm.queryIntentActivitiesAsUser(intent, 0, MY_USER_ID);
|
||||
if (activities.size() != 0) {
|
||||
return intent;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private ComponentName getDeviceOwnerComponent() {
|
||||
if (!mPm.hasSystemFeature(PackageManager.FEATURE_DEVICE_ADMIN)) {
|
||||
return null;
|
||||
|
Reference in New Issue
Block a user