Search in sources :

Example 31 with Build

use of android.os.Build in project Signal-Android by WhisperSystems.

the class Megaphones method buildNotificationsMegaphone.

@NonNull
private static Megaphone buildNotificationsMegaphone(@NonNull Context context) {
    return new Megaphone.Builder(Event.NOTIFICATIONS, Megaphone.Style.BASIC).setTitle(R.string.NotificationsMegaphone_turn_on_notifications).setBody(R.string.NotificationsMegaphone_never_miss_a_message).setImage(R.drawable.megaphone_notifications_64).setActionButton(R.string.NotificationsMegaphone_turn_on, (megaphone, controller) -> {
        if (Build.VERSION.SDK_INT >= 26 && !NotificationChannels.isMessageChannelEnabled(context)) {
            Intent intent = new Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS);
            intent.putExtra(Settings.EXTRA_CHANNEL_ID, NotificationChannels.getMessagesChannel(context));
            intent.putExtra(Settings.EXTRA_APP_PACKAGE, context.getPackageName());
            controller.onMegaphoneNavigationRequested(intent);
        } else if (Build.VERSION.SDK_INT >= 26 && (!NotificationChannels.areNotificationsEnabled(context) || !NotificationChannels.isMessagesChannelGroupEnabled(context))) {
            Intent intent = new Intent(Settings.ACTION_APP_NOTIFICATION_SETTINGS);
            intent.putExtra(Settings.EXTRA_APP_PACKAGE, context.getPackageName());
            controller.onMegaphoneNavigationRequested(intent);
        } else {
            controller.onMegaphoneNavigationRequested(AppSettingsActivity.notifications(context));
        }
    }).setSecondaryButton(R.string.NotificationsMegaphone_not_now, (megaphone, controller) -> controller.onMegaphoneSnooze(Event.NOTIFICATIONS)).build();
}
Also used : SignalStore(org.thoughtcrime.securesms.keyvalue.SignalStore) Context(android.content.Context) Stream(com.annimon.stream.Stream) NonNull(androidx.annotation.NonNull) LocalDateTime(java.time.LocalDateTime) WorkerThread(androidx.annotation.WorkerThread) Intent(android.content.Intent) R(org.thoughtcrime.securesms.R) LinkedHashMap(java.util.LinkedHashMap) LocaleFeatureFlags(org.thoughtcrime.securesms.util.LocaleFeatureFlags) SignalPinReminders(org.thoughtcrime.securesms.lock.SignalPinReminders) NotificationChannels(org.thoughtcrime.securesms.notifications.NotificationChannels) TranslationDetection(org.signal.core.util.TranslationDetection) Locale(java.util.Locale) Map(java.util.Map) Badge(org.thoughtcrime.securesms.badges.models.Badge) Settings(android.provider.Settings) Recipient(org.thoughtcrime.securesms.recipients.Recipient) KbsMigrationActivity(org.thoughtcrime.securesms.lock.v2.KbsMigrationActivity) Build(android.os.Build) PlayServicesUtil(org.thoughtcrime.securesms.util.PlayServicesUtil) AppSettingsActivity(org.thoughtcrime.securesms.components.settings.app.AppSettingsActivity) MegaphoneRecord(org.thoughtcrime.securesms.database.model.MegaphoneRecord) AvatarHelper(org.thoughtcrime.securesms.profiles.AvatarHelper) Month(java.time.Month) ApplicationDependencies(org.thoughtcrime.securesms.dependencies.ApplicationDependencies) Set(java.util.Set) NetworkConstraint(org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint) DynamicLanguageContextWrapper(org.thoughtcrime.securesms.util.dynamiclanguage.DynamicLanguageContextWrapper) SetUtil(org.thoughtcrime.securesms.util.SetUtil) CreateKbsPinActivity(org.thoughtcrime.securesms.lock.v2.CreateKbsPinActivity) SignalPinReminderDialog(org.thoughtcrime.securesms.lock.SignalPinReminderDialog) Objects(java.util.Objects) TimeUnit(java.util.concurrent.TimeUnit) Log(org.signal.core.util.logging.Log) FeatureFlags(org.thoughtcrime.securesms.util.FeatureFlags) List(java.util.List) Nullable(androidx.annotation.Nullable) VersionTracker(org.thoughtcrime.securesms.util.VersionTracker) ChatWallpaperActivity(org.thoughtcrime.securesms.wallpaper.ChatWallpaperActivity) ManageProfileActivity(org.thoughtcrime.securesms.profiles.manage.ManageProfileActivity) Intent(android.content.Intent) NonNull(androidx.annotation.NonNull)

Example 32 with Build

