Settings: Refactor for new API and remove some unused references / imports
Signed-off-by: San Mehat <san@google.com>
This commit is contained in:
@@ -27,7 +27,6 @@ import android.content.Intent;
|
|||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.IMountService;
|
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
import android.preference.CheckBoxPreference;
|
import android.preference.CheckBoxPreference;
|
||||||
|
@@ -23,7 +23,7 @@ import android.app.AlertDialog;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.IMountService;
|
import android.os.storage.IMountService;
|
||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
import android.os.SystemProperties;
|
import android.os.SystemProperties;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
|
@@ -24,9 +24,10 @@ import android.content.IntentFilter;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.os.IMountService;
|
|
||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
import android.os.StatFs;
|
import android.os.StatFs;
|
||||||
|
import android.os.storage.StorageManager;
|
||||||
|
import android.os.storage.IMountService;
|
||||||
import android.text.format.Formatter;
|
import android.text.format.Formatter;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
@@ -45,6 +46,7 @@ public class SdCardSettings extends Activity
|
|||||||
|
|
||||||
setContentView(R.layout.sdcard_settings_screen);
|
setContentView(R.layout.sdcard_settings_screen);
|
||||||
|
|
||||||
|
mStorageManager = (StorageManager) getSystemService(Context.STORAGE_SERVICE);
|
||||||
mMountService = IMountService.Stub.asInterface(ServiceManager.getService("mount"));
|
mMountService = IMountService.Stub.asInterface(ServiceManager.getService("mount"));
|
||||||
|
|
||||||
mRemovedLayout = findViewById(R.id.removed);
|
mRemovedLayout = findViewById(R.id.removed);
|
||||||
@@ -105,10 +107,7 @@ public class SdCardSettings extends Activity
|
|||||||
private void update() {
|
private void update() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String path = Environment.getExternalStorageDirectory().getPath();
|
mMassStorage.setChecked(mStorageManager.isUsbMassStorageEnabled());
|
||||||
mMassStorage.setChecked(
|
|
||||||
mMountService.getVolumeShared(
|
|
||||||
Environment.getExternalStorageDirectory().getPath(), "ums"));
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,11 +157,9 @@ public class SdCardSettings extends Activity
|
|||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
try {
|
try {
|
||||||
if (mMassStorage.isChecked()) {
|
if (mMassStorage.isChecked()) {
|
||||||
mMountService.shareVolume(
|
mStorageManager.enableUsbMassStorage();
|
||||||
Environment.getExternalStorageDirectory().getPath(), "ums");
|
|
||||||
} else {
|
} else {
|
||||||
mMountService.unshareVolume(
|
mStorageManager.disableUsbMassStorage();
|
||||||
Environment.getExternalStorageDirectory().getPath(), "ums");
|
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
}
|
}
|
||||||
@@ -194,7 +191,8 @@ public class SdCardSettings extends Activity
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private IMountService mMountService;
|
private StorageManager mStorageManager;
|
||||||
|
private IMountService mMountService;
|
||||||
|
|
||||||
private CheckBox mMassStorage;
|
private CheckBox mMassStorage;
|
||||||
|
|
||||||
|
@@ -25,7 +25,6 @@ import android.content.Intent;
|
|||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.IMountService;
|
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
import android.preference.CheckBoxPreference;
|
import android.preference.CheckBoxPreference;
|
||||||
@@ -59,8 +58,6 @@ public class SoundSettings extends PreferenceActivity implements
|
|||||||
|
|
||||||
private CheckBoxPreference mSilent;
|
private CheckBoxPreference mSilent;
|
||||||
|
|
||||||
private IMountService mMountService = null;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If we are currently in one of the silent modes (the ringer mode is set to either
|
* If we are currently in one of the silent modes (the ringer mode is set to either
|
||||||
* "silent mode" or "vibrate mode"), then toggling the "Phone vibrate"
|
* "silent mode" or "vibrate mode"), then toggling the "Phone vibrate"
|
||||||
@@ -95,8 +92,6 @@ public class SoundSettings extends PreferenceActivity implements
|
|||||||
|
|
||||||
mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
|
mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
|
||||||
|
|
||||||
mMountService = IMountService.Stub.asInterface(ServiceManager.getService("mount"));
|
|
||||||
|
|
||||||
addPreferencesFromResource(R.xml.sound_settings);
|
addPreferencesFromResource(R.xml.sound_settings);
|
||||||
|
|
||||||
if (TelephonyManager.PHONE_TYPE_CDMA != activePhoneType) {
|
if (TelephonyManager.PHONE_TYPE_CDMA != activePhoneType) {
|
||||||
|
@@ -25,11 +25,11 @@ import android.os.Bundle;
|
|||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.os.IMountService;
|
import android.os.storage.IMountService;
|
||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
import android.os.StatFs;
|
import android.os.StatFs;
|
||||||
import android.storage.StorageManager;
|
import android.os.storage.StorageManager;
|
||||||
import android.storage.StorageEventListener;
|
import android.os.storage.StorageEventListener;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.preference.PreferenceActivity;
|
import android.preference.PreferenceActivity;
|
||||||
import android.preference.PreferenceScreen;
|
import android.preference.PreferenceScreen;
|
||||||
@@ -95,16 +95,6 @@ public class Memory extends PreferenceActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
StorageEventListener mStorageListener = new StorageEventListener() {
|
StorageEventListener mStorageListener = new StorageEventListener() {
|
||||||
public void onShareAvailabilityChanged(String method, boolean available) {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onMediaInserted(String label, String path, int major, int minor) {
|
|
||||||
updateMemoryStatus();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onMediaRemoved(String label, String path, int major, int minor, boolean clean) {
|
|
||||||
updateMemoryStatus();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onVolumeStateChanged(
|
public void onVolumeStateChanged(
|
||||||
String label, String path, String oldState, String newState) {
|
String label, String path, String oldState, String newState) {
|
||||||
|
Reference in New Issue
Block a user