Migrate PaymentSettings to DashboardFragment
- Move preference related logic to controllers. - Add some test cases for controllers. Test: manual Test: make RunSettingsRoboTests -j ROBOTEST_FILTER=com.android.settings.nfc make RunSettingsRoboTests -j ROBOTEST_FILTER=com.android.settings.core atest SettingsGatewayTest UniquePreferenceTest Change-Id: I061a194c170f63fab51974f26c24be43d67d6f6f
This commit is contained in:
@@ -25,7 +25,9 @@ import android.nfc.NfcAdapter;
|
||||
import android.nfc.cardemulation.ApduServiceInfo;
|
||||
import android.nfc.cardemulation.CardEmulation;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.os.UserHandle;
|
||||
import android.provider.Settings;
|
||||
import android.provider.Settings.SettingNotFoundException;
|
||||
|
||||
@@ -57,7 +59,7 @@ public class PaymentBackend {
|
||||
// Fields below only modified on UI thread
|
||||
private ArrayList<PaymentAppInfo> mAppInfos;
|
||||
private PaymentAppInfo mDefaultAppInfo;
|
||||
private ArrayList<Callback> mCallbacks = new ArrayList<Callback>();
|
||||
private ArrayList<Callback> mCallbacks = new ArrayList<>();
|
||||
|
||||
public PaymentBackend(Context context) {
|
||||
mContext = context;
|
||||
@@ -102,7 +104,8 @@ public class PaymentBackend {
|
||||
appInfo.componentName = service.getComponent();
|
||||
String settingsActivity = service.getSettingsActivityName();
|
||||
if (settingsActivity != null) {
|
||||
appInfo.settingsComponent = new ComponentName(appInfo.componentName.getPackageName(),
|
||||
appInfo.settingsComponent = new ComponentName(
|
||||
appInfo.componentName.getPackageName(),
|
||||
settingsActivity);
|
||||
} else {
|
||||
appInfo.settingsComponent = null;
|
||||
@@ -162,7 +165,7 @@ public class PaymentBackend {
|
||||
|
||||
void setForegroundMode(boolean foreground) {
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.NFC_PAYMENT_FOREGROUND, foreground ? 1 : 0) ;
|
||||
Settings.Secure.NFC_PAYMENT_FOREGROUND, foreground ? 1 : 0);
|
||||
}
|
||||
|
||||
ComponentName getDefaultPaymentApp() {
|
||||
@@ -182,14 +185,23 @@ public class PaymentBackend {
|
||||
refresh();
|
||||
}
|
||||
|
||||
private final Handler mHandler = new Handler() {
|
||||
@Override
|
||||
public void dispatchMessage(Message msg) {
|
||||
refresh();
|
||||
}
|
||||
};
|
||||
|
||||
private class SettingsPackageMonitor extends PackageMonitor {
|
||||
private Handler mHandler;
|
||||
|
||||
@Override
|
||||
public void register(Context context, Looper thread, UserHandle user,
|
||||
boolean externalStorage) {
|
||||
if (mHandler == null) {
|
||||
mHandler = new Handler(thread) {
|
||||
@Override
|
||||
public void dispatchMessage(Message msg) {
|
||||
refresh();
|
||||
}
|
||||
};
|
||||
}
|
||||
super.register(context, thread, user, externalStorage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPackageAdded(String packageName, int uid) {
|
||||
mHandler.obtainMessage().sendToTarget();
|
||||
@@ -210,4 +222,4 @@ public class PaymentBackend {
|
||||
mHandler.obtainMessage().sendToTarget();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user