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

Add get system webview Responder #15

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/src/main/java/jp/co/cyberagent/stf/Service.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import jp.co.cyberagent.stf.query.GetRingerModeResponder;
import jp.co.cyberagent.stf.query.GetSdStatusResponder;
import jp.co.cyberagent.stf.query.GetVersionResponder;
import jp.co.cyberagent.stf.query.GetWebviewVersionResponder;
import jp.co.cyberagent.stf.query.GetWifiStatusResponder;
import jp.co.cyberagent.stf.query.SetClipboardResponder;
import jp.co.cyberagent.stf.query.SetKeyguardStateResponder;
Expand Down Expand Up @@ -303,6 +304,9 @@ public void run() {
router.register(Wire.MessageType.GET_VERSION,
new GetVersionResponder(getBaseContext()));

router.register(Wire.MessageType.GET_WEBVIEW_VERSION,
new GetWebviewVersionResponder(getBaseContext()));

router.register(Wire.MessageType.GET_WIFI_STATUS,
new GetWifiStatusResponder(getBaseContext()));

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package jp.co.cyberagent.stf.query;

import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;

import com.google.protobuf.GeneratedMessageLite;

import java.util.ArrayList;
import java.util.List;

import jp.co.cyberagent.stf.BuildConfig;
import jp.co.cyberagent.stf.IdentityActivity;
import jp.co.cyberagent.stf.proto.Wire;

import static android.content.ContentValues.TAG;

public class GetWebviewVersionResponder extends AbstractResponder {

public GetWebviewVersionResponder(Context context) {
super(context);
}

@Override
public GeneratedMessageLite respond(Wire.Envelope envelope) {
String webViewVersion = "0.0.0";
PackageManager packageManager = context.getPackageManager();
List<PackageInfo> packageInfoList = packageManager.getInstalledPackages(0);

for (int i = 0; i < packageInfoList.size(); i++) {
PackageInfo pak = packageInfoList.get(i);
String applicationname = pak.applicationInfo.loadLabel(packageManager).toString();
if(applicationname.equals("Android System WebView")) {
webViewVersion = pak.versionName;
break;
}
}

return Wire.Envelope.newBuilder()
.setId(envelope.getId())
.setType(Wire.MessageType.GET_WEBVIEW_VERSION)
.setMessage(Wire.GetWebviewVersionResponse.newBuilder()
.setSuccess(true).setVersion(webViewVersion)
.build()
.toByteString())
.build();
}

@Override
public void cleanup() {
// No-op
}
}
10 changes: 10 additions & 0 deletions app/src/main/proto/wire.proto
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ enum MessageType {
SET_WAKE_LOCK = 11;
SET_WIFI_ENABLED = 22;
SET_MASTER_MUTE = 28;
GET_WEBVIEW_VERSION = 29;
EVENT_AIRPLANE_MODE = 13;
EVENT_BATTERY = 14;
EVENT_CONNECTIVITY = 15;
Expand Down Expand Up @@ -262,6 +263,15 @@ message SetMasterMuteResponse {
required bool success = 1;
}

//get system webview
message GetWebviewVersionRequest {
}

message GetWebviewVersionResponse {
required bool success = 1;
optional string version = 2;
}

// Agent

enum KeyEvent {
Expand Down
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

buildscript {
repositories {

mavenCentral()
jcenter()
}
Expand Down