VCamera v2.0.3版本的 MD5 值为:0c69d90ea31aeb3cb9d1431fccc77864
以下内容为反编译后的 CloudmadeUtil.java 源代码,内容仅作参考
package org.osmdroid.tileprovider.util;
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.provider.Settings;
import android.util.Log;
import androidx.browser.trusted.sharing.ShareTarget;
import com.google.android.exoplayer2.C;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Map;
import org.osmdroid.api.IMapView;
import org.osmdroid.config.Configuration;
public class CloudmadeUtil {
private static final String CLOUDMADE_ID = "CLOUDMADE_ID";
private static final String CLOUDMADE_KEY = "CLOUDMADE_KEY";
private static final String CLOUDMADE_TOKEN = "CLOUDMADE_TOKEN";
public static boolean DEBUGMODE = false;
private static String mAndroidId = "android_id";
private static String mKey = "";
private static SharedPreferences.Editor mPreferenceEditor = null;
private static String mToken = "";
public static String getCloudmadeKey() {
return mKey;
}
public static String getCloudmadeToken() {
BufferedReader bufferedReader;
Throwable th;
BufferedReader bufferedReader2;
IOException iOException;
if (mToken.length() == 0) {
synchronized (mToken) {
if (mToken.length() == 0) {
HttpURLConnection httpURLConnection = null;
BufferedReader bufferedReader3 = null;
httpURLConnection = null;
try {
HttpURLConnection httpURLConnection2 = (HttpURLConnection) new URL("https://auth.cloudmade.com/token/" + mKey + "?userid=" + mAndroidId).openConnection();
try {
httpURLConnection2.setDoOutput(true);
httpURLConnection2.setRequestMethod(ShareTarget.METHOD_POST);
httpURLConnection2.setRequestProperty("Content-Type", ShareTarget.ENCODING_TYPE_URL_ENCODED);
httpURLConnection2.setRequestProperty(Configuration.getInstance().getUserAgentHttpHeader(), Configuration.getInstance().getUserAgentValue());
for (Map.Entry<String, String> entry : Configuration.getInstance().getAdditionalHttpRequestProperties().entrySet()) {
httpURLConnection2.setRequestProperty(entry.getKey(), entry.getValue());
}
httpURLConnection2.connect();
if (DEBUGMODE) {
Log.d(IMapView.LOGTAG, "Response from Cloudmade auth: " + httpURLConnection2.getResponseMessage());
}
if (httpURLConnection2.getResponseCode() == 200) {
bufferedReader2 = new InputStreamReader(httpURLConnection2.getInputStream(), C.UTF8_NAME);
try {
bufferedReader = new BufferedReader(bufferedReader2, 8192);
try {
String readLine = bufferedReader.readLine();
if (DEBUGMODE) {
Log.d(IMapView.LOGTAG, "First line from Cloudmade auth: " + readLine);
}
String trim = readLine.trim();
mToken = trim;
if (trim.length() > 0) {
mPreferenceEditor.putString(CLOUDMADE_TOKEN, mToken);
mPreferenceEditor.commit();
mPreferenceEditor = null;
} else {
Log.e(IMapView.LOGTAG, "No authorization token received from Cloudmade");
}
bufferedReader3 = bufferedReader;
bufferedReader2 = bufferedReader2;
} catch (IOException e) {
httpURLConnection = httpURLConnection2;
iOException = e;
bufferedReader2 = bufferedReader2;
try {
Log.e(IMapView.LOGTAG, "No authorization token received from Cloudmade: " + iOException);
if (httpURLConnection != null) {
}
if (bufferedReader != null) {
}
} catch (Throwable th2) {
th = th2;
if (httpURLConnection != null) {
try {
httpURLConnection.disconnect();
} catch (Exception unused) {
}
}
if (bufferedReader != null) {
try {
bufferedReader.close();
} catch (Exception unused2) {
}
}
if (bufferedReader2 != 0) {
try {
bufferedReader2.close();
} catch (Exception unused3) {
}
}
throw th;
}
} catch (Throwable th3) {
httpURLConnection = httpURLConnection2;
th = th3;
if (httpURLConnection != null) {
}
if (bufferedReader != null) {
}
if (bufferedReader2 != 0) {
}
throw th;
}
} catch (IOException e2) {
httpURLConnection = httpURLConnection2;
iOException = e2;
bufferedReader = null;
bufferedReader2 = bufferedReader2;
} catch (Throwable th4) {
httpURLConnection = httpURLConnection2;
th = th4;
bufferedReader = null;
}
} else {
bufferedReader2 = 0;
}
try {
httpURLConnection2.disconnect();
} catch (Exception unused4) {
}
if (bufferedReader3 != null) {
try {
bufferedReader3.close();
} catch (Exception unused5) {
}
}
} catch (IOException e3) {
e = e3;
bufferedReader = null;
httpURLConnection = httpURLConnection2;
iOException = e;
bufferedReader2 = bufferedReader;
Log.e(IMapView.LOGTAG, "No authorization token received from Cloudmade: " + iOException);
if (httpURLConnection != null) {
try {
httpURLConnection.disconnect();
} catch (Exception unused6) {
}
}
if (bufferedReader != null) {
try {
bufferedReader.close();
} catch (Exception unused7) {
}
}
} catch (Throwable th5) {
th = th5;
bufferedReader = null;
httpURLConnection = httpURLConnection2;
th = th;
bufferedReader2 = bufferedReader;
if (httpURLConnection != null) {
}
if (bufferedReader != null) {
}
if (bufferedReader2 != 0) {
}
throw th;
}
} catch (IOException e4) {
e = e4;
bufferedReader = null;
} catch (Throwable th6) {
th = th6;
bufferedReader = null;
}
}
}
}
return mToken;
}
public static void retrieveCloudmadeKey(Context context) {
mAndroidId = Settings.Secure.getString(context.getContentResolver(), "android_id");
mKey = ManifestUtil.retrieveKey(context, CLOUDMADE_KEY);
SharedPreferences defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
mPreferenceEditor = defaultSharedPreferences.edit();
if (!defaultSharedPreferences.getString(CLOUDMADE_ID, "").equals(mAndroidId)) {
mPreferenceEditor.putString(CLOUDMADE_ID, mAndroidId);
mPreferenceEditor.commit();
return;
}
String string = defaultSharedPreferences.getString(CLOUDMADE_TOKEN, "");
mToken = string;
if (string.length() > 0) {
mPreferenceEditor = null;
}
}
public static void setCloudmadeKey(String str) {
mKey = str;
}
}