mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-20 22:26:54 +01:00
make GCM_SENDER_ID empty for xw4d variant build
This seems to fix that app, when built by me where GCM_SENDER_ID's set in the environment, being a battery hog. Apparently google's code doesn't handle being passed the wrong senderID very well.
This commit is contained in:
parent
9bdf43a89e
commit
096aa3bd0f
2 changed files with 23 additions and 15 deletions
|
@ -2,6 +2,7 @@ def INITIAL_CLIENT_VERS = 8
|
|||
def VERSION_CODE_BASE = 125
|
||||
def VERSION_NAME = '4.4.129'
|
||||
def FABRIC_API_KEY = System.getenv("FABRIC_API_KEY")
|
||||
def GCM_SENDER_ID = System.getenv("GCM_SENDER_ID")
|
||||
|
||||
boolean forFDroid = hasProperty('forFDroid')
|
||||
|
||||
|
@ -37,8 +38,6 @@ android {
|
|||
applicationVariants.all { variant ->
|
||||
// renameArtifact(variant)
|
||||
// variant.buildConfigField "String", "FIELD_NAME", "\"my String\""
|
||||
def GCM_SENDER_ID = System.getenv("GCM_SENDER_ID")
|
||||
variant.buildConfigField "String", "GCM_SENDER_ID", "\"$GCM_SENDER_ID\""
|
||||
variant.buildConfigField "String", "FABRIC_API_KEY", "\"$FABRIC_API_KEY\""
|
||||
|
||||
resValue "string", "git_rev", "$GITREV"
|
||||
|
@ -67,6 +66,8 @@ android {
|
|||
resValue "string", "invite_prefix", "/and/"
|
||||
buildConfigField "boolean", "WIDIR_ENABLED", "false"
|
||||
buildConfigField "boolean", "RELAYINVITE_SUPPORTED", "false"
|
||||
|
||||
buildConfigField "String", "GCM_SENDER_ID", "\"$GCM_SENDER_ID\""
|
||||
}
|
||||
xw4d {
|
||||
dimension "variant"
|
||||
|
@ -78,6 +79,8 @@ android {
|
|||
resValue "string", "invite_prefix", "/anddbg/"
|
||||
buildConfigField "boolean", "WIDIR_ENABLED", "true"
|
||||
buildConfigField "boolean", "RELAYINVITE_SUPPORTED", "true"
|
||||
|
||||
buildConfigField "String", "GCM_SENDER_ID", "\"\""
|
||||
}
|
||||
|
||||
// WARNING: "all" breaks things. Seems to be a keyword. Need
|
||||
|
|
|
@ -29,12 +29,15 @@ import com.google.android.gcm.GCMRegistrar;
|
|||
|
||||
import org.json.JSONArray;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
public class GCMIntentService extends GCMBaseIntentService {
|
||||
private static final String TAG = GCMIntentService.class.getSimpleName();
|
||||
|
||||
public GCMIntentService()
|
||||
{
|
||||
super( BuildConfig.GCM_SENDER_ID );
|
||||
Assert.assertTrue( BuildConfig.GCM_SENDER_ID.length() > 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -120,20 +123,22 @@ public class GCMIntentService extends GCMBaseIntentService {
|
|||
|
||||
public static void init( Application app )
|
||||
{
|
||||
int sdkVersion = Integer.valueOf( android.os.Build.VERSION.SDK );
|
||||
if ( 8 <= sdkVersion && 0 < BuildConfig.GCM_SENDER_ID.length() ) {
|
||||
try {
|
||||
GCMRegistrar.checkDevice( app );
|
||||
// GCMRegistrar.checkManifest( app );
|
||||
String regId = DevID.getGCMDevID( app );
|
||||
if ( regId.equals("") ) {
|
||||
GCMRegistrar.register( app, BuildConfig.GCM_SENDER_ID );
|
||||
if ( 0 < BuildConfig.GCM_SENDER_ID.length() ) {
|
||||
int sdkVersion = Integer.valueOf( android.os.Build.VERSION.SDK );
|
||||
if ( 8 <= sdkVersion ) {
|
||||
try {
|
||||
GCMRegistrar.checkDevice( app );
|
||||
// GCMRegistrar.checkManifest( app );
|
||||
String regId = DevID.getGCMDevID( app );
|
||||
if ( regId.equals("") ) {
|
||||
GCMRegistrar.register( app, BuildConfig.GCM_SENDER_ID );
|
||||
}
|
||||
} catch ( UnsupportedOperationException uoe ) {
|
||||
Log.w( TAG, "Device can't do GCM." );
|
||||
} catch ( Exception whatever ) {
|
||||
// funky devices could do anything
|
||||
Log.ex( TAG, whatever );
|
||||
}
|
||||
} catch ( UnsupportedOperationException uoe ) {
|
||||
Log.w( TAG, "Device can't do GCM." );
|
||||
} catch ( Exception whatever ) {
|
||||
// funky devices could do anything
|
||||
Log.ex( TAG, whatever );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue