Launch DO/PO sepecific settings when parental are enabled.
Test: make RunSettingsRoboTests && manual Bug: 161861348 Change-Id: I73ce27d0aa740f47e6ed3e4be9bee4d5eaf039ad
This commit is contained in:
@@ -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