import android.os.RemoteException;
import android.os.UserHandle;
import android.os.SystemProperties;
-import android.provider.Settings;
import android.util.Log;
+import com.android.internal.notification.SystemNotificationChannels;
import com.android.internal.R;
import com.android.internal.telephony.GsmAlphabet;
import com.android.internal.telephony.TelephonyProperties;
public static final String NI_INTENT_KEY_TIMEOUT = "timeout";
public static final String NI_INTENT_KEY_DEFAULT_RESPONSE = "default_resp";
- // the extra command to send NI response to GpsLocationProvider
+ // the extra command to send NI response to GnssLocationProvider
public static final String NI_RESPONSE_EXTRA_CMD = "send_ni_response";
// the extra command parameter names in the Bundle
public String text;
public int requestorIdEncoding;
public int textEncoding;
- public Bundle extras;
};
public static class GpsNiResponse {
/* User response, one of the values in GpsUserResponseType */
int userResponse;
- /* Optional extra data to pass with the user response */
- Bundle extras;
};
private final BroadcastReceiver mBroadcastReciever = new BroadcastReceiver() {
* <p>
* This is lazily created, so use {@link #setNINotification()}.
*/
- private Notification mNiNotification;
+ private Notification.Builder mNiNotificationBuilder;
public GpsNetInitiatedHandler(Context context,
INetInitiatedListener netInitiatedListener,
}
public boolean getInEmergency() {
- boolean isInEmergencyCallback = Boolean.parseBoolean(
- SystemProperties.get(TelephonyProperties.PROPERTY_INECM_MODE));
+ boolean isInEmergencyCallback = mTelephonyManager.getEmergencyCallbackMode();
return mIsInEmergency || isInEmergencyCallback;
}
", message: " + message);
// Construct Notification
- if (mNiNotification == null) {
- mNiNotification = new Notification();
- mNiNotification.icon = com.android.internal.R.drawable.stat_sys_gps_on; /* Change notification icon here */
- mNiNotification.when = 0;
+ if (mNiNotificationBuilder == null) {
+ mNiNotificationBuilder = new Notification.Builder(mContext,
+ SystemNotificationChannels.NETWORK_ALERTS)
+ .setSmallIcon(com.android.internal.R.drawable.stat_sys_gps_on)
+ .setWhen(0)
+ .setOngoing(true)
+ .setAutoCancel(true)
+ .setColor(mContext.getColor(
+ com.android.internal.R.color.system_notification_accent_color));
}
if (mPlaySounds) {
- mNiNotification.defaults |= Notification.DEFAULT_SOUND;
+ mNiNotificationBuilder.setDefaults(Notification.DEFAULT_SOUND);
} else {
- mNiNotification.defaults &= ~Notification.DEFAULT_SOUND;
+ mNiNotificationBuilder.setDefaults(0);
}
- mNiNotification.flags = Notification.FLAG_ONGOING_EVENT | Notification.FLAG_AUTO_CANCEL;
- mNiNotification.tickerText = getNotifTicker(notif, mContext);
-
// if not to popup dialog immediately, pending intent will open the dialog
Intent intent = !mPopupImmediately ? getDlgIntent(notif) : new Intent();
PendingIntent pi = PendingIntent.getBroadcast(mContext, 0, intent, 0);
- mNiNotification.color = mContext.getResources().getColor(
- com.android.internal.R.color.system_notification_accent_color);
- mNiNotification.setLatestEventInfo(mContext, title, message, pi);
+ mNiNotificationBuilder.setTicker(getNotifTicker(notif, mContext))
+ .setContentTitle(title)
+ .setContentText(message)
+ .setContentIntent(pi);
- notificationManager.notifyAsUser(null, notif.notificationId, mNiNotification,
+ notificationManager.notifyAsUser(null, notif.notificationId, mNiNotificationBuilder.build(),
UserHandle.ALL);
}