From f61b3ba65e3d868267ea141c88b59127163e4766 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20Kalliom=C3=A4ki?= Date: Tue, 30 Jan 2018 08:34:15 +0000 Subject: [PATCH] Revert "Target SDK level 27 in AppRTCMobile." MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit af4f1b41277ebdf0d7386cbd2903abc709cbc183. Reason for revert: Causes timeouts with loopback tests. Reverting and investigating. Original change's description: > Target SDK level 27 in AppRTCMobile. > > Implements the dynamic permission model required by the newer SDK and > changes the theme. > > Bug: webrtc:8803 > Change-Id: I3ea23a25b27f196fcffd018c7cdd2ff6255b62d9 > Reviewed-on: https://webrtc-review.googlesource.com/44400 > Commit-Queue: Sami Kalliomäki > Reviewed-by: Anders Carlsson > Cr-Commit-Position: refs/heads/master@{#21788} TBR=sakal@webrtc.org,andersc@webrtc.org Change-Id: I4074c48fc7c7466765793244a5a7f60029bc7937 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:8803 Reviewed-on: https://webrtc-review.googlesource.com/45980 Reviewed-by: Sami Kalliomäki Commit-Queue: Sami Kalliomäki Cr-Commit-Position: refs/heads/master@{#21797} --- examples/androidapp/AndroidManifest.xml | 8 +- examples/androidapp/res/values-v17/styles.xml | 2 - examples/androidapp/res/values-v21/styles.xml | 6 +- examples/androidapp/res/values/strings.xml | 3 - .../org/appspot/apprtc/ConnectActivity.java | 112 ++---------------- 5 files changed, 18 insertions(+), 113 deletions(-) diff --git a/examples/androidapp/AndroidManifest.xml b/examples/androidapp/AndroidManifest.xml index 6edb0c1d02..d6e0ff0417 100644 --- a/examples/androidapp/AndroidManifest.xml +++ b/examples/androidapp/AndroidManifest.xml @@ -8,7 +8,7 @@ - + @@ -30,8 +30,7 @@ + android:windowSoftInputMode="adjustPan"> @@ -47,8 +46,7 @@ + android:label="@string/settings_name"> - diff --git a/examples/androidapp/res/values/strings.xml b/examples/androidapp/res/values/strings.xml index 95d1b68c62..231475f587 100644 --- a/examples/androidapp/res/values/strings.xml +++ b/examples/androidapp/res/values/strings.xml @@ -27,9 +27,6 @@ Connect to the room Add favorite %1$dx%2$d @ %3$d fps - The application is missing permissions. It might not work correctly. Do you want to try again? - Yes - No room_preference diff --git a/examples/androidapp/src/org/appspot/apprtc/ConnectActivity.java b/examples/androidapp/src/org/appspot/apprtc/ConnectActivity.java index 4e5df6e6fb..28add759c0 100644 --- a/examples/androidapp/src/org/appspot/apprtc/ConnectActivity.java +++ b/examples/androidapp/src/org/appspot/apprtc/ConnectActivity.java @@ -10,17 +10,12 @@ package org.appspot.apprtc; -import android.Manifest; -import android.annotation.TargetApi; import android.app.Activity; import android.app.AlertDialog; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; -import android.content.pm.PackageInfo; -import android.content.pm.PackageManager; import android.net.Uri; -import android.os.Build; import android.os.Bundle; import android.preference.PreferenceManager; import android.util.Log; @@ -49,7 +44,6 @@ import org.json.JSONException; public class ConnectActivity extends Activity { private static final String TAG = "ConnectActivity"; private static final int CONNECTION_REQUEST = 1; - private static final int PERMISSION_REQUEST = 2; private static final int REMOVE_FAVORITE_INDEX = 0; private static boolean commandLineRun = false; @@ -110,7 +104,16 @@ public class ConnectActivity extends Activity { addFavoriteButton = findViewById(R.id.add_favorite_button); addFavoriteButton.setOnClickListener(addFavoriteListener); - requestPermissions(); + // If an implicit VIEW intent is launching the app, go directly to that URL. + final Intent intent = getIntent(); + if ("android.intent.action.VIEW".equals(intent.getAction()) && !commandLineRun) { + boolean loopback = intent.getBooleanExtra(CallActivity.EXTRA_LOOPBACK, false); + int runTimeMs = intent.getIntExtra(CallActivity.EXTRA_RUNTIME, 0); + boolean useValuesFromIntent = + intent.getBooleanExtra(CallActivity.EXTRA_USE_VALUES_FROM_INTENT, false); + String room = sharedPref.getString(keyprefRoom, ""); + connectToRoom(room, true, loopback, useValuesFromIntent, runTimeMs); + } } @Override @@ -207,101 +210,6 @@ public class ConnectActivity extends Activity { } } - @Override - public void onRequestPermissionsResult( - int requestCode, String[] permissions, int[] grantResults) { - if (requestCode == PERMISSION_REQUEST) { - String[] missingPermissions = getMissingPermissions(); - if (missingPermissions.length != 0) { - // User didn't grant all the permissions. Warn that the application might not work - // correctly. - new AlertDialog.Builder(this) - .setMessage(R.string.missing_permissions_try_again) - .setPositiveButton(R.string.yes, - (dialog, id) -> { - // User wants to try giving the permissions again. - dialog.cancel(); - requestPermissions(); - }) - .setNegativeButton(R.string.no, - (dialog, id) -> { - // User doesn't want to give the permissions. - dialog.cancel(); - onPermissionsGranted(); - }) - .show(); - } else { - // All permissions granted. - onPermissionsGranted(); - } - } - } - - private void onPermissionsGranted() { - // If an implicit VIEW intent is launching the app, go directly to that URL. - final Intent intent = getIntent(); - if ("android.intent.action.VIEW".equals(intent.getAction()) && !commandLineRun) { - boolean loopback = intent.getBooleanExtra(CallActivity.EXTRA_LOOPBACK, false); - int runTimeMs = intent.getIntExtra(CallActivity.EXTRA_RUNTIME, 0); - boolean useValuesFromIntent = - intent.getBooleanExtra(CallActivity.EXTRA_USE_VALUES_FROM_INTENT, false); - String room = sharedPref.getString(keyprefRoom, ""); - connectToRoom(room, true, loopback, useValuesFromIntent, runTimeMs); - } - } - - @TargetApi(Build.VERSION_CODES.M) - private void requestPermissions() { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { - // Dynamic permissions are not required before Android M. - onPermissionsGranted(); - return; - } - - String[] missingPermissions = getMissingPermissions(); - if (missingPermissions.length != 0) { - requestPermissions(missingPermissions, PERMISSION_REQUEST); - } else { - onPermissionsGranted(); - } - } - - @TargetApi(Build.VERSION_CODES.M) - private String[] getMissingPermissions() { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { - return new String[0]; - } - - PackageInfo info; - try { - info = getPackageManager().getPackageInfo(getPackageName(), PackageManager.GET_PERMISSIONS); - } catch (PackageManager.NameNotFoundException e) { - Log.w(TAG, "Failed to retrieve permissions."); - return new String[0]; - } - - if (info.requestedPermissions == null) { - Log.w(TAG, "No requested permissions."); - return new String[0]; - } - - ArrayList missingPermissions = new ArrayList<>(); - for (int i = 0; i < info.requestedPermissions.length; i++) { - if (Manifest.permission.CAPTURE_VIDEO_OUTPUT.equals(info.requestedPermissions[i])) { - // Screen recording permission has to be asked every time a session is started. (See - // CallActivity#startScreenCapture.) - continue; - } - - if ((info.requestedPermissionsFlags[i] & PackageInfo.REQUESTED_PERMISSION_GRANTED) == 0) { - missingPermissions.add(info.requestedPermissions[i]); - } - } - Log.d(TAG, "Missing permissions: " + missingPermissions); - - return missingPermissions.toArray(new String[missingPermissions.size()]); - } - /** * Get a value from the shared preference or from the intent, if it does not * exist the default is used.