am 906b830d: Revert "UMS: Avoid SystemUI ANRs during long vold operations."
* commit '906b830d1d61cbd8b1f9c2dc87e564cfb0f315fd': Revert "UMS: Avoid SystemUI ANRs during long vold operations."
This commit is contained in:
@@ -23,8 +23,6 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.os.Handler;
|
|
||||||
import android.os.HandlerThread;
|
|
||||||
import android.os.storage.StorageEventListener;
|
import android.os.storage.StorageEventListener;
|
||||||
import android.os.storage.StorageManager;
|
import android.os.storage.StorageManager;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
@@ -62,8 +60,6 @@ public class StorageNotification extends StorageEventListener {
|
|||||||
private boolean mUmsAvailable;
|
private boolean mUmsAvailable;
|
||||||
private StorageManager mStorageManager;
|
private StorageManager mStorageManager;
|
||||||
|
|
||||||
private Handler mAsyncEventHandler;
|
|
||||||
|
|
||||||
public StorageNotification(Context context) {
|
public StorageNotification(Context context) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
|
|
||||||
@@ -71,11 +67,6 @@ public class StorageNotification extends StorageEventListener {
|
|||||||
final boolean connected = mStorageManager.isUsbMassStorageConnected();
|
final boolean connected = mStorageManager.isUsbMassStorageConnected();
|
||||||
Slog.d(TAG, String.format( "Startup with UMS connection %s (media state %s)", mUmsAvailable,
|
Slog.d(TAG, String.format( "Startup with UMS connection %s (media state %s)", mUmsAvailable,
|
||||||
Environment.getExternalStorageState()));
|
Environment.getExternalStorageState()));
|
||||||
|
|
||||||
HandlerThread thr = new HandlerThread("SystemUI StorageNotification");
|
|
||||||
thr.start();
|
|
||||||
mAsyncEventHandler = new Handler(thr.getLooper());
|
|
||||||
|
|
||||||
onUsbMassStorageConnectionChanged(connected);
|
onUsbMassStorageConnectionChanged(connected);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,16 +74,7 @@ public class StorageNotification extends StorageEventListener {
|
|||||||
* @override com.android.os.storage.StorageEventListener
|
* @override com.android.os.storage.StorageEventListener
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onUsbMassStorageConnectionChanged(final boolean connected) {
|
public void onUsbMassStorageConnectionChanged(boolean connected) {
|
||||||
mAsyncEventHandler.post(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
onUsbMassStorageConnectionChangedAsync(connected);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onUsbMassStorageConnectionChangedAsync(boolean connected) {
|
|
||||||
mUmsAvailable = connected;
|
mUmsAvailable = connected;
|
||||||
/*
|
/*
|
||||||
* Even though we may have a UMS host connected, we the SD card
|
* Even though we may have a UMS host connected, we the SD card
|
||||||
@@ -116,16 +98,7 @@ public class StorageNotification extends StorageEventListener {
|
|||||||
* @override com.android.os.storage.StorageEventListener
|
* @override com.android.os.storage.StorageEventListener
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onStorageStateChanged(final String path, final String oldState, final String newState) {
|
public void onStorageStateChanged(String path, String oldState, String newState) {
|
||||||
mAsyncEventHandler.post(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
onStorageStateChanged(path, oldState, newState);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onStorageStateChangedAsync(String path, String oldState, String newState) {
|
|
||||||
Slog.i(TAG, String.format(
|
Slog.i(TAG, String.format(
|
||||||
"Media {%s} state changed from {%s} -> {%s}", path, oldState, newState));
|
"Media {%s} state changed from {%s} -> {%s}", path, oldState, newState));
|
||||||
if (newState.equals(Environment.MEDIA_SHARED)) {
|
if (newState.equals(Environment.MEDIA_SHARED)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user