Context.MODE_PRIVATE);
SharedPreferences.Editor editor = pref.edit();
editor.putBoolean(mAddress, true);
- editor.commit();
+ editor.apply();
}
private int modifyRcFeatureFromBlacklist(int feature, String address) {
Context.MODE_PRIVATE);
SharedPreferences.Editor editor = pref.edit();
editor.remove(address);
- editor.commit();
+ editor.apply();
}
/**
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
+import android.os.AsyncTask;
import android.os.BatteryStats;
import android.os.Binder;
import android.os.Bundle;
mProfileObserver.start();
setAdapterService(this);
+
+ // First call to getSharedPreferences will result in a file read into
+ // memory cache. Call it here asynchronously to avoid potential ANR
+ // in the future
+ new AsyncTask<Void, Void, Void>() {
+ @Override
+ protected Void doInBackground(Void... params) {
+ getSharedPreferences(
+ PHONEBOOK_ACCESS_PERMISSION_PREFERENCE_FILE, Context.MODE_PRIVATE);
+ getSharedPreferences(
+ MESSAGE_ACCESS_PERMISSION_PREFERENCE_FILE, Context.MODE_PRIVATE);
+ getSharedPreferences(SIM_ACCESS_PERMISSION_PREFERENCE_FILE, Context.MODE_PRIVATE);
+ return null;
+ }
+ }.execute();
}
@Override
} else {
editor.putBoolean(device.getAddress(), value == BluetoothDevice.ACCESS_ALLOWED);
}
- return editor.commit();
+ editor.apply();
+ return true;
}
int getMessageAccessPermission(BluetoothDevice device) {
} else {
editor.putBoolean(device.getAddress(), value == BluetoothDevice.ACCESS_ALLOWED);
}
- return editor.commit();
+ editor.apply();
+ return true;
}
int getSimAccessPermission(BluetoothDevice device) {
} else {
editor.putBoolean(device.getAddress(), value == BluetoothDevice.ACCESS_ALLOWED);
}
- return editor.commit();
+ editor.apply();
+ return true;
}
void sendConnectionStateChange(BluetoothDevice