com.google.android.gms.security.ProviderInstaller Java Examples
The following examples show how to use
com.google.android.gms.security.ProviderInstaller.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AccountManagerFactory.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
public static @NonNull SignalServiceAccountManager createAuthenticated(@NonNull Context context, @NonNull UUID uuid, @NonNull String number, @NonNull String password) { if (new SignalServiceNetworkAccess(context).isCensored(number)) { SignalExecutors.BOUNDED.execute(() -> { try { ProviderInstaller.installIfNeeded(context); } catch (Throwable t) { Log.w(TAG, t); } }); } return new SignalServiceAccountManager(new SignalServiceNetworkAccess(context).getConfiguration(number), uuid, number, password, BuildConfig.SIGNAL_AGENT); }
Example #2
Source File: AccountManagerFactory.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
/** * Should only be used during registration when you haven't yet been assigned a UUID. */ public static @NonNull SignalServiceAccountManager createUnauthenticated(@NonNull Context context, @NonNull String number, @NonNull String password) { if (new SignalServiceNetworkAccess(context).isCensored(number)) { SignalExecutors.BOUNDED.execute(() -> { try { ProviderInstaller.installIfNeeded(context); } catch (Throwable t) { Log.w(TAG, t); } }); } return new SignalServiceAccountManager(new SignalServiceNetworkAccess(context).getConfiguration(number), null, number, password, BuildConfig.SIGNAL_AGENT); }
Example #3
Source File: ApplicationContext.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
@SuppressLint("StaticFieldLeak") private void initializeCircumvention() { AsyncTask<Void, Void, Void> task = new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... params) { if (new SignalServiceNetworkAccess(ApplicationContext.this).isCensored(ApplicationContext.this)) { try { ProviderInstaller.installIfNeeded(ApplicationContext.this); } catch (Throwable t) { Log.w(TAG, t); } } return null; } }; task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }
Example #4
Source File: TesterActivity.java From grpc-nebula-java with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_tester); buttons = new LinkedList<>(); buttons.add((Button) findViewById(R.id.empty_unary_button)); buttons.add((Button) findViewById(R.id.large_unary_button)); buttons.add((Button) findViewById(R.id.client_streaming_button)); buttons.add((Button) findViewById(R.id.server_streaming_button)); buttons.add((Button) findViewById(R.id.ping_pong_button)); hostEdit = (EditText) findViewById(R.id.host_edit_text); portEdit = (EditText) findViewById(R.id.port_edit_text); resultText = (TextView) findViewById(R.id.grpc_response_text); getCheckBox = (CheckBox) findViewById(R.id.get_checkbox); testCertCheckBox = (CheckBox) findViewById(R.id.test_cert_checkbox); ProviderInstaller.installIfNeededAsync(this, this); // Disable buttons until the security provider installing finishes. enableButtons(false); }
Example #5
Source File: MainActivity.java From developerWorks with Apache License 2.0 | 6 votes |
/** * Returns the SSLSocketFactory to use to connect to the MQTT server over ssl:// * @param context The ApplicationContext to use * @return SSLSocketFactory */ private SSLSocketFactory getSSLSocketFactory(Context context) { SSLSocketFactory factory = null; try { ProviderInstaller.installIfNeeded(context); SSLContext sslContext; KeyStore ks = KeyStore.getInstance("bks"); ks.load(context.getResources().openRawResource(R.raw.iot), "password".toCharArray()); TrustManagerFactory tmf = TrustManagerFactory.getInstance("X509"); tmf.init(ks); TrustManager[] tm = tmf.getTrustManagers(); sslContext = SSLContext.getInstance("TLSv1.2"); sslContext.init(null, tm, null); factory = sslContext.getSocketFactory(); } catch (Exception e) { String notificationMessage = "Exception thrown trying to get SSLSocketFactory: "; Log.e(TAG, notificationMessage, e); // Store this in the Notification deque pushNotification(notificationMessage); } return factory; }
Example #6
Source File: TesterActivity.java From grpc-java with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_tester); buttons = new ArrayList<>(); buttons.add((Button) findViewById(R.id.empty_unary_button)); buttons.add((Button) findViewById(R.id.large_unary_button)); buttons.add((Button) findViewById(R.id.client_streaming_button)); buttons.add((Button) findViewById(R.id.server_streaming_button)); buttons.add((Button) findViewById(R.id.ping_pong_button)); hostEdit = (EditText) findViewById(R.id.host_edit_text); portEdit = (EditText) findViewById(R.id.port_edit_text); resultText = (TextView) findViewById(R.id.grpc_response_text); testCertCheckBox = (CheckBox) findViewById(R.id.test_cert_checkbox); ProviderInstaller.installIfNeededAsync(this, this); // Disable buttons until the security provider installing finishes. enableButtons(false); }
Example #7
Source File: GrpcCallProvider.java From firebase-android-sdk with Apache License 2.0 | 5 votes |
/** Sets up the SSL provider and configures the gRPC channel. */ private ManagedChannel initChannel(Context context, DatabaseInfo databaseInfo) { try { // We need to upgrade the Security Provider before any network channels are initialized. // `OkHttp` maintains a list of supported providers that is initialized when the JVM first // resolves the static dependencies of ManagedChannel. ProviderInstaller.installIfNeeded(context); } catch (GooglePlayServicesNotAvailableException /* Thrown by ProviderInstaller */ | GooglePlayServicesRepairableException /* Thrown by ProviderInstaller */ | IllegalStateException e /* Thrown by Robolectric */) { // Mark the SSL initialization as done, even though we may be using outdated SSL // ciphers. gRPC-Java recommends obtaining updated ciphers from GMSCore, but we allow // the device to fall back to other SSL ciphers if GMSCore is not available. Logger.warn(LOG_TAG, "Failed to update ssl context: %s", e); } ManagedChannelBuilder<?> channelBuilder; if (overrideChannelBuilderSupplier != null) { channelBuilder = overrideChannelBuilderSupplier.get(); } else { channelBuilder = ManagedChannelBuilder.forTarget(databaseInfo.getHost()); if (!databaseInfo.isSslEnabled()) { // Note that the boolean flag does *NOT* switch the wire format from Protobuf to Plaintext. // It merely turns off SSL encryption. channelBuilder.usePlaintext(); } } // Ensure gRPC recovers from a dead connection. (Not typically necessary, as the OS will // usually notify gRPC when a connection dies. But not always. This acts as a failsafe.) channelBuilder.keepAliveTime(30, TimeUnit.SECONDS); // Wrap the ManagedChannelBuilder in an AndroidChannelBuilder. This allows the channel to // respond more gracefully to network change events (such as switching from cell to wifi). AndroidChannelBuilder androidChannelBuilder = AndroidChannelBuilder.usingBuilder(channelBuilder).context(context); return androidChannelBuilder.build(); }
Example #8
Source File: FirebaseFunctions.java From firebase-android-sdk with Apache License 2.0 | 5 votes |
/** * Runs ProviderInstaller.installIfNeededAsync once per application instance. * * @param context The application context. */ private static void maybeInstallProviders(Context context) { // Make sure this only runs once. synchronized (providerInstalled) { if (providerInstallStarted) { return; } providerInstallStarted = true; } // Package installIfNeededAsync into a Runnable so it can be run on the main thread. // installIfNeededAsync checks to make sure it is on the main thread, and throws otherwise. Runnable runnable = () -> ProviderInstaller.installIfNeededAsync( context, new ProviderInstallListener() { @Override public void onProviderInstalled() { providerInstalled.setResult(null); } @Override public void onProviderInstallFailed(int i, android.content.Intent intent) { Log.d("FirebaseFunctions", "Failed to update ssl context"); providerInstalled.setResult(null); } }); Handler handler = new Handler(context.getMainLooper()); handler.post(runnable); }
Example #9
Source File: APDE.java From APDE with GNU General Public License v2.0 | 5 votes |
/** * Disable SSL3 to force TLS. Fix for Android 4.4 and below. * * https://stackoverflow.com/questions/29916962/javax-net-ssl-sslhandshakeexception-javax-net-ssl-sslprotocolexception-ssl-han */ public void disableSsl3() { try { ProviderInstaller.installIfNeeded(this); } catch (GooglePlayServicesNotAvailableException | GooglePlayServicesRepairableException e) { // Too bad System.err.println("Failed to disable SSL3"); } }
Example #10
Source File: MotionRecognition.java From Saiy-PS with GNU Affero General Public License v3.0 | 4 votes |
/** * Prepare the Activity Recognition API for use. * * @param ctx the application context */ public void prepare(@NonNull final Context ctx) { final GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance(); final int connectionResult = apiAvailability.isGooglePlayServicesAvailable(ctx); switch (connectionResult) { case ConnectionResult.SUCCESS: activityClient = new GoogleApiClient.Builder(ctx).addConnectionCallbacks(this) .addOnConnectionFailedListener(this).addApi(ActivityRecognition.API).build(); pendingIntent = PendingIntent.getService(ctx, MotionIntentService.REQUEST_CODE, new Intent(ctx, MotionIntentService.class), PendingIntent.FLAG_UPDATE_CURRENT); try { ProviderInstaller.installIfNeededAsync(ctx, new ProviderInstaller.ProviderInstallListener() { @Override public void onProviderInstalled() { if (DEBUG) { MyLog.i(CLS_NAME, "prepare: play services onProviderInstalled"); } } @Override public void onProviderInstallFailed(final int errorCode, final Intent intent) { if (DEBUG) { MyLog.w(CLS_NAME, "prepare: play services onProviderInstallFailed"); } if (apiAvailability.isUserResolvableError(errorCode)) { if (DEBUG) { MyLog.w(CLS_NAME, "prepare: play services onProviderInstallFailed"); } apiAvailability.showErrorNotification(ctx, errorCode); } else { // TODO - unrecoverable } } }); } catch (final Exception e) { if (DEBUG) { MyLog.w(CLS_NAME, "prepare: play services unavailable"); e.printStackTrace(); } } break; default: if (DEBUG) { MyLog.w(CLS_NAME, "prepare: play services unavailable"); } apiAvailability.showErrorNotification(ctx, connectionResult); break; } }
Example #11
Source File: HentoidApp.java From Hentoid with Apache License 2.0 | 4 votes |
@Override public void onCreate() { super.onCreate(); instance = this; Fabric.with(this, new Crashlytics()); // Fix the SSLHandshake error with okhttp on Android 4.1-4.4 when server only supports TLS1.2 // see https://github.com/square/okhttp/issues/2372 for more information try { ProviderInstaller.installIfNeeded(getApplicationContext()); } catch (Exception e) { Timber.e(e, "Google Play ProviderInstaller exception"); } // Init datetime AndroidThreeTen.init(this); // Timber if (BuildConfig.DEBUG) Timber.plant(new Timber.DebugTree()); Timber.plant(new CrashlyticsTree()); // Prefs Preferences.init(this); Preferences.performHousekeeping(); // Image viewer // Needs ARGB_8888 to be able to resize images using RenderScript // (defaults to Bitmap.Config.RGB_565 if not set) CustomSubsamplingScaleImageView.setPreferredBitmapConfig(Bitmap.Config.ARGB_8888); // Init version number on first run if (0 == Preferences.getLastKnownAppVersionCode()) Preferences.setLastKnownAppVersionCode(BuildConfig.VERSION_CODE); // Firebase boolean isAnalyticsEnabled = Preferences.isAnalyticsEnabled(); FirebaseAnalytics.getInstance(this).setAnalyticsCollectionEnabled(isAnalyticsEnabled); // DB housekeeping performDatabaseHousekeeping(); // Init notification channels UpdateNotificationChannel.init(this); DownloadNotificationChannel.init(this); MaintenanceNotificationChannel.init(this); // Clears all previous notifications NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); if (manager != null) manager.cancelAll(); // Run app update checks if (Preferences.isAutomaticUpdateEnabled()) { Intent intent = UpdateCheckService.makeIntent(this, false); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { startForegroundService(intent); } else { startService(intent); } } // Build Android shortcuts if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) { ShortcutHelper.buildShortcuts(this); } // Send stats to Firebase FirebaseAnalytics.getInstance(this).setUserProperty("color_theme", Integer.toString(Preferences.getColorTheme())); FirebaseAnalytics.getInstance(this).setUserProperty("endless", Boolean.toString(Preferences.getEndlessScroll())); // Plug the lifecycle listener to handle locking ProcessLifecycleOwner.get().getLifecycle().addObserver(new LifeCycleListener()); // Set RxJava's default error handler for unprocessed network and IO errors RxJavaPlugins.setErrorHandler(e -> { if (e instanceof UndeliverableException) { e = e.getCause(); } if (e instanceof IOException) { // fine, irrelevant network problem or API that throws on cancellation return; } if (e instanceof InterruptedException) { // fine, some blocking code was interrupted by a dispose call return; } Timber.w(e, "Undeliverable exception received, not sure what to do"); }); }
Example #12
Source File: GoogleCompat.java From Popeens-DSub with GNU General Public License v3.0 | 4 votes |
public static void installProvider(Context context) throws Exception{ ProviderInstaller.installIfNeeded(context); }
Example #13
Source File: MainActivity.java From KernelAdiutor with GNU General Public License v3.0 | 4 votes |
/** * Determinate what sections are supported */ private void collectData() { MainActivity activity = mRefActivity.get(); if (activity == null) return; Battery.getInstance(activity); CPUBoost.getInstance(); // Assign core ctl min cpu CPUFreq.getInstance(activity); Device.CPUInfo.getInstance(); Device.Input.getInstance(); Device.MemInfo.getInstance(); Device.ROMInfo.getInstance(); Device.TrustZone.getInstance(); GPU.supported(); Hotplug.supported(); IO.getInstance(); KSM.getInstance(); MSMPerformance.getInstance(); QcomBcl.supported(); Screen.supported(); Sound.getInstance(); Temperature.getInstance(activity); Thermal.supported(); Tile.publishProfileTile(new Profiles(activity).getAllProfiles(), activity); Vibration.getInstance(); Voltage.getInstance(); Wake.supported(); try { ProviderInstaller.installIfNeeded(activity); } catch (GooglePlayServicesNotAvailableException | GooglePlayServicesRepairableException e) { e.printStackTrace(); } if (!BuildConfig.DEBUG) { // Send SoC type to analytics to collect stats Answers.getInstance().logCustom(new CustomEvent("SoC") .putCustomAttribute("type", Device.getBoard())); } Log.crashlyticsI(TAG, "Build Display ID: " + Device.getBuildDisplayId()); Log.crashlyticsI(TAG, "ROM: " + Device.ROMInfo.getInstance().getVersion()); Log.crashlyticsI(TAG, "Kernel version: " + Device.getKernelVersion(true)); Log.crashlyticsI(TAG, "Board: " + Device.getBoard()); }