Loading packages/SystemUI/src/com/android/systemui/SystemUIService.java +1 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ public class SystemUIService extends Service { private final Class<?>[] SERVICES = new Class[] { com.android.systemui.recent.Recents.class, com.android.systemui.statusbar.SystemBars.class, com.android.systemui.usb.StorageNotification.class, com.android.systemui.power.PowerUI.class, com.android.systemui.media.RingtonePlayer.class, com.android.systemui.settings.SettingsUI.class, Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java +0 −10 Original line number Diff line number Diff line Loading @@ -24,7 +24,6 @@ import android.content.Intent; import android.content.IntentFilter; import android.media.AudioManager; import android.os.Handler; import android.os.storage.StorageManager; import android.util.Log; import com.android.internal.telephony.IccCardConstants; Loading Loading @@ -57,10 +56,6 @@ public class PhoneStatusBarPolicy { private final StatusBarManager mService; private final Handler mHandler = new Handler(); // storage private StorageManager mStorageManager; // Assume it's all good unless we hear otherwise. We don't always seem // to get broadcasts that it *is* there. IccCardConstants.State mSimState = IccCardConstants.State.READY; Loading Loading @@ -136,11 +131,6 @@ public class PhoneStatusBarPolicy { filter.addAction(TtyIntent.TTY_ENABLED_CHANGE_ACTION); mContext.registerReceiver(mIntentReceiver, filter, null, mHandler); // storage mStorageManager = (StorageManager) context.getSystemService(Context.STORAGE_SERVICE); mStorageManager.registerListener( new com.android.systemui.usb.StorageNotification(context)); // TTY status mService.setIcon("tty", R.drawable.stat_sys_tty_mode, 0, null); mService.setIconVisibility("tty", false); Loading packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java +29 −37 Original line number Diff line number Diff line Loading @@ -31,17 +31,14 @@ import android.os.storage.StorageManager; import android.provider.Settings; import android.util.Log; public class StorageNotification extends StorageEventListener { import com.android.systemui.SystemUI; public class StorageNotification extends SystemUI { private static final String TAG = "StorageNotification"; private static final boolean DEBUG = false; private static final boolean POP_UMS_ACTIVITY_ON_CONNECT = true; /** * Binder context for this service */ private Context mContext; /** * The notification that is shown when a USB mass storage host * is connected. Loading @@ -66,10 +63,29 @@ public class StorageNotification extends StorageEventListener { private Handler mAsyncEventHandler; public StorageNotification(Context context) { mContext = context; private class StorageNotificationEventListener extends StorageEventListener { public void onUsbMassStorageConnectionChanged(final boolean connected) { mAsyncEventHandler.post(new Runnable() { @Override public void run() { onUsbMassStorageConnectionChangedAsync(connected); } }); } public void onStorageStateChanged(final String path, final String oldState, final String newState) { mAsyncEventHandler.post(new Runnable() { @Override public void run() { onStorageStateChangedAsync(path, oldState, newState); } }); } } mStorageManager = (StorageManager) context.getSystemService(Context.STORAGE_SERVICE); @Override public void start() { mStorageManager = (StorageManager) mContext.getSystemService(Context.STORAGE_SERVICE); final boolean connected = mStorageManager.isUsbMassStorageConnected(); if (DEBUG) Log.d(TAG, String.format( "Startup with UMS connection %s (media state %s)", mUmsAvailable, Environment.getExternalStorageState())); Loading @@ -78,20 +94,9 @@ public class StorageNotification extends StorageEventListener { thr.start(); mAsyncEventHandler = new Handler(thr.getLooper()); onUsbMassStorageConnectionChanged(connected); } /* * @override com.android.os.storage.StorageEventListener */ @Override public void onUsbMassStorageConnectionChanged(final boolean connected) { mAsyncEventHandler.post(new Runnable() { @Override public void run() { onUsbMassStorageConnectionChangedAsync(connected); } }); StorageNotificationEventListener listener = new StorageNotificationEventListener(); listener.onUsbMassStorageConnectionChanged(connected); mStorageManager.registerListener(listener); } private void onUsbMassStorageConnectionChangedAsync(boolean connected) { Loading @@ -115,19 +120,6 @@ public class StorageNotification extends StorageEventListener { updateUsbMassStorageNotification(connected); } /* * @override com.android.os.storage.StorageEventListener */ @Override public void onStorageStateChanged(final String path, final String oldState, final String newState) { mAsyncEventHandler.post(new Runnable() { @Override public void run() { onStorageStateChangedAsync(path, oldState, newState); } }); } private void onStorageStateChangedAsync(String path, String oldState, String newState) { if (DEBUG) Log.i(TAG, String.format( "Media {%s} state changed from {%s} -> {%s}", path, oldState, newState)); Loading Loading
packages/SystemUI/src/com/android/systemui/SystemUIService.java +1 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ public class SystemUIService extends Service { private final Class<?>[] SERVICES = new Class[] { com.android.systemui.recent.Recents.class, com.android.systemui.statusbar.SystemBars.class, com.android.systemui.usb.StorageNotification.class, com.android.systemui.power.PowerUI.class, com.android.systemui.media.RingtonePlayer.class, com.android.systemui.settings.SettingsUI.class, Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java +0 −10 Original line number Diff line number Diff line Loading @@ -24,7 +24,6 @@ import android.content.Intent; import android.content.IntentFilter; import android.media.AudioManager; import android.os.Handler; import android.os.storage.StorageManager; import android.util.Log; import com.android.internal.telephony.IccCardConstants; Loading Loading @@ -57,10 +56,6 @@ public class PhoneStatusBarPolicy { private final StatusBarManager mService; private final Handler mHandler = new Handler(); // storage private StorageManager mStorageManager; // Assume it's all good unless we hear otherwise. We don't always seem // to get broadcasts that it *is* there. IccCardConstants.State mSimState = IccCardConstants.State.READY; Loading Loading @@ -136,11 +131,6 @@ public class PhoneStatusBarPolicy { filter.addAction(TtyIntent.TTY_ENABLED_CHANGE_ACTION); mContext.registerReceiver(mIntentReceiver, filter, null, mHandler); // storage mStorageManager = (StorageManager) context.getSystemService(Context.STORAGE_SERVICE); mStorageManager.registerListener( new com.android.systemui.usb.StorageNotification(context)); // TTY status mService.setIcon("tty", R.drawable.stat_sys_tty_mode, 0, null); mService.setIconVisibility("tty", false); Loading
packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java +29 −37 Original line number Diff line number Diff line Loading @@ -31,17 +31,14 @@ import android.os.storage.StorageManager; import android.provider.Settings; import android.util.Log; public class StorageNotification extends StorageEventListener { import com.android.systemui.SystemUI; public class StorageNotification extends SystemUI { private static final String TAG = "StorageNotification"; private static final boolean DEBUG = false; private static final boolean POP_UMS_ACTIVITY_ON_CONNECT = true; /** * Binder context for this service */ private Context mContext; /** * The notification that is shown when a USB mass storage host * is connected. Loading @@ -66,10 +63,29 @@ public class StorageNotification extends StorageEventListener { private Handler mAsyncEventHandler; public StorageNotification(Context context) { mContext = context; private class StorageNotificationEventListener extends StorageEventListener { public void onUsbMassStorageConnectionChanged(final boolean connected) { mAsyncEventHandler.post(new Runnable() { @Override public void run() { onUsbMassStorageConnectionChangedAsync(connected); } }); } public void onStorageStateChanged(final String path, final String oldState, final String newState) { mAsyncEventHandler.post(new Runnable() { @Override public void run() { onStorageStateChangedAsync(path, oldState, newState); } }); } } mStorageManager = (StorageManager) context.getSystemService(Context.STORAGE_SERVICE); @Override public void start() { mStorageManager = (StorageManager) mContext.getSystemService(Context.STORAGE_SERVICE); final boolean connected = mStorageManager.isUsbMassStorageConnected(); if (DEBUG) Log.d(TAG, String.format( "Startup with UMS connection %s (media state %s)", mUmsAvailable, Environment.getExternalStorageState())); Loading @@ -78,20 +94,9 @@ public class StorageNotification extends StorageEventListener { thr.start(); mAsyncEventHandler = new Handler(thr.getLooper()); onUsbMassStorageConnectionChanged(connected); } /* * @override com.android.os.storage.StorageEventListener */ @Override public void onUsbMassStorageConnectionChanged(final boolean connected) { mAsyncEventHandler.post(new Runnable() { @Override public void run() { onUsbMassStorageConnectionChangedAsync(connected); } }); StorageNotificationEventListener listener = new StorageNotificationEventListener(); listener.onUsbMassStorageConnectionChanged(connected); mStorageManager.registerListener(listener); } private void onUsbMassStorageConnectionChangedAsync(boolean connected) { Loading @@ -115,19 +120,6 @@ public class StorageNotification extends StorageEventListener { updateUsbMassStorageNotification(connected); } /* * @override com.android.os.storage.StorageEventListener */ @Override public void onStorageStateChanged(final String path, final String oldState, final String newState) { mAsyncEventHandler.post(new Runnable() { @Override public void run() { onStorageStateChangedAsync(path, oldState, newState); } }); } private void onStorageStateChangedAsync(String path, String oldState, String newState) { if (DEBUG) Log.i(TAG, String.format( "Media {%s} state changed from {%s} -> {%s}", path, oldState, newState)); Loading