Revert "Target SDK level 27 in AppRTCMobile."
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 <sakal@webrtc.org> > Reviewed-by: Anders Carlsson <andersc@webrtc.org> > 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 <sakal@webrtc.org> Commit-Queue: Sami Kalliomäki <sakal@webrtc.org> Cr-Commit-Position: refs/heads/master@{#21797}
This commit is contained in:
committed by
Commit Bot
parent
2036da9cd8
commit
f61b3ba65e
@ -8,7 +8,7 @@
|
|||||||
<uses-feature android:name="android.hardware.camera" />
|
<uses-feature android:name="android.hardware.camera" />
|
||||||
<uses-feature android:name="android.hardware.camera.autofocus" />
|
<uses-feature android:name="android.hardware.camera.autofocus" />
|
||||||
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
|
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
|
||||||
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="27" />
|
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="21" />
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.CAMERA" />
|
<uses-permission android:name="android.permission.CAMERA" />
|
||||||
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
|
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
|
||||||
@ -30,8 +30,7 @@
|
|||||||
|
|
||||||
<activity android:name="ConnectActivity"
|
<activity android:name="ConnectActivity"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:windowSoftInputMode="adjustPan"
|
android:windowSoftInputMode="adjustPan">
|
||||||
android:theme="@style/AppTheme">
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN"/>
|
<action android:name="android.intent.action.MAIN"/>
|
||||||
<category android:name="android.intent.category.LAUNCHER"/>
|
<category android:name="android.intent.category.LAUNCHER"/>
|
||||||
@ -47,8 +46,7 @@
|
|||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity android:name="SettingsActivity"
|
<activity android:name="SettingsActivity"
|
||||||
android:label="@string/settings_name"
|
android:label="@string/settings_name">
|
||||||
android:theme="@style/AppTheme">
|
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity android:name="CallActivity"
|
<activity android:name="CallActivity"
|
||||||
|
|||||||
@ -1,7 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<style name="AppTheme" parent="android:Theme.Holo" />
|
|
||||||
|
|
||||||
<style name="CallActivityTheme" parent="android:Theme.Black">
|
<style name="CallActivityTheme" parent="android:Theme.Black">
|
||||||
<item name="android:windowActionBar">false</item>
|
<item name="android:windowActionBar">false</item>
|
||||||
<item name="android:windowFullscreen">true</item>
|
<item name="android:windowFullscreen">true</item>
|
||||||
|
|||||||
@ -1,4 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<style name="AppTheme" parent="android:Theme.Material" />
|
<style name="AppRTCMobileActivityTheme" parent="android:Theme.Material">
|
||||||
|
<item name="android:windowActionBar">false</item>
|
||||||
|
<item name="android:windowFullscreen">true</item>
|
||||||
|
<item name="android:windowNoTitle">true</item>
|
||||||
|
</style>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@ -27,9 +27,6 @@
|
|||||||
<string name="connect_description">Connect to the room</string>
|
<string name="connect_description">Connect to the room</string>
|
||||||
<string name="add_favorite_description">Add favorite</string>
|
<string name="add_favorite_description">Add favorite</string>
|
||||||
<string name="format_description">%1$dx%2$d @ %3$d fps</string>
|
<string name="format_description">%1$dx%2$d @ %3$d fps</string>
|
||||||
<string name="missing_permissions_try_again">The application is missing permissions. It might not work correctly. Do you want to try again?</string>
|
|
||||||
<string name="yes">Yes</string>
|
|
||||||
<string name="no">No</string>
|
|
||||||
|
|
||||||
<!-- Settings strings. -->
|
<!-- Settings strings. -->
|
||||||
<string name="pref_room_key">room_preference</string>
|
<string name="pref_room_key">room_preference</string>
|
||||||
|
|||||||
@ -10,17 +10,12 @@
|
|||||||
|
|
||||||
package org.appspot.apprtc;
|
package org.appspot.apprtc;
|
||||||
|
|
||||||
import android.Manifest;
|
|
||||||
import android.annotation.TargetApi;
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.pm.PackageInfo;
|
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@ -49,7 +44,6 @@ import org.json.JSONException;
|
|||||||
public class ConnectActivity extends Activity {
|
public class ConnectActivity extends Activity {
|
||||||
private static final String TAG = "ConnectActivity";
|
private static final String TAG = "ConnectActivity";
|
||||||
private static final int CONNECTION_REQUEST = 1;
|
private static final int CONNECTION_REQUEST = 1;
|
||||||
private static final int PERMISSION_REQUEST = 2;
|
|
||||||
private static final int REMOVE_FAVORITE_INDEX = 0;
|
private static final int REMOVE_FAVORITE_INDEX = 0;
|
||||||
private static boolean commandLineRun = false;
|
private static boolean commandLineRun = false;
|
||||||
|
|
||||||
@ -110,7 +104,16 @@ public class ConnectActivity extends Activity {
|
|||||||
addFavoriteButton = findViewById(R.id.add_favorite_button);
|
addFavoriteButton = findViewById(R.id.add_favorite_button);
|
||||||
addFavoriteButton.setOnClickListener(addFavoriteListener);
|
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
|
@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<String> 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
|
* Get a value from the shared preference or from the intent, if it does not
|
||||||
* exist the default is used.
|
* exist the default is used.
|
||||||
|
|||||||
Reference in New Issue
Block a user