Bug 309, ArrayKK-JXIT-101 / MP Global Android / Need to rollback scheme to android:scheme="motionproplus"
Review Request #48 — Created Oct. 11, 2023 and submitted — Latest diff uploaded
| Information | |
|---|---|
| yunting | |
| AG_Client | |
| Reviewers | |
| wugene | |
fix Bug 309 and Bug 278
fix Bug 309 and Bug 278
Updates
For Android 13 (API level 33), notification runtime permission has been added. After MotionPro Global is started, it will ask your permission to push notifications. (278)
Resolved Issues
Solved the issue that MotionPro Global could not be started from browsers. Now you can start MotionPro Global on a web page. After it is started, it will connect to the VPN automatically. (309)• motionpro_android\app\build.gradle
(1) modify:
implementation 'androidx.appcompat:appcompat:1.5.1' -> implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.annotation:annotation:1.6.0' -> implementation 'androidx.annotation:annotation:1.7.0'• motionpro_android\app\src\main\AndroidManifest.xml
(1) add:
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>(2) revert:
<intent-filter>
<data android:scheme="motionproplus"/><action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /></intent-filter>
• motionpro_android\app\src\main\java\net\arraynetworks\mobilenow\portal\AppIntentHandler.java
(1) modify:
/String scheme = data.getScheme();
if (!"motionproplus".equals(scheme)) {
return;
}/String path = data.getPath();
if(path != null) {
if (!path.startsWith("/motionproglobal"))
return;
}
to
/
String scheme = data.getScheme();
if (!"motionproplus".equals(scheme)) {
return;
}//
String path = data.getPath();
if(path != null) {
if (!path.startsWith("/motionproglobal"))
return;
}/String scheme = data.getScheme();
String path = data.getPath();if(path != null) {
if (!path.startsWith("/motionproglobal")) {
if (!"motionproplus".equals(scheme))
return;
}
}• motionpro_android\app\src\main\java\net\arraynetworks\mobilenow\portal\IntentHandlerActivity.java
(1) add:
private void startMotionPro() {
......
startPortalistActivity();
}• motionpro_android\app\src\main\java\net\arraynetworks\mobilenow\util\RequestPermissions.java
(1) add:
public final static int MY_PERMISSIONS_REQUEST_NOTIFICATIONS = 4;@RequiresApi(api = Build.VERSION_CODES.TIRAMISU)
private boolean has_POST_NOTIFICATION() {
return ContextCompat.checkSelfPermission(mActivity,
Manifest.permission.POST_NOTIFICATIONS) == PackageManager.PERMISSION_GRANTED;
}public boolean allPermissionsGranted() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
return has_READ_PHONE_STATE() && has_WRITE_EXTERNAL_STORAGE() && has_POST_NOTIFICATION();
} else {
return has_READ_PHONE_STATE() && has_WRITE_EXTERNAL_STORAGE();
}
}public void onRequestPermissionsResult(int requestCode,
......
case MY_PERMISSIONS_REQUEST_NOTIFICATIONS: {
if (granted) {
if (callback != null) callback.result("", CommonConstant.COMMON_CONSTANT_SUCCESS);
} else {
if (callback != null) callback.result("", CommonConstant.COMMON_CONSTANT_ERROR);
DialogUtils.getInstence().oneBtnDialog(mActivity,mActivity.getString(R.string.privacy_agreement_tip_title),
mActivity.getString(R.string.permission_notification),mActivity.getString(R.string.ok),null);
}
break;
}
}
}(2) modify:
public boolean requestPermissions() {
if ((!has_READ_PHONE_STATE()) || (!has_WRITE_EXTERNAL_STORAGE())) {
ActivityCompat.requestPermissions(mActivity, new String[] {
Manifest.permission.READ_PHONE_STATE,
Manifest.permission.WRITE_EXTERNAL_STORAGE },
MY_PERMISSIONS_REQUEST_PERMISSIONS);
return false;
}
return true;
}
to
public boolean requestPermissions() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
if ((!has_READ_PHONE_STATE()) || (!has_WRITE_EXTERNAL_STORAGE()) || (!has_POST_NOTIFICATION())) {
ActivityCompat.requestPermissions(mActivity, new String[] {
Manifest.permission.READ_PHONE_STATE,
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.POST_NOTIFICATIONS},
MY_PERMISSIONS_REQUEST_PERMISSIONS);
return false;
}
} else {
if ((!has_READ_PHONE_STATE()) || (!has_WRITE_EXTERNAL_STORAGE())) {
ActivityCompat.requestPermissions(mActivity, new String[] {
Manifest.permission.READ_PHONE_STATE,
Manifest.permission.WRITE_EXTERNAL_STORAGE },
MY_PERMISSIONS_REQUEST_PERMISSIONS);
return false;
}
}
return true;
}• motionpro_android\app\src\main\res\values\strings.xml
(1) add:
<string name="permission_notification">The app will not work properly if the permission is denied. You should manually enable the permissions "Post Notifications" \n\nvia Settings->Application&Notifications->Permission Manager->MotionPro.</string>• motionpro_android\app\src\main\res\values-zh\strings.xml
(1) add:
<string name="permission_notification">拒绝此权限后应用无法正常工作。\n\n请通过设置->应用和通知->权限管理->MotionPro手动开启 “通知” 权限。</string>
