Skip to content

Commit

Permalink
[Gradle Release Plugin] - pre tag commit: 'v0.6.0'.
Browse files Browse the repository at this point in the history
  • Loading branch information
tyvsmith committed Feb 15, 2017
1 parent 32b2d46 commit cd16143
Show file tree
Hide file tree
Showing 35 changed files with 209 additions and 343 deletions.
14 changes: 12 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
v0.5.5 - TBD
------------
v0.6.0 - 2/14/2017
-------------------
### Fixed
- [Issue #71](https://github.com/uber/rides-android-sdk/issues/71) LoginManager breaks when used with Rides SDK 0.6.0
- [Issue #65](https://github.com/uber/rides-android-sdk/issues/65) Empty AndroidHttpClient get compiled when using core-android 0.5.4 leading to unresolved references to actual methods of AndroidHttpClient

### Added
- Updated to match API 1.2 changes

### Breaking
- Removed Region (China) support

v0.5.4 - 9/29/2016
------------------
Expand All @@ -13,6 +22,7 @@ v0.5.4 - 9/29/2016
- [Issue #48](https://github.com/uber/rides-android-sdk/issues/48) Typo in Readme.md
- [Issue #54](https://github.com/uber/rides-android-sdk/issues/54) log4j lib still exists in 0.5.3 causing Proguard failing


v0.5.3 - 8/12/2016
------------------
### Fixed
Expand Down
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ To use the Uber Rides Android SDK, add the compile dependency with the latest ve
Add the Uber Rides Android SDK to your `build.gradle`:
```gradle
dependencies {
compile 'com.uber.sdk:rides-android:0.5.4'
compile 'com.uber.sdk:rides-android:0.6.0'
}
```

Expand All @@ -31,7 +31,7 @@ In the `pom.xml` file:
<dependency>
<groupId>com.uber.sdk</groupId>
<artifactId>rides-android</artifactId>
<version>0.5.4</version>
<version>0.6.0</version>
</dependency>
```

Expand Down Expand Up @@ -319,7 +319,7 @@ service.getUserProfile().enqueue(new Callback<UserProfile>() {

## Sample Apps

Sample apps can be found in the `samples` folder. Alternatively, you can also download a sample from the [releases page](https://github.com/uber/rides-android-sdk/releases/tag/v0.5.4).
Sample apps can be found in the `samples` folder. Alternatively, you can also download a sample from the [releases page](https://github.com/uber/rides-android-sdk/releases/tag/v0.6.0).

The Sample apps require configuration parameters to interact with the Uber API, these include the client id, redirect uri, and server token. They are provided on the [Uber developer dashboard](https://developer.uber.com/dashboard).

Expand Down Expand Up @@ -349,6 +349,4 @@ As the Uber Android SDK get closer to a 1.0 release, the API's will become more

We :heart: contributions. Found a bug or looking for a new feature? Open an issue and we'll respond as fast as we can. Or, better yet, implement it yourself and open a pull request! We ask that you include tests to show the bug was fixed or the feature works as expected.

**Note:** All contributors also need to fill out the [Uber Contributor License Agreement](http://t.uber.com/cla) before we can merge in any of your changes.

## MIT Licensed
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'net.researchgate:gradle-release:2.3.5'
classpath 'co.riiid:gradle-github-plugin:0.4.2'
classpath 'net.saliman:gradle-cobertura-plugin:2.3.1'
Expand Down
12 changes: 3 additions & 9 deletions core-android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ buildscript {
}

dependencies {
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
}
}

Expand Down Expand Up @@ -129,12 +129,6 @@ uploadArchives {
name 'Ty Smith'
email 'tys@uber.com'
}

developer {
id 'yhartanto'
name 'Yohan Hartanto'
email 'yohan@uber.com'
}
}
}
}
Expand All @@ -153,7 +147,7 @@ cobertura {
}

dependencies {
compile ('com.uber.sdk:rides:0.5.2') {
compile ('com.uber.sdk:rides:0.6.0') {
//Do not need Google OAuth based logic in Android
exclude group: 'org.slf4j', module: 'slf4j-log4j12'
exclude group: 'com.google.oauth-client', module: 'google-oauth-client'
Expand All @@ -171,7 +165,7 @@ dependencies {
testCompile 'com.google.http-client:google-http-client-jackson2:1.19.0'
testCompile 'org.mockito:mockito-core:1.10.19'
testCompile 'org.assertj:assertj-core:1.7.1'
testCompile 'org.robolectric:robolectric:3.0'
testCompile 'org.robolectric:robolectric:3.2.2'

//Needed for Cobertura checks because of above exclude
testCompile 'com.google.http-client:google-http-client-jackson2:1.19.0'
Expand Down
32 changes: 0 additions & 32 deletions core-android/src/main/java/android/net/http/AndroidHttpClient.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
*/
public enum AuthenticationError {

/**
* User cancelled flow
*/
CANCELLED,

/**
* There was a connectivity error while trying to load.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ String buildUrl(

Uri.Builder builder = new Uri.Builder();
builder.scheme(HTTPS)
.authority(ENDPOINT + "." + configuration.getEndpointRegion().domain)
.authority(ENDPOINT + "." + configuration.getEndpointRegion().getDomain())
.appendEncodedPath(PATH)
.appendQueryParameter(CLIENT_ID_PARAM, configuration.getClientId())
.appendQueryParameter(REDIRECT_PARAM, redirectUri)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public class LoginManager {

static final int REQUEST_CODE_LOGIN_DEFAULT = 1001;

private static final String USER_AGENT = "core-android-v0.5.4-login_manager";
private static final String USER_AGENT = "core-android-v0.6.0-login_manager";

private final AccessTokenManager accessTokenManager;
private final LoginCallback callback;
Expand Down Expand Up @@ -144,7 +144,6 @@ public void login(@NonNull Activity activity) {

SsoDeeplink ssoDeeplink = new SsoDeeplink.Builder(activity)
.clientId(sessionConfiguration.getClientId())
.region(sessionConfiguration.getEndpointRegion())
.scopes(sessionConfiguration.getScopes())
.customScopes(sessionConfiguration.getCustomScopes())
.activityRequestCode(requestCode)
Expand Down Expand Up @@ -304,7 +303,11 @@ private void handleResultCancelled(
final AuthenticationError authenticationError
= (error != null) ? AuthenticationError.fromString(error) : AuthenticationError.UNKNOWN;

if (authenticationError.equals(AuthenticationError.UNAVAILABLE) &&
if (authenticationError.equals(AuthenticationError.CANCELLED)) {
// User canceled login
callback.onLoginCancel();
return;
} else if (authenticationError.equals(AuthenticationError.UNAVAILABLE) &&
!AuthUtils.isPrivilegeScopeRequired(sessionConfiguration.getScopes())) {
loginForImplicitGrant(activity);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,12 @@
import com.uber.sdk.android.core.utils.AppProtocol;
import com.uber.sdk.android.core.utils.PackageManagers;
import com.uber.sdk.core.auth.Scope;
import com.uber.sdk.rides.client.SessionConfiguration;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;

import static com.uber.sdk.android.core.UberSdk.UBER_SDK_LOG_TAG;
import static com.uber.sdk.android.core.utils.AppProtocol.UBER_PACKAGE_NAME;
import static com.uber.sdk.android.core.utils.Preconditions.checkNotEmpty;
import static com.uber.sdk.android.core.utils.Preconditions.checkNotNull;
import static com.uber.sdk.android.core.utils.Preconditions.checkState;
Expand All @@ -56,11 +54,10 @@ public class SsoDeeplink implements Deeplink {
public static final int DEFAULT_REQUEST_CODE = LoginManager.REQUEST_CODE_LOGIN_DEFAULT;

@VisibleForTesting
static final int MIN_VERSION_SUPPORTED = 31256;
static final int MIN_VERSION_SUPPORTED = 31302;

private static final String URI_QUERY_CLIENT_ID = "client_id";
private static final String URI_QUERY_SCOPE = "scope";
private static final String URI_QUERY_LOGIN_TYPE = "login_type";
private static final String URI_QUERY_PLATFORM = "sdk";
private static final String URI_QUERY_SDK_VERSION = "sdk_version";
private static final String URI_HOST = "connect";
Expand All @@ -69,19 +66,16 @@ public class SsoDeeplink implements Deeplink {
private final String clientId;
private final Collection<Scope> requestedScopes;
private final Collection<String> requestedCustomScopes;
private final SessionConfiguration.EndpointRegion region;
private final int requestCode;

AppProtocol appProtocol;

SsoDeeplink(
@NonNull Activity activity,
@NonNull String clientId,
@NonNull SessionConfiguration.EndpointRegion region,
@NonNull Collection<Scope> requestedScopes,
@NonNull Collection<String> requestedCustomScopes,
int requestCode) {
this.region = region;
this.activity = activity;
this.clientId = clientId;
this.requestCode = requestCode;
Expand All @@ -101,10 +95,17 @@ public void execute() {
checkState(isSupported(), "Single sign on is not supported on the device. " +
"Please install or update to the latest version of Uber app.");

final Uri deepLinkUri = createSsoUri();

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setPackage(AppProtocol.UBER_PACKAGE_NAME);
final Uri deepLinkUri = createSsoUri();
intent.setData(deepLinkUri);

for (String installedPackage : AppProtocol.UBER_PACKAGE_NAMES) {
if (PackageManagers.isPackageAvailable(activity, installedPackage)) {
intent.setPackage(installedPackage);
break;
}
}
activity.startActivityForResult(intent, requestCode);
}

Expand All @@ -118,7 +119,6 @@ private Uri createSsoUri() {
.authority(URI_HOST)
.appendQueryParameter(URI_QUERY_CLIENT_ID, clientId)
.appendQueryParameter(URI_QUERY_SCOPE, scopes)
.appendQueryParameter(URI_QUERY_LOGIN_TYPE, region.name())
.appendQueryParameter(URI_QUERY_PLATFORM, AppProtocol.PLATFORM)
.appendQueryParameter(URI_QUERY_SDK_VERSION, BuildConfig.VERSION_NAME)
.build();
Expand All @@ -131,10 +131,18 @@ private Uri createSsoUri() {
*/
@Override
public boolean isSupported() {
final PackageInfo packageInfo = PackageManagers.getPackageInfo(activity, UBER_PACKAGE_NAME);

PackageInfo packageInfo = null;
for (String installedPackage : AppProtocol.UBER_PACKAGE_NAMES) {
if (PackageManagers.isPackageAvailable(activity, installedPackage)) {
packageInfo = PackageManagers.getPackageInfo(activity, installedPackage);
break;
}
}

return (packageInfo != null)
&& (packageInfo.versionCode >= MIN_VERSION_SUPPORTED) &&
appProtocol.validateSignature(activity, UBER_PACKAGE_NAME);
&& appProtocol.validateMinimumVersion(activity, packageInfo, MIN_VERSION_SUPPORTED)
&& appProtocol.validateSignature(activity, packageInfo.packageName);
}

public static class Builder {
Expand All @@ -144,7 +152,6 @@ public static class Builder {
private String clientId;
private Collection<Scope> requestedScopes;
private Collection<String> requestedCustomScopes;
private SessionConfiguration.EndpointRegion region;
private int requestCode = DEFAULT_REQUEST_CODE;

public Builder(@NonNull Activity activity) {
Expand All @@ -171,11 +178,6 @@ public Builder customScopes(@NonNull Collection<String> customScopes) {
return this;
}

public Builder region(@NonNull SessionConfiguration.EndpointRegion region) {
this.region = region;
return this;
}

public Builder activityRequestCode(int requestCode) {
this.requestCode = requestCode;
return this;
Expand All @@ -186,18 +188,14 @@ public SsoDeeplink build() {

checkNotEmpty(requestedScopes, "Scopes must be set.");

if (region == null) {
region = SessionConfiguration.EndpointRegion.WORLD;
}

if (requestedCustomScopes == null) {
requestedCustomScopes = new ArrayList<>();
}

if (requestCode == DEFAULT_REQUEST_CODE) {
Log.i(UBER_SDK_LOG_TAG, "Request code is not set, using default request code");
}
return new SsoDeeplink(activity, clientId, region, requestedScopes, requestedCustomScopes, requestCode);
return new SsoDeeplink(activity, clientId, requestedScopes, requestedCustomScopes, requestCode);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
import javax.annotation.Nullable;

public class AppProtocol {
public static final String UBER_PACKAGE_NAME = "com.ubercab";
public static final String[] UBER_PACKAGE_NAMES =
{"com.ubercab", "com.ubercab.presidio.app", "com.ubercab.presidio.exo"};
public static final String DEEPLINK_SCHEME = "uber";
public static final String PLATFORM = "android";

Expand All @@ -31,13 +32,24 @@ private static HashSet<String> buildAppSignatureHashes() {
set.add(UBER_RIDER_HASH);
return set;
}

/**
* Validates minimum version of app required or returns true if in debug.
*/
public boolean validateMinimumVersion(Context context, PackageInfo packageInfo, int minimumVersion) {
if (isDebug(context)) {
return true;
}

return packageInfo.versionCode >= minimumVersion;
}

/**
* Validates the app signature required or returns true if in debug.
*/
@SuppressLint("PackageManagerGetSignatures")
public boolean validateSignature(Context context, String packageName) {
String brand = Build.BRAND;
int applicationFlags = context.getApplicationInfo().flags;
if ((brand.startsWith("Android") || brand.startsWith("generic")) &&
(applicationFlags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) {
// We are debugging on an emulator, don't validate package signature.
if (isDebug(context)) {
return true;
}

Expand Down Expand Up @@ -96,4 +108,15 @@ public String getAppSignature(@NonNull Context context) {
MessageDigest getSha1MessageDigest() throws NoSuchAlgorithmException {
return MessageDigest.getInstance(HASH_ALGORITHM_SHA1);
}

private boolean isDebug(Context context) {
String brand = Build.BRAND;
int applicationFlags = context.getApplicationInfo().flags;
if ((brand.startsWith("Android") || brand.startsWith("generic")) &&
(applicationFlags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) {
// We are debugging on an emulator, don't validate package signature.
return true;
}
return false;
}
}
Loading

0 comments on commit cd16143

Please sign in to comment.