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

Commit bdd5f60b authored by repo sync's avatar repo sync Committed by martinlong1978
Browse files

Added notification profile support.

This adds finer-grained support for notification tones, and groups settings into profiles,
which can be easily switched. API support is also added, allowing configuration, and profile
switching from another program (e.g. Tasker, Locale).

A profile represents a particular set of settings, and could be for example "Silent",
"Office", or "Night". Each profile contains the settings for a definable set of application
groups.

An application group represents a group of applications to which the settings should apply.
For example "SMS" might contain "Messaging" and "Handcent".

The applications in an application group are globally defined. The notification settings for
an application group are per-profile.

For each profile/application group you can define behaviour for lights/vibrate and sound.
Either you can suppress, override, or leave unchanged (ie system, or app default).

Example:

Work : SMS vibrate. Ringer vibrate. Email no alert. Gmail vibrate.
Night: SMS silent. Ringer on. Email silent. Gmail silent.

There is still a lot of work to be done here. A lot of code tidy up, javadocs, standards etc.
Might be suitable for nightlies.

This has been on dumb Nokias for years, I'm surprised a single smartphone doesn't have it yet.

Change-Id: I9662651dd597392dfe915f8cd81d66064f00bb76
parent 29f40ea8
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -83,6 +83,7 @@ LOCAL_SRC_FILES += \
	core/java/android/app/IBackupAgent.aidl \
	core/java/android/app/IInstrumentationWatcher.aidl \
	core/java/android/app/INotificationManager.aidl \
	core/java/android/app/IProfileManager.aidl \
	core/java/android/app/ISearchManager.aidl \
	core/java/android/app/ISearchManagerCallback.aidl \
	core/java/android/app/IServiceConnection.aidl \
@@ -241,6 +242,8 @@ aidl_files := \
	frameworks/base/core/java/android/accounts/IAccountAuthenticator.aidl \
	frameworks/base/core/java/android/accounts/IAccountAuthenticatorResponse.aidl \
	frameworks/base/core/java/android/app/Notification.aidl \
	frameworks/base/core/java/android/app/NotificationGroup.aidl \
	frameworks/base/core/java/android/app/Profile.aidl \
	frameworks/base/core/java/android/app/PendingIntent.aidl \
	frameworks/base/core/java/android/bluetooth/BluetoothDevice.aidl \
	frameworks/base/core/java/android/content/ComponentName.aidl \
+768 −1
Original line number Diff line number Diff line
@@ -24322,6 +24322,178 @@
>
</field>
</class>
<class name="NotificationGroup"
 extends="java.lang.Object"
 abstract="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<implements name="android.os.Parcelable">
</implements>
<constructor name="NotificationGroup"
 type="android.app.NotificationGroup"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="name" type="java.lang.String">
</parameter>
</constructor>
<method name="addPackage"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="pkg" type="java.lang.String">
</parameter>
</method>
<method name="describeContents"
 return="int"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="fromXml"
 return="android.app.NotificationGroup"
 abstract="false"
 native="false"
 synchronized="false"
 static="true"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="xpp" type="org.xmlpull.v1.XmlPullParser">
</parameter>
<exception name="IOException" type="java.io.IOException">
</exception>
<exception name="XmlPullParserException" type="org.xmlpull.v1.XmlPullParserException">
</exception>
</method>
<method name="getName"
 return="java.lang.String"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="getPackages"
 return="java.lang.String[]"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="getXmlString"
 return="java.lang.String"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="getXmlString"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="builder" type="java.lang.StringBuilder">
</parameter>
</method>
<method name="hasPackage"
 return="boolean"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="pkg" type="java.lang.String">
</parameter>
</method>
<method name="readFromParcel"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="in" type="android.os.Parcel">
</parameter>
</method>
<method name="removePackage"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="pkg" type="java.lang.String">
</parameter>
</method>
<method name="writeToParcel"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="dest" type="android.os.Parcel">
</parameter>
<parameter name="flags" type="int">
</parameter>
</method>
<field name="CREATOR"
 type="android.os.Parcelable.Creator"
 transient="false"
 volatile="false"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
</class>
<class name="NotificationManager"
 extends="java.lang.Object"
 abstract="false"
