am de6bd120: Merge "Notifications: Use new ACTION_USB_STATE broadcast to monitor USB connected state" into gingerbread
Merge commit 'de6bd120c97bb7986a6bac3889288f77bca63288' into gingerbread-plus-aosp * commit 'de6bd120c97bb7986a6bac3889288f77bca63288': Notifications: Use new ACTION_USB_STATE broadcast to monitor USB connected state
This commit is contained in:
@@ -38,9 +38,11 @@ import android.content.pm.PackageManager;
|
|||||||
import android.content.pm.PackageManager.NameNotFoundException;
|
import android.content.pm.PackageManager.NameNotFoundException;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.database.ContentObserver;
|
import android.database.ContentObserver;
|
||||||
|
import android.hardware.Usb;
|
||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.BatteryManager;
|
import android.os.BatteryManager;
|
||||||
|
import android.os.Bundle;
|
||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
@@ -111,8 +113,6 @@ class NotificationManagerService extends INotificationManager.Stub
|
|||||||
private boolean mNotificationPulseEnabled;
|
private boolean mNotificationPulseEnabled;
|
||||||
|
|
||||||
// for adb connected notifications
|
// for adb connected notifications
|
||||||
private boolean mUsbConnected;
|
|
||||||
private boolean mAdbEnabled = false;
|
|
||||||
private boolean mAdbNotificationShown = false;
|
private boolean mAdbNotificationShown = false;
|
||||||
private Notification mAdbNotification;
|
private Notification mAdbNotification;
|
||||||
|
|
||||||
@@ -346,12 +346,14 @@ class NotificationManagerService extends INotificationManager.Stub
|
|||||||
mBatteryFull = batteryFull;
|
mBatteryFull = batteryFull;
|
||||||
updateLights();
|
updateLights();
|
||||||
}
|
}
|
||||||
} else if (action.equals(Intent.ACTION_UMS_CONNECTED)) {
|
} else if (action.equals(Usb.ACTION_USB_STATE)) {
|
||||||
mUsbConnected = true;
|
Bundle extras = intent.getExtras();
|
||||||
updateAdbNotification();
|
boolean usbConnected = extras.getBoolean(Usb.USB_CONNECTED);
|
||||||
} else if (action.equals(Intent.ACTION_UMS_DISCONNECTED)) {
|
boolean adbEnabled = (Usb.USB_FUNCTION_ENABLED.equals(
|
||||||
mUsbConnected = false;
|
extras.getString(Usb.USB_FUNCTION_ADB)));
|
||||||
updateAdbNotification();
|
updateAdbNotification(usbConnected && adbEnabled);
|
||||||
|
} else if (action.equals(Usb.ACTION_USB_DISCONNECTED)) {
|
||||||
|
updateAdbNotification(false);
|
||||||
} else if (action.equals(Intent.ACTION_PACKAGE_REMOVED)
|
} else if (action.equals(Intent.ACTION_PACKAGE_REMOVED)
|
||||||
|| action.equals(Intent.ACTION_PACKAGE_RESTARTED)
|
|| action.equals(Intent.ACTION_PACKAGE_RESTARTED)
|
||||||
|| (queryRestart=action.equals(Intent.ACTION_QUERY_PACKAGE_RESTART))
|
|| (queryRestart=action.equals(Intent.ACTION_QUERY_PACKAGE_RESTART))
|
||||||
@@ -397,8 +399,6 @@ class NotificationManagerService extends INotificationManager.Stub
|
|||||||
|
|
||||||
void observe() {
|
void observe() {
|
||||||
ContentResolver resolver = mContext.getContentResolver();
|
ContentResolver resolver = mContext.getContentResolver();
|
||||||
resolver.registerContentObserver(Settings.Secure.getUriFor(
|
|
||||||
Settings.Secure.ADB_ENABLED), false, this);
|
|
||||||
resolver.registerContentObserver(Settings.System.getUriFor(
|
resolver.registerContentObserver(Settings.System.getUriFor(
|
||||||
Settings.System.NOTIFICATION_LIGHT_PULSE), false, this);
|
Settings.System.NOTIFICATION_LIGHT_PULSE), false, this);
|
||||||
update();
|
update();
|
||||||
@@ -410,12 +410,6 @@ class NotificationManagerService extends INotificationManager.Stub
|
|||||||
|
|
||||||
public void update() {
|
public void update() {
|
||||||
ContentResolver resolver = mContext.getContentResolver();
|
ContentResolver resolver = mContext.getContentResolver();
|
||||||
boolean adbEnabled = Settings.Secure.getInt(resolver,
|
|
||||||
Settings.Secure.ADB_ENABLED, 0) != 0;
|
|
||||||
if (mAdbEnabled != adbEnabled) {
|
|
||||||
mAdbEnabled = adbEnabled;
|
|
||||||
updateAdbNotification();
|
|
||||||
}
|
|
||||||
boolean pulseEnabled = Settings.System.getInt(resolver,
|
boolean pulseEnabled = Settings.System.getInt(resolver,
|
||||||
Settings.System.NOTIFICATION_LIGHT_PULSE, 0) != 0;
|
Settings.System.NOTIFICATION_LIGHT_PULSE, 0) != 0;
|
||||||
if (mNotificationPulseEnabled != pulseEnabled) {
|
if (mNotificationPulseEnabled != pulseEnabled) {
|
||||||
@@ -464,8 +458,7 @@ class NotificationManagerService extends INotificationManager.Stub
|
|||||||
// register for battery changed notifications
|
// register for battery changed notifications
|
||||||
IntentFilter filter = new IntentFilter();
|
IntentFilter filter = new IntentFilter();
|
||||||
filter.addAction(Intent.ACTION_BATTERY_CHANGED);
|
filter.addAction(Intent.ACTION_BATTERY_CHANGED);
|
||||||
filter.addAction(Intent.ACTION_UMS_CONNECTED);
|
filter.addAction(Usb.ACTION_USB_STATE);
|
||||||
filter.addAction(Intent.ACTION_UMS_DISCONNECTED);
|
|
||||||
filter.addAction(Intent.ACTION_SCREEN_ON);
|
filter.addAction(Intent.ACTION_SCREEN_ON);
|
||||||
filter.addAction(Intent.ACTION_SCREEN_OFF);
|
filter.addAction(Intent.ACTION_SCREEN_OFF);
|
||||||
filter.addAction(TelephonyManager.ACTION_PHONE_STATE_CHANGED);
|
filter.addAction(TelephonyManager.ACTION_PHONE_STATE_CHANGED);
|
||||||
@@ -1137,8 +1130,8 @@ class NotificationManagerService extends INotificationManager.Stub
|
|||||||
// This is here instead of StatusBarPolicy because it is an important
|
// This is here instead of StatusBarPolicy because it is an important
|
||||||
// security feature that we don't want people customizing the platform
|
// security feature that we don't want people customizing the platform
|
||||||
// to accidentally lose.
|
// to accidentally lose.
|
||||||
private void updateAdbNotification() {
|
private void updateAdbNotification(boolean adbEnabled) {
|
||||||
if (mAdbEnabled && mUsbConnected) {
|
if (adbEnabled) {
|
||||||
if ("0".equals(SystemProperties.get("persist.adb.notify"))) {
|
if ("0".equals(SystemProperties.get("persist.adb.notify"))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user