Commit 6148953c authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Improvements for permissions

parent 41eada01
......@@ -56,3 +56,18 @@ dependencies {
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:28.0.0'
}
// Grant permissions
task grantPermissions {
def adb = android.getAdbExecutable().toString()
"${adb} devices".execute().text.eachLine {
if(it.endsWith("device")){
def device = it.split()[0]
println "Granting permissions on devices ${device}"
"${adb} shell pm grant ${android.defaultConfig.applicationId} android.permission.RECORD_AUDIO".execute()
"${adb} shell pm grant ${android.defaultConfig.applicationId} android.permission.WRITE_EXTERNAL_STORAGE".execute()
"${adb} shell pm grant ${android.defaultConfig.applicationId} android.permission.CAMERA".execute()
"${adb} shell pm grant ${android.defaultConfig.applicationId} android.permission.WRITE_EXTERNAL_STORAGE".execute()
}
}
}
\ No newline at end of file
......@@ -20,6 +20,8 @@ public class LogsActivity extends Activity implements TesterLogListener {
mSuite = getIntent().getStringExtra("Suite");
mTest = getIntent().getStringExtra("Test");
Tester.getInstance().setContext(getApplicationContext());
}
@Override
......
......@@ -19,13 +19,20 @@ package org.linphone.tester;
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import android.Manifest;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import org.linphone.mediastream.Version;
import java.util.ArrayList;
public class SuitesActivity extends Activity implements View.OnClickListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
......@@ -58,4 +65,26 @@ public class SuitesActivity extends Activity implements View.OnClickListener {
intent.putExtra("Suite", (String)v.getTag());
startActivity(intent);
}
@Override
protected void onStart() {
super.onStart();
if (Version.sdkAboveOrEqual(Version.API23_MARSHMALLOW_60)) {
askForPermissions();
}
}
@TargetApi(23)
private void askForPermissions() {
ArrayList<String> permissionsList = new ArrayList<>();
permissionsList.add(Manifest.permission.RECORD_AUDIO);
permissionsList.add(Manifest.permission.CAMERA);
permissionsList.add(Manifest.permission.READ_PHONE_STATE);
permissionsList.add(Manifest.permission.WRITE_EXTERNAL_STORAGE);
if (permissionsList.size() > 0) {
String[] permissions = new String[permissionsList.size()];
permissions = permissionsList.toArray(permissions);
requestPermissions(permissions, 0);
}
}
}
......@@ -16,6 +16,8 @@ public class TestsActivity extends Activity implements View.OnClickListener {
setContentView(R.layout.activity_tests);
LinearLayout testsLayout = findViewById(R.id.testsLayout);
Tester.getInstance().setContext(getApplicationContext());
String suiteName = getIntent().getStringExtra("Suite");
if (suiteName.equals("All")) {
Intent intent = new Intent(this, LogsActivity.class);
......
......@@ -6,14 +6,16 @@
android:layout_height="match_parent"
tools:context=".SuitesActivity">
<LinearLayout
android:id="@+id/suitesLayout"
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/suitesLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"/>
</LinearLayout>
</ScrollView>
</android.support.constraint.ConstraintLayout>
\ No newline at end of file
......@@ -6,14 +6,16 @@
android:layout_height="match_parent"
tools:context=".TestsActivity">
<LinearLayout
android:id="@+id/testsLayout"
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/testsLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"/>
</LinearLayout>
</ScrollView>
</android.support.constraint.ConstraintLayout>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment