// Copyright 2021 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License 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.

syntax = "proto3";

package google.devtools.testing.v1;

import "google/api/annotations.proto";
import "google/devtools/testing/v1/test_execution.proto";
import "google/api/client.proto";

option go_package = "google.golang.org/genproto/googleapis/devtools/testing/v1;testing";
option java_multiple_files = true;
option java_outer_classname = "ApplicationDetailProto";
option java_package = "com.google.devtools.testing.v1";

// A service which parses input applications and returns details that can be
// useful in the context of testing.
service ApplicationDetailService {
  option (google.api.default_host) = "testing.googleapis.com";
  option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform";

  // Gets the details of an Android application APK.
  rpc GetApkDetails(GetApkDetailsRequest) returns (GetApkDetailsResponse) {
    option (google.api.http) = {
      post: "/v1/applicationDetailService/getApkDetails"
      body: "location"
    };
  }
}

// Android application details based on application manifest and apk archive
// contents.
message ApkDetail {
  ApkManifest apk_manifest = 1;
}

// An Android app manifest. See
// http://developer.android.com/guide/topics/manifest/manifest-intro.html
message ApkManifest {
  // Full Java-style package name for this application, e.g.
  // "com.example.foo".
  string package_name = 1;

  // Minimum API level required for the application to run.
  int32 min_sdk_version = 2;

  // Maximum API level on which the application is designed to run.
  int32 max_sdk_version = 3;

  // Specifies the API Level on which the application is designed to run.
  int32 target_sdk_version = 6;

  // User-readable name for the application.
  string application_label = 4;

  repeated IntentFilter intent_filters = 5;

  // Permissions declared to be used by the application
  repeated string uses_permission = 7;
}

// The <intent-filter> section of an <activity> tag.
// https://developer.android.com/guide/topics/manifest/intent-filter-element.html
message IntentFilter {
  // The android:name value of the <action> tag.
  repeated string action_names = 1;

  // The android:name value of the <category> tag.
  repeated string category_names = 2;

  // The android:mimeType value of the <data> tag.
  string mime_type = 3;
}

// A request to get the details of an Android application APK.
message GetApkDetailsRequest {
  // The APK to be parsed for details.
  FileReference location = 1;
}

// Response containing the details of the specified Android application APK.
message GetApkDetailsResponse {
  // Details of the Android APK.
  ApkDetail apk_detail = 1;
}
