diff --git a/xwords4/android/app/build.gradle b/xwords4/android/app/build.gradle index a6e2287ac..b8d5c980b 100644 --- a/xwords4/android/app/build.gradle +++ b/xwords4/android/app/build.gradle @@ -141,8 +141,7 @@ android { dimension "variant" applicationId "org.eehouse.android.xw4" manifestPlaceholders = [ APP_ID: applicationId ] - resValue "string", "app_name", "CrossWords" - resValue "string", "nbs_port", "3344" + resValue "string", "app_name", "DoNotRelease" buildConfigField "boolean", "WIDIR_ENABLED", "false" buildConfigField "String", "VARIANT_NAME", "\"Google Play Store\"" buildConfigField "int", "VARIANT_CODE", "1" diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/Perms23.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/Perms23.java index ba781129c..0bc1068f0 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/Perms23.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/Perms23.java @@ -49,7 +49,8 @@ public class Perms23 { RECEIVE_SMS(Manifest.permission.RECEIVE_SMS), READ_CONTACTS(Manifest.permission.READ_CONTACTS), BLUETOOTH_CONNECT(Manifest.permission.BLUETOOTH_CONNECT), - BLUETOOTH_SCAN(Manifest.permission.BLUETOOTH_SCAN); + BLUETOOTH_SCAN(Manifest.permission.BLUETOOTH_SCAN), + REQUEST_INSTALL_PACKAGES(Manifest.permission.REQUEST_INSTALL_PACKAGES); private String m_str = null; private Perm(String str) { m_str = str; } @@ -72,7 +73,7 @@ public class Perms23 { } private static Map sManifestMap = new HashMap<>(); - private static boolean permInManifest( Context context, Perm perm ) + static boolean permInManifest( Context context, Perm perm ) { boolean result = false; if ( sManifestMap.containsKey( perm ) ) { diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/UpdateCheckReceiver.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/UpdateCheckReceiver.java index 1ec40039e..869c9eb2d 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/UpdateCheckReceiver.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/UpdateCheckReceiver.java @@ -297,72 +297,78 @@ public class UpdateCheckReceiver extends BroadcastReceiver { // Add upgrade if ( jobj.has( k_APP ) ) { - JSONObject app = jobj.getJSONObject( k_APP ); - if ( app.has( k_URL ) ) { - ApplicationInfo ai = - m_pm.getApplicationInfo( m_packageName, 0); - String label = m_pm.getApplicationLabel( ai ).toString(); + if ( Perms23.permInManifest( m_context, + Perms23.Perm + .REQUEST_INSTALL_PACKAGES ) ) { + JSONObject app = jobj.getJSONObject( k_APP ); + if ( app.has( k_URL ) ) { + ApplicationInfo ai = + m_pm.getApplicationInfo( m_packageName, 0); + String label = m_pm.getApplicationLabel( ai ).toString(); - // If there's a download dir AND an installer - // app, handle this ourselves. Otherwise just - // launch the browser - boolean useBrowser; - File downloads = DictUtils.getDownloadDir( m_context ); - if ( null == downloads ) { - useBrowser = true; - } else { - File tmp = new File( downloads, - "xx" + XWConstants.APK_EXTN ); - useBrowser = !Utils.canInstall( m_context, tmp ); - } - - String urlParm = app.getString( k_URL ); - - // Debug builds check frequently on a timer and - // when it's something we don't want it's annoying - // to get a lot of offers. So track the URL used, - // and only offer once per URL unless the request - // was manual. - boolean skipIt = false; - if ( BuildConfig.NON_RELEASE && !m_fromUI ) { - String prevURL = DBUtils.getStringFor( m_context, KEY_PREV_URL ); - if ( urlParm.equals( prevURL ) ) { - skipIt = true; + // If there's a download dir AND an installer + // app, handle this ourselves. Otherwise just + // launch the browser + boolean useBrowser; + File downloads = DictUtils.getDownloadDir( m_context ); + if ( null == downloads ) { + useBrowser = true; } else { - DBUtils.setStringFor( m_context, KEY_PREV_URL, urlParm ); - } - } - if ( !skipIt ) { - gotOne = true; - String url = NetUtils.ensureHttps( urlParm ); - Intent intent; - if ( useBrowser ) { - intent = new Intent( Intent.ACTION_VIEW, - Uri.parse(url) ); - } else { - intent = DwnldDelegate - .makeAppDownloadIntent( m_context, url ); + File tmp = new File( downloads, + "xx" + XWConstants.APK_EXTN ); + useBrowser = !Utils.canInstall( m_context, tmp ); } - // If I asked explicitly, let's download now. - if ( m_fromUI && !useBrowser ) { - m_context.startActivity( intent ); - } else { - // title and/or body might be in the reply - String title = app.optString( k_UPGRADE_TITLE, null ); - if ( null == title ) { - title = LocUtils - .getString( m_context, R.string.new_app_avail_fmt, label ); + String urlParm = app.getString( k_URL ); + + // Debug builds check frequently on a timer and + // when it's something we don't want it's annoying + // to get a lot of offers. So track the URL used, + // and only offer once per URL unless the request + // was manual. + boolean skipIt = false; + if ( BuildConfig.NON_RELEASE && !m_fromUI ) { + String prevURL = DBUtils.getStringFor( m_context, KEY_PREV_URL ); + if ( urlParm.equals( prevURL ) ) { + skipIt = true; + } else { + DBUtils.setStringFor( m_context, KEY_PREV_URL, urlParm ); } - String body = app.optString( k_UPGRADE_BODY, null ); - if ( null == body ) { - body = LocUtils - .getString( m_context, R.string.new_app_avail ); + } + if ( !skipIt ) { + gotOne = true; + String url = NetUtils.ensureHttps( urlParm ); + Intent intent; + if ( useBrowser ) { + intent = new Intent( Intent.ACTION_VIEW, + Uri.parse(url) ); + } else { + intent = DwnldDelegate + .makeAppDownloadIntent( m_context, url ); + } + + // If I asked explicitly, let's download now. + if ( m_fromUI && !useBrowser ) { + m_context.startActivity( intent ); + } else { + // title and/or body might be in the reply + String title = app.optString( k_UPGRADE_TITLE, null ); + if ( null == title ) { + title = LocUtils + .getString( m_context, R.string.new_app_avail_fmt, label ); + } + String body = app.optString( k_UPGRADE_BODY, null ); + if ( null == body ) { + body = LocUtils + .getString( m_context, R.string.new_app_avail ); + } + Utils.postNotification( m_context, intent, title, + body, title.hashCode() ); } - Utils.postNotification( m_context, intent, title, - body, title.hashCode() ); } } + } else { + Log.d( TAG, "need to notify upgrade available" ); } } diff --git a/xwords4/android/app/src/xw4Foss/AndroidManifest.xml b/xwords4/android/app/src/xw4Foss/AndroidManifest.xml index 8204e69f6..e9a473d88 100644 --- a/xwords4/android/app/src/xw4Foss/AndroidManifest.xml +++ b/xwords4/android/app/src/xw4Foss/AndroidManifest.xml @@ -8,9 +8,6 @@ - - -