Loading core/java/android/app/Profile.java +3 −0 Original line number Diff line number Diff line Loading @@ -123,6 +123,9 @@ public class Profile implements Parcelable { for (Parcelable group : in.readParcelableArray(null)) { ProfileGroup grp = (ProfileGroup) group; profileGroups.put(grp.getName(), grp); if(grp.isDefaultGroup()){ mDefaultGroup = grp; } } } Loading core/java/android/app/ProfileManager.java +16 −1 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.os.Handler; import android.os.IBinder; import android.os.RemoteException; import android.os.ServiceManager; import android.util.Log; public class ProfileManager { Loading Loading @@ -54,6 +55,7 @@ public class ProfileManager getService().setActiveProfile(profileName); getService().persist(); } catch (RemoteException e) { Log.e(TAG, e.getLocalizedMessage(), e); } } Loading @@ -61,6 +63,7 @@ public class ProfileManager try { return getService().getActiveProfile(); } catch (RemoteException e) { Log.e(TAG, e.getLocalizedMessage(), e); } return null; } Loading @@ -71,6 +74,7 @@ public class ProfileManager getService().addProfile(profile); getService().persist(); } catch (RemoteException e) { Log.e(TAG, e.getLocalizedMessage(), e); } } Loading @@ -79,6 +83,7 @@ public class ProfileManager try { getService().removeProfile(profile); } catch (RemoteException e) { Log.e(TAG, e.getLocalizedMessage(), e); } } Loading @@ -86,6 +91,7 @@ public class ProfileManager try { return getService().getProfile(profileName); } catch (RemoteException e) { Log.e(TAG, e.getLocalizedMessage(), e); } return null; } Loading @@ -100,6 +106,7 @@ public class ProfileManager } return names; } catch (RemoteException e) { Log.e(TAG, e.getLocalizedMessage(), e); } return null; } Loading @@ -108,6 +115,7 @@ public class ProfileManager try { return getService().getProfiles(); } catch (RemoteException e) { Log.e(TAG, e.getLocalizedMessage(), e); } return null; } Loading @@ -117,6 +125,7 @@ public class ProfileManager try { return getService().getNotificationGroups(); } catch (RemoteException e) { Log.e(TAG, e.getLocalizedMessage(), e); } return null; } Loading @@ -127,6 +136,7 @@ public class ProfileManager getService().addNotificationGroup(group); getService().persist(); } catch (RemoteException e) { Log.e(TAG, e.getLocalizedMessage(), e); } } Loading @@ -135,6 +145,7 @@ public class ProfileManager try { getService().removeNotificationGroup(group); } catch (RemoteException e) { Log.e(TAG, e.getLocalizedMessage(), e); } } Loading @@ -143,6 +154,7 @@ public class ProfileManager try { return getService().getNotificationGroupForPackage(pkg); } catch (RemoteException e) { Log.e(TAG, e.getLocalizedMessage(), e); } return null; } Loading @@ -152,6 +164,7 @@ public class ProfileManager try { return getService().getNotificationGroup(name); } catch (RemoteException e) { Log.e(TAG, e.getLocalizedMessage(), e); } return null; } Loading @@ -160,7 +173,9 @@ public class ProfileManager public ProfileGroup getActiveProfileGroup(String packageName) { NotificationGroup notificationGroup = getNotificationGroupForPackage(packageName); if(notificationGroup == null){ return getActiveProfile().getDefaultGroup(); ProfileGroup defaultGroup = getActiveProfile().getDefaultGroup(); Log.v(TAG, "No active group, returning default: " + (defaultGroup == null ? "null" : defaultGroup.getName())); return defaultGroup; } String notificationGroupName = notificationGroup.getName(); return getActiveProfile().getProfileGroup(notificationGroupName); Loading media/java/android/media/AudioManager.java +17 −9 Original line number Diff line number Diff line Loading @@ -601,8 +601,13 @@ public class AudioManager { * @see #getVibrateSetting(int) */ public boolean shouldVibrate(int vibrateType) { ProfileGroup profileGroup = mProfileManager.getActiveProfileGroup(mContext.getPackageName()); String packageName = mContext.getPackageName(); // Don't apply profiles for "android" context, as these could // come from the NotificationManager, and originate from a real package. if(!packageName.equals("android")){ ProfileGroup profileGroup = mProfileManager.getActiveProfileGroup(packageName); if(profileGroup != null){ Log.v(TAG, "shouldVibrate, group: " + profileGroup.getName() + " mode: " + profileGroup.getVibrateMode()); switch(profileGroup.getVibrateMode()){ case OVERRIDE : return true; Loading @@ -612,6 +617,9 @@ public class AudioManager { // Drop through } } }else{ Log.v(TAG, "Not applying override for 'android' package"); } IAudioService service = getService(); try { return service.shouldVibrate(vibrateType); Loading services/java/com/android/server/NotificationManagerService.java +2 −0 Original line number Diff line number Diff line Loading @@ -964,7 +964,9 @@ public class NotificationManagerService extends INotificationManager.Stub .getSystemService(Context.PROFILE_SERVICE); Profile currentProfile = profileManager.getActiveProfile(); Log.v(TAG, "Active profile: " + currentProfile.getName()); ProfileGroup group = profileManager.getActiveProfileGroup(pkg); Log.v(TAG, "Pkg: " + pkg + " group: " + group.getName()); notification = currentProfile.processNotification(group.getName(), notification); }catch(Throwable th){ Log.e(TAG, "An error occurred profiling the notification.", th); Loading Loading
core/java/android/app/Profile.java +3 −0 Original line number Diff line number Diff line Loading @@ -123,6 +123,9 @@ public class Profile implements Parcelable { for (Parcelable group : in.readParcelableArray(null)) { ProfileGroup grp = (ProfileGroup) group; profileGroups.put(grp.getName(), grp); if(grp.isDefaultGroup()){ mDefaultGroup = grp; } } } Loading
core/java/android/app/ProfileManager.java +16 −1 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.os.Handler; import android.os.IBinder; import android.os.RemoteException; import android.os.ServiceManager; import android.util.Log; public class ProfileManager { Loading Loading @@ -54,6 +55,7 @@ public class ProfileManager getService().setActiveProfile(profileName); getService().persist(); } catch (RemoteException e) { Log.e(TAG, e.getLocalizedMessage(), e); } } Loading @@ -61,6 +63,7 @@ public class ProfileManager try { return getService().getActiveProfile(); } catch (RemoteException e) { Log.e(TAG, e.getLocalizedMessage(), e); } return null; } Loading @@ -71,6 +74,7 @@ public class ProfileManager getService().addProfile(profile); getService().persist(); } catch (RemoteException e) { Log.e(TAG, e.getLocalizedMessage(), e); } } Loading @@ -79,6 +83,7 @@ public class ProfileManager try { getService().removeProfile(profile); } catch (RemoteException e) { Log.e(TAG, e.getLocalizedMessage(), e); } } Loading @@ -86,6 +91,7 @@ public class ProfileManager try { return getService().getProfile(profileName); } catch (RemoteException e) { Log.e(TAG, e.getLocalizedMessage(), e); } return null; } Loading @@ -100,6 +106,7 @@ public class ProfileManager } return names; } catch (RemoteException e) { Log.e(TAG, e.getLocalizedMessage(), e); } return null; } Loading @@ -108,6 +115,7 @@ public class ProfileManager try { return getService().getProfiles(); } catch (RemoteException e) { Log.e(TAG, e.getLocalizedMessage(), e); } return null; } Loading @@ -117,6 +125,7 @@ public class ProfileManager try { return getService().getNotificationGroups(); } catch (RemoteException e) { Log.e(TAG, e.getLocalizedMessage(), e); } return null; } Loading @@ -127,6 +136,7 @@ public class ProfileManager getService().addNotificationGroup(group); getService().persist(); } catch (RemoteException e) { Log.e(TAG, e.getLocalizedMessage(), e); } } Loading @@ -135,6 +145,7 @@ public class ProfileManager try { getService().removeNotificationGroup(group); } catch (RemoteException e) { Log.e(TAG, e.getLocalizedMessage(), e); } } Loading @@ -143,6 +154,7 @@ public class ProfileManager try { return getService().getNotificationGroupForPackage(pkg); } catch (RemoteException e) { Log.e(TAG, e.getLocalizedMessage(), e); } return null; } Loading @@ -152,6 +164,7 @@ public class ProfileManager try { return getService().getNotificationGroup(name); } catch (RemoteException e) { Log.e(TAG, e.getLocalizedMessage(), e); } return null; } Loading @@ -160,7 +173,9 @@ public class ProfileManager public ProfileGroup getActiveProfileGroup(String packageName) { NotificationGroup notificationGroup = getNotificationGroupForPackage(packageName); if(notificationGroup == null){ return getActiveProfile().getDefaultGroup(); ProfileGroup defaultGroup = getActiveProfile().getDefaultGroup(); Log.v(TAG, "No active group, returning default: " + (defaultGroup == null ? "null" : defaultGroup.getName())); return defaultGroup; } String notificationGroupName = notificationGroup.getName(); return getActiveProfile().getProfileGroup(notificationGroupName); Loading
media/java/android/media/AudioManager.java +17 −9 Original line number Diff line number Diff line Loading @@ -601,8 +601,13 @@ public class AudioManager { * @see #getVibrateSetting(int) */ public boolean shouldVibrate(int vibrateType) { ProfileGroup profileGroup = mProfileManager.getActiveProfileGroup(mContext.getPackageName()); String packageName = mContext.getPackageName(); // Don't apply profiles for "android" context, as these could // come from the NotificationManager, and originate from a real package. if(!packageName.equals("android")){ ProfileGroup profileGroup = mProfileManager.getActiveProfileGroup(packageName); if(profileGroup != null){ Log.v(TAG, "shouldVibrate, group: " + profileGroup.getName() + " mode: " + profileGroup.getVibrateMode()); switch(profileGroup.getVibrateMode()){ case OVERRIDE : return true; Loading @@ -612,6 +617,9 @@ public class AudioManager { // Drop through } } }else{ Log.v(TAG, "Not applying override for 'android' package"); } IAudioService service = getService(); try { return service.shouldVibrate(vibrateType); Loading
services/java/com/android/server/NotificationManagerService.java +2 −0 Original line number Diff line number Diff line Loading @@ -964,7 +964,9 @@ public class NotificationManagerService extends INotificationManager.Stub .getSystemService(Context.PROFILE_SERVICE); Profile currentProfile = profileManager.getActiveProfile(); Log.v(TAG, "Active profile: " + currentProfile.getName()); ProfileGroup group = profileManager.getActiveProfileGroup(pkg); Log.v(TAG, "Pkg: " + pkg + " group: " + group.getName()); notification = currentProfile.processNotification(group.getName(), notification); }catch(Throwable th){ Log.e(TAG, "An error occurred profiling the notification.", th); Loading