mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 727958 - Sync set-up screen results in StrictMode policy violation. r=rnewman
This commit is contained in:
parent
2b50ea839d
commit
0b9c148a1c
@ -9,6 +9,7 @@ import java.util.HashMap;
|
|||||||
import org.json.simple.JSONObject;
|
import org.json.simple.JSONObject;
|
||||||
import org.mozilla.gecko.R;
|
import org.mozilla.gecko.R;
|
||||||
import org.mozilla.gecko.sync.Logger;
|
import org.mozilla.gecko.sync.Logger;
|
||||||
|
import org.mozilla.gecko.sync.ThreadPool;
|
||||||
import org.mozilla.gecko.sync.jpake.JPakeClient;
|
import org.mozilla.gecko.sync.jpake.JPakeClient;
|
||||||
import org.mozilla.gecko.sync.jpake.JPakeNoActivePairingException;
|
import org.mozilla.gecko.sync.jpake.JPakeNoActivePairingException;
|
||||||
import org.mozilla.gecko.sync.setup.Constants;
|
import org.mozilla.gecko.sync.setup.Constants;
|
||||||
@ -84,10 +85,20 @@ public class SetupSyncActivity extends AccountAuthenticatorActivity {
|
|||||||
setContentView(R.layout.sync_setup_nointernet);
|
setContentView(R.layout.sync_setup_nointernet);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check whether Sync accounts exist; if not, display J-PAKE PIN.
|
|
||||||
Account[] accts = mAccountManager.getAccountsByType(Constants.ACCOUNTTYPE_SYNC);
|
|
||||||
|
|
||||||
|
// Check whether Sync accounts exist; if not, display J-PAKE PIN.
|
||||||
|
// Run this on a separate thread to comply with Strict Mode thread policies.
|
||||||
|
ThreadPool.run(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
Account[] accts = mAccountManager.getAccountsByType(Constants.ACCOUNTTYPE_SYNC);
|
||||||
|
finishResume(accts);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void finishResume(Account[] accts) {
|
||||||
|
Logger.debug(LOG_TAG, "Finishing Resume after fetching accounts.");
|
||||||
if (accts.length == 0) { // Start J-PAKE for pairing if no accounts present.
|
if (accts.length == 0) { // Start J-PAKE for pairing if no accounts present.
|
||||||
Logger.debug(LOG_TAG, "No accounts; starting J-PAKE receiver.");
|
Logger.debug(LOG_TAG, "No accounts; starting J-PAKE receiver.");
|
||||||
displayReceiveNoPin();
|
displayReceiveNoPin();
|
||||||
@ -112,19 +123,27 @@ public class SetupSyncActivity extends AccountAuthenticatorActivity {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
Logger.debug(LOG_TAG, "Only one account supported. Redirecting.");
|
||||||
|
// Display toast for "Only one account supported."
|
||||||
|
// Redirect to account management.
|
||||||
|
Toast toast = Toast.makeText(mContext,
|
||||||
|
R.string.sync_notification_oneaccount, Toast.LENGTH_LONG);
|
||||||
|
toast.show();
|
||||||
|
|
||||||
Logger.debug(LOG_TAG, "Only one account supported. Redirecting.");
|
Intent intent = new Intent(Settings.ACTION_SYNC_SETTINGS);
|
||||||
// Display toast for "Only one account supported." and redirect to account management.
|
intent.setFlags(Constants.FLAG_ACTIVITY_REORDER_TO_FRONT_NO_ANIMATION);
|
||||||
Toast toast = Toast.makeText(mContext, R.string.sync_notification_oneaccount, Toast.LENGTH_LONG);
|
startActivity(intent);
|
||||||
toast.show();
|
|
||||||
|
|
||||||
Intent intent = new Intent(Settings.ACTION_SYNC_SETTINGS);
|
finish();
|
||||||
intent.setFlags(Constants.FLAG_ACTIVITY_REORDER_TO_FRONT_NO_ANIMATION);
|
}
|
||||||
startActivity(intent);
|
});
|
||||||
|
|
||||||
finish();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
@ -418,92 +437,113 @@ public class SetupSyncActivity extends AccountAuthenticatorActivity {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays layout for entering a PIN from another device.
|
||||||
|
* A Sync Account has already been set up.
|
||||||
|
*/
|
||||||
private void displayPairWithPin() {
|
private void displayPairWithPin() {
|
||||||
Logger.debug(LOG_TAG, "PairWithPin initiated.");
|
Logger.debug(LOG_TAG, "PairWithPin initiated.");
|
||||||
setContentView(R.layout.sync_setup_pair);
|
runOnUiThread(new Runnable() {
|
||||||
connectButton = (Button) findViewById(R.id.pair_button_connect);
|
|
||||||
pinError = (LinearLayout) findViewById(R.id.pair_error);
|
|
||||||
|
|
||||||
row1 = (EditText) findViewById(R.id.pair_row1);
|
|
||||||
row2 = (EditText) findViewById(R.id.pair_row2);
|
|
||||||
row3 = (EditText) findViewById(R.id.pair_row3);
|
|
||||||
|
|
||||||
row1.addTextChangedListener(new TextWatcher() {
|
|
||||||
@Override
|
|
||||||
public void afterTextChanged(Editable s) {
|
|
||||||
activateButton(connectButton, pinEntryCompleted());
|
|
||||||
if (s.length() == 4) {
|
|
||||||
row2.requestFocus();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void beforeTextChanged(CharSequence s, int start, int count,
|
public void run() {
|
||||||
int after) {
|
setContentView(R.layout.sync_setup_pair);
|
||||||
}
|
connectButton = (Button) findViewById(R.id.pair_button_connect);
|
||||||
|
pinError = (LinearLayout) findViewById(R.id.pair_error);
|
||||||
|
|
||||||
@Override
|
row1 = (EditText) findViewById(R.id.pair_row1);
|
||||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
row2 = (EditText) findViewById(R.id.pair_row2);
|
||||||
}
|
row3 = (EditText) findViewById(R.id.pair_row3);
|
||||||
});
|
|
||||||
|
|
||||||
row2.addTextChangedListener(new TextWatcher() {
|
row1.addTextChangedListener(new TextWatcher() {
|
||||||
@Override
|
@Override
|
||||||
public void afterTextChanged(Editable s) {
|
public void afterTextChanged(Editable s) {
|
||||||
activateButton(connectButton, pinEntryCompleted());
|
activateButton(connectButton, pinEntryCompleted());
|
||||||
if (s.length() == 4) {
|
if (s.length() == 4) {
|
||||||
row3.requestFocus();
|
row2.requestFocus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void beforeTextChanged(CharSequence s, int start, int count,
|
public void beforeTextChanged(CharSequence s, int start, int count,
|
||||||
int after) {
|
int after) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
row3.addTextChangedListener(new TextWatcher() {
|
});
|
||||||
@Override
|
row2.addTextChangedListener(new TextWatcher() {
|
||||||
public void afterTextChanged(Editable s) {
|
@Override
|
||||||
activateButton(connectButton, pinEntryCompleted());
|
public void afterTextChanged(Editable s) {
|
||||||
}
|
activateButton(connectButton, pinEntryCompleted());
|
||||||
|
if (s.length() == 4) {
|
||||||
|
row3.requestFocus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void beforeTextChanged(CharSequence s, int start, int count,
|
public void beforeTextChanged(CharSequence s, int start, int count,
|
||||||
int after) {
|
int after) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
row3.addTextChangedListener(new TextWatcher() {
|
||||||
|
@Override
|
||||||
|
public void afterTextChanged(Editable s) {
|
||||||
|
activateButton(connectButton, pinEntryCompleted());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void beforeTextChanged(CharSequence s, int start, int count,
|
||||||
|
int after) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays layout with PIN for pairing with another device.
|
||||||
|
* No Sync Account has been set up yet.
|
||||||
|
*/
|
||||||
private void displayReceiveNoPin() {
|
private void displayReceiveNoPin() {
|
||||||
Logger.debug(LOG_TAG, "ReceiveNoPin initiated");
|
Logger.debug(LOG_TAG, "ReceiveNoPin initiated");
|
||||||
setContentView(R.layout.sync_setup);
|
runOnUiThread(new Runnable(){
|
||||||
|
|
||||||
// Set up UI.
|
@Override
|
||||||
setupTitleView = ((TextView) findViewById(R.id.setup_title));
|
public void run() {
|
||||||
setupSubtitleView = (TextView) findViewById(R.id.setup_subtitle);
|
setContentView(R.layout.sync_setup);
|
||||||
setupNoDeviceLinkTitleView = (TextView) findViewById(R.id.link_nodevice);
|
|
||||||
pinTextView1 = ((TextView) findViewById(R.id.text_pin1));
|
|
||||||
pinTextView2 = ((TextView) findViewById(R.id.text_pin2));
|
|
||||||
pinTextView3 = ((TextView) findViewById(R.id.text_pin3));
|
|
||||||
|
|
||||||
// UI checks.
|
// Set up UI.
|
||||||
if (setupTitleView == null) {
|
setupTitleView = ((TextView) findViewById(R.id.setup_title));
|
||||||
Logger.error(LOG_TAG, "No title view.");
|
setupSubtitleView = (TextView) findViewById(R.id.setup_subtitle);
|
||||||
}
|
setupNoDeviceLinkTitleView = (TextView) findViewById(R.id.link_nodevice);
|
||||||
if (setupSubtitleView == null) {
|
pinTextView1 = ((TextView) findViewById(R.id.text_pin1));
|
||||||
Logger.error(LOG_TAG, "No subtitle view.");
|
pinTextView2 = ((TextView) findViewById(R.id.text_pin2));
|
||||||
}
|
pinTextView3 = ((TextView) findViewById(R.id.text_pin3));
|
||||||
if (setupNoDeviceLinkTitleView == null) {
|
|
||||||
Logger.error(LOG_TAG, "No 'no device' link view.");
|
// UI checks.
|
||||||
}
|
if (setupTitleView == null) {
|
||||||
|
Logger.error(LOG_TAG, "No title view.");
|
||||||
|
}
|
||||||
|
if (setupSubtitleView == null) {
|
||||||
|
Logger.error(LOG_TAG, "No subtitle view.");
|
||||||
|
}
|
||||||
|
if (setupNoDeviceLinkTitleView == null) {
|
||||||
|
Logger.error(LOG_TAG, "No 'no device' link view.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user