Populate Enterprise Privacy Settings page - batch 2
This CL adds the second batch of items to the Privacy Settings page. These are all the remaining items that fall into the "What types of information can your organization see?" category. Test: make RunSettingsRoboTests Bug: 32692748 Change-Id: I08569646ed6bb6f5d9d6d65ed2718be8456f50ae
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (C) 2016 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the
|
||||
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
package com.android.settings.enterprise;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.text.format.DateUtils;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.PreferenceController;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public abstract class AdminActionPreferenceControllerBase extends PreferenceController {
|
||||
|
||||
private final Context mContext;
|
||||
protected final EnterprisePrivacyFeatureProvider mFeatureProvider;
|
||||
|
||||
public AdminActionPreferenceControllerBase(Context context) {
|
||||
super(context);
|
||||
mContext = context;
|
||||
mFeatureProvider = FeatureFactory.getFactory(context)
|
||||
.getEnterprisePrivacyFeatureProvider(context);
|
||||
}
|
||||
|
||||
protected abstract Date getAdminActionTimestamp();
|
||||
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
final Date timestamp = getAdminActionTimestamp();
|
||||
preference.setSummary(timestamp == null ?
|
||||
mContext.getString(R.string.enterprise_privacy_never) :
|
||||
DateUtils.formatDateTime(mContext, timestamp.getTime(),
|
||||
DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_DATE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handlePreferenceTreeClick(Preference preference) {
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2016 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the
|
||||
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
package com.android.settings.enterprise;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class BugReportsPreferenceController extends AdminActionPreferenceControllerBase {
|
||||
|
||||
private static final String KEY_BUG_REPORTS = "bug_reports";
|
||||
|
||||
public BugReportsPreferenceController(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Date getAdminActionTimestamp() {
|
||||
return mFeatureProvider.getLastBugReportRequestTime();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPreferenceKey() {
|
||||
return KEY_BUG_REPORTS;
|
||||
}
|
||||
}
|
@@ -31,4 +31,25 @@ public interface DevicePolicyManagerWrapper {
|
||||
* @see android.app.admin.DevicePolicyManager#getDeviceOwnerComponentOnAnyUser
|
||||
*/
|
||||
ComponentName getDeviceOwnerComponentOnAnyUser();
|
||||
|
||||
/**
|
||||
* Calls {@code DevicePolicyManager.getLastSecurityLogRetrievalTime()}.
|
||||
*
|
||||
* @see android.app.admin.DevicePolicyManager#getLastSecurityLogRetrievalTime
|
||||
*/
|
||||
public long getLastSecurityLogRetrievalTime();
|
||||
|
||||
/**
|
||||
* Calls {@code DevicePolicyManager.getLastBugReportRequestTime()}.
|
||||
*
|
||||
* @see android.app.admin.DevicePolicyManager#getLastBugReportRequestTime
|
||||
*/
|
||||
public long getLastBugReportRequestTime();
|
||||
|
||||
/**
|
||||
* Calls {@code DevicePolicyManager.getLastNetworkLogRetrievalTime()}.
|
||||
*
|
||||
* @see android.app.admin.DevicePolicyManager#getLastNetworkLogRetrievalTime
|
||||
*/
|
||||
public long getLastNetworkLogRetrievalTime();
|
||||
}
|
||||
|
@@ -30,4 +30,19 @@ public class DevicePolicyManagerWrapperImpl implements DevicePolicyManagerWrappe
|
||||
public ComponentName getDeviceOwnerComponentOnAnyUser() {
|
||||
return mDpm.getDeviceOwnerComponentOnAnyUser();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLastSecurityLogRetrievalTime() {
|
||||
return mDpm.getLastSecurityLogRetrievalTime();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLastBugReportRequestTime() {
|
||||
return mDpm.getLastBugReportRequestTime();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLastNetworkLogRetrievalTime() {
|
||||
return mDpm.getLastNetworkLogRetrievalTime();
|
||||
}
|
||||
}
|
||||
|
@@ -16,6 +16,30 @@
|
||||
|
||||
package com.android.settings.enterprise;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public interface EnterprisePrivacyFeatureProvider {
|
||||
|
||||
/**
|
||||
* Returns whether the device is managed by a Device Owner app.
|
||||
*/
|
||||
boolean hasDeviceOwner();
|
||||
|
||||
/**
|
||||
* Returns the time at which the Device Owner last retrieved security logs, or {@code null} if
|
||||
* logs were never retrieved by the Device Owner on this device.
|
||||
*/
|
||||
Date getLastSecurityLogRetrievalTime();
|
||||
|
||||
/**
|
||||
* Returns the time at which the Device Owner last requested a bug report, or {@code null} if no
|
||||
* bug report was ever requested by the Device Owner on this device.
|
||||
*/
|
||||
Date getLastBugReportRequestTime();
|
||||
|
||||
/**
|
||||
* Returns the time at which the Device Owner last retrieved network logs, or {@code null} if
|
||||
* logs were never retrieved by the Device Owner on this device.
|
||||
*/
|
||||
Date getLastNetworkLogRetrievalTime();
|
||||
}
|
||||
|
@@ -20,6 +20,8 @@ import android.content.pm.PackageManager;
|
||||
|
||||
import com.android.settings.applications.PackageManagerWrapper;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class EnterprisePrivacyFeatureProviderImpl implements EnterprisePrivacyFeatureProvider {
|
||||
|
||||
private final DevicePolicyManagerWrapper mDpm;
|
||||
@@ -38,4 +40,20 @@ public class EnterprisePrivacyFeatureProviderImpl implements EnterprisePrivacyFe
|
||||
}
|
||||
return mDpm.getDeviceOwnerComponentOnAnyUser() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date getLastSecurityLogRetrievalTime() {
|
||||
final long timestamp = mDpm.getLastSecurityLogRetrievalTime();
|
||||
return timestamp < 0 ? null : new Date(timestamp);
|
||||
}
|
||||
|
||||
public Date getLastBugReportRequestTime() {
|
||||
final long timestamp = mDpm.getLastBugReportRequestTime();
|
||||
return timestamp < 0 ? null : new Date(timestamp);
|
||||
}
|
||||
|
||||
public Date getLastNetworkLogRetrievalTime() {
|
||||
final long timestamp = mDpm.getLastNetworkLogRetrievalTime();
|
||||
return timestamp < 0 ? null : new Date(timestamp);
|
||||
}
|
||||
}
|
||||
|
@@ -58,6 +58,9 @@ public class EnterprisePrivacySettings extends DashboardFragment {
|
||||
protected List<PreferenceController> getPreferenceControllers(Context context) {
|
||||
final List controllers = new ArrayList<PreferenceController>();
|
||||
controllers.add(new InstalledPackagesPreferenceController(context));
|
||||
controllers.add(new NetworkLogsPreferenceController(context));
|
||||
controllers.add(new BugReportsPreferenceController(context));
|
||||
controllers.add(new SecurityLogsPreferenceController(context));
|
||||
return controllers;
|
||||
}
|
||||
|
||||
|
@@ -40,7 +40,7 @@ public class InstalledPackagesPreferenceController extends PreferenceController
|
||||
@Override
|
||||
public void onNumberOfInstalledAppsResult(int num) {
|
||||
preference.setTitle(mContext.getResources().getQuantityString(
|
||||
R.plurals.number_installed_packages, num, num));
|
||||
R.plurals.enterprise_privacy_number_installed_packages, num, num));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2016 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the
|
||||
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
package com.android.settings.enterprise;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class NetworkLogsPreferenceController extends AdminActionPreferenceControllerBase {
|
||||
|
||||
private static final String KEY_NETWORK_LOGS = "network_logs";
|
||||
|
||||
public NetworkLogsPreferenceController(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Date getAdminActionTimestamp() {
|
||||
return mFeatureProvider.getLastNetworkLogRetrievalTime();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPreferenceKey() {
|
||||
return KEY_NETWORK_LOGS;
|
||||
}
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2016 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the
|
||||
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
package com.android.settings.enterprise;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class SecurityLogsPreferenceController extends AdminActionPreferenceControllerBase {
|
||||
|
||||
private static final String KEY_SECURITY_LOGS = "security_logs";
|
||||
|
||||
public SecurityLogsPreferenceController(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Date getAdminActionTimestamp() {
|
||||
return mFeatureProvider.getLastSecurityLogRetrievalTime();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPreferenceKey() {
|
||||
return KEY_SECURITY_LOGS;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user