mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-18 05:39:53 +01:00
Merge branch '1633-min-api-16' into 'master'
[android] Raise minimum API level to 16 Closes #1633 See merge request briar/briar!1171
This commit is contained in:
@@ -9,7 +9,7 @@ android {
|
|||||||
buildToolsVersion '28.0.3'
|
buildToolsVersion '28.0.3'
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 14
|
minSdkVersion 16
|
||||||
targetSdkVersion 26
|
targetSdkVersion 26
|
||||||
versionCode 10109
|
versionCode 10109
|
||||||
versionName "1.1.9"
|
versionName "1.1.9"
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package org.briarproject.bramble.plugin.tor;
|
package org.briarproject.bramble.plugin.tor;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Build;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.battery.BatteryManager;
|
import org.briarproject.bramble.api.battery.BatteryManager;
|
||||||
import org.briarproject.bramble.api.event.EventBus;
|
import org.briarproject.bramble.api.event.EventBus;
|
||||||
@@ -101,8 +100,8 @@ public class AndroidTorPluginFactory implements DuplexPluginFactory {
|
|||||||
LOG.info("Tor is not supported on this architecture");
|
LOG.info("Tor is not supported on this architecture");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// Use position-independent executable for SDK >= 16
|
// Use position-independent executable
|
||||||
if (Build.VERSION.SDK_INT >= 16) architecture += "_pie";
|
architecture += "_pie";
|
||||||
|
|
||||||
Backoff backoff = backoffFactory.createBackoff(MIN_POLLING_INTERVAL,
|
Backoff backoff = backoffFactory.createBackoff(MIN_POLLING_INTERVAL,
|
||||||
MAX_POLLING_INTERVAL, BACKOFF_BASE);
|
MAX_POLLING_INTERVAL, BACKOFF_BASE);
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import javax.annotation.concurrent.Immutable;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import static android.content.Context.WIFI_SERVICE;
|
import static android.content.Context.WIFI_SERVICE;
|
||||||
|
import static android.os.Build.VERSION.SDK_INT;
|
||||||
import static android.provider.Settings.Secure.ANDROID_ID;
|
import static android.provider.Settings.Secure.ANDROID_ID;
|
||||||
|
|
||||||
@Immutable
|
@Immutable
|
||||||
@@ -74,8 +75,7 @@ class AndroidSecureRandomProvider extends UnixSecureRandomProvider {
|
|||||||
// Silence strict mode
|
// Silence strict mode
|
||||||
StrictMode.ThreadPolicy tp = StrictMode.allowThreadDiskWrites();
|
StrictMode.ThreadPolicy tp = StrictMode.allowThreadDiskWrites();
|
||||||
super.writeSeed();
|
super.writeSeed();
|
||||||
if (Build.VERSION.SDK_INT >= 16 && Build.VERSION.SDK_INT <= 18)
|
if (SDK_INT <= 18) applyOpenSslFix();
|
||||||
applyOpenSslFix();
|
|
||||||
StrictMode.setThreadPolicy(tp);
|
StrictMode.setThreadPolicy(tp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ android {
|
|||||||
buildToolsVersion '28.0.3'
|
buildToolsVersion '28.0.3'
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 15
|
minSdkVersion 16
|
||||||
targetSdkVersion 26
|
targetSdkVersion 26
|
||||||
versionCode 10109
|
versionCode 10109
|
||||||
versionName "1.1.9"
|
versionName "1.1.9"
|
||||||
|
|||||||
@@ -1,54 +0,0 @@
|
|||||||
package org.briarproject.briar.android;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.Application.ActivityLifecycleCallbacks;
|
|
||||||
import android.os.Bundle;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import javax.annotation.concurrent.ThreadSafe;
|
|
||||||
|
|
||||||
@ThreadSafe
|
|
||||||
@NotNullByDefault
|
|
||||||
class BackgroundMonitor implements ActivityLifecycleCallbacks {
|
|
||||||
|
|
||||||
private final AtomicInteger foregroundActivities = new AtomicInteger(0);
|
|
||||||
|
|
||||||
boolean isRunningInBackground() {
|
|
||||||
return foregroundActivities.get() == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onActivityCreated(Activity a, @Nullable Bundle state) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onActivityStarted(Activity a) {
|
|
||||||
foregroundActivities.incrementAndGet();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onActivityResumed(Activity a) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onActivityPaused(Activity a) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onActivityStopped(Activity a) {
|
|
||||||
foregroundActivities.decrementAndGet();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onActivitySaveInstanceState(Activity a,
|
|
||||||
@Nullable Bundle outState) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onActivityDestroyed(Activity a) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -34,7 +34,6 @@ import java.util.logging.LogRecord;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import static android.app.ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND;
|
import static android.app.ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND;
|
||||||
import static android.os.Build.VERSION.SDK_INT;
|
|
||||||
import static java.util.logging.Level.FINE;
|
import static java.util.logging.Level.FINE;
|
||||||
import static java.util.logging.Level.INFO;
|
import static java.util.logging.Level.INFO;
|
||||||
import static java.util.logging.Logger.getLogger;
|
import static java.util.logging.Logger.getLogger;
|
||||||
@@ -86,7 +85,6 @@ public class BriarApplicationImpl extends Application
|
|||||||
getLogger(BriarApplicationImpl.class.getName());
|
getLogger(BriarApplicationImpl.class.getName());
|
||||||
|
|
||||||
private final CachingLogHandler logHandler = new CachingLogHandler();
|
private final CachingLogHandler logHandler = new CachingLogHandler();
|
||||||
private final BackgroundMonitor backgroundMonitor = new BackgroundMonitor();
|
|
||||||
|
|
||||||
private AndroidComponent applicationComponent;
|
private AndroidComponent applicationComponent;
|
||||||
private volatile SharedPreferences prefs;
|
private volatile SharedPreferences prefs;
|
||||||
@@ -127,9 +125,6 @@ public class BriarApplicationImpl extends Application
|
|||||||
|
|
||||||
applicationComponent = createApplicationComponent();
|
applicationComponent = createApplicationComponent();
|
||||||
EmojiManager.install(new GoogleEmojiProvider());
|
EmojiManager.install(new GoogleEmojiProvider());
|
||||||
|
|
||||||
if (SDK_INT < 16)
|
|
||||||
registerActivityLifecycleCallbacks(backgroundMonitor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected AndroidComponent createApplicationComponent() {
|
protected AndroidComponent createApplicationComponent() {
|
||||||
@@ -191,12 +186,8 @@ public class BriarApplicationImpl extends Application
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isRunningInBackground() {
|
public boolean isRunningInBackground() {
|
||||||
if (SDK_INT >= 16) {
|
RunningAppProcessInfo info = new RunningAppProcessInfo();
|
||||||
RunningAppProcessInfo info = new RunningAppProcessInfo();
|
ActivityManager.getMyMemoryState(info);
|
||||||
ActivityManager.getMyMemoryState(info);
|
return (info.importance != IMPORTANCE_FOREGROUND);
|
||||||
return (info.importance != IMPORTANCE_FOREGROUND);
|
|
||||||
} else {
|
|
||||||
return backgroundMonitor.isRunningInBackground();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -238,8 +238,6 @@ public class BriarService extends Service {
|
|||||||
} else if (level == TRIM_MEMORY_RUNNING_LOW) {
|
} else if (level == TRIM_MEMORY_RUNNING_LOW) {
|
||||||
LOG.info("Trim memory: running low");
|
LOG.info("Trim memory: running low");
|
||||||
} else if (level == TRIM_MEMORY_RUNNING_CRITICAL) {
|
} else if (level == TRIM_MEMORY_RUNNING_CRITICAL) {
|
||||||
// This level may be received if SDK_INT < 16, although the
|
|
||||||
// constant isn't declared until API level 16
|
|
||||||
LOG.warning("Trim memory: running critically low");
|
LOG.warning("Trim memory: running critically low");
|
||||||
// If we're not in the foreground, clear the UI to save memory
|
// If we're not in the foreground, clear the UI to save memory
|
||||||
if (app.isRunningInBackground()) hideUi();
|
if (app.isRunningInBackground()) hideUi();
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ class ScreenFilterMonitorImpl implements ScreenFilterMonitor, Service {
|
|||||||
// Get permissions
|
// Get permissions
|
||||||
String[] requestedPermissions = packageInfo.requestedPermissions;
|
String[] requestedPermissions = packageInfo.requestedPermissions;
|
||||||
if (requestedPermissions == null) return false;
|
if (requestedPermissions == null) return false;
|
||||||
if (SDK_INT >= 16 && SDK_INT < 23) {
|
if (SDK_INT < 23) {
|
||||||
// Check whether the permission has been requested and granted
|
// Check whether the permission has been requested and granted
|
||||||
int[] flags = packageInfo.requestedPermissionsFlags;
|
int[] flags = packageInfo.requestedPermissionsFlags;
|
||||||
for (int i = 0; i < requestedPermissions.length; i++) {
|
for (int i = 0; i < requestedPermissions.length; i++) {
|
||||||
|
|||||||
@@ -142,11 +142,8 @@ public class ImageActivity extends BriarActivity
|
|||||||
viewPager.setAdapter(pagerAdapter);
|
viewPager.setAdapter(pagerAdapter);
|
||||||
viewPager.setCurrentItem(position);
|
viewPager.setCurrentItem(position);
|
||||||
|
|
||||||
if (SDK_INT >= 16) {
|
viewModel.getOnImageClicked().observeEvent(this, this::onImageClicked);
|
||||||
viewModel.getOnImageClicked()
|
window.getDecorView().setSystemUiVisibility(UI_FLAGS_DEFAULT);
|
||||||
.observeEvent(this, this::onImageClicked);
|
|
||||||
window.getDecorView().setSystemUiVisibility(UI_FLAGS_DEFAULT);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -174,11 +171,7 @@ public class ImageActivity extends BriarActivity
|
|||||||
viewModel.setToolbarPosition(
|
viewModel.setToolbarPosition(
|
||||||
appBarLayout.getTop(), appBarLayout.getBottom()
|
appBarLayout.getTop(), appBarLayout.getBottom()
|
||||||
);
|
);
|
||||||
if (SDK_INT >= 16) {
|
layout.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
||||||
layout.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
|
||||||
} else {
|
|
||||||
layout.getViewTreeObserver().removeGlobalOnLayoutListener(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -265,7 +258,7 @@ public class ImageActivity extends BriarActivity
|
|||||||
* when the previous activity (with visible status bar) is shown.
|
* when the previous activity (with visible status bar) is shown.
|
||||||
*/
|
*/
|
||||||
private void showStatusBarBeforeFinishing() {
|
private void showStatusBarBeforeFinishing() {
|
||||||
if (SDK_INT >= 16 && appBarLayout.getVisibility() == GONE) {
|
if (appBarLayout.getVisibility() == GONE) {
|
||||||
View decorView = getWindow().getDecorView();
|
View decorView = getWindow().getDecorView();
|
||||||
decorView.setSystemUiVisibility(UI_FLAGS_DEFAULT);
|
decorView.setSystemUiVisibility(UI_FLAGS_DEFAULT);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ import static android.hardware.Camera.Parameters.FOCUS_MODE_FIXED;
|
|||||||
import static android.hardware.Camera.Parameters.FOCUS_MODE_MACRO;
|
import static android.hardware.Camera.Parameters.FOCUS_MODE_MACRO;
|
||||||
import static android.hardware.Camera.Parameters.SCENE_MODE_AUTO;
|
import static android.hardware.Camera.Parameters.SCENE_MODE_AUTO;
|
||||||
import static android.hardware.Camera.Parameters.SCENE_MODE_BARCODE;
|
import static android.hardware.Camera.Parameters.SCENE_MODE_BARCODE;
|
||||||
import static android.os.Build.VERSION.SDK_INT;
|
|
||||||
import static java.util.logging.Level.INFO;
|
import static java.util.logging.Level.INFO;
|
||||||
import static java.util.logging.Level.WARNING;
|
import static java.util.logging.Level.WARNING;
|
||||||
import static org.briarproject.bramble.util.LogUtils.logException;
|
import static org.briarproject.bramble.util.LogUtils.logException;
|
||||||
@@ -340,7 +339,7 @@ public class CameraView extends SurfaceView implements SurfaceHolder.Callback,
|
|||||||
|
|
||||||
@UiThread
|
@UiThread
|
||||||
private void setVideoStabilisation(Parameters params) {
|
private void setVideoStabilisation(Parameters params) {
|
||||||
if (SDK_INT >= 15 && params.isVideoStabilizationSupported()) {
|
if (params.isVideoStabilizationSupported()) {
|
||||||
params.setVideoStabilization(true);
|
params.setVideoStabilization(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -415,10 +414,8 @@ public class CameraView extends SurfaceView implements SurfaceHolder.Callback,
|
|||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
throw new CameraException(e);
|
throw new CameraException(e);
|
||||||
}
|
}
|
||||||
if (SDK_INT >= 15) {
|
LOG.info("Video stabilisation enabled: "
|
||||||
LOG.info("Video stabilisation enabled: "
|
+ params.getVideoStabilization());
|
||||||
+ params.getVideoStabilization());
|
|
||||||
}
|
|
||||||
LOG.info("Scene mode: " + params.getSceneMode());
|
LOG.info("Scene mode: " + params.getSceneMode());
|
||||||
LOG.info("Focus mode: " + params.getFocusMode());
|
LOG.info("Focus mode: " + params.getFocusMode());
|
||||||
LOG.info("Flash mode: " + params.getFlashMode());
|
LOG.info("Flash mode: " + params.getFlashMode());
|
||||||
|
|||||||
@@ -90,14 +90,9 @@ public class BriarReportPrimer implements ReportPrimer {
|
|||||||
ActivityManager.MemoryInfo mem = new ActivityManager.MemoryInfo();
|
ActivityManager.MemoryInfo mem = new ActivityManager.MemoryInfo();
|
||||||
am.getMemoryInfo(mem);
|
am.getMemoryInfo(mem);
|
||||||
String systemMemory;
|
String systemMemory;
|
||||||
if (Build.VERSION.SDK_INT >= 16) {
|
systemMemory = (mem.totalMem / 1024 / 1024) + " MiB total, "
|
||||||
systemMemory = (mem.totalMem / 1024 / 1024) + " MiB total, "
|
+ (mem.availMem / 1024 / 1204) + " MiB free, "
|
||||||
+ (mem.availMem / 1024 / 1204) + " MiB free, "
|
+ (mem.threshold / 1024 / 1024) + " MiB threshold";
|
||||||
+ (mem.threshold / 1024 / 1024) + " MiB threshold";
|
|
||||||
} else {
|
|
||||||
systemMemory = (mem.availMem / 1024 / 1204) + " MiB free, "
|
|
||||||
+ (mem.threshold / 1024 / 1024) + " MiB threshold";
|
|
||||||
}
|
|
||||||
customData.put("System memory", systemMemory);
|
customData.put("System memory", systemMemory);
|
||||||
|
|
||||||
// Virtual machine memory
|
// Virtual machine memory
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import android.widget.ProgressBar;
|
|||||||
import org.briarproject.briar.R;
|
import org.briarproject.briar.R;
|
||||||
|
|
||||||
import static android.content.Context.LAYOUT_INFLATER_SERVICE;
|
import static android.content.Context.LAYOUT_INFLATER_SERVICE;
|
||||||
import static android.os.Build.VERSION.SDK_INT;
|
|
||||||
import static java.util.Objects.requireNonNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
public class CompositeSendButton extends FrameLayout {
|
public class CompositeSendButton extends FrameLayout {
|
||||||
@@ -75,33 +74,24 @@ public class CompositeSendButton extends FrameLayout {
|
|||||||
if (showImageButton) {
|
if (showImageButton) {
|
||||||
imageButton.setVisibility(VISIBLE);
|
imageButton.setVisibility(VISIBLE);
|
||||||
sendButton.setEnabled(false);
|
sendButton.setEnabled(false);
|
||||||
if (SDK_INT <= 15) {
|
sendButton.clearAnimation();
|
||||||
|
sendButton.animate().alpha(0f).withEndAction(() -> {
|
||||||
sendButton.setVisibility(INVISIBLE);
|
sendButton.setVisibility(INVISIBLE);
|
||||||
imageButton.setEnabled(true);
|
imageButton.setEnabled(true);
|
||||||
} else {
|
}).start();
|
||||||
sendButton.clearAnimation();
|
imageButton.clearAnimation();
|
||||||
sendButton.animate().alpha(0f).withEndAction(() -> {
|
imageButton.animate().alpha(1f).start();
|
||||||
sendButton.setVisibility(INVISIBLE);
|
|
||||||
imageButton.setEnabled(true);
|
|
||||||
}).start();
|
|
||||||
imageButton.clearAnimation();
|
|
||||||
imageButton.animate().alpha(1f).start();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
sendButton.setVisibility(VISIBLE);
|
sendButton.setVisibility(VISIBLE);
|
||||||
// enable/disable buttons right away to allow fast sending
|
// enable/disable buttons right away to allow fast sending
|
||||||
sendButton.setEnabled(sendEnabled);
|
sendButton.setEnabled(sendEnabled);
|
||||||
imageButton.setEnabled(false);
|
imageButton.setEnabled(false);
|
||||||
if (SDK_INT <= 15) {
|
sendButton.clearAnimation();
|
||||||
imageButton.setVisibility(INVISIBLE);
|
sendButton.animate().alpha(1f).start();
|
||||||
} else {
|
imageButton.clearAnimation();
|
||||||
sendButton.clearAnimation();
|
imageButton.animate().alpha(0f).withEndAction(() ->
|
||||||
sendButton.animate().alpha(1f).start();
|
imageButton.setVisibility(INVISIBLE)
|
||||||
imageButton.clearAnimation();
|
).start();
|
||||||
imageButton.animate().alpha(0f).withEndAction(() ->
|
|
||||||
imageButton.setVisibility(INVISIBLE)
|
|
||||||
).start();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user