use of android.os.Build in project robolectric by robolectric.

the class RobolectricTestRunnerTest method shouldReportPerfStats.

@Test
public void shouldReportPerfStats() throws Exception {
    List<Metric> metrics = new ArrayList<>();
    PerfStatsReporter reporter = (metadata, metrics1) -> metrics.addAll(metrics1);
    RobolectricTestRunner runner = new SingleSdkRobolectricTestRunner(TestWithTwoMethods.class, RobolectricTestRunner.defaultInjector().bind(PerfStatsReporter[].class, new PerfStatsReporter[] { reporter }).build());
    runner.run(notifier);
    Set<String> metricNames = metrics.stream().map(Metric::getName).collect(toSet());
    assertThat(metricNames).contains("initialization");
}
Also used : MethodSorters(org.junit.runners.MethodSorters) Arrays(java.util.Arrays) Result(org.junit.runner.Result) SdkCollection(org.robolectric.plugins.SdkCollection) PerfStatsReporter(org.robolectric.pluginapi.perf.PerfStatsReporter) ShadowProvider(org.robolectric.internal.ShadowProvider) ShadowLooper.shadowMainLooper(org.robolectric.shadows.ShadowLooper.shadowMainLooper) Configuration(org.robolectric.pluginapi.config.ConfigurationStrategy.Configuration) Handler(android.os.Handler) Looper(android.os.Looper) After(org.junit.After) Assert.fail(org.junit.Assert.fail) Method(java.lang.reflect.Method) Path(java.nio.file.Path) Collectors.toSet(java.util.stream.Collectors.toSet) StubSdk(org.robolectric.plugins.StubSdk) RunListener(org.junit.runner.notification.RunListener) AndroidTestEnvironment(org.robolectric.android.internal.AndroidTestEnvironment) Sdk(org.robolectric.pluginapi.Sdk) Set(java.util.Set) Description(org.junit.runner.Description) RobolectricFrameworkMethod(org.robolectric.RobolectricTestRunner.RobolectricFrameworkMethod) StandardCharsets(java.nio.charset.StandardCharsets) Failure(org.junit.runner.notification.Failure) LazyLoad(org.robolectric.annotation.experimental.LazyApplication.LazyLoad) List(java.util.List) Application(android.app.Application) TestEnvironmentLifecyclePlugin(org.robolectric.pluginapi.TestEnvironmentLifecyclePlugin) FixMethodOrder(org.junit.FixMethodOrder) Implementation(org.robolectric.annotation.Config.Implementation) Mockito.mock(org.mockito.Mockito.mock) TestEnvironmentSpec(org.robolectric.internal.AndroidSandbox.TestEnvironmentSpec) RobolectricTestRunner.defaultInjector(org.robolectric.RobolectricTestRunner.defaultInjector) RunWith(org.junit.runner.RunWith) Config(org.robolectric.annotation.Config) HashMap(java.util.HashMap) FileSystemProvider(java.nio.file.spi.FileSystemProvider) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) JarEntry(java.util.jar.JarEntry) SuppressLint(android.annotation.SuppressLint) ResourcesMode(org.robolectric.internal.ResourcesMode) ResModeStrategy(org.robolectric.RobolectricTestRunner.ResModeStrategy) AndroidManifest(org.robolectric.manifest.AndroidManifest) Named(javax.inject.Named) Build(android.os.Build) DefaultSdkPicker(org.robolectric.plugins.DefaultSdkPicker) JarOutputStream(java.util.jar.JarOutputStream) Nonnull(javax.annotation.Nonnull) Before(org.junit.Before) AssumptionViolatedException(org.junit.AssumptionViolatedException) FrameworkMethod(org.junit.runners.model.FrameworkMethod) FileOutputStream(java.io.FileOutputStream) Test(org.junit.Test) JUnit4(org.junit.runners.JUnit4) Truth.assertThat(com.google.common.truth.Truth.assertThat) LazyApplication(org.robolectric.annotation.experimental.LazyApplication) SdkProvider(org.robolectric.pluginapi.SdkProvider) TempDirectory(org.robolectric.util.TempDirectory) TestUtil(org.robolectric.util.TestUtil) Metric(org.robolectric.pluginapi.perf.Metric) Ignore(org.junit.Ignore) Paths(java.nio.file.Paths) RunNotifier(org.junit.runner.notification.RunNotifier) PerfStatsReporter(org.robolectric.pluginapi.perf.PerfStatsReporter) ArrayList(java.util.ArrayList) Metric(org.robolectric.pluginapi.perf.Metric) Test(org.junit.Test)

Example 33 with Build

use of android.os.Build in project armadillo by patrickfav.

the class SecureSharedPreferencesTest method testSecurePreferenceNotMatching.

@Test
@UiThreadTest
public void testSecurePreferenceNotMatching() {
    ArmadilloSharedPreferences armadilloSharedPreferences = create("fingerprint", null).build();
    AtomicBoolean matched = new AtomicBoolean(false);
    armadilloSharedPreferences.registerOnSecurePreferenceChangeListener(((sharedPreferences, comparison) -> {
        if (comparison.isDerivedKeyEqualTo("key-of-interest")) {
            matched.set(true);
        }
    }));
    armadilloSharedPreferences.edit().putInt("another-key", 3).commit();
    assertFalse(matched.get());
}
Also used : Context(android.content.Context) RunWith(org.junit.runner.RunWith) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Test(org.junit.Test) AndroidJUnit4(androidx.test.ext.junit.runners.AndroidJUnit4) StandardCharsets(java.nio.charset.StandardCharsets) ApplicationProvider(androidx.test.core.app.ApplicationProvider) SecureRandom(java.security.SecureRandom) Bytes(at.favre.lib.bytes.Bytes) SharedPreferences(android.content.SharedPreferences) TestCase.assertTrue(junit.framework.TestCase.assertTrue) UiThreadTest(androidx.test.annotation.UiThreadTest) Settings(android.provider.Settings) Build(android.os.Build) TestCase.assertFalse(junit.framework.TestCase.assertFalse) TestCase.assertEquals(junit.framework.TestCase.assertEquals) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Test(org.junit.Test) UiThreadTest(androidx.test.annotation.UiThreadTest) UiThreadTest(androidx.test.annotation.UiThreadTest)

Example 34 with Build

use of android.os.Build in project armadillo by patrickfav.

the class SecureSharedPreferencesTest method testSecurePreferenceChangeNotification.

@Test
@UiThreadTest
public void testSecurePreferenceChangeNotification() {
    ArmadilloSharedPreferences armadilloSharedPreferences = create("fingerprint", null).build();
    AtomicBoolean matched = new AtomicBoolean(false);
    armadilloSharedPreferences.registerOnSecurePreferenceChangeListener(((sharedPreferences, comparison) -> {
        if (comparison.isDerivedKeyEqualTo("key-of-interest")) {
            matched.set(true);
        }
    }));
    armadilloSharedPreferences.edit().putInt("key-of-interest", 3).commit();
    assertTrue(matched.get());
}
Also used : Context(android.content.Context) RunWith(org.junit.runner.RunWith) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Test(org.junit.Test) AndroidJUnit4(androidx.test.ext.junit.runners.AndroidJUnit4) StandardCharsets(java.nio.charset.StandardCharsets) ApplicationProvider(androidx.test.core.app.ApplicationProvider) SecureRandom(java.security.SecureRandom) Bytes(at.favre.lib.bytes.Bytes) SharedPreferences(android.content.SharedPreferences) TestCase.assertTrue(junit.framework.TestCase.assertTrue) UiThreadTest(androidx.test.annotation.UiThreadTest) Settings(android.provider.Settings) Build(android.os.Build) TestCase.assertFalse(junit.framework.TestCase.assertFalse) TestCase.assertEquals(junit.framework.TestCase.assertEquals) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Test(org.junit.Test) UiThreadTest(androidx.test.annotation.UiThreadTest) UiThreadTest(androidx.test.annotation.UiThreadTest)

Example 35 with Build

use of android.os.Build in project incubator-weex by apache.

the class WXSoInstallMgrSdk method _cpuType.

private static String _cpuType() {
    String abi = _getFieldReflectively(new Build(), "CPU_ABI");
    if (abi == null || abi.length() == 0 || abi.equals("Unknown")) {
        abi = ARMEABI;
    }
    abi = abi.toLowerCase();
    return abi;
}
Also used : Build(android.os.Build)

Aggregations

Build (android.os.Build)42 Context (android.content.Context)30 Intent (android.content.Intent)22 List (java.util.List)22 PackageManager (android.content.pm.PackageManager)20 ArrayList (java.util.ArrayList)19 View (android.view.View)16 Toast (android.widget.Toast)15 File (java.io.File)15 Bundle (android.os.Bundle)14 Uri (android.net.Uri)13 TextView (android.widget.TextView)13 Locale (java.util.Locale)13 Manifest (android.Manifest)11 SharedPreferences (android.content.SharedPreferences)11 NonNull (android.support.annotation.NonNull)11 Activity (android.app.Activity)10 DialogInterface (android.content.DialogInterface)10 EditText (android.widget.EditText)10 Arrays (java.util.Arrays)10