Peter Cai 2020-09-16 20:02:42 +08:00
parent 6f765b58bd
commit 749ad11dbe
No known key found for this signature in database
GPG key ID: 71F5FB4E4F3FD54F
7 changed files with 36 additions and 0 deletions

View file

@ -588,6 +588,11 @@ public class DummyActivity extends Activity {
}
// TODO: Cases for other types
SettingsManager.getInstance().applyAll();
if (mIsProfileOwner) {
// Refresh profile policies because
// settings may have been changed
Utility.enforceWorkProfilePolicies(this);
}
finish();
}
}

View file

@ -32,6 +32,7 @@ public class SettingsFragment extends PreferenceFragmentCompat implements Prefer
private static final String SETTINGS_PATREON = "settings_patreon";
private static final String SETTINGS_CROSS_PROFILE_FILE_CHOOSER = "settings_cross_profile_file_chooser";
private static final String SETTINGS_CAMERA_PROXY = "settings_camera_proxy";
private static final String SETTINGS_BLOCK_CONTACTS_SEARCHING = "settings_block_contacts_searching";
private static final String SETTINGS_AUTO_FREEZE_SERVICE = "settings_auto_freeze_service";
private static final String SETTINGS_AUTO_FREEZE_DELAY = "settings_auto_freeze_delay";
private static final String SETTINGS_SKIP_FOREGROUND = "settings_dont_freeze_foreground";
@ -41,6 +42,7 @@ public class SettingsFragment extends PreferenceFragmentCompat implements Prefer
private CheckBoxPreference mPrefCrossProfileFileChooser = null;
private CheckBoxPreference mPrefCameraProxy = null;
private CheckBoxPreference mPrefBlockContactsSearching = null;
private CheckBoxPreference mPrefAutoFreezeService = null;
private CheckBoxPreference mPrefSkipForeground = null;
@ -78,6 +80,9 @@ public class SettingsFragment extends PreferenceFragmentCompat implements Prefer
mPrefCameraProxy = (CheckBoxPreference) findPreference(SETTINGS_CAMERA_PROXY);
mPrefCameraProxy.setChecked(mManager.getCameraProxyEnabled());
mPrefCameraProxy.setOnPreferenceChangeListener(this);
mPrefBlockContactsSearching = (CheckBoxPreference) findPreference(SETTINGS_BLOCK_CONTACTS_SEARCHING);
mPrefBlockContactsSearching.setChecked(mManager.getBlockContactsSearchingEnabled());
mPrefBlockContactsSearching.setOnPreferenceChangeListener(this);
// === Services ===
mPrefAutoFreezeService = (CheckBoxPreference) findPreference(SETTINGS_AUTO_FREEZE_SERVICE);
@ -185,6 +190,9 @@ public class SettingsFragment extends PreferenceFragmentCompat implements Prefer
} else if (preference == mPrefCameraProxy) {
mManager.setCameraProxyEnabled(((boolean) newState));
return true;
} else if (preference == mPrefBlockContactsSearching) {
mManager.setBlockContactsSearchingEnabled((boolean) newState);
return true;
} else if (preference == mPrefAutoFreezeService) {
mManager.setAutoFreezeServiceEnabled((boolean) newState);
return true;

View file

@ -17,6 +17,7 @@ public class LocalStorageManager {
public static final String PREF_DONT_FREEZE_FOREGROUND = "dont_freeze_foreground";
public static final String PREF_AUTO_FREEZE_DELAY = "auto_freeze_delay";
public static final String PREF_CAMERA_PROXY = "camera_proxy";
public static final String PREF_BLOCK_CONTACTS_SEARCHING = "block_contacts_searching";
private static final String LIST_DIVIDER = ",";

View file

@ -92,6 +92,17 @@ public class SettingsManager {
return mStorage.getBoolean(LocalStorageManager.PREF_CAMERA_PROXY);
}
// Set the blocked state of cross-profile contacts searching
public void setBlockContactsSearchingEnabled(boolean enabled) {
mStorage.setBoolean(LocalStorageManager.PREF_BLOCK_CONTACTS_SEARCHING, enabled);
syncSettingsToProfileBool(LocalStorageManager.PREF_BLOCK_CONTACTS_SEARCHING, enabled);
}
// Get the blocked state of cross-profile contacts searching
public boolean getBlockContactsSearchingEnabled() {
return mStorage.getBoolean(LocalStorageManager.PREF_BLOCK_CONTACTS_SEARCHING);
}
// Set the enabled state of the auto freeze service
// This does NOT need to be synchronized nor applied across profile
public void setAutoFreezeServiceEnabled(boolean enabled) {

View file

@ -199,6 +199,10 @@ public class Utility {
browsableDefaultIntentFilter,
DevicePolicyManager.FLAG_PARENT_CAN_ACCESS_MANAGED);
// Block contacts searching optionally
manager.setCrossProfileContactsSearchDisabled(adminComponent,
SettingsManager.getInstance().getBlockContactsSearchingEnabled());
manager.setProfileEnabled(adminComponent);
}

View file

@ -55,6 +55,8 @@
<string name="settings_cross_profile_file_chooser_desc">When enabled, you\'ll be able to browse / view / pick / copy files in Shelter from main profile and vice-versa, ONLY through Documents UI (named Files or Documents on your launcher) or apps with Documents UI support (they only gain temporary access to files you choose in Documents UI), while still pertaining the filesystem isolation.</string>
<string name="settings_camera_proxy">Image Chooser as Fake Camera</string>
<string name="settings_camera_proxy_desc">Present a fake camera app to other apps, allowing you to choose an arbitrary image from Documents UI (and File Shuttle if enabled) as the taken picture. This enables File Shuttle for any app that supports invoking other camera apps to take a picture, even if they don\'t support Documents UI natively.</string>
<string name="settings_block_contacts_searching">Block Contacts Searching</string>
<string name="settings_block_contacts_searching_desc">Deny access from main profile to contacts inside work profile.</string>
<string name="settings_services">Services</string>
<string name="settings_auto_freeze_service">Auto Freeze Service</string>
<string name="settings_auto_freeze_service_desc">When the screen is locked, automatically freeze apps launched from \"Unfreeze &amp; Launch Shortcut\".</string>

View file

@ -15,6 +15,11 @@
android:title="@string/settings_camera_proxy"
android:summary="@string/settings_camera_proxy_desc" />
<androidx.preference.CheckBoxPreference
android:key="settings_block_contacts_searching"
android:title="@string/settings_block_contacts_searching"
android:summary="@string/settings_block_contacts_searching_desc" />
</androidx.preference.PreferenceCategory>
<androidx.preference.PreferenceCategory