io.grpc.internal.DnsNameResolverProvider#com.google.android.gms.common.GooglePlayServicesRepairableException源码实例Demo

下面列出了io.grpc.internal.DnsNameResolverProvider#com.google.android.gms.common.GooglePlayServicesRepairableException 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: aptoide-client   文件: AptoideUtils.java
public static String parseString(Context context, String clickUrl) throws IOException, GooglePlayServicesNotAvailableException, GooglePlayServicesRepairableException {

            String deviceId = android.provider.Settings.Secure.getString(Aptoide.getContext().getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
            String myid = PreferenceManager.getDefaultSharedPreferences(context).getString(EnumPreferences.APTOIDE_CLIENT_UUID.name(), "NoInfo");

            if (deviceId != null) {
                clickUrl = clickUrl.replace("[USER_ANDROID_ID]", deviceId);
            }

            if (myid != null) {
                clickUrl = clickUrl.replace("[USER_UDID]", myid);
            }

            clickUrl = replaceAdvertisementId(clickUrl, context);
            clickUrl = clickUrl.replace("[TIME_STAMP]", String.valueOf(new Date().getTime()));

            return clickUrl;
        }
 
源代码2 项目: cronet-sample   文件: WelcomeActivity.java
public void openImages(View view) {
    Task<Void> installTask = CronetProviderInstaller.installProvider(this);
    installTask.addOnCompleteListener(
        task -> {
            if (task.isSuccessful()) {
                Intent mpdIntent = new Intent(this, MainActivity.class);
                startActivity(mpdIntent);
            } else if (task.getException() != null) {
                Exception cause = task.getException();
                if (cause instanceof GooglePlayServicesNotAvailableException) {
                    Toast.makeText(this, "Google Play services not available.",
                            Toast.LENGTH_SHORT).show();
                } else if (cause instanceof GooglePlayServicesRepairableException) {
                    Toast.makeText(this, "Google Play services update is required.",
                            Toast.LENGTH_SHORT).show();
                    startActivity(((GooglePlayServicesRepairableException) cause).getIntent());
                } else {
                    Toast.makeText(this, "Unexpected error: " + cause,
                            Toast.LENGTH_SHORT).show();
                }
            } else {
                Toast.makeText(this, "Unable to load Google Play services.",
                        Toast.LENGTH_SHORT).show();
            }
        });
}
 
源代码3 项目: firebase-android-sdk   文件: GrpcCallProvider.java
/** 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();
}
 
源代码4 项目: firebase-android-sdk   文件: ProviderInstaller.java
public void install() {
  try {
    com.google.android.gms.security.ProviderInstaller.installIfNeeded(application);
  } catch (GooglePlayServicesNotAvailableException | GooglePlayServicesRepairableException e) {
    e.printStackTrace();
  }
}
 
源代码5 项目: NaviBee   文件: EventEditActivity.java
public void showPlacePicker(View view) {
    locationLayout.setError(null);
    try {
        PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder();
        startActivityForResult(builder.build(this), PLACE_PICKER_REQUEST);
    } catch ( GooglePlayServicesNotAvailableException |
              GooglePlayServicesRepairableException ignored) {
    }
}
 
@Override
protected Void doInBackground(Void... params) {
    try {
        info = AdvertisingIdClient.getAdvertisingIdInfo(context);
    } catch (IOException
            | GooglePlayServicesNotAvailableException
            | GooglePlayServicesRepairableException e) {
        Log.e(TAG, e.getMessage() != null ? e.getMessage() : "Failed to get ad id.");
    }

    return null;
}
 
源代码7 项目: aptoide-client   文件: AptoideUtils.java
private static String replaceAdvertisementId(String clickUrl, Context context) throws IOException, GooglePlayServicesNotAvailableException, GooglePlayServicesRepairableException {

            String aaId = "";
            if (GoogleServices.checkGooglePlayServices(context)) {
                if (AptoideUtils.getSharedPreferences().contains("advertisingIdClient")) {
                    aaId = AptoideUtils.getSharedPreferences().getString("advertisingIdClient", "");
                } else {
                    try {
                        aaId = AdvertisingIdClient.getAdvertisingIdInfo(context).getId();
                    } catch (Exception e) {
                        // In case we try to do this from a Broadcast Receiver, exception will be thrown.
                        Logger.w("AptoideUtils", e.getMessage());
                    }
                }
            } else {
                byte[] data = new byte[16];
                String deviceId = android.provider.Settings.Secure.getString(context.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
                SecureRandom secureRandom = new SecureRandom();
                secureRandom.setSeed(deviceId.hashCode());
                secureRandom.nextBytes(data);
                aaId = UUID.nameUUIDFromBytes(data).toString();
            }

            clickUrl = clickUrl.replace("[USER_AAID]", aaId);

            return clickUrl;
        }
 
源代码8 项目: aptoide-client   文件: UpdatesService.java
private String getAdvertisementId() {
    try {
        return AdvertisingIdClient.getAdvertisingIdInfo(Aptoide.getContext()).getId();
    } catch (IOException | GooglePlayServicesNotAvailableException | GooglePlayServicesRepairableException e) {
        Logger.printException(e);
    }
    return null;
}
 
@Override
protected View onCreateView(ViewGroup parent) {
    View view = super.onCreateView(parent);
    View currentLocation = view.findViewById(R.id.current_location);
    currentLocation.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Context context = getContext();

            // Launch the Place Picker so that the user can specify their location, and then
            // return the result to SettingsActivity.
            PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder();


            // We are in a view right now, not an activity. So we need to get ourselves
            // an activity that we can use to start our Place Picker intent. By using
            // SettingsActivity in this way, we can ensure the result of the Place Picker
            // intent comes to the right place for us to process it.
            Activity settingsActivity = (SettingsActivity) context;
            try {
                settingsActivity.startActivityForResult(
                        builder.build(context), SettingsActivity.PLACE_PICKER_REQUEST);

            } catch (GooglePlayServicesNotAvailableException
                    | GooglePlayServicesRepairableException e) {
                // What did you do?? This is why we check Google Play services in onResume!!!
                // The difference in these exception types is the difference between pausing
                // for a moment to prompt the user to update/install/enable Play services vs
                // complete and utter failure.
                // If you prefer to manage Google Play services dynamically, then you can do so
                // by responding to these exceptions in the right moment. But I prefer a cleaner
                // user experience, which is why you check all of this when the app resumes,
                // and then disable/enable features based on that availability.
            }
        }
    });

    return view;
}
 
源代码10 项目: APDE   文件: APDE.java
/**
 * 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");
	}
}
 
源代码11 项目: KernelAdiutor   文件: MainActivity.java
/**
 * 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());
}