@@ -24766,6 +24938,590 @@
</parameter>
</method>
</interface>
<class name="Profile"
 extends="java.lang.Object"
 abstract="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<implements name="android.os.Parcelable">
</implements>
<constructor name="Profile"
 type="android.app.Profile"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="name" type="java.lang.String">
</parameter>
</constructor>
<method name="describeContents"
 return="int"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="ensureProfleGroup"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="groupName" type="java.lang.String">
</parameter>
</method>
<method name="fromXml"
 return="android.app.Profile"
 abstract="false"
 native="false"
 synchronized="false"
 static="true"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="xpp" type="org.xmlpull.v1.XmlPullParser">
</parameter>
<exception name="IOException" type="java.io.IOException">
</exception>
<exception name="XmlPullParserException" type="org.xmlpull.v1.XmlPullParserException">
</exception>
</method>
<method name="getName"
 return="java.lang.String"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="getProfileGroup"
 return="android.app.ProfileGroup"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="name" type="java.lang.String">
</parameter>
</method>
<method name="getProfileGroups"
 return="android.app.ProfileGroup[]"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="getXmlString"
 return="java.lang.String"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="getXmlString"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="builder" type="java.lang.StringBuilder">
</parameter>
</method>
<method name="processNotification"
 return="android.app.Notification"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="groupName" type="java.lang.String">
</parameter>
<parameter name="notification" type="android.app.Notification">
</parameter>
</method>
<method name="readFromParcel"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="in" type="android.os.Parcel">
</parameter>
</method>
<method name="removeProfileGroup"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="name" type="java.lang.String">
</parameter>
</method>
<method name="setName"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="name" type="java.lang.String">
</parameter>
</method>
<method name="writeToParcel"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="dest" type="android.os.Parcel">
</parameter>
<parameter name="flags" type="int">
</parameter>
</method>
<field name="CREATOR"
 type="android.os.Parcelable.Creator"
 transient="false"
 volatile="false"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
</class>
<class name="ProfileGroup"
 extends="java.lang.Object"
 abstract="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<implements name="android.os.Parcelable">
</implements>
<constructor name="ProfileGroup"
 type="android.app.ProfileGroup"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="name" type="java.lang.String">
</parameter>
</constructor>
<method name="describeContents"
 return="int"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="fromXml"
 return="android.app.ProfileGroup"
 abstract="false"
 native="false"
 synchronized="false"
 static="true"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="xpp" type="org.xmlpull.v1.XmlPullParser">
</parameter>
<exception name="IOException" type="java.io.IOException">
</exception>
<exception name="XmlPullParserException" type="org.xmlpull.v1.XmlPullParserException">
</exception>
</method>
<method name="getLightsMode"
 return="android.app.ProfileGroup.Mode"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="getName"
 return="java.lang.String"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="getSoundMode"
 return="android.app.ProfileGroup.Mode"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="getSoundOverride"
 return="android.net.Uri"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="getVibrateMode"
 return="android.app.ProfileGroup.Mode"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="getXmlString"
 return="java.lang.String"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="getXmlString"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="builder" type="java.lang.StringBuilder">
</parameter>
</method>
<method name="readFromParcel"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="in" type="android.os.Parcel">
</parameter>
</method>
<method name="setLightsMode"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="lightsMode" type="android.app.ProfileGroup.Mode">
</parameter>
</method>
<method name="setSoundMode"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="soundMode" type="android.app.ProfileGroup.Mode">
</parameter>
</method>
<method name="setSoundOverride"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="sound" type="android.net.Uri">
</parameter>
</method>
<method name="setVibrateMode"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="vibrateMode" type="android.app.ProfileGroup.Mode">
</parameter>
</method>
<method name="writeToParcel"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="dest" type="android.os.Parcel">
</parameter>
<parameter name="flags" type="int">
</parameter>
</method>
<field name="CREATOR"
 type="android.os.Parcelable.Creator"
 transient="false"
 volatile="false"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
</class>
<class name="ProfileGroup.Mode"
 extends="java.lang.Enum"
 abstract="false"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
<method name="valueOf"
 return="android.app.ProfileGroup.Mode"
 abstract="false"
 native="false"
 synchronized="false"
 static="true"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="name" type="java.lang.String">
</parameter>
</method>
<method name="values"
 return="android.app.ProfileGroup.Mode[]"
 abstract="false"
 native="false"
 synchronized="false"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</method>
</class>
<class name="ProfileManager"
 extends="java.lang.Object"
 abstract="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<method name="addNotificationGroup"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="group" type="android.app.NotificationGroup">
</parameter>
</method>
<method name="addProfile"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="profile" type="android.app.Profile">
</parameter>
</method>
<method name="getActiveProfile"
 return="android.app.Profile"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="getNotificationGroupForPackage"
 return="android.app.NotificationGroup"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="pkg" type="java.lang.String">
</parameter>
</method>
<method name="getNotificationGroups"
 return="android.app.NotificationGroup[]"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="getProfile"
 return="android.app.Profile"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="profileName" type="java.lang.String">
</parameter>
</method>
<method name="getProfiles"
 return="android.app.Profile[]"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="removeNotificationGroup"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="group" type="android.app.NotificationGroup">
</parameter>
</method>
<method name="removeProfile"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="profile" type="android.app.Profile">
</parameter>
</method>
<method name="setActiveProfile"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="profileName" type="java.lang.String">
</parameter>
</method>
</class>
<class name="ProgressDialog"
 extends="android.app.AlertDialog"
 abstract="false"
@@ -35816,6 +36572,17 @@
 visibility="public"
>
</field>
<field name="PROFILE_SERVICE"
 type="java.lang.String"
 transient="false"
 volatile="false"
 value="&quot;profile&quot;"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="SEARCH_SERVICE"
 type="java.lang.String"
 transient="false"
@@ -77083,7 +77850,7 @@
 type="float"
 transient="false"
 volatile="false"
 value="0.001f"
 value="0.0010f"
 static="true"
 final="true"
 deprecated="not deprecated"
+13 −0
Original line number Diff line number Diff line
@@ -193,6 +193,7 @@ class ContextImpl extends Context {
    private Resources.Theme mTheme = null;
    private PackageManager mPackageManager;
    private NotificationManager mNotificationManager = null;
    private ProfileManager mProfileManager = null;
    private ActivityManager mActivityManager = null;
    private WallpaperManager mWallpaperManager = null;
    private Context mReceiverRestrictedContext = null;
@@ -966,6 +967,8 @@ class ContextImpl extends Context {
            return getWimaxController();
        } else if (NOTIFICATION_SERVICE.equals(name)) {
            return getNotificationManager();
        } else if (PROFILE_SERVICE.equals(name)) {
            return getProfileManager();
        } else if (KEYGUARD_SERVICE.equals(name)) {
            return new KeyguardManager();
        } else if (ACCESSIBILITY_SERVICE.equals(name)) {
@@ -1131,6 +1134,16 @@ class ContextImpl extends Context {
        return mNotificationManager;
    }

    private ProfileManager getProfileManager() {
        synchronized (mSync) {
            if (mProfileManager == null) {
                mProfileManager = new ProfileManager(getOuterContext(),
                        mMainThread.getHandler());
            }
        }
        return mProfileManager;
    }

    private WallpaperManager getWallpaperManager() {
        synchronized (mSync) {
            if (mWallpaperManager == null) {
+40 −0
Original line number Diff line number Diff line
/* //device/java/android/android/app/IProfileManager.aidl
**
** Copyright 2007, 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 android.app;

import android.app.Profile;
import android.app.NotificationGroup;

/** {@hide} */
interface IProfileManager
{
    void setActiveProfile(in String profileName);
    Profile getActiveProfile();
    void addProfile(in Profile profile);
    void removeProfile(in Profile profile);
    Profile getProfile(String profileName);
    Profile[] getProfiles();
    void persist();

    NotificationGroup[] getNotificationGroups();
    void addNotificationGroup(in NotificationGroup group);
    void removeNotificationGroup(in NotificationGroup group);
    NotificationGroup getNotificationGroupForPackage(in String pkg);
    NotificationGroup getNotificationGroup(in String name);
 }
+19 −0
Original line number Diff line number Diff line
/**
 * Copyright (c) 2007, 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 android.app;

parcelable NotificationGroup;
Loading