v0.3.0: bubble for Android 0.3.0 — texts over the Rabbit's own SIM card
A third source next to voip.ms and Google Voice, while bubble is Android's default SMS app (Settings → SIM card asks for the role). SMS and MMS in and out, group chats as MMS, the phone's existing texts imported, and Android's message store kept as the record so another app still agrees. - Sim: role check, sending (SmsManager, waits for the radio), receiving, chunked import from content://sms and content://mms - Pdu: MMS wire format (notification-ind, retrieve-conf, send-req, ack) - SmsReceiver, MmsReceiver, MmsDownloaded, MmsFiles, RespondService, SendToActivity: what Android requires of a default SMS app - The import no longer shares a lock with Config.get, which froze the screens on the first copy of a long history
This commit is contained in:
@@ -17,6 +17,7 @@ import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
/**
|
||||
* Accounts, copied over by the desktop's "Install to Rabbit" into the app's
|
||||
@@ -31,19 +32,26 @@ import java.util.Map;
|
||||
final class Config {
|
||||
static final class Did {
|
||||
final String did, description;
|
||||
final boolean gv;
|
||||
final boolean gv, sim;
|
||||
|
||||
Did(String did, String description, boolean gv) {
|
||||
this(did, description, gv, false);
|
||||
}
|
||||
|
||||
Did(String did, String description, boolean gv, boolean sim) {
|
||||
this.did = did;
|
||||
this.description = description;
|
||||
this.gv = gv;
|
||||
this.sim = sim;
|
||||
}
|
||||
}
|
||||
|
||||
String voipUser, voipPass;
|
||||
String gvNumber;
|
||||
final Map<String, String> gvCookies = new LinkedHashMap<>();
|
||||
final List<Did> dids = new ArrayList<>();
|
||||
// Changes while screens read it: the SIM comes and goes with the default-SMS-app role.
|
||||
final List<Did> dids = new CopyOnWriteArrayList<>();
|
||||
private boolean hasSim;
|
||||
String defaultDid;
|
||||
/** Made-up data for testing (android/tools/push_sandbox.py): never goes online. */
|
||||
boolean sandbox;
|
||||
@@ -59,9 +67,24 @@ final class Config {
|
||||
static synchronized Config get(Context c) {
|
||||
File f = new File(c.getFilesDir(), "config.json");
|
||||
if (cached == null || cached.stale()) cached = load(f);
|
||||
cached.applySim(c);
|
||||
return cached;
|
||||
}
|
||||
|
||||
/** The SIM is a number to text from while bubble is the default SMS app (never in the sandbox). */
|
||||
private void applySim(Context c) {
|
||||
boolean sim = !sandbox && Sim.isDefault(c);
|
||||
if (sim == hasSim) return;
|
||||
hasSim = sim;
|
||||
if (sim) {
|
||||
dids.add(new Did(Sim.DID, "SIM card", false, true));
|
||||
if (defaultDid == null) defaultDid = Sim.DID;
|
||||
} else {
|
||||
dids.removeIf(d -> d.sim);
|
||||
if (Sim.DID.equals(defaultDid)) defaultDid = dids.isEmpty() ? null : dids.get(0).did;
|
||||
}
|
||||
}
|
||||
|
||||
private long loadedAt;
|
||||
|
||||
private boolean stale() {
|
||||
@@ -106,7 +129,12 @@ final class Config {
|
||||
}
|
||||
|
||||
boolean configured() {
|
||||
return voipUser != null || gvNumber != null;
|
||||
return voipUser != null || gvNumber != null || hasSim;
|
||||
}
|
||||
|
||||
/** Group chats: Google Voice and the SIM (as MMS); voip.ms numbers can't. */
|
||||
boolean canGroup(String did) {
|
||||
return isGv(did) || Sim.isSim(did) && hasSim;
|
||||
}
|
||||
|
||||
boolean isGv(String did) {
|
||||
|
||||
Reference in New Issue
Block a user