mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-30 08:34:16 +01:00
remove notion of banned permissions
This commit is contained in:
parent
e5d91be4c4
commit
af8c7b9900
8 changed files with 101 additions and 173 deletions
|
@ -1197,17 +1197,11 @@ public class BoardDelegate extends DelegateBase
|
||||||
showInviteChoicesThen();
|
showInviteChoicesThen();
|
||||||
break;
|
break;
|
||||||
case INVITE_SMS_DATA:
|
case INVITE_SMS_DATA:
|
||||||
Perms23.Perm[] perms = (Perms23.Perm[])params[2];
|
if ( Perms23.haveNBSPerms( m_activity ) ) {
|
||||||
if ( Perms23.bannedWithWorkaround( m_activity, perms ) ) {
|
|
||||||
int nMissing = (Integer)params[0];
|
int nMissing = (Integer)params[0];
|
||||||
SentInvitesInfo info = (SentInvitesInfo)params[1];
|
SentInvitesInfo info = (SentInvitesInfo)params[1];
|
||||||
launchPhoneNumberInvite( nMissing, info,
|
launchPhoneNumberInvite( nMissing, info,
|
||||||
RequestCode.SMS_DATA_INVITE_RESULT );
|
RequestCode.SMS_DATA_INVITE_RESULT );
|
||||||
} else if ( Perms23.anyBanned( m_activity, perms ) ) {
|
|
||||||
makeOkOnlyBuilder( R.string.sms_banned_ok_only )
|
|
||||||
.setActionPair(Action.PERMS_BANNED_INFO,
|
|
||||||
R.string.button_more_info )
|
|
||||||
.show();
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -1282,10 +1276,8 @@ public class BoardDelegate extends DelegateBase
|
||||||
RequestCode.BT_INVITE_RESULT );
|
RequestCode.BT_INVITE_RESULT );
|
||||||
break;
|
break;
|
||||||
case SMS_DATA:
|
case SMS_DATA:
|
||||||
Perm[] perms = { Perm.SEND_SMS, Perm.RECEIVE_SMS };
|
Perms23.tryGetPerms( this, Perms23.NBS_PERMS, R.string.sms_invite_rationale,
|
||||||
Perms23.tryGetPerms( this, perms, R.string.sms_invite_rationale,
|
Action.INVITE_SMS_DATA, m_mySIS.nMissing, info );
|
||||||
Action.INVITE_SMS_DATA, m_mySIS.nMissing,
|
|
||||||
info, perms );
|
|
||||||
break;
|
break;
|
||||||
case RELAY:
|
case RELAY:
|
||||||
case MQTT:
|
case MQTT:
|
||||||
|
@ -2390,42 +2382,28 @@ public class BoardDelegate extends DelegateBase
|
||||||
final StartAlertOrder thisOrder = StartAlertOrder.NBS_PERMS;
|
final StartAlertOrder thisOrder = StartAlertOrder.NBS_PERMS;
|
||||||
if ( alertOrderAt( thisOrder ) // already asked?
|
if ( alertOrderAt( thisOrder ) // already asked?
|
||||||
&& m_summary.conTypes.contains( CommsConnType.COMMS_CONN_SMS ) ) {
|
&& m_summary.conTypes.contains( CommsConnType.COMMS_CONN_SMS ) ) {
|
||||||
Perm[] nbsPerms = { Perm.SEND_SMS, Perm.RECEIVE_SMS };
|
if ( Perms23.haveNBSPerms( m_activity ) ) {
|
||||||
if ( Perms23.havePermissions( m_activity, nbsPerms ) ) {
|
|
||||||
// We have them or a workaround; cool! proceed
|
// We have them or a workaround; cool! proceed
|
||||||
alertOrderIncrIfAt( thisOrder );
|
alertOrderIncrIfAt( thisOrder );
|
||||||
} else {
|
} else {
|
||||||
// Make sure these can be treated the same!!!
|
|
||||||
Assert.assertTrue( nbsPerms.length == 2 &&
|
|
||||||
nbsPerms[0].isBanned(m_activity)
|
|
||||||
== nbsPerms[1].isBanned(m_activity) );
|
|
||||||
|
|
||||||
m_permCbck = new Perms23.PermCbck() {
|
m_permCbck = new Perms23.PermCbck() {
|
||||||
@Override
|
@Override
|
||||||
public void onPermissionResult( boolean allGood,
|
public void onPermissionResult( boolean allGood )
|
||||||
Map<Perm, Boolean> perms )
|
|
||||||
{
|
{
|
||||||
if ( allGood ) {
|
if ( allGood ) {
|
||||||
// Yay! nothing to do
|
// Yay! nothing to do
|
||||||
alertOrderIncrIfAt( thisOrder );
|
alertOrderIncrIfAt( thisOrder );
|
||||||
} else {
|
} else {
|
||||||
boolean banned = Perm.SEND_SMS.isBanned(m_activity);
|
int explID = Perms23.NBSPermsInManifest( m_activity )
|
||||||
int explID = banned
|
? R.string.missing_sms_perms
|
||||||
? R.string.banned_nbs_perms : R.string.missing_sms_perms;
|
: R.string.variant_missing_nbs;
|
||||||
DlgDelegate.Builder builder =
|
makeConfirmThenBuilder( Action.DROP_SMS_ACTION, explID )
|
||||||
makeConfirmThenBuilder( Action.DROP_SMS_ACTION, explID );
|
.setNegButton( R.string.remove_sms )
|
||||||
if ( banned ) {
|
|
||||||
builder.setActionPair( Action.PERMS_BANNED_INFO,
|
|
||||||
R.string.button_more_info )
|
|
||||||
.setNAKey( R.string.key_na_sms_banned )
|
|
||||||
;
|
|
||||||
}
|
|
||||||
builder.setNegButton( R.string.remove_sms )
|
|
||||||
.show();
|
.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
new Perms23.Builder( nbsPerms )
|
new Perms23.Builder( Perms23.NBS_PERMS )
|
||||||
.asyncQuery( m_activity, m_permCbck );
|
.asyncQuery( m_activity, m_permCbck );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -176,14 +176,9 @@ public class ConnViaViewLayout extends LinearLayout {
|
||||||
keyID = R.string.key_na_comms_relay;
|
keyID = R.string.key_na_comms_relay;
|
||||||
break;
|
break;
|
||||||
case COMMS_CONN_SMS:
|
case COMMS_CONN_SMS:
|
||||||
if ( Perms23.havePermissions( getContext(),
|
if ( Perms23.haveNBSPerms( getContext() ) ) {
|
||||||
Perms23.Perm.SEND_SMS,
|
|
||||||
Perms23.Perm.RECEIVE_SMS )
|
|
||||||
|| !Perms23.Perm.SEND_SMS.isBanned(getContext()) ) {
|
|
||||||
msgID = R.string.not_again_comms_sms;
|
msgID = R.string.not_again_comms_sms;
|
||||||
keyID = R.string.key_na_comms_sms;
|
keyID = R.string.key_na_comms_sms;
|
||||||
} else {
|
|
||||||
msgID = R.string.sms_banned_ok_only;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case COMMS_CONN_BT:
|
case COMMS_CONN_BT:
|
||||||
|
@ -203,13 +198,13 @@ public class ConnViaViewLayout extends LinearLayout {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
DlgDelegate.Builder builder = 0 != keyID
|
if ( 0 != msgID ) {
|
||||||
? m_dlgDlgt.makeNotAgainBuilder( keyID, msgID )
|
DlgDelegate.Builder builder = 0 != keyID
|
||||||
: m_dlgDlgt.makeOkOnlyBuilder( msgID )
|
? m_dlgDlgt.makeNotAgainBuilder( keyID, msgID )
|
||||||
.setActionPair( Action.PERMS_BANNED_INFO,
|
: m_dlgDlgt.makeOkOnlyBuilder( msgID )
|
||||||
R.string.button_more_info )
|
;
|
||||||
;
|
builder.show();
|
||||||
builder.show();
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -890,7 +890,8 @@ public class GameConfigDelegate extends DelegateBase
|
||||||
|
|
||||||
private void showConnAfterCheck()
|
private void showConnAfterCheck()
|
||||||
{
|
{
|
||||||
if ( null == SMSPhoneInfo.get( m_activity ) ) {
|
if ( Perms23.NBSPermsInManifest( m_activity )
|
||||||
|
&& null == SMSPhoneInfo.get( m_activity ) ) {
|
||||||
Perms23.tryGetPermsNA( this, Perms23.Perm.READ_PHONE_STATE,
|
Perms23.tryGetPermsNA( this, Perms23.Perm.READ_PHONE_STATE,
|
||||||
R.string.phone_state_rationale,
|
R.string.phone_state_rationale,
|
||||||
R.string.key_na_perms_phonestate,
|
R.string.key_na_perms_phonestate,
|
||||||
|
|
|
@ -1042,20 +1042,6 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
|
|
||||||
updateField();
|
updateField();
|
||||||
|
|
||||||
// RECEIVE_SMS is required now (Oreo/SDK_26) but wasn't
|
|
||||||
// before. There's logic elsewhere to ask for it AND SEND_SMS, but if
|
|
||||||
// the user's already granted SEND_SMS we can get RECEIVE_SMS just by
|
|
||||||
// asking (OS will grant without user interaction) since they're in
|
|
||||||
// the same group. So just do it now. This code can be removed
|
|
||||||
// later...
|
|
||||||
if ( !Perm.RECEIVE_SMS.isBanned(m_activity) ) {
|
|
||||||
if ( Perms23.havePermissions( m_activity, Perm.SEND_SMS ) ) {
|
|
||||||
Perms23.tryGetPerms( this, Perm.RECEIVE_SMS, 0, Action.SKIP_CALLBACK );
|
|
||||||
}
|
|
||||||
} else if ( isFirstLaunch ) {
|
|
||||||
warnSMSBannedIf();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( false ) {
|
if ( false ) {
|
||||||
Set<Long> dupModeGames = DBUtils.getDupModeGames( m_activity ).keySet();
|
Set<Long> dupModeGames = DBUtils.getDupModeGames( m_activity ).keySet();
|
||||||
long[] asArray = new long[dupModeGames.size()];
|
long[] asArray = new long[dupModeGames.size()];
|
||||||
|
@ -1144,22 +1130,6 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void warnSMSBannedIf()
|
|
||||||
{
|
|
||||||
if ( !Perms23.havePermissions( m_activity, Perm.SEND_SMS, Perm.RECEIVE_SMS )
|
|
||||||
&& Perm.SEND_SMS.isBanned(m_activity) ) {
|
|
||||||
int smsGameCount = DBUtils.countOpenGamesUsingNBS( m_activity );
|
|
||||||
if ( 0 < smsGameCount ) {
|
|
||||||
makeNotAgainBuilder( R.string.key_notagain_nbsGamesOnUpgrade,
|
|
||||||
R.string.not_again_nbsGamesOnUpgrade,
|
|
||||||
smsGameCount )
|
|
||||||
.setActionPair( Action.PERMS_BANNED_INFO,
|
|
||||||
R.string.button_more_info )
|
|
||||||
.show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void moveGroup( long groupID, boolean moveUp )
|
private void moveGroup( long groupID, boolean moveUp )
|
||||||
{
|
{
|
||||||
m_adapter.moveGroup( groupID, moveUp );
|
m_adapter.moveGroup( groupID, moveUp );
|
||||||
|
|
|
@ -227,14 +227,8 @@ public class InviteChoicesAlert extends DlgDelegateAlert
|
||||||
R.string.qrcode_invite_expl );
|
R.string.qrcode_invite_expl );
|
||||||
break;
|
break;
|
||||||
case SMS_DATA:
|
case SMS_DATA:
|
||||||
if ( !Perms23.havePermissions( activity, Perm.SEND_SMS, Perm.RECEIVE_SMS )
|
if ( Perms23.NBSPermsInManifest( activity )
|
||||||
&& Perm.SEND_SMS.isBanned(activity) ) {
|
&& ! XWPrefs.getNBSEnabled( getContext() ) ) {
|
||||||
builder = activity
|
|
||||||
.makeOkOnlyBuilder( R.string.sms_banned_ok_only )
|
|
||||||
.setActionPair( Action.PERMS_BANNED_INFO,
|
|
||||||
R.string.button_more_info )
|
|
||||||
;
|
|
||||||
} else if ( ! XWPrefs.getNBSEnabled( getContext() ) ) {
|
|
||||||
builder = activity
|
builder = activity
|
||||||
.makeConfirmThenBuilder( Action.ENABLE_NBS_ASK,
|
.makeConfirmThenBuilder( Action.ENABLE_NBS_ASK,
|
||||||
R.string.warn_sms_disabled )
|
R.string.warn_sms_disabled )
|
||||||
|
|
|
@ -330,7 +330,7 @@ public class NBSProto {
|
||||||
Context context = XWApp.getContext();
|
Context context = XWApp.getContext();
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
if ( XWPrefs.getNBSEnabled( context )
|
if ( XWPrefs.getNBSEnabled( context )
|
||||||
&& !Perms23.Perm.SEND_SMS.isBanned( context ) ) {
|
&& Perms23.haveNBSPerms( context ) ) {
|
||||||
|
|
||||||
// Try send-to-self
|
// Try send-to-self
|
||||||
if ( XWPrefs.getSMSToSelfEnabled( context ) ) {
|
if ( XWPrefs.getSMSToSelfEnabled( context ) ) {
|
||||||
|
|
|
@ -23,6 +23,7 @@ import android.Manifest;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
|
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import androidx.core.app.ActivityCompat;
|
import androidx.core.app.ActivityCompat;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
@ -56,10 +57,6 @@ public class Perms23 {
|
||||||
private Perm(String str) { m_str = str; }
|
private Perm(String str) { m_str = str; }
|
||||||
|
|
||||||
public String getString() { return m_str; }
|
public String getString() { return m_str; }
|
||||||
public boolean isBanned( Context context )
|
|
||||||
{
|
|
||||||
return !permInManifest( context, this );
|
|
||||||
}
|
|
||||||
public static Perm getFor( String str ) {
|
public static Perm getFor( String str ) {
|
||||||
Perm result = null;
|
Perm result = null;
|
||||||
for ( Perm one : Perm.values() ) {
|
for ( Perm one : Perm.values() ) {
|
||||||
|
@ -101,8 +98,18 @@ public class Perms23 {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static boolean permsInManifest( Context context, Perm[] perms )
|
||||||
|
{
|
||||||
|
boolean result = true;
|
||||||
|
for ( int ii = 0; result && ii < perms.length; ++ii ) {
|
||||||
|
result = permInManifest( context, perms[ii] );
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public interface PermCbck {
|
public interface PermCbck {
|
||||||
void onPermissionResult( boolean allGood, Map<Perm, Boolean> perms );
|
void onPermissionResult( boolean allGood );
|
||||||
}
|
}
|
||||||
public interface OnShowRationale {
|
public interface OnShowRationale {
|
||||||
void onShouldShowRationale( Set<Perm> perms );
|
void onShouldShowRationale( Set<Perm> perms );
|
||||||
|
@ -148,13 +155,14 @@ public class Perms23 {
|
||||||
List<String> askStrings = new ArrayList<>();
|
List<String> askStrings = new ArrayList<>();
|
||||||
for ( Perm perm : m_perms ) {
|
for ( Perm perm : m_perms ) {
|
||||||
String permStr = perm.getString();
|
String permStr = perm.getString();
|
||||||
boolean haveIt = perm.isBanned(activity) || PackageManager.PERMISSION_GRANTED
|
boolean inManifest = permInManifest( activity, perm );
|
||||||
|
boolean haveIt = inManifest
|
||||||
|
&& PERMISSION_GRANTED
|
||||||
== ContextCompat.checkSelfPermission( activity, permStr );
|
== ContextCompat.checkSelfPermission( activity, permStr );
|
||||||
|
|
||||||
if ( !haveIt ) {
|
if ( !haveIt && inManifest ) {
|
||||||
// do not pass banned perms to the OS! They're not in
|
// do not pass banned perms to the OS! They're not in
|
||||||
// AndroidManifest.xml so may crash on some devices
|
// AndroidManifest.xml so may crash on some devices
|
||||||
Assert.assertFalse( perm.isBanned(activity) );
|
|
||||||
askStrings.add( permStr );
|
askStrings.add( permStr );
|
||||||
|
|
||||||
if ( null != m_onShow ) {
|
if ( null != m_onShow ) {
|
||||||
|
@ -167,14 +175,7 @@ public class Perms23 {
|
||||||
|
|
||||||
if ( haveAll ) {
|
if ( haveAll ) {
|
||||||
if ( null != cbck ) {
|
if ( null != cbck ) {
|
||||||
Map<Perm, Boolean> map = new HashMap<>();
|
callOPR( cbck, true );
|
||||||
boolean allGood = true;
|
|
||||||
for ( Perm perm : m_perms ) {
|
|
||||||
boolean banned = perm.isBanned(activity);
|
|
||||||
map.put( perm, !banned );
|
|
||||||
allGood = allGood & !banned;
|
|
||||||
}
|
|
||||||
callOPR( cbck, allGood, map );
|
|
||||||
}
|
}
|
||||||
} else if ( 0 < needShow.size() && null != m_onShow ) {
|
} else if ( 0 < needShow.size() && null != m_onShow ) {
|
||||||
// Log.d( TAG, "calling onShouldShowRationale()" );
|
// Log.d( TAG, "calling onShouldShowRationale()" );
|
||||||
|
@ -222,11 +223,8 @@ public class Perms23 {
|
||||||
private void doIt( boolean showRationale )
|
private void doIt( boolean showRationale )
|
||||||
{
|
{
|
||||||
Set<Perm> validPerms = new HashSet<>();
|
Set<Perm> validPerms = new HashSet<>();
|
||||||
Set<Perm> bannedPerms = new HashSet<>();
|
|
||||||
for ( Perm perm : m_perms ) {
|
for ( Perm perm : m_perms ) {
|
||||||
if ( perm.isBanned(m_delegate.getActivity()) ) {
|
if ( permInManifest(m_delegate.getActivity(), perm ) ) {
|
||||||
bannedPerms.add( perm );
|
|
||||||
} else {
|
|
||||||
validPerms.add( perm );
|
validPerms.add( perm );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -234,9 +232,6 @@ public class Perms23 {
|
||||||
if ( 0 < validPerms.size() ) {
|
if ( 0 < validPerms.size() ) {
|
||||||
doItAsk( validPerms, showRationale );
|
doItAsk( validPerms, showRationale );
|
||||||
}
|
}
|
||||||
if ( 0 < bannedPerms.size() ) {
|
|
||||||
postNeg();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doItAsk( Set<Perm> perms, boolean showRationale )
|
private void doItAsk( Set<Perm> perms, boolean showRationale )
|
||||||
|
@ -259,8 +254,7 @@ public class Perms23 {
|
||||||
}
|
}
|
||||||
builder.asyncQuery( m_delegate.getActivity(), new PermCbck() {
|
builder.asyncQuery( m_delegate.getActivity(), new PermCbck() {
|
||||||
@Override
|
@Override
|
||||||
public void onPermissionResult( boolean allGood,
|
public void onPermissionResult( boolean allGood ) {
|
||||||
Map<Perm, Boolean> permsMap ) {
|
|
||||||
if ( Action.SKIP_CALLBACK != m_action ) {
|
if ( Action.SKIP_CALLBACK != m_action ) {
|
||||||
if ( allGood ) {
|
if ( allGood ) {
|
||||||
m_delegate.onPosButton( m_action, m_params );
|
m_delegate.onPosButton( m_action, m_params );
|
||||||
|
@ -383,15 +377,13 @@ public class Perms23 {
|
||||||
String[] perms, int[] granteds )
|
String[] perms, int[] granteds )
|
||||||
{
|
{
|
||||||
// Log.d( TAG, "gotPermissionResult(%s)", perms.toString() );
|
// Log.d( TAG, "gotPermissionResult(%s)", perms.toString() );
|
||||||
Map<Perm, Boolean> result = new HashMap<>();
|
|
||||||
boolean shouldResend = false;
|
boolean shouldResend = false;
|
||||||
boolean allGood = true;
|
boolean allGood = true;
|
||||||
for ( int ii = 0; ii < perms.length; ++ii ) {
|
for ( int ii = 0; ii < perms.length; ++ii ) {
|
||||||
Perm perm = Perm.getFor( perms[ii] );
|
Perm perm = Perm.getFor( perms[ii] );
|
||||||
Assert.assertTrue( !perm.isBanned(context) || ! BuildConfig.DEBUG );
|
Assert.assertTrueNR( permInManifest( context, perm ) );
|
||||||
boolean granted = PackageManager.PERMISSION_GRANTED == granteds[ii];
|
boolean granted = PERMISSION_GRANTED == granteds[ii];
|
||||||
allGood = allGood && granted;
|
allGood = allGood && granted;
|
||||||
result.put( perm, granted );
|
|
||||||
|
|
||||||
// Hack. If SMS has been granted, resend all moves. This should be
|
// Hack. If SMS has been granted, resend all moves. This should be
|
||||||
// replaced with an api allowing listeners to register
|
// replaced with an api allowing listeners to register
|
||||||
|
@ -412,7 +404,7 @@ public class Perms23 {
|
||||||
|
|
||||||
PermCbck cbck = s_map.remove( code );
|
PermCbck cbck = s_map.remove( code );
|
||||||
if ( null != cbck ) {
|
if ( null != cbck ) {
|
||||||
callOPR( cbck, allGood, result );
|
callOPR( cbck, allGood );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -421,52 +413,60 @@ public class Perms23 {
|
||||||
boolean result = true;
|
boolean result = true;
|
||||||
for ( int ii = 0; result && ii < perms.length; ++ii ) {
|
for ( int ii = 0; result && ii < perms.length; ++ii ) {
|
||||||
Perm perm = perms[ii];
|
Perm perm = perms[ii];
|
||||||
boolean thisResult;
|
boolean thisResult = permInManifest( context, perm )
|
||||||
if ( perm.isBanned(context) ) {
|
&& PERMISSION_GRANTED
|
||||||
thisResult = bannedWithWorkaround( context, perm );
|
== ContextCompat.checkSelfPermission( XWApp.getContext(),
|
||||||
} else {
|
perm.getString() );
|
||||||
thisResult = PackageManager.PERMISSION_GRANTED
|
|
||||||
== ContextCompat.checkSelfPermission( XWApp.getContext(),
|
|
||||||
perm.getString() );
|
|
||||||
}
|
|
||||||
result = result && thisResult;
|
result = result && thisResult;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean anyBanned( Context context, Perms23.Perm... perms )
|
static final Perm[] NBS_PERMS = { Perm.SEND_SMS, Perm.RECEIVE_SMS, };
|
||||||
|
|
||||||
|
static boolean haveNBSPerms( Context context )
|
||||||
{
|
{
|
||||||
boolean anyBanned = false;
|
return havePermissions( context, NBS_PERMS );
|
||||||
for ( int ii = 0; !anyBanned && ii < perms.length; ++ii ) {
|
|
||||||
anyBanned = perms[ii].isBanned( context );
|
|
||||||
}
|
|
||||||
return anyBanned;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean bannedWithWorkaround( Context context, Perms23.Perm... perms )
|
static boolean NBSPermsInManifest( Context context )
|
||||||
{
|
{
|
||||||
boolean allBanned = true;
|
return permsInManifest( context, NBS_PERMS );
|
||||||
boolean workaroundKnown = true;
|
|
||||||
for ( Perms23.Perm perm : perms ) {
|
|
||||||
allBanned = allBanned && perm.isBanned(context);
|
|
||||||
|
|
||||||
switch ( perm ) {
|
|
||||||
case SEND_SMS:
|
|
||||||
case RECEIVE_SMS:
|
|
||||||
workaroundKnown = false;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
Log.e( TAG, "bannedWithWorkaround(): unexpected perm %s", perm );
|
|
||||||
Assert.failDbg();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean result = allBanned && workaroundKnown;
|
|
||||||
Log.d( TAG, "bannedWithWorkaround() => %b", result );
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// static boolean anyBanned( Context context, Perms23.Perm... perms )
|
||||||
|
// {
|
||||||
|
// boolean anyBanned = false;
|
||||||
|
// for ( int ii = 0; !anyBanned && ii < perms.length; ++ii ) {
|
||||||
|
// anyBanned = perms[ii].isBanned( context );
|
||||||
|
// }
|
||||||
|
// return anyBanned;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// static boolean bannedWithWorkaround( Context context, Perms23.Perm... perms )
|
||||||
|
// {
|
||||||
|
// boolean allBanned = true;
|
||||||
|
// boolean workaroundKnown = true;
|
||||||
|
// for ( Perms23.Perm perm : perms ) {
|
||||||
|
// allBanned = allBanned && perm.isBanned(context);
|
||||||
|
|
||||||
|
// switch ( perm ) {
|
||||||
|
// case SEND_SMS:
|
||||||
|
// case RECEIVE_SMS:
|
||||||
|
// workaroundKnown = false;
|
||||||
|
// break;
|
||||||
|
// default:
|
||||||
|
// Log.e( TAG, "bannedWithWorkaround(): unexpected perm %s", perm );
|
||||||
|
// Assert.failDbg();
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// boolean result = allBanned && workaroundKnown;
|
||||||
|
// Log.d( TAG, "bannedWithWorkaround() => %b", result );
|
||||||
|
// return result;
|
||||||
|
// }
|
||||||
|
|
||||||
// If two permission requests are made in a row the map may contain more
|
// If two permission requests are made in a row the map may contain more
|
||||||
// than one entry.
|
// than one entry.
|
||||||
private static int s_nextRecord = 0;
|
private static int s_nextRecord = 0;
|
||||||
|
@ -478,11 +478,10 @@ public class Perms23 {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void callOPR( PermCbck cbck, boolean allGood,
|
private static void callOPR( PermCbck cbck, boolean allGood )
|
||||||
Map<Perm, Boolean> map )
|
|
||||||
{
|
{
|
||||||
Log.d( TAG, "callOPR(): passing %s to %s", map, cbck );
|
Log.d( TAG, "callOPR(): passing %b to %s", allGood, cbck );
|
||||||
cbck.onPermissionResult( allGood, map );
|
cbck.onPermissionResult( allGood );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2340,18 +2340,15 @@
|
||||||
via Data SMS but CrossWords does not have permission to do so. You
|
via Data SMS but CrossWords does not have permission to do so. You
|
||||||
can still open the game, but it may not be able to send or receive
|
can still open the game, but it may not be able to send or receive
|
||||||
moves.\n\nYou can re-open it to be asked for permission again. Or
|
moves.\n\nYou can re-open it to be asked for permission again. Or
|
||||||
you can remove the Data SMS communication setting.</string>
|
you can remove the Data SMS communication setting.</string>
|
||||||
<string name="not_again_nbsGamesOnUpgrade">The Google Play Store
|
|
||||||
version of CrossWords is no longer allowed to support the
|
<string name="variant_missing_nbs">This game is configured to
|
||||||
Play-by-Data-SMS feature.
|
communicate via Data SMS, but the Google Play Store version of
|
||||||
\n\n
|
CrossWords is no longer allowed to support the Play-by-Data-SMS
|
||||||
You have %1$d open games that use this feature. They will not be
|
feature. \n\n You can still open the game, but it may not be able
|
||||||
able to send or receive moves via Data SMS as long as you are using
|
to send or receive moves.</string>
|
||||||
the Google Play version of CrossWords, or until I can figure out a
|
|
||||||
workaround that meets Store policies.
|
<string name="download_rationale">CrossWords needs access to
|
||||||
\n\n
|
|
||||||
You can read more using the button below.</string>
|
|
||||||
<string name="download_rationale">CrossWords needs access to
|
|
||||||
temporary storage to keep what you’re about to download.
|
temporary storage to keep what you’re about to download.
|
||||||
</string>
|
</string>
|
||||||
<string name="sms_invite_rationale">
|
<string name="sms_invite_rationale">
|
||||||
|
@ -2416,12 +2413,6 @@
|
||||||
• Launch CrossWords on the other device\n
|
• Launch CrossWords on the other device\n
|
||||||
• If all else fails, reboot this device\n
|
• If all else fails, reboot this device\n
|
||||||
</string>
|
</string>
|
||||||
|
|
||||||
<string name="sms_banned_ok_only">The Google Play version of CrossWords no longer supports invitations or play via data SMS.</string>
|
|
||||||
<string name="button_more_info">Read more</string>
|
|
||||||
<string name="banned_nbs_perms">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.
|
|
||||||
\n
|
|
||||||
\nYou can remove the data SMS communication setting, or use the “Read more” button to check progress on the development of an alternative.</string>
|
|
||||||
<string name="not_again_longtap_lookup">You can look up words BEFORE
|
<string name="not_again_longtap_lookup">You can look up words BEFORE
|
||||||
they’re committed as moves—by long-tapping, same as committed
|
they’re committed as moves—by long-tapping, same as committed
|
||||||
words.\n\nUse this feature to check the validity of words you’re
|
words.\n\nUse this feature to check the validity of words you’re
|
||||||
|
|
Loading…
Add table
Reference in a new issue