Loading core/java/android/app/ProfileManager.java +40 −13 Original line number Diff line number Diff line Loading @@ -24,8 +24,12 @@ import android.os.IBinder; import android.os.ParcelUuid; import android.os.RemoteException; import android.os.ServiceManager; import android.provider.Settings; import android.util.Log; import com.android.internal.R; /** * @hide */ Loading @@ -37,6 +41,11 @@ public class ProfileManager { private static final String TAG = "ProfileManager"; private static final String SYSTEM_PROFILES_ENABLED = "system_profiles_enabled"; // A blank profile that is created to be returned if profiles disabled private static Profile mEmptyProfile; /** @hide */ static public IProfileManager getService() { if (sService != null) { Loading @@ -50,32 +59,50 @@ public class ProfileManager { /** @hide */ ProfileManager(Context context, Handler handler) { mContext = context; mEmptyProfile = new Profile("EmptyProfile"); } @Deprecated public void setActiveProfile(String profileName) { if (Settings.System.getInt(mContext.getContentResolver(), SYSTEM_PROFILES_ENABLED, 1) == 1) { // Profiles are enabled, return active profile try { getService().setActiveProfileByName(profileName); } catch (RemoteException e) { Log.e(TAG, e.getLocalizedMessage(), e); } } } public void setActiveProfile(UUID profileUuid) { if (Settings.System.getInt(mContext.getContentResolver(), SYSTEM_PROFILES_ENABLED, 1) == 1) { // Profiles are enabled, return active profile try { getService().setActiveProfile(new ParcelUuid(profileUuid)); } catch (RemoteException e) { Log.e(TAG, e.getLocalizedMessage(), e); } } } public Profile getActiveProfile() { if (Settings.System.getInt(mContext.getContentResolver(), SYSTEM_PROFILES_ENABLED, 1) == 1) { // Profiles are enabled, return active profile try { return getService().getActiveProfile(); } catch (RemoteException e) { Log.e(TAG, e.getLocalizedMessage(), e); } return null; } else { // Profiles are not enabled, return the empty profile return mEmptyProfile; } } /** @hide */ Loading core/java/android/provider/Settings.java +6 −0 Original line number Diff line number Diff line Loading @@ -2648,6 +2648,12 @@ public final class Settings { */ public static final String STATUS_BAR_NOTIF_COUNT = "status_bar_notif_count"; /** * Show the pending notification counts as overlays on the status bar * @hide */ public static final String SYSTEM_PROFILES_ENABLED = "system_profiles_enabled"; /** * Settings to backup. This is here so that it's in the same place as the settings * keys and easy to update. Loading policy/src/com/android/internal/policy/impl/GlobalActions.java +19 −17 Original line number Diff line number Diff line Loading @@ -106,6 +106,7 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac private IWindowManager mIWindowManager; private Profile mChosenProfile; private static final String SYSTEM_PROFILES_ENABLED = "system_profiles_enabled"; /** * @param context everything needs a context :( Loading Loading @@ -258,8 +259,8 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac } }); // next: profile // next: profile - only shown if enabled, which is true by default if (Settings.System.getInt(mContext.getContentResolver(), SYSTEM_PROFILES_ENABLED, 1) == 1) { mItems.add( new ProfileChooseAction() { public void onPress() { Loading @@ -278,6 +279,7 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac return false; } }); } // next: screenshot mItems.add( Loading policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java +7 −4 Original line number Diff line number Diff line Loading @@ -670,11 +670,14 @@ public class KeyguardViewMediator implements KeyguardViewCallback, } // if the current profile has disabled us, don't show Profile profile = mProfileManager.getActiveProfile(); if (profile != null) { if (!lockedOrMissing && mProfileManager.getActiveProfile().getScreenLockMode() == Profile.LockMode.DISABLE) { && profile.getScreenLockMode() == Profile.LockMode.DISABLE) { if (DEBUG) Log.d(TAG, "doKeyguard: not showing because of profile override"); return; } } if (DEBUG) Log.d(TAG, "doKeyguard: showing the lock screen"); showLocked(); Loading Loading
core/java/android/app/ProfileManager.java +40 −13 Original line number Diff line number Diff line Loading @@ -24,8 +24,12 @@ import android.os.IBinder; import android.os.ParcelUuid; import android.os.RemoteException; import android.os.ServiceManager; import android.provider.Settings; import android.util.Log; import com.android.internal.R; /** * @hide */ Loading @@ -37,6 +41,11 @@ public class ProfileManager { private static final String TAG = "ProfileManager"; private static final String SYSTEM_PROFILES_ENABLED = "system_profiles_enabled"; // A blank profile that is created to be returned if profiles disabled private static Profile mEmptyProfile; /** @hide */ static public IProfileManager getService() { if (sService != null) { Loading @@ -50,32 +59,50 @@ public class ProfileManager { /** @hide */ ProfileManager(Context context, Handler handler) { mContext = context; mEmptyProfile = new Profile("EmptyProfile"); } @Deprecated public void setActiveProfile(String profileName) { if (Settings.System.getInt(mContext.getContentResolver(), SYSTEM_PROFILES_ENABLED, 1) == 1) { // Profiles are enabled, return active profile try { getService().setActiveProfileByName(profileName); } catch (RemoteException e) { Log.e(TAG, e.getLocalizedMessage(), e); } } } public void setActiveProfile(UUID profileUuid) { if (Settings.System.getInt(mContext.getContentResolver(), SYSTEM_PROFILES_ENABLED, 1) == 1) { // Profiles are enabled, return active profile try { getService().setActiveProfile(new ParcelUuid(profileUuid)); } catch (RemoteException e) { Log.e(TAG, e.getLocalizedMessage(), e); } } } public Profile getActiveProfile() { if (Settings.System.getInt(mContext.getContentResolver(), SYSTEM_PROFILES_ENABLED, 1) == 1) { // Profiles are enabled, return active profile try { return getService().getActiveProfile(); } catch (RemoteException e) { Log.e(TAG, e.getLocalizedMessage(), e); } return null; } else { // Profiles are not enabled, return the empty profile return mEmptyProfile; } } /** @hide */ Loading
core/java/android/provider/Settings.java +6 −0 Original line number Diff line number Diff line Loading @@ -2648,6 +2648,12 @@ public final class Settings { */ public static final String STATUS_BAR_NOTIF_COUNT = "status_bar_notif_count"; /** * Show the pending notification counts as overlays on the status bar * @hide */ public static final String SYSTEM_PROFILES_ENABLED = "system_profiles_enabled"; /** * Settings to backup. This is here so that it's in the same place as the settings * keys and easy to update. Loading
policy/src/com/android/internal/policy/impl/GlobalActions.java +19 −17 Original line number Diff line number Diff line Loading @@ -106,6 +106,7 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac private IWindowManager mIWindowManager; private Profile mChosenProfile; private static final String SYSTEM_PROFILES_ENABLED = "system_profiles_enabled"; /** * @param context everything needs a context :( Loading Loading @@ -258,8 +259,8 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac } }); // next: profile // next: profile - only shown if enabled, which is true by default if (Settings.System.getInt(mContext.getContentResolver(), SYSTEM_PROFILES_ENABLED, 1) == 1) { mItems.add( new ProfileChooseAction() { public void onPress() { Loading @@ -278,6 +279,7 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac return false; } }); } // next: screenshot mItems.add( Loading
policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java +7 −4 Original line number Diff line number Diff line Loading @@ -670,11 +670,14 @@ public class KeyguardViewMediator implements KeyguardViewCallback, } // if the current profile has disabled us, don't show Profile profile = mProfileManager.getActiveProfile(); if (profile != null) { if (!lockedOrMissing && mProfileManager.getActiveProfile().getScreenLockMode() == Profile.LockMode.DISABLE) { && profile.getScreenLockMode() == Profile.LockMode.DISABLE) { if (DEBUG) Log.d(TAG, "doKeyguard: not showing because of profile override"); return; } } if (DEBUG) Log.d(TAG, "doKeyguard: showing the lock screen"); showLocked(); Loading