Loading core/java/android/app/INotificationManager.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ interface INotificationManager void enqueueToast(String pkg, ITransientNotification callback, int duration); void cancelToast(String pkg, ITransientNotification callback); void enqueueNotificationWithTag(String pkg, String tag, int id, in Notification notification, inout int[] idReceived); void enqueueNotificationWithTagPriority(String pkg, String tag, int id, int priority, in Notification notification, inout int[] idReceived); void cancelNotificationWithTag(String pkg, String tag, int id); } core/java/com/android/internal/statusbar/StatusBarNotification.java +1 −2 Original line number Diff line number Diff line Loading @@ -63,8 +63,7 @@ public class StatusBarNotification implements Parcelable { this.initialPid = initialPid; this.notification = notification; this.priority = ((notification.flags & Notification.FLAG_ONGOING_EVENT) != 0) ? PRIORITY_ONGOING : PRIORITY_NORMAL; this.priority = PRIORITY_NORMAL; } public StatusBarNotification(Parcel in) { Loading packages/SystemUI/res/values-es-rUS-xlarge/strings.xml +6 −0 Original line number Diff line number Diff line Loading @@ -22,4 +22,10 @@ <string name="status_bar_clear_all_button" msgid="4722520806446512408">"Eliminar todos"</string> <string name="status_bar_settings_signal_meter_disconnected" msgid="4684094636492991496">"Sin conexión a Int."</string> <string name="status_bar_settings_signal_meter_wifi_nossid" msgid="1456658018593445677">"WiFi conectado"</string> <!-- manually translated --> <string name="gps_notification_searching_text">Buscando señal de GPS</string> <!-- manually translated --> <string name="gps_notification_found_text">Ubicación establecida por el GPS</string> </resources> packages/SystemUI/res/values-xlarge/strings.xml +5 −0 Original line number Diff line number Diff line Loading @@ -38,4 +38,9 @@ <!-- Separator for PLMN and SPN in network name. --> <string name="status_bar_network_name_separator" translatable="false">" – "</string> <!-- Notification text: when GPS is getting a fix [CHAR LIMIT=50] --> <string name="gps_notification_searching_text">Searching for GPS</string> <!-- Notification text: when GPS has found a fix [CHAR LIMIT=50] --> <string name="gps_notification_found_text">Location set by GPS</string> </resources> packages/SystemUI/src/com/android/systemui/statusbar/policy/LocationController.java 0 → 100644 +114 −0 Original line number Diff line number Diff line /* * Copyright (C) 2008 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 com.android.systemui.statusbar.policy; import java.util.ArrayList; import android.app.Notification; import android.app.NotificationManager; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.location.LocationManager; import android.util.Slog; import android.view.View; import android.widget.ImageView; // private NM API import android.app.INotificationManager; import com.android.internal.statusbar.StatusBarNotification; import com.android.systemui.R; public class LocationController extends BroadcastReceiver { private static final String TAG = "StatusBar.LocationController"; private static final int GPS_NOTIFICATION_ID = 374203-122084; private Context mContext; private INotificationManager mNotificationService; public LocationController(Context context) { mContext = context; IntentFilter filter = new IntentFilter(); filter.addAction(LocationManager.GPS_ENABLED_CHANGE_ACTION); filter.addAction(LocationManager.GPS_FIX_CHANGE_ACTION); context.registerReceiver(this, filter); NotificationManager nm = (NotificationManager)context.getSystemService( Context.NOTIFICATION_SERVICE); mNotificationService = nm.getService(); } @Override public void onReceive(Context context, Intent intent) { final String action = intent.getAction(); final boolean enabled = intent.getBooleanExtra(LocationManager.EXTRA_GPS_ENABLED, false); boolean visible; int iconId, textResId; if (action.equals(LocationManager.GPS_FIX_CHANGE_ACTION) && enabled) { // GPS is getting fixes iconId = com.android.internal.R.drawable.stat_sys_gps_on; textResId = R.string.gps_notification_found_text; visible = true; } else if (action.equals(LocationManager.GPS_ENABLED_CHANGE_ACTION) && !enabled) { // GPS is off visible = false; iconId = textResId = 0; } else { // GPS is on, but not receiving fixes iconId = R.drawable.stat_sys_gps_acquiring_anim; textResId = R.string.gps_notification_searching_text; visible = true; } try { if (visible) { Notification n = new Notification.Builder(mContext) .setSmallIcon(iconId) .setContentTitle(mContext.getText(textResId)) .setOngoing(true) .getNotification(); // Notification.Builder will helpfully fill these out for you no matter what you do n.tickerView = null; n.tickerText = null; int[] idOut = new int[1]; mNotificationService.enqueueNotificationWithTagPriority( mContext.getPackageName(), null, GPS_NOTIFICATION_ID, StatusBarNotification.PRIORITY_SYSTEM, // !!!1!one!!! n, idOut); } else { mNotificationService.cancelNotification( mContext.getPackageName(), GPS_NOTIFICATION_ID); } } catch (android.os.RemoteException ex) { // well, it was worth a shot } } } Loading
core/java/android/app/INotificationManager.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ interface INotificationManager void enqueueToast(String pkg, ITransientNotification callback, int duration); void cancelToast(String pkg, ITransientNotification callback); void enqueueNotificationWithTag(String pkg, String tag, int id, in Notification notification, inout int[] idReceived); void enqueueNotificationWithTagPriority(String pkg, String tag, int id, int priority, in Notification notification, inout int[] idReceived); void cancelNotificationWithTag(String pkg, String tag, int id); }
core/java/com/android/internal/statusbar/StatusBarNotification.java +1 −2 Original line number Diff line number Diff line Loading @@ -63,8 +63,7 @@ public class StatusBarNotification implements Parcelable { this.initialPid = initialPid; this.notification = notification; this.priority = ((notification.flags & Notification.FLAG_ONGOING_EVENT) != 0) ? PRIORITY_ONGOING : PRIORITY_NORMAL; this.priority = PRIORITY_NORMAL; } public StatusBarNotification(Parcel in) { Loading
packages/SystemUI/res/values-es-rUS-xlarge/strings.xml +6 −0 Original line number Diff line number Diff line Loading @@ -22,4 +22,10 @@ <string name="status_bar_clear_all_button" msgid="4722520806446512408">"Eliminar todos"</string> <string name="status_bar_settings_signal_meter_disconnected" msgid="4684094636492991496">"Sin conexión a Int."</string> <string name="status_bar_settings_signal_meter_wifi_nossid" msgid="1456658018593445677">"WiFi conectado"</string> <!-- manually translated --> <string name="gps_notification_searching_text">Buscando señal de GPS</string> <!-- manually translated --> <string name="gps_notification_found_text">Ubicación establecida por el GPS</string> </resources>
packages/SystemUI/res/values-xlarge/strings.xml +5 −0 Original line number Diff line number Diff line Loading @@ -38,4 +38,9 @@ <!-- Separator for PLMN and SPN in network name. --> <string name="status_bar_network_name_separator" translatable="false">" – "</string> <!-- Notification text: when GPS is getting a fix [CHAR LIMIT=50] --> <string name="gps_notification_searching_text">Searching for GPS</string> <!-- Notification text: when GPS has found a fix [CHAR LIMIT=50] --> <string name="gps_notification_found_text">Location set by GPS</string> </resources>
packages/SystemUI/src/com/android/systemui/statusbar/policy/LocationController.java 0 → 100644 +114 −0 Original line number Diff line number Diff line /* * Copyright (C) 2008 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 com.android.systemui.statusbar.policy; import java.util.ArrayList; import android.app.Notification; import android.app.NotificationManager; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.location.LocationManager; import android.util.Slog; import android.view.View; import android.widget.ImageView; // private NM API import android.app.INotificationManager; import com.android.internal.statusbar.StatusBarNotification; import com.android.systemui.R; public class LocationController extends BroadcastReceiver { private static final String TAG = "StatusBar.LocationController"; private static final int GPS_NOTIFICATION_ID = 374203-122084; private Context mContext; private INotificationManager mNotificationService; public LocationController(Context context) { mContext = context; IntentFilter filter = new IntentFilter(); filter.addAction(LocationManager.GPS_ENABLED_CHANGE_ACTION); filter.addAction(LocationManager.GPS_FIX_CHANGE_ACTION); context.registerReceiver(this, filter); NotificationManager nm = (NotificationManager)context.getSystemService( Context.NOTIFICATION_SERVICE); mNotificationService = nm.getService(); } @Override public void onReceive(Context context, Intent intent) { final String action = intent.getAction(); final boolean enabled = intent.getBooleanExtra(LocationManager.EXTRA_GPS_ENABLED, false); boolean visible; int iconId, textResId; if (action.equals(LocationManager.GPS_FIX_CHANGE_ACTION) && enabled) { // GPS is getting fixes iconId = com.android.internal.R.drawable.stat_sys_gps_on; textResId = R.string.gps_notification_found_text; visible = true; } else if (action.equals(LocationManager.GPS_ENABLED_CHANGE_ACTION) && !enabled) { // GPS is off visible = false; iconId = textResId = 0; } else { // GPS is on, but not receiving fixes iconId = R.drawable.stat_sys_gps_acquiring_anim; textResId = R.string.gps_notification_searching_text; visible = true; } try { if (visible) { Notification n = new Notification.Builder(mContext) .setSmallIcon(iconId) .setContentTitle(mContext.getText(textResId)) .setOngoing(true) .getNotification(); // Notification.Builder will helpfully fill these out for you no matter what you do n.tickerView = null; n.tickerText = null; int[] idOut = new int[1]; mNotificationService.enqueueNotificationWithTagPriority( mContext.getPackageName(), null, GPS_NOTIFICATION_ID, StatusBarNotification.PRIORITY_SYSTEM, // !!!1!one!!! n, idOut); } else { mNotificationService.cancelNotification( mContext.getPackageName(), GPS_NOTIFICATION_ID); } } catch (android.os.RemoteException ex) { // well, it was worth a shot } } }