aboutsummaryrefslogtreecommitdiff
path: root/car-lib/src/android/car/content
diff options
context:
space:
mode:
authorKeun-young Park <keunyoung@google.com>2016-05-31 10:00:51 -0700
committerKeun-young Park <keunyoung@google.com>2016-06-27 17:41:02 -0700
commit4727da3796711ddd09d8c684fe50a341841284ee (patch)
tree103b7271d639c6aca8f8c55ac8df4411ee3afe93 /car-lib/src/android/car/content
parenta757f4b1f133f1b5161c32a2658dac2d3cb9c2b2 (diff)
downloadCar-4727da3796711ddd09d8c684fe50a341841284ee.tar.gz
implement activity blocking
- monitor activity launch and shut it down if car is not parked and if the app is not allowed. - Launch blocking activity for unsafe app. - Blocking activity stays up to timeout (3 secs) and finish itself if there is safe app behind. If safe app is not there, launch home. If home is not safe either. stay. - allow OEMs to give static whitelist as overlay. bug: 25267050 Change-Id: Id0bdae757fa98345069f2d83711b46447506f888
Diffstat (limited to 'car-lib/src/android/car/content')
-rw-r--r--car-lib/src/android/car/content/pm/CarPackageManager.java30
-rw-r--r--car-lib/src/android/car/content/pm/ICarPackageManager.aidl2
2 files changed, 31 insertions, 1 deletions
diff --git a/car-lib/src/android/car/content/pm/CarPackageManager.java b/car-lib/src/android/car/content/pm/CarPackageManager.java
index 1cdbfc7a27..ffef31e3e1 100644
--- a/car-lib/src/android/car/content/pm/CarPackageManager.java
+++ b/car-lib/src/android/car/content/pm/CarPackageManager.java
@@ -21,6 +21,7 @@ import android.annotation.SystemApi;
import android.car.CarApiUtil;
import android.car.CarManagerBase;
import android.car.CarNotConnectedException;
+import android.content.ComponentName;
import android.content.Context;
import android.os.IBinder;
import android.os.Looper;
@@ -122,13 +123,40 @@ public class CarPackageManager implements CarManagerBase {
}
/**
+ * Check if finishing Activity will lead into safe Activity (=allowed Activity) to be shown.
+ * This can be used by unsafe activity blocking Activity to check if finishing itself can
+ * lead into being launched again due to unsafe activity shown. Note that checking this does not
+ * guarantee that blocking will not be done as driving state can change after this call is made.
+ *
+ * @param activityName
+ * @return true if there is a safe Activity (or car is stopped) in the back of task stack
+ * so that finishing the Activity will not trigger another Activity blocking. If
+ * the given Activity is not in foreground, then it will return true as well as
+ * finishing the Activity will not make any difference.
+ *
+ * @hide
+ */
+ @SystemApi
+ public boolean isActivityBackedBySafeActivity(ComponentName activityName)
+ throws CarNotConnectedException {
+ try {
+ return mService.isActivityBackedBySafeActivity(activityName);
+ } catch (IllegalStateException e) {
+ CarApiUtil.checkCarNotConnectedExceptionFromCarService(e);
+ } catch (RemoteException e) {
+ //ignore as CarApi will handle disconnection anyway.
+ }
+ return true;
+ }
+
+ /**
* Check if given activity is allowed while driving.
* @param packageName
* @param className
* @return
*/
public boolean isActivityAllowedWhileDriving(String packageName, String className)
- throws CarNotConnectedException{
+ throws CarNotConnectedException {
try {
return mService.isActivityAllowedWhileDriving(packageName, className);
} catch (IllegalStateException e) {
diff --git a/car-lib/src/android/car/content/pm/ICarPackageManager.aidl b/car-lib/src/android/car/content/pm/ICarPackageManager.aidl
index d451187f2a..306db6567c 100644
--- a/car-lib/src/android/car/content/pm/ICarPackageManager.aidl
+++ b/car-lib/src/android/car/content/pm/ICarPackageManager.aidl
@@ -17,10 +17,12 @@
package android.car.content.pm;
import android.car.content.pm.CarAppBlockingPolicy;
+import android.content.ComponentName;
/** @hide */
interface ICarPackageManager {
void setAppBlockingPolicy(in String packageName, in CarAppBlockingPolicy policy, int flags) = 0;
boolean isActivityAllowedWhileDriving(in String packageName, in String className) = 1;
boolean isServiceAllowedWhileDriving(in String packageName, in String className) = 2;
+ boolean isActivityBackedBySafeActivity(in ComponentName activityName) = 3;
}