Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7fe44a25 authored by Steve Kondik's avatar Steve Kondik Committed by Gerrit Code Review
Browse files

Merge "Fixed some bugs in Notification Profiles" into gingerbread

parents dfd7c8a9 f87b7c03
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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;
            }
        }
    }

+16 −1
Original line number Diff line number Diff line
@@ -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
{
@@ -54,6 +55,7 @@ public class ProfileManager
            getService().setActiveProfile(profileName);
            getService().persist();
        } catch (RemoteException e) {
            Log.e(TAG, e.getLocalizedMessage(), e);
        }
    }

@@ -61,6 +63,7 @@ public class ProfileManager
        try {
            return getService().getActiveProfile();
        } catch (RemoteException e) {
            Log.e(TAG, e.getLocalizedMessage(), e);
        }
        return null;
    }
@@ -71,6 +74,7 @@ public class ProfileManager
            getService().addProfile(profile);
            getService().persist();
        } catch (RemoteException e) {
            Log.e(TAG, e.getLocalizedMessage(), e);
        }
    }

@@ -79,6 +83,7 @@ public class ProfileManager
        try {
            getService().removeProfile(profile);
        } catch (RemoteException e) {
            Log.e(TAG, e.getLocalizedMessage(), e);
        }
    }

@@ -86,6 +91,7 @@ public class ProfileManager
        try {
            return getService().getProfile(profileName);
        } catch (RemoteException e) {
            Log.e(TAG, e.getLocalizedMessage(), e);
        }
        return null;
    }
@@ -100,6 +106,7 @@ public class ProfileManager
            }
            return names;
        } catch (RemoteException e) {
            Log.e(TAG, e.getLocalizedMessage(), e);
        }
        return null;
    }
@@ -108,6 +115,7 @@ public class ProfileManager
        try {
            return getService().getProfiles();
        } catch (RemoteException e) {
            Log.e(TAG, e.getLocalizedMessage(), e);
        }
        return null;
    }
@@ -117,6 +125,7 @@ public class ProfileManager
        try {
            return getService().getNotificationGroups();
        } catch (RemoteException e) {
            Log.e(TAG, e.getLocalizedMessage(), e);
        }
        return null;
    }
@@ -127,6 +136,7 @@ public class ProfileManager
            getService().addNotificationGroup(group);
            getService().persist();
        } catch (RemoteException e) {
            Log.e(TAG, e.getLocalizedMessage(), e);
        }
    }

@@ -135,6 +145,7 @@ public class ProfileManager
        try {
            getService().removeNotificationGroup(group);
        } catch (RemoteException e) {
            Log.e(TAG, e.getLocalizedMessage(), e);
        }
    }

@@ -143,6 +154,7 @@ public class ProfileManager
        try {
            return getService().getNotificationGroupForPackage(pkg);
        } catch (RemoteException e) {
            Log.e(TAG, e.getLocalizedMessage(), e);
        }
        return null;
    }
@@ -152,6 +164,7 @@ public class ProfileManager
        try {
            return getService().getNotificationGroup(name);
        } catch (RemoteException e) {
            Log.e(TAG, e.getLocalizedMessage(), e);
        }
        return null;
    }
@@ -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);
+17 −9
Original line number Diff line number Diff line
@@ -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;
@@ -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);
+2 −0
Original line number Diff line number Diff line
@@ -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);