forked from choppa1890/alexa-avs-raspberry-pi
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 16d0b2c
Showing
292 changed files
with
15,822 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#Alexa Voice Service Raspberry Pi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
07/31/2015 - Initial Release. Includes Java reference implementation of device code, and a Node.js reference companion service for authenticating and provisioning the device code. | ||
10/02/2015 - Fixed a bug related to the enabling of TuneIn. Users can now listen to TuneIn radio streams from the reference implementation of device code. | ||
10/15/2015 - Added reference implementations for mobile app authentication and provisioning for iOS and Android phones. Also adds support for play/pause/previous/next buttons in the reference implementation of device code. | ||
03/22/2016 - Updated the reference client to use the new v20160207 APIs over HTTP2. Adds support for timers, alarms, button events, and control via the companion app. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Please run the setup at libraries/java/README.txt before continuing. | ||
|
||
To build the Android sample you need to import into Android Studio, or run "sh gradlew build". | ||
|
||
To import into Android Studio: | ||
1. From the "Welcome to Android Studio" window select "Open an existing Android Studio project" | ||
2. Navigation to and select $PACKAGE_ROOT/samples/android/ | ||
3. Once loaded hit the green "Play" button |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
dependencies { | ||
compile fileTree(dir: 'libs', include: ['*.jar']) | ||
compile 'com.android.support:appcompat-v7:22.2.0' | ||
compile 'commons-io:commons-io:2.4' | ||
compile 'org.apache.commons:commons-lang3:3.4' | ||
} | ||
|
||
String apiKeyLocation = "./src/main/assets/api_key.txt" | ||
String caCertLocation = "./src/main/res/raw/ca.crt" | ||
|
||
task checkForRequiredFiles << { | ||
if (!file(apiKeyLocation).exists()) { | ||
throw new FileNotFoundException("The API Key file does not exist. Please make sure " + apiKeyLocation + " has been created and populated with the proper values from the Security Profile you created.") | ||
} | ||
|
||
if (!file(caCertLocation).exists()) { | ||
throw new FileNotFoundException("The Certificate Authority public certificate file does not exist. Please make sure " + caCertLocation + " exists and contains the public certificate created during setup.") | ||
} | ||
} | ||
preBuild.dependsOn checkForRequiredFiles | ||
|
||
android { | ||
compileSdkVersion 22 | ||
buildToolsVersion "22.0.1" | ||
|
||
defaultConfig { | ||
applicationId "com.amazon.alexa.avs.companion" | ||
minSdkVersion 8 | ||
targetSdkVersion 22 | ||
versionCode 1 | ||
versionName "1.0" | ||
} | ||
|
||
// Sign both debug and release with a single key so that LWA always works | ||
// In practice you would have separate keys for debug and release | ||
signingConfigs { | ||
lwa { | ||
storeFile file('keystore.jks') | ||
keyAlias 'androiddebugkey' | ||
keyPassword 'android' | ||
storePassword 'android' | ||
} | ||
} | ||
|
||
packagingOptions { | ||
exclude 'META-INF/LICENSE.txt' | ||
exclude 'META-INF/NOTICE.txt' | ||
} | ||
|
||
lintOptions { | ||
abortOnError false | ||
disable 'IconMissingDensityFolder' | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
signingConfig signingConfigs.lwa | ||
} | ||
|
||
debug { | ||
signingConfig signingConfigs.lwa | ||
} | ||
} | ||
} |
Empty file.
Binary file not shown.
40 changes: 40 additions & 0 deletions
40
samples/androidCompanionApp/app/src/main/AndroidManifest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
package="com.amazon.alexa.avs.companion"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:theme="@style/AppTheme" | ||
tools:replace="android:label"> | ||
<activity | ||
android:name=".LoginWithAmazonActivity" | ||
android:label="@string/app_name" | ||
android:configChanges="keyboard|keyboardHidden|orientation"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
|
||
<activity | ||
android:name="com.amazon.identity.auth.device.authorization.AuthorizationActivity" | ||
android:theme="@android:style/Theme.NoDisplay" | ||
android:allowTaskReparenting="true" | ||
android:launchMode="singleTask"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.VIEW" /> | ||
|
||
<category android:name="android.intent.category.DEFAULT" /> | ||
<category android:name="android.intent.category.BROWSABLE" /> | ||
<data android:host="${applicationId}" android:scheme="amzn" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
22 changes: 22 additions & 0 deletions
22
...s/androidCompanionApp/app/src/main/java/com/amazon/alexa/avs/companion/AuthConstants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* You may not use this file except in compliance with the License. A copy of the License is located the "LICENSE.txt" | ||
* file accompanying this source. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package com.amazon.alexa.avs.companion; | ||
|
||
public class AuthConstants { | ||
public static final String SESSION_ID = "sessionId"; | ||
|
||
public static final String CLIENT_ID = "clientId"; | ||
public static final String REDIRECT_URI = "redirectUri"; | ||
public static final String AUTH_CODE = "authCode"; | ||
|
||
public static final String CODE_CHALLENGE = "codeChallenge"; | ||
public static final String CODE_CHALLENGE_METHOD = "codeChallengeMethod"; | ||
public static final String DSN = "dsn"; | ||
public static final String PRODUCT_ID = "productId"; | ||
} |
55 changes: 55 additions & 0 deletions
55
...panionApp/app/src/main/java/com/amazon/alexa/avs/companion/CompanionProvisioningInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/** | ||
* Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* You may not use this file except in compliance with the License. A copy of the License is located the "LICENSE.txt" | ||
* file accompanying this source. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package com.amazon.alexa.avs.companion; | ||
|
||
import org.json.JSONException; | ||
import org.json.JSONObject; | ||
|
||
public class CompanionProvisioningInfo { | ||
private final String sessionId; | ||
private final String clientId; | ||
private final String redirectUri; | ||
private final String authCode; | ||
|
||
public CompanionProvisioningInfo(String sessionId, String clientId, String redirectUri, String authCode) { | ||
this.sessionId = sessionId; | ||
this.clientId = clientId; | ||
this.redirectUri = redirectUri; | ||
this.authCode = authCode; | ||
} | ||
|
||
public String getSessionId() { | ||
return sessionId; | ||
} | ||
|
||
public String getClientId() { | ||
return clientId; | ||
} | ||
|
||
public String getRedirectUri() { | ||
return redirectUri; | ||
} | ||
|
||
public String getAuthCode() { | ||
return authCode; | ||
} | ||
|
||
public JSONObject toJson() { | ||
try { | ||
JSONObject jsonObject = new JSONObject(); | ||
jsonObject.put(AuthConstants.AUTH_CODE, authCode); | ||
jsonObject.put(AuthConstants.CLIENT_ID, clientId); | ||
jsonObject.put(AuthConstants.REDIRECT_URI, redirectUri); | ||
jsonObject.put(AuthConstants.SESSION_ID, sessionId); | ||
return jsonObject; | ||
} catch (JSONException e) { | ||
return null; | ||
} | ||
} | ||
} |
95 changes: 95 additions & 0 deletions
95
...CompanionApp/app/src/main/java/com/amazon/alexa/avs/companion/DeviceProvisioningInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/** | ||
* Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* You may not use this file except in compliance with the License. A copy of the License is located the "LICENSE.txt" | ||
* file accompanying this source. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package com.amazon.alexa.avs.companion; | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class DeviceProvisioningInfo { | ||
private final String productId; | ||
private final String dsn; | ||
private final String sessionId; | ||
private final String codeChallenge; | ||
private final String codeChallengeMethod; | ||
|
||
public DeviceProvisioningInfo(String productId, String dsn, String sessionId, String codeChallenge, String codeChallengeMethod) { | ||
List<String> missingParameters = new ArrayList<String>(); | ||
if (StringUtils.isBlank(productId)) { | ||
missingParameters.add(AuthConstants.PRODUCT_ID); | ||
} | ||
|
||
if (StringUtils.isBlank(dsn)) { | ||
missingParameters.add(AuthConstants.DSN); | ||
} | ||
|
||
if (StringUtils.isBlank(sessionId)) { | ||
missingParameters.add(AuthConstants.SESSION_ID); | ||
} | ||
|
||
if (StringUtils.isBlank(codeChallenge)) { | ||
missingParameters.add(AuthConstants.CODE_CHALLENGE); | ||
} | ||
|
||
if (StringUtils.isBlank(codeChallengeMethod)) { | ||
missingParameters.add(AuthConstants.CODE_CHALLENGE_METHOD); | ||
} | ||
|
||
if (missingParameters.size() != 0) { | ||
throw new MissingParametersException(missingParameters); | ||
} | ||
|
||
this.productId = productId; | ||
this.dsn = dsn; | ||
this.sessionId = sessionId; | ||
this.codeChallenge = codeChallenge; | ||
this.codeChallengeMethod = codeChallengeMethod; | ||
} | ||
|
||
public String getProductId() { | ||
return productId; | ||
} | ||
|
||
public String getDsn() { | ||
return dsn; | ||
} | ||
|
||
public String getSessionId() { | ||
return sessionId; | ||
} | ||
|
||
public String getCodeChallenge() { | ||
return codeChallenge; | ||
} | ||
|
||
public String getCodeChallengeMethod() { | ||
return codeChallengeMethod; | ||
} | ||
|
||
public static class MissingParametersException extends IllegalArgumentException { | ||
private static final long serialVersionUID = 1L; | ||
private final List<String> missingParameters; | ||
|
||
public MissingParametersException(List<String> missingParameters) { | ||
super(); | ||
this.missingParameters = missingParameters; | ||
} | ||
|
||
@Override | ||
public String getMessage() { | ||
return "The following parameters were missing or empty strings: " | ||
+ StringUtils.join(missingParameters.toArray(), ", "); | ||
} | ||
|
||
public List<String> getMissingParameters() { | ||
return missingParameters; | ||
} | ||
} | ||
} |
Oops, something went wrong.