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"
|
||||
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"
|
||||
|
|
|
@ -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<Perm, Boolean> 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 ) ) {
|
||||
|
|
|
@ -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" );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,9 +8,6 @@
|
|||
<uses-permission android:name="android.permission.SEND_SMS" />
|
||||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
||||
|
||||
<!-- for crittercism -->
|
||||
<uses-permission android:name="android.permission.GET_TASKS"/>
|
||||
|
||||
<application android:icon="@drawable/icon48x48"
|
||||
android:label="@string/app_name"
|
||||
android:name=".XWApp"
|
||||
|
|
Loading…
Add table
Reference in a new issue