diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/Channels.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/Channels.java index 9252537e4..e0e2222ce 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/Channels.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/Channels.java @@ -39,7 +39,6 @@ public class Channels { // HIGH seems to be required for sound ,GAME_EVENT( R.string.gameevent_channel_expl, NotificationManager.IMPORTANCE_HIGH ) - ,SERVICE_STALL( R.string.servicestall_channel_expl ) ,DUP_TIMER_RUNNING( R.string.dup_timer_expl ) ,DUP_PAUSED( R.string.dup_paused_expl ) ; diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/Utils.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/Utils.java index 708c0a2c1..f9095e2ac 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/Utils.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/Utils.java @@ -354,39 +354,6 @@ public class Utils { return pi; } - private static final String KEY_LAST_STALL_NOT = TAG + ".last_stall_note"; - private static final long MIN_STALL_NOTE_INTERVAL_MS = 1000 * 60 * 30; - public static void showStallNotification( Context context, String typ, - long ageMS ) - { - String body = LocUtils.getString( context, R.string.notify_stall_body_fmt, - typ, (ageMS + 500) / 1000, - MIN_STALL_NOTE_INTERVAL_MS / (1000 * 60)); - - long now = System.currentTimeMillis(); - long lastStallNotify = DBUtils.getLongFor( context, KEY_LAST_STALL_NOT, 0 ); - if ( now - lastStallNotify > MIN_STALL_NOTE_INTERVAL_MS ) { - String title = LocUtils.getString( context, R.string.notify_stall_title ); - Intent intent = GamesListDelegate - .makeAlertWithEmailIntent( context, body ); - postNotification( context, intent, title, body, - R.string.notify_stall_title, - Channels.ID.SERVICE_STALL, false, null, 0 ); - DBUtils.setLongFor( context, KEY_LAST_STALL_NOT, now ); - } else { - Log.e( TAG, "stalled, but too recent for notification: %s", - body ); - } - } - - // If the OS starts delivering Intents before the user notices the - // notification, remove it. PENDING: should I replace it with something - // that tells how long the stall was? - public static void clearStallNotification( Context context, long age ) - { - cancelNotification( context, R.string.notify_stall_title ); - } - public static void cancelNotification( Context context, Channels.ID channel, long rowid ) { diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWJIService.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWJIService.java index 3b5e2e996..c42730f77 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWJIService.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWJIService.java @@ -22,14 +22,9 @@ package org.eehouse.android.xw4; import android.content.Context; import android.content.Intent; -import android.os.Bundle; import androidx.core.app.JobIntentService; -import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; -import java.util.Iterator; -import java.util.List; import java.util.Map; import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnType; @@ -62,7 +57,6 @@ abstract class XWJIService extends JobIntentService { { long timestamp = getTimestamp(intent); long ageMS = System.currentTimeMillis() - timestamp; - forget( this, getClass(), intent, ageMS ); XWJICmds cmd = cmdFrom( intent ); if ( LOG_PACKETS ) { @@ -76,9 +70,7 @@ abstract class XWJIService extends JobIntentService { protected static void enqueueWork( Context context, Class clazz, Intent intent ) { - remember( context, clazz, intent ); enqueueWork( context, clazz, sJobIDs.get(clazz), intent ); - checkForStall( context, clazz ); } static XWJICmds cmdFrom( Intent intent, XWJICmds[] values ) @@ -105,154 +97,4 @@ abstract class XWJIService extends JobIntentService { .putExtra( TIMESTAMP, System.currentTimeMillis() ); return intent; } - - private static Map> sPendingIntents = new HashMap<>(); - - private static void remember( Context context, Class clazz, Intent intent ) - { - if ( stallCheckEnabled( context ) ) { - String name = clazz.getSimpleName(); - synchronized ( sPendingIntents ) { - if ( !sPendingIntents.containsKey( name )) { - sPendingIntents.put( name, new ArrayList() ); - } - sPendingIntents.get(name).add( intent ); - if ( LOG_INTENT_COUNTS ) { - Log.d( TAG, "remember(): now have %d intents for class %s", - sPendingIntents.get(name).size(), name ); - } - } - } - } - - private static final long AGE_THRESHOLD_MS = 1000 * 60; // one minute to start - private static void checkForStall( Context context, Class clazz ) - { - if ( stallCheckEnabled( context ) ) { - long now = System.currentTimeMillis(); - long maxAge = 0; - String maxName = null; - synchronized ( sPendingIntents ) { - for ( String simpleName : sPendingIntents.keySet() ) { - List intents = sPendingIntents.get( simpleName ); - if ( 1 <= intents.size() ) { - Intent intent = intents.get(0); - long timestamp = intent.getLongExtra( TIMESTAMP, -1 ); - long age = now - timestamp; - if ( age > maxAge ) { - maxAge = age; - maxName = simpleName; - } - } - } - } - - if ( maxAge > AGE_THRESHOLD_MS ) { - // ConnStatusHandler.noteStall( sTypes.get( clazz ), maxAge ); - Utils.showStallNotification( context, maxName, maxAge ); - } - } - } - - // Called when an intent is successfully delivered - private static void forget( Context context, Class clazz, - Intent intent, long ageMS ) - { - if ( stallCheckEnabled( context ) ) { - String name = clazz.getSimpleName(); - synchronized ( sPendingIntents ) { - String found = null; - if ( sPendingIntents.containsKey( name ) ) { - List intents = sPendingIntents.get( name ); - for (Iterator iter = intents.iterator(); - iter.hasNext(); ) { - Intent candidate = iter.next(); - if ( areSame( candidate, intent ) ) { - found = name; - iter.remove(); - break; - } else { - Log.d( TAG, "skipping intent: %s", - DbgUtils.extrasToString( candidate ) ); - } - } - - if ( found != null ) { - if ( LOG_INTENT_COUNTS ) { - Log.d( TAG, "forget(): now have %d intents for class %s", - sPendingIntents.get(found).size(), found ); - } - } - } - } - - ConnStatusHandler.noteIntentHandled( context, sTypes.get( clazz ), ageMS ); - Utils.clearStallNotification( context, ageMS ); - } - } - - private static boolean stallCheckEnabled( Context context ) - { - return XWPrefs.getPrefsBoolean( context, R.string.key_enable_stallnotify, - BuildConfig.DEBUG ); - } - - private static boolean areSame( Intent intent1, Intent intent2 ) - { - boolean equal = intent1.filterEquals( intent2 ); - if ( equal ) { - Bundle bundle1 = intent1.getExtras(); - equal = null != bundle1; - if ( equal ) { - Bundle bundle2 = intent2.getExtras(); - equal = null != bundle2 && bundle1.size() == bundle2.size(); - if ( equal ) { - for ( final String key : bundle1.keySet()) { - if ( ! bundle2.containsKey( key ) ) { - equal = false; - break; - } - - Object obj1 = bundle1.get( key ); - Object obj2 = bundle2.get( key ); - if ( obj1 == obj2 ) { // catches case where both null - continue; - } else if ( obj1 == null || obj2 == null ) { - equal = false; - break; - } - - if ( obj1.getClass() != obj2.getClass() ) { - equal = false; - break; - } - - if ( obj1 instanceof byte[] ) { - equal = Arrays.equals( (byte[])obj1, (byte[])obj2 ); - } else if ( obj1 instanceof String[] ) { - equal = Arrays.equals( (String[])obj1, (String[])obj2 ); - } else { - if ( BuildConfig.DEBUG ) { - if ( obj1 instanceof Long - || obj1 instanceof String - || obj1 instanceof Boolean - || obj1 instanceof Integer ) { - // expected class; log nothing - } else { - Log.d( TAG, "areSame: using default for class %s", - obj1.getClass().getSimpleName() ); - } - } - equal = obj1.equals( obj2 ); - } - if ( ! equal ) { - break; - } - } - } - } - } - - return equal; - } } diff --git a/xwords4/android/app/src/main/res/values/common_rsrc.xml b/xwords4/android/app/src/main/res/values/common_rsrc.xml index 76479c36c..7afc9f29d 100644 --- a/xwords4/android/app/src/main/res/values/common_rsrc.xml +++ b/xwords4/android/app/src/main/res/values/common_rsrc.xml @@ -72,7 +72,6 @@ key_notify_vibrate key_enable_nbs key_enable_p2p - key_enable_stallnotify key_prefs_defaults key_network_behavior key_keep_screenon diff --git a/xwords4/android/app/src/main/res/values/strings.xml b/xwords4/android/app/src/main/res/values/strings.xml index d24d0beb5..0bd849d82 100644 --- a/xwords4/android/app/src/main/res/values/strings.xml +++ b/xwords4/android/app/src/main/res/values/strings.xml @@ -2473,24 +2473,13 @@ Alerts about NBSProxy In-game events - - Stalled messaging alerts If a scan doesn’t find the device you expect:\n • First, just Rescan\n • Make sure Bluetooth is enabled on the other device\n • Launch CrossWords on the other device\n • If all else fails, reboot this device\n - - Show stalled network notification - Notify when Android’s - slow to process outgoing invitations and moves - Message sending is stalled - %1$s (and others?) could not send outbound messages - for %2$d seconds. -\n -\nIf it happens again, e-mail the developer logs and info about your device. -\n -\nThis message will be seen at most once every %3$d minutes. + + The Google Play version of CrossWords no longer supports invitations or play via data SMS. Read more This game is set up to communicate via data SMS, but apps from the Google Play Store are no longer allowed to do so (with rare exceptions). You can still open the game, but it may not be able to send or receive moves. diff --git a/xwords4/android/app/src/main/res/xml/xwprefs.xml b/xwords4/android/app/src/main/res/xml/xwprefs.xml index c02c8299c..4b26fc6dc 100644 --- a/xwords4/android/app/src/main/res/xml/xwprefs.xml +++ b/xwords4/android/app/src/main/res/xml/xwprefs.xml @@ -341,11 +341,6 @@ android:summary="@string/summary_enable_p2p" android:defaultValue="false" /> -