Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to androidx packages #105

Merged
merged 2 commits into from Jan 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 11 additions & 11 deletions build.gradle
Expand Up @@ -6,14 +6,14 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.android.tools.build:gradle:3.2.1'

// NOTE: Do not place your application dependencies here.
}
}

plugins {
id "com.github.sherter.google-java-format" version "0.6"
id "com.github.sherter.google-java-format" version "0.8"
}

repositories {
Expand All @@ -32,7 +32,7 @@ allprojects {
}

android {
compileSdkVersion 24
compileSdkVersion 28

defaultConfig {
applicationId "com.google.android.mobly.snippet.bundled"
Expand All @@ -54,7 +54,7 @@ android {
warningsAsErrors true
disable 'HardwareIds','MissingApplicationIcon','GoogleAppIndexingWarning','InvalidPackage','OldTargetApi'
}
buildToolsVersion '27.0.3'
buildToolsVersion '28.0.3'
}

// Produces a jar of source files. Needed for compliance reasons.
Expand All @@ -74,15 +74,15 @@ artifacts {
}

dependencies {
implementation 'com.android.support.test:runner:1.0.2'
implementation 'androidx.test:runner:1.1.1'
implementation 'com.google.android.mobly:mobly-snippet-lib:1.2.0'
implementation 'com.google.code.gson:gson:2.8.4'
implementation 'com.google.guava:guava:24.1.1-android'
implementation 'com.google.errorprone:error_prone_annotations:2.3.1'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.google.guava:guava:27.0.1-android'
implementation 'com.google.errorprone:error_prone_annotations:2.3.2'

testImplementation 'com.google.errorprone:error_prone_annotations:2.3.1'
testImplementation 'com.google.guava:guava:24.1.1-android'
testImplementation 'com.google.truth:truth:0.40'
testImplementation 'com.google.errorprone:error_prone_annotations:2.3.2'
testImplementation 'com.google.guava:guava:27.0.1-android'
testImplementation 'com.google.truth:truth:0.42'
testImplementation 'junit:junit:4.12'
}

Expand Down
2 changes: 2 additions & 0 deletions gradle.properties
@@ -1,2 +1,4 @@
org.gradle.jvmargs=-Xmx1536M
android.enableD8.desugaring=true
android.useAndroidX=true
android.enableJetifier=true
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
#Mon May 21 15:55:23 PDT 2018
#Thu Jan 10 15:04:39 PST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
2 changes: 1 addition & 1 deletion src/main/AndroidManifest.xml
Expand Up @@ -28,7 +28,7 @@
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
<uses-permission android:name="android.permission.SEND_SMS" />
<application android:allowBackup="false"
android:name="android.support.multidex.MultiDexApplication">
android:name="androidx.multidex.MultiDexApplication">
<meta-data
android:name="mobly-snippets"
android:value="com.google.android.mobly.snippet.bundled.AccountSnippet,
Expand Down
Expand Up @@ -24,7 +24,7 @@
import android.content.Context;
import android.content.SyncAdapterType;
import android.os.Bundle;
import android.support.test.InstrumentationRegistry;
import androidx.test.platform.app.InstrumentationRegistry;
import com.google.android.mobly.snippet.Snippet;
import com.google.android.mobly.snippet.rpc.Rpc;
import com.google.android.mobly.snippet.util.Log;
Expand Down Expand Up @@ -68,7 +68,7 @@ public AccountSnippetException(String msg) {
private final ReentrantReadWriteLock mLock;

public AccountSnippet() {
Context context = InstrumentationRegistry.getContext();
Context context = InstrumentationRegistry.getInstrumentation().getContext();
mAccountManager = AccountManager.get(context);
mSyncStatusObserverHandles = new LinkedList<>();
mSyncWhitelist = new HashMap<>();
Expand All @@ -86,8 +86,8 @@ public AccountSnippet() {
* @param password Password of the account to add.
*/
@Rpc(
description = "Add a Google (GMail) account to the device, with account data sync disabled."
)
description =
"Add a Google (GMail) account to the device, with account data sync disabled.")
public void addAccount(String username, String password)
throws AccountSnippetException, AccountsException, IOException {
// Check for existing account. If we try to re-add an existing account, Android throws an
Expand Down
Expand Up @@ -18,7 +18,7 @@

import android.content.Context;
import android.media.AudioManager;
import android.support.test.InstrumentationRegistry;
import androidx.test.platform.app.InstrumentationRegistry;
import com.google.android.mobly.snippet.Snippet;
import com.google.android.mobly.snippet.rpc.Rpc;
import java.lang.reflect.Method;
Expand All @@ -29,7 +29,7 @@ public class AudioSnippet implements Snippet {
private final AudioManager mAudioManager;

public AudioSnippet() {
Context context = InstrumentationRegistry.getContext();
Context context = InstrumentationRegistry.getInstrumentation().getContext();
mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
}

Expand All @@ -44,7 +44,7 @@ public boolean isMicrophoneMute() {
}

@Rpc(description = "Gets the music stream volume.")
public int getMusicVolume() {
public Integer getMusicVolume() {
return mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
}

Expand All @@ -54,17 +54,16 @@ public int getMusicMaxVolume() {
}

@Rpc(
description =
"Sets the music stream volume. The minimum value is 0. Use 'getMusicMaxVolume'"
+ " to determine the maximum."
)
description =
"Sets the music stream volume. The minimum value is 0. Use 'getMusicMaxVolume'"
+ " to determine the maximum.")
public void setMusicVolume(Integer value) {
mAudioManager.setStreamVolume(
AudioManager.STREAM_MUSIC, value, 0 /* flags, 0 = no flags */);
}

@Rpc(description = "Gets the ringer volume.")
public int getRingVolume() {
public Integer getRingVolume() {
return mAudioManager.getStreamVolume(AudioManager.STREAM_RING);
}

Expand All @@ -74,16 +73,15 @@ public int getRingMaxVolume() {
}

@Rpc(
description =
"Sets the ringer stream volume. The minimum value is 0. Use 'getRingMaxVolume'"
+ " to determine the maximum."
)
description =
"Sets the ringer stream volume. The minimum value is 0. Use 'getRingMaxVolume'"
+ " to determine the maximum.")
public void setRingVolume(Integer value) {
mAudioManager.setStreamVolume(AudioManager.STREAM_RING, value, 0 /* flags, 0 = no flags */);
}

@Rpc(description = "Gets the voice call volume.")
public int getVoiceCallVolume() {
public Integer getVoiceCallVolume() {
return mAudioManager.getStreamVolume(AudioManager.STREAM_VOICE_CALL);
}

Expand All @@ -93,13 +91,12 @@ public int getVoiceCallMaxVolume() {
}

@Rpc(
description =
"Sets the voice call stream volume. The minimum value is 0. Use"
+ " 'getVoiceCallMaxVolume' to determine the maximum."
)
description =
"Sets the voice call stream volume. The minimum value is 0. Use"
+ " 'getVoiceCallMaxVolume' to determine the maximum.")
public void setVoiceCallVolume(Integer value) {
mAudioManager.setStreamVolume(AudioManager.STREAM_VOICE_CALL,
value, 0 /* flags, 0 = no flags */);
mAudioManager.setStreamVolume(
AudioManager.STREAM_VOICE_CALL, value, 0 /* flags, 0 = no flags */);
}

@Rpc(description = "Silences all audio streams.")
Expand All @@ -115,10 +112,9 @@ public void muteAll() throws Exception {
}

@Rpc(
description =
"Puts the ringer volume at the lowest setting, but does not set it to "
+ "DO NOT DISTURB; the phone will vibrate when receiving a call."
)
description =
"Puts the ringer volume at the lowest setting, but does not set it to "
+ "DO NOT DISTURB; the phone will vibrate when receiving a call.")
public void muteRing() {
setRingVolume(0);
}
Expand Down
Expand Up @@ -19,7 +19,7 @@
import android.content.Context;
import android.net.Uri;
import android.os.ParcelFileDescriptor;
import android.support.test.InstrumentationRegistry;
import androidx.test.platform.app.InstrumentationRegistry;
import com.google.android.mobly.snippet.Snippet;
import com.google.android.mobly.snippet.bundled.utils.Utils;
import com.google.android.mobly.snippet.rpc.Rpc;
Expand All @@ -34,7 +34,7 @@ public class FileSnippet implements Snippet {
private final Context mContext;

public FileSnippet() {
mContext = InstrumentationRegistry.getContext();
mContext = InstrumentationRegistry.getInstrumentation().getContext();
}

private static class FileSnippetException extends Exception {
Expand Down
Expand Up @@ -23,7 +23,7 @@
import android.content.IntentFilter;
import android.net.Uri;
import android.os.Environment;
import android.support.test.InstrumentationRegistry;
import androidx.test.platform.app.InstrumentationRegistry;
import com.google.android.mobly.snippet.Snippet;
import com.google.android.mobly.snippet.bundled.utils.Utils;
import com.google.android.mobly.snippet.rpc.Rpc;
Expand All @@ -44,7 +44,7 @@ public class NetworkingSnippet implements Snippet {
private volatile long mReqid = 0;

public NetworkingSnippet() {
mContext = InstrumentationRegistry.getContext();
mContext = InstrumentationRegistry.getInstrumentation().getContext();
mDownloadManager = (DownloadManager) mContext.getSystemService(Context.DOWNLOAD_SERVICE);
}

Expand Down Expand Up @@ -78,10 +78,9 @@ public boolean networkIsTcpConnectable(String host, int port) {
}

@Rpc(
description =
"Download a file using HTTP. Return content Uri (file remains on device). "
+ "The Uri should be treated as an opaque handle for further operations."
)
description =
"Download a file using HTTP. Return content Uri (file remains on device). "
+ "The Uri should be treated as an opaque handle for further operations.")
public String networkHttpDownload(String url)
throws IllegalArgumentException, NetworkingSnippetException {

Expand Down
Expand Up @@ -16,8 +16,8 @@

package com.google.android.mobly.snippet.bundled;

import android.support.test.InstrumentationRegistry;
import android.widget.Toast;
import androidx.test.platform.app.InstrumentationRegistry;
import com.google.android.mobly.snippet.Snippet;
import com.google.android.mobly.snippet.rpc.Rpc;
import com.google.android.mobly.snippet.rpc.RunOnUiThread;
Expand All @@ -28,7 +28,11 @@ public class NotificationSnippet implements Snippet {
@RunOnUiThread
@Rpc(description = "Make a toast on screen.")
public void makeToast(String message) {
Toast.makeText(InstrumentationRegistry.getContext(), message, Toast.LENGTH_LONG).show();
Toast.makeText(
InstrumentationRegistry.getInstrumentation().getContext(),
message,
Toast.LENGTH_LONG)
.show();
}

@Override
Expand Down
Expand Up @@ -26,9 +26,9 @@
import android.os.Build;
import android.os.Bundle;
import android.provider.Telephony.Sms.Intents;
import android.support.test.InstrumentationRegistry;
import android.telephony.SmsManager;
import android.telephony.SmsMessage;
import androidx.test.platform.app.InstrumentationRegistry;
import com.google.android.mobly.snippet.Snippet;
import com.google.android.mobly.snippet.bundled.utils.Utils;
import com.google.android.mobly.snippet.event.EventCache;
Expand Down Expand Up @@ -62,7 +62,7 @@ private static class SmsSnippetException extends Exception {
private final SmsManager mSmsManager;

public SmsSnippet() {
this.mContext = InstrumentationRegistry.getContext();
this.mContext = InstrumentationRegistry.getInstrumentation().getContext();
this.mSmsManager = SmsManager.getDefault();
}

Expand Down
Expand Up @@ -17,8 +17,8 @@
package com.google.android.mobly.snippet.bundled;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.telephony.TelephonyManager;
import androidx.test.platform.app.InstrumentationRegistry;
import com.google.android.mobly.snippet.Snippet;
import com.google.android.mobly.snippet.rpc.Rpc;

Expand All @@ -28,7 +28,7 @@ public class TelephonySnippet implements Snippet {
private final TelephonyManager mTelephonyManager;

public TelephonySnippet() {
Context context = InstrumentationRegistry.getContext();
Context context = InstrumentationRegistry.getInstrumentation().getContext();
mTelephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
}

Expand All @@ -43,10 +43,9 @@ public String getSubscriberId() {
}

@Rpc(
description =
"Gets the call state for the default subscription. Call state values are"
+ "0: IDLE, 1: RINGING, 2: OFFHOOK"
)
description =
"Gets the call state for the default subscription. Call state values are"
+ "0: IDLE, 1: RINGING, 2: OFFHOOK")
public int getTelephonyCallState() {
return mTelephonyManager.getCallState();
}
Expand Down