mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-30 08:34:16 +01:00
remove REQUEST_INSTALL_PACKAGES from all variants
And start adding it to those not on the Play Store
This commit is contained in:
parent
c5e24d1294
commit
93db9f5add
4 changed files with 68 additions and 65 deletions
|
@ -141,8 +141,7 @@ android {
|
||||||
dimension "variant"
|
dimension "variant"
|
||||||
applicationId "org.eehouse.android.xw4"
|
applicationId "org.eehouse.android.xw4"
|
||||||
manifestPlaceholders = [ APP_ID: applicationId ]
|
manifestPlaceholders = [ APP_ID: applicationId ]
|
||||||
resValue "string", "app_name", "CrossWords"
|
resValue "string", "app_name", "DoNotRelease"
|
||||||
resValue "string", "nbs_port", "3344"
|
|
||||||
buildConfigField "boolean", "WIDIR_ENABLED", "false"
|
buildConfigField "boolean", "WIDIR_ENABLED", "false"
|
||||||
buildConfigField "String", "VARIANT_NAME", "\"Google Play Store\""
|
buildConfigField "String", "VARIANT_NAME", "\"Google Play Store\""
|
||||||
buildConfigField "int", "VARIANT_CODE", "1"
|
buildConfigField "int", "VARIANT_CODE", "1"
|
||||||
|
|
|
@ -49,7 +49,8 @@ public class Perms23 {
|
||||||
RECEIVE_SMS(Manifest.permission.RECEIVE_SMS),
|
RECEIVE_SMS(Manifest.permission.RECEIVE_SMS),
|
||||||
READ_CONTACTS(Manifest.permission.READ_CONTACTS),
|
READ_CONTACTS(Manifest.permission.READ_CONTACTS),
|
||||||
BLUETOOTH_CONNECT(Manifest.permission.BLUETOOTH_CONNECT),
|
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 String m_str = null;
|
||||||
private Perm(String str) { m_str = str; }
|
private Perm(String str) { m_str = str; }
|
||||||
|
@ -72,7 +73,7 @@ public class Perms23 {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Map<Perm, Boolean> sManifestMap = new HashMap<>();
|
private static Map<Perm, Boolean> sManifestMap = new HashMap<>();
|
||||||
private static boolean permInManifest( Context context, Perm perm )
|
static boolean permInManifest( Context context, Perm perm )
|
||||||
{
|
{
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
if ( sManifestMap.containsKey( perm ) ) {
|
if ( sManifestMap.containsKey( perm ) ) {
|
||||||
|
|
|
@ -297,72 +297,78 @@ public class UpdateCheckReceiver extends BroadcastReceiver {
|
||||||
|
|
||||||
// Add upgrade
|
// Add upgrade
|
||||||
if ( jobj.has( k_APP ) ) {
|
if ( jobj.has( k_APP ) ) {
|
||||||
JSONObject app = jobj.getJSONObject( k_APP );
|
if ( Perms23.permInManifest( m_context,
|
||||||
if ( app.has( k_URL ) ) {
|
Perms23.Perm
|
||||||
ApplicationInfo ai =
|
.REQUEST_INSTALL_PACKAGES ) ) {
|
||||||
m_pm.getApplicationInfo( m_packageName, 0);
|
JSONObject app = jobj.getJSONObject( k_APP );
|
||||||
String label = m_pm.getApplicationLabel( ai ).toString();
|
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
|
// If there's a download dir AND an installer
|
||||||
// app, handle this ourselves. Otherwise just
|
// app, handle this ourselves. Otherwise just
|
||||||
// launch the browser
|
// launch the browser
|
||||||
boolean useBrowser;
|
boolean useBrowser;
|
||||||
File downloads = DictUtils.getDownloadDir( m_context );
|
File downloads = DictUtils.getDownloadDir( m_context );
|
||||||
if ( null == downloads ) {
|
if ( null == downloads ) {
|
||||||
useBrowser = true;
|
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;
|
|
||||||
} else {
|
} else {
|
||||||
DBUtils.setStringFor( m_context, KEY_PREV_URL, urlParm );
|
File tmp = new File( downloads,
|
||||||
}
|
"xx" + XWConstants.APK_EXTN );
|
||||||
}
|
useBrowser = !Utils.canInstall( m_context, tmp );
|
||||||
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.
|
String urlParm = app.getString( k_URL );
|
||||||
if ( m_fromUI && !useBrowser ) {
|
|
||||||
m_context.startActivity( intent );
|
// Debug builds check frequently on a timer and
|
||||||
} else {
|
// when it's something we don't want it's annoying
|
||||||
// title and/or body might be in the reply
|
// to get a lot of offers. So track the URL used,
|
||||||
String title = app.optString( k_UPGRADE_TITLE, null );
|
// and only offer once per URL unless the request
|
||||||
if ( null == title ) {
|
// was manual.
|
||||||
title = LocUtils
|
boolean skipIt = false;
|
||||||
.getString( m_context, R.string.new_app_avail_fmt, label );
|
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 ) {
|
if ( !skipIt ) {
|
||||||
body = LocUtils
|
gotOne = true;
|
||||||
.getString( m_context, R.string.new_app_avail );
|
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" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,9 +8,6 @@
|
||||||
<uses-permission android:name="android.permission.SEND_SMS" />
|
<uses-permission android:name="android.permission.SEND_SMS" />
|
||||||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
||||||
|
|
||||||
<!-- for crittercism -->
|
|
||||||
<uses-permission android:name="android.permission.GET_TASKS"/>
|
|
||||||
|
|
||||||
<application android:icon="@drawable/icon48x48"
|
<application android:icon="@drawable/icon48x48"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:name=".XWApp"
|
android:name=".XWApp"
|
||||||
|
|
Loading…
Add table
Reference in a new